@livechat/developer-studio-api 2.3.51 → 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";
@@ -2392,28 +2392,420 @@ function getNeonClientAuthorization(req) {
2392
2392
  token: req.headers["neon-token"]
2393
2393
  };
2394
2394
  }
2395
- function getNeonClientConfig(options = {}) {
2396
- const currentHeaders = neonClientInstance.defaults.headers;
2395
+ function getNeonClientConfig(options = {}) {
2396
+ const currentHeaders = neonClientInstance.defaults.headers;
2397
+ const defaultAuthorization = currentHeaders.Authorization;
2398
+ const headers = {
2399
+ authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2400
+ };
2401
+ if (options.ensureAuthorizationToken && !headers.authorization) {
2402
+ throw new UnauthorizeApiError("neon");
2403
+ }
2404
+ return {
2405
+ headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2406
+ };
2407
+ }
2408
+ function initNeonClientInstance(token) {
2409
+ if (token) {
2410
+ updateNeonClientInstance(token);
2411
+ }
2412
+ }
2413
+ function updateNeonClientInstance(token) {
2414
+ const headers = neonClientInstance.defaults.headers;
2415
+ if (token) {
2416
+ headers.Authorization = `${token}`;
2417
+ } else {
2418
+ delete headers.Authorization;
2419
+ }
2420
+ }
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;
2397
2784
  const defaultAuthorization = currentHeaders.Authorization;
2398
2785
  const headers = {
2399
2786
  authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
2400
2787
  };
2401
- if (options.ensureAuthorizationToken && !headers.authorization) {
2402
- throw new UnauthorizeApiError("neon");
2403
- }
2404
2788
  return {
2405
2789
  headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
2406
2790
  };
2407
2791
  }
