@shuffleio/shuffle-mcps 0.0.63 → 0.0.65

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.
@@ -2,8 +2,7 @@ import {
2
2
  fetchApps,
3
3
  fetchAppsViaApiConfig,
4
4
  invalidateAppsCache
5
- } from "./chunk-DSJHIKBO.mjs";
6
- import "./chunk-XNE7PKME.mjs";
5
+ } from "./chunk-V3R4HDJT.mjs";
7
6
  export {
8
7
  fetchApps,
9
8
  fetchAppsViaApiConfig,
@@ -1,4 +1,4 @@
1
- // fetchBreaker.ts
1
+ // ../Shuffle-Core/fetchBreaker.ts
2
2
  var rewriteShufflerApiToShuffleSecurity = (input) => {
3
3
  if (typeof window === "undefined") return input;
4
4
  const currentHost = window.location.hostname.toLowerCase();
@@ -148,7 +148,11 @@ var synthetic503 = (key, retryInMs) => new Response(
148
148
  {
149
149
  status: 503,
150
150
  statusText: "Service Unavailable (circuit breaker)",
151
- headers: { "Content-Type": "application/json", "Retry-After": String(Math.ceil(retryInMs / 1e3)) }
151
+ headers: {
152
+ "Content-Type": "application/json",
153
+ "Retry-After": String(Math.ceil(retryInMs / 1e3)),
154
+ "X-Circuit-Breaker": "open"
155
+ }
152
156
  }
153
157
  );
154
158
  var registerProtectedOrigin = (url) => {
@@ -552,12 +556,6 @@ var isCapacitorNative = () => {
552
556
  const cap = window.Capacitor;
553
557
  return Boolean(cap?.isNativePlatform && cap.isNativePlatform());
554
558
  };
555
- var isIos = () => {
556
- return getPlatform() === "ios";
557
- };
558
- var isAndroid = () => {
559
- return getPlatform() === "android";
560
- };
561
559
  var isIosWebView = () => {
562
560
  if (typeof window === "undefined") return false;
563
561
  const cap = window.Capacitor;
@@ -589,7 +587,7 @@ if (typeof window !== "undefined") {
589
587
  window.getPlatform = getPlatform;
590
588
  }
591
589
 
592
- // api.ts
590
+ // ../Shuffle-Core/api.ts
593
591
  installFetchBreaker();
594
592
  var DEV_BACKEND = "https://tunnel.schemaless.org";
595
593
  var PROD_BACKEND = "https://uk.shuffle.security";
@@ -1003,18 +1001,66 @@ var hasShuffleAuth = () => {
1003
1001
  }
1004
1002
  };
1005
1003
 
1004
+ // ../Shuffle-Core/appsCache.ts
1005
+ var TTL_MS = 3e4;
1006
+ var ERROR_TTL_MS = 3e4;
1007
+ var cache = /* @__PURE__ */ new Map();
1008
+ var cacheKey = (o) => `${o.baseUrl}|${o.path || "/api/v1/apps"}|${o.apiKey || ""}|${o.orgId || ""}`;
1009
+ var doFetch = async (o) => {
1010
+ const headers = {
1011
+ ...getAuthHeader(o.orgId || void 0)
1012
+ };
1013
+ if (o.apiKey) headers["Authorization"] = `Bearer ${o.apiKey}`;
1014
+ if (o.orgId) headers["Org-Id"] = o.orgId;
1015
+ const response = await fetch(`${o.baseUrl}${o.path || "/api/v1/apps"}`, {
1016
+ credentials: "include",
1017
+ headers
1018
+ });
1019
+ if (!response.ok) return [];
1020
+ const data = await response.json();
1021
+ if (Array.isArray(data)) return data;
1022
+ return Array.isArray(data?.data) ? data.data : [];
1023
+ };
1024
+ var fetchApps = (opts) => {
1025
+ const key = cacheKey(opts);
1026
+ const entry = cache.get(key) || {};
1027
+ if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS) {
1028
+ return Promise.resolve(entry.data);
1029
+ }
1030
+ if (entry.promise) return entry.promise;
1031
+ const promise = doFetch(opts).then((data) => {
1032
+ cache.set(key, { data, fetchedAt: Date.now() });
1033
+ return data;
1034
+ }).catch(() => {
1035
+ cache.set(key, { data: [], fetchedAt: Date.now() - (TTL_MS - ERROR_TTL_MS) });
1036
+ return [];
1037
+ });
1038
+ cache.set(key, { ...entry, promise });
1039
+ return promise;
1040
+ };
1041
+ var invalidateAppsCache = (opts) => {
1042
+ if (!opts) {
1043
+ cache.clear();
1044
+ return;
1045
+ }
1046
+ cache.delete(cacheKey(opts));
1047
+ };
1048
+ var fetchAppsViaApiConfig = () => {
1049
+ const headers = getAuthHeader();
1050
+ const orgId = headers["Org-Id"] || null;
1051
+ return fetchApps({
1052
+ baseUrl: API_CONFIG.baseUrl,
1053
+ apiKey: API_CONFIG.apiKey,
1054
+ orgId
1055
+ });
1056
+ };
1057
+
1006
1058
  export {
1007
- resolveProductLink,
1008
1059
  registerProtectedOrigin,
1009
1060
  installFetchBreaker,
1010
- isCapacitorNative,
1011
- isIos,
1012
- isAndroid,
1013
- isIosWebView,
1014
- isAndroidWebView,
1061
+ resolveProductLink,
1015
1062
  isShuffleCloudDomain,
1016
1063
  mapCloudRegionUrl,
1017
- isDevEnvironment,
1018
1064
  isCloudDomain,
1019
1065
  isCloud,
1020
1066
  isOnprem,
@@ -1030,5 +1076,8 @@ export {
1030
1076
  getApiUrl,
1031
1077
  shuffleFetch,
1032
1078
  getAuthHeader,
1033
- hasShuffleAuth
1079
+ hasShuffleAuth,
1080
+ fetchApps,
1081
+ invalidateAppsCache,
1082
+ fetchAppsViaApiConfig
1034
1083
  };