@predictorsdk/client 0.10.0 → 0.11.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/Client.d.ts +13 -1
- package/dist/Client.js +61 -1
- package/dist/api/types/Plan.d.ts +22 -0
- package/dist/api/types/Plan.js +2 -0
- package/dist/api/types/PlansResponse.d.ts +4 -0
- package/dist/api/types/PlansResponse.js +2 -0
- package/dist/api/types/index.d.ts +2 -0
- package/dist/api/types/index.js +2 -0
- package/dist/auth/BearerAuthProvider.d.ts +1 -1
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +3 -2
- package/dist/serialization/types/Plan.d.ts +22 -0
- package/dist/serialization/types/Plan.js +18 -0
- package/dist/serialization/types/PlansResponse.d.ts +10 -0
- package/dist/serialization/types/PlansResponse.js +6 -0
- package/dist/serialization/types/index.d.ts +2 -0
- package/dist/serialization/types/index.js +2 -0
- package/package.json +1 -1
package/dist/Client.d.ts
CHANGED
|
@@ -9,7 +9,19 @@ export declare namespace PredictorSDKClient {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class PredictorSDKClient {
|
|
11
11
|
protected readonly _options: NormalizedClientOptionsWithAuth<PredictorSDKClient.Options>;
|
|
12
|
-
constructor(options
|
|
12
|
+
constructor(options?: PredictorSDKClient.Options);
|
|
13
|
+
/**
|
|
14
|
+
* Returns the machine-readable public billing catalog used by API consumers and pricing surfaces. This endpoint is intentionally unauthenticated. Stripe price IDs and all other provisioning secrets are excluded from the response.
|
|
15
|
+
*
|
|
16
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
17
|
+
*
|
|
18
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* await client.getPlans()
|
|
22
|
+
*/
|
|
23
|
+
getPlans(requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.PlansResponse>;
|
|
24
|
+
private __getPlans;
|
|
13
25
|
/**
|
|
14
26
|
* Find cross-platform market matches for sports events. When called without parameters, returns all currently matched sports markets with cursor-based pagination (default `limit=25`, max `100`). Provide a canonical event key, Kalshi event ticker, Polymarket slug, Predict market ID, or SX Bet market ID to look up a specific event — lookups return the full match immediately and skip pagination.
|
|
15
27
|
*
|
package/dist/Client.js
CHANGED
|
@@ -9,9 +9,69 @@ import * as errors from "./errors/index.js";
|
|
|
9
9
|
import * as serializers from "./serialization/index.js";
|
|
10
10
|
export class PredictorSDKClient {
|
|
11
11
|
_options;
|
|
12
|
-
constructor(options) {
|
|
12
|
+
constructor(options = {}) {
|
|
13
13
|
this._options = normalizeClientOptionsWithAuth(options);
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the machine-readable public billing catalog used by API consumers and pricing surfaces. This endpoint is intentionally unauthenticated. Stripe price IDs and all other provisioning secrets are excluded from the response.
|
|
17
|
+
*
|
|
18
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
19
|
+
*
|
|
20
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* await client.getPlans()
|
|
24
|
+
*/
|
|
25
|
+
getPlans(requestOptions) {
|
|
26
|
+
return core.HttpResponsePromise.fromPromise(this.__getPlans(requestOptions));
|
|
27
|
+
}
|
|
28
|
+
async __getPlans(requestOptions) {
|
|
29
|
+
const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
|
|
30
|
+
const _response = await core.fetcher({
|
|
31
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
32
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
33
|
+
environments.PredictorSDKEnvironment.Production, "v1/plans"),
|
|
34
|
+
method: "GET",
|
|
35
|
+
headers: _headers,
|
|
36
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
37
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
38
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
39
|
+
abortSignal: requestOptions?.abortSignal,
|
|
40
|
+
fetchFn: this._options?.fetch,
|
|
41
|
+
logging: this._options.logging,
|
|
42
|
+
});
|
|
43
|
+
if (_response.ok) {
|
|
44
|
+
return {
|
|
45
|
+
data: serializers.PlansResponse.parseOrThrow(_response.body, {
|
|
46
|
+
unrecognizedObjectKeys: "passthrough",
|
|
47
|
+
allowUnrecognizedUnionMembers: true,
|
|
48
|
+
allowUnrecognizedEnumValues: true,
|
|
49
|
+
skipValidation: true,
|
|
50
|
+
breadcrumbsPrefix: ["response"],
|
|
51
|
+
}),
|
|
52
|
+
rawResponse: _response.rawResponse,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (_response.error.reason === "status-code") {
|
|
56
|
+
switch (_response.error.statusCode) {
|
|
57
|
+
case 503:
|
|
58
|
+
throw new PredictorSDK.ServiceUnavailableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
59
|
+
unrecognizedObjectKeys: "passthrough",
|
|
60
|
+
allowUnrecognizedUnionMembers: true,
|
|
61
|
+
allowUnrecognizedEnumValues: true,
|
|
62
|
+
skipValidation: true,
|
|
63
|
+
breadcrumbsPrefix: ["response"],
|
|
64
|
+
}), _response.rawResponse);
|
|
65
|
+
default:
|
|
66
|
+
throw new errors.PredictorSDKError({
|
|
67
|
+
statusCode: _response.error.statusCode,
|
|
68
|
+
body: _response.error.body,
|
|
69
|
+
rawResponse: _response.rawResponse,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/plans");
|
|
74
|
+
}
|
|
15
75
|
/**
|
|
16
76
|
* Find cross-platform market matches for sports events. When called without parameters, returns all currently matched sports markets with cursor-based pagination (default `limit=25`, max `100`). Provide a canonical event key, Kalshi event ticker, Polymarket slug, Predict market ID, or SX Bet market ID to look up a specific event — lookups return the full match immediately and skip pagination.
|
|
17
77
|
*
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public plan metadata. Stripe price IDs and legacy provisioning IDs are intentionally absent.
|
|
3
|
+
*/
|
|
4
|
+
export interface Plan {
|
|
5
|
+
/** Stable public plan key. */
|
|
6
|
+
key: string;
|
|
7
|
+
name: string;
|
|
8
|
+
/** Runtime entitlement tier; empty for a manually provisioned contact-sales plan. */
|
|
9
|
+
billingTier: string;
|
|
10
|
+
trialDays: number;
|
|
11
|
+
tagline: string;
|
|
12
|
+
/** Monthly display price in US cents; zero for free or contact-sales plans. */
|
|
13
|
+
monthlyPriceCents: number;
|
|
14
|
+
includedRequestsPerMonth: number;
|
|
15
|
+
overageCentsPer1K: number;
|
|
16
|
+
rateLimitPerMin: number;
|
|
17
|
+
maxKeys: number;
|
|
18
|
+
features: string[];
|
|
19
|
+
ctaLabel: string;
|
|
20
|
+
highlighted: boolean;
|
|
21
|
+
contactSales: boolean;
|
|
22
|
+
}
|
|
@@ -31,6 +31,8 @@ export * from "./MarketsListResponse.js";
|
|
|
31
31
|
export * from "./PaginationBlock.js";
|
|
32
32
|
export * from "./PaymentRequiredErrorAction.js";
|
|
33
33
|
export * from "./PaymentRequiredErrorBody.js";
|
|
34
|
+
export * from "./Plan.js";
|
|
35
|
+
export * from "./PlansResponse.js";
|
|
34
36
|
export * from "./PlatformMarket.js";
|
|
35
37
|
export * from "./PlatformMarketPlatform.js";
|
|
36
38
|
export * from "./PolymarketPosition.js";
|
package/dist/api/types/index.js
CHANGED
|
@@ -31,6 +31,8 @@ export * from "./MarketsListResponse.js";
|
|
|
31
31
|
export * from "./PaginationBlock.js";
|
|
32
32
|
export * from "./PaymentRequiredErrorAction.js";
|
|
33
33
|
export * from "./PaymentRequiredErrorBody.js";
|
|
34
|
+
export * from "./Plan.js";
|
|
35
|
+
export * from "./PlansResponse.js";
|
|
34
36
|
export * from "./PlatformMarket.js";
|
|
35
37
|
export * from "./PlatformMarketPlatform.js";
|
|
36
38
|
export * from "./PolymarketPosition.js";
|
|
@@ -13,7 +13,7 @@ export declare namespace BearerAuthProvider {
|
|
|
13
13
|
const AUTH_CONFIG_ERROR_MESSAGE: string;
|
|
14
14
|
type Options = AuthOptions;
|
|
15
15
|
type AuthOptions = {
|
|
16
|
-
[TOKEN_PARAM]
|
|
16
|
+
[TOKEN_PARAM]?: core.Supplier<core.BearerToken>;
|
|
17
17
|
};
|
|
18
18
|
function createInstance(options: Options): core.AuthProvider;
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ function addSymmetricJitter(delay) {
|
|
|
13
13
|
const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
|
|
14
14
|
return delay * jitterMultiplier;
|
|
15
15
|
}
|
|
16
|
-
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
16
|
+
export function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
17
17
|
const retryAfter = response.headers.get("Retry-After");
|
|
18
18
|
if (retryAfter) {
|
|
19
19
|
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
@@ -32,7 +32,8 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
|
32
32
|
if (rateLimitReset) {
|
|
33
33
|
const resetTime = parseInt(rateLimitReset, 10);
|
|
34
34
|
if (!Number.isNaN(resetTime)) {
|
|
35
|
-
const
|
|
35
|
+
const resetTimeMilliseconds = resetTime >= 1_000_000_000_000 ? resetTime : resetTime * 1000;
|
|
36
|
+
const delay = resetTimeMilliseconds - Date.now();
|
|
36
37
|
if (delay > 0) {
|
|
37
38
|
return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
|
|
38
39
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../../api/index.js";
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import type * as serializers from "../index.js";
|
|
4
|
+
export declare const Plan: core.serialization.ObjectSchema<serializers.Plan.Raw, PredictorSDK.Plan>;
|
|
5
|
+
export declare namespace Plan {
|
|
6
|
+
interface Raw {
|
|
7
|
+
key: string;
|
|
8
|
+
name: string;
|
|
9
|
+
billing_tier: string;
|
|
10
|
+
trial_days: number;
|
|
11
|
+
tagline: string;
|
|
12
|
+
monthly_price_cents: number;
|
|
13
|
+
included_requests_per_month: number;
|
|
14
|
+
overage_cents_per_1k: number;
|
|
15
|
+
rate_limit_per_min: number;
|
|
16
|
+
max_keys: number;
|
|
17
|
+
features: string[];
|
|
18
|
+
cta_label: string;
|
|
19
|
+
highlighted: boolean;
|
|
20
|
+
contact_sales: boolean;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
export const Plan = core.serialization.object({
|
|
4
|
+
key: core.serialization.string(),
|
|
5
|
+
name: core.serialization.string(),
|
|
6
|
+
billingTier: core.serialization.property("billing_tier", core.serialization.string()),
|
|
7
|
+
trialDays: core.serialization.property("trial_days", core.serialization.number()),
|
|
8
|
+
tagline: core.serialization.string(),
|
|
9
|
+
monthlyPriceCents: core.serialization.property("monthly_price_cents", core.serialization.number()),
|
|
10
|
+
includedRequestsPerMonth: core.serialization.property("included_requests_per_month", core.serialization.number()),
|
|
11
|
+
overageCentsPer1K: core.serialization.property("overage_cents_per_1k", core.serialization.number()),
|
|
12
|
+
rateLimitPerMin: core.serialization.property("rate_limit_per_min", core.serialization.number()),
|
|
13
|
+
maxKeys: core.serialization.property("max_keys", core.serialization.number()),
|
|
14
|
+
features: core.serialization.list(core.serialization.string()),
|
|
15
|
+
ctaLabel: core.serialization.property("cta_label", core.serialization.string()),
|
|
16
|
+
highlighted: core.serialization.boolean(),
|
|
17
|
+
contactSales: core.serialization.property("contact_sales", core.serialization.boolean()),
|
|
18
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../../api/index.js";
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import type * as serializers from "../index.js";
|
|
4
|
+
import { Plan } from "./Plan.js";
|
|
5
|
+
export declare const PlansResponse: core.serialization.ObjectSchema<serializers.PlansResponse.Raw, PredictorSDK.PlansResponse>;
|
|
6
|
+
export declare namespace PlansResponse {
|
|
7
|
+
interface Raw {
|
|
8
|
+
data: Plan.Raw[];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -31,6 +31,8 @@ export * from "./MarketsListResponse.js";
|
|
|
31
31
|
export * from "./PaginationBlock.js";
|
|
32
32
|
export * from "./PaymentRequiredErrorAction.js";
|
|
33
33
|
export * from "./PaymentRequiredErrorBody.js";
|
|
34
|
+
export * from "./Plan.js";
|
|
35
|
+
export * from "./PlansResponse.js";
|
|
34
36
|
export * from "./PlatformMarket.js";
|
|
35
37
|
export * from "./PlatformMarketPlatform.js";
|
|
36
38
|
export * from "./PolymarketPosition.js";
|
|
@@ -31,6 +31,8 @@ export * from "./MarketsListResponse.js";
|
|
|
31
31
|
export * from "./PaginationBlock.js";
|
|
32
32
|
export * from "./PaymentRequiredErrorAction.js";
|
|
33
33
|
export * from "./PaymentRequiredErrorBody.js";
|
|
34
|
+
export * from "./Plan.js";
|
|
35
|
+
export * from "./PlansResponse.js";
|
|
34
36
|
export * from "./PlatformMarket.js";
|
|
35
37
|
export * from "./PlatformMarketPlatform.js";
|
|
36
38
|
export * from "./PolymarketPosition.js";
|