@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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +331 -0
  3. package/dist/cjs/client.cjs +138 -0
  4. package/dist/cjs/errors.cjs +200 -0
  5. package/dist/cjs/http.cjs +449 -0
  6. package/dist/cjs/index.cjs +65 -0
  7. package/dist/cjs/resources/analytics.cjs +134 -0
  8. package/dist/cjs/resources/assistance.cjs +101 -0
  9. package/dist/cjs/resources/entities.cjs +149 -0
  10. package/dist/cjs/resources/exclusions.cjs +135 -0
  11. package/dist/cjs/resources/intelligence.cjs +96 -0
  12. package/dist/cjs/resources/opportunities.cjs +170 -0
  13. package/dist/cjs/resources/webhooks.cjs +262 -0
  14. package/dist/cjs/types/analytics.cjs +5 -0
  15. package/dist/cjs/types/assistance.cjs +5 -0
  16. package/dist/cjs/types/common.cjs +5 -0
  17. package/dist/cjs/types/entities.cjs +5 -0
  18. package/dist/cjs/types/exclusions.cjs +5 -0
  19. package/dist/cjs/types/index.cjs +5 -0
  20. package/dist/cjs/types/intelligence.cjs +5 -0
  21. package/dist/cjs/types/opportunities.cjs +5 -0
  22. package/dist/cjs/types/webhooks.cjs +5 -0
  23. package/dist/cjs/webhooks-verify.cjs +184 -0
  24. package/dist/esm/client.js +135 -0
  25. package/dist/esm/client.js.map +1 -0
  26. package/dist/esm/errors.js +187 -0
  27. package/dist/esm/errors.js.map +1 -0
  28. package/dist/esm/http.js +445 -0
  29. package/dist/esm/http.js.map +1 -0
  30. package/dist/esm/index.js +40 -0
  31. package/dist/esm/index.js.map +1 -0
  32. package/dist/esm/resources/analytics.js +131 -0
  33. package/dist/esm/resources/analytics.js.map +1 -0
  34. package/dist/esm/resources/assistance.js +98 -0
  35. package/dist/esm/resources/assistance.js.map +1 -0
  36. package/dist/esm/resources/entities.js +146 -0
  37. package/dist/esm/resources/entities.js.map +1 -0
  38. package/dist/esm/resources/exclusions.js +132 -0
  39. package/dist/esm/resources/exclusions.js.map +1 -0
  40. package/dist/esm/resources/intelligence.js +93 -0
  41. package/dist/esm/resources/intelligence.js.map +1 -0
  42. package/dist/esm/resources/opportunities.js +167 -0
  43. package/dist/esm/resources/opportunities.js.map +1 -0
  44. package/dist/esm/resources/webhooks.js +259 -0
  45. package/dist/esm/resources/webhooks.js.map +1 -0
  46. package/dist/esm/types/analytics.js +5 -0
  47. package/dist/esm/types/analytics.js.map +1 -0
  48. package/dist/esm/types/assistance.js +5 -0
  49. package/dist/esm/types/assistance.js.map +1 -0
  50. package/dist/esm/types/common.js +5 -0
  51. package/dist/esm/types/common.js.map +1 -0
  52. package/dist/esm/types/entities.js +5 -0
  53. package/dist/esm/types/entities.js.map +1 -0
  54. package/dist/esm/types/exclusions.js +5 -0
  55. package/dist/esm/types/exclusions.js.map +1 -0
  56. package/dist/esm/types/index.js +5 -0
  57. package/dist/esm/types/index.js.map +1 -0
  58. package/dist/esm/types/intelligence.js +5 -0
  59. package/dist/esm/types/intelligence.js.map +1 -0
  60. package/dist/esm/types/opportunities.js +5 -0
  61. package/dist/esm/types/opportunities.js.map +1 -0
  62. package/dist/esm/types/webhooks.js +5 -0
  63. package/dist/esm/types/webhooks.js.map +1 -0
  64. package/dist/esm/webhooks-verify.js +179 -0
  65. package/dist/esm/webhooks-verify.js.map +1 -0
  66. package/dist/types/client.d.cts +136 -0
  67. package/dist/types/client.d.ts +136 -0
  68. package/dist/types/client.d.ts.map +1 -0
  69. package/dist/types/errors.d.cts +139 -0
  70. package/dist/types/errors.d.ts +139 -0
  71. package/dist/types/errors.d.ts.map +1 -0
  72. package/dist/types/http.d.cts +137 -0
  73. package/dist/types/http.d.ts +137 -0
  74. package/dist/types/http.d.ts.map +1 -0
  75. package/dist/types/index.d.cts +39 -0
  76. package/dist/types/index.d.ts +39 -0
  77. package/dist/types/index.d.ts.map +1 -0
  78. package/dist/types/resources/analytics.d.cts +94 -0
  79. package/dist/types/resources/analytics.d.ts +94 -0
  80. package/dist/types/resources/analytics.d.ts.map +1 -0
  81. package/dist/types/resources/assistance.d.cts +66 -0
  82. package/dist/types/resources/assistance.d.ts +66 -0
  83. package/dist/types/resources/assistance.d.ts.map +1 -0
  84. package/dist/types/resources/entities.d.cts +101 -0
  85. package/dist/types/resources/entities.d.ts +101 -0
  86. package/dist/types/resources/entities.d.ts.map +1 -0
  87. package/dist/types/resources/exclusions.d.cts +84 -0
  88. package/dist/types/resources/exclusions.d.ts +84 -0
  89. package/dist/types/resources/exclusions.d.ts.map +1 -0
  90. package/dist/types/resources/intelligence.d.cts +66 -0
  91. package/dist/types/resources/intelligence.d.ts +66 -0
  92. package/dist/types/resources/intelligence.d.ts.map +1 -0
  93. package/dist/types/resources/opportunities.d.cts +116 -0
  94. package/dist/types/resources/opportunities.d.ts +116 -0
  95. package/dist/types/resources/opportunities.d.ts.map +1 -0
  96. package/dist/types/resources/webhooks.d.cts +180 -0
  97. package/dist/types/resources/webhooks.d.ts +180 -0
  98. package/dist/types/resources/webhooks.d.ts.map +1 -0
  99. package/dist/types/types/analytics.d.cts +85 -0
  100. package/dist/types/types/analytics.d.ts +85 -0
  101. package/dist/types/types/analytics.d.ts.map +1 -0
  102. package/dist/types/types/assistance.d.cts +55 -0
  103. package/dist/types/types/assistance.d.ts +55 -0
  104. package/dist/types/types/assistance.d.ts.map +1 -0
  105. package/dist/types/types/common.d.cts +58 -0
  106. package/dist/types/types/common.d.ts +58 -0
  107. package/dist/types/types/common.d.ts.map +1 -0
  108. package/dist/types/types/entities.d.cts +85 -0
  109. package/dist/types/types/entities.d.ts +85 -0
  110. package/dist/types/types/entities.d.ts.map +1 -0
  111. package/dist/types/types/exclusions.d.cts +81 -0
  112. package/dist/types/types/exclusions.d.ts +81 -0
  113. package/dist/types/types/exclusions.d.ts.map +1 -0
  114. package/dist/types/types/index.d.cts +12 -0
  115. package/dist/types/types/index.d.ts +12 -0
  116. package/dist/types/types/index.d.ts.map +1 -0
  117. package/dist/types/types/intelligence.d.cts +104 -0
  118. package/dist/types/types/intelligence.d.ts +104 -0
  119. package/dist/types/types/intelligence.d.ts.map +1 -0
  120. package/dist/types/types/opportunities.d.cts +149 -0
  121. package/dist/types/types/opportunities.d.ts +149 -0
  122. package/dist/types/types/opportunities.d.ts.map +1 -0
  123. package/dist/types/types/webhooks.d.cts +106 -0
  124. package/dist/types/types/webhooks.d.ts +106 -0
  125. package/dist/types/types/webhooks.d.ts.map +1 -0
  126. package/dist/types/webhooks-verify.d.cts +102 -0
  127. package/dist/types/webhooks-verify.d.ts +102 -0
  128. package/dist/types/webhooks-verify.d.ts.map +1 -0
  129. package/package.json +62 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Intelligence resource client.
