@piaa/sdk 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Merrr <wign@wign.dev>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # @piaa/sdk (Official TypeScript / JavaScript SDK)
2
+
3
+ The official, production-ready SDK for the **PIA Market Intelligence & Realtime Financial Platform**.
4
+
5
+ Designed for institutional algorithmic traders, fintech dashboards, and quantitative applications across **Node.js 18+**, **Bun**, **Deno**, and modern **Browsers**.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - ⚡ **Zero-Fuss Sensible Defaults**: Connect in 3 lines of code with pre-configured endpoints and sensible timeout/retry defaults.
12
+ - 🔁 **Enterprise Resiliency**: Automatic exponential backoff with full jitter for transient 5xx/429 network hiccups and retry-after headers.
13
+ - 🛡️ **Typed Error Hierarchy**: Clear, actionable, strongly-typed errors (`AuthenticationError`, `RateLimitError`, `TimeoutError`, `ValidationError`, `NetworkError`).
14
+ - 🔒 **Zero Sensitive Data Leaks**: Automatic redaction of API keys, bearer tokens, and secrets from error logs and stack traces.
15
+ - 📡 **Cross-Platform Realtime Streaming**: Built-in resilient WebSocket client with **In-Band Message Authentication**, ping/pong keep-alives, and automatic re-subscription on reconnect.
16
+ - 📊 **Rate Limit Telemetry**: Real-time inspection of RFC 6585 and daily quota headers (`X-RateLimit-*`, `X-DailyQuota-*`).
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ # Using bun
24
+ bun add @piaa/sdk
25
+
26
+ # Using npm
27
+ npm install @piaa/sdk
28
+
29
+ # Using pnpm / yarn
30
+ pnpm add @piaa/sdk
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Quickstart
36
+
37
+ ### 1. REST API Usage
38
+
39
+ ```typescript
40
+ import { PiaClient, RateLimitError, AuthenticationError } from "@piaa/sdk";
41
+
42
+ // Automatically picks up process.env.PIA_API_KEY if omitted
43
+ const client = new PiaClient({
44
+ apiKey: "wi_live_your_api_key",
45
+ });
46
+
47
+ async function run() {
48
+ try {
49
+ // 1. Fetch live multi-asset snapshot (105+ symbols)
50
+ const prices = await client.market.getPrices();
51
+ console.log(`Tracked assets: ${prices.total}`);
52
+ for (const item of prices.items.slice(0, 5)) {
53
+ console.log(`[${item.symbol}] $${item.price} (${item.asset_type})`);
54
+ }
55
+
56
+ // 2. Fetch historical OHLCV candlesticks
57
+ const candles = await client.market.getCandles("XAUUSD", {
58
+ timeframe: "1h",
59
+ limit: 100,
60
+ });
61
+ console.log(`Fetched ${candles.count} bars for ${candles.symbol}`);
62
+
63
+ // 3. Inspect rate limit telemetry
64
+ const quota = client.getRateLimitInfo();
65
+ console.log(`Remaining daily hits: ${quota.dailyRemaining}/${quota.dailyLimit}`);
66
+ } catch (err) {
67
+ if (err instanceof AuthenticationError) {
68
+ console.error("Invalid or expired API key.");
69
+ } else if (err instanceof RateLimitError) {
70
+ console.error(`Rate limited! Retry after ${err.retryAfterSeconds} seconds.`);
71
+ } else {
72
+ console.error("API error:", err);
73
+ }
74
+ }
75
+ }
76
+
77
+ run();
78
+ ```
79
+
80
+ ---
81
+
82
+ ### 2. Realtime WebSocket Streaming (In-Band Message Auth)
83
+
84
+ Cross-platform streaming without query-string leakage:
85
+
86
+ ```typescript
87
+ import { PiaClient } from "@piaa/sdk";
88
+
89
+ const client = new PiaClient({ apiKey: "wi_live_..." });
90
+
91
+ // Listen for connection events
92
+ client.realtime.on("connect", () => {
93
+ console.log("WebSocket connected. Authenticating...");
94
+ });
95
+
96
+ // Fired once In-Band authentication is accepted by the server
97
+ client.realtime.on("authenticated", (info) => {
98
+ console.log("Authenticated! Tier:", info.plan);
99
+
100
+ // Subscribe to market symbols
101
+ client.realtime.subscribe(["XAUUSD", "BTCUSDT", "EURUSD"]);
102
+ });
103
+
104
+ // Handle real-time price ticks
105
+ client.realtime.on("tick", (tick) => {
106
+ console.log(`[TICK] ${tick.symbol} -> $${tick.price} (bid: ${tick.bid}, ask: ${tick.ask})`);
107
+ });
108
+
109
+ // Handle disconnections (auto-reconnect is handled automatically)
110
+ client.realtime.on("disconnect", ({ code, reason }) => {
111
+ console.warn(`WebSocket closed (${code}): ${reason}`);
112
+ });
113
+
114
+ // Start streaming
115
+ client.realtime.connect();
116
+
117
+ // To stop and prevent auto-reconnection:
118
+ // client.realtime.disconnect();
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Configuration Reference
124
+
125
+ ```typescript
126
+ const client = new PiaClient({
127
+ // Secret API key. Falls back to process.env.PIA_API_KEY
128
+ apiKey: "wi_live_...",
129
+
130
+ // Unified REST gateway (Default: "https://api-engine.wign.dev")
131
+ baseUrl: "https://api-engine.wign.dev",
132
+
133
+ // Realtime streaming gateway (Default: "wss://api-engine.wign.dev/api/v1/ws")
134
+ wsUrl: "wss://api-engine.wign.dev/api/v1/ws",
135
+
136
+ // Request timeout in milliseconds (Default: 15,000)
137
+ timeoutMs: 10_000,
138
+
139
+ // Maximum retry attempts for transient errors (Default: 3)
140
+ maxRetries: 3,
141
+
142
+ // Initial retry delay for exponential backoff (Default: 500ms)
143
+ retryDelayMs: 500,
144
+
145
+ // Custom HTTP headers injected into all requests
146
+ headers: {
147
+ "X-Client-App": "my-trading-bot",
148
+ },
149
+
150
+ // Custom fetch implementation (useful for mocking or custom proxies)
151
+ fetch: customFetch,
152
+
153
+ // Custom WebSocket implementation (e.g. 'ws' in Node.js)
154
+ WebSocket: customWebSocket,
155
+
156
+ // Enable verbose debug logs (Default: false)
157
+ debug: false,
158
+ });
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Error Handling
164
+
165
+ All errors thrown by the SDK inherit from `PiaError`:
166
+
167
+ | Error Class | HTTP Status | Description | Properties |
168
+ |---|---|---|---|
169
+ | `ConfigurationError` | N/A | Missing or invalid client configuration | `message` |
170
+ | `ValidationError` | N/A | Invalid method arguments (e.g. empty symbol) | `paramName` |
171
+ | `AuthenticationError` | 401 | Invalid, expired, or revoked API key | `statusCode`, `endpoint` |
172
+ | `PermissionError` | 403 | API key lacks required scope (e.g. `realtime:ws`) | `requiredScope` |
173
+ | `RateLimitError` | 429 | Rate limit or daily quota exceeded | `retryAfterSeconds`, `dailyRemaining`, `minuteRemaining` |
174
+ | `TimeoutError` | 408 / N/A | Request exceeded configured `timeoutMs` | `timeoutMs`, `endpoint` |
175
+ | `NetworkError` | N/A | Network drop, DNS resolution failure | `causeError` |
176
+ | `ParseError` | N/A | Response was not valid JSON | `rawText` |
177
+ | `ApiError` | Other | General HTTP errors | `statusCode`, `rawBody` |
178
+
179
+ ---
180
+
181
+ ## Testing
182
+
183
+ Run the test suite using Bun:
184
+
185
+ ```bash
186
+ bun test
187
+ ```
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Official PIA SDK - Main Client Facade
3
+ */
4
+ import { type PiaClientOptions, type ResolvedPiaConfig } from "./config";
5
+ import { RealtimeClient } from "./realtime/socket";
6
+ import { MarketResource } from "./resources/market";
7
+ import { NewsResource } from "./resources/news";
8
+ import { SocialResource } from "./resources/social";
9
+ import { WsResource } from "./resources/ws";
10
+ import type { RateLimitInfo } from "./types";
11
+ export declare class PiaClient {
12
+ readonly config: Readonly<ResolvedPiaConfig>;
13
+ private readonly transport;
14
+ /**
15
+ * Market data & prices API resource.
16
+ */
17
+ readonly market: MarketResource;
18
+ /**
19
+ * Social sentiment and discussions resource.
20
+ */
21
+ readonly social: SocialResource;
22
+ /**
23
+ * Financial news resource.
24
+ */
25
+ readonly news: NewsResource;
26
+ /**
27
+ * WebSocket ticket issuance resource.
28
+ */
29
+ readonly ws: WsResource;
30
+ /**
31
+ * Resilient realtime WebSocket streaming client with In-Band Auth.
32
+ */
33
+ readonly realtime: RealtimeClient;
34
+ /**
35
+ * Initializes a new PIA API Client.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { PiaClient } from "@piaa/sdk";
40
+ *
41
+ * const client = new PiaClient({ apiKey: "wi_live_..." });
42
+ * const prices = await client.market.getPrices();
43
+ * ```
44
+ */
45
+ constructor(options?: PiaClientOptions);
46
+ /**
47
+ * Returns telemetry on rate limit and daily quota usage from the latest request.
48
+ */
49
+ getRateLimitInfo(): RateLimitInfo;
50
+ }
51
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAiB,MAAM,UAAU,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,SAAS;IACpB,SAAgB,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAE1C;;OAEG;IACH,SAAgB,MAAM,EAAE,cAAc,CAAC;IAEvC;;OAEG;IACH,SAAgB,MAAM,EAAE,cAAc,CAAC;IAEvC;;OAEG;IACH,SAAgB,IAAI,EAAE,YAAY,CAAC;IAEnC;;OAEG;IACH,SAAgB,EAAE,EAAE,UAAU,CAAC;IAE/B;;OAEG;IACH,SAAgB,QAAQ,EAAE,cAAc,CAAC;IAEzC;;;;;;;;;;OAUG;IACH,YAAY,OAAO,GAAE,gBAAqB,EASzC;IAED;;OAEG;IACI,gBAAgB,IAAI,aAAa,CAEvC;CACF"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Official PIA SDK - Configuration & Validation
3
+ */
4
+ import { type LogLevel, type PiaLogger } from "./logger";
5
+ export interface PiaClientOptions {
6
+ /**
7
+ * Secret or live API Key (e.g. "wi_live_...").
8
+ * If omitted, the SDK attempts to read from process.env.PIA_API_KEY or ATSLD_API_KEY.
9
+ */
10
+ apiKey?: string;
11
+ /**
12
+ * Base URL for the unified REST gateway.
13
+ * Default: "https://api-engine.wign.dev"
14
+ */
15
+ baseUrl?: string;
16
+ /**
17
+ * WebSocket URL for realtime streaming.
18
+ * Default: "wss://api-engine.wign.dev/api/v1/ws"
19
+ */
20
+ wsUrl?: string;
21
+ /**
22
+ * Global HTTP request timeout in milliseconds.
23
+ * Default: 15_000 (15s)
24
+ */
25
+ timeoutMs?: number;
26
+ /**
27
+ * Maximum number of retry attempts for transient failures (408, 429, 5xx).
28
+ * Default: 3
29
+ */
30
+ maxRetries?: number;
31
+ /**
32
+ * Base initial delay for exponential backoff in milliseconds.
33
+ * Default: 500
34
+ */
35
+ retryDelayMs?: number;
36
+ /**
37
+ * Maximum cap on retry backoff delay in milliseconds.
38
+ * Default: 10_000 (10s)
39
+ */
40
+ maxRetryDelayMs?: number;
41
+ /**
42
+ * Custom HTTP headers injected into all requests.
43
+ */
44
+ headers?: Record<string, string>;
45
+ /**
46
+ * Custom fetch implementation (useful for tests or runtime environments).
47
+ */
48
+ fetch?: typeof fetch;
49
+ /**
50
+ * Custom WebSocket implementation (e.g. 'ws' in Node.js).
51
+ */
52
+ WebSocket?: unknown;
53
+ /**
54
+ * Custom logger instance.
55
+ */
56
+ logger?: PiaLogger;
57
+ /**
58
+ * Logging level when using the default logger.
59
+ * Default: "warn" (or "debug" if debug: true)
60
+ */
61
+ logLevel?: LogLevel;
62
+ /**
63
+ * Enable verbose debug logs.
64
+ * Default: false
65
+ */
66
+ debug?: boolean;
67
+ }
68
+ export interface ResolvedPiaConfig {
69
+ apiKey: string;
70
+ baseUrl: string;
71
+ wsUrl: string;
72
+ timeoutMs: number;
73
+ maxRetries: number;
74
+ retryDelayMs: number;
75
+ maxRetryDelayMs: number;
76
+ headers: Record<string, string>;
77
+ fetch: typeof fetch;
78
+ WebSocket?: unknown;
79
+ logger: PiaLogger;
80
+ debug: boolean;
81
+ }
82
+ export declare const DEFAULT_BASE_URL = "https://api-engine.wign.dev";
83
+ export declare const DEFAULT_WS_URL = "wss://api-engine.wign.dev/api/v1/ws";
84
+ export declare const DEFAULT_TIMEOUT_MS = 15000;
85
+ export declare const DEFAULT_MAX_RETRIES = 3;
86
+ export declare const DEFAULT_RETRY_DELAY_MS = 500;
87
+ export declare const DEFAULT_MAX_RETRY_DELAY_MS = 10000;
88
+ /**
89
+ * Validates and resolves full client configuration with sensible defaults.
90
+ */
91
+ export declare function resolveConfig(options?: PiaClientOptions): ResolvedPiaConfig;
92
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src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KAAK,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,gBAAgB,gCAAgC,CAAC;AAC9D,eAAO,MAAM,cAAc,wCAAwC,CAAC;AACpE,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAcjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,gBAAqB,GAAG,iBAAiB,CAuF/E"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Official PIA SDK - Strongly Typed Error Hierarchy
3
+ */
4
+ export interface PiaErrorDetails {
5
+ statusCode?: number;
6
+ endpoint?: string;
7
+ method?: string;
8
+ requestId?: string | null;
9
+ headers?: Record<string, string>;
10
+ rawResponse?: unknown;
11
+ }
12
+ /**
13
+ * Base class for all errors thrown by the PIA SDK.
14
+ */
15
+ export declare class PiaError extends Error {
16
+ readonly isPiaError = true;
17
+ readonly statusCode?: number;
18
+ readonly endpoint?: string;
19
+ readonly method?: string;
20
+ readonly requestId?: string | null;
21
+ constructor(message: string, details?: PiaErrorDetails);
22
+ }
23
+ /**
24
+ * Thrown when client configuration is invalid (e.g. missing API key, invalid URL).
25
+ */
26
+ export declare class ConfigurationError extends PiaError {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Thrown when caller passes invalid arguments (e.g. empty symbol, negative limit).
31
+ */
32
+ export declare class ValidationError extends PiaError {
33
+ readonly paramName?: string;
34
+ constructor(message: string, paramName?: string);
35
+ }
36
+ /**
37
+ * Thrown on HTTP 401 Unauthorized (invalid or revoked API key).
38
+ * Redacts any sensitive data.
39
+ */
40
+ export declare class AuthenticationError extends PiaError {
41
+ constructor(message?: string, details?: PiaErrorDetails);
42
+ }
43
+ /**
44
+ * Thrown on HTTP 403 Forbidden (missing required scope/permissions, e.g. 'realtime:ws').
45
+ */
46
+ export declare class PermissionError extends PiaError {
47
+ readonly requiredScope?: string;
48
+ constructor(message: string, requiredScope?: string, details?: PiaErrorDetails);
49
+ }
50
+ /**
51
+ * Thrown on HTTP 429 Too Many Requests (rate limit or daily quota exceeded).
52
+ */
53
+ export declare class RateLimitError extends PiaError {
54
+ readonly retryAfterSeconds?: number;
55
+ readonly dailyLimit?: number;
56
+ readonly dailyRemaining?: number;
57
+ readonly minuteLimit?: number;
58
+ readonly minuteRemaining?: number;
59
+ constructor(message: string, options?: {
60
+ retryAfterSeconds?: number;
61
+ dailyLimit?: number;
62
+ dailyRemaining?: number;
63
+ minuteLimit?: number;
64
+ minuteRemaining?: number;
65
+ details?: PiaErrorDetails;
66
+ });
67
+ }
68
+ /**
69
+ * Thrown when a request or operation exceeds the configured timeout threshold.
70
+ */
71
+ export declare class TimeoutError extends PiaError {
72
+ readonly timeoutMs: number;
73
+ constructor(message: string, timeoutMs: number, details?: PiaErrorDetails);
74
+ }
75
+ /**
76
+ * Thrown when network transport fails (DNS resolution, connection refused, connection reset).
77
+ */
78
+ export declare class NetworkError extends PiaError {
79
+ readonly causeError?: unknown;
80
+ constructor(message: string, cause?: unknown, details?: PiaErrorDetails);
81
+ }
82
+ /**
83
+ * Thrown when response parsing fails (malformed JSON or unexpected response body).
84
+ */
85
+ export declare class ParseError extends PiaError {
86
+ readonly rawText?: string;
87
+ constructor(message: string, rawText?: string, details?: PiaErrorDetails);
88
+ }
89
+ /**
90
+ * Thrown on generic unexpected API responses (4xx, 5xx).
91
+ */
92
+ export declare class ApiError extends PiaError {
93
+ readonly rawBody?: unknown;
94
+ constructor(message: string, statusCode: number, rawBody?: unknown, details?: PiaErrorDetails);
95
+ }
96
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,C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/**
2
+ * Official PIA SDK - Resilient HTTP Transport with Exponential Backoff & Telemetry
3
+ */
4
+ import type { ResolvedPiaConfig } from "../config";
5
+ import type { RateLimitInfo, RequestOptions } from "../types";
6
+ export declare class HttpTransport {
7
+ private readonly config;
8
+ private lastRateLimitInfo;
9
+ constructor(config: ResolvedPiaConfig);
10
+ /**
11
+ * Returns the most recent rate limit headers telemetry recorded by the SDK.
12
+ */
13
+ getRateLimitInfo(): RateLimitInfo;
14
+ /**
15
+ * Executes an HTTP request with automatic retry, jittered backoff, and timeout.
16
+ */
17
+ request<T>(endpoint: string, method?: "GET" | "POST" | "PUT" | "DELETE", body?: unknown, options?: RequestOptions): Promise<T>;
18
+ private parseTelemetryHeaders;
19
+ private calculateBackoffDelay;
20
+ private parseResponseBody;
21
+ private handleHttpError;
22
+ private sleep;
23
+ }
24
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/http/transport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAUnD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK9D,qBAAa,aAAa;IAGZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,iBAAiB,CAAqB;IAE9C,YAA6B,MAAM,EAAE,iBAAiB,EAAI;IAE1D;;OAEG;IACI,gBAAgB,IAAI,aAAa,CAEvC;IAED;;OAEG;IACU,OAAO,CAAC,CAAC,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAgB,EACjD,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC,CAsIZ;IAED,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,qBAAqB;YAiBf,iBAAiB;IAqB/B,OAAO,CAAC,eAAe;IAwCvB,OAAO,CAAC,KAAK;CAGd"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Official PIA SDK
3
+ * Enterprise market intelligence & realtime streaming SDK.
4
+ */
5
+ export { PiaClient } from "./client";
6
+ export { type PiaClientOptions, type ResolvedPiaConfig, resolveConfig, DEFAULT_BASE_URL, DEFAULT_WS_URL, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, } from "./config";
7
+ export { PiaError, type PiaErrorDetails, ConfigurationError, ValidationError, AuthenticationError, PermissionError, RateLimitError, TimeoutError, NetworkError, ParseError, ApiError, } from "./errors";
8
+ export { type PiaLogger, type LogLevel, DefaultLogger, redactSensitive, } from "./logger";
9
+ export { type Timeframe, type RateLimitInfo, type RequestOptions, type MarketPrice, type MarketPricesResponse, type Candle, type CandleResponse, type GetCandlesOptions, type OrderBook, type OrderBookLevel, type SocialPost, type SocialFeedResponse, type GetSocialOptions, type NewsArticle, type NewsFeedResponse, type GetNewsOptions, type WsTicketResponse, } from "./types";
10
+ export { RealtimeClient, type SocketState } from "./realtime/socket";
11
+ export { type RealtimeEvents } from "./realtime/events";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,QAAQ,EACR,KAAK,eAAe,EACpB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,QAAQ,GACT,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,aAAa,EACb,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC"}