@livechat/developer-studio-api 2.3.54 → 2.3.56

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 CHANGED
@@ -91,7 +91,7 @@ __export(src_exports, {
91
91
  getPlatformDpsAdminClientAuthorization: () => getPlatformDpsAdminClientAuthorization,
92
92
  getPlatformDpsClientAuthorization: () => getPlatformDpsClientAuthorization,
93
93
  getPlatformDpsClientConfig: () => getPlatformDpsClientConfig,
94
- getRegion: () => getRegion2,
94
+ getRegion: () => getRegion,
95
95
  getSentryClientAuthorization: () => getSentryClientAuthorization,
96
96
  getSentryClientConfig: () => getSentryClientConfig,
97
97
  getTextClientAuthorization: () => getTextClientAuthorization,
@@ -2464,444 +2464,52 @@ var vercelApi = {
2464
2464
  };
2465
2465
 
2466
2466
  // src/apis/integrations/neon/api.ts
2467
- var import_axios16 = __toESM(require("axios"));
2468
-
2469
- // src/apis/integrations/neon/instance.ts
2470
- var import_axios10 = __toESM(require("axios"));
2471
- var neonClientInstance = import_axios10.default.create({
2472
- baseURL: "https://console.neon.tech/api/v2/"
2473
- });
2474
- neonClientInstance.interceptors.response.use(
2475
- (r) => r,
2476
- (error) => {
2477
- var _a;
2478
- if (import_axios10.default.isAxiosError(error)) {
2479
- if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
2480
- throw new UnauthorizeApiError("neon");
2481
- }
2482
- }
2483
- throw error;
2484
- }
2485
- );
2486
- function getNeonClientAuthorization(req) {
2487
- return {
2488
- token: req.headers["neon-token"]
2489
- };
2490
- }
2491
- function getNeonClientConfig(options = {}) {
2492
- const currentHeaders = neonClientInstance.defaults.headers;
2493
- const defaultAuthorization = currentHeaders.Authorization;
2494
- const headers = {
2495
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2496
- };
2497
- if (options.ensureAuthorizationToken && !headers.authorization) {
2498
- throw new UnauthorizeApiError("neon");
2499
- }
2500
- return {
2501
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2502
- };
2503
- }
2504
- function initNeonClientInstance(token) {
2505
- if (token) {
2506
- updateNeonClientInstance(token);
2507
- }
2508
- }
2509
- function updateNeonClientInstance(token) {
2510
- const headers = neonClientInstance.defaults.headers;
2511
- if (token) {
2512
- headers.Authorization = `${token}`;
2513
- } else {
2514
- delete headers.Authorization;
2515
- }
2516
- }
2517
-
2518
- // src/apis/platform/accounts/instance.ts
2519
- var import_axios11 = __toESM(require("axios"));
2520
- var platformAccountsClientInstance = import_axios11.default.create({
2521
- baseURL: "https://accounts.labs.livechatinc.com"
2522
- });
2523
- function getPlatformAccountsClientAuthorization(req) {
2524
- return {
2525
- token: req.headers["platform-accounts-token"]
2526
- };
2527
- }
2528
- function getPlatformAccountsClientConfig(options = {}) {
2529
- const defaultAuthorization = platformAccountsClientInstance.defaults.headers["Authorization"];
2530
- const headers = {
2531
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2532
- };
2533
- return {
2534
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2535
- };
2536
- }
2537
- function initPlatformAccountsClientInstance(baseUrl, token) {
2538
- if (baseUrl) {
2539
- platformAccountsClientInstance.interceptors.request.use(
2540
- (config) => __async(this, null, function* () {
2541
- config.baseURL = baseUrl;
2542
- return config;
2543
- }),
2544
- (error) => Promise.reject(error)
2545
- );
2546
- }
2547
- if (token) {
2548
- platformAccountsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
2549
- } else {
2550
- delete platformAccountsClientInstance.defaults.headers["Authorization"];
2551
- }
2552
- }
2553
-
2554
- // src/apis/platform/billing/instance.ts
2555
- var import_axios12 = __toESM(require("axios"));
2556
- var platformBillingClientInstance = import_axios12.default.create({
2557
- baseURL: "https://billing.labs.livechatinc.com"
2558
- });
2559
- function getPlatformBillingClientAuthorization(req) {
2560
- return {
2561
- token: req.headers["platform-token"]
2562
- };
2563
- }
2564
- function getPlatformBillingClientConfig(options = {}) {
2565
- const defaultAuthorization = platformBillingClientInstance.defaults.headers.Authorization;
2566
- const headers = {
2567
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2568
- };
2569
- return {
2570
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2571
- };
2572
- }
2573
- function initPlatformBillingClientInstance(baseUrl, token) {
2574
- if (baseUrl) {
2575
- platformBillingClientInstance.interceptors.request.use(
2576
- (config) => __async(this, null, function* () {
2577
- config.baseURL = baseUrl;
2578
- return config;
2579
- }),
2580
- (error) => Promise.reject(error)
2581
- );
2582
- }
2583
- if (token) {
2584
- platformBillingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
2585
- } else {
2586
- delete platformBillingClientInstance.defaults.headers.Authorization;
2587
- }
2588
- }
2589
-
2590
- // src/apis/platform/adapter/instance.ts
2591
- var import_axios13 = __toESM(require("axios"));
2592
- var REGION = {
2593
- FRA: "fra",
2594
- DAL: "dal",
2595
- FRA_A: "fra-a",
2596
- FRA_B: "fra-b"
2597
- };
2598
- var supportedRegions = Object.values(REGION);
2599
- var getRegion = (token) => {
2600
- const region = token.split(":")[0];
2601
- if (supportedRegions.includes(region)) {
2602
- return region;
2603
- }
2604
- };
2605
- function getPlatformAdapterClientAuthorization(req) {
2606
- return {
2607
- platform: {
2608
- dps: req.headers["platform-dps-token"]
2609
- },
2610
- github: {
2611
- app: req.headers["github-app-token"],
2612
- oauth: req.headers["github-oauth-token"]
2613
- },
2614
- netlify: req.headers["netlify-token"],
2615
- vercel: req.headers["vercel-token"],
2616
- planetscale: req.headers["planetscale-token"],
2617
- neon: req.headers["neon-token"],
2618
- sentry: req.headers["sentry-token"],
2619
- openai: req.headers["openai-token"]
2620
- };
2621
- }
2622
- var platformAdapterClientInstance = import_axios13.default.create({
2623
- baseURL: "https://platform.labs.text.com/console-adapter/api",
2624
- headers: {
2625
- "Content-Type": "application/json"
2626
- }
2627
- });
2628
- platformAdapterClientInstance.interceptors.response.use(
2629
- (r) => r,
2630
- (error) => {
2631
- var _a;
2632
- if (import_axios13.default.isAxiosError(error)) {
2633
- if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
2634
- const source = error.response.data.error.source;
2635
- if (source) {
2636
- throw new UnauthorizeApiError(source);
2637
- }
2638
- }
2639
- }
2640
- throw error;
2641
- }
2642
- );
2643
- function getPlatformAdapterClientConfig(options = {}) {
2644
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2645
- const currentHeaders = platformAdapterClientInstance.defaults.headers;
2646
- const headers = {
2647
- platform: {
2648
- dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
2649
- },
2650
- integrations: {
2651
- github: {
2652
- app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
2653
- oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
2654
- },
2655
- netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
2656
- vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
2657
- planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
2658
- neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
2659
- sentry: (_k = currentHeaders["sentry-token"]) != null ? _k : options.sentry,
2660
- openai: (_l = currentHeaders["openai-token"]) != null ? _l : options.openai
2661
- }
2662
- };
2663
- if (currentHeaders["platform-dps-token"]) {
2664
- currentHeaders["X-Region"] = (_m = getRegion(currentHeaders["platform-dps-token"])) != null ? _m : void 0;
2665
- }
2666
- if (((_o = (_n = options.ensureAuthorizationToken) == null ? void 0 : _n.platform) == null ? void 0 : _o.dps) && !headers.platform.dps) {
2667
- throw new UnauthorizeApiError("dps");
2668
- }
2669
- if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
2670
- throw new UnauthorizeApiError("github");
2671
- }
2672
- if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.vercel) && !headers.integrations.vercel) {
2673
- throw new UnauthorizeApiError("vercel");
2674
- }
2675
- if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.netlify) && !headers.integrations.netlify) {
2676
- throw new UnauthorizeApiError("netlify");
2677
- }
2678
- if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.planetscale) && !headers.integrations.planetscale) {
2679
- throw new UnauthorizeApiError("planetscale");
2680
- }
2681
- if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.neon) && !headers.integrations.neon) {
2682
- throw new UnauthorizeApiError("neon");
2683
- }
2684
- if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.sentry) && !headers.integrations.sentry) {
2685
- throw new UnauthorizeApiError("sentry");
2686
- }
2687
- if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.openai) && !headers.integrations.openai) {
2688
- throw new UnauthorizeApiError("openai");
2689
- }
2690
- return {
2691
- headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.dps ? { "platform-dps-token": headers.platform.dps } : {}), headers.integrations.github.app ? { "github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.sentry ? { "sentry-token": headers.integrations.sentry } : {}), headers.integrations.openai ? { "openai-token": headers.integrations.openai } : {})
2692
- };
2693
- }
2694
- function initPlatformAdapterClientInstance(baseUrl, tokens) {
2695
- if (baseUrl) {
2696
- platformAdapterClientInstance.interceptors.request.use(
2697
- (config) => {
2698
- config.baseURL = baseUrl;
2699
- return config;
2700
- },
2701
- (error) => Promise.reject(error)
2702
- );
2703
- }
2704
- if (tokens) {
2705
- updatePlatformAdapterClientInstance(tokens);
2706
- }
2707
- }
2708
- function updatePlatformAdapterClientInstance(tokens) {
2709
- var _a, _b, _c;
2710
- const headers = platformAdapterClientInstance.defaults.headers;
2711
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
2712
- headers["platform-dps-token"] = tokens.platform.dps;
2713
- }
2714
- if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
2715
- headers["github-app-token"] = tokens.github.app;
2716
- }
2717
- if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
2718
- headers["github-oauth-token"] = tokens.github.oauth;
2719
- }
2720
- if (tokens == null ? void 0 : tokens.netlify) {
2721
- headers["netlify-token"] = tokens.netlify;
2722
- }
2723
- if (tokens == null ? void 0 : tokens.vercel) {
2724
- headers["vercel-token"] = tokens.vercel;
2725
- }
2726
- if (tokens == null ? void 0 : tokens.planetscale) {
2727
- headers["planetscale-token"] = tokens.planetscale;
2728
- }
2729
- if (tokens == null ? void 0 : tokens.neon) {
2730
- headers["neon-token"] = tokens.neon;
2731
- }
2732
- if (tokens == null ? void 0 : tokens.sentry) {
2733
- headers["sentry-token"] = tokens.sentry;
2734
- }
2735
- if (tokens == null ? void 0 : tokens.openai) {
2736
- headers["openai-token"] = tokens.openai;
2737
- }
2738
- }
2739
-
2740
- // src/apis/platform/dps/applications/application/autoReview/_contracts/dtos/autoReview.ts
2741
- var getEmptyAppAutoReview = () => ({
2742
- isReviewed: false,
2743
- recommendations: {
2744
- listingDetails: {
2745
- appName: "",
2746
- shortDescription: "",
2747
- longDescription: "",
2748
- features: "",
2749
- benefits: ""
2750
- },
2751
- auth: {
2752
- hasZeroScopes: false
2753
- }
2754
- },
2755
- errors: {
2756
- listingDetails: {
2757
- appName: "",
2758
- shortDescription: "",
2759
- longDescription: "",
2760
- features: "",
2761
- benefits: ""
2762
- },
2763
- auth: {
2764
- hasAllScopes: false,
2765
- isRedirectUriSafe: false
2766
- },
2767
- links: {
2768
- tutorial: {
2769
- returns200: false,
2770
- isValid: false
2771
- },
2772
- privacyPolicy: {
2773
- returns200: false,
2774
- isValid: false
2775
- }
2776
- },
2777
- images: {
2778
- icon: {
2779
- isNsfw: false,
2780
- isRatioValid: false
2781
- },
2782
- screenshots: {
2783
- areNsfw: false,
2784
- areRatiosValid: false
2785
- }
2786
- }
2787
- }
2788
- });
2789
-
2790
- // src/apis/platform/dps/applications/application/autoReview/_contracts/payloads/autoReview.ts
2791
- var getAppAutoReviewPayload = (value) => {
2792
- return {
2793
- appName: value,
2794
- shortDescription: value,
2795
- longDescription: value,
2796
- features: value,
2797
- benefits: value,
2798
- scopes: value,
2799
- redirect: value,
2800
- tutorial: value,
2801
- privacyPolicy: value,
2802
- icons: value,
2803
- screenshots: value
2804
- };
2805
- };
2806
-
2807
- // src/apis/platform/dps/instance.ts
2808
- var import_axios14 = __toESM(require("axios"));
2809
- var platformDpsClientInstance = import_axios14.default.create({
2810
- baseURL: "https://dev-platform.labs.livechatinc.com"
2811
- });
2812
- function getPlatformDpsClientAuthorization(req) {
2813
- var _a;
2814
- return {
2815
- token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
2816
- tokenType: "Bearer"
2817
- };
2818
- }
2819
- function getPlatformDpsAdminClientAuthorization() {
2820
- var _a, _b;
2821
- const token = process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? (_a = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB) != null ? _a : "" : (_b = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB_LABS) != null ? _b : "";
2822
- return {
2823
- token: btoa(`apps@livechatinc.com:${token}`),
2824
- tokenType: "Basic"
2825
- };
2826
- }
2827
- function getPlatformDpsClientConfig(options = {}) {
2828
- const currentHeaders = platformDpsClientInstance.defaults.headers;
2829
- const defaultAuthorization = currentHeaders.Authorization;
2830
- const headers = {
2831
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2832
- };
2833
- return {
2834
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2835
- };
2836
- }
2837
- function initPlatformDpsClientInstance(baseUrl, token) {
2838
- const headers = platformDpsClientInstance.defaults.headers;
2839
- if (baseUrl) {
2840
- platformDpsClientInstance.interceptors.request.use(
2841
- (config) => {
2842
- config.baseURL = baseUrl;
2843
- return config;
2844
- },
2845
- (error) => Promise.reject(error)
2846
- );
2847
- }
2848
- if (token) {
2849
- headers.Authorization = `Bearer ${token}`;
2850
- } else {
2851
- delete headers.Authorization;
2852
- }
2853
- }
2854
-
2855
- // src/apis/products/livechat/instance.ts
2856
- var import_axios15 = __toESM(require("axios"));
2857
- var REGION2 = {
2858
- FRA: "fra",
2859
- DAL: "dal",
2860
- FRA_A: "fra-a",
2861
- FRA_B: "fra-b"
2862
- };
2863
- var supportedRegions2 = Object.values(REGION2);
2864
- var getRegion2 = (token) => {
2865
- const region = token.split(":")[0];
2866
- if (supportedRegions2.includes(region)) {
2867
- return region;
2868
- }
2869
- };
2870
- var livechatClientInstance = import_axios15.default.create({
2871
- baseURL: "https://api.labs.livechatinc.com"
2467
+ var import_axios11 = __toESM(require("axios"));
2468
+
2469
+ // src/apis/integrations/neon/instance.ts
2470
+ var import_axios10 = __toESM(require("axios"));
2471
+ var neonClientInstance = import_axios10.default.create({
2472
+ baseURL: "https://console.neon.tech/api/v2/"
2872
2473
  });
2873
- function getLiveChatClientAuthorization(req) {
2474
+ neonClientInstance.interceptors.response.use(
2475
+ (r) => r,
2476
+ (error) => {
2477
+ var _a;
2478
+ if (import_axios10.default.isAxiosError(error)) {
2479
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
2480
+ throw new UnauthorizeApiError("neon");
2481
+ }
2482
+ }
2483
+ throw error;
2484
+ }
2485
+ );
2486
+ function getNeonClientAuthorization(req) {
2874
2487
  return {
2875
- token: req.headers["livechat-token"]
2488
+ token: req.headers["neon-token"]
2876
2489
  };
2877
2490
  }
2878
- function getLiveChatClientConfig(options = {}) {
2879
- const currentHeaders = livechatClientInstance.defaults.headers;
2491
+ function getNeonClientConfig(options = {}) {
2492
+ const currentHeaders = neonClientInstance.defaults.headers;
2880
2493
  const defaultAuthorization = currentHeaders.Authorization;
2881
2494
  const headers = {
2882
2495
  authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2883
2496
  };
2497
+ if (options.ensureAuthorizationToken && !headers.authorization) {
2498
+ throw new UnauthorizeApiError("neon");
2499
+ }
2884
2500
  return {
2885
2501
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2886
2502
  };
2887
2503
  }
2888
- function initLiveChatClientInstance(baseUrl, token) {
2889
- const region = token ? getRegion2(token) : void 0;
2890
- const headers = livechatClientInstance.defaults.headers;
2891
- if (baseUrl) {
2892
- livechatClientInstance.interceptors.request.use(
2893
- (config) => {
2894
- config.baseURL = baseUrl;
2895
- return config;
2896
- },
2897
- (error) => Promise.reject(error)
2898
- );
2899
- }
2900
- if (region) {
2901
- headers["X-Region"] = region;
2504
+ function initNeonClientInstance(token) {
2505
+ if (token) {
2506
+ updateNeonClientInstance(token);
2902
2507
  }
2508
+ }
2509
+ function updateNeonClientInstance(token) {
2510
+ const headers = neonClientInstance.defaults.headers;
2903
2511
  if (token) {
2904
- headers.Authorization = `Bearer ${token}`;
2512
+ headers.Authorization = `${token}`;
2905
2513
  } else {
2906
2514
  delete headers.Authorization;
2907
2515
  }
@@ -2948,10 +2556,10 @@ var neonProjectBranchApi = {
2948
2556
  return response.data;
2949
2557
  });
2950
2558
  },
2951
- getDatabases(projectId, branchId, authorization) {
2559
+ getDatabase(projectId, branchId, databaseName, authorization) {
2952
2560
  return __async(this, null, function* () {
2953
2561
  const response = yield neonClientInstance.get(
2954
- `projects/${projectId}/branches/${branchId}/databases`,
2562
+ `projects/${projectId}/branches/${branchId}/databases/${databaseName}`,
2955
2563
  getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2956
2564
  ensureAuthorizationToken: true
2957
2565
  }))
@@ -2959,13 +2567,10 @@ var neonProjectBranchApi = {
2959
2567
  return response.data;
2960
2568
  });
2961
2569
  },
2962
- getNeonDatabases(projectId, authorization) {
2570
+ getDatabases(projectId, branchId, authorization) {
2963
2571
  return __async(this, null, function* () {
2964
- const response = yield platformAdapterClientInstance.post(
2965
- `integrations/neon/databases`,
2966
- {
2967
- projectId
2968
- },
2572
+ const response = yield neonClientInstance.get(
2573
+ `projects/${projectId}/branches/${branchId}/databases`,
2969
2574
  getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2970
2575
  ensureAuthorizationToken: true
2971
2576
  }))
@@ -3051,17 +2656,6 @@ var neonProjectApi = {
3051
2656
  );
3052
2657
  return response.data;
3053
2658
  });
3054
- },
3055
- getNeonProjects(authorization) {
3056
- return __async(this, null, function* () {
3057
- const response = yield platformAdapterClientInstance.get(
3058
- "/integrations/neon/projects",
3059
- getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
3060
- ensureAuthorizationToken: true
3061
- }))
3062
- );
3063
- return response.data;
3064
- });
3065
2659
  }
3066
2660
  };
