@structbuild/sdk 0.1.6 → 0.1.8
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/README.md +39 -0
- package/dist/client.d.ts +2 -2
- package/dist/generated/polymarket.d.ts +85 -142
- package/dist/generated/webhooks.d.ts +1548 -0
- package/dist/http.d.ts +3 -0
- package/dist/index.cjs +80 -42
- package/dist/index.cjs.map +12 -12
- package/dist/index.js +80 -42
- package/dist/index.js.map +12 -12
- package/dist/namespaces/base.d.ts +11 -0
- package/dist/namespaces/events.d.ts +1 -3
- package/dist/namespaces/index.d.ts +2 -2
- package/dist/namespaces/markets.d.ts +1 -3
- package/dist/namespaces/webhooks.d.ts +11 -0
- package/dist/types/helpers.d.ts +21 -3
- package/dist/types/index.d.ts +40 -65
- package/dist/types/webhook-helpers.d.ts +7 -0
- package/package.json +6 -3
- package/dist/namespaces/scoring.d.ts +0 -10
package/dist/types/helpers.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { components, operations } from "../generated/polymarket.js";
|
|
2
2
|
export type Schemas = components["schemas"];
|
|
3
|
-
export type
|
|
3
|
+
export type OperationQueryOf<Ops, K extends keyof Ops> = Ops[K] extends {
|
|
4
4
|
parameters: {
|
|
5
5
|
query?: infer Q;
|
|
6
6
|
};
|
|
7
7
|
} ? NonNullable<Q> : never;
|
|
8
|
-
export type
|
|
8
|
+
export type OperationPathOf<Ops, K extends keyof Ops> = Ops[K] extends {
|
|
9
9
|
parameters: {
|
|
10
10
|
path: infer P;
|
|
11
11
|
};
|
|
12
12
|
} ? P : never;
|
|
13
|
-
export type
|
|
13
|
+
export type OperationResponseOf<Ops, K extends keyof Ops> = Ops[K] extends {
|
|
14
14
|
responses: {
|
|
15
15
|
200: {
|
|
16
16
|
content: {
|
|
@@ -18,4 +18,22 @@ export type OperationResponse<K extends keyof operations> = operations[K] extend
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
} ? R : Ops[K] extends {
|
|
22
|
+
responses: {
|
|
23
|
+
201: {
|
|
24
|
+
content: {
|
|
25
|
+
"application/json": infer R;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
21
29
|
} ? R : never;
|
|
30
|
+
export type OperationRequestBodyOf<Ops, K extends keyof Ops> = Ops[K] extends {
|
|
31
|
+
requestBody: {
|
|
32
|
+
content: {
|
|
33
|
+
"application/json": infer B;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
} ? B : never;
|
|
37
|
+
export type OperationQuery<K extends keyof operations> = OperationQueryOf<operations, K>;
|
|
38
|
+
export type OperationPath<K extends keyof operations> = OperationPathOf<operations, K>;
|
|
39
|
+
export type OperationResponse<K extends keyof operations> = OperationResponseOf<operations, K>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export type { components, operations, paths } from "../generated/polymarket.js";
|
|
2
|
-
export type { Schemas, OperationQuery, OperationPath, OperationResponse } from "./helpers.js";
|
|
2
|
+
export type { Schemas, OperationQuery, OperationPath, OperationResponse, OperationQueryOf, OperationPathOf, OperationResponseOf, OperationRequestBodyOf } from "./helpers.js";
|
|
3
|
+
export type { WebhookSchemas, WebhookOperationQuery, WebhookOperationPath, WebhookOperationResponse, WebhookOperationRequestBody, } from "./webhook-helpers.js";
|
|
4
|
+
export type { components as WebhookComponents, operations as WebhookOperations, paths as WebhookPaths, } from "../generated/webhooks.js";
|
|
3
5
|
import type { Schemas, OperationQuery } from "./helpers.js";
|
|
6
|
+
import type { WebhookSchemas, WebhookOperationQuery, WebhookOperationRequestBody } from "./webhook-helpers.js";
|
|
4
7
|
export type BondMarket = Schemas["BondMarket"];
|
|
5
8
|
export type BondOutcome = Schemas["BondOutcome"];
|
|
6
9
|
export type CandlestickResolution = Schemas["CandlestickResolution"];
|
|
@@ -38,7 +41,6 @@ export type UserProfile = Schemas["PolymarketUserProfile"];
|
|
|
38
41
|
export type PositionHolderPnl = Schemas["PositionHolderPnl"];
|
|
39
42
|
export type PositionHoldersResponse = Schemas["PositionHoldersResponse"];
|
|
40
43
|
export type PositionMetricsResponse = Schemas["PositionMetricsResponse"];
|
|
41
|
-
export type PositionPnlSortBy = Schemas["PositionPnlSortBy"];
|
|
42
44
|
export type PositionStatus = Schemas["PositionStatus"];
|
|
43
45
|
export type PositionVolumeChartResponse = Schemas["PositionVolumeChartResponse"];
|
|
44
46
|
export type PositionVolumeDataPoint = Schemas["PositionVolumeDataPoint"];
|
|
@@ -64,48 +66,6 @@ export type GlobalPnlTimeframe = Schemas["PnlTimeframe"];
|
|
|
64
66
|
export type TradeSide = "Buy" | "Sell";
|
|
65
67
|
export type EventStatus = "active" | "resolved" | "ended" | "archived";
|
|
66
68
|
export type HolderSortBy = "shares_held" | "total_cost_usd" | "unrealized_pnl_usd";
|
|
67
|
-
export interface TraderScore {
|
|
68
|
-
trader: TraderInfo;
|
|
69
|
-
is_bot: boolean;
|
|
70
|
-
bot_confidence: number;
|
|
71
|
-
bot_reasons: string[];
|
|
72
|
-
smart_money_score: number;
|
|
73
|
-
insider_score: number;
|
|
74
|
-
insider_score_permanent: boolean;
|
|
75
|
-
market_count: number;
|
|
76
|
-
avg_trade_size_usd: string;
|
|
77
|
-
total_trades: number;
|
|
78
|
-
total_volume_usd: string;
|
|
79
|
-
first_trade_at: number | null;
|
|
80
|
-
last_trade_at: number;
|
|
81
|
-
}
|
|
82
|
-
export interface SmartMoneyEntry {
|
|
83
|
-
trader: TraderInfo;
|
|
84
|
-
smart_money_score: number;
|
|
85
|
-
total_trades: number;
|
|
86
|
-
total_volume_usd: string;
|
|
87
|
-
market_count: number;
|
|
88
|
-
last_trade_at: number;
|
|
89
|
-
}
|
|
90
|
-
export interface InsiderEntry {
|
|
91
|
-
trader: TraderInfo;
|
|
92
|
-
insider_score: number;
|
|
93
|
-
insider_score_permanent: boolean;
|
|
94
|
-
market_count: number;
|
|
95
|
-
avg_trade_size_usd: string;
|
|
96
|
-
total_trades: number;
|
|
97
|
-
first_trade_at: number | null;
|
|
98
|
-
last_trade_at: number;
|
|
99
|
-
}
|
|
100
|
-
export interface BotEntry {
|
|
101
|
-
trader: TraderInfo;
|
|
102
|
-
is_bot: boolean;
|
|
103
|
-
bot_confidence: number;
|
|
104
|
-
bot_reasons: string[];
|
|
105
|
-
total_trades: number;
|
|
106
|
-
total_volume_usd: string;
|
|
107
|
-
last_trade_at: number;
|
|
108
|
-
}
|
|
109
69
|
export type PortfolioTimeframe = "7d" | "30d" | "lifetime";
|
|
110
70
|
export interface PortfolioOutcome {
|
|
111
71
|
index: number;
|
|
@@ -398,12 +358,6 @@ export interface GetPositionHoldersHistoryParams {
|
|
|
398
358
|
}
|
|
399
359
|
export interface GetMarketsParams extends OperationQuery<"list_markets"> {
|
|
400
360
|
}
|
|
401
|
-
export interface GetMarketParams {
|
|
402
|
-
conditionId: string;
|
|
403
|
-
}
|
|
404
|
-
export interface GetMarketBySlugParams {
|
|
405
|
-
slug: string;
|
|
406
|
-
}
|
|
407
361
|
export interface GetCandlestickParams extends OperationQuery<"get_market_candlestick"> {
|
|
408
362
|
}
|
|
409
363
|
export interface GetPositionCandlestickParams extends OperationQuery<"get_position_candlestick"> {
|
|
@@ -471,21 +425,42 @@ export interface GetTraderProfilesBatchParams {
|
|
|
471
425
|
export interface GetTraderVolumeChartParams extends OperationQuery<"get_trader_volume_chart"> {
|
|
472
426
|
address: string;
|
|
473
427
|
}
|
|
474
|
-
export
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
export
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
export
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
export
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
428
|
+
export type WebhookResponse = WebhookSchemas["WebhookResponse"];
|
|
429
|
+
export type WebhookListResponseBody = WebhookSchemas["WebhookListResponseBody"];
|
|
430
|
+
export type WebhookTestResponseBody = WebhookSchemas["WebhookTestResponseBody"];
|
|
431
|
+
export type CreateWebhookRequestBody = WebhookSchemas["CreateWebhookRequestBody"];
|
|
432
|
+
export type UpdateWebhookRequestBody = WebhookSchemas["UpdateWebhookRequestBody"];
|
|
433
|
+
export type WebhookFiltersBody = WebhookSchemas["WebhookFiltersBody"];
|
|
434
|
+
export type WebhookStatusBody = WebhookSchemas["WebhookStatusBody"];
|
|
435
|
+
export type PolymarketWebhookEvent = WebhookSchemas["PolymarketWebhookEvent"];
|
|
436
|
+
export type PolymarketWebhookFilter = WebhookSchemas["PolymarketWebhookFilter"];
|
|
437
|
+
export type PnlTimeframeFilter = WebhookSchemas["PnlTimeframeFilter"];
|
|
438
|
+
export type FirstTradePayload = WebhookSchemas["FirstTradePayload"];
|
|
439
|
+
export type GlobalPnlPayload = WebhookSchemas["GlobalPnlPayload"];
|
|
440
|
+
export type MarketPnlPayload = WebhookSchemas["MarketPnlPayload"];
|
|
441
|
+
export type EventPnlPayload = WebhookSchemas["EventPnlPayload"];
|
|
442
|
+
export type ConditionMetricsPayload = WebhookSchemas["ConditionMetricsPayload"];
|
|
443
|
+
export type EventMetricsPayload = WebhookSchemas["EventMetricsPayload"];
|
|
444
|
+
export type PositionMetricsPayload = WebhookSchemas["PositionMetricsPayload"];
|
|
445
|
+
export type VolumeMilestonePayload = WebhookSchemas["VolumeMilestonePayload"];
|
|
446
|
+
export type EventVolumeMilestonePayload = WebhookSchemas["EventVolumeMilestonePayload"];
|
|
447
|
+
export type PositionVolumeMilestonePayload = WebhookSchemas["PositionVolumeMilestonePayload"];
|
|
448
|
+
export type ProbabilitySpikePayload = WebhookSchemas["ProbabilitySpikePayload"];
|
|
449
|
+
export interface ListWebhooksParams extends WebhookOperationQuery<"list_webhooks"> {
|
|
450
|
+
}
|
|
451
|
+
export interface GetWebhookParams {
|
|
452
|
+
webhookId: string;
|
|
453
|
+
}
|
|
454
|
+
export interface CreateWebhookParams extends WebhookOperationRequestBody<"create_webhook"> {
|
|
455
|
+
}
|
|
456
|
+
export interface UpdateWebhookParams extends WebhookOperationRequestBody<"update_webhook"> {
|
|
457
|
+
webhookId: string;
|
|
458
|
+
}
|
|
459
|
+
export interface DeleteWebhookParams {
|
|
460
|
+
webhookId: string;
|
|
461
|
+
}
|
|
462
|
+
export interface TestWebhookParams {
|
|
463
|
+
webhookId: string;
|
|
489
464
|
}
|
|
490
465
|
export type { RetryConfig, HttpClientConfig, RequestOptions, HttpResponse, RequestHookInfo, ResponseHookInfo, ApiResponseInfo } from "./http.js";
|
|
491
466
|
export type { Address, PaginationParams, SortParams, Venue } from "./common.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { components, operations } from "../generated/webhooks.js";
|
|
2
|
+
import type { OperationQueryOf, OperationPathOf, OperationResponseOf, OperationRequestBodyOf } from "./helpers.js";
|
|
3
|
+
export type WebhookSchemas = components["schemas"];
|
|
4
|
+
export type WebhookOperationQuery<K extends keyof operations> = OperationQueryOf<operations, K>;
|
|
5
|
+
export type WebhookOperationPath<K extends keyof operations> = OperationPathOf<operations, K>;
|
|
6
|
+
export type WebhookOperationResponse<K extends keyof operations> = OperationResponseOf<operations, K>;
|
|
7
|
+
export type WebhookOperationRequestBody<K extends keyof operations> = OperationRequestBodyOf<operations, K>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@structbuild/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "rm -rf dist && bun build ./src/index.ts --target browser --format esm --sourcemap --outdir ./dist && bun build ./src/index.ts --target browser --format cjs --sourcemap --outdir ./dist-cjs && mv ./dist-cjs/index.js ./dist/index.cjs && mv ./dist-cjs/index.js.map ./dist/index.cjs.map && rm -rf dist-cjs && tsc --emitDeclarationOnly",
|
|
25
|
-
"
|
|
25
|
+
"check-routes": "bun run scripts/check-routes.ts",
|
|
26
|
+
"prep": "bun run fetch-spec:polymarket && bun run generate:polymarket && bun run fetch-spec:webhooks && bun run generate:webhooks && bun run check-routes && bun run build",
|
|
26
27
|
"typecheck": "bun run tsc --noEmit",
|
|
27
28
|
"fetch-spec:polymarket": "curl -s -o openapi/polymarket.json https://api.struct.to/api-docs/openapi.json",
|
|
28
|
-
"generate:polymarket": "openapi-typescript openapi/polymarket.json -o src/generated/polymarket.ts"
|
|
29
|
+
"generate:polymarket": "openapi-typescript openapi/polymarket.json -o src/generated/polymarket.ts",
|
|
30
|
+
"fetch-spec:webhooks": "curl -s -o openapi/webhooks.json https://api.struct.to/webhookopenapi.json",
|
|
31
|
+
"generate:webhooks": "openapi-typescript openapi/webhooks.json -o src/generated/webhooks.ts"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
34
|
"@types/bun": "latest",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Namespace } from "./base.js";
|
|
2
|
-
import type { HttpResponse } from "../types/http.js";
|
|
3
|
-
import type { Venue } from "../types/common.js";
|
|
4
|
-
import type { TraderScore, SmartMoneyEntry, InsiderEntry, BotEntry, GetTraderScoreParams, LeaderboardParams } from "../types/index.js";
|
|
5
|
-
export declare class ScoringNamespace extends Namespace {
|
|
6
|
-
getTraderScore(params: GetTraderScoreParams, venue?: Venue): Promise<HttpResponse<TraderScore>>;
|
|
7
|
-
getSmartMoneyLeaderboard(params?: LeaderboardParams, venue?: Venue): Promise<HttpResponse<SmartMoneyEntry[]>>;
|
|
8
|
-
getInsiderLeaderboard(params?: LeaderboardParams, venue?: Venue): Promise<HttpResponse<InsiderEntry[]>>;
|
|
9
|
-
getBots(params?: LeaderboardParams, venue?: Venue): Promise<HttpResponse<BotEntry[]>>;
|
|
10
|
-
}
|