@livechat/developer-studio-api 2.3.50 → 2.3.52

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.mjs CHANGED
@@ -2368,7 +2368,7 @@ var vercelApi = {
2368
2368
  };
2369
2369
 
2370
2370
  // src/apis/integrations/neon/api.ts
2371
- import axios11 from "axios";
2371
+ import axios16 from "axios";
2372
2372
 
2373
2373
  // src/apis/integrations/neon/instance.ts
2374
2374
  import axios10 from "axios";
@@ -2419,22 +2419,482 @@ function updateNeonClientInstance(token) {
2419
2419
  }
2420
2420
  }
2421
2421
 
2422
+ // src/apis/platform/accounts/instance.ts
2423
+ import axios11 from "axios";
2424
+ var platformAccountsClientInstance = axios11.create({
2425
+ baseURL: "https://accounts.labs.livechatinc.com"
2426
+ });
2427
+ function getPlatformAccountsClientAuthorization(req) {
2428
+ return {
2429
+ token: req.headers["platform-accounts-token"]
2430
+ };
2431
+ }
2432
+ function getPlatformAccountsClientConfig(options = {}) {
2433
+ const defaultAuthorization = platformAccountsClientInstance.defaults.headers["Authorization"];
2434
+ const headers = {
2435
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2436
+ };
2437
+ return {
2438
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2439
+ };
2440
+ }
2441
+ function initPlatformAccountsClientInstance(baseUrl, token) {
2442
+ if (baseUrl) {
2443
+ platformAccountsClientInstance.interceptors.request.use(
2444
+ (config) => __async(this, null, function* () {
2445
+ config.baseURL = baseUrl;
2446
+ return config;
2447
+ }),
2448
+ (error) => Promise.reject(error)
2449
+ );
2450
+ }
2451
+ if (token) {
2452
+ platformAccountsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
2453
+ } else {
2454
+ delete platformAccountsClientInstance.defaults.headers["Authorization"];
2455
+ }
2456
+ }
2457
+
2458
+ // src/apis/platform/billing/instance.ts
2459
+ import axios12 from "axios";
2460
+ var platformBillingClientInstance = axios12.create({
2461
+ baseURL: "https://billing.labs.livechatinc.com"
2462
+ });
2463
+ function getPlatformBillingClientAuthorization(req) {
2464
+ return {
2465
+ token: req.headers["platform-token"]
2466
+ };
2467
+ }
2468
+ function getPlatformBillingClientConfig(options = {}) {
2469
+ const defaultAuthorization = platformBillingClientInstance.defaults.headers.Authorization;
2470
+ const headers = {
2471
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2472
+ };
2473
+ return {
2474
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2475
+ };
2476
+ }
2477
+ function initPlatformBillingClientInstance(baseUrl, token) {
2478
+ if (baseUrl) {
2479
+ platformBillingClientInstance.interceptors.request.use(
2480
+ (config) => __async(this, null, function* () {
2481
+ config.baseURL = baseUrl;
2482
+ return config;
2483
+ }),
2484
+ (error) => Promise.reject(error)
2485
+ );
2486
+ }
2487
+ if (token) {
2488
+ platformBillingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
2489
+ } else {
2490
+ delete platformBillingClientInstance.defaults.headers.Authorization;
2491
+ }
2492
+ }
2493
+
2494
+ // src/apis/platform/adapter/instance.ts
2495
+ import axios13 from "axios";
2496
+ var REGION = {
2497
+ FRA: "fra",
2498
+ DAL: "dal",
2499
+ FRA_A: "fra-a",
2500
+ FRA_B: "fra-b"
2501
+ };
2502
+ var supportedRegions = Object.values(REGION);
2503
+ var getRegion = (token) => {
2504
+ const region = token.split(":")[0];
2505
+ if (supportedRegions.includes(region)) {
2506
+ return region;
2507
+ }
2508
+ };
2509
+ function getPlatformAdapterClientAuthorization(req) {
2510
+ return {
2511
+ platform: {
2512
+ dps: req.headers["platform-dps-token"]
2513
+ },
2514
+ github: {
2515
+ app: req.headers["github-app-token"],
2516
+ oauth: req.headers["github-oauth-token"]
2517
+ },
2518
+ netlify: req.headers["netlify-token"],
2519
+ vercel: req.headers["vercel-token"],
2520
+ planetscale: req.headers["planetscale-token"],
2521
+ neon: req.headers["neon-token"],
2522
+ sentry: req.headers["sentry-token"],
2523
+ openai: req.headers["openai-token"]
2524
+ };
2525
+ }
2526
+ var platformAdapterClientInstance = axios13.create({
2527
+ baseURL: "https://platform.labs.text.com/console-adapter/api",
2528
+ headers: {
2529
+ "Content-Type": "application/json"
2530
+ }
2531
+ });
2532
+ platformAdapterClientInstance.interceptors.response.use(
2533
+ (r) => r,
2534
+ (error) => {
2535
+ var _a;
2536
+ if (axios13.isAxiosError(error)) {
2537
+ if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
2538
+ const source = error.response.data.error.source;
2539
+ if (source) {
2540
+ throw new UnauthorizeApiError(source);
2541
+ }
2542
+ }
2543
+ }
2544
+ throw error;
2545
+ }
2546
+ );
2547
+ function getPlatformAdapterClientConfig(options = {}) {
2548
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2549
+ const currentHeaders = platformAdapterClientInstance.defaults.headers;
2550
+ const headers = {
2551
+ platform: {
2552
+ dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
2553
+ },
2554
+ integrations: {
2555
+ github: {
2556
+ app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
2557
+ oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
2558
+ },
2559
+ netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
2560
+ vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
2561
+ planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
2562
+ neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
2563
+ sentry: (_k = currentHeaders["sentry-token"]) != null ? _k : options.sentry,
2564
+ openai: (_l = currentHeaders["openai-token"]) != null ? _l : options.openai
2565
+ }
2566
+ };
2567
+ if (currentHeaders["platform-dps-token"]) {
2568
+ currentHeaders["X-Region"] = (_m = getRegion(currentHeaders["platform-dps-token"])) != null ? _m : void 0;
2569
+ }
2570
+ if (((_o = (_n = options.ensureAuthorizationToken) == null ? void 0 : _n.platform) == null ? void 0 : _o.dps) && !headers.platform.dps) {
2571
+ throw new UnauthorizeApiError("dps");
2572
+ }
2573
+ if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
2574
+ throw new UnauthorizeApiError("github");
2575
+ }
2576
+ if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.vercel) && !headers.integrations.vercel) {
2577
+ throw new UnauthorizeApiError("vercel");
2578
+ }
2579
+ if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.netlify) && !headers.integrations.netlify) {
2580
+ throw new UnauthorizeApiError("netlify");
2581
+ }
2582
+ if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.planetscale) && !headers.integrations.planetscale) {
2583
+ throw new UnauthorizeApiError("planetscale");
2584
+ }
2585
+ if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.neon) && !headers.integrations.neon) {
2586
+ throw new UnauthorizeApiError("neon");
2587
+ }
2588
+ if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.sentry) && !headers.integrations.sentry) {
2589
+ throw new UnauthorizeApiError("sentry");
2590
+ }
2591
+ if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.openai) && !headers.integrations.openai) {
2592
+ throw new UnauthorizeApiError("openai");
2593
+ }
2594
+ return {
2595
+ 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 } : {})
2596
+ };
2597
+ }
2598
+ function initPlatformAdapterClientInstance(baseUrl, tokens) {
2599
+ if (baseUrl) {
2600
+ platformAdapterClientInstance.interceptors.request.use(
2601
+ (config) => {
2602
+ config.baseURL = baseUrl;
2603
+ return config;
2604
+ },
2605
+ (error) => Promise.reject(error)
2606
+ );
2607
+ }
2608
+ if (tokens) {
2609
+ updatePlatformAdapterClientInstance(tokens);
2610
+ }
2611
+ }
2612
+ function updatePlatformAdapterClientInstance(tokens) {
2613
+ var _a, _b, _c;
2614
+ const headers = platformAdapterClientInstance.defaults.headers;
2615
+ if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
2616
+ headers["platform-dps-token"] = tokens.platform.dps;
2617
+ }
2618
+ if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
2619
+ headers["github-app-token"] = tokens.github.app;
2620
+ }
2621
+ if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
2622
+ headers["github-oauth-token"] = tokens.github.oauth;
2623
+ }
2624
+ if (tokens == null ? void 0 : tokens.netlify) {
2625
+ headers["netlify-token"] = tokens.netlify;
2626
+ }
2627
+ if (tokens == null ? void 0 : tokens.vercel) {
2628
+ headers["vercel-token"] = tokens.vercel;
2629
+ }
2630
+ if (tokens == null ? void 0 : tokens.planetscale) {
2631
+ headers["planetscale-token"] = tokens.planetscale;
2632
+ }
2633
+ if (tokens == null ? void 0 : tokens.neon) {
2634
+ headers["neon-token"] = tokens.neon;
2635
+ }
2636
+ if (tokens == null ? void 0 : tokens.sentry) {
2637
+ headers["sentry-token"] = tokens.sentry;
2638
+ }
2639
+ if (tokens == null ? void 0 : tokens.openai) {
2640
+ headers["openai-token"] = tokens.openai;
2641
+ }
2642
+ }
2643
+
2644
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/dtos/autoReview.ts
2645
+ var getEmptyAppAutoReview = () => ({
2646
+ isReviewed: false,
2647
+ recommendations: {
2648
+ listingDetails: {
2649
+ appName: "",
2650
+ shortDescription: "",
2651
+ longDescription: "",
2652
+ features: "",
2653
+ benefits: ""
2654
+ },
2655
+ auth: {
2656
+ hasZeroScopes: false
2657
+ }
2658
+ },
2659
+ errors: {
2660
+ listingDetails: {
2661
+ appName: "",
2662
+ shortDescription: "",
2663
+ longDescription: "",
2664
+ features: "",
2665
+ benefits: ""
2666
+ },
2667
+ auth: {
2668
+ hasAllScopes: false,
2669
+ isRedirectUriSafe: false
2670
+ },
2671
+ links: {
2672
+ tutorial: {
2673
+ returns200: false,
2674
+ isValid: false
2675
+ },
2676
+ privacyPolicy: {
2677
+ returns200: false,
2678
+ isValid: false
2679
+ }
2680
+ },
2681
+ images: {
2682
+ icon: {
2683
+ isNsfw: false,
2684
+ isRatioValid: false
2685
+ },
2686
+ screenshots: {
2687
+ areNsfw: false,
2688
+ areRatiosValid: false
2689
+ }
2690
+ }
2691
+ }
2692
+ });
2693
+
2694
+ // src/apis/platform/dps/applications/application/autoReview/_contracts/payloads/autoReview.ts
2695
+ var getAppAutoReviewPayload = (value) => {
2696
+ return {
2697
+ appName: value,
2698
+ shortDescription: value,
2699
+ longDescription: value,
2700
+ features: value,
2701
+ benefits: value,
2702
+ scopes: value,
2703
+ redirect: value,
2704
+ tutorial: value,
2705
+ privacyPolicy: value,
2706
+ icons: value,
2707
+ screenshots: value
2708
+ };
2709
+ };
2710
+
2711
+ // src/apis/platform/dps/instance.ts
2712
+ import axios14 from "axios";
2713
+ var platformDpsClientInstance = axios14.create({
2714
+ baseURL: "https://dev-platform.labs.livechatinc.com"
2715
+ });
2716
+ function getPlatformDpsClientAuthorization(req) {
2717
+ var _a;
2718
+ return {
2719
+ token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
2720
+ tokenType: "Bearer"
2721
+ };
2722
+ }
2723
+ function getPlatformDpsAdminClientAuthorization() {
2724
+ var _a, _b;
2725
+ 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 : "";
2726
+ return {
2727
+ token: btoa(`apps@livechatinc.com:${token}`),
2728
+ tokenType: "Basic"
2729
+ };
2730
+ }
2731
+ function getPlatformDpsClientConfig(options = {}) {
2732
+ const currentHeaders = platformDpsClientInstance.defaults.headers;
2733
+ const defaultAuthorization = currentHeaders.Authorization;
2734
+ const headers = {
2735
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2736
+ };
2737
+ return {
2738
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2739
+ };
2740
+ }
2741
+ function initPlatformDpsClientInstance(baseUrl, token) {
2742
+ const headers = platformDpsClientInstance.defaults.headers;
2743
+ if (baseUrl) {
2744
+ platformDpsClientInstance.interceptors.request.use(
2745
+ (config) => {
2746
+ config.baseURL = baseUrl;
2747
+ return config;
2748
+ },
2749
+ (error) => Promise.reject(error)
2750
+ );
2751
+ }
2752
+ if (token) {
2753
+ headers.Authorization = `Bearer ${token}`;
2754
+ } else {
2755
+ delete headers.Authorization;
2756
+ }
2757
+ }
2758
+
2759
+ // src/apis/products/livechat/instance.ts
2760
+ import axios15 from "axios";
2761
+ var REGION2 = {
2762
+ FRA: "fra",
2763
+ DAL: "dal",
2764
+ FRA_A: "fra-a",
2765
+ FRA_B: "fra-b"
2766
+ };
2767
+ var supportedRegions2 = Object.values(REGION2);
2768
+ var getRegion2 = (token) => {
2769
+ const region = token.split(":")[0];
2770
+ if (supportedRegions2.includes(region)) {
2771
+ return region;
2772
+ }
2773
+ };
2774
+ var livechatClientInstance = axios15.create({
2775
+ baseURL: "https://api.labs.livechatinc.com"
2776
+ });
2777
+ function getLiveChatClientAuthorization(req) {
2778
+ return {
2779
+ token: req.headers["livechat-token"]
2780
+ };
2781
+ }
2782
+ function getLiveChatClientConfig(options = {}) {
2783
+ const currentHeaders = livechatClientInstance.defaults.headers;
2784
+ const defaultAuthorization = currentHeaders.Authorization;
2785
+ const headers = {
2786
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2787
+ };
2788
+ return {
2789
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2790
+ };
2791
+ }
2792
+ function initLiveChatClientInstance(baseUrl, token) {
2793
+ const region = token ? getRegion2(token) : void 0;
2794
+ const headers = livechatClientInstance.defaults.headers;
2795
+ if (baseUrl) {
2796
+ livechatClientInstance.interceptors.request.use(
2797
+ (config) => {
2798
+ config.baseURL = baseUrl;
2799
+ return config;
2800
+ },
2801
+ (error) => Promise.reject(error)
2802
+ );
2803
+ }
2804
+ if (region) {
2805
+ headers["X-Region"] = region;
2806
+ }
2807
+ if (token) {
2808
+ headers.Authorization = `Bearer ${token}`;
2809
+ } else {
2810
+ delete headers.Authorization;
2811
+ }
2812
+ }
2813
+
2422
2814
  // src/apis/integrations/neon/project/branch/api.ts