3067
2661
 
@@ -3077,17 +2671,6 @@ var neonUserApi = {
3077
2671
  );
3078
2672
  return response.data;
3079
2673
  });
3080
- },
3081
- getNeonUser(authorization) {
3082
- return __async(this, null, function* () {
3083
- const response = yield platformAdapterClientInstance.get(
3084
- "/integrations/neon/user",
3085
- getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
3086
- ensureAuthorizationToken: true
3087
- }))
3088
- );
3089
- return response.data;
3090
- });
3091
2674
  }
3092
2675
  };
3093
2676
 
@@ -3105,7 +2688,7 @@ var neonApi = {
3105
2688
  redirect_uri: redirectUri,
3106
2689
  grant_type: "authorization_code"
3107
2690
  });
3108
- const response = yield import_axios16.default.post(
2691
+ const response = yield import_axios11.default.post(
3109
2692
  "https://oauth2.neon.tech/oauth2/token",
3110
2693
  data,
3111
2694
  {
@@ -3120,6 +2703,27 @@ var neonApi = {
3120
2703
  refreshToken: (_b = params.get("refresh_token")) != null ? _b : ""
3121
2704
  };
3122
2705
  });
2706
+ },
2707
+ refreshToken(refreshToken, clientId, clientSecret) {
2708
+ return __async(this, null, function* () {
2709
+ var _a, _b;
2710
+ const data = new URLSearchParams({
2711
+ refresh_token: refreshToken,
2712
+ client_id: clientId,
2713
+ client_secret: clientSecret,
2714
+ grant_type: "refresh_token"
2715
+ });
2716
+ const response = yield import_axios11.default.post("https://oauth2.neon.tech/oauth2/token", data, {
2717
+ headers: {
2718
+ "Content-Type": "application/x-www-form-urlencoded"
2719
+ }
2720
+ });
2721
+ const params = new URLSearchParams(response.data);
2722
+ return {
2723
+ token: (_a = params.get("access_token")) != null ? _a : "",
2724
+ refreshToken: (_b = params.get("refresh_token")) != null ? _b : ""
2725
+ };
2726
+ });
3123
2727
  }
