@fedpulse/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 +21 -0
- package/README.md +331 -0
- package/dist/cjs/client.cjs +138 -0
- package/dist/cjs/errors.cjs +200 -0
- package/dist/cjs/http.cjs +449 -0
- package/dist/cjs/index.cjs +65 -0
- package/dist/cjs/resources/analytics.cjs +134 -0
- package/dist/cjs/resources/assistance.cjs +101 -0
- package/dist/cjs/resources/entities.cjs +149 -0
- package/dist/cjs/resources/exclusions.cjs +135 -0
- package/dist/cjs/resources/intelligence.cjs +96 -0
- package/dist/cjs/resources/opportunities.cjs +170 -0
- package/dist/cjs/resources/webhooks.cjs +262 -0
- package/dist/cjs/types/analytics.cjs +5 -0
- package/dist/cjs/types/assistance.cjs +5 -0
- package/dist/cjs/types/common.cjs +5 -0
- package/dist/cjs/types/entities.cjs +5 -0
- package/dist/cjs/types/exclusions.cjs +5 -0
- package/dist/cjs/types/index.cjs +5 -0
- package/dist/cjs/types/intelligence.cjs +5 -0
- package/dist/cjs/types/opportunities.cjs +5 -0
- package/dist/cjs/types/webhooks.cjs +5 -0
- package/dist/cjs/webhooks-verify.cjs +184 -0
- package/dist/esm/client.js +135 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +187 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http.js +445 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/resources/analytics.js +131 -0
- package/dist/esm/resources/analytics.js.map +1 -0
- package/dist/esm/resources/assistance.js +98 -0
- package/dist/esm/resources/assistance.js.map +1 -0
- package/dist/esm/resources/entities.js +146 -0
- package/dist/esm/resources/entities.js.map +1 -0
- package/dist/esm/resources/exclusions.js +132 -0
- package/dist/esm/resources/exclusions.js.map +1 -0
- package/dist/esm/resources/intelligence.js +93 -0
- package/dist/esm/resources/intelligence.js.map +1 -0
- package/dist/esm/resources/opportunities.js +167 -0
- package/dist/esm/resources/opportunities.js.map +1 -0
- package/dist/esm/resources/webhooks.js +259 -0
- package/dist/esm/resources/webhooks.js.map +1 -0
- package/dist/esm/types/analytics.js +5 -0
- package/dist/esm/types/analytics.js.map +1 -0
- package/dist/esm/types/assistance.js +5 -0
- package/dist/esm/types/assistance.js.map +1 -0
- package/dist/esm/types/common.js +5 -0
- package/dist/esm/types/common.js.map +1 -0
- package/dist/esm/types/entities.js +5 -0
- package/dist/esm/types/entities.js.map +1 -0
- package/dist/esm/types/exclusions.js +5 -0
- package/dist/esm/types/exclusions.js.map +1 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/intelligence.js +5 -0
- package/dist/esm/types/intelligence.js.map +1 -0
- package/dist/esm/types/opportunities.js +5 -0
- package/dist/esm/types/opportunities.js.map +1 -0
- package/dist/esm/types/webhooks.js +5 -0
- package/dist/esm/types/webhooks.js.map +1 -0
- package/dist/esm/webhooks-verify.js +179 -0
- package/dist/esm/webhooks-verify.js.map +1 -0
- package/dist/types/client.d.cts +136 -0
- package/dist/types/client.d.ts +136 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.cts +139 -0
- package/dist/types/errors.d.ts +139 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/http.d.cts +137 -0
- package/dist/types/http.d.ts +137 -0
- package/dist/types/http.d.ts.map +1 -0
- package/dist/types/index.d.cts +39 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/resources/analytics.d.cts +94 -0
- package/dist/types/resources/analytics.d.ts +94 -0
- package/dist/types/resources/analytics.d.ts.map +1 -0
- package/dist/types/resources/assistance.d.cts +66 -0
- package/dist/types/resources/assistance.d.ts +66 -0
- package/dist/types/resources/assistance.d.ts.map +1 -0
- package/dist/types/resources/entities.d.cts +101 -0
- package/dist/types/resources/entities.d.ts +101 -0
- package/dist/types/resources/entities.d.ts.map +1 -0
- package/dist/types/resources/exclusions.d.cts +84 -0
- package/dist/types/resources/exclusions.d.ts +84 -0
- package/dist/types/resources/exclusions.d.ts.map +1 -0
- package/dist/types/resources/intelligence.d.cts +66 -0
- package/dist/types/resources/intelligence.d.ts +66 -0
- package/dist/types/resources/intelligence.d.ts.map +1 -0
- package/dist/types/resources/opportunities.d.cts +116 -0
- package/dist/types/resources/opportunities.d.ts +116 -0
- package/dist/types/resources/opportunities.d.ts.map +1 -0
- package/dist/types/resources/webhooks.d.cts +180 -0
- package/dist/types/resources/webhooks.d.ts +180 -0
- package/dist/types/resources/webhooks.d.ts.map +1 -0
- package/dist/types/types/analytics.d.cts +85 -0
- package/dist/types/types/analytics.d.ts +85 -0
- package/dist/types/types/analytics.d.ts.map +1 -0
- package/dist/types/types/assistance.d.cts +55 -0
- package/dist/types/types/assistance.d.ts +55 -0
- package/dist/types/types/assistance.d.ts.map +1 -0
- package/dist/types/types/common.d.cts +58 -0
- package/dist/types/types/common.d.ts +58 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/entities.d.cts +85 -0
- package/dist/types/types/entities.d.ts +85 -0
- package/dist/types/types/entities.d.ts.map +1 -0
- package/dist/types/types/exclusions.d.cts +81 -0
- package/dist/types/types/exclusions.d.ts +81 -0
- package/dist/types/types/exclusions.d.ts.map +1 -0
- package/dist/types/types/index.d.cts +12 -0
- package/dist/types/types/index.d.ts +12 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/intelligence.d.cts +104 -0
- package/dist/types/types/intelligence.d.ts +104 -0
- package/dist/types/types/intelligence.d.ts.map +1 -0
- package/dist/types/types/opportunities.d.cts +149 -0
- package/dist/types/types/opportunities.d.ts +149 -0
- package/dist/types/types/opportunities.d.ts.map +1 -0
- package/dist/types/types/webhooks.d.cts +106 -0
- package/dist/types/types/webhooks.d.ts +106 -0
- package/dist/types/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks-verify.d.cts +102 -0
- package/dist/types/webhooks-verify.d.ts +102 -0
- package/dist/types/webhooks-verify.d.ts.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FedPulse SDK error classes.
|
|
3
|
+
*
|
|
4
|
+
* All errors thrown by the SDK extend FedPulseError so callers can use
|
|
5
|
+
* `instanceof FedPulseError` to distinguish SDK errors from other exceptions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all FedPulse SDK errors.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FedPulseError extends Error {
|
|
11
|
+
/** HTTP status code returned by the API, or 0 for network errors. */
|
|
12
|
+
readonly status: number;
|
|
13
|
+
/** Machine-readable error code from the API (e.g. NOT_FOUND, RATE_LIMIT_EXCEEDED). */
|
|
14
|
+
readonly code: string;
|
|
15
|
+
/** Request ID for debugging — correlates with API logs. */
|
|
16
|
+
readonly requestId: string | undefined;
|
|
17
|
+
/** Additional structured details from the API response. */
|
|
18
|
+
readonly details: unknown | undefined;
|
|
19
|
+
constructor({ message, status, code, requestId, details, }: {
|
|
20
|
+
message: string;
|
|
21
|
+
status: number;
|
|
22
|
+
code: string;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
details?: unknown;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when the API returns 401 Unauthorized.
|
|
29
|
+
* Usually caused by missing, invalid, or revoked API key / JWT.
|
|
30
|
+
*/
|
|
31
|
+
export declare class AuthenticationError extends FedPulseError {
|
|
32
|
+
constructor(params: {
|
|
33
|
+
message: string;
|
|
34
|
+
requestId?: string;
|
|
35
|
+
details?: unknown;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when the API returns 403 Forbidden.
|
|
40
|
+
* Usually caused by insufficient plan permissions or missing key scope.
|
|
41
|
+
*/
|
|
42
|
+
export declare class PermissionError extends FedPulseError {
|
|
43
|
+
constructor(params: {
|
|
44
|
+
message: string;
|
|
45
|
+
code?: string;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
details?: unknown;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thrown when the API returns 404 Not Found.
|
|
52
|
+
*/
|
|
53
|
+
export declare class NotFoundError extends FedPulseError {
|
|
54
|
+
constructor(params: {
|
|
55
|
+
message: string;
|
|
56
|
+
requestId?: string;
|
|
57
|
+
details?: unknown;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Thrown when the API returns 422 Unprocessable Entity or 400 Bad Request
|
|
62
|
+
* due to invalid request parameters or body.
|
|
63
|
+
*/
|
|
64
|
+
export declare class ValidationError extends FedPulseError {
|
|
65
|
+
constructor(params: {
|
|
66
|
+
message: string;
|
|
67
|
+
status?: number;
|
|
68
|
+
requestId?: string;
|
|
69
|
+
details?: unknown;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Thrown when the API returns 429 Too Many Requests.
|
|
74
|
+
* The `retryAfter` property indicates when the rate limit resets (Unix seconds).
|
|
75
|
+
*/
|
|
76
|
+
export declare class RateLimitError extends FedPulseError {
|
|
77
|
+
/** Unix epoch seconds when the rate limit window resets. */
|
|
78
|
+
readonly retryAfter: number | undefined;
|
|
79
|
+
constructor(params: {
|
|
80
|
+
message: string;
|
|
81
|
+
retryAfter?: number;
|
|
82
|
+
requestId?: string;
|
|
83
|
+
details?: unknown;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Thrown when the API returns a 5xx server error.
|
|
88
|
+
*/
|
|
89
|
+
export declare class ServerError extends FedPulseError {
|
|
90
|
+
constructor(params: {
|
|
91
|
+
message: string;
|
|
92
|
+
status?: number;
|
|
93
|
+
code?: string;
|
|
94
|
+
requestId?: string;
|
|
95
|
+
details?: unknown;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Thrown when a network-level failure occurs (DNS, TCP, timeout, ECONNREFUSED).
|
|
100
|
+
* The `cause` property contains the original error.
|
|
101
|
+
*/
|
|
102
|
+
export declare class NetworkError extends FedPulseError {
|
|
103
|
+
/** The underlying network error. */
|
|
104
|
+
readonly cause: Error;
|
|
105
|
+
constructor(params: {
|
|
106
|
+
message: string;
|
|
107
|
+
cause: Error;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Thrown when a request exceeds the configured timeout.
|
|
112
|
+
*/
|
|
113
|
+
export declare class TimeoutError extends FedPulseError {
|
|
114
|
+
constructor(params: {
|
|
115
|
+
message: string;
|
|
116
|
+
requestId?: string;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Thrown when the SDK's retry budget is exhausted.
|
|
121
|
+
* The `lastError` property contains the final underlying error.
|
|
122
|
+
*/
|
|
123
|
+
export declare class RetryExhaustedError extends FedPulseError {
|
|
124
|
+
readonly lastError: FedPulseError;
|
|
125
|
+
readonly attempts: number;
|
|
126
|
+
constructor(params: {
|
|
127
|
+
lastError: FedPulseError;
|
|
128
|
+
attempts: number;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Factory — parses a raw API error response object into the correct error subtype.
|
|
133
|
+
*
|
|
134
|
+
* @param status HTTP response status code.
|
|
135
|
+
* @param body Parsed JSON body (may be the error envelope or anything).
|
|
136
|
+
* @param headers Response headers map (used for Retry-After).
|
|
137
|
+
*/
|
|
138
|
+
export declare function createApiError(status: number, body: unknown, headers: Record<string, string | null>): FedPulseError;
|
|
139
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,qE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E,OAAO,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GACrC,aAAa,CAuCf"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core HTTP client for the FedPulse SDK.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Native fetch (Node 18+) — zero runtime dependencies
|
|
6
|
+
* - Configurable timeout via AbortController
|
|
7
|
+
* - Automatic retry with exponential back-off + full jitter for transient errors
|
|
8
|
+
* - In-memory LRU cache for GET requests with per-entry TTL
|
|
9
|
+
* - Rate-limit header tracking (X-RateLimit-*)
|
|
10
|
+
* - Standard API envelope parsing + typed error creation
|
|
11
|
+
* - Array query-parameter serialisation (repeated keys)
|
|
12
|
+
*/
|
|
13
|
+
import type { RateLimitInfo, Pagination } from './types/common.cjs';
|
|
14
|
+
/**
|
|
15
|
+
* Serialise a plain-object params map to a URLSearchParams instance.
|
|
16
|
+
*
|
|
17
|
+
* Arrays are serialised as repeated keys: `{ naics: ['11', '21'] }` →
|
|
18
|
+
* `?naics=11&naics=21`.
|
|
19
|
+
*
|
|
20
|
+
* Undefined and null values are omitted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildQueryParams(params: Record<string, unknown>): URLSearchParams;
|
|
23
|
+
export interface HttpClientOptions {
|
|
24
|
+
/** API key or JWT token. Sent as `Authorization: Bearer <apiKey>`. */
|
|
25
|
+
apiKey: string;
|
|
26
|
+
/** API base URL. Defaults to `https://api.fedpulse.dev`. */
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Request timeout in milliseconds. Applies to each individual attempt (not
|
|
30
|
+
* total retry budget). Default: 30 000 ms.
|
|
31
|
+
*/
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum number of retry attempts for transient errors.
|
|
35
|
+
* Set to 0 to disable retries. Default: 3.
|
|
36
|
+
*/
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum number of GET responses to cache in memory.
|
|
40
|
+
* Set to 0 to disable caching. Default: 256.
|
|
41
|
+
*/
|
|
42
|
+
cacheSize?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Default TTL for cached GET responses in milliseconds. Default: 60 000 ms.
|
|
45
|
+
*/
|
|
46
|
+
cacheTtlMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Custom `fetch` implementation. Defaults to the global `fetch`.
|
|
49
|
+
* Useful for testing or environments with a non-standard fetch.
|
|
50
|
+
*/
|
|
51
|
+
fetchFn?: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
export interface RequestOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Override cache TTL for this specific request (ms).
|
|
56
|
+
* Pass 0 to bypass cache entirely.
|
|
57
|
+
*/
|
|
58
|
+
cacheTtlMs?: number;
|
|
59
|
+
/** Extra headers to merge into this request. */
|
|
60
|
+
headers?: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
export interface ParsedResponse<T> {
|
|
63
|
+
data: T;
|
|
64
|
+
pagination: Pagination;
|
|
65
|
+
meta: {
|
|
66
|
+
requestId: string;
|
|
67
|
+
cached?: boolean;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
rateLimit: RateLimitInfo | null;
|
|
71
|
+
/** Whether the result was served from the in-memory cache. */
|
|
72
|
+
fromCache: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Low-level HTTP client used by all domain resources.
|
|
76
|
+
*
|
|
77
|
+
* You should not need to instantiate this directly — use `FedPulse` instead.
|
|
78
|
+
*/
|
|
79
|
+
export declare class HttpClient {
|
|
80
|
+
private readonly apiKey;
|
|
81
|
+
private readonly baseUrl;
|
|
82
|
+
private readonly timeoutMs;
|
|
83
|
+
private readonly maxRetries;
|
|
84
|
+
private readonly cache;
|
|
85
|
+
private readonly defaultCacheTtlMs;
|
|
86
|
+
private readonly fetchFn;
|
|
87
|
+
/** Most recent rate-limit info observed across all requests. */
|
|
88
|
+
lastRateLimit: RateLimitInfo | null;
|
|
89
|
+
constructor(options: HttpClientOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Perform a GET request. Results are cached unless `cacheTtlMs` is 0.
|
|
92
|
+
*
|
|
93
|
+
* @param path API path (e.g. `/v1/opportunities`).
|
|
94
|
+
* @param params Query parameters — arrays serialised as repeated keys.
|
|
95
|
+
* @param options Per-request overrides.
|
|
96
|
+
*/
|
|
97
|
+
get<T>(path: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
98
|
+
/**
|
|
99
|
+
* Perform a POST request (never cached).
|
|
100
|
+
*
|
|
101
|
+
* @param path API path.
|
|
102
|
+
* @param body JSON-serialisable request body.
|
|
103
|
+
* @param options Per-request overrides.
|
|
104
|
+
*/
|
|
105
|
+
post<T>(path: string, body: unknown, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
106
|
+
/**
|
|
107
|
+
* Perform a PATCH request (never cached).
|
|
108
|
+
*/
|
|
109
|
+
patch<T>(path: string, body: unknown, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Perform a DELETE request (never cached).
|
|
112
|
+
*/
|
|
113
|
+
del<T = null>(path: string, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
114
|
+
/**
|
|
115
|
+
* Clear all cached responses.
|
|
116
|
+
*/
|
|
117
|
+
clearCache(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Execute a request, retrying on transient failures with exponential back-off
|
|
120
|
+
* and full jitter.
|
|
121
|
+
*/
|
|
122
|
+
private executeWithRetry;
|
|
123
|
+
/**
|
|
124
|
+
* Execute a single HTTP request (no retry logic).
|
|
125
|
+
* Handles timeout, response parsing, header extraction, and error creation.
|
|
126
|
+
*/
|
|
127
|
+
private executeOnce;
|
|
128
|
+
/**
|
|
129
|
+
* Perform a raw fetch that returns the full Response (for streaming downloads).
|
|
130
|
+
* No retry, no envelope parsing.
|
|
131
|
+
*
|
|
132
|
+
* @param path API path.
|
|
133
|
+
* @param params Query parameters.
|
|
134
|
+
*/
|
|
135
|
+
rawGet(path: string, params?: Record<string, unknown>): Promise<Response>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core HTTP client for the FedPulse SDK.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Native fetch (Node 18+) — zero runtime dependencies
|
|
6
|
+
* - Configurable timeout via AbortController
|
|
7
|
+
* - Automatic retry with exponential back-off + full jitter for transient errors
|
|
8
|
+
* - In-memory LRU cache for GET requests with per-entry TTL
|
|
9
|
+
* - Rate-limit header tracking (X-RateLimit-*)
|
|
10
|
+
* - Standard API envelope parsing + typed error creation
|
|
11
|
+
* - Array query-parameter serialisation (repeated keys)
|
|
12
|
+
*/
|
|
13
|
+
import type { RateLimitInfo, Pagination } from './types/common.js';
|
|
14
|
+
/**
|
|
15
|
+
* Serialise a plain-object params map to a URLSearchParams instance.
|
|
16
|
+
*
|
|
17
|
+
* Arrays are serialised as repeated keys: `{ naics: ['11', '21'] }` →
|
|
18
|
+
* `?naics=11&naics=21`.
|
|
19
|
+
*
|
|
20
|
+
* Undefined and null values are omitted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildQueryParams(params: Record<string, unknown>): URLSearchParams;
|
|
23
|
+
export interface HttpClientOptions {
|
|
24
|
+
/** API key or JWT token. Sent as `Authorization: Bearer <apiKey>`. */
|
|
25
|
+
apiKey: string;
|
|
26
|
+
/** API base URL. Defaults to `https://api.fedpulse.dev`. */
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Request timeout in milliseconds. Applies to each individual attempt (not
|
|
30
|
+
* total retry budget). Default: 30 000 ms.
|
|
31
|
+
*/
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum number of retry attempts for transient errors.
|
|
35
|
+
* Set to 0 to disable retries. Default: 3.
|
|
36
|
+
*/
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum number of GET responses to cache in memory.
|
|
40
|
+
* Set to 0 to disable caching. Default: 256.
|
|
41
|
+
*/
|
|
42
|
+
cacheSize?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Default TTL for cached GET responses in milliseconds. Default: 60 000 ms.
|
|
45
|
+
*/
|
|
46
|
+
cacheTtlMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Custom `fetch` implementation. Defaults to the global `fetch`.
|
|
49
|
+
* Useful for testing or environments with a non-standard fetch.
|
|
50
|
+
*/
|
|
51
|
+
fetchFn?: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
export interface RequestOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Override cache TTL for this specific request (ms).
|
|
56
|
+
* Pass 0 to bypass cache entirely.
|
|
57
|
+
*/
|
|
58
|
+
cacheTtlMs?: number;
|
|
59
|
+
/** Extra headers to merge into this request. */
|
|
60
|
+
headers?: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
export interface ParsedResponse<T> {
|
|
63
|
+
data: T;
|
|
64
|
+
pagination: Pagination;
|
|
65
|
+
meta: {
|
|
66
|
+
requestId: string;
|
|
67
|
+
cached?: boolean;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
rateLimit: RateLimitInfo | null;
|
|
71
|
+
/** Whether the result was served from the in-memory cache. */
|
|
72
|
+
fromCache: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Low-level HTTP client used by all domain resources.
|
|
76
|
+
*
|
|
77
|
+
* You should not need to instantiate this directly — use `FedPulse` instead.
|
|
78
|
+
*/
|
|
79
|
+
export declare class HttpClient {
|
|
80
|
+
private readonly apiKey;
|
|
81
|
+
private readonly baseUrl;
|
|
82
|
+
private readonly timeoutMs;
|
|
83
|
+
private readonly maxRetries;
|
|
84
|
+
private readonly cache;
|
|
85
|
+
private readonly defaultCacheTtlMs;
|
|
86
|
+
private readonly fetchFn;
|
|
87
|
+
/** Most recent rate-limit info observed across all requests. */
|
|
88
|
+
lastRateLimit: RateLimitInfo | null;
|
|
89
|
+
constructor(options: HttpClientOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Perform a GET request. Results are cached unless `cacheTtlMs` is 0.
|
|
92
|
+
*
|
|
93
|
+
* @param path API path (e.g. `/v1/opportunities`).
|
|
94
|
+
* @param params Query parameters — arrays serialised as repeated keys.
|
|
95
|
+
* @param options Per-request overrides.
|
|
96
|
+
*/
|
|
97
|
+
get<T>(path: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
98
|
+
/**
|
|
99
|
+
* Perform a POST request (never cached).
|
|
100
|
+
*
|
|
101
|
+
* @param path API path.
|
|
102
|
+
* @param body JSON-serialisable request body.
|
|
103
|
+
* @param options Per-request overrides.
|
|
104
|
+
*/
|
|
105
|
+
post<T>(path: string, body: unknown, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
106
|
+
/**
|
|
107
|
+
* Perform a PATCH request (never cached).
|
|
108
|
+
*/
|
|
109
|
+
patch<T>(path: string, body: unknown, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
110
|
+
/**
|
|
111
|
+
* Perform a DELETE request (never cached).
|
|
112
|
+
*/
|
|
113
|
+
del<T = null>(path: string, options?: RequestOptions): Promise<ParsedResponse<T>>;
|
|
114
|
+
/**
|
|
115
|
+
* Clear all cached responses.
|
|
116
|
+
*/
|
|
117
|
+
clearCache(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Execute a request, retrying on transient failures with exponential back-off
|
|
120
|
+
* and full jitter.
|
|
121
|
+
*/
|
|
122
|
+
private executeWithRetry;
|
|
123
|
+
/**
|
|
124
|
+
* Execute a single HTTP request (no retry logic).
|
|
125
|
+
* Handles timeout, response parsing, header extraction, and error creation.
|
|
126
|
+
*/
|
|
127
|
+
private executeOnce;
|
|
128
|
+
/**
|
|
129
|
+
* Perform a raw fetch that returns the full Response (for streaming downloads).
|
|
130
|
+
* No retry, no envelope parsing.
|
|
131
|
+
*
|
|
132
|
+
* @param path API path.
|
|
133
|
+
* @param params Query parameters.
|
|
134
|
+
*/
|
|
135
|
+
rawGet(path: string, params?: Record<string, unknown>): Promise<Response>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,OAAO,KAAK,EAAe,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkIhF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAejF;AAID,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAID,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAID,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC;IACR,UAA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,GAAG,CAAC,CAAC,GAAG,IAAI,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAK7B;;OAEG;IACH,UAAU,IAAI,IAAI;IAMlB;;;OAGG;YACW,gBAAgB;IA6D9B;;;OAGG;YACW,WAAW;IA6FzB;;;;;;OAMG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAyCpF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fedpulse/sdk — Official JavaScript/TypeScript SDK for the FedPulse API.
|
|
3
|
+
*
|
|
4
|
+
* Quick start:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { FedPulse } from '@fedpulse/sdk';
|
|
7
|
+
*
|
|
8
|
+
* const client = new FedPulse({ apiKey: process.env.FEDPULSE_API_KEY! });
|
|
9
|
+
*
|
|
10
|
+
* const { data } = await client.opportunities.list({ q: 'cloud', naics: '541512' });
|
|
11
|
+
* console.log(data[0].title);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Webhook verification:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const payload = FedPulse.verifyWebhook({
|
|
17
|
+
* rawBody: req.body,
|
|
18
|
+
* signatureHeader: req.headers['x-fedpulse-signature'],
|
|
19
|
+
* timestampHeader: req.headers['x-fedpulse-timestamp'],
|
|
20
|
+
* secret: process.env.FEDPULSE_WEBHOOK_SECRET!,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { FedPulse, WebhookVerificationError } from './client.cjs';
|
|
25
|
+
export type { FedPulseOptions } from './client.cjs';
|
|
26
|
+
export { FedPulseError, AuthenticationError, PermissionError, NotFoundError, ValidationError, RateLimitError, ServerError, NetworkError, TimeoutError, RetryExhaustedError, } from './errors.cjs';
|
|
27
|
+
export { HttpClient, buildQueryParams } from './http.cjs';
|
|
28
|
+
export type { HttpClientOptions, ParsedResponse, RequestOptions } from './http.cjs';
|
|
29
|
+
export { OpportunitiesResource } from './resources/opportunities.cjs';
|
|
30
|
+
export { ExclusionsResource } from './resources/exclusions.cjs';
|
|
31
|
+
export { EntitiesResource } from './resources/entities.cjs';
|
|
32
|
+
export { IntelligenceResource } from './resources/intelligence.cjs';
|
|
33
|
+
export { AssistanceResource } from './resources/assistance.cjs';
|
|
34
|
+
export { AnalyticsResource } from './resources/analytics.cjs';
|
|
35
|
+
export { WebhooksResource } from './resources/webhooks.cjs';
|
|
36
|
+
export { verifyWebhook, extractWebhookHeaders } from './webhooks-verify.cjs';
|
|
37
|
+
export type { VerifyWebhookInput } from './webhooks-verify.cjs';
|
|
38
|
+
export type { RateLimitInfo, OffsetPagination, CursorPagination, Pagination, ResponseMeta, ApiResponse, PaginationParams, SortParams, FieldsParam, Opportunity, AiCategory, AiDifficulty, OpportunitiesStats, OpportunityStatsItem, OpportunitiesStatsGroupBy, ListOpportunitiesParams, GetOpportunitiesStatsParams, CreateExportParams, ExportJob, ExportFormat, ExportStatus, Exclusion, ExclusionsStats, ListExclusionsParams, BulkComplianceCheckParams, ComplianceCheckEntity, ComplianceCheckResult, Entity, EntityStats, EntityAddress, EntityCertification, EntityNaicsEntry, EntityExclusionCheckResult, ListEntitiesParams, EntityIntelProfile, MarketAnalysis, CompliancePackage, ComplianceCheckRequestParams, AgencyRelationship, ContractHistoryItem, RiskIndicator, MarketAwardee, MarketAgency, SetAsideBreakdown, AssistanceListing, AssistanceStats, ListAssistanceParams, GetAssistanceStatsParams, AnalyticsSummary, AnalyticsChart, AnalyticsChartDay, AnalyticsEndpoints, AnalyticsEndpoint, AnalyticsLogs, AnalyticsLogEntry, AnalyticsSummaryParams, AnalyticsChartParams, AnalyticsEndpointsParams, AnalyticsLogsParams, AnalyticsRange, LogStatusFilter, Webhook, WebhookDelivery, WebhookPayload, WebhookFilters, WebhookEvent, DeliveryStatus, CreateWebhookParams, UpdateWebhookParams, CreateWebhookResult, RotateSecretResult, ListDeliveriesParams, WebhookVerifyOptions, } from './types/index.cjs';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fedpulse/sdk — Official JavaScript/TypeScript SDK for the FedPulse API.
|
|
3
|
+
*
|
|
4
|
+
* Quick start:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { FedPulse } from '@fedpulse/sdk';
|
|
7
|
+
*
|
|
8
|
+
* const client = new FedPulse({ apiKey: process.env.FEDPULSE_API_KEY! });
|
|
9
|
+
*
|
|
10
|
+
* const { data } = await client.opportunities.list({ q: 'cloud', naics: '541512' });
|
|
11
|
+
* console.log(data[0].title);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Webhook verification:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const payload = FedPulse.verifyWebhook({
|
|
17
|
+
* rawBody: req.body,
|
|
18
|
+
* signatureHeader: req.headers['x-fedpulse-signature'],
|
|
19
|
+
* timestampHeader: req.headers['x-fedpulse-timestamp'],
|
|
20
|
+
* secret: process.env.FEDPULSE_WEBHOOK_SECRET!,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { FedPulse, WebhookVerificationError } from './client.js';
|
|
25
|
+
export type { FedPulseOptions } from './client.js';
|
|
26
|
+
export { FedPulseError, AuthenticationError, PermissionError, NotFoundError, ValidationError, RateLimitError, ServerError, NetworkError, TimeoutError, RetryExhaustedError, } from './errors.js';
|
|
27
|
+
export { HttpClient, buildQueryParams } from './http.js';
|
|
28
|
+
export type { HttpClientOptions, ParsedResponse, RequestOptions } from './http.js';
|
|
29
|
+
export { OpportunitiesResource } from './resources/opportunities.js';
|
|
30
|
+
export { ExclusionsResource } from './resources/exclusions.js';
|
|
31
|
+
export { EntitiesResource } from './resources/entities.js';
|
|
32
|
+
export { IntelligenceResource } from './resources/intelligence.js';
|
|
33
|
+
export { AssistanceResource } from './resources/assistance.js';
|
|
34
|
+
export { AnalyticsResource } from './resources/analytics.js';
|
|
35
|
+
export { WebhooksResource } from './resources/webhooks.js';
|
|
36
|
+
export { verifyWebhook, extractWebhookHeaders } from './webhooks-verify.js';
|
|
37
|
+
export type { VerifyWebhookInput } from './webhooks-verify.js';
|
|
38
|
+
export type { RateLimitInfo, OffsetPagination, CursorPagination, Pagination, ResponseMeta, ApiResponse, PaginationParams, SortParams, FieldsParam, Opportunity, AiCategory, AiDifficulty, OpportunitiesStats, OpportunityStatsItem, OpportunitiesStatsGroupBy, ListOpportunitiesParams, GetOpportunitiesStatsParams, CreateExportParams, ExportJob, ExportFormat, ExportStatus, Exclusion, ExclusionsStats, ListExclusionsParams, BulkComplianceCheckParams, ComplianceCheckEntity, ComplianceCheckResult, Entity, EntityStats, EntityAddress, EntityCertification, EntityNaicsEntry, EntityExclusionCheckResult, ListEntitiesParams, EntityIntelProfile, MarketAnalysis, CompliancePackage, ComplianceCheckRequestParams, AgencyRelationship, ContractHistoryItem, RiskIndicator, MarketAwardee, MarketAgency, SetAsideBreakdown, AssistanceListing, AssistanceStats, ListAssistanceParams, GetAssistanceStatsParams, AnalyticsSummary, AnalyticsChart, AnalyticsChartDay, AnalyticsEndpoints, AnalyticsEndpoint, AnalyticsLogs, AnalyticsLogEntry, AnalyticsSummaryParams, AnalyticsChartParams, AnalyticsEndpointsParams, AnalyticsLogsParams, AnalyticsRange, LogStatusFilter, Webhook, WebhookDelivery, WebhookPayload, WebhookFilters, WebhookEvent, DeliveryStatus, CreateWebhookParams, UpdateWebhookParams, CreateWebhookResult, RotateSecretResult, ListDeliveriesParams, WebhookVerifyOptions, } from './types/index.js';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index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AAY,EAEZ,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EAErB,MAAM,EACN,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,EAElB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EAEjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,EAExB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,eAAe,EAEf,OAAO,EACP,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytics resource client.
|
|
3
|
+
*
|
|
4
|
+
* Wraps all /v1/analytics endpoints (per-user API usage analytics):
|
|
5
|
+
* - summary GET /v1/analytics/summary
|
|
6
|
+
* - chart GET /v1/analytics/chart
|
|
7
|
+
* - endpoints GET /v1/analytics/endpoints
|
|
8
|
+
* - logs GET /v1/analytics/logs
|
|
9
|
+
* - logPages async generator over the logs endpoint
|
|
10
|
+
*
|
|
11
|
+
* All results are scoped to the authenticated user — no cross-user visibility.
|
|
12
|
+
*/
|
|
13
|
+
import type { HttpClient, ParsedResponse } from '../http.cjs';
|
|
14
|
+
import type { AnalyticsSummary, AnalyticsChart, AnalyticsEndpoints, AnalyticsLogs, AnalyticsSummaryParams, AnalyticsChartParams, AnalyticsEndpointsParams, AnalyticsLogsParams } from '../types/analytics.cjs';
|
|
15
|
+
export declare class AnalyticsResource {
|
|
16
|
+
private readonly http;
|
|
17
|
+
constructor(http: HttpClient);
|
|
18
|
+
/**
|
|
19
|
+
* Get KPI summary totals for the authenticated user.
|
|
20
|
+
*
|
|
21
|
+
* Returns: requests today, this month, in range, 4xx/5xx counts and rates.
|
|
22
|
+
* Analytics data is never cached — always returns live counts.
|
|
23
|
+
*
|
|
24
|
+
* @param params Optional key-scoping and time range.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const summary = await client.analytics.summary({ range: '7d' });
|
|
29
|
+
* console.log('Requests last 7d:', summary.data.requestsInRange);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
summary(params?: AnalyticsSummaryParams): Promise<ParsedResponse<AnalyticsSummary>>;
|
|
33
|
+
/**
|
|
34
|
+
* Get per-day request counts broken down by success / 4xx / 5xx.
|
|
35
|
+
*
|
|
36
|
+
* @param params Optional key-scoping and time range.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const chart = await client.analytics.chart({ range: '30d' });
|
|
41
|
+
* for (const day of chart.data.days) {
|
|
42
|
+
* console.log(day.date, day.total);
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
chart(params?: AnalyticsChartParams): Promise<ParsedResponse<AnalyticsChart>>;
|
|
47
|
+
/**
|
|
48
|
+
* Get top-10 endpoints by request volume and by P95 latency.
|
|
49
|
+
*
|
|
50
|
+
* @param params Optional key-scoping and time range.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const endpoints = await client.analytics.endpoints({ range: '7d' });
|
|
55
|
+
* console.log('Slowest endpoint:', endpoints.data.byLatency[0]?.endpoint);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
endpoints(params?: AnalyticsEndpointsParams): Promise<ParsedResponse<AnalyticsEndpoints>>;
|
|
59
|
+
/**
|
|
60
|
+
* Get paginated API request logs for the authenticated user.
|
|
61
|
+
*
|
|
62
|
+
* Supports cursor-based pagination via the `cursor` parameter.
|
|
63
|
+
* Maximum `limit` is 1000.
|
|
64
|
+
*
|
|
65
|
+
* @param params Filter and pagination parameters.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const logs = await client.analytics.logs({ limit: 50, status: '4xx' });
|
|
70
|
+
* for (const entry of logs.data.items) {
|
|
71
|
+
* console.log(entry.method, entry.endpoint, entry.statusCode);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
logs(params?: AnalyticsLogsParams): Promise<ParsedResponse<AnalyticsLogs>>;
|
|
76
|
+
/**
|
|
77
|
+
* Async generator that automatically paginates through all log entries.
|
|
78
|
+
*
|
|
79
|
+
* Uses cursor-based pagination. Yields one page at a time.
|
|
80
|
+
*
|
|
81
|
+
* @param params Same parameters as `logs()`. Do not pass `cursor`.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* for await (const page of client.analytics.logPages({ range: '7d' })) {
|
|
86
|
+
* for (const entry of page.data.items) {
|
|
87
|
+
* console.log(entry.requestId, entry.statusCode);
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
logPages(params: Omit<AnalyticsLogsParams, 'cursor'>): AsyncGenerator<ParsedResponse<AnalyticsLogs>>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=analytics.d.ts.map
|