2423
2815
  var neonProjectBranchApi = {
2424
- getBranch(projectId, branchId, authorization) {
2816
+ getBranches(projectId, authorization) {
2817
+ return __async(this, null, function* () {
2818
+ const response = yield neonClientInstance.get(
2819
+ `projects/${projectId}/branches`,
2820
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2821
+ ensureAuthorizationToken: true
2822
+ }))
2823
+ );
2824
+ return response.data;
2825
+ });
2826
+ },
2827
+ createDatabase(projectId, branchId, databaseName, ownerName, authorization) {
2828
+ return __async(this, null, function* () {
2829
+ const response = yield neonClientInstance.post(
2830
+ `projects/${projectId}/branches/${branchId}/databases`,
2831
+ {
2832
+ database: {
2833
+ name: databaseName,
2834
+ owner_name: ownerName
2835
+ }
2836
+ },
2837
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2838
+ ensureAuthorizationToken: true
2839
+ }))
2840
+ );
2841
+ return response.data;
2842
+ });
2843
+ },
2844
+ deleteDatabase(projectId, branchId, databaseName, authorization) {
2845
+ return __async(this, null, function* () {
2846
+ const response = yield neonClientInstance.delete(
2847
+ `projects/${projectId}/branches/${branchId}/databases/${databaseName}`,
2848
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2849
+ ensureAuthorizationToken: true
2850
+ }))
2851
+ );
2852
+ return response.data;
2853
+ });
2854
+ },
2855
+ getDatabases(projectId, branchId, authorization) {
2856
+ return __async(this, null, function* () {
2857
+ const response = yield neonClientInstance.get(
2858
+ `projects/${projectId}/branches/${branchId}/databases`,
2859
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2860
+ ensureAuthorizationToken: true
2861
+ }))
2862
+ );
2863
+ return response.data;
2864
+ });
2865
+ },
2866
+ getNeonDatabases(projectId, authorization) {
2867
+ return __async(this, null, function* () {
2868
+ const response = yield platformAdapterClientInstance.post(
2869
+ `integrations/neon/databases`,
2870
+ {
2871
+ projectId
2872
+ },
2873
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2874
+ ensureAuthorizationToken: true
2875
+ }))
2876
+ );
2877
+ return response.data;
2878
+ });
2879
+ },
2880
+ getRolePassword(projectId, branchId, roleName, authorization) {
2425
2881
  return __async(this, null, function* () {
2426
2882
  const response = yield neonClientInstance.get(
2427
- `projects/${projectId}/branches/${branchId}`,
2428
- getNeonClientConfig(__spreadValues({}, authorization))
2883
+ `projects/${projectId}/branches/${branchId}/roles/${roleName}/reveal_password`,
2884
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2885
+ ensureAuthorizationToken: true
2886
+ }))
2429
2887
  );