3124
2728
  };
3125
2729
 
@@ -3134,6 +2738,61 @@ var integrationsApi = {
3134
2738
  text: textApi
3135
2739
  };
3136
2740
 
2741
+ // src/apis/products/livechat/instance.ts
2742
+ var import_axios12 = __toESM(require("axios"));
2743
+ var REGION = {
2744
+ FRA: "fra",
2745
+ DAL: "dal",
2746
+ FRA_A: "fra-a",
2747
+ FRA_B: "fra-b"
2748
+ };
2749
+ var supportedRegions = Object.values(REGION);
2750
+ var getRegion = (token) => {
2751
+ const region = token.split(":")[0];
2752
+ if (supportedRegions.includes(region)) {
2753
+ return region;
2754
+ }
2755
+ };
2756
+ var livechatClientInstance = import_axios12.default.create({
2757
+ baseURL: "https://api.labs.livechatinc.com"
2758
+ });
2759
+ function getLiveChatClientAuthorization(req) {
2760
+ return {
2761
+ token: req.headers["livechat-token"]
2762
+ };
2763
+ }
2764
+ function getLiveChatClientConfig(options = {}) {
2765
+ const currentHeaders = livechatClientInstance.defaults.headers;
2766
+ const defaultAuthorization = currentHeaders.Authorization;
2767
+ const headers = {
2768
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2769
+ };
2770
+ return {
2771
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2772
+ };
2773
+ }
2774
+ function initLiveChatClientInstance(baseUrl, token) {
2775
+ const region = token ? getRegion(token) : void 0;
2776
+ const headers = livechatClientInstance.defaults.headers;
2777
+ if (baseUrl) {
2778
+ livechatClientInstance.interceptors.request.use(
2779
+ (config) => {
2780
+ config.baseURL = baseUrl;
2781
+ return config;
2782
+ },
2783
+ (error) => Promise.reject(error)
2784
+ );
2785
+ }
2786
+ if (region) {
2787
+ headers["X-Region"] = region;
2788
+ }
2789
+ if (token) {
2790
+ headers.Authorization = `Bearer ${token}`;
2791
+ } else {
2792
+ delete headers.Authorization;
2793
+ }
2794
+ }
2795
+
3137
2796
  // src/apis/products/livechat/agents/api.ts
