@shuffleio/shuffle-mcps 0.0.60 → 0.0.64
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/analytics-JGBV375U.mjs +20 -0
- package/dist/{appsCache-VD3DQH53.mjs → appsCache-A4OIDXIN.mjs} +2 -1
- package/dist/auth-utils-HYVXQKTL.mjs +12 -0
- package/dist/chunk-2NCPSII6.mjs +105 -0
- package/dist/{chunk-7HRNENGV.mjs → chunk-2PFFYHRO.mjs} +16 -60
- package/dist/chunk-C7HCHOHU.mjs +1208 -0
- package/dist/chunk-PL74JBB4.mjs +64 -0
- package/dist/chunk-TUSSDUVQ.mjs +155 -0
- package/dist/datastore-TTQFTTDP.mjs +27 -0
- package/dist/index.d.mts +65 -1
- package/dist/index.d.ts +65 -1
- package/dist/index.js +69037 -14115
- package/dist/index.mjs +62952 -8680
- package/dist/shuffle-core-LIQTRTFD.css +169 -0
- package/dist/{shuffle-mcp-E56K3LGU.css → shuffle-mcp-LXISGW4I.css} +1 -2
- package/package.json +9 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GA_EVENTS,
|
|
3
|
+
initAnalytics,
|
|
4
|
+
trackCTA,
|
|
5
|
+
trackEvent,
|
|
6
|
+
trackOnboardingStep,
|
|
7
|
+
trackPageView,
|
|
8
|
+
trackPredefinedEvent,
|
|
9
|
+
trackReferralParams
|
|
10
|
+
} from "./chunk-TUSSDUVQ.mjs";
|
|
11
|
+
export {
|
|
12
|
+
GA_EVENTS,
|
|
13
|
+
initAnalytics,
|
|
14
|
+
trackCTA,
|
|
15
|
+
trackEvent,
|
|
16
|
+
trackOnboardingStep,
|
|
17
|
+
trackPageView,
|
|
18
|
+
trackPredefinedEvent,
|
|
19
|
+
trackReferralParams
|
|
20
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// ../Shuffle-Core/auth-utils.ts
|
|
2
|
+
var THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
3
|
+
function isValidationFresh(validation) {
|
|
4
|
+
if (validation?.valid !== true) return false;
|
|
5
|
+
if (!validation.last_valid) return true;
|
|
6
|
+
const cutoff = Date.now() - THIRTY_DAYS_MS;
|
|
7
|
+
const lastValidMs = validation.last_valid > 1e12 ? validation.last_valid : validation.last_valid * 1e3;
|
|
8
|
+
return lastValidMs >= cutoff;
|
|
9
|
+
}
|
|
10
|
+
function deduplicateAuthApps(apps) {
|
|
11
|
+
const appMap = /* @__PURE__ */ new Map();
|
|
12
|
+
apps.forEach((auth) => {
|
|
13
|
+
if (!auth.app?.name) return;
|
|
14
|
+
if (!auth.active && !isValidationFresh(auth.validation)) return;
|
|
15
|
+
const normalizedName = auth.app.name.toLowerCase().trim().replace(/[\s_\-]+/g, "_");
|
|
16
|
+
const existing = appMap.get(normalizedName);
|
|
17
|
+
const isValidated = isValidationFresh(auth.validation);
|
|
18
|
+
const entryImage = auth.app.large_image || "";
|
|
19
|
+
const instance = {
|
|
20
|
+
label: auth.label || auth.id || "Default",
|
|
21
|
+
isValidated
|
|
22
|
+
};
|
|
23
|
+
if (!existing) {
|
|
24
|
+
appMap.set(normalizedName, {
|
|
25
|
+
app: auth.app,
|
|
26
|
+
hasValidAuth: isValidated,
|
|
27
|
+
bestImage: entryImage,
|
|
28
|
+
instances: [instance]
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
existing.instances.push(instance);
|
|
32
|
+
if (isValidated) existing.hasValidAuth = true;
|
|
33
|
+
if (!existing.bestImage && entryImage) existing.bestImage = entryImage;
|
|
34
|
+
if (isValidated && !existing.app.large_image && entryImage) {
|
|
35
|
+
existing.app = { ...existing.app, large_image: entryImage };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return Array.from(appMap.values());
|
|
40
|
+
}
|
|
41
|
+
var _imageCache = /* @__PURE__ */ new Map();
|
|
42
|
+
var _pendingLookups = /* @__PURE__ */ new Map();
|
|
43
|
+
var _normalize = (n) => n.toLowerCase().replace(/[\s_\-]+/g, "_");
|
|
44
|
+
function seedImageCache(appName, imageUrl) {
|
|
45
|
+
if (appName && imageUrl) _imageCache.set(_normalize(appName), imageUrl);
|
|
46
|
+
}
|
|
47
|
+
async function backfillAppImages(dedupedApps) {
|
|
48
|
+
for (const d of dedupedApps) {
|
|
49
|
+
const norm = _normalize(d.app.name);
|
|
50
|
+
const existingImg = d.bestImage || d.app.large_image;
|
|
51
|
+
if (existingImg) {
|
|
52
|
+
_imageCache.set(norm, existingImg);
|
|
53
|
+
} else if (_imageCache.has(norm)) {
|
|
54
|
+
const cached = _imageCache.get(norm);
|
|
55
|
+
if (cached) {
|
|
56
|
+
d.bestImage = cached;
|
|
57
|
+
d.app = { ...d.app, large_image: cached };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const missing = dedupedApps.filter((d) => !d.bestImage && !d.app.large_image && !_imageCache.has(_normalize(d.app.name)));
|
|
62
|
+
if (missing.length === 0) return dedupedApps;
|
|
63
|
+
try {
|
|
64
|
+
const { algoliasearch } = await import("algoliasearch");
|
|
65
|
+
const client = algoliasearch("JNSS5CFDZZ", "33e4e3564f4f060e96e0531957bed552");
|
|
66
|
+
await Promise.all(missing.map(async (entry) => {
|
|
67
|
+
const norm = _normalize(entry.app.name);
|
|
68
|
+
if (!_pendingLookups.has(norm)) {
|
|
69
|
+
_pendingLookups.set(norm, (async () => {
|
|
70
|
+
try {
|
|
71
|
+
const result = await client.searchSingleIndex({
|
|
72
|
+
indexName: "appsearch",
|
|
73
|
+
searchParams: { query: entry.app.name, hitsPerPage: 3 }
|
|
74
|
+
});
|
|
75
|
+
const match = result.hits.find(
|
|
76
|
+
(h) => _normalize(h.name || "") === norm
|
|
77
|
+
);
|
|
78
|
+
const url2 = match?.image_url || "";
|
|
79
|
+
_imageCache.set(norm, url2);
|
|
80
|
+
return url2;
|
|
81
|
+
} catch {
|
|
82
|
+
_imageCache.set(norm, "");
|
|
83
|
+
return null;
|
|
84
|
+
} finally {
|
|
85
|
+
_pendingLookups.delete(norm);
|
|
86
|
+
}
|
|
87
|
+
})());
|
|
88
|
+
}
|
|
89
|
+
const url = await _pendingLookups.get(norm);
|
|
90
|
+
if (url) {
|
|
91
|
+
entry.bestImage = url;
|
|
92
|
+
entry.app = { ...entry.app, large_image: url };
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
} catch {
|
|
96
|
+
}
|
|
97
|
+
return dedupedApps;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
isValidationFresh,
|
|
102
|
+
deduplicateAuthApps,
|
|
103
|
+
seedImageCache,
|
|
104
|
+
backfillAppImages
|
|
105
|
+
};
|
|
@@ -552,6 +552,12 @@ var isCapacitorNative = () => {
|
|
|
552
552
|
const cap = window.Capacitor;
|
|
553
553
|
return Boolean(cap?.isNativePlatform && cap.isNativePlatform());
|
|
554
554
|
};
|
|
555
|
+
var isIos = () => {
|
|
556
|
+
return getPlatform() === "ios";
|
|
557
|
+
};
|
|
558
|
+
var isAndroid = () => {
|
|
559
|
+
return getPlatform() === "android";
|
|
560
|
+
};
|
|
555
561
|
var isIosWebView = () => {
|
|
556
562
|
if (typeof window === "undefined") return false;
|
|
557
563
|
const cap = window.Capacitor;
|
|
@@ -813,7 +819,8 @@ var resetRegionUrl = () => {
|
|
|
813
819
|
};
|
|
814
820
|
var SHUFFLE_HOST_BASE_URL_EVENT = "shuffle:set-host-base-url";
|
|
815
821
|
var setHostBaseUrl = (url) => {
|
|
816
|
-
|
|
822
|
+
let next = url ? url.replace(/\/+$/, "") : null;
|
|
823
|
+
if (next && isShuffleCloudDomain(next) && !isDevEnvironment()) next = null;
|
|
817
824
|
if (next === _hostBaseUrl) return;
|
|
818
825
|
_hostBaseUrl = next;
|
|
819
826
|
if (next) {
|
|
@@ -996,67 +1003,18 @@ var hasShuffleAuth = () => {
|
|
|
996
1003
|
}
|
|
997
1004
|
};
|
|
998
1005
|
|
|
999
|
-
// appsCache.ts
|
|
1000
|
-
var TTL_MS = 3e4;
|
|
1001
|
-
var ERROR_TTL_MS = 3e4;
|
|
1002
|
-
var cache = /* @__PURE__ */ new Map();
|
|
1003
|
-
var cacheKey = (o) => `${o.baseUrl}|${o.path || "/api/v1/apps"}|${o.apiKey || ""}|${o.orgId || ""}`;
|
|
1004
|
-
var doFetch = async (o) => {
|
|
1005
|
-
const headers = {
|
|
1006
|
-
...getAuthHeader(o.orgId || void 0)
|
|
1007
|
-
};
|
|
1008
|
-
if (o.apiKey) headers["Authorization"] = `Bearer ${o.apiKey}`;
|
|
1009
|
-
if (o.orgId) headers["Org-Id"] = o.orgId;
|
|
1010
|
-
const response = await fetch(`${o.baseUrl}${o.path || "/api/v1/apps"}`, {
|
|
1011
|
-
credentials: "include",
|
|
1012
|
-
headers
|
|
1013
|
-
});
|
|
1014
|
-
if (!response.ok) return [];
|
|
1015
|
-
const data = await response.json();
|
|
1016
|
-
if (Array.isArray(data)) return data;
|
|
1017
|
-
return Array.isArray(data?.data) ? data.data : [];
|
|
1018
|
-
};
|
|
1019
|
-
var fetchApps = (opts) => {
|
|
1020
|
-
const key = cacheKey(opts);
|
|
1021
|
-
const entry = cache.get(key) || {};
|
|
1022
|
-
if (entry.data && entry.fetchedAt && Date.now() - entry.fetchedAt < TTL_MS) {
|
|
1023
|
-
return Promise.resolve(entry.data);
|
|
1024
|
-
}
|
|
1025
|
-
if (entry.promise) return entry.promise;
|
|
1026
|
-
const promise = doFetch(opts).then((data) => {
|
|
1027
|
-
cache.set(key, { data, fetchedAt: Date.now() });
|
|
1028
|
-
return data;
|
|
1029
|
-
}).catch(() => {
|
|
1030
|
-
cache.set(key, { data: [], fetchedAt: Date.now() - (TTL_MS - ERROR_TTL_MS) });
|
|
1031
|
-
return [];
|
|
1032
|
-
});
|
|
1033
|
-
cache.set(key, { ...entry, promise });
|
|
1034
|
-
return promise;
|
|
1035
|
-
};
|
|
1036
|
-
var invalidateAppsCache = (opts) => {
|
|
1037
|
-
if (!opts) {
|
|
1038
|
-
cache.clear();
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
cache.delete(cacheKey(opts));
|
|
1042
|
-
};
|
|
1043
|
-
var fetchAppsViaApiConfig = () => {
|
|
1044
|
-
const headers = getAuthHeader();
|
|
1045
|
-
const orgId = headers["Org-Id"] || null;
|
|
1046
|
-
return fetchApps({
|
|
1047
|
-
baseUrl: API_CONFIG.baseUrl,
|
|
1048
|
-
apiKey: API_CONFIG.apiKey,
|
|
1049
|
-
orgId
|
|
1050
|
-
});
|
|
1051
|
-
};
|
|
1052
|
-
|
|
1053
1006
|
export {
|
|
1054
|
-
resolveProductLink,
|
|
1055
1007
|
registerProtectedOrigin,
|
|
1056
1008
|
installFetchBreaker,
|
|
1009
|
+
resolveProductLink,
|
|
1057
1010
|
isCapacitorNative,
|
|
1011
|
+
isIos,
|
|
1012
|
+
isAndroid,
|
|
1013
|
+
isIosWebView,
|
|
1014
|
+
isAndroidWebView,
|
|
1058
1015
|
isShuffleCloudDomain,
|
|
1059
1016
|
mapCloudRegionUrl,
|
|
1017
|
+
isDevEnvironment,
|
|
1060
1018
|
isCloudDomain,
|
|
1061
1019
|
isCloud,
|
|
1062
1020
|
isOnprem,
|
|
@@ -1066,13 +1024,11 @@ export {
|
|
|
1066
1024
|
setHostBaseUrl,
|
|
1067
1025
|
getHostBaseUrl,
|
|
1068
1026
|
getTrackedOrgId,
|
|
1027
|
+
getSessionToken,
|
|
1069
1028
|
isShuffleSecurityBackend,
|
|
1070
1029
|
API_CONFIG,
|
|
1071
1030
|
getApiUrl,
|
|
1072
1031
|
shuffleFetch,
|
|
1073
1032
|
getAuthHeader,
|
|
1074
|
-
hasShuffleAuth
|
|
1075
|
-
fetchApps,
|
|
1076
|
-
invalidateAppsCache,
|
|
1077
|
-
fetchAppsViaApiConfig
|
|
1033
|
+
hasShuffleAuth
|
|
1078
1034
|
};
|