2430
2888
  return response.data;
2431
2889
  });
2432
2890
  },
2433
- getBranches(projectId, authorization) {
2891
+ getBranchEndpoints(projectId, branchId, authorization) {
2434
2892
  return __async(this, null, function* () {
2435
2893
  const response = yield neonClientInstance.get(
2436
- `projects/${projectId}/branches`,
2437
- getNeonClientConfig(__spreadValues({}, authorization))
2894
+ `projects/${projectId}/branches/${branchId}/endpoints`,
2895
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2896
+ ensureAuthorizationToken: true
2897
+ }))
2438
2898
  );
2439
2899
  return response.data;
2440
2900
  });
@@ -2444,13 +2904,16 @@ var neonProjectBranchApi = {
2444
2904
  // src/apis/integrations/neon/project/api.ts
2445
2905
  var neonProjectApi = {
2446
2906
  branch: neonProjectBranchApi,
2447
- createProject(projectName, authorization) {
2907
+ createProject(projectName, databaseName, authorization) {
2448
2908
  return __async(this, null, function* () {
2449
2909
  const response = yield neonClientInstance.post(
2450
2910
  `/projects`,
2451
2911
  {
2452
2912
  project: {
2453
- name: projectName
2913
+ name: projectName,
2914
+ branch: {
2915
+ database_name: databaseName
2916
+ }
2454
2917
  }
2455
2918
  },
2456
2919
  getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
@@ -2492,6 +2955,17 @@ var neonProjectApi = {
2492
2955
  );
2493
2956
  return response.data;
2494
2957
  });
2958
+ },
2959
+ getNeonProjects(authorization) {
2960
+ return __async(this, null, function* () {
2961
+ const response = yield platformAdapterClientInstance.get(
2962
+ "/integrations/neon/projects",
2963
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2964
+ ensureAuthorizationToken: true
2965
+ }))
2966
+ );
2967
+ return response.data;
2968
+ });
2495
2969
  }
2496
2970
  };