2408
- function initNeonClientInstance(token) {
2409
- if (token) {
2410
- updateNeonClientInstance(token);
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;
2411
2806
  }
2412
- }
2413
- function updateNeonClientInstance(token) {
2414
- const headers = neonClientInstance.defaults.headers;
2415
2807
  if (token) {
2416
- headers.Authorization = `${token}`;
2808
+ headers.Authorization = `Bearer ${token}`;
2417
2809
  } else {
2418
2810
  delete headers.Authorization;
2419
2811
  }
@@ -2421,20 +2813,88 @@ function updateNeonClientInstance(token) {
2421
2813
 
2422
2814
  // src/apis/integrations/neon/project/branch/api.ts
2423
2815
  var neonProjectBranchApi = {
2424
- getBranch(projectId, branchId, authorization) {
2816
+ getBranches(projectId, authorization) {
2425
2817
  return __async(this, null, function* () {
2426
2818
  const response = yield neonClientInstance.get(
2427
- `projects/${projectId}/branches/${branchId}`,
2428
- getNeonClientConfig(__spreadValues({}, authorization))
2819
+ `projects/${projectId}/branches`,
2820
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2821
+ ensureAuthorizationToken: true
2822
+ }))
2429
2823
  );
2430
2824
  return response.data;
2431
2825
  });
2432
2826
  },
2433
- getBranches(projectId, authorization) {
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) {
2434
2856
  return __async(this, null, function* () {
2435
2857
  const response = yield neonClientInstance.get(
2436
- `projects/${projectId}/branches`,
2437
- getNeonClientConfig(__spreadValues({}, authorization))
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) {
2881
+ return __async(this, null, function* () {
2882
+ const response = yield neonClientInstance.get(
2883
+ `projects/${projectId}/branches/${branchId}/roles/${roleName}/reveal_password`,
2884
+ getNeonClientConfig(__spreadProps(__spreadValues({}, authorization), {
2885
+ ensureAuthorizationToken: true
2886
+ }))
2887
+ );
2888
+ return response.data;
2889
+ });
2890
+ },
2891
+ getBranchEndpoints(projectId, branchId, authorization) {
2892
+ return __async(this, null, function* () {
2893
+ const response = yield neonClientInstance.get(
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) {
@@ -3494,61 +3891,13 @@ var platformAccountsTokenApi = {
3494
3891
  var platformAccountsApi = {
3495
3892
  account: platformAccountsAccountApi,
3496
3893
  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
- }
3894
+ pat: platformAccountsPersonalAccessTokenApi,
3895
+ organization: platformAccountsOrganizationApi,
3896
+ products: platformAccountsProductsApi,
3897
+ scopes: platformAccountsScopesApi,
3898
+ sessions: platformAccountsSessionsApi,
3899
+ token: platformAccountsTokenApi
3900
+ };
3552
3901
 
3553
3902
  // src/apis/platform/dps/applications/application/authorization/api.ts
3554
3903
  var platformDpsApplicationAuthorizationApi = {
@@ -3572,73 +3921,6 @@ var platformDpsApplicationAuthorizationApi = {
3572
3921
  }
3573
3922
  };
3574
3923
 
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
3620
- }
3621
- }
3622
- }
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
- };
3641
-
3642
3924
  // src/apis/platform/dps/applications/application/autoReview/api.ts
3643
3925
  var platformDpsApplicationAutoReviewApi = {
3644
3926
  getAutoReview(appId, authorization) {
@@ -5119,156 +5401,6 @@ var platformDpsApi = {
5119
5401
  research: platformDpsResearchApi
5120
5402
  };
5121
5403
 
5122
- // src/apis/platform/adapter/instance.ts
5123
- import axios15 from "axios";
5124
- var REGION2 = {
5125
- FRA: "fra",
5126
- DAL: "dal",
5127
- FRA_A: "fra-a",
5128
- FRA_B: "fra-b"
5129
- };
5130
- var supportedRegions2 = Object.values(REGION2);
5131
- var getRegion2 = (token) => {
5132
- const region = token.split(":")[0];
5133
- if (supportedRegions2.includes(region)) {
5134
- return region;
5135
- }
5136
- };
5137
- function getPlatformAdapterClientAuthorization(req) {
5138
- return {
5139
- platform: {
5140
- dps: req.headers["platform-dps-token"]
5141
- },
5142
- github: {
5143
- app: req.headers["github-app-token"],
5144
- oauth: req.headers["github-oauth-token"]
5145
- },
5146
- netlify: req.headers["netlify-token"],
5147
- vercel: req.headers["vercel-token"],
5148
- planetscale: req.headers["planetscale-token"],
5149
- neon: req.headers["neon-token"],
5150
- sentry: req.headers["sentry-token"],
5151
- openai: req.headers["openai-token"]
5152
- };
5153
- }
5154
- var platformAdapterClientInstance = axios15.create({
5155
- baseURL: "https://platform.labs.text.com/console-adapter/api",
5156
- headers: {
5157
- "Content-Type": "application/json"
5158
- }
5159
- });
5160
- platformAdapterClientInstance.interceptors.response.use(
5161
- (r) => r,
5162
- (error) => {
5163
- var _a;
5164
- if (axios15.isAxiosError(error)) {
5165
- if (((_a = error.response) == null ? void 0 : _a.status) === 401) {
5166
- const source = error.response.data.error.source;
5167
- if (source) {
5168
- throw new UnauthorizeApiError(source);
5169
- }
5170
- }
5171
- }
5172
- throw error;
5173
- }
5174
- );
5175
- function getPlatformAdapterClientConfig(options = {}) {
5176
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
5177
- const currentHeaders = platformAdapterClientInstance.defaults.headers;
5178
- const headers = {
5179
- platform: {
5180
- dps: (_b = currentHeaders["platform-dps-token"]) != null ? _b : (_a = options.platform) == null ? void 0 : _a.dps
5181
- },
5182
- integrations: {
5183
- github: {
5184
- app: (_d = currentHeaders["github-app-token"]) != null ? _d : (_c = options.github) == null ? void 0 : _c.app,
5185
- oauth: (_f = currentHeaders["github-oauth-token"]) != null ? _f : (_e = options.github) == null ? void 0 : _e.oauth
5186
- },
5187
- netlify: (_g = currentHeaders["netlify-token"]) != null ? _g : options.netlify,
5188
- vercel: (_h = currentHeaders["vercel-token"]) != null ? _h : options.vercel,
5189
- planetscale: (_i = currentHeaders["planetscale-token"]) != null ? _i : options.planetscale,
5190
- neon: (_j = currentHeaders["neon-token"]) != null ? _j : options.neon,
5191
- sentry: (_k = currentHeaders["sentry-token"]) != null ? _k : options.sentry,
5192
- openai: (_l = currentHeaders["openai-token"]) != null ? _l : options.openai
5193
- }
5194
- };
5195
- if (currentHeaders["platform-dps-token"]) {
5196
- currentHeaders["X-Region"] = (_m = getRegion2(currentHeaders["platform-dps-token"])) != null ? _m : void 0;
5197
- }
5198
- if (((_o = (_n = options.ensureAuthorizationToken) == null ? void 0 : _n.platform) == null ? void 0 : _o.dps) && !headers.platform.dps) {
5199
- throw new UnauthorizeApiError("dps");
5200
- }
5201
- if (((_p = options.ensureAuthorizationToken) == null ? void 0 : _p.github) && (!headers.integrations.github.app || !headers.integrations.github.oauth)) {
5202
- throw new UnauthorizeApiError("github");
5203
- }
5204
- if (((_q = options.ensureAuthorizationToken) == null ? void 0 : _q.vercel) && !headers.integrations.vercel) {
5205
- throw new UnauthorizeApiError("vercel");
5206
- }
5207
- if (((_r = options.ensureAuthorizationToken) == null ? void 0 : _r.netlify) && !headers.integrations.netlify) {
5208
- throw new UnauthorizeApiError("netlify");
5209
- }
5210
- if (((_s = options.ensureAuthorizationToken) == null ? void 0 : _s.planetscale) && !headers.integrations.planetscale) {
5211
- throw new UnauthorizeApiError("planetscale");
5212
- }
5213
- if (((_t = options.ensureAuthorizationToken) == null ? void 0 : _t.neon) && !headers.integrations.neon) {
5214
- throw new UnauthorizeApiError("neon");
5215
- }
5216
- if (((_u = options.ensureAuthorizationToken) == null ? void 0 : _u.sentry) && !headers.integrations.sentry) {
5217
- throw new UnauthorizeApiError("sentry");
5218
- }
5219
- if (((_v = options.ensureAuthorizationToken) == null ? void 0 : _v.openai) && !headers.integrations.openai) {
5220
- throw new UnauthorizeApiError("openai");
5221
- }
5222
- return {
5223
- 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 } : {})
5224
- };
5225
- }
5226
- function initPlatformAdapterClientInstance(baseUrl, tokens) {
5227
- if (baseUrl) {
5228
- platformAdapterClientInstance.interceptors.request.use(
5229
- (config) => {
5230
- config.baseURL = baseUrl;
5231
- return config;
5232
- },
5233
- (error) => Promise.reject(error)
5234
- );
5235
- }
5236
- if (tokens) {
5237
- updatePlatformAdapterClientInstance(tokens);
5238
- }
5239
- }
5240
- function updatePlatformAdapterClientInstance(tokens) {
5241
- var _a, _b, _c;
5242
- const headers = platformAdapterClientInstance.defaults.headers;
5243
- if ((_a = tokens == null ? void 0 : tokens.platform) == null ? void 0 : _a.dps) {
5244
- headers["platform-dps-token"] = tokens.platform.dps;
5245
- }
5246
- if ((_b = tokens == null ? void 0 : tokens.github) == null ? void 0 : _b.app) {
5247
- headers["github-app-token"] = tokens.github.app;
5248
- }
5249
- if ((_c = tokens == null ? void 0 : tokens.github) == null ? void 0 : _c.oauth) {
5250
- headers["github-oauth-token"] = tokens.github.oauth;
5251
- }
5252
- if (tokens == null ? void 0 : tokens.netlify) {
5253
- headers["netlify-token"] = tokens.netlify;
5254
- }
5255
- if (tokens == null ? void 0 : tokens.vercel) {
5256
- headers["vercel-token"] = tokens.vercel;
5257
- }
5258
- if (tokens == null ? void 0 : tokens.planetscale) {
5259
- headers["planetscale-token"] = tokens.planetscale;
5260
- }
5261
- if (tokens == null ? void 0 : tokens.neon) {
5262
- headers["neon-token"] = tokens.neon;
5263
- }
5264
- if (tokens == null ? void 0 : tokens.sentry) {
5265
- headers["sentry-token"] = tokens.sentry;
5266
- }
5267
- if (tokens == null ? void 0 : tokens.openai) {
5268
- headers["openai-token"] = tokens.openai;
5269
- }
5270
- }
5271
-
5272
5404
  // src/apis/platform/adapter/app/blocks/deployment/api.ts
5273
5405
  var platformAdapterAppDeploymentApi = {
5274
5406
  get(appId, authorization) {
@@ -5809,42 +5941,6 @@ var platformAdapterApi = {
5809
5941
  conductor: platformAdapterConductorApi
5810
5942
  };
5811
5943
 
5812
- // src/apis/platform/billing/instance.ts
5813
- import axios16 from "axios";
5814
- var platformBillingClientInstance = axios16.create({
5815
- baseURL: "https://billing.labs.livechatinc.com"
5816
- });
5817
- function getPlatformBillingClientAuthorization(req) {
5818
- return {
5819
- token: req.headers["platform-token"]
5820
- };
5821
- }
5822
- function getPlatformBillingClientConfig(options = {}) {
5823
- const defaultAuthorization = platformBillingClientInstance.defaults.headers.Authorization;
5824
- const headers = {
5825
- authorization: defaultAuthorization != null ? defaultAuthorization : options.token ? `Bearer ${options.token}` : void 0
5826
- };
5827
- return {
5828
- headers: __spreadValues({}, headers.authorization ? { Authorization: headers.authorization } : {})
5829
- };
5830
- }
5831
- function initPlatformBillingClientInstance(baseUrl, token) {
5832
- if (baseUrl) {
5833
- platformBillingClientInstance.interceptors.request.use(
5834
- (config) => __async(this, null, function* () {
5835
- config.baseURL = baseUrl;
5836
- return config;
5837
- }),
5838
- (error) => Promise.reject(error)
5839
- );
5840
- }
5841
- if (token) {
5842
- platformBillingClientInstance.defaults.headers.Authorization = `Bearer ${token}`;
5843
- } else {
5844
- delete platformBillingClientInstance.defaults.headers.Authorization;
5845
- }
5846
- }
5847
-
5848
5944
  // src/apis/platform/billing/account/api.ts
5849
5945
  var platformBillingAccountApi = {
5850
5946
  getAccount(authorization) {
@@ -6030,7 +6126,7 @@ export {
6030
6126
  getPlatformDpsAdminClientAuthorization,
6031
6127
  getPlatformDpsClientAuthorization,
6032
6128
  getPlatformDpsClientConfig,
6033
- getRegion,
6129
+ getRegion2 as getRegion,
6034
6130
  getSentryClientAuthorization,
6035
6131
  getSentryClientConfig,
6036
6132
  getTextClientAuthorization,