@apify/actors-mcp-server 0.9.20-beta.0 → 0.9.20-beta.10
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/const.d.ts +1 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +3 -0
- package/dist/const.js.map +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/tools/core/call_actor_common.d.ts +45 -0
- package/dist/tools/core/call_actor_common.d.ts.map +1 -1
- package/dist/tools/core/call_actor_common.js +148 -13
- package/dist/tools/core/call_actor_common.js.map +1 -1
- package/dist/tools/core/fetch_actor_details_common.d.ts +62 -1
- package/dist/tools/core/fetch_actor_details_common.d.ts.map +1 -1
- package/dist/tools/core/fetch_actor_details_common.js +168 -2
- package/dist/tools/core/fetch_actor_details_common.js.map +1 -1
- package/dist/tools/core/get_actor_run_common.d.ts +11 -0
- package/dist/tools/core/get_actor_run_common.d.ts.map +1 -1
- package/dist/tools/core/get_actor_run_common.js +40 -1
- package/dist/tools/core/get_actor_run_common.js.map +1 -1
- package/dist/tools/core/search_actors_common.d.ts +12 -2
- package/dist/tools/core/search_actors_common.d.ts.map +1 -1
- package/dist/tools/core/search_actors_common.js +26 -16
- package/dist/tools/core/search_actors_common.js.map +1 -1
- package/dist/tools/default/call_actor.d.ts.map +1 -1
- package/dist/tools/default/call_actor.js +19 -50
- package/dist/tools/default/call_actor.js.map +1 -1
- package/dist/tools/default/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/default/fetch_actor_details.js +3 -36
- package/dist/tools/default/fetch_actor_details.js.map +1 -1
- package/dist/tools/default/get_actor_run.d.ts.map +1 -1
- package/dist/tools/default/get_actor_run.js +3 -16
- package/dist/tools/default/get_actor_run.js.map +1 -1
- package/dist/tools/default/search_actors.d.ts.map +1 -1
- package/dist/tools/default/search_actors.js +16 -10
- package/dist/tools/default/search_actors.js.map +1 -1
- package/dist/tools/openai/actor_executor.d.ts.map +1 -1
- package/dist/tools/openai/actor_executor.js +6 -26
- package/dist/tools/openai/actor_executor.js.map +1 -1
- package/dist/tools/openai/call_actor.d.ts.map +1 -1
- package/dist/tools/openai/call_actor.js +18 -62
- package/dist/tools/openai/call_actor.js.map +1 -1
- package/dist/tools/openai/fetch_actor_details.d.ts.map +1 -1
- package/dist/tools/openai/fetch_actor_details.js +19 -13
- package/dist/tools/openai/fetch_actor_details.js.map +1 -1
- package/dist/tools/openai/fetch_actor_details_internal.d.ts.map +1 -1
- package/dist/tools/openai/fetch_actor_details_internal.js +16 -51
- package/dist/tools/openai/fetch_actor_details_internal.js.map +1 -1
- package/dist/tools/openai/get_actor_run.d.ts.map +1 -1
- package/dist/tools/openai/get_actor_run.js +3 -25
- package/dist/tools/openai/get_actor_run.js.map +1 -1
- package/dist/tools/openai/search_actors.d.ts.map +1 -1
- package/dist/tools/openai/search_actors.js +18 -12
- package/dist/tools/openai/search_actors.js.map +1 -1
- package/dist/tools/openai/search_actors_internal.d.ts.map +1 -1
- package/dist/tools/openai/search_actors_internal.js +5 -19
- package/dist/tools/openai/search_actors_internal.js.map +1 -1
- package/dist/tools/structured_output_schemas.d.ts +68 -4
- package/dist/tools/structured_output_schemas.d.ts.map +1 -1
- package/dist/tools/structured_output_schemas.js +28 -4
- package/dist/tools/structured_output_schemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/actor_card.d.ts +7 -2
- package/dist/utils/actor_card.d.ts.map +1 -1
- package/dist/utils/actor_card.js +20 -8
- package/dist/utils/actor_card.js.map +1 -1
- package/dist/utils/actor_details.d.ts +21 -95
- package/dist/utils/actor_details.d.ts.map +1 -1
- package/dist/utils/actor_details.js +39 -180
- package/dist/utils/actor_details.js.map +1 -1
- package/dist/utils/pricing_info.d.ts +71 -20
- package/dist/utils/pricing_info.d.ts.map +1 -1
- package/dist/utils/pricing_info.js +362 -129
- package/dist/utils/pricing_info.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +5 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/userid_cache.d.ts +12 -4
- package/dist/utils/userid_cache.d.ts.map +1 -1
- package/dist/utils/userid_cache.js +41 -14
- package/dist/utils/userid_cache.js.map +1 -1
- package/dist/web/dist/actor-detail-widget.js +2 -2
- package/dist/web/dist/search-actors-widget.js +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { ApifyClient } from '../apify_client.js';
|
|
2
|
+
import { type PricingTier } from './pricing_info.js';
|
|
3
|
+
export type CachedUserInfo = {
|
|
4
|
+
userId: string | null;
|
|
5
|
+
userPlanTier: PricingTier;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
|
-
* Gets user
|
|
4
|
-
* Token is hashed before caching to avoid storing raw tokens
|
|
5
|
-
*
|
|
8
|
+
* Gets user info (id + plan tier) from token, using cache to avoid repeated API calls.
|
|
9
|
+
* Token is hashed before caching to avoid storing raw tokens.
|
|
10
|
+
*
|
|
11
|
+
* Defensive defaults: returns `{ userId: null, userPlanTier: 'FREE' }` when the token is
|
|
12
|
+
* missing/empty, the API call fails, or the plan is unrecognized. Failed lookups are NOT
|
|
13
|
+
* cached so the next call retries.
|
|
6
14
|
*/
|
|
7
|
-
export declare function
|
|
15
|
+
export declare function getUserInfoCached(token: string | undefined, apifyClient: ApifyClient): Promise<CachedUserInfo>;
|
|
8
16
|
//# sourceMappingURL=userid_cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userid_cache.d.ts","sourceRoot":"","sources":["../../src/utils/userid_cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"userid_cache.d.ts","sourceRoot":"","sources":["../../src/utils/userid_cache.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGpE,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,EAAE,WAAW,CAAC;CAC7B,CAAC;AAiBF;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACnC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,WAAW,GACzB,OAAO,CAAC,cAAc,CAAC,CAuBzB"}
|
|
@@ -1,28 +1,55 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import log from '@apify/log';
|
|
2
3
|
import { USER_CACHE_MAX_SIZE, USER_CACHE_TTL_SECS } from '../const.js';
|
|
4
|
+
import { PRICING_TIERS } from './pricing_info.js';
|
|
3
5
|
import { TTLLRUCache } from './ttl_lru.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
const ANONYMOUS_USER_INFO = { userId: null, userPlanTier: 'FREE' };
|
|
7
|
+
// LRU cache with TTL for user info - keyed by hashed token
|
|
8
|
+
const userInfoCache = new TTLLRUCache(USER_CACHE_MAX_SIZE, USER_CACHE_TTL_SECS);
|
|
9
|
+
function normalizePlanTier(tier) {
|
|
10
|
+
if (!tier)
|
|
11
|
+
return 'FREE';
|
|
12
|
+
const upper = tier.toUpperCase();
|
|
13
|
+
const match = PRICING_TIERS.find((t) => t === upper);
|
|
14
|
+
if (match)
|
|
15
|
+
return match;
|
|
16
|
+
// Enterprise / custom plan names fall through to FREE; log so we can spot them in the wild.
|
|
17
|
+
log.info(`Unrecognized plan tier "${tier}", defaulting to FREE`);
|
|
18
|
+
return 'FREE';
|
|
19
|
+
}
|
|
6
20
|
/**
|
|
7
|
-
* Gets user
|
|
8
|
-
* Token is hashed before caching to avoid storing raw tokens
|
|
9
|
-
*
|
|
21
|
+
* Gets user info (id + plan tier) from token, using cache to avoid repeated API calls.
|
|
22
|
+
* Token is hashed before caching to avoid storing raw tokens.
|
|
23
|
+
*
|
|
24
|
+
* Defensive defaults: returns `{ userId: null, userPlanTier: 'FREE' }` when the token is
|
|
25
|
+
* missing/empty, the API call fails, or the plan is unrecognized. Failed lookups are NOT
|
|
26
|
+
* cached so the next call retries.
|
|
10
27
|
*/
|
|
11
|
-
export async function
|
|
28
|
+
export async function getUserInfoCached(token, apifyClient) {
|
|
29
|
+
var _a;
|
|
30
|
+
if (!token)
|
|
31
|
+
return ANONYMOUS_USER_INFO;
|
|
12
32
|
const tokenHash = createHash('sha256').update(token).digest('hex');
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
33
|
+
const cached = userInfoCache.get(tokenHash);
|
|
34
|
+
if (cached)
|
|
35
|
+
return cached;
|
|
16
36
|
try {
|
|
17
37
|
const user = await apifyClient.user('me').get();
|
|
18
|
-
if (!user ||
|
|
19
|
-
return
|
|
38
|
+
if (!(user === null || user === void 0 ? void 0 : user.id)) {
|
|
39
|
+
return { ...ANONYMOUS_USER_INFO };
|
|
20
40
|
}
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
// `tier` is present on /v2/users/me `plan` response (FREE/BRONZE/SILVER/GOLD/PLATINUM/DIAMOND)
|
|
42
|
+
// but missing from apify-client's type declaration — hence the cast.
|
|
43
|
+
const planTier = (_a = user.plan) === null || _a === void 0 ? void 0 : _a.tier;
|
|
44
|
+
const info = {
|
|
45
|
+
userId: user.id,
|
|
46
|
+
userPlanTier: normalizePlanTier(planTier),
|
|
47
|
+
};
|
|
48
|
+
userInfoCache.set(tokenHash, info);
|
|
49
|
+
return info;
|
|
23
50
|
}
|
|
24
51
|
catch {
|
|
25
|
-
return
|
|
52
|
+
return { ...ANONYMOUS_USER_INFO };
|
|
26
53
|
}
|
|
27
54
|
}
|
|
28
55
|
//# sourceMappingURL=userid_cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userid_cache.js","sourceRoot":"","sources":["../../src/utils/userid_cache.ts"],"names":[],"mappings":"AAAA,OAAO,EA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