2497
2971
 
@@ -2507,6 +2981,17 @@ var neonUserApi = {
2507
2981
  );
2508
2982
  return response.data;
2509
2983
  });
2984
+ },
2985
+ getNeonUser(authorization) {
2986
+ return __async(this, null, function* () {
2987
+ const response = yield platformAdapterClientInstance.get(
2988
+ "/integrations/neon/user",
2989
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2990
+ ensureAuthorizationToken: true
2991
+ }))
2992
+ );
2993
+ return response.data;
2994
+ });
2510
2995
  }
2511
2996
  };
2512
2997
 
@@ -2516,7 +3001,7 @@ var neonApi = {
2516
3001
  user: neonUserApi,
2517
3002
  getToken(code, clientId, clientSecret, redirectUri) {
2518
3003
  return __async(this, null, function* () {
2519
- var _a;
3004
+ var _a, _b;
2520
3005
  const data = new URLSearchParams({
2521
3006
  code,
2522
3007
  client_id: clientId,
@@ -2524,7 +3009,7 @@ var neonApi = {
2524
3009
  redirect_uri: redirectUri,
2525
3010
  grant_type: "authorization_code"
2526
3011
  });
2527
- const response = yield axios11.post(
3012
+ const response = yield axios16.post(
2528
3013
  "https://oauth2.neon.tech/oauth2/token",
2529
3014
  data,
2530
3015
  {
@@ -2534,7 +3019,10 @@ var neonApi = {
2534
3019
  }
2535
3020
  );
2536
3021
  const params = new URLSearchParams(response.data);
2537
- return (_a = params.get("access_token")) != null ? _a : "";
3022
+ return {
3023
+ token: (_a = params.get("access_token")) != null ? _a : "",
3024
+ refreshToken: (_b = params.get("refresh_token")) != null ? _b : ""
3025
+ };
2538
3026
  });
2539
3027
  }
2540
3028
  };
@@ -2550,61 +3038,6 @@ var integrationsApi = {
2550
3038
  text: textApi
2551
3039
  };
2552
3040
 
2553
- // src/apis/products/livechat/instance.ts
2554
- import axios12 from "axios";
2555
- var REGION = {
2556
- FRA: "fra",
2557
- DAL: "dal",
2558
- FRA_A: "fra-a",
2559
- FRA_B: "fra-b"
2560
- };
2561
- var supportedRegions = Object.values(REGION);
2562
- var getRegion = (token) => {
2563
- const region = token.split(":")[0];
2564
- if (supportedRegions.includes(region)) {
2565
- return region;
2566
- }
2567
- };
2568
- var livechatClientInstance = axios12.create({
2569
- baseURL: "https://api.labs.livechatinc.com"
2570
- });
2571
- function getLiveChatClientAuthorization(req) {
2572
- return {
2573
- token: req.headers["livechat-token"]
2574
- };
2575
- }
2576
- function getLiveChatClientConfig(options = {}) {
2577
- const currentHeaders = livechatClientInstance.defaults.headers;
2578
- const defaultAuthorization = currentHeaders.Authorization;
2579
- const headers = {
2580
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2581
- };
2582
- return {
2583
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2584
- };
2585
- }
2586
- function initLiveChatClientInstance(baseUrl, token) {
2587
- const region = token ? getRegion(token) : void 0;
2588
- const headers = livechatClientInstance.defaults.headers;
2589
- if (baseUrl) {
2590
- livechatClientInstance.interceptors.request.use(
2591
- (config) => {
2592
- config.baseURL = baseUrl;
2593
- return config;
2594
- },
2595
- (error) => Promise.reject(error)
2596
- );
2597
- }
2598
- if (region) {
2599
- headers["X-Region"] = region;
2600
- }
2601
- if (token) {
2602
- headers.Authorization = `Bearer ${token}`;
2603
- } else {
2604
- delete headers.Authorization;
2605
- }
2606
- }
2607
-
2608
3041
  // src/apis/products/livechat/agents/api.ts
2609
3042
  var livechatAgentApi = {
2610
3043
  getUser() {
@@ -3047,42 +3480,6 @@ var productsApi = {
3047
3480
  livechat: livechatApi
3048
3481
  };
3049
3482
 
3050
- // src/apis/platform/accounts/instance.ts
3051
- import axios13 from "axios";
3052
- var platformAccountsClientInstance = axios13.create({
3053
- baseURL: "https://accounts.labs.livechatinc.com"
3054
- });
3055
- function getPlatformAccountsClientAuthorization(req) {
3056
- return {
3057
- token: req.headers["platform-accounts-token"]
3058
- };
3059
- }
3060
- function getPlatformAccountsClientConfig(options = {}) {
3061
- const defaultAuthorization = platformAccountsClientInstance.defaults.headers["Authorization"];
3062
- const headers = {
3063
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
3064
- };
3065
- return {
3066
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3067
- };
3068
- }
3069
- function initPlatformAccountsClientInstance(baseUrl, token) {
3070
- if (baseUrl) {
3071
- platformAccountsClientInstance.interceptors.request.use(
3072
- (config) => __async(this, null, function* () {
3073
- config.baseURL = baseUrl;
3074
- return config;
3075
- }),
3076
- (error) => Promise.reject(error)
3077
- );
3078
- }
3079
- if (token) {
3080
- platformAccountsClientInstance.defaults.headers["Authorization"] = `Bearer ${token}`;
3081
- } else {
3082
- delete platformAccountsClientInstance.defaults.headers["Authorization"];
3083
- }
3084
- }
3085
-
3086
3483
  // src/apis/platform/accounts/accounts/api.ts
3087
3484
  var platformAccountsAccountApi = {
3088
3485
  getAccounts(authorization) {
@@ -3493,150 +3890,35 @@ var platformAccountsTokenApi = {
3493
3890
  // src/apis/platform/accounts/api.ts
3494
3891
  var platformAccountsApi = {
3495
3892
  account: platformAccountsAccountApi,
3496
- client: platformAccountsClientApi,
3497
- pat: platformAccountsPersonalAccessTokenApi,
3498
- organization: platformAccountsOrganizationApi,
3499
- products: platformAccountsProductsApi,
3500
- scopes: platformAccountsScopesApi,
3501
- sessions: platformAccountsSessionsApi,
3502
- token: platformAccountsTokenApi
3503
- };
3504
-
3505
- // src/apis/platform/dps/instance.ts
3506
- import axios14 from "axios";
3507
- var platformDpsClientInstance = axios14.create({
3508
- baseURL: "https://dev-platform.labs.livechatinc.com"
3509
- });
3510
- function getPlatformDpsClientAuthorization(req) {
3511
- var _a;
3512
- return {
3513
- token: (_a = req.headers["platform-dps-token"]) != null ? _a : req.headers["platform-token"],
3514
- tokenType: "Bearer"
3515
- };
3516
- }
3517
- function getPlatformDpsAdminClientAuthorization() {
3518
- var _a, _b;
3519
- 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 : "";
3520
- return {
3521
- token: btoa(`apps@livechatinc.com:${token}`),
3522
- tokenType: "Basic"
3523
- };
3524
- }
3525
- function getPlatformDpsClientConfig(options = {}) {
3526
- const currentHeaders = platformDpsClientInstance.defaults.headers;
3527
- const defaultAuthorization = currentHeaders.Authorization;
3528
- const headers = {
3529
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
3530
- };
3531
- return {
3532
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
3533
- };
3534
- }
3535
- function initPlatformDpsClientInstance(baseUrl, token) {
3536
- const headers = platformDpsClientInstance.defaults.headers;
3537
- if (baseUrl) {
3538
- platformDpsClientInstance.interceptors.request.use(
3539
- (config) => {
3540
- config.baseURL = baseUrl;
3541
- return config;
3542
- },
3543
- (error) => Promise.reject(error)
3544
- );
3545
- }
3546
- if (token) {
3547
- headers.Authorization = `Bearer ${token}`;
3548
- } else {
3549
- delete headers.Authorization;
3550
- }
3551
- }
3552
-
3553
- // src/apis/platform/dps/applications/application/authorization/api.ts
3554
- var platformDpsApplicationAuthorizationApi = {
3555
- createAuth(appId, payload, authorization) {
3556
- return __async(this, null, function* () {
3557
- try {
3558
- yield platformDpsClientInstance.post(
3559
- `/v2/applications/${appId}/authorization`,
3560
- payload,
3561
- getPlatformDpsClientConfig(authorization)
3562
- );
3563
- } catch (error) {
3564
- if (error instanceof Error) {
3565
- throw new Error(
3566
- `Authorization couldn't be created. [${error.message}]`
3567
- );
3568
- }
3569
- throw error;
3570
- }
3571
- });
3572
- }
3573
- };
3574
-
3575
- // src/apis/platform/dps/applications/application/autoReview/_contracts/dtos/autoReview.ts
3576
- var getEmptyAppAutoReview = () => ({
3577
- isReviewed: false,
3578
- recommendations: {
3579
- listingDetails: {
3580
- appName: "",
3581
- shortDescription: "",
3582
- longDescription: "",
3583
- features: "",
3584
- benefits: ""
3585
- },
3586
- auth: {
3587
- hasZeroScopes: false
3588
- }
3589
- },
3590
- errors: {
3591
- listingDetails: {
3592
- appName: "",
3593
- shortDescription: "",
3594
- longDescription: "",
3595
- features: "",
3596
- benefits: ""
3597
- },
3598
- auth: {
3599
- hasAllScopes: false,
3600
- isRedirectUriSafe: false
3601
- },
3602
- links: {
3603
- tutorial: {
3604
- returns200: false,
3605
- isValid: false
3606
- },
3607
- privacyPolicy: {
3608
- returns200: false,
3609
- isValid: false
3610
- }
3611
- },
3612
- images: {
3613
- icon: {
3614
- isNsfw: false,
3615
- isRatioValid: false
3616
- },
3617
- screenshots: {
3618
- areNsfw: false,
3619
- areRatiosValid: false
3893
+ client: platformAccountsClientApi,
3894
+ pat: platformAccountsPersonalAccessTokenApi,
3895
+ organization: platformAccountsOrganizationApi,
3896
+ products: platformAccountsProductsApi,
3897
+ scopes: platformAccountsScopesApi,
3898
+ sessions: platformAccountsSessionsApi,
3899
+ token: platformAccountsTokenApi
3900
+ };
3901
+
3902
+ // src/apis/platform/dps/applications/application/authorization/api.ts
3903
+ var platformDpsApplicationAuthorizationApi = {
3904
+ createAuth(appId, payload, authorization) {
3905
+ return __async(this, null, function* () {
3906
+ try {
3907
+ yield platformDpsClientInstance.post(
3908
+ `/v2/applications/${appId}/authorization`,
3909
+ payload,
3910
+ getPlatformDpsClientConfig(authorization)
3911
+ );
3912
+ } catch (error) {
3913
+ if (error instanceof Error) {
3914
+ throw new Error(
3915
+ `Authorization couldn't be created. [${error.message}]`
3916
+ );
3917
+ }
3918
+ throw error;
3620
3919
  }
3621
- }
3920
+ });
3622
3921
  }
3623
- });
3624
-
3625
- // src/apis/platform/dps/applications/application/autoReview/_contracts/payloads/autoReview.ts
3626
- var getAppAutoReviewPayload = (value) => {
3627
- return {
3628
- appName: value,
3629
- shortDescription: value,
3630
- longDescription: value,
3631
- features: value,
3632
- benefits: value,
3633
- scopes: value,
3634
- redirect: value,
3635
- tutorial: value,
3636
- privacyPolicy: value,
3637
- icons: value,
3638
- screenshots: value
3639
- };
3640
3922
  };
3641
3923
 
3642
3924
  // src/apis/platform/dps/applications/application/autoReview/api.ts
@@ -4041,6 +4323,41 @@ var platformDpsApplicationInfrastructureApi = {
4041
4323
 
4042
4324
  // src/apis/platform/dps/applications/application/install/api.ts
4043
4325
  var platformDpsApplicationInstallApi = {
4326
+ install(appId, authorization) {
4327
+ return __async(this, null, function* () {
4328
+ try {
4329
+ yield platformDpsClientInstance.put(
4330
+ `/v2/applications/${appId}/install`,
4331
+ {},
4332
+ getPlatformDpsClientConfig(authorization)
4333
+ );
4334
+ } catch (error) {
4335
+ if (error instanceof Error) {
4336
+ throw new Error(
4337
+ `App couldn't be installed. [${error.message}]`
4338
+ );
4339
+ }
4340
+ throw error;
4341
+ }
4342
+ });
4343
+ },
4344
+ uninstall(appId, authorization) {
4345
+ return __async(this, null, function* () {
4346
+ try {
4347
+ yield platformDpsClientInstance.delete(
4348
+ `/v2/applications/${appId}/install`,
4349
+ getPlatformDpsClientConfig(authorization)
4350
+ );
4351
+ } catch (error) {
4352
+ if (error instanceof Error) {
4353
+ throw new Error(
4354
+ `App couldn't be uninstalled. [${error.message}]`
4355
+ );
4356
+ }
4357
+ throw error;
4358
+ }
4359
+ });
4360
+ },
4044
4361
  updateDirectInstallationUrl(appId, payload, authorization) {
4045
4362
  return __async(this, null, function* () {
4046
4363
  try {
@@ -5084,156 +5401,6 @@ var platformDpsApi = {
5084
5401
  research: platformDpsResearchApi
5085
5402
  };
5086
5403
 
5087
- // src/apis/platform/adapter/instance.ts
5088
- import axios15 from "axios";
5089
- var REGION2 = {
5090
- FRA: "fra",
5091
- DAL: "dal",
5092
- FRA_A: "fra-a",
5093
- FRA_B: "fra-b"
5094
- };
5095
- var supportedRegions2 = Object.values(REGION2);
5096
- var getRegion2 = (token) => {
5097
- const region = token.split(":")[0];
5098
- if (supportedRegions2.includes(region)) {
5099
- return region;
5100
- }
5101
- };
5102
- function getPlatformAdapterClientAuthorization(req) {
5103
- return {
5104
- platform: {
5105
- dps: req.headers["platform-dps-token"]
5106
- },
5107
- github: {
5108
- app: req.headers["github-app-token"],
5109
- oauth: req.headers["github-oauth-token"]
5110
- },
5111
- netlify: req.headers["netlify-token"],
5112
- vercel: req.headers["vercel-token"],
5113
- planetscale: req.headers["planetscale-token"],
5114
- neon: req.headers["neon-token"],
5115
- sentry: req.headers["sentry-token"],
5116
- openai: req.headers["openai-token"]
5117
- };
5118
- }
5119
- var platformAdapterClientInstance = axios15.create({
5120
- baseURL: "https://platform.labs.text.com/console-adapter/api",
5121
- headers: {
5122
- "Content-Type": "application/json"
5123
- }
5124
- });
5125
- platformAdapterClientInstance.interceptors.response.use(
5126
- (r) => r,
5127
- (error) => {
5128
- var _a;
5129
- if (axios15.isAxiosError(error)) {
5130
- if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
5131
- const source = error.response.data.error.source;
5132
- if (source) {
5133
- throw new UnauthorizeApiError(source);
5134
- }
5135
- }
5136
- }
5137
- throw error;
5138
- }
5139
- );
5140
- function getPlatformAdapterClientConfig(options = {}) {
5141
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
5142
- const currentHeaders = platformAdapterClientInstance.defaults.headers;
5143
- const headers = {
5144
- platform: {
5145
- dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
5146
- },
5147
- integrations: {
5148
- github: {
5149
- app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
5150
- oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
5151
- },
5152
- netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
5153
- vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
5154
- planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
5155
- neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
5156
- sentry: (_k = currentHeaders["sentry-token"]) != null ? _k : options.sentry,
5157
- openai: (_l = currentHeaders["openai-token"]) != null ? _l : options.openai
5158
- }
5159
- };
5160
- if (currentHeaders["platform-dps-token"]) {
5161
- currentHeaders["X-Region"] = (_m = getRegion2(currentHeaders["platform-dps-token"])) != null ? _m : void 0;
5162
- }
5163
- if (((_o = (_n = options.ensureAuthorizationToken) == null ? void 0 : _n.platform) == null ? void 0 : _o.dps) && !headers.platform.dps) {
5164
- throw new UnauthorizeApiError("dps");
5165
- }
5166
- if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
5167
- throw new UnauthorizeApiError("github");
5168
- }
5169
- if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.vercel) && !headers.integrations.vercel) {
5170
- throw new UnauthorizeApiError("vercel");
5171
- }
5172
- if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.netlify) && !headers.integrations.netlify) {
5173
- throw new UnauthorizeApiError("netlify");
5174
- }
5175
- if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.planetscale) && !headers.integrations.planetscale) {
5176
- throw new UnauthorizeApiError("planetscale");
5177
- }
5178
- if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.neon) && !headers.integrations.neon) {
5179
- throw new UnauthorizeApiError("neon");
5180
- }
5181
- if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.sentry) && !headers.integrations.sentry) {
5182
- throw new UnauthorizeApiError("sentry");
5183
- }
5184
- if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.openai) && !headers.integrations.openai) {
5185
- throw new UnauthorizeApiError("openai");
5186
- }
5187
- return {
5188
- 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 } : {})
5189
- };
5190
- }
5191
- function initPlatformAdapterClientInstance(baseUrl, tokens) {
5192
- if (baseUrl) {
5193
- platformAdapterClientInstance.interceptors.request.use(
5194
- (config) => {
5195
- config.baseURL = baseUrl;
5196
- return config;
5197
- },
5198
- (error) => Promise.reject(error)
5199
- );
5200
- }
5201
- if (tokens) {
5202
- updatePlatformAdapterClientInstance(tokens);
5203
- }
5204
- }
5205
- function updatePlatformAdapterClientInstance(tokens) {
5206
- var _a, _b, _c;
5207
- const headers = platformAdapterClientInstance.defaults.headers;
5208
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
5209
- headers["platform-dps-token"] = tokens.platform.dps;
5210
- }
5211
- if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
5212
- headers["github-app-token"] = tokens.github.app;
5213
- }
5214
- if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
5215
- headers["github-oauth-token"] = tokens.github.oauth;
5216
- }
5217
- if (tokens == null ? void 0 : tokens.netlify) {
5218
- headers["netlify-token"] = tokens.netlify;
5219
- }
5220
- if (tokens == null ? void 0 : tokens.vercel) {
5221
- headers["vercel-token"] = tokens.vercel;
5222
- }
5223
- if (tokens == null ? void 0 : tokens.planetscale) {
5224
- headers["planetscale-token"] = tokens.planetscale;
5225
- }
5226
- if (tokens == null ? void 0 : tokens.neon) {
5227
- headers["neon-token"] = tokens.neon;
5228
- }
5229
- if (tokens == null ? void 0 : tokens.sentry) {
5230
- headers["sentry-token"] = tokens.sentry;
5231
- }
5232
- if (tokens == null ? void 0 : tokens.openai) {
5233
- headers["openai-token"] = tokens.openai;
5234
- }
5235
- }
5236
-
5237
5404
  // src/apis/platform/adapter/app/blocks/deployment/api.ts
