@predictorsdk/client 0.3.1 → 0.4.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/BaseClient.d.ts +3 -0
- package/dist/BaseClient.js +15 -0
- package/dist/Client.d.ts +26 -0
- package/dist/Client.js +155 -3
- package/dist/api/client/requests/GetPolymarketWalletRequest.d.ts +12 -0
- package/dist/api/client/requests/GetPolymarketWalletRequest.js +2 -0
- package/dist/api/client/requests/index.d.ts +1 -0
- package/dist/api/errors/NotFoundError.d.ts +7 -0
- package/dist/api/errors/NotFoundError.js +17 -0
- package/dist/api/errors/index.d.ts +1 -0
- package/dist/api/errors/index.js +1 -0
- package/dist/api/types/PolymarketWalletResponse.d.ts +10 -0
- package/dist/api/types/PolymarketWalletResponse.js +2 -0
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/core/auth/AuthProvider.d.ts +1 -0
- package/dist/core/auth/AuthProvider.js +6 -1
- package/dist/core/auth/index.d.ts +1 -1
- package/dist/core/auth/index.js +1 -0
- package/dist/core/fetcher/Fetcher.d.ts +6 -0
- package/dist/core/fetcher/Fetcher.js +9 -8
- package/dist/core/fetcher/requestWithRetries.js +4 -1
- package/dist/core/schemas/builders/enum/enum.d.ts +1 -0
- package/dist/core/schemas/builders/enum/enum.js +6 -0
- package/dist/core/schemas/builders/enum/index.d.ts +1 -1
- package/dist/core/schemas/builders/enum/index.js +1 -1
- package/dist/core/schemas/builders/schema-utils/JsonError.js +2 -1
- package/dist/core/schemas/builders/schema-utils/ParseError.js +2 -1
- package/dist/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/core/url/QueryStringBuilder.js +78 -0
- package/dist/core/url/index.d.ts +1 -0
- package/dist/core/url/index.js +1 -0
- package/dist/core/url/qs.d.ts +2 -1
- package/dist/core/url/qs.js +24 -12
- package/dist/serialization/types/PolymarketWalletResponse.d.ts +12 -0
- package/dist/serialization/types/PolymarketWalletResponse.js +8 -0
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/package.json +1 -1
package/dist/BaseClient.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BearerAuthProvider } from "./auth/BearerAuthProvider.js";
|
|
2
2
|
import * as core from "./core/index.js";
|
|
3
3
|
import type * as environments from "./environments.js";
|
|
4
|
+
export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | BearerAuthProvider.AuthOptions;
|
|
4
5
|
export type BaseClientOptions = {
|
|
5
6
|
environment?: core.Supplier<environments.PredictorSDKEnvironment | string>;
|
|
6
7
|
/** Specify a custom URL to connect the client to. */
|
|
@@ -15,6 +16,8 @@ export type BaseClientOptions = {
|
|
|
15
16
|
fetch?: typeof fetch;
|
|
16
17
|
/** Configure logging for the client. */
|
|
17
18
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
19
|
+
/** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
|
|
20
|
+
auth?: AuthOption;
|
|
18
21
|
} & BearerAuthProvider.AuthOptions;
|
|
19
22
|
export interface BaseRequestOptions {
|
|
20
23
|
/** The maximum time to wait for a response in seconds. */
|
package/dist/BaseClient.js
CHANGED
|
@@ -16,6 +16,21 @@ export function normalizeClientOptions(options) {
|
|
|
16
16
|
}
|
|
17
17
|
export function normalizeClientOptionsWithAuth(options) {
|
|
18
18
|
const normalized = normalizeClientOptions(options);
|
|
19
|
+
if (options.auth === false) {
|
|
20
|
+
normalized.authProvider = new core.NoOpAuthProvider();
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
if (options.auth != null) {
|
|
24
|
+
if (typeof options.auth === "function") {
|
|
25
|
+
normalized.authProvider = { getAuthRequest: options.auth };
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
if (core.isAuthProvider(options.auth)) {
|
|
29
|
+
normalized.authProvider = options.auth;
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
Object.assign(normalized, options.auth);
|
|
33
|
+
}
|
|
19
34
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
20
35
|
normalized.authProvider ??= new BearerAuthProvider(normalizedWithNoOpAuthProvider);
|
|
21
36
|
return normalized;
|
package/dist/Client.d.ts
CHANGED
|
@@ -67,6 +67,32 @@ export declare class PredictorSDKClient {
|
|
|
67
67
|
*/
|
|
68
68
|
getBinanceCryptoPrices(request: PredictorSDK.GetBinanceCryptoPricesRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.CryptoPricesResponse>;
|
|
69
69
|
private __getBinanceCryptoPrices;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the public profile (image and display name) for a Polymarket wallet. Accepts either a wallet `address` (proxy or signer EOA) or a Polymarket `username`. Exactly one of the two must be supplied — passing both returns `400`.
|
|
72
|
+
*
|
|
73
|
+
* When `address` is the underlying signer EOA, the endpoint resolves it to the deterministic proxy address and returns the proxy's profile, with `signer` echoing the input.
|
|
74
|
+
*
|
|
75
|
+
* When `username` is supplied, the endpoint resolves it to the wallet via Polymarket's profile search. Match is case-insensitive and exact: a query of `Theo` resolves the user literally named `theo` but does not resolve `theo46` or `Theo47`. A leading `@` is accepted (and stripped) as a convenience for callers used to Twitter-style handles. `signer` is always `null` on the username path. Profiles that don't exist (or only match fuzzily) return `404`.
|
|
76
|
+
*
|
|
77
|
+
* @param {PredictorSDK.GetPolymarketWalletRequest} request
|
|
78
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
79
|
+
*
|
|
80
|
+
* @throws {@link PredictorSDK.BadRequestError}
|
|
81
|
+
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
82
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
83
|
+
* @throws {@link PredictorSDK.ForbiddenError}
|
|
84
|
+
* @throws {@link PredictorSDK.NotFoundError}
|
|
85
|
+
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
86
|
+
* @throws {@link PredictorSDK.BadGatewayError}
|
|
87
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await client.getPolymarketWallet({
|
|
91
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
92
|
+
* })
|
|
93
|
+
*/
|
|
94
|
+
getPolymarketWallet(request?: PredictorSDK.GetPolymarketWalletRequest, requestOptions?: PredictorSDKClient.RequestOptions): core.HttpResponsePromise<PredictorSDK.PolymarketWalletResponse>;
|
|
95
|
+
private __getPolymarketWallet;
|
|
70
96
|
/**
|
|
71
97
|
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
72
98
|
* This is useful for making requests to endpoints not yet supported in the SDK.
|
package/dist/Client.js
CHANGED
|
@@ -50,7 +50,11 @@ export class PredictorSDKClient {
|
|
|
50
50
|
environments.PredictorSDKEnvironment.Production, "v1/matching-markets/sports"),
|
|
51
51
|
method: "GET",
|
|
52
52
|
headers: _headers,
|
|
53
|
-
|
|
53
|
+
queryString: core.url
|
|
54
|
+
.queryBuilder()
|
|
55
|
+
.addMany(_queryParams)
|
|
56
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
57
|
+
.build(),
|
|
54
58
|
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
55
59
|
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
56
60
|
abortSignal: requestOptions?.abortSignal,
|
|
@@ -162,7 +166,11 @@ export class PredictorSDKClient {
|
|
|
162
166
|
environments.PredictorSDKEnvironment.Production, "v1/markets"),
|
|
163
167
|
method: "GET",
|
|
164
168
|
headers: _headers,
|
|
165
|
-
|
|
169
|
+
queryString: core.url
|
|
170
|
+
.queryBuilder()
|
|
171
|
+
.addMany(_queryParams)
|
|
172
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
173
|
+
.build(),
|
|
166
174
|
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
167
175
|
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
168
176
|
abortSignal: requestOptions?.abortSignal,
|
|
@@ -280,7 +288,11 @@ export class PredictorSDKClient {
|
|
|
280
288
|
environments.PredictorSDKEnvironment.Production, "v1/crypto-prices/binance"),
|
|
281
289
|
method: "GET",
|
|
282
290
|
headers: _headers,
|
|
283
|
-
|
|
291
|
+
queryString: core.url
|
|
292
|
+
.queryBuilder()
|
|
293
|
+
.addMany(_queryParams)
|
|
294
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
295
|
+
.build(),
|
|
284
296
|
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
285
297
|
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
286
298
|
abortSignal: requestOptions?.abortSignal,
|
|
@@ -367,6 +379,146 @@ export class PredictorSDKClient {
|
|
|
367
379
|
}
|
|
368
380
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/crypto-prices/binance");
|
|
369
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Returns the public profile (image and display name) for a Polymarket wallet. Accepts either a wallet `address` (proxy or signer EOA) or a Polymarket `username`. Exactly one of the two must be supplied — passing both returns `400`.
|
|
384
|
+
*
|
|
385
|
+
* When `address` is the underlying signer EOA, the endpoint resolves it to the deterministic proxy address and returns the proxy's profile, with `signer` echoing the input.
|
|
386
|
+
*
|
|
387
|
+
* When `username` is supplied, the endpoint resolves it to the wallet via Polymarket's profile search. Match is case-insensitive and exact: a query of `Theo` resolves the user literally named `theo` but does not resolve `theo46` or `Theo47`. A leading `@` is accepted (and stripped) as a convenience for callers used to Twitter-style handles. `signer` is always `null` on the username path. Profiles that don't exist (or only match fuzzily) return `404`.
|
|
388
|
+
*
|
|
389
|
+
* @param {PredictorSDK.GetPolymarketWalletRequest} request
|
|
390
|
+
* @param {PredictorSDKClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
391
|
+
*
|
|
392
|
+
* @throws {@link PredictorSDK.BadRequestError}
|
|
393
|
+
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
394
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
395
|
+
* @throws {@link PredictorSDK.ForbiddenError}
|
|
396
|
+
* @throws {@link PredictorSDK.NotFoundError}
|
|
397
|
+
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
398
|
+
* @throws {@link PredictorSDK.BadGatewayError}
|
|
399
|
+
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* await client.getPolymarketWallet({
|
|
403
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
404
|
+
* })
|
|
405
|
+
*/
|
|
406
|
+
getPolymarketWallet(request = {}, requestOptions) {
|
|
407
|
+
return core.HttpResponsePromise.fromPromise(this.__getPolymarketWallet(request, requestOptions));
|
|
408
|
+
}
|
|
409
|
+
async __getPolymarketWallet(request = {}, requestOptions) {
|
|
410
|
+
const { address, username } = request;
|
|
411
|
+
const _queryParams = {
|
|
412
|
+
address,
|
|
413
|
+
username,
|
|
414
|
+
};
|
|
415
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
416
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
417
|
+
const _response = await core.fetcher({
|
|
418
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
419
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
420
|
+
environments.PredictorSDKEnvironment.Production, "v1/polymarket/wallet"),
|
|
421
|
+
method: "GET",
|
|
422
|
+
headers: _headers,
|
|
423
|
+
queryString: core.url
|
|
424
|
+
.queryBuilder()
|
|
425
|
+
.addMany(_queryParams)
|
|
426
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
427
|
+
.build(),
|
|
428
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
429
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
430
|
+
abortSignal: requestOptions?.abortSignal,
|
|
431
|
+
fetchFn: this._options?.fetch,
|
|
432
|
+
logging: this._options.logging,
|
|
433
|
+
});
|
|
434
|
+
if (_response.ok) {
|
|
435
|
+
return {
|
|
436
|
+
data: serializers.PolymarketWalletResponse.parseOrThrow(_response.body, {
|
|
437
|
+
unrecognizedObjectKeys: "passthrough",
|
|
438
|
+
allowUnrecognizedUnionMembers: true,
|
|
439
|
+
allowUnrecognizedEnumValues: true,
|
|
440
|
+
skipValidation: true,
|
|
441
|
+
breadcrumbsPrefix: ["response"],
|
|
442
|
+
}),
|
|
443
|
+
rawResponse: _response.rawResponse,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
if (_response.error.reason === "status-code") {
|
|
447
|
+
switch (_response.error.statusCode) {
|
|
448
|
+
case 400:
|
|
449
|
+
throw new PredictorSDK.BadRequestError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
450
|
+
unrecognizedObjectKeys: "passthrough",
|
|
451
|
+
allowUnrecognizedUnionMembers: true,
|
|
452
|
+
allowUnrecognizedEnumValues: true,
|
|
453
|
+
skipValidation: true,
|
|
454
|
+
breadcrumbsPrefix: ["response"],
|
|
455
|
+
}), _response.rawResponse);
|
|
456
|
+
case 401:
|
|
457
|
+
throw new PredictorSDK.UnauthorizedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
458
|
+
unrecognizedObjectKeys: "passthrough",
|
|
459
|
+
allowUnrecognizedUnionMembers: true,
|
|
460
|
+
allowUnrecognizedEnumValues: true,
|
|
461
|
+
skipValidation: true,
|
|
462
|
+
breadcrumbsPrefix: ["response"],
|
|
463
|
+
}), _response.rawResponse);
|
|
464
|
+
case 402:
|
|
465
|
+
throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
|
|
466
|
+
unrecognizedObjectKeys: "passthrough",
|
|
467
|
+
allowUnrecognizedUnionMembers: true,
|
|
468
|
+
allowUnrecognizedEnumValues: true,
|
|
469
|
+
skipValidation: true,
|
|
470
|
+
breadcrumbsPrefix: ["response"],
|
|
471
|
+
}), _response.rawResponse);
|
|
472
|
+
case 403:
|
|
473
|
+
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
474
|
+
unrecognizedObjectKeys: "passthrough",
|
|
475
|
+
allowUnrecognizedUnionMembers: true,
|
|
476
|
+
allowUnrecognizedEnumValues: true,
|
|
477
|
+
skipValidation: true,
|
|
478
|
+
breadcrumbsPrefix: ["response"],
|
|
479
|
+
}), _response.rawResponse);
|
|
480
|
+
case 404:
|
|
481
|
+
throw new PredictorSDK.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
482
|
+
unrecognizedObjectKeys: "passthrough",
|
|
483
|
+
allowUnrecognizedUnionMembers: true,
|
|
484
|
+
allowUnrecognizedEnumValues: true,
|
|
485
|
+
skipValidation: true,
|
|
486
|
+
breadcrumbsPrefix: ["response"],
|
|
487
|
+
}), _response.rawResponse);
|
|
488
|
+
case 429:
|
|
489
|
+
throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
490
|
+
unrecognizedObjectKeys: "passthrough",
|
|
491
|
+
allowUnrecognizedUnionMembers: true,
|
|
492
|
+
allowUnrecognizedEnumValues: true,
|
|
493
|
+
skipValidation: true,
|
|
494
|
+
breadcrumbsPrefix: ["response"],
|
|
495
|
+
}), _response.rawResponse);
|
|
496
|
+
case 502:
|
|
497
|
+
throw new PredictorSDK.BadGatewayError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
498
|
+
unrecognizedObjectKeys: "passthrough",
|
|
499
|
+
allowUnrecognizedUnionMembers: true,
|
|
500
|
+
allowUnrecognizedEnumValues: true,
|
|
501
|
+
skipValidation: true,
|
|
502
|
+
breadcrumbsPrefix: ["response"],
|
|
503
|
+
}), _response.rawResponse);
|
|
504
|
+
case 503:
|
|
505
|
+
throw new PredictorSDK.ServiceUnavailableError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
506
|
+
unrecognizedObjectKeys: "passthrough",
|
|
507
|
+
allowUnrecognizedUnionMembers: true,
|
|
508
|
+
allowUnrecognizedEnumValues: true,
|
|
509
|
+
skipValidation: true,
|
|
510
|
+
breadcrumbsPrefix: ["response"],
|
|
511
|
+
}), _response.rawResponse);
|
|
512
|
+
default:
|
|
513
|
+
throw new errors.PredictorSDKError({
|
|
514
|
+
statusCode: _response.error.statusCode,
|
|
515
|
+
body: _response.error.body,
|
|
516
|
+
rawResponse: _response.rawResponse,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/polymarket/wallet");
|
|
521
|
+
}
|
|
370
522
|
/**
|
|
371
523
|
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
372
524
|
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* address: "0x7c3db723f1d4d8cb9c550095203b686cb11e5c6b"
|
|
5
|
+
* }
|
|
6
|
+
*/
|
|
7
|
+
export interface GetPolymarketWalletRequest {
|
|
8
|
+
/** Wallet address to look up. May be a Polymarket proxy address or the underlying signer EOA — the endpoint resolves either form. Must match `^0x[a-fA-F0-9]{40}$`. Mixed-case input is accepted and lowercased in the response. Mutually exclusive with `username`; exactly one of the two is required. */
|
|
9
|
+
address?: string;
|
|
10
|
+
/** Polymarket display name to look up. Match is case-insensitive and exact against the user's stored `name` (so `Car`, `car`, and `CAR` all resolve, but `Theo` does not match `Theo47`). A leading `@` is accepted and stripped before the lookup. Mutually exclusive with `address`; exactly one of the two is required. Example: `Car`. */
|
|
11
|
+
username?: string;
|
|
12
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { GetBinanceCryptoPricesRequest } from "./GetBinanceCryptoPricesRequest.js";
|
|
2
2
|
export type { GetMarketsRequest } from "./GetMarketsRequest.js";
|
|
3
|
+
export type { GetPolymarketWalletRequest } from "./GetPolymarketWalletRequest.js";
|
|
3
4
|
export type { GetSportsMatchingMarketsRequest } from "./GetSportsMatchingMarketsRequest.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as core from "../../core/index.js";
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
import type * as PredictorSDK from "../index.js";
|
|
4
|
+
export declare class NotFoundError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
6
|
+
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
export class NotFoundError extends errors.PredictorSDKError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "NotFoundError",
|
|
7
|
+
statusCode: 404,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
+
export * from "./NotFoundError.js";
|
|
4
5
|
export * from "./PaymentRequiredError.js";
|
|
5
6
|
export * from "./ServiceUnavailableError.js";
|
|
6
7
|
export * from "./TooManyRequestsError.js";
|
package/dist/api/errors/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
+
export * from "./NotFoundError.js";
|
|
4
5
|
export * from "./PaymentRequiredError.js";
|
|
5
6
|
export * from "./ServiceUnavailableError.js";
|
|
6
7
|
export * from "./TooManyRequestsError.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PolymarketWalletResponse {
|
|
2
|
+
/** Polymarket proxy address (lowercased) the profile is keyed on. When the input was a signer EOA, this is the resolved proxy. */
|
|
3
|
+
address: string;
|
|
4
|
+
/** Original signer EOA from the request, when the input was an EOA that resolved to a different proxy. `null` when the input was already a proxy address (no resolution needed) or when no populated profile could be found for the resolved proxy. */
|
|
5
|
+
signer: string | null;
|
|
6
|
+
/** URL of the wallet's profile image, or `null` if unset. */
|
|
7
|
+
profileImage: string | null;
|
|
8
|
+
/** User-chosen display name when set; otherwise the auto-generated pseudonym Polymarket assigns. `null` only when both are missing. */
|
|
9
|
+
displayName: string | null;
|
|
10
|
+
}
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
package/dist/api/types/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
|
|
2
2
|
export type { AuthRequest } from "./AuthRequest.js";
|
|
3
3
|
export { BasicAuth } from "./BasicAuth.js";
|
|
4
4
|
export { BearerToken } from "./BearerToken.js";
|
package/dist/core/auth/index.js
CHANGED
|
@@ -8,7 +8,13 @@ export declare namespace Fetcher {
|
|
|
8
8
|
method: string;
|
|
9
9
|
contentType?: string;
|
|
10
10
|
headers?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `queryString` (produced by `core.url.queryBuilder()`).
|
|
13
|
+
* Retained for backwards compatibility with custom fetchers and callers that
|
|
14
|
+
* still construct request args with a query-parameter object.
|
|
15
|
+
*/
|
|
11
16
|
queryParameters?: Record<string, unknown>;
|
|
17
|
+
queryString?: string;
|
|
12
18
|
body?: unknown;
|
|
13
19
|
timeoutMs?: number;
|
|
14
20
|
maxRetries?: number;
|
|
@@ -62,16 +62,11 @@ const SENSITIVE_QUERY_PARAMS = new Set([
|
|
|
62
62
|
]);
|
|
63
63
|
function redactQueryParameters(queryParameters) {
|
|
64
64
|
if (queryParameters == null) {
|
|
65
|
-
return
|
|
65
|
+
return undefined;
|
|
66
66
|
}
|
|
67
67
|
const redacted = {};
|
|
68
68
|
for (const [key, value] of Object.entries(queryParameters)) {
|
|
69
|
-
|
|
70
|
-
redacted[key] = "[REDACTED]";
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
redacted[key] = value;
|
|
74
|
-
}
|
|
69
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
75
70
|
}
|
|
76
71
|
return redacted;
|
|
77
72
|
}
|
|
@@ -168,7 +163,13 @@ async function getHeaders(args) {
|
|
|
168
163
|
return newHeaders;
|
|
169
164
|
}
|
|
170
165
|
export async function fetcherImpl(args) {
|
|
171
|
-
|
|
166
|
+
let url = args.url;
|
|
167
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
168
|
+
url = `${url}?${args.queryString}`;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
172
|
+
}
|
|
172
173
|
const requestBody = await getRequestBody({
|
|
173
174
|
body: args.body,
|
|
174
175
|
type: args.requestType ?? "other",
|
|
@@ -2,6 +2,9 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
|
2
2
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
3
3
|
const DEFAULT_MAX_RETRIES = 2;
|
|
4
4
|
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
5
|
+
function isRetryableStatusCode(statusCode) {
|
|
6
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
7
|
+
}
|
|
5
8
|
function addPositiveJitter(delay) {
|
|
6
9
|
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
7
10
|
return delay * jitterMultiplier;
|
|
@@ -40,7 +43,7 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
|
40
43
|
export async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
41
44
|
let response = await requestFn();
|
|
42
45
|
for (let i = 0; i < maxRetries; ++i) {
|
|
43
|
-
if (
|
|
46
|
+
if (isRetryableStatusCode(response.status)) {
|
|
44
47
|
const delay = getRetryDelayFromHeaders(response, i);
|
|
45
48
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
46
49
|
response = await requestFn();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { enum_ } from "./enum.js";
|
|
1
|
+
export { enum_, forwardCompatibleEnum_ } from "./enum.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { enum_ } from "./enum.js";
|
|
1
|
+
export { enum_, forwardCompatibleEnum_ } from "./enum.js";
|
|
@@ -4,6 +4,7 @@ export class JsonError extends Error {
|
|
|
4
4
|
constructor(errors) {
|
|
5
5
|
super(errors.map(stringifyValidationError).join("; "));
|
|
6
6
|
this.errors = errors;
|
|
7
|
-
Object.setPrototypeOf(this,
|
|
7
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
+
this.name = this.constructor.name;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -4,6 +4,7 @@ export class ParseError extends Error {
|
|
|
4
4
|
constructor(errors) {
|
|
5
5
|
super(errors.map(stringifyValidationError).join("; "));
|
|
6
6
|
this.errors = errors;
|
|
7
|
-
Object.setPrototypeOf(this,
|
|
7
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
+
this.name = this.constructor.name;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fluent builder for constructing URL query strings.
|
|
3
|
+
*
|
|
4
|
+
* Each `.add()` call serializes its value immediately (like C#'s builder),
|
|
5
|
+
* so no format tracking is needed — the style is applied at add-time.
|
|
6
|
+
*
|
|
7
|
+
* Usage (generated code):
|
|
8
|
+
*
|
|
9
|
+
* const qs = core.url.queryBuilder()
|
|
10
|
+
* .add("limit", limit)
|
|
11
|
+
* .add("tags", tags, { style: "comma" }) // explode: false
|
|
12
|
+
* .mergeAdditional(requestOptions?.queryParams)
|
|
13
|
+
* .build();
|
|
14
|
+
*/
|
|
15
|
+
export declare function queryBuilder(): QueryStringBuilder;
|
|
16
|
+
declare class QueryStringBuilder {
|
|
17
|
+
private parts;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a query parameter, serializing it immediately.
|
|
20
|
+
*
|
|
21
|
+
* By default arrays use "repeat" format (`key=a&key=b`).
|
|
22
|
+
* Pass `{ style: "comma" }` for OpenAPI `explode: false` parameters
|
|
23
|
+
* to get comma-separated values (`key=a,b,c`).
|
|
24
|
+
*
|
|
25
|
+
* Null / undefined values are silently skipped.
|
|
26
|
+
*/
|
|
27
|
+
add(key: string, value: unknown, options?: {
|
|
28
|
+
style?: "comma";
|
|
29
|
+
}): this;
|
|
30
|
+
/**
|
|
31
|
+
* Adds multiple query parameters at once from a record.
|
|
32
|
+
* All parameters use the default "repeat" array format.
|
|
33
|
+
* Null / undefined values are silently skipped.
|
|
34
|
+
*/
|
|
35
|
+
addMany(params: Record<string, unknown>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Merges additional query parameters supplied at call-time via
|
|
38
|
+
* `requestOptions.queryParams`. Overrides existing keys (last-write-wins).
|
|
39
|
+
*/
|
|
40
|
+
mergeAdditional(additionalParams?: Record<string, unknown>): this;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the assembled query string (without the leading `?`).
|
|
43
|
+
* Returns an empty string when no parameters were added.
|
|
44
|
+
*/
|
|
45
|
+
build(): string;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { toQueryString } from "./qs.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a fluent builder for constructing URL query strings.
|
|
4
|
+
*
|
|
5
|
+
* Each `.add()` call serializes its value immediately (like C#'s builder),
|
|
6
|
+
* so no format tracking is needed — the style is applied at add-time.
|
|
7
|
+
*
|
|
8
|
+
* Usage (generated code):
|
|
9
|
+
*
|
|
10
|
+
* const qs = core.url.queryBuilder()
|
|
11
|
+
* .add("limit", limit)
|
|
12
|
+
* .add("tags", tags, { style: "comma" }) // explode: false
|
|
13
|
+
* .mergeAdditional(requestOptions?.queryParams)
|
|
14
|
+
* .build();
|
|
15
|
+
*/
|
|
16
|
+
export function queryBuilder() {
|
|
17
|
+
return new QueryStringBuilder();
|
|
18
|
+
}
|
|
19
|
+
class QueryStringBuilder {
|
|
20
|
+
parts = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Adds a query parameter, serializing it immediately.
|
|
23
|
+
*
|
|
24
|
+
* By default arrays use "repeat" format (`key=a&key=b`).
|
|
25
|
+
* Pass `{ style: "comma" }` for OpenAPI `explode: false` parameters
|
|
26
|
+
* to get comma-separated values (`key=a,b,c`).
|
|
27
|
+
*
|
|
28
|
+
* Null / undefined values are silently skipped.
|
|
29
|
+
*/
|
|
30
|
+
add(key, value, options) {
|
|
31
|
+
if (value === undefined || value === null) {
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
const serialized = toQueryString({ [key]: value }, { arrayFormat: options?.style === "comma" ? "comma" : "repeat" });
|
|
35
|
+
if (serialized.length > 0) {
|
|
36
|
+
this.parts.set(key, serialized);
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Adds multiple query parameters at once from a record.
|
|
42
|
+
* All parameters use the default "repeat" array format.
|
|
43
|
+
* Null / undefined values are silently skipped.
|
|
44
|
+
*/
|
|
45
|
+
addMany(params) {
|
|
46
|
+
if (params != null) {
|
|
47
|
+
for (const [key, value] of Object.entries(params)) {
|
|
48
|
+
this.add(key, value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Merges additional query parameters supplied at call-time via
|
|
55
|
+
* `requestOptions.queryParams`. Overrides existing keys (last-write-wins).
|
|
56
|
+
*/
|
|
57
|
+
mergeAdditional(additionalParams) {
|
|
58
|
+
if (additionalParams != null) {
|
|
59
|
+
for (const [key, value] of Object.entries(additionalParams)) {
|
|
60
|
+
if (value === undefined || value === null) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const serialized = toQueryString({ [key]: value }, { arrayFormat: "repeat" });
|
|
64
|
+
if (serialized.length > 0) {
|
|
65
|
+
this.parts.set(key, serialized);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the assembled query string (without the leading `?`).
|
|
73
|
+
* Returns an empty string when no parameters were added.
|
|
74
|
+
*/
|
|
75
|
+
build() {
|
|
76
|
+
return [...this.parts.values()].join("&");
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/core/url/index.d.ts
CHANGED
package/dist/core/url/index.js
CHANGED
package/dist/core/url/qs.d.ts
CHANGED
package/dist/core/url/qs.js
CHANGED
|
@@ -23,19 +23,31 @@ function stringifyObject(obj, prefix = "", options) {
|
|
|
23
23
|
if (value.length === 0) {
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const effectiveFormat = options.arrayFormat;
|
|
27
|
+
if (effectiveFormat === "comma") {
|
|
28
|
+
const encodedKey = options.encode ? encodeURIComponent(fullKey) : fullKey;
|
|
29
|
+
const encodedValues = value
|
|
30
|
+
.filter((item) => item !== undefined && item !== null)
|
|
31
|
+
.map((item) => encodeValue(item, options.encode));
|
|
32
|
+
if (encodedValues.length > 0) {
|
|
33
|
+
parts.push(`${encodedKey}=${encodedValues.join(",")}`);
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
for (let i = 0; i < value.length; i++) {
|
|
38
|
+
const item = value[i];
|
|
39
|
+
if (item === undefined) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (typeof item === "object" && !Array.isArray(item) && item !== null) {
|
|
43
|
+
const arrayKey = effectiveFormat === "indices" ? `${fullKey}[${i}]` : fullKey;
|
|
44
|
+
parts.push(...stringifyObject(item, arrayKey, options));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const arrayKey = effectiveFormat === "indices" ? `${fullKey}[${i}]` : fullKey;
|
|
48
|
+
const encodedKey = options.encode ? encodeURIComponent(arrayKey) : arrayKey;
|
|
49
|
+
parts.push(`${encodedKey}=${encodeValue(item, options.encode)}`);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 PolymarketWalletResponse: core.serialization.ObjectSchema<serializers.PolymarketWalletResponse.Raw, PredictorSDK.PolymarketWalletResponse>;
|
|
5
|
+
export declare namespace PolymarketWalletResponse {
|
|
6
|
+
interface Raw {
|
|
7
|
+
address: string;
|
|
8
|
+
signer?: string | null;
|
|
9
|
+
profile_image?: string | null;
|
|
10
|
+
display_name?: string | null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
export const PolymarketWalletResponse = core.serialization.object({
|
|
4
|
+
address: core.serialization.string(),
|
|
5
|
+
signer: core.serialization.string().nullable(),
|
|
6
|
+
profileImage: core.serialization.property("profile_image", core.serialization.string().nullable()),
|
|
7
|
+
displayName: core.serialization.property("display_name", core.serialization.string().nullable()),
|
|
8
|
+
});
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|
|
@@ -7,6 +7,7 @@ export * from "./PaymentRequiredErrorAction.js";
|
|
|
7
7
|
export * from "./PaymentRequiredErrorBody.js";
|
|
8
8
|
export * from "./PlatformMarket.js";
|
|
9
9
|
export * from "./PlatformMarketPlatform.js";
|
|
10
|
+
export * from "./PolymarketWalletResponse.js";
|
|
10
11
|
export * from "./SportsMatchingResponse.js";
|
|
11
12
|
export * from "./UnifiedMarket.js";
|
|
12
13
|
export * from "./UnifiedMarketProvider.js";
|