@structbuild/sdk 0.1.5 → 0.1.7

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.
@@ -1,16 +1,16 @@
1
1
  import type { components, operations } from "../generated/polymarket.js";
2
2
  export type Schemas = components["schemas"];
3
- export type OperationQuery<K extends keyof operations> = operations[K] extends {
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 OperationPath<K extends keyof operations> = operations[K] extends {
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 OperationResponse<K extends keyof operations> = operations[K] extends {
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>;
@@ -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"];
@@ -64,48 +67,6 @@ export type GlobalPnlTimeframe = Schemas["PnlTimeframe"];
64
67
  export type TradeSide = "Buy" | "Sell";
65
68
  export type EventStatus = "active" | "resolved" | "ended" | "archived";
66
69
  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
70
  export type PortfolioTimeframe = "7d" | "30d" | "lifetime";
110
71
  export interface PortfolioOutcome {
111
72
  index: number;
@@ -398,12 +359,6 @@ export interface GetPositionHoldersHistoryParams {
398
359
  }
399
360
  export interface GetMarketsParams extends OperationQuery<"list_markets"> {
400
361
  }
401
- export interface GetMarketParams {
402
- conditionId: string;
403
- }
404
- export interface GetMarketBySlugParams {
405
- slug: string;
406
- }
407
362
  export interface GetCandlestickParams extends OperationQuery<"get_market_candlestick"> {
408
363
  }
409
364
  export interface GetPositionCandlestickParams extends OperationQuery<"get_position_candlestick"> {
@@ -471,21 +426,43 @@ export interface GetTraderProfilesBatchParams {
471
426
  export interface GetTraderVolumeChartParams extends OperationQuery<"get_trader_volume_chart"> {
472
427
  address: string;
473
428
  }
474
- export interface GetTraderScoreParams {
475
- address: string;
476
- }
477
- export interface LeaderboardParams {
478
- limit?: number;
479
- }
480
- export interface GetEventParams {
481
- id: string;
482
- include_tags?: boolean;
483
- include_markets?: boolean;
484
- }
485
- export interface GetEventBySlugParams {
486
- slug: string;
487
- include_tags?: boolean;
488
- include_markets?: boolean;
429
+ export type WebhookResponse = WebhookSchemas["WebhookResponse"];
430
+ export type WebhookListResponseBody = WebhookSchemas["WebhookListResponseBody"];
431
+ export type WebhookTestResponseBody = WebhookSchemas["WebhookTestResponseBody"];
432
+ export type CreateWebhookRequestBody = WebhookSchemas["CreateWebhookRequestBody"];
433
+ export type UpdateWebhookRequestBody = WebhookSchemas["UpdateWebhookRequestBody"];
434
+ export type WebhookFiltersBody = WebhookSchemas["WebhookFiltersBody"];
435
+ export type WebhookStatusBody = WebhookSchemas["WebhookStatusBody"];
436
+ export type PolymarketWebhookEvent = WebhookSchemas["PolymarketWebhookEvent"];
437
+ export type PolymarketWebhookFilter = WebhookSchemas["PolymarketWebhookFilter"];
438
+ export type PnlTimeframeFilter = WebhookSchemas["PnlTimeframeFilter"];
439
+ export type FirstTradePayload = WebhookSchemas["FirstTradePayload"];
440
+ export type GlobalPnlPayload = WebhookSchemas["GlobalPnlPayload"];
441
+ export type MarketPnlPayload = WebhookSchemas["MarketPnlPayload"];
442
+ export type EventPnlPayload = WebhookSchemas["EventPnlPayload"];
443
+ export type PositionPnlPayload = WebhookSchemas["PositionPnlPayload"];
444
+ export type ConditionMetricsPayload = WebhookSchemas["ConditionMetricsPayload"];
445
+ export type EventMetricsPayload = WebhookSchemas["EventMetricsPayload"];
446
+ export type PositionMetricsPayload = WebhookSchemas["PositionMetricsPayload"];
447
+ export type VolumeMilestonePayload = WebhookSchemas["VolumeMilestonePayload"];
448
+ export type EventVolumeMilestonePayload = WebhookSchemas["EventVolumeMilestonePayload"];
449
+ export type PositionVolumeMilestonePayload = WebhookSchemas["PositionVolumeMilestonePayload"];
450
+ export type ProbabilitySpikePayload = WebhookSchemas["ProbabilitySpikePayload"];
451
+ export interface ListWebhooksParams extends WebhookOperationQuery<"list_webhooks"> {
452
+ }
453
+ export interface GetWebhookParams {
454
+ webhookId: string;
455
+ }
456
+ export interface CreateWebhookParams extends WebhookOperationRequestBody<"create_webhook"> {
457
+ }
458
+ export interface UpdateWebhookParams extends WebhookOperationRequestBody<"update_webhook"> {
459
+ webhookId: string;
460
+ }
461
+ export interface DeleteWebhookParams {
462
+ webhookId: string;
463
+ }
464
+ export interface TestWebhookParams {
465
+ webhookId: string;
489
466
  }
490
467
  export type { RetryConfig, HttpClientConfig, RequestOptions, HttpResponse, RequestHookInfo, ResponseHookInfo, ApiResponseInfo } from "./http.js";
491
468
  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.5",
3
+ "version": "0.1.7",
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
- "prep": "bun run fetch-spec:polymarket && bun run generate:polymarket && bun run build",
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
- }