3138
2797
  var livechatAgentApi = {
3139
2798
  getUser() {
@@ -3576,6 +3235,42 @@ var productsApi = {
3576
3235
  livechat: livechatApi
3577
3236
  };
3578
3237
 
3238
+ // src/apis/platform/accounts/instance.ts
3239
+ var import_axios13 = __toESM(require("axios"));
3240
+ var platformAccountsClientInstance = import_axios13.default.create({
3241
+ baseURL: "https://accounts.labs.livechatinc.com"
3242
+ });
3243
+ function getPlatformAccountsClientAuthorization(req) {
3244
+ return {
3245
+ token: req.headers["platform-accounts-token"]
3246
+ };
3247
+ }
3248
+ function getPlatformAccountsClientConfig(options = {}) {
3249
+ const defaultAuthorization = platformAccountsClientInstance.defaults.headers["Authorization"];
3250
+ const headers = {
3251
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
3252
+ };
3253
+ return {
3254
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3255
+ };
3256
+ }
3257
+ function initPlatformAccountsClientInstance(baseUrl, token) {
3258
+ if (baseUrl) {
3259
+ platformAccountsClientInstance.interceptors.request.use(
3260
+ (config) => __async(this, null, function* () {
3261
+ config.baseURL = baseUrl;
3262
+ return config;
3263
+ }),
3264
+ (error) => Promise.reject(error)
3265
+ );
3266
+ }
3267
+ if (token) {
3268
+ platformAccountsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
3269
+ } else {
3270
+ delete platformAccountsClientInstance.defaults.headers["Authorization"];
3271
+ }
3272
+ }
3273
+
3579
3274
  // src/apis/platform/accounts/accounts/api.ts
3580
3275
  var platformAccountsAccountApi = {
3581
3276
  getAccounts(authorization) {
@@ -3995,6 +3690,54 @@ var platformAccountsApi = {
3995
3690
  token: platformAccountsTokenApi
3996
3691
  };
3997
3692
 
3693
+ // src/apis/platform/dps/instance.ts
3694
+ var import_axios14 = __toESM(require("axios"));
3695
+ var platformDpsClientInstance = import_axios14.default.create({
3696
+ baseURL: "https://dev-platform.labs.livechatinc.com"
3697
+ });
3698
+ function getPlatformDpsClientAuthorization(req) {
3699
+ var _a;
3700
+ return {
3701
+ token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
3702
+ tokenType: "Bearer"
3703
+ };
3704
+ }
3705
+ function getPlatformDpsAdminClientAuthorization() {
3706
+ var _a, _b;
3707
+ const token = process.env.NEXT_PUBLIC_PLATFORM_ENV === "prod" ? (_a = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB) != null ? _a : "" : (_b = process.env.PLATFORM_DPS_TOKEN_FOR_GITHUB_LABS) != null ? _b : "";
3708
+ return {
3709
+ token: btoa(`apps@livechatinc.com:${token}`),
3710
+ tokenType: "Basic"
3711
+ };
3712
+ }
3713
+ function getPlatformDpsClientConfig(options = {}) {
3714
+ const currentHeaders = platformDpsClientInstance.defaults.headers;
3715
+ const defaultAuthorization = currentHeaders.Authorization;
3716
+ const headers = {
3717
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
3718
+ };
3719
+ return {
3720
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3721
+ };
3722
+ }
3723
+ function initPlatformDpsClientInstance(baseUrl, token) {
3724
+ const headers = platformDpsClientInstance.defaults.headers;
3725
+ if (baseUrl) {
3726
+ platformDpsClientInstance.interceptors.request.use(
3727
+ (config) => {
3728
+ config.baseURL = baseUrl;
3729
+ return config;
3730
+ },
3731
+ (error) => Promise.reject(error)
3732
+ );
3733
+ }
3734
+ if (token) {
3735
+ headers.Authorization = `Bearer ${token}`;
3736
+ } else {
3737
+ delete headers.Authorization;
3738
+ }
3739
+ }
3740
+
3998
3741
  // src/apis/platform/dps/applications/application/authorization/api.ts
3999
3742
  var platformDpsApplicationAuthorizationApi = {
4000
3743
  createAuth(appId, payload, authorization) {
@@ -4013,8 +3756,75 @@ var platformDpsApplicationAuthorizationApi = {
4013
3756
  }
4014
3757
  throw error;
4015
3758
  }
4016
- });
3759
+ });
3760
+ }
3761
+ };
3762
+
3763
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/dtos/autoReview.ts
3764
+ var getEmptyAppAutoReview = () => ({
3765
+ isReviewed: false,
3766
+ recommendations: {
3767
+ listingDetails: {
3768
+ appName: "",
3769
+ shortDescription: "",
3770
+ longDescription: "",
3771
+ features: "",
3772
+ benefits: ""
3773
+ },
3774
+ auth: {
3775
+ hasZeroScopes: false
3776
+ }
3777
+ },
3778
+ errors: {
3779
+ listingDetails: {
3780
+ appName: "",
3781
+ shortDescription: "",
3782
+ longDescription: "",
3783
+ features: "",
3784
+ benefits: ""
3785
+ },
3786
+ auth: {
3787
+ hasAllScopes: false,
3788
+ isRedirectUriSafe: false
3789
+ },
3790
+ links: {
3791
+ tutorial: {
3792
+ returns200: false,
3793
+ isValid: false
3794
+ },
3795
+ privacyPolicy: {
3796
+ returns200: false,
3797
+ isValid: false
3798
+ }
3799
+ },
3800
+ images: {
3801
+ icon: {
3802
+ isNsfw: false,
3803
+ isRatioValid: false
3804
+ },
3805
+ screenshots: {
3806
+ areNsfw: false,
3807
+ areRatiosValid: false
3808
+ }
3809
+ }
4017
3810
  }
3811
+ });
3812
+
3813
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/payloads/autoReview.ts
3814
+ var getAppAutoReviewPayload = (value) => {
3815
+ return {
3816
+ appName: value,
3817
+ shortDescription: value,
3818
+ longDescription: value,
3819
+ features: value,
3820
+ benefits: value,
3821
+ scopes: value,
3822
+ redirect: value,
3823
+ tutorial: value,
3824
+ privacyPolicy: value,
3825
+ icons: value,
3826
+ screenshots: value
3827
+ };
4018
3828
  };
