@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,167 @@
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
+ export class OpportunitiesResource {
14
+ http;
15
+ constructor(http) {
16
+ this.http = http;
17
+ }
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
+ async list(params = {}) {
36
+ return this.http.get('/v1/opportunities', params);
37
+ }
38
+ /**
39
+ * Get a single opportunity by its SAM.gov notice ID.
40
+ *
41
+ * @param noticeId The unique SAM.gov notice identifier.
42
+ * @throws {NotFoundError} If the opportunity does not exist.
43
+ */
44
+ async get(noticeId) {
45
+ if (!noticeId || typeof noticeId !== 'string' || noticeId.trim() === '') {
46
+ throw new Error('noticeId must be a non-empty string');
47
+ }
48
+ return this.http.get(`/v1/opportunities/${encodeURIComponent(noticeId.trim())}`);
49
+ }
50
+ /**
51
+ * Get aggregated statistics for opportunities.
52
+ *
53
+ * @param params Grouping and filter parameters.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const stats = await client.opportunities.stats({ groupBy: 'naics', limit: 10 });
58
+ * ```
59
+ */
60
+ async stats(params = {}) {
61
+ return this.http.get('/v1/opportunities/stats', params);
62
+ }
63
+ /**
64
+ * Create a background export job for opportunities.
65
+ *
66
+ * Requires: Developer plan (CSV only) or Professional/Enterprise plan (all formats).
67
+ * Requires: `export` API key scope.
68
+ *
69
+ * @param params Export parameters (format + same filters as `list`).
70
+ * @returns Export job metadata.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const job = await client.opportunities.createExport({ format: 'csv', agency: 'NASA' });
75
+ * // Poll getExport() until job.data.status === 'done', then call downloadExport().
76
+ * ```
77
+ */
78
+ async createExport(params) {
79
+ return this.http.post('/v1/opportunities/export', params);
80
+ }
81
+ /**
82
+ * Get the status of an export job.
83
+ *
84
+ * @param exportId UUID of the export job.
85
+ * @throws {NotFoundError} If the export job does not exist or belongs to another user.
86
+ */
87
+ async getExport(exportId) {
88
+ if (!exportId || typeof exportId !== 'string' || exportId.trim() === '') {
89
+ throw new Error('exportId must be a non-empty string');
90
+ }
91
+ return this.http.get(`/v1/opportunities/export/${encodeURIComponent(exportId.trim())}`, {}, { cacheTtlMs: 0 } // Never cache — status changes over time.
92
+ );
93
+ }
94
+ /**
95
+ * Download the output file of a completed export job.
96
+ *
97
+ * Returns the raw `Response` object so callers can stream or save the body.
98
+ * The response body will be CSV or NDJSON depending on the export format.
99
+ *
100
+ * @param exportId UUID of a **completed** export job.
101
+ * @returns Raw fetch `Response` with the file body.
102
+ * @throws {PermissionError} If the export is not complete.
103
+ * @throws {NotFoundError} If the export does not exist.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const response = await client.opportunities.downloadExport(exportId);
108
+ * const csv = await response.text();
109
+ * ```
110
+ */
111
+ async downloadExport(exportId) {
112
+ if (!exportId || typeof exportId !== 'string' || exportId.trim() === '') {
113
+ throw new Error('exportId must be a non-empty string');
114
+ }
115
+ return this.http.rawGet(`/v1/opportunities/export/${encodeURIComponent(exportId.trim())}/download`);
116
+ }
117
+ /**
118
+ * Async generator that automatically paginates over all matching opportunities.
119
+ *
120
+ * Uses cursor-based pagination when available, falling back to offset.
121
+ * Yields one page of results at a time.
122
+ *
123
+ * @param params Same filter parameters as `list()`. Do not pass `page` or `cursor`.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * for await (const page of client.opportunities.paginate({ naics: '541512' })) {
128
+ * for (const opp of page.data) {
129
+ * console.log(opp.title);
130
+ * }
131
+ * }
132
+ * ```
133
+ */
134
+ async *paginate(params) {
135
+ let cursor = undefined;
136
+ let page = 1;
137
+ let hasMore = true;
138
+ while (hasMore) {
139
+ const queryParams = {
140
+ ...params,
141
+ ...(cursor !== undefined ? { cursor } : { page }),
142
+ };
143
+ const result = await this.list(queryParams);
144
+ yield result;
145
+ const pagination = result.pagination;
146
+ if (pagination === null) {
147
+ hasMore = false;
148
+ }
149
+ else if ('nextCursor' in pagination) {
150
+ cursor = pagination.nextCursor ?? undefined;
151
+ hasMore = pagination.hasNextPage;
152
+ }
153
+ else if ('hasNextPage' in pagination) {
154
+ if (!pagination.hasNextPage) {
155
+ hasMore = false;
156
+ }
157
+ else {
158
+ page++;
159
+ }
160
+ }
161
+ else {
162
+ hasMore = false;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ //# sourceMappingURL=opportunities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunities.js","sourceRoot":"","sources":["../../../src/resources/opportunities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,MAAM,OAAO,qBAAqB;IACf,IAAI,CAAa;IAElC,YAAY,IAAgB;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M,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;gBACvC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;oBAC5B,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACN,IAAI,EAAE,CAAC;gBACT,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,259 @@
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
+ export class WebhooksResource {
19
+ http;
20
+ constructor(http) {
21
+ this.http = http;
22
+ }
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
+ async create(params) {
45
+ validateCreateParams(params);
46
+ return this.http.post('/v1/webhooks', params);
47
+ }
48
+ /**
49
+ * List all webhook subscriptions for the authenticated user.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const webhooks = await client.webhooks.list();
54
+ * for (const wh of webhooks.data) {
55
+ * console.log(wh.id, wh.url, wh.isActive);
56
+ * }
57
+ * ```
58
+ */
59
+ async list() {
60
+ return this.http.get('/v1/webhooks', {}, { cacheTtlMs: 0 });
61
+ }
62
+ /**
63
+ * Get a single webhook subscription.
64
+ *
65
+ * @param id Webhook UUID.
66
+ * @throws {NotFoundError} If the webhook does not exist or belongs to another user.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const wh = await client.webhooks.get('wh-uuid');
71
+ * console.log(wh.data.isActive, wh.data.consecutiveFailures);
72
+ * ```
73
+ */
74
+ async get(id) {
75
+ validateId(id, 'id');
76
+ return this.http.get(`/v1/webhooks/${encodeURIComponent(id)}`, {}, { cacheTtlMs: 0 });
77
+ }
78
+ /**
79
+ * Update a webhook subscription.
80
+ *
81
+ * Pass `rotateSecret: true` to generate a new signing secret.
82
+ * The new secret will be returned in the response.
83
+ *
84
+ * @param id Webhook UUID.
85
+ * @param params Fields to update. At least one non-`rotateSecret` field required.
86
+ * @throws {NotFoundError} If the webhook does not exist.
87
+ * @throws {ValidationError} If no update fields are provided.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const updated = await client.webhooks.update('wh-uuid', {
92
+ * url: 'https://new-endpoint.example.com/webhooks',
93
+ * events: ['opportunity.new'],
94
+ * });
95
+ * ```
96
+ */
97
+ async update(id, params) {
98
+ validateId(id, 'id');
99
+ if (Object.keys(params).length === 0) {
100
+ throw new Error('At least one field must be provided for update');
101
+ }
102
+ return this.http.patch(`/v1/webhooks/${encodeURIComponent(id)}`, params);
103
+ }
104
+ /**
105
+ * Delete a webhook subscription.
106
+ *
107
+ * @param id Webhook UUID.
108
+ * @throws {NotFoundError} If the webhook does not exist.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * await client.webhooks.delete('wh-uuid');
113
+ * ```
114
+ */
115
+ async delete(id) {
116
+ validateId(id, 'id');
117
+ return this.http.del(`/v1/webhooks/${encodeURIComponent(id)}`);
118
+ }
119
+ /**
120
+ * Send a test event to a webhook endpoint (synchronous delivery).
121
+ *
122
+ * Unlike real deliveries, test events are sent immediately (no queue) and
123
+ * do not count against the circuit-breaker failure counter.
124
+ *
125
+ * @param id Webhook UUID.
126
+ * @throws {NotFoundError} If the webhook does not exist.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const result = await client.webhooks.test('wh-uuid');
131
+ * console.log('Test delivery status:', result.data);
132
+ * ```
133
+ */
134
+ async test(id) {
135
+ validateId(id, 'id');
136
+ return this.http.post(`/v1/webhooks/${encodeURIComponent(id)}/test`, {});
137
+ }
138
+ /**
139
+ * Resume a paused webhook (clear the circuit-breaker).
140
+ *
141
+ * Webhooks are auto-paused after 5 consecutive delivery failures.
142
+ * Use this to re-enable delivery after fixing the endpoint.
143
+ *
144
+ * @param id Webhook UUID.
145
+ * @throws {NotFoundError} If the webhook does not exist.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * await client.webhooks.resume('wh-uuid');
150
+ * ```
151
+ */
152
+ async resume(id) {
153
+ validateId(id, 'id');
154
+ return this.http.post(`/v1/webhooks/${encodeURIComponent(id)}/resume`, {});
155
+ }
156
+ /**
157
+ * Get paginated delivery history for a webhook.
158
+ *
159
+ * @param id Webhook UUID.
160
+ * @param params Filter and pagination parameters.
161
+ * @throws {NotFoundError} If the webhook does not exist.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * const deliveries = await client.webhooks.listDeliveries('wh-uuid', {
166
+ * status: 'failed',
167
+ * limit: 50,
168
+ * });
169
+ * ```
170
+ */
171
+ async listDeliveries(id, params = {}) {
172
+ validateId(id, 'id');
173
+ return this.http.get(`/v1/webhooks/${encodeURIComponent(id)}/deliveries`, params, { cacheTtlMs: 0 });
174
+ }
175
+ /**
176
+ * Get the full detail of a single webhook delivery, including the payload.
177
+ *
178
+ * @param id Webhook UUID.
179
+ * @param deliveryId Delivery UUID.
180
+ * @throws {NotFoundError} If the webhook or delivery does not exist.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * const delivery = await client.webhooks.getDelivery('wh-uuid', 'del-uuid');
185
+ * console.log('Payload:', delivery.data.payload);
186
+ * ```
187
+ */
188
+ async getDelivery(id, deliveryId) {
189
+ validateId(id, 'id');
190
+ validateId(deliveryId, 'deliveryId');
191
+ return this.http.get(`/v1/webhooks/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}`, {}, { cacheTtlMs: 0 });
192
+ }
193
+ /**
194
+ * Async generator that automatically paginates through delivery history.
195
+ *
196
+ * @param id Webhook UUID.
197
+ * @param params Same filter parameters as `listDeliveries()`. Do not pass `page`.
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * for await (const page of client.webhooks.deliveryPages('wh-uuid', { status: 'failed' })) {
202
+ * for (const delivery of page.data) {
203
+ * console.log(delivery.id, delivery.status, delivery.httpStatus);
204
+ * }
205
+ * }
206
+ * ```
207
+ */
208
+ async *deliveryPages(id, params = {}) {
209
+ validateId(id, 'id');
210
+ let page = 1;
211
+ let hasMore = true;
212
+ while (hasMore) {
213
+ const result = await this.listDeliveries(id, { ...params, page });
214
+ yield result;
215
+ const pagination = result.pagination;
216
+ if (pagination === null) {
217
+ hasMore = false;
218
+ }
219
+ else if ('hasNextPage' in pagination) {
220
+ hasMore = pagination.hasNextPage;
221
+ if (hasMore)
222
+ page++;
223
+ }
224
+ else {
225
+ hasMore = false;
226
+ }
227
+ }
228
+ }
229
+ }
230
+ // ── Helpers ────────────────────────────────────────────────────────────────────
231
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
232
+ function validateId(value, name) {
233
+ if (!value || typeof value !== 'string' || value.trim() === '') {
234
+ throw new Error(`${name} must be a non-empty string`);
235
+ }
236
+ if (!UUID_RE.test(value.trim())) {
237
+ throw new Error(`${name} must be a valid UUID`);
238
+ }
239
+ }
240
+ function validateCreateParams(params) {
241
+ if (!params.url || typeof params.url !== 'string' || params.url.trim() === '') {
242
+ throw new Error('url must be a non-empty string');
243
+ }
244
+ try {
245
+ const parsed = new URL(params.url);
246
+ if (parsed.protocol !== 'https:') {
247
+ throw new Error('url must use the https:// scheme');
248
+ }
249
+ }
250
+ catch (err) {
251
+ if (err instanceof Error && err.message.includes('https://'))
252
+ throw err;
253
+ throw new Error(`url is not a valid URL: ${params.url}`);
254
+ }
255
+ if (!Array.isArray(params.events) || params.events.length === 0) {
256
+ throw new Error('events must be a non-empty array of webhook event types');
257
+ }
258
+ }
259
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,MAAM,OAAO,gBAAgB;IACV,IAAI,CAAa;IAElC,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,MAAM,CACV,MAA2B;QAE3B,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsB,cAAc,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,cAAc,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC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AAE,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Analytics domain (/v1/analytics).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/types/analytics.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Assistance Listings domain (/v1/assistance).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=assistance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistance.js","sourceRoot":"","sources":["../../../src/types/assistance.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Common types shared across all FedPulse API domains.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Entities domain (/v1/entities).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Exclusions domain (/v1/exclusions).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=exclusions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exclusions.js","sourceRoot":"","sources":["../../../src/types/exclusions.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Barrel export for all FedPulse SDK TypeScript types.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Intelligence domain (/v1/intelligence).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=intelligence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence.js","sourceRoot":"","sources":["../../../src/types/intelligence.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Opportunities domain (/v1/opportunities).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=opportunities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opportunities.js","sourceRoot":"","sources":["../../../src/types/opportunities.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types for the Webhooks domain (/v1/webhooks).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/types/webhooks.ts"],"names":[],"mappings":"AAAA;;GAEG"}