5238
5405
  var platformAdapterAppDeploymentApi = {
5239
5406
  get(appId, authorization) {
@@ -5774,42 +5941,6 @@ var platformAdapterApi = {
5774
5941
  conductor: platformAdapterConductorApi
5775
5942
  };
5776
5943
 
5777
- // src/apis/platform/billing/instance.ts
5778
- import axios16 from "axios";
5779
- var platformBillingClientInstance = axios16.create({
5780
- baseURL: "https://billing.labs.livechatinc.com"
5781
- });
5782
- function getPlatformBillingClientAuthorization(req) {
5783
- return {
5784
- token: req.headers["platform-token"]
5785
- };
5786
- }
5787
- function getPlatformBillingClientConfig(options = {}) {
5788
- const defaultAuthorization = platformBillingClientInstance.defaults.headers.Authorization;
5789
- const headers = {
5790
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
5791
- };
5792
- return {
5793
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5794
- };
5795
- }
5796
- function initPlatformBillingClientInstance(baseUrl, token) {
5797
- if (baseUrl) {
5798
- platformBillingClientInstance.interceptors.request.use(
5799
- (config) => __async(this, null, function* () {
5800
- config.baseURL = baseUrl;
5801
- return config;
5802
- }),
5803
- (error) => Promise.reject(error)
5804
- );
5805
- }
5806
- if (token) {
5807
- platformBillingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
5808
- } else {
5809
- delete platformBillingClientInstance.defaults.headers.Authorization;
5810
- }
5811
- }
5812
-
5813
5944
  // src/apis/platform/billing/account/api.ts
5814
5945
  var platformBillingAccountApi = {
5815
5946
  getAccount(authorization) {
@@ -5995,7 +6126,7 @@ export {
5995
6126
  getPlatformDpsAdminClientAuthorization,
5996
6127
  getPlatformDpsClientAuthorization,
5997
6128
  getPlatformDpsClientConfig,
5998
- getRegion,
6129
+ getRegion2 as getRegion,
5999
6130
  getSentryClientAuthorization,
6000
6131
  getSentryClientConfig,
6001
6132
  getTextClientAuthorization,