4019
3829
 
4020
3830
  // src/apis/platform/dps/applications/application/autoReview/api.ts
@@ -5512,6 +5322,156 @@ var platformDpsApi = {
5512
5322
  research: platformDpsResearchApi
5513
5323
  };
5514
5324
 
5325
+ // src/apis/platform/adapter/instance.ts
5326
+ var import_axios15 = __toESM(require("axios"));
5327
+ var REGION2 = {
5328
+ FRA: "fra",
5329
+ DAL: "dal",
5330
+ FRA_A: "fra-a",
5331
+ FRA_B: "fra-b"
5332
+ };
5333
+ var supportedRegions2 = Object.values(REGION2);
5334
+ var getRegion2 = (token) => {
5335
+ const region = token.split(":")[0];
5336
+ if (supportedRegions2.includes(region)) {
5337
+ return region;
5338
+ }
5339
+ };
5340
+ function getPlatformAdapterClientAuthorization(req) {
5341
+ return {
5342
+ platform: {
5343
+ dps: req.headers["platform-dps-token"]
5344
+ },
5345
+ github: {
5346
+ app: req.headers["github-app-token"],
5347
+ oauth: req.headers["github-oauth-token"]
5348
+ },
5349
+ netlify: req.headers["netlify-token"],
5350
+ vercel: req.headers["vercel-token"],
5351
+ planetscale: req.headers["planetscale-token"],
5352
+ neon: req.headers["neon-token"],
5353
+ sentry: req.headers["sentry-token"],
5354
+ openai: req.headers["openai-token"]
5355
+ };
5356
+ }
5357
+ var platformAdapterClientInstance = import_axios15.default.create({
5358
+ baseURL: "https://platform.labs.text.com/console-adapter/api",
5359
+ headers: {
5360
+ "Content-Type": "application/json"
5361
+ }
5362
+ });
5363
+ platformAdapterClientInstance.interceptors.response.use(
5364
+ (r) => r,
5365
+ (error) => {
5366
+ var _a;
5367
+ if (import_axios15.default.isAxiosError(error)) {
5368
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
5369
+ const source = error.response.data.error.source;
5370
+ if (source) {
5371
+ throw new UnauthorizeApiError(source);
5372
+ }
5373
+ }
5374
+ }
5375
+ throw error;
5376
+ }
5377
+ );
5378
+ function getPlatformAdapterClientConfig(options = {}) {
5379
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
5380
+ const currentHeaders = platformAdapterClientInstance.defaults.headers;
5381
+ const headers = {
5382
+ platform: {
5383
+ dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
5384
+ },
5385
+ integrations: {
5386
+ github: {
5387
+ app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
5388
+ oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
5389
+ },
5390
+ netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
5391
+ vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
5392
+ planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
5393
+ neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
5394
+ sentry: (_k = currentHeaders["sentry-token"]) != null ? _k : options.sentry,
5395
+ openai: (_l = currentHeaders["openai-token"]) != null ? _l : options.openai
5396
+ }
5397
+ };
5398
+ if (currentHeaders["platform-dps-token"]) {
5399
+ currentHeaders["X-Region"] = (_m = getRegion2(currentHeaders["platform-dps-token"])) != null ? _m : void 0;
5400
+ }
5401
+ if (((_o = (_n = options.ensureAuthorizationToken) == null ? void 0 : _n.platform) == null ? void 0 : _o.dps) && !headers.platform.dps) {
5402
+ throw new UnauthorizeApiError("dps");
5403
+ }
5404
+ if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
5405
+ throw new UnauthorizeApiError("github");
5406
+ }
5407
+ if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.vercel) && !headers.integrations.vercel) {
5408
+ throw new UnauthorizeApiError("vercel");
5409
+ }
5410
+ if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.netlify) && !headers.integrations.netlify) {
5411
+ throw new UnauthorizeApiError("netlify");
5412
+ }
5413
+ if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.planetscale) && !headers.integrations.planetscale) {
5414
+ throw new UnauthorizeApiError("planetscale");
5415
+ }
5416
+ if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.neon) && !headers.integrations.neon) {
5417
+ throw new UnauthorizeApiError("neon");
5418
+ }
5419
+ if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.sentry) && !headers.integrations.sentry) {
5420
+ throw new UnauthorizeApiError("sentry");
5421
+ }
5422
+ if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.openai) && !headers.integrations.openai) {
5423
+ throw new UnauthorizeApiError("openai");
5424
+ }
5425
+ return {
5426
+ headers: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, headers.platform.dps ? { "platform-dps-token": headers.platform.dps } : {}), headers.integrations.github.app ? { "github-app-token": headers.integrations.github.app } : {}), headers.integrations.github.oauth ? { "github-oauth-token": headers.integrations.github.oauth } : {}), headers.integrations.netlify ? { "netlify-token": headers.integrations.netlify } : {}), headers.integrations.vercel ? { "vercel-token": headers.integrations.vercel } : {}), headers.integrations.planetscale ? { "planetscale-token": headers.integrations.planetscale } : {}), headers.integrations.sentry ? { "sentry-token": headers.integrations.sentry } : {}), headers.integrations.openai ? { "openai-token": headers.integrations.openai } : {})
5427
+ };
5428
+ }
5429
+ function initPlatformAdapterClientInstance(baseUrl, tokens) {
5430
+ if (baseUrl) {
5431
+ platformAdapterClientInstance.interceptors.request.use(
5432
+ (config) => {
5433
+ config.baseURL = baseUrl;
5434
+ return config;
5435
+ },
5436
+ (error) => Promise.reject(error)
5437
+ );
5438
+ }
5439
+ if (tokens) {
5440
+ updatePlatformAdapterClientInstance(tokens);
5441
+ }
5442
+ }
5443
+ function updatePlatformAdapterClientInstance(tokens) {
5444
+ var _a, _b, _c;
5445
+ const headers = platformAdapterClientInstance.defaults.headers;
5446
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
5447
+ headers["platform-dps-token"] = tokens.platform.dps;
5448
+ }
5449
+ if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
5450
+ headers["github-app-token"] = tokens.github.app;
5451
+ }
5452
+ if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
5453
+ headers["github-oauth-token"] = tokens.github.oauth;
5454
+ }
5455
+ if (tokens == null ? void 0 : tokens.netlify) {
5456
+ headers["netlify-token"] = tokens.netlify;
5457
+ }
5458
+ if (tokens == null ? void 0 : tokens.vercel) {
5459
+ headers["vercel-token"] = tokens.vercel;
5460
+ }
5461
+ if (tokens == null ? void 0 : tokens.planetscale) {
5462
+ headers["planetscale-token"] = tokens.planetscale;
5463
+ }
5464
+ if (tokens == null ? void 0 : tokens.neon) {
5465
+ headers["neon-token"] = tokens.neon;
5466
+ }
5467
+ if (tokens == null ? void 0 : tokens.sentry) {
5468
+ headers["sentry-token"] = tokens.sentry;
5469
+ }
5470
+ if (tokens == null ? void 0 : tokens.openai) {
5471
+ headers["openai-token"] = tokens.openai;
5472
+ }
5473
+ }
5474
+
5515
5475
  // src/apis/platform/adapter/app/blocks/deployment/api.ts
