@apify/actors-mcp-server 0.2.9 → 0.2.10-beta.0
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 +2 -1
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +2 -7
- package/dist/const.js.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +10 -14
- package/dist/mcp/server.js.map +1 -1
- package/dist/tools/actor.d.ts +3 -5
- package/dist/tools/actor.d.ts.map +1 -1
- package/dist/tools/actor.js +122 -11
- package/dist/tools/actor.js.map +1 -1
- package/dist/tools/get-actor-details.d.ts +3 -0
- package/dist/tools/get-actor-details.d.ts.map +1 -0
- package/dist/tools/get-actor-details.js +74 -0
- package/dist/tools/get-actor-details.js.map +1 -0
- package/dist/tools/helpers.d.ts +3 -3
- package/dist/tools/helpers.d.ts.map +1 -1
- package/dist/tools/helpers.js +27 -55
- package/dist/tools/helpers.js.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +22 -24
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/store_collection.d.ts +22 -2
- package/dist/tools/store_collection.d.ts.map +1 -1
- package/dist/tools/store_collection.js +47 -43
- package/dist/tools/store_collection.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +51 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/actor.d.ts +7 -0
- package/dist/utils/actor.d.ts.map +1 -0
- package/dist/utils/actor.js +24 -0
- package/dist/utils/actor.js.map +1 -0
- package/dist/utils/ajv.d.ts +3 -0
- package/dist/utils/ajv.d.ts.map +1 -0
- package/dist/utils/ajv.js +3 -0
- package/dist/utils/ajv.js.map +1 -0
- package/dist/utils/generic.d.ts +7 -0
- package/dist/utils/generic.d.ts.map +1 -0
- package/dist/utils/generic.js +27 -0
- package/dist/utils/generic.js.map +1 -0
- package/dist/utils/pricing-info.d.ts +13 -0
- package/dist/utils/pricing-info.d.ts.map +1 -0
- package/dist/utils/pricing-info.js +93 -0
- package/dist/utils/pricing-info.js.map +1 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
2
2
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
3
3
|
import type { Notification, Request } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import type { ValidateFunction } from 'ajv';
|
|
5
|
-
import type { ActorDefaultRunOptions, ActorDefinition } from 'apify-client';
|
|
5
|
+
import type { ActorDefaultRunOptions, ActorDefinition, ActorStoreList, PricingInfo } from 'apify-client';
|
|
6
6
|
import type { ACTOR_PRICING_MODEL } from './const.js';
|
|
7
7
|
import type { ActorsMcpServer } from './mcp/server.js';
|
|
8
8
|
export interface ISchemaProperties {
|
|
@@ -134,23 +134,43 @@ export interface ActorStats {
|
|
|
134
134
|
totalUsers30Days: number;
|
|
135
135
|
publicActorRunStats30Days: unknown;
|
|
136
136
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Price for a single event in a specific tier.
|
|
139
|
+
*/
|
|
140
|
+
export interface TieredEventPrice {
|
|
141
|
+
tieredEventPriceUsd: number;
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Allowed pricing tiers for tiered event pricing.
|
|
145
|
+
*/
|
|
146
|
+
export type PricingTier = 'FREE' | 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM' | 'DIAMOND';
|
|
147
|
+
/**
|
|
148
|
+
* Describes a single chargeable event for an Actor.
|
|
149
|
+
* Supports either flat pricing (eventPriceUsd) or tiered pricing (eventTieredPricingUsd).
|
|
150
|
+
*/
|
|
151
|
+
export interface ActorChargeEvent {
|
|
152
|
+
eventTitle: string;
|
|
153
|
+
eventDescription: string;
|
|
154
|
+
/** Flat price per event in USD (if not tiered) */
|
|
155
|
+
eventPriceUsd?: number;
|
|
156
|
+
/** Tiered pricing per event, by tier name (FREE, BRONZE, etc.) */
|
|
157
|
+
eventTieredPricingUsd?: Partial<Record<PricingTier, TieredEventPrice>>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Pricing per event for an Actor, supporting both flat and tiered pricing.
|
|
161
|
+
*/
|
|
162
|
+
export interface PricingPerEvent {
|
|
163
|
+
actorChargeEvents: Record<string, ActorChargeEvent>;
|
|
153
164
|
}
|
|
165
|
+
export type ExtendedPricingInfo = PricingInfo & {
|
|
166
|
+
pricePerUnitUsd?: number;
|
|
167
|
+
trialMinutes?: number;
|
|
168
|
+
unitName?: string;
|
|
169
|
+
pricingPerEvent: PricingPerEvent;
|
|
170
|
+
tieredPricing?: Partial<Record<PricingTier, {
|
|
171
|
+
tieredPricePerUnitUsd: number;
|
|
172
|
+
}>>;
|
|
173
|
+
};
|
|
154
174
|
/**
|
|
155
175
|
* Interface for internal tools - tools implemented directly in the MCP server.
|
|
156
176
|
* Extends ToolBase with a call function implementation.
|
|
@@ -182,4 +202,19 @@ export interface ActorInfo {
|
|
|
182
202
|
webServerMcpPath: string | null;
|
|
183
203
|
actorDefinitionPruned: ActorDefinitionPruned;
|
|
184
204
|
}
|
|
205
|
+
export type ExtendedActorStoreList = ActorStoreList & {
|
|
206
|
+
categories?: string[];
|
|
207
|
+
bookmarkCount?: number;
|
|
208
|
+
actorReviewRating?: number;
|
|
209
|
+
};
|
|
210
|
+
export type ActorDefinitionStorage = {
|
|
211
|
+
views: Record<string, {
|
|
212
|
+
transformation: {
|
|
213
|
+
fields?: string[];
|
|
214
|
+
};
|
|
215
|
+
display: {
|
|
216
|
+
properties: Record<string, object>;
|
|
217
|
+
};
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
185
220
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IAEpB,IAAI,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ED,MAAM,MAAM,KAAK,GAAG;IAChB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B;;MAEE;IACF,sBAAsB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1C,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,qBAAqB,EAAE,qBAAqB,CAAC;CAChD;AAED,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG;IAClD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,KAAK,EAAE,MAAM,CACT,MAAM,EACN;QACI,cAAc,EAAE;YACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;SACrB,CAAC;QACF,OAAO,EAAE;YACL,UAAU,EAAE,MAAM,CACd,MAAM,EACN,MAAM,CACT,CAAC;SACL,CAAC;KACL,CACJ,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ActorDefinitionStorage } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of all field names mentioned in the display.properties
|
|
4
|
+
* of all views in the given ActorDefinitionStorage object.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getActorDefinitionStorageFieldNames(storage: ActorDefinitionStorage | object): string[];
|
|
7
|
+
//# sourceMappingURL=actor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../../src/utils/actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,GAAG,MAAM,EAAE,CAiBtG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an array of all field names mentioned in the display.properties
|
|
3
|
+
* of all views in the given ActorDefinitionStorage object.
|
|
4
|
+
*/
|
|
5
|
+
export function getActorDefinitionStorageFieldNames(storage) {
|
|
6
|
+
const fieldSet = new Set();
|
|
7
|
+
if ('views' in storage && typeof storage.views === 'object' && storage.views !== null) {
|
|
8
|
+
for (const view of Object.values(storage.views)) {
|
|
9
|
+
// Collect from display.properties
|
|
10
|
+
if (view.display && view.display.properties) {
|
|
11
|
+
Object.keys(view.display.properties).forEach((field) => fieldSet.add(field));
|
|
12
|
+
}
|
|
13
|
+
// Collect from transformation.fields
|
|
14
|
+
if (view.transformation && Array.isArray(view.transformation.fields)) {
|
|
15
|
+
view.transformation.fields.forEach((field) => {
|
|
16
|
+
if (typeof field === 'string')
|
|
17
|
+
fieldSet.add(field);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return Array.from(fieldSet);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=actor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor.js","sourceRoot":"","sources":["../../src/utils/actor.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,OAAwC;IACxF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACpF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,kCAAkC;YAClC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACjF,CAAC;YACD,qCAAqC;YACrC,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;wBAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACvD,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv.d.ts","sourceRoot":"","sources":["../../src/utils/ajv.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,GAAG,KAAmD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ajv.js","sourceRoot":"","sources":["../../src/utils/ajv.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively gets the value in a nested object for each key in the keys array.
|
|
3
|
+
* Each key can be a dot-separated path (e.g. 'a.b.c').
|
|
4
|
+
* Returns an object mapping each key to its resolved value (or undefined if not found).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getValuesByDotKeys<T extends object>(obj: T, keys: string[]): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../src/utils/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBpG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively gets the value in a nested object for each key in the keys array.
|
|
3
|
+
* Each key can be a dot-separated path (e.g. 'a.b.c').
|
|
4
|
+
* Returns an object mapping each key to its resolved value (or undefined if not found).
|
|
5
|
+
*/
|
|
6
|
+
export function getValuesByDotKeys(obj, keys) {
|
|
7
|
+
const result = {};
|
|
8
|
+
for (const key of keys) {
|
|
9
|
+
const path = key.split('.');
|
|
10
|
+
let current = obj;
|
|
11
|
+
for (const segment of path) {
|
|
12
|
+
if (current !== null
|
|
13
|
+
&& typeof current === 'object'
|
|
14
|
+
&& Object.prototype.hasOwnProperty.call(current, segment)) {
|
|
15
|
+
// Use index signature to avoid 'any' and type errors
|
|
16
|
+
current = current[segment];
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
current = undefined;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
result[key] = current;
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=generic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/utils/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAmB,GAAM,EAAE,IAAc;IACvE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,OAAO,GAAY,GAAG,CAAC;QAC3B,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YACzB,IACI,OAAO,KAAK,IAAI;mBACb,OAAO,OAAO,KAAK,QAAQ;mBAC3B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAC3D,CAAC;gBACC,qDAAqD;gBACrD,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,SAAS,CAAC;gBACpB,MAAM;YACV,CAAC;QACL,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ActorRunPricingInfo } from 'apify-client';
|
|
2
|
+
import type { ExtendedPricingInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the most recent valid pricing information from a list of pricing infos,
|
|
5
|
+
* based on the provided current date.
|
|
6
|
+
*
|
|
7
|
+
* Filters out pricing infos that have a `startedAt` date in the future or missing,
|
|
8
|
+
* then sorts the remaining infos by `startedAt` in descending order (most recent first).
|
|
9
|
+
* Returns the most recent valid pricing info, or `null` if none are valid.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCurrentPricingInfo(pricingInfos: ActorRunPricingInfo[], now: Date): ActorRunPricingInfo | null;
|
|
12
|
+
export declare function pricingInfoToString(pricingInfo: ExtendedPricingInfo | null): string;
|
|
13
|
+
//# sourceMappingURL=pricing-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-info.d.ts","sourceRoot":"","sources":["../../src/utils/pricing-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,mBAAmB,EAAE,EAAE,GAAG,EAAE,IAAI,GAAG,mBAAmB,GAAG,IAAI,CAmBhH;AA+BD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,CAgCnF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ACTOR_PRICING_MODEL } from '../const.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the most recent valid pricing information from a list of pricing infos,
|
|
4
|
+
* based on the provided current date.
|
|
5
|
+
*
|
|
6
|
+
* Filters out pricing infos that have a `startedAt` date in the future or missing,
|
|
7
|
+
* then sorts the remaining infos by `startedAt` in descending order (most recent first).
|
|
8
|
+
* Returns the most recent valid pricing info, or `null` if none are valid.
|
|
9
|
+
*/
|
|
10
|
+
export function getCurrentPricingInfo(pricingInfos, now) {
|
|
11
|
+
// Filter out all future dates and those without a startedAt date
|
|
12
|
+
const validPricingInfos = pricingInfos.filter((info) => {
|
|
13
|
+
if (!info.startedAt)
|
|
14
|
+
return false;
|
|
15
|
+
const startedAt = new Date(info.startedAt);
|
|
16
|
+
return startedAt <= now;
|
|
17
|
+
});
|
|
18
|
+
// Sort and return the most recent pricing info
|
|
19
|
+
validPricingInfos.sort((a, b) => {
|
|
20
|
+
const aDate = new Date(a.startedAt || 0);
|
|
21
|
+
const bDate = new Date(b.startedAt || 0);
|
|
22
|
+
return bDate.getTime() - aDate.getTime(); // Sort descending
|
|
23
|
+
});
|
|
24
|
+
if (validPricingInfos.length > 0) {
|
|
25
|
+
return validPricingInfos[0]; // Return the most recent pricing info
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function convertMinutesToGreatestUnit(minutes) {
|
|
30
|
+
if (minutes < 60) {
|
|
31
|
+
return { value: minutes, unit: 'minutes' };
|
|
32
|
+
}
|
|
33
|
+
if (minutes < 60 * 24) { // Less than 24 hours
|
|
34
|
+
return { value: Math.floor(minutes / 60), unit: 'hours' };
|
|
35
|
+
} // 24 hours or more
|
|
36
|
+
return { value: Math.floor(minutes / (60 * 24)), unit: 'days' };
|
|
37
|
+
}
|
|
38
|
+
function payPerEventPricingToString(pricingPerEvent) {
|
|
39
|
+
if (!pricingPerEvent || !pricingPerEvent.actorChargeEvents)
|
|
40
|
+
return 'No event pricing information available.';
|
|
41
|
+
const eventStrings = [];
|
|
42
|
+
for (const event of Object.values(pricingPerEvent.actorChargeEvents)) {
|
|
43
|
+
let eventStr = `- ${event.eventTitle}: ${event.eventDescription} `;
|
|
44
|
+
if (typeof event.eventPriceUsd === 'number') {
|
|
45
|
+
eventStr += `(Flat price: $${event.eventPriceUsd} per event)`;
|
|
46
|
+
}
|
|
47
|
+
else if (event.eventTieredPricingUsd) {
|
|
48
|
+
const tiers = Object.entries(event.eventTieredPricingUsd)
|
|
49
|
+
.map(([tier, price]) => `${tier}: $${price.tieredEventPriceUsd}`)
|
|
50
|
+
.join(', ');
|
|
51
|
+
eventStr += `(Tiered pricing: ${tiers} per event)`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
eventStr += '(No price info)';
|
|
55
|
+
}
|
|
56
|
+
eventStrings.push(eventStr);
|
|
57
|
+
}
|
|
58
|
+
return `This Actor charges per event as follows:\n${eventStrings.join('\n')}`;
|
|
59
|
+
}
|
|
60
|
+
export function pricingInfoToString(pricingInfo) {
|
|
61
|
+
// If there is no pricing infos entries the Actor is free to use
|
|
62
|
+
// based on https://github.com/apify/apify-core/blob/058044945f242387dde2422b8f1bef395110a1bf/src/packages/actor/src/paid_actors/paid_actors_common.ts#L691
|
|
63
|
+
if (pricingInfo === null || pricingInfo.pricingModel === ACTOR_PRICING_MODEL.FREE) {
|
|
64
|
+
return 'This Actor is free to use; the user only pays for the computing resources consumed by the Actor.';
|
|
65
|
+
}
|
|
66
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.PRICE_PER_DATASET_ITEM) {
|
|
67
|
+
const customUnitName = pricingInfo.unitName !== 'result' ? pricingInfo.unitName : '';
|
|
68
|
+
// Handle tiered pricing if present
|
|
69
|
+
if (pricingInfo.tieredPricing && Object.keys(pricingInfo.tieredPricing).length > 0) {
|
|
70
|
+
const tiers = Object.entries(pricingInfo.tieredPricing)
|
|
71
|
+
.map(([tier, obj]) => `${tier}: $${obj.tieredPricePerUnitUsd * 1000} per 1000 ${customUnitName || 'results'}`)
|
|
72
|
+
.join(', ');
|
|
73
|
+
return `This Actor charges per results${customUnitName ? ` (in this case named ${customUnitName})` : ''}; tiered pricing per 1000 ${customUnitName || 'results'}: ${tiers}.`;
|
|
74
|
+
}
|
|
75
|
+
return `This Actor charges per results${customUnitName ? ` (in this case named ${customUnitName})` : ''}; the price per 1000 ${customUnitName || 'results'} is ${pricingInfo.pricePerUnitUsd * 1000} USD.`;
|
|
76
|
+
}
|
|
77
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.FLAT_PRICE_PER_MONTH) {
|
|
78
|
+
const { value, unit } = convertMinutesToGreatestUnit(pricingInfo.trialMinutes || 0);
|
|
79
|
+
// Handle tiered pricing if present
|
|
80
|
+
if (pricingInfo.tieredPricing && Object.keys(pricingInfo.tieredPricing).length > 0) {
|
|
81
|
+
const tiers = Object.entries(pricingInfo.tieredPricing)
|
|
82
|
+
.map(([tier, obj]) => `${tier}: $${obj.tieredPricePerUnitUsd} per month`)
|
|
83
|
+
.join(', ');
|
|
84
|
+
return `This Actor is rental and thus has tiered pricing per month: ${tiers}, with a trial period of ${value} ${unit}.`;
|
|
85
|
+
}
|
|
86
|
+
return `This Actor is rental and thus has a flat price of ${pricingInfo.pricePerUnitUsd} USD per month, with a trial period of ${value} ${unit}.`;
|
|
87
|
+
}
|
|
88
|
+
if (pricingInfo.pricingModel === ACTOR_PRICING_MODEL.PAY_PER_EVENT) {
|
|
89
|
+
return payPerEventPricingToString(pricingInfo.pricingPerEvent);
|
|
90
|
+
}
|
|
91
|
+
return 'unknown';
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=pricing-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-info.js","sourceRoot":"","sources":["../../src/utils/pricing-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAmC,EAAE,GAAS;IAChF,iEAAiE;IACjE,MAAM,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACnD,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,SAAS,IAAI,GAAG,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,+CAA+C;IAC/C,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;QACz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