3
+ *
4
+ * Wraps all /v1/intelligence endpoints:
5
+ * - entityProfile GET /v1/intelligence/entity/:uei
6
+ * - marketAnalysis GET /v1/intelligence/market/:naics
7
+ * - complianceCheck POST /v1/intelligence/compliance-check
8
+ */
9
+ import type { HttpClient, ParsedResponse } from '../http.js';
10
+ import type { EntityIntelProfile, MarketAnalysis, CompliancePackage, ComplianceCheckRequestParams } from '../types/intelligence.js';
11
+ export declare class IntelligenceResource {
12
+ private readonly http;
13
+ constructor(http: HttpClient);
14
+ /**
15
+ * Get a comprehensive 360° intelligence profile for a vendor.
16
+ *
17
+ * Aggregates: contract history, agency relationships, certifications,
18
+ * exclusion status, and risk indicators into a single response.
19
+ *
20
+ * @param uei Unique Entity Identifier (12-char alphanumeric).
21
+ * @throws {NotFoundError} If the entity does not exist in SAM.gov.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const profile = await client.intelligence.entityProfile('ABCDEF123456');
26
+ * console.log('Contract count:', profile.data.contractCount);
27
+ * console.log('Risk:', profile.data.riskLevel);
28
+ * ```
29
+ */
30
+ entityProfile(uei: string): Promise<ParsedResponse<EntityIntelProfile>>;
31
+ /**
32
+ * Get a market analysis for a specific NAICS code.
33
+ *
34
+ * Returns: top awardees, top agencies, set-aside breakdown, active solicitations,
35
+ * total market size, and recent award trends.
36
+ *
37
+ * @param naics 2–6 digit NAICS code (more digits = more specific market segment).
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const market = await client.intelligence.marketAnalysis('541512');
42
+ * console.log('Market size (cents):', market.data.totalMarketSize);
43
+ * console.log('Top awardee:', market.data.topAwardees[0]?.name);
44
+ * ```
45
+ */
46
+ marketAnalysis(naics: string): Promise<ParsedResponse<MarketAnalysis>>;
47
+ /**
48
+ * Perform a full compliance check for a vendor.
49
+ *
50
+ * Returns: exclusion status, SAM.gov registration status, risk score,
51
+ * and risk indicators in one API call.
52
+ *
53
+ * @param params Object containing the UEI to check.
54
+ * @throws {NotFoundError} If the entity does not exist in SAM.gov.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const compliance = await client.intelligence.complianceCheck({ uei: 'ABCDEF123456' });
59
+ * if (compliance.data.excluded || compliance.data.riskLevel === 'high') {
60
+ * console.warn('Do not contract with this vendor.');
61
+ * }
62
+ * ```
63
+ */
64
+ complianceCheck(params: ComplianceCheckRequestParams): Promise<ParsedResponse<CompliancePackage>>;
65
+ }
66
+ //# sourceMappingURL=intelligence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence.d.ts","sourceRoot":"","sources":["../../../src/resources/intelligence.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,0BAA0B,CAAC;AAElC,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;;;OAeG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAY7E;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IAY5E;;;;;;;;;;;;;;;;OAgBG;IACG,eAAe,CACnB,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;CAW9C"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Opportunities resource client.
3
+ *
4
+ * Wraps all /v1/opportunities endpoints:
5
+ * - search (list) GET /v1/opportunities
6
+ * - stats GET /v1/opportunities/stats
7
+ * - get GET /v1/opportunities/:noticeId
8
+ * - createExport POST /v1/opportunities/export
9
+ * - getExport GET /v1/opportunities/export/:exportId
10
+ * - downloadExport GET /v1/opportunities/export/:exportId/download
11
+ * - paginate (generator) auto-paginates over the search endpoint
12
+ */
13
+ import type { HttpClient, ParsedResponse } from '../http.cjs';
14
+ import type { Opportunity, OpportunitiesStats, ListOpportunitiesParams, GetOpportunitiesStatsParams, CreateExportParams, ExportJob } from '../types/opportunities.cjs';
15
+ export declare class OpportunitiesResource {
16
+ private readonly http;
17
+ constructor(http: HttpClient);
18
+ /**
19
+ * Search and filter federal contract opportunities.
20
+ *
21
+ * @param params Filter and pagination parameters.
22
+ * @returns Paginated list of opportunities.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const result = await client.opportunities.list({
27
+ * q: 'cybersecurity',
28
+ * naics: '541512',
29
+ * postedAfter: '2025-01-01',
30
+ * limit: 50,
31
+ * });
32
+ * console.log(result.data[0].title);
33
+ * ```
34
+ */
35
+ list(params?: ListOpportunitiesParams): Promise<ParsedResponse<Opportunity[]>>;
36
+ /**
37
+ * Get a single opportunity by its SAM.gov notice ID.
38
+ *
39
+ * @param noticeId The unique SAM.gov notice identifier.
40
+ * @throws {NotFoundError} If the opportunity does not exist.
41
+ */
42
+ get(noticeId: string): Promise<ParsedResponse<Opportunity>>;
43
+ /**
44
+ * Get aggregated statistics for opportunities.
45
+ *
46
+ * @param params Grouping and filter parameters.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const stats = await client.opportunities.stats({ groupBy: 'naics', limit: 10 });
51
+ * ```
52
+ */
53
+ stats(params?: GetOpportunitiesStatsParams): Promise<ParsedResponse<OpportunitiesStats>>;
54
+ /**
55
+ * Create a background export job for opportunities.
56
+ *
57
+ * Requires: Developer plan (CSV only) or Professional/Enterprise plan (all formats).
58
+ * Requires: `export` API key scope.
59
+ *
60
+ * @param params Export parameters (format + same filters as `list`).
61
+ * @returns Export job metadata.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const job = await client.opportunities.createExport({ format: 'csv', agency: 'NASA' });
66
+ * // Poll getExport() until job.data.status === 'done', then call downloadExport().
67
+ * ```
68
+ */
69
+ createExport(params: CreateExportParams): Promise<ParsedResponse<ExportJob>>;
70
+ /**
71
+ * Get the status of an export job.
72
+ *
73
+ * @param exportId UUID of the export job.
74
+ * @throws {NotFoundError} If the export job does not exist or belongs to another user.
75
+ */
76
+ getExport(exportId: string): Promise<ParsedResponse<ExportJob>>;
77
+ /**
78
+ * Download the output file of a completed export job.
79
+ *
80
+ * Returns the raw `Response` object so callers can stream or save the body.
81
+ * The response body will be CSV or NDJSON depending on the export format.
82
+ *
83
+ * @param exportId UUID of a **completed** export job.
84
+ * @returns Raw fetch `Response` with the file body.
85
+ * @throws {PermissionError} If the export is not complete.
86
+ * @throws {NotFoundError} If the export does not exist.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const response = await client.opportunities.downloadExport(exportId);
91
+ * const csv = await response.text();
92
+ * ```
93
+ */
94
+ downloadExport(exportId: string): Promise<Response>;
95
+ /**
96
+ * Async generator that automatically paginates over all matching opportunities.
97
+ *
98
+ * Uses cursor-based pagination when available, falling back to offset.
99
+ * Yields one page of results at a time.
100
+ *
101
+ * @param params Same filter parameters as `list()`. Do not pass `page` or `cursor`.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * for await (const page of client.opportunities.paginate({ naics: '541512' })) {
106
+ * for (const opp of page.data) {
107
+ * console.log(opp.title);
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ paginate(params: Omit<ListOpportunitiesParams, 'page' | 'cursor'> & {
113
+ limit?: number;
114
+ }): AsyncGenerator<ParsedResponse<Opportunity[]>>;
115
+ }
116
+ //# sourceMappingURL=opportunities.d.ts.map
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Opportunities resource client.
3
+ *
4
+ * Wraps all /v1/opportunities endpoints:
5
+ * - search (list) GET /v1/opportunities
6
+ * - stats GET /v1/opportunities/stats
7
+ * - get GET /v1/opportunities/:noticeId
8
+ * - createExport POST /v1/opportunities/export
9
+ * - getExport GET /v1/opportunities/export/:exportId
10
+ * - downloadExport GET /v1/opportunities/export/:exportId/download
11
+ * - paginate (generator) auto-paginates over the search endpoint
12
+ */
13
+ import type { HttpClient, ParsedResponse } from '../http.js';
14
+ import type { Opportunity, OpportunitiesStats, ListOpportunitiesParams, GetOpportunitiesStatsParams, CreateExportParams, ExportJob } from '../types/opportunities.js';
15
+ export declare class OpportunitiesResource {
16
+ private readonly http;
17
+ constructor(http: HttpClient);
18
+ /**
19
+ * Search and filter federal contract opportunities.
20
+ *
21
+ * @param params Filter and pagination parameters.
22
+ * @returns Paginated list of opportunities.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const result = await client.opportunities.list({
27
+ * q: 'cybersecurity',
28
+ * naics: '541512',
29
+ * postedAfter: '2025-01-01',
30
+ * limit: 50,
31
+ * });
32
+ * console.log(result.data[0].title);
33
+ * ```
34
+ */
35
+ list(params?: ListOpportunitiesParams): Promise<ParsedResponse<Opportunity[]>>;
36
+ /**
37
+ * Get a single opportunity by its SAM.gov notice ID.
38
+ *
39
+ * @param noticeId The unique SAM.gov notice identifier.
40
+ * @throws {NotFoundError} If the opportunity does not exist.
41
+ */
42
+ get(noticeId: string): Promise<ParsedResponse<Opportunity>>;
43
+ /**
44
+ * Get aggregated statistics for opportunities.
45
+ *
46
+ * @param params Grouping and filter parameters.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const stats = await client.opportunities.stats({ groupBy: 'naics', limit: 10 });
51
+ * ```
52
+ */
53
+ stats(params?: GetOpportunitiesStatsParams): Promise<ParsedResponse<OpportunitiesStats>>;
54
+ /**
55
+ * Create a background export job for opportunities.
56
+ *
57
+ * Requires: Developer plan (CSV only) or Professional/Enterprise plan (all formats).
58
+ * Requires: `export` API key scope.
59
+ *
60
+ * @param params Export parameters (format + same filters as `list`).
61
+ * @returns Export job metadata.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const job = await client.opportunities.createExport({ format: 'csv', agency: 'NASA' });
66
+ * // Poll getExport() until job.data.status === 'done', then call downloadExport().
67
+ * ```
68
+ */
69
+ createExport(params: CreateExportParams): Promise<ParsedResponse<ExportJob>>;
70
+ /**
71
+ * Get the status of an export job.
72
+ *
73
+ * @param exportId UUID of the export job.
74
+ * @throws {NotFoundError} If the export job does not exist or belongs to another user.
75
+ */
76
+ getExport(exportId: string): Promise<ParsedResponse<ExportJob>>;
77
+ /**
78
+ * Download the output file of a completed export job.
79
+ *
80
+ * Returns the raw `Response` object so callers can stream or save the body.
81
+ * The response body will be CSV or NDJSON depending on the export format.
82
+ *
83
+ * @param exportId UUID of a **completed** export job.
84
+ * @returns Raw fetch `Response` with the file body.
85
+ * @throws {PermissionError} If the export is not complete.
86
+ * @throws {NotFoundError} If the export does not exist.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const response = await client.opportunities.downloadExport(exportId);
91
+ * const csv = await response.text();
92
+ * ```
93
+ */
94
+ downloadExport(exportId: string): Promise<Response>;
95
+ /**
96
+ * Async generator that automatically paginates over all matching opportunities.
97
+ *
98
+ * Uses cursor-based pagination when available, falling back to offset.
99
+ * Yields one page of results at a time.
100
+ *
101
+ * @param params Same filter parameters as `list()`. Do not pass `page` or `cursor`.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * for await (const page of client.opportunities.paginate({ naics: '541512' })) {
106
+ * for (const opp of page.data) {
107
+ * console.log(opp.title);
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ paginate(params: Omit<ListOpportunitiesParams, 'page' | 'cursor'> & {
113
+ limit?: number;
114
+ }): AsyncGenerator<ParsedResponse<Opportunity[]>>;
115
+ }
116
+ //# sourceMappingURL=opportunities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunities.d.ts","sourceRoot":"","sources":["../../../src/resources/opportunities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,kBAAkB,EAClB,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,CACR,MAAM,GAAE,uBAA4B,GACnC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC;IAOzC;;;;;OAKG;IACG,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IASjE;;;;;;;;;OASG;IACG,KAAK,CACT,MAAM,GAAE,2BAAgC,GACvC,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAO9C;;;;;;;;;;;;;;OAcG;IACG,YAAY,CAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAIrC;;;;;OAKG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAWrE;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IASzD;;;;;;;;;;;;;;;;OAgBG;IACI,QAAQ,CACb,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5E,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC;CA+BjD"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Webhooks resource client.
3
+ *
4
+ * Wraps all /v1/webhooks endpoints:
5
+ * - create POST /v1/webhooks
6
+ * - list GET /v1/webhooks
7
+ * - get GET /v1/webhooks/:id
8
+ * - update PATCH /v1/webhooks/:id
9
+ * - delete DELETE /v1/webhooks/:id
10
+ * - test POST /v1/webhooks/:id/test
11
+ * - resume POST /v1/webhooks/:id/resume
12
+ * - listDeliveries GET /v1/webhooks/:id/deliveries
13
+ * - getDelivery GET /v1/webhooks/:id/deliveries/:deliveryId
14
+ * - deliveryPages async generator over deliveries
15
+ *
16
+ * Requires: `webhook` API key scope for all operations.
17
+ */
18
+ import type { HttpClient, ParsedResponse } from '../http.cjs';
19
+ import type { Webhook, WebhookDelivery, CreateWebhookParams, UpdateWebhookParams, CreateWebhookResult, RotateSecretResult, ListDeliveriesParams } from '../types/webhooks.cjs';
20
+ export declare class WebhooksResource {
21
+ private readonly http;
22
+ constructor(http: HttpClient);
23
+ /**
24
+ * Create a new webhook subscription.
25
+ *
26
+ * **Important:** The raw signing secret is returned once in the response
27
+ * (`result.data.secret`) and can never be retrieved again. Store it securely
28
+ * and use it to verify incoming deliveries with `FedPulse.verifyWebhook()`.
29
+ *
30
+ * @param params Webhook creation parameters.
31
+ * @throws {PermissionError} If the API key lacks the `webhook` scope.
32
+ * @throws {PermissionError} If the plan limit for webhooks has been reached.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const result = await client.webhooks.create({
37
+ * url: 'https://my-app.example.com/webhooks/fedpulse',
38
+ * events: ['opportunity.new', 'opportunity.modified'],
39
+ * filters: { naics: ['541512'], state: 'VA' },
40
+ * });
41
+ * const signingSecret = result.data.secret; // Store this securely!
42
+ * ```
43
+ */
44
+ create(params: CreateWebhookParams): Promise<ParsedResponse<CreateWebhookResult>>;
45
+ /**
46
+ * List all webhook subscriptions for the authenticated user.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const webhooks = await client.webhooks.list();
51
+ * for (const wh of webhooks.data) {
52
+ * console.log(wh.id, wh.url, wh.isActive);
53
+ * }
54
+ * ```
55
+ */
56
+ list(): Promise<ParsedResponse<Webhook[]>>;
57
+ /**
58
+ * Get a single webhook subscription.
59
+ *
60
+ * @param id Webhook UUID.
61
+ * @throws {NotFoundError} If the webhook does not exist or belongs to another user.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const wh = await client.webhooks.get('wh-uuid');
66
+ * console.log(wh.data.isActive, wh.data.consecutiveFailures);
67
+ * ```
68
+ */
69
+ get(id: string): Promise<ParsedResponse<Webhook>>;
70
+ /**
71
+ * Update a webhook subscription.
72
+ *
73
+ * Pass `rotateSecret: true` to generate a new signing secret.
74
+ * The new secret will be returned in the response.
75
+ *
76
+ * @param id Webhook UUID.
77
+ * @param params Fields to update. At least one non-`rotateSecret` field required.
78
+ * @throws {NotFoundError} If the webhook does not exist.
79
+ * @throws {ValidationError} If no update fields are provided.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const updated = await client.webhooks.update('wh-uuid', {
84
+ * url: 'https://new-endpoint.example.com/webhooks',
85
+ * events: ['opportunity.new'],
86
+ * });
87
+ * ```
88
+ */
89
+ update(id: string, params: UpdateWebhookParams): Promise<ParsedResponse<Webhook | RotateSecretResult>>;
90
+ /**
91
+ * Delete a webhook subscription.
92
+ *
93
+ * @param id Webhook UUID.
94
+ * @throws {NotFoundError} If the webhook does not exist.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * await client.webhooks.delete('wh-uuid');
99
+ * ```
100
+ */
101
+ delete(id: string): Promise<ParsedResponse<null>>;
102
+ /**
103
+ * Send a test event to a webhook endpoint (synchronous delivery).
104
+ *
105
+ * Unlike real deliveries, test events are sent immediately (no queue) and
106
+ * do not count against the circuit-breaker failure counter.
107
+ *
108
+ * @param id Webhook UUID.
109
+ * @throws {NotFoundError} If the webhook does not exist.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const result = await client.webhooks.test('wh-uuid');
114
+ * console.log('Test delivery status:', result.data);
115
+ * ```
116
+ */
117
+ test(id: string): Promise<ParsedResponse<unknown>>;
118
+ /**
119
+ * Resume a paused webhook (clear the circuit-breaker).
120
+ *
121
+ * Webhooks are auto-paused after 5 consecutive delivery failures.
122
+ * Use this to re-enable delivery after fixing the endpoint.
123
+ *
124
+ * @param id Webhook UUID.
125
+ * @throws {NotFoundError} If the webhook does not exist.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * await client.webhooks.resume('wh-uuid');
130
+ * ```
131
+ */
132
+ resume(id: string): Promise<ParsedResponse<Webhook>>;
133
+ /**
134
+ * Get paginated delivery history for a webhook.
135
+ *
136
+ * @param id Webhook UUID.
137
+ * @param params Filter and pagination parameters.
138
+ * @throws {NotFoundError} If the webhook does not exist.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const deliveries = await client.webhooks.listDeliveries('wh-uuid', {
143
+ * status: 'failed',
144
+ * limit: 50,
145
+ * });
146
+ * ```
147
+ */
148
+ listDeliveries(id: string, params?: ListDeliveriesParams): Promise<ParsedResponse<WebhookDelivery[]>>;
149
+ /**
150
+ * Get the full detail of a single webhook delivery, including the payload.
151
+ *
152
+ * @param id Webhook UUID.
153
+ * @param deliveryId Delivery UUID.
154
+ * @throws {NotFoundError} If the webhook or delivery does not exist.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const delivery = await client.webhooks.getDelivery('wh-uuid', 'del-uuid');
159
+ * console.log('Payload:', delivery.data.payload);
160
+ * ```
161
+ */
162
+ getDelivery(id: string, deliveryId: string): Promise<ParsedResponse<WebhookDelivery>>;
163
+ /**
164
+ * Async generator that automatically paginates through delivery history.
165
+ *
166
+ * @param id Webhook UUID.
167
+ * @param params Same filter parameters as `listDeliveries()`. Do not pass `page`.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * for await (const page of client.webhooks.deliveryPages('wh-uuid', { status: 'failed' })) {
172
+ * for (const delivery of page.data) {
173
+ * console.log(delivery.id, delivery.status, delivery.httpStatus);
174
+ * }
175
+ * }
176
+ * ```
177
+ */
178
+ deliveryPages(id: string, params?: Omit<ListDeliveriesParams, 'page'>): AsyncGenerator<ParsedResponse<WebhookDelivery[]>>;
179
+ }
180
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Webhooks resource client.
3
+ *
4
+ * Wraps all /v1/webhooks endpoints:
5
+ * - create POST /v1/webhooks
6
+ * - list GET /v1/webhooks
7
+ * - get GET /v1/webhooks/:id
8
+ * - update PATCH /v1/webhooks/:id
9
+ * - delete DELETE /v1/webhooks/:id
10
+ * - test POST /v1/webhooks/:id/test
11
+ * - resume POST /v1/webhooks/:id/resume
12
+ * - listDeliveries GET /v1/webhooks/:id/deliveries
13
+ * - getDelivery GET /v1/webhooks/:id/deliveries/:deliveryId
14
+ * - deliveryPages async generator over deliveries
15
+ *
16
+ * Requires: `webhook` API key scope for all operations.
17
+ */
18
+ import type { HttpClient, ParsedResponse } from '../http.js';
19
+ import type { Webhook, WebhookDelivery, CreateWebhookParams, UpdateWebhookParams, CreateWebhookResult, RotateSecretResult, ListDeliveriesParams } from '../types/webhooks.js';
20
+ export declare class WebhooksResource {
21
+ private readonly http;
22
+ constructor(http: HttpClient);
23
+ /**
24
+ * Create a new webhook subscription.
25
+ *
26
+ * **Important:** The raw signing secret is returned once in the response
27
+ * (`result.data.secret`) and can never be retrieved again. Store it securely
28
+ * and use it to verify incoming deliveries with `FedPulse.verifyWebhook()`.
29
+ *
30
+ * @param params Webhook creation parameters.
31
+ * @throws {PermissionError} If the API key lacks the `webhook` scope.
32
+ * @throws {PermissionError} If the plan limit for webhooks has been reached.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const result = await client.webhooks.create({
37
+ * url: 'https://my-app.example.com/webhooks/fedpulse',
38
+ * events: ['opportunity.new', 'opportunity.modified'],
39
+ * filters: { naics: ['541512'], state: 'VA' },
40
+ * });
41
+ * const signingSecret = result.data.secret; // Store this securely!
42
+ * ```
43
+ */
44
+ create(params: CreateWebhookParams): Promise<ParsedResponse<CreateWebhookResult>>;
45
+ /**
46
+ * List all webhook subscriptions for the authenticated user.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const webhooks = await client.webhooks.list();
51
+ * for (const wh of webhooks.data) {
52
+ * console.log(wh.id, wh.url, wh.isActive);
53
+ * }
54
+ * ```
55
+ */
56
+ list(): Promise<ParsedResponse<Webhook[]>>;
57
+ /**
58
+ * Get a single webhook subscription.
59
+ *
60
+ * @param id Webhook UUID.
61
+ * @throws {NotFoundError} If the webhook does not exist or belongs to another user.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const wh = await client.webhooks.get('wh-uuid');
66
+ * console.log(wh.data.isActive, wh.data.consecutiveFailures);
67
+ * ```
68
+ */
69
+ get(id: string): Promise<ParsedResponse<Webhook>>;
70
+ /**
71
+ * Update a webhook subscription.
72
+ *
73
+ * Pass `rotateSecret: true` to generate a new signing secret.
74
+ * The new secret will be returned in the response.
75
+ *
76
+ * @param id Webhook UUID.
77
+ * @param params Fields to update. At least one non-`rotateSecret` field required.
78
+ * @throws {NotFoundError} If the webhook does not exist.
79
+ * @throws {ValidationError} If no update fields are provided.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const updated = await client.webhooks.update('wh-uuid', {
84
+ * url: 'https://new-endpoint.example.com/webhooks',
85
+ * events: ['opportunity.new'],
86
+ * });
87
+ * ```
88
+ */
89
+ update(id: string, params: UpdateWebhookParams): Promise<ParsedResponse<Webhook | RotateSecretResult>>;
90
+ /**
91
+ * Delete a webhook subscription.
92
+ *
93
+ * @param id Webhook UUID.
94
+ * @throws {NotFoundError} If the webhook does not exist.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * await client.webhooks.delete('wh-uuid');
99
+ * ```
100
+ */
101
+ delete(id: string): Promise<ParsedResponse<null>>;
102
+ /**
103
+ * Send a test event to a webhook endpoint (synchronous delivery).
104
+ *
105
+ * Unlike real deliveries, test events are sent immediately (no queue) and
106
+ * do not count against the circuit-breaker failure counter.
107
+ *
108
+ * @param id Webhook UUID.
109
+ * @throws {NotFoundError} If the webhook does not exist.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const result = await client.webhooks.test('wh-uuid');
114
+ * console.log('Test delivery status:', result.data);
115
+ * ```
116
+ */
117
+ test(id: string): Promise<ParsedResponse<unknown>>;
118
+ /**
119
+ * Resume a paused webhook (clear the circuit-breaker).
120
+ *
121
+ * Webhooks are auto-paused after 5 consecutive delivery failures.
122
+ * Use this to re-enable delivery after fixing the endpoint.
123
+ *
124
+ * @param id Webhook UUID.
125
+ * @throws {NotFoundError} If the webhook does not exist.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * await client.webhooks.resume('wh-uuid');
130
+ * ```
131
+ */
132
+ resume(id: string): Promise<ParsedResponse<Webhook>>;
133
+ /**
134
+ * Get paginated delivery history for a webhook.
135
+ *
136
+ * @param id Webhook UUID.
137
+ * @param params Filter and pagination parameters.
138
+ * @throws {NotFoundError} If the webhook does not exist.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const deliveries = await client.webhooks.listDeliveries('wh-uuid', {
143
+ * status: 'failed',
144
+ * limit: 50,
145
+ * });
146
+ * ```
147
+ */
148
+ listDeliveries(id: string, params?: ListDeliveriesParams): Promise<ParsedResponse<WebhookDelivery[]>>;
149
+ /**
150
+ * Get the full detail of a single webhook delivery, including the payload.
151
+ *
152
+ * @param id Webhook UUID.
153
+ * @param deliveryId Delivery UUID.
154
+ * @throws {NotFoundError} If the webhook or delivery does not exist.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const delivery = await client.webhooks.getDelivery('wh-uuid', 'del-uuid');
159
+ * console.log('Payload:', delivery.data.payload);
160
+ * ```
161
+ */
162
+ getDelivery(id: string, deliveryId: string): Promise<ParsedResponse<WebhookDelivery>>;
163
+ /**
164
+ * Async generator that automatically paginates through delivery history.
165
+ *
166
+ * @param id Webhook UUID.
167
+ * @param params Same filter parameters as `listDeliveries()`. Do not pass `page`.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * for await (const page of client.webhooks.deliveryPages('wh-uuid', { status: 'failed' })) {
172
+ * for (const delivery of page.data) {
173
+ * console.log(delivery.id, delivery.status, delivery.httpStatus);
174
+ * }
175
+ * }
176
+ * ```
177
+ */
178
+ deliveryPages(id: string, params?: Omit<ListDeliveriesParams, 'page'>): AsyncGenerator<ParsedResponse<WebhookDelivery[]>>;
179
+ }
180
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CACV,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAK/C;;;;;;;;;;OAUG;IACG,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;IAIhD;;;;;;;;;;;OAWG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAKvD;;;;;;;;;;;;;;;;;;OAkBG;IACG,MAAM,CACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAC;IAWxD;;;;;;;;;;OAUG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAKvD;;;;;;;;;;;;;;OAcG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAKxD;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAK1D;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAClB,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,oBAAyB,GAChC,OAAO,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,CAAC;IAS7C;;;;;;;;;;;;OAYG;IACG,WAAW,CACf,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAU3C;;;;;;;;;;;;;;OAcG;IACI,aAAa,CAClB,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAM,GAC9C,cAAc,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,CAAC;CAoBrD"}