5516
5476
  var platformAdapterAppDeploymentApi = {
5517
5477
  get(appId, authorization) {
@@ -6046,10 +6006,90 @@ var platformAdapterConductorApi = {
6046
6006
  }
6047
6007
  };
6048
6008
 
6009
+ // src/apis/platform/billing/instance.ts
6010
+ var import_axios16 = __toESM(require("axios"));
6011
+ var platformBillingClientInstance = import_axios16.default.create({
6012
+ baseURL: "https://billing.labs.livechatinc.com"
6013
+ });
6014
+ function getPlatformBillingClientAuthorization(req) {
6015
+ return {
6016
+ token: req.headers["platform-token"]
6017
+ };
6018
+ }
6019
+ function getPlatformBillingClientConfig(options = {}) {
6020
+ const defaultAuthorization = platformBillingClientInstance.defaults.headers.Authorization;
6021
+ const headers = {
6022
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
6023
+ };
6024
+ return {
6025
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
6026
+ };
6027
+ }
6028
+ function initPlatformBillingClientInstance(baseUrl, token) {
6029
+ if (baseUrl) {
6030
+ platformBillingClientInstance.interceptors.request.use(
6031
+ (config) => __async(this, null, function* () {
6032
+ config.baseURL = baseUrl;
6033
+ return config;
6034
+ }),
6035
+ (error) => Promise.reject(error)
6036
+ );
6037
+ }
6038
+ if (token) {
6039
+ platformBillingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
6040
+ } else {
6041
+ delete platformBillingClientInstance.defaults.headers.Authorization;
6042
+ }
6043
+ }
6044
+
6045
+ // src/apis/platform/adapter/integrations/neon/api.ts
6046
+ var platformAdapterNeonProxyApi = {
6047
+ user(authorization) {
6048
+ return __async(this, null, function* () {
6049
+ const response = yield platformAdapterClientInstance.get(
6050
+ `/integrations/neon/user`,
6051
+ getNeonClientConfig(authorization)
6052
+ );
6053
+ return response.data;
6054
+ });
6055
+ },
6056
+ projects(authorization) {
6057
+ return __async(this, null, function* () {
6058
+ const response = yield platformAdapterClientInstance.get(
6059
+ `/integrations/neon/projects`,
6060
+ getNeonClientConfig(authorization)
6061
+ );
6062
+ return response.data;
6063
+ });
6064
+ },
6065
+ databases(projectId, authorization) {
6066
+ return __async(this, null, function* () {
6067
+ const response = yield platformAdapterClientInstance.post(
6068
+ `/integrations/neon/databases`,
6069
+ { projectId },
6070
+ getNeonClientConfig(authorization)
6071
+ );
6072
+ return response.data;
6073
+ });
6074
+ },
6075
+ refreshToken(authorization) {
6076
+ return __async(this, null, function* () {
6077
+ const response = yield platformAdapterClientInstance.get(`/integrations/neon/refresh-token`, getNeonClientConfig(authorization));
6078
+ return response.data;
6079
+ });
6080
+ }
6081
+ };
6082
+
6083
+ // src/apis/platform/adapter/integrations/api.ts
6084
+ var platformAdapterIntegrationsProxyApi = {
6085
+ neon: platformAdapterNeonProxyApi
6086
+ };
6087
+
6049
6088
  // src/apis/platform/adapter/api.ts
6050
6089
  var platformAdapterApi = {
6051
6090
  app: platformAdapterAppApi,
6052
- conductor: platformAdapterConductorApi
6091
+ conductor: platformAdapterConductorApi,
6092
+ proxy: platformAdapterIntegrationsProxyApi
6053
6093
  };
6054
6094
 
6055
6095
  // src/apis/platform/billing/account/api.ts