@specstream/sdk 0.0.0-stage → 1.1.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/dist/index.js ADDED
@@ -0,0 +1,1009 @@
1
+ import { requireWorkAuthorization } from "./authorization.js";
2
+ export const FAMILIES = [
3
+ "local_business",
4
+ "creator",
5
+ "organization",
6
+ "storefront_product",
7
+ "app_listing",
8
+ "job_posting",
9
+ "scholarly_work",
10
+ "tender",
11
+ "grant",
12
+ "software_repository",
13
+ "software_package",
14
+ "dataset",
15
+ "clinical_trial",
16
+ "regulatory_document",
17
+ "vulnerability",
18
+ "book",
19
+ "podcast",
20
+ "web_page",
21
+ "knowledge_entity",
22
+ "person",
23
+ ];
24
+ export const DEFAULT_BASE_URL = "https://api.specstream.ai";
25
+ export class SpecstreamError extends Error {
26
+ status;
27
+ body;
28
+ code;
29
+ details;
30
+ constructor(message, status = null, body = null) {
31
+ super(message);
32
+ this.name = "SpecstreamError";
33
+ this.status = status;
34
+ this.body = body;
35
+ let parsed = body;
36
+ if (typeof parsed === "string") {
37
+ try {
38
+ parsed = JSON.parse(parsed);
39
+ }
40
+ catch {
41
+ parsed = null;
42
+ }
43
+ }
44
+ const candidate = parsed && typeof parsed === "object" && !Array.isArray(parsed)
45
+ ? parsed.error : null;
46
+ const error = candidate && typeof candidate === "object" && !Array.isArray(candidate)
47
+ ? candidate : {};
48
+ this.code = typeof error.code === "string" ? error.code : null;
49
+ this.details = error.details && typeof error.details === "object" && !Array.isArray(error.details)
50
+ ? { ...error.details } : {};
51
+ }
52
+ }
53
+ export function assertFamily(entityType) {
54
+ if (!FAMILIES.includes(entityType)) {
55
+ throw new Error(`unsupported entity_type ${entityType}`);
56
+ }
57
+ return entityType;
58
+ }
59
+ export class Client {
60
+ apiKey;
61
+ baseUrl;
62
+ fetchFn;
63
+ exportOrigin;
64
+ timeoutMs;
65
+ constructor(options) {
66
+ const key = (options.apiKey || "").trim();
67
+ if (!key) {
68
+ throw new SpecstreamError("SPECSTREAM_API_KEY is required");
69
+ }
70
+ this.apiKey = key;
71
+ this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
72
+ this.fetchFn = options.fetch ?? fetch;
73
+ this.exportOrigin = options.exportOrigin;
74
+ this.timeoutMs = options.timeoutMs ?? 150_000;
75
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || this.timeoutMs > 2_147_483_647) {
76
+ throw new SpecstreamError("timeoutMs must be a positive integer up to 2147483647");
77
+ }
78
+ }
79
+ families() {
80
+ return FAMILIES;
81
+ }
82
+ compile(q, locale = "en-US") {
83
+ return this.request("POST", "/v1/parse", { q, locale });
84
+ }
85
+ editSpec(ast, operations = []) {
86
+ return this.request("POST", "/v1/parse/from-chips", { ast, operations });
87
+ }
88
+ specOptions(target) {
89
+ return this.request("GET", "/v1/spec-options/" + encodeURIComponent(target));
90
+ }
91
+ getFind(findId) {
92
+ return this.request("GET", `/v1/finds/${encodeURIComponent(findId)}`);
93
+ }
94
+ revisit(findId, after = "", limit = 100) {
95
+ const query = new URLSearchParams({ after, limit: String(limit) });
96
+ return this.request("GET", `/v1/finds/${encodeURIComponent(findId)}/revisit?${query}`);
97
+ }
98
+ rows(findId, cursor = null, limit = 100) {
99
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)
100
+ throw new Error("Row page limit must be an integer from 1 to 100");
101
+ if (cursor !== null && (typeof cursor !== "string" || !cursor || cursor.length > 2048))
102
+ throw new Error("Use the opaque next_cursor returned by this Delivery");
103
+ const query = new URLSearchParams({ limit: String(limit) });
104
+ if (cursor !== null)
105
+ query.set("cursor", cursor);
106
+ return this.request("GET", "/v1/finds/" + encodeURIComponent(findId) + "/rows?" + query);
107
+ }
108
+ export(findId, format = "csv") {
109
+ return this.request("POST", "/v1/finds/" + encodeURIComponent(findId) + "/export", { format });
110
+ }
111
+ /** Fetch a fresh one-use export. Account credentials never accompany its capability. */
112
+ async downloadExport(findId, format = "xlsx", maxBytes = 64 * 1024 * 1024) {
113
+ if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
114
+ throw new SpecstreamError("maxBytes must be a positive integer");
115
+ }
116
+ const exported = await this.export(findId, format);
117
+ const location = exported.download_url;
118
+ if (typeof location !== "string" || /[\x00-\x20\\]/.test(location) ||
119
+ /^https?:\/\/[^/]*@/i.test(location)) {
120
+ throw new SpecstreamError("Export returned an invalid download location");
121
+ }
122
+ let url;
123
+ try {
124
+ url = new URL(location);
125
+ const base = new URL(this.baseUrl);
126
+ const allowed = new Set([base.origin]);
127
+ if (this.exportOrigin !== undefined) {
128
+ const declared = new URL(this.exportOrigin);
129
+ if (!['http:', 'https:'].includes(declared.protocol) || declared.username ||
130
+ declared.password || declared.search || declared.hash || declared.pathname !== '/') {
131
+ throw new Error("invalid export origin");
132
+ }
133
+ allowed.add(declared.origin);
134
+ }
135
+ else if (base.origin === "https://api.specstream.ai") {
136
+ allowed.add("https://specstream.ai");
137
+ }
138
+ if (!allowed.has(url.origin) || !['http:', 'https:'].includes(url.protocol) ||
139
+ url.username || url.password || url.search || url.hash ||
140
+ !/^\/export\/[A-Za-z0-9_-]+$/.test(url.pathname)) {
141
+ throw new Error("untrusted download location");
142
+ }
143
+ }
144
+ catch {
145
+ throw new SpecstreamError("Export returned an untrusted download location");
146
+ }
147
+ try {
148
+ const response = await this.fetchFn(url.href, {
149
+ method: "GET", redirect: "error", credentials: "omit",
150
+ signal: AbortSignal.timeout(this.timeoutMs),
151
+ headers: { Accept: "*/*", "Accept-Encoding": "identity" },
152
+ });
153
+ if (response.status !== 200) {
154
+ await response.body?.cancel();
155
+ throw new SpecstreamError("Export download failed", response.status);
156
+ }
157
+ const reader = response.body?.getReader();
158
+ if (!reader)
159
+ throw new SpecstreamError("Export download returned no body", response.status);
160
+ const chunks = [];
161
+ let size = 0;
162
+ try {
163
+ for (;;) {
164
+ const { done, value } = await reader.read();
165
+ if (done)
166
+ break;
167
+ size += value.length;
168
+ if (size > maxBytes) {
169
+ await reader.cancel();
170
+ throw new SpecstreamError("Export exceeds maxBytes", response.status);
171
+ }
172
+ chunks.push(value);
173
+ }
174
+ }
175
+ finally {
176
+ reader.releaseLock();
177
+ }
178
+ if (!size)
179
+ throw new SpecstreamError("Export download returned no body", response.status);
180
+ const bytes = new Uint8Array(size);
181
+ let offset = 0;
182
+ for (const chunk of chunks) {
183
+ bytes.set(chunk, offset);
184
+ offset += chunk.length;
185
+ }
186
+ return bytes;
187
+ }
188
+ catch (error) {
189
+ if (error instanceof SpecstreamError)
190
+ throw error;
191
+ throw new SpecstreamError("Export download transport failed");
192
+ }
193
+ }
194
+ // BEGIN GENERATED LIFECYCLE
195
+ getVocabulary() {
196
+ let path = `/v1/vocabulary`;
197
+ return this.request("GET", path);
198
+ }
199
+ workspaceListAuditEvents(query = {}) {
200
+ let path = `/v1/workspace/audit`;
201
+ const queryString = new URLSearchParams();
202
+ for (const [key, value] of Object.entries(query))
203
+ if (value !== undefined && value !== null)
204
+ queryString.set(key, String(value));
205
+ if (queryString.size)
206
+ path += "?" + queryString.toString();
207
+ return this.request("GET", path);
208
+ }
209
+ understandLive(request) {
210
+ let path = `/v1/understand`;
211
+ return this.request("POST", path, request);
212
+ }
213
+ workspaceSearch(query) {
214
+ let path = `/v1/search`;
215
+ const queryString = new URLSearchParams();
216
+ for (const [key, value] of Object.entries(query))
217
+ if (value !== undefined && value !== null)
218
+ queryString.set(key, String(value));
219
+ if (queryString.size)
220
+ path += "?" + queryString.toString();
221
+ return this.request("GET", path);
222
+ }
223
+ workspaceListNotifications(query = {}) {
224
+ let path = `/v1/workspace/notifications`;
225
+ const queryString = new URLSearchParams();
226
+ for (const [key, value] of Object.entries(query))
227
+ if (value !== undefined && value !== null)
228
+ queryString.set(key, String(value));
229
+ if (queryString.size)
230
+ path += "?" + queryString.toString();
231
+ return this.request("GET", path);
232
+ }
233
+ workspaceUpdateNotification(identifier, request) {
234
+ let path = `/v1/workspace/notifications/${encodeURIComponent(identifier)}`;
235
+ return this.request("PATCH", path, request);
236
+ }
237
+ workspaceReadNotifications(request) {
238
+ let path = `/v1/workspace/notifications/read`;
239
+ return this.request("POST", path, request);
240
+ }
241
+ getMe() {
242
+ let path = `/v1/me`;
243
+ return this.request("GET", path);
244
+ }
245
+ getAccount() {
246
+ let path = `/v1/account`;
247
+ return this.request("GET", path);
248
+ }
249
+ listAccountKeys() {
250
+ let path = `/v1/account/keys`;
251
+ return this.request("GET", path);
252
+ }
253
+ createAccountKey(request) {
254
+ let path = `/v1/account/keys`;
255
+ return this.request("POST", path, request);
256
+ }
257
+ updateAccountSpend(request) {
258
+ let path = `/v1/account/spend`;
259
+ return this.request("PATCH", path, request);
260
+ }
261
+ revokeAccountKey(keyId) {
262
+ let path = `/v1/account/keys/${encodeURIComponent(keyId)}`;
263
+ return this.request("DELETE", path);
264
+ }
265
+ getFindCommerce(findId) {
266
+ let path = `/v1/finds/${encodeURIComponent(findId)}/commerce`;
267
+ return this.request("GET", path);
268
+ }
269
+ reconcileFindCommerce(findId) {
270
+ let path = `/v1/finds/${encodeURIComponent(findId)}/reconcile`;
271
+ return this.request("POST", path);
272
+ }
273
+ cancelFind(findId) {
274
+ let path = `/v1/finds/${encodeURIComponent(findId)}/cancel`;
275
+ return this.request("POST", path);
276
+ }
277
+ shareFind(findId, request) {
278
+ let path = `/v1/finds/${encodeURIComponent(findId)}/share`;
279
+ return this.request("POST", path, request);
280
+ }
281
+ revokeShare(shareId, request) {
282
+ let path = `/v1/share/${encodeURIComponent(shareId)}/revoke`;
283
+ return this.request("POST", path, request);
284
+ }
285
+ createSpec(request) {
286
+ let path = `/v1/specs`;
287
+ return this.request("POST", path, request);
288
+ }
289
+ listSpecs(query = {}) {
290
+ let path = `/v1/specs`;
291
+ const queryString = new URLSearchParams();
292
+ for (const [key, value] of Object.entries(query))
293
+ if (value !== undefined && value !== null)
294
+ queryString.set(key, String(value));
295
+ if (queryString.size)
296
+ path += "?" + queryString.toString();
297
+ return this.request("GET", path);
298
+ }
299
+ getSpec(specId) {
300
+ let path = `/v1/specs/${encodeURIComponent(specId)}`;
301
+ return this.request("GET", path);
302
+ }
303
+ reviseSpec(specId, request) {
304
+ let path = `/v1/specs/${encodeURIComponent(specId)}/revisions`;
305
+ return this.request("POST", path, request);
306
+ }
307
+ listSpecRevisions(specId, query = {}) {
308
+ let path = `/v1/specs/${encodeURIComponent(specId)}/revisions`;
309
+ const queryString = new URLSearchParams();
310
+ for (const [key, value] of Object.entries(query))
311
+ if (value !== undefined && value !== null)
312
+ queryString.set(key, String(value));
313
+ if (queryString.size)
314
+ path += "?" + queryString.toString();
315
+ return this.request("GET", path);
316
+ }
317
+ getSpecRevision(specId, revisionId) {
318
+ let path = `/v1/specs/${encodeURIComponent(specId)}/revisions/${encodeURIComponent(revisionId)}`;
319
+ return this.request("GET", path);
320
+ }
321
+ archiveSpec(specId, request) {
322
+ let path = `/v1/specs/${encodeURIComponent(specId)}`;
323
+ return this.request("PATCH", path, request);
324
+ }
325
+ listSpecFinds(specId, query = {}) {
326
+ let path = `/v1/specs/${encodeURIComponent(specId)}/finds`;
327
+ const queryString = new URLSearchParams();
328
+ for (const [key, value] of Object.entries(query))
329
+ if (value !== undefined && value !== null)
330
+ queryString.set(key, String(value));
331
+ if (queryString.size)
332
+ path += "?" + queryString.toString();
333
+ return this.request("GET", path);
334
+ }
335
+ getFindLineage(findId) {
336
+ let path = `/v1/finds/${encodeURIComponent(findId)}/lineage`;
337
+ return this.request("GET", path);
338
+ }
339
+ getDelivery(findId) {
340
+ let path = `/v1/finds/${encodeURIComponent(findId)}/delivery`;
341
+ return this.request("GET", path);
342
+ }
343
+ getFindDecisions(findId, query = {}) {
344
+ let path = `/v1/finds/${encodeURIComponent(findId)}/decisions`;
345
+ const queryString = new URLSearchParams();
346
+ for (const [key, value] of Object.entries(query))
347
+ if (value !== undefined && value !== null)
348
+ queryString.set(key, String(value));
349
+ if (queryString.size)
350
+ path += "?" + queryString.toString();
351
+ return this.request("GET", path);
352
+ }
353
+ createProject(request) {
354
+ let path = `/v1/projects`;
355
+ return this.request("POST", path, request);
356
+ }
357
+ listProjects(query = {}) {
358
+ let path = `/v1/projects`;
359
+ const queryString = new URLSearchParams();
360
+ for (const [key, value] of Object.entries(query))
361
+ if (value !== undefined && value !== null)
362
+ queryString.set(key, String(value));
363
+ if (queryString.size)
364
+ path += "?" + queryString.toString();
365
+ return this.request("GET", path);
366
+ }
367
+ getProject(projectId) {
368
+ let path = `/v1/projects/${encodeURIComponent(projectId)}`;
369
+ return this.request("GET", path);
370
+ }
371
+ updateProject(projectId, request) {
372
+ let path = `/v1/projects/${encodeURIComponent(projectId)}`;
373
+ return this.request("PATCH", path, request);
374
+ }
375
+ putProjectMember(projectId, request) {
376
+ let path = `/v1/projects/${encodeURIComponent(projectId)}/members`;
377
+ return this.request("POST", path, request);
378
+ }
379
+ listProjectMembers(projectId, query = {}) {
380
+ let path = `/v1/projects/${encodeURIComponent(projectId)}/members`;
381
+ const queryString = new URLSearchParams();
382
+ for (const [key, value] of Object.entries(query))
383
+ if (value !== undefined && value !== null)
384
+ queryString.set(key, String(value));
385
+ if (queryString.size)
386
+ path += "?" + queryString.toString();
387
+ return this.request("GET", path);
388
+ }
389
+ revokeProjectMember(projectId, accountId) {
390
+ let path = `/v1/projects/${encodeURIComponent(projectId)}/members/${encodeURIComponent(accountId)}`;
391
+ return this.request("DELETE", path);
392
+ }
393
+ listCustomerWebhooks() {
394
+ let path = `/v1/account/webhooks`;
395
+ return this.request("GET", path);
396
+ }
397
+ createCustomerWebhook(request) {
398
+ let path = `/v1/account/webhooks`;
399
+ return this.request("POST", path, request);
400
+ }
401
+ revokeCustomerWebhook(hookId) {
402
+ let path = `/v1/account/webhooks/${encodeURIComponent(hookId)}`;
403
+ return this.request("DELETE", path);
404
+ }
405
+ getCapacityCatalog() {
406
+ let path = `/v1/capacity/catalog`;
407
+ return this.request("GET", path);
408
+ }
409
+ getCapacityBalance(query = {}) {
410
+ let path = `/v1/capacity/balance`;
411
+ const queryString = new URLSearchParams();
412
+ for (const [key, value] of Object.entries(query))
413
+ if (value !== undefined && value !== null)
414
+ queryString.set(key, String(value));
415
+ if (queryString.size)
416
+ path += "?" + queryString.toString();
417
+ return this.request("GET", path);
418
+ }
419
+ getCapacityEntitlements(query = {}) {
420
+ let path = `/v1/capacity/entitlements`;
421
+ const queryString = new URLSearchParams();
422
+ for (const [key, value] of Object.entries(query))
423
+ if (value !== undefined && value !== null)
424
+ queryString.set(key, String(value));
425
+ if (queryString.size)
426
+ path += "?" + queryString.toString();
427
+ return this.request("GET", path);
428
+ }
429
+ getCapacityReferral() {
430
+ let path = `/v1/capacity/referral`;
431
+ return this.request("GET", path);
432
+ }
433
+ captureCapacityReferral(request) {
434
+ let path = `/v1/capacity/referral/visit`;
435
+ return this.request("POST", path, request);
436
+ }
437
+ getCapacityHistory() {
438
+ let path = `/v1/capacity/history`;
439
+ return this.request("GET", path);
440
+ }
441
+ claimFreeCapacity() {
442
+ let path = `/v1/capacity/free`;
443
+ return this.request("POST", path);
444
+ }
445
+ setCapacityBudget(request) {
446
+ let path = `/v1/capacity/budget`;
447
+ return this.request("PATCH", path, request);
448
+ }
449
+ quoteCapacityWork(request) {
450
+ let path = `/v1/capacity/quotes`;
451
+ return this.request("POST", path, request);
452
+ }
453
+ getCapacityQuote(quoteId) {
454
+ let path = `/v1/capacity/quotes/${encodeURIComponent(quoteId)}`;
455
+ return this.request("GET", path);
456
+ }
457
+ authorizeCapacityWork(request) {
458
+ let path = `/v1/capacity/executions`;
459
+ requireWorkAuthorization(request);
460
+ return this.request("POST", path, request);
461
+ }
462
+ getCapacityRequest(requestKey, query = {}) {
463
+ let path = `/v1/capacity/requests/${encodeURIComponent(requestKey)}`;
464
+ const queryString = new URLSearchParams();
465
+ for (const [key, value] of Object.entries(query))
466
+ if (value !== undefined && value !== null)
467
+ queryString.set(key, String(value));
468
+ if (queryString.size)
469
+ path += "?" + queryString.toString();
470
+ return this.request("GET", path);
471
+ }
472
+ getCapacityExecution(findId) {
473
+ let path = `/v1/capacity/executions/${encodeURIComponent(findId)}`;
474
+ return this.request("GET", path);
475
+ }
476
+ createCapacityFunding(request) {
477
+ let path = `/v1/capacity/funding`;
478
+ return this.request("POST", path, request);
479
+ }
480
+ getCapacityFunding(fundingId) {
481
+ let path = `/v1/capacity/funding/${encodeURIComponent(fundingId)}`;
482
+ return this.request("GET", path);
483
+ }
484
+ cancelCapacityFunding(fundingId) {
485
+ let path = `/v1/capacity/funding/${encodeURIComponent(fundingId)}`;
486
+ return this.request("DELETE", path);
487
+ }
488
+ getCapacityMembership() {
489
+ let path = `/v1/capacity/membership`;
490
+ return this.request("GET", path);
491
+ }
492
+ changeCapacityMembership(request) {
493
+ let path = `/v1/capacity/membership`;
494
+ return this.request("POST", path, request);
495
+ }
496
+ createCapacityAuthority(request) {
497
+ let path = `/v1/capacity/authorities`;
498
+ return this.request("POST", path, request);
499
+ }
500
+ revokeCapacityAuthority(authorityId) {
501
+ let path = `/v1/capacity/authorities/${encodeURIComponent(authorityId)}`;
502
+ return this.request("DELETE", path);
503
+ }
504
+ createCapacitySchedule(request) {
505
+ let path = `/v1/capacity/schedules`;
506
+ return this.request("POST", path, request);
507
+ }
508
+ listCapacitySchedules(query = {}) {
509
+ let path = `/v1/capacity/schedules`;
510
+ const queryString = new URLSearchParams();
511
+ for (const [key, value] of Object.entries(query))
512
+ if (value !== undefined && value !== null)
513
+ queryString.set(key, String(value));
514
+ if (queryString.size)
515
+ path += "?" + queryString.toString();
516
+ return this.request("GET", path);
517
+ }
518
+ updateCapacitySchedule(scheduleId, request) {
519
+ let path = `/v1/capacity/schedules/${encodeURIComponent(scheduleId)}`;
520
+ return this.request("PATCH", path, request);
521
+ }
522
+ listCapacityOccurrences(scheduleId, query = {}) {
523
+ let path = `/v1/capacity/schedules/${encodeURIComponent(scheduleId)}/occurrences`;
524
+ const queryString = new URLSearchParams();
525
+ for (const [key, value] of Object.entries(query))
526
+ if (value !== undefined && value !== null)
527
+ queryString.set(key, String(value));
528
+ if (queryString.size)
529
+ path += "?" + queryString.toString();
530
+ return this.request("GET", path);
531
+ }
532
+ runCapacityScheduleNow(scheduleId) {
533
+ let path = `/v1/capacity/schedules/${encodeURIComponent(scheduleId)}/run`;
534
+ return this.request("POST", path);
535
+ }
536
+ createCapacityRefundClaim(request) {
537
+ let path = `/v1/capacity/refund-claims`;
538
+ return this.request("POST", path, request);
539
+ }
540
+ listCapacityRefundClaims() {
541
+ let path = `/v1/capacity/refund-claims`;
542
+ return this.request("GET", path);
543
+ }
544
+ getCapacityRefundClaim(claimId) {
545
+ let path = `/v1/capacity/refund-claims/${encodeURIComponent(claimId)}`;
546
+ return this.request("GET", path);
547
+ }
548
+ requestCapacityCustomPlan(request) {
549
+ let path = `/v1/capacity/enterprise`;
550
+ return this.request("POST", path, request);
551
+ }
552
+ getCapacityStoreConfig() {
553
+ let path = `/v1/capacity/stores/config`;
554
+ return this.request("GET", path);
555
+ }
556
+ verifyCapacityStorePurchase(request) {
557
+ let path = `/v1/capacity/stores/purchases`;
558
+ return this.request("POST", path, request);
559
+ }
560
+ restoreCapacityStorePurchases(request) {
561
+ let path = `/v1/capacity/stores/restore`;
562
+ return this.request("POST", path, request);
563
+ }
564
+ transferCapacityStoreToCard(request) {
565
+ let path = `/v1/capacity/stores/card-transfer`;
566
+ return this.request("POST", path, request);
567
+ }
568
+ createSpecLink(specId, request) {
569
+ let path = `/v1/specs/${encodeURIComponent(specId)}/links`;
570
+ return this.request("POST", path, request);
571
+ }
572
+ getSharedSpec(token) {
573
+ let path = `/v1/shared-specs/${encodeURIComponent(token)}`;
574
+ return this.request("GET", path);
575
+ }
576
+ revokeSpecLink(specId, linkId) {
577
+ let path = `/v1/specs/${encodeURIComponent(specId)}/links/${encodeURIComponent(linkId)}/revoke`;
578
+ return this.request("POST", path);
579
+ }
580
+ workspaceResearchInput(findId) {
581
+ let path = `/v1/workspace/collections/${encodeURIComponent(findId)}/input`;
582
+ return this.request("GET", path);
583
+ }
584
+ workspaceSetScheduleDelivery(scheduleId, request) {
585
+ let path = `/v1/workspace/schedules/${encodeURIComponent(scheduleId)}/delivery`;
586
+ return this.request("PATCH", path, request);
587
+ }
588
+ workspaceListCollections(query = {}) {
589
+ let path = `/v1/workspace/collections`;
590
+ const queryString = new URLSearchParams();
591
+ for (const [key, value] of Object.entries(query))
592
+ if (value !== undefined && value !== null)
593
+ queryString.set(key, String(value));
594
+ if (queryString.size)
595
+ path += "?" + queryString.toString();
596
+ return this.request("GET", path);
597
+ }
598
+ workspaceReadCollection(collectionId) {
599
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}`;
600
+ return this.request("GET", path);
601
+ }
602
+ workspaceCombineCollections(request) {
603
+ let path = `/v1/workspace/collections/combine`;
604
+ return this.request("POST", path, request);
605
+ }
606
+ workspaceCopyCollection(collectionId, request) {
607
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/copy`;
608
+ return this.request("POST", path, request);
609
+ }
610
+ workspaceFilterCollection(collectionId, request) {
611
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/filter`;
612
+ return this.request("POST", path, request);
613
+ }
614
+ workspaceListViews(collectionId) {
615
+ let path = `/v1/workspace/views/${encodeURIComponent(collectionId)}`;
616
+ return this.request("GET", path);
617
+ }
618
+ workspaceSaveView(collectionId, request) {
619
+ let path = `/v1/workspace/views/${encodeURIComponent(collectionId)}`;
620
+ return this.request("PUT", path, request);
621
+ }
622
+ workspaceListStars() {
623
+ let path = `/v1/workspace/stars`;
624
+ return this.request("GET", path);
625
+ }
626
+ workspaceStarItem(request) {
627
+ let path = `/v1/workspace/stars`;
628
+ return this.request("PUT", path, request);
629
+ }
630
+ workspaceListNotes(query = {}) {
631
+ let path = `/v1/workspace/notes`;
632
+ const queryString = new URLSearchParams();
633
+ for (const [key, value] of Object.entries(query))
634
+ if (value !== undefined && value !== null)
635
+ queryString.set(key, String(value));
636
+ if (queryString.size)
637
+ path += "?" + queryString.toString();
638
+ return this.request("GET", path);
639
+ }
640
+ workspaceAddNote(request) {
641
+ let path = `/v1/workspace/notes`;
642
+ return this.request("POST", path, request);
643
+ }
644
+ workspaceResolveNote(noteId, request) {
645
+ let path = `/v1/workspace/notes/${encodeURIComponent(noteId)}`;
646
+ return this.request("PATCH", path, request);
647
+ }
648
+ workspaceEditNote(noteId, request) {
649
+ let path = `/v1/workspace/notes/${encodeURIComponent(noteId)}`;
650
+ return this.request("PUT", path, request);
651
+ }
652
+ workspaceDeleteNote(noteId, request) {
653
+ let path = `/v1/workspace/notes/${encodeURIComponent(noteId)}`;
654
+ return this.request("DELETE", path, request);
655
+ }
656
+ workspaceRegisterWebPushSubscription(request) {
657
+ let path = `/v1/workspace/push/subscriptions`;
658
+ return this.request("POST", path, request);
659
+ }
660
+ workspacePushCapabilities() {
661
+ let path = `/v1/workspace/push/capabilities`;
662
+ return this.request("GET", path);
663
+ }
664
+ workspaceListPushDevices() {
665
+ let path = `/v1/workspace/push/devices`;
666
+ return this.request("GET", path);
667
+ }
668
+ workspaceRegisterPushDevice(request) {
669
+ let path = `/v1/workspace/push/devices`;
670
+ return this.request("POST", path, request);
671
+ }
672
+ workspaceRevokePushDevice(deviceId) {
673
+ let path = `/v1/workspace/push/devices/${encodeURIComponent(deviceId)}`;
674
+ return this.request("DELETE", path);
675
+ }
676
+ workspaceListYourFields(collectionId) {
677
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/fields`;
678
+ return this.request("GET", path);
679
+ }
680
+ workspaceSaveYourFields(collectionId, request) {
681
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/fields`;
682
+ return this.request("PUT", path, request);
683
+ }
684
+ workspaceSetYourFieldValue(collectionId, request) {
685
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/fields/values`;
686
+ return this.request("PUT", path, request);
687
+ }
688
+ beginConnectionAuthorization(provider) {
689
+ let path = `/v1/connections/${encodeURIComponent(provider)}/authorize`;
690
+ return this.request("POST", path);
691
+ }
692
+ disconnectConnection(connectionId) {
693
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}`;
694
+ return this.request("DELETE", path);
695
+ }
696
+ listCloudImports() {
697
+ let path = `/v1/imports/cloud`;
698
+ return this.request("GET", path);
699
+ }
700
+ listConnectedTools() {
701
+ let path = `/v1/connections/catalog`;
702
+ return this.request("GET", path);
703
+ }
704
+ listConnections() {
705
+ let path = `/v1/connections`;
706
+ return this.request("GET", path);
707
+ }
708
+ listConnectionDestinations(connectionId, query = {}) {
709
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}/destinations`;
710
+ const queryString = new URLSearchParams();
711
+ for (const [key, value] of Object.entries(query))
712
+ if (value !== undefined && value !== null)
713
+ queryString.set(key, String(value));
714
+ if (queryString.size)
715
+ path += "?" + queryString.toString();
716
+ return this.request("GET", path);
717
+ }
718
+ getConnectionColumns(connectionId, request) {
719
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}/columns`;
720
+ return this.request("POST", path, request);
721
+ }
722
+ saveConnectionDestination(connectionId, request) {
723
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}/destination`;
724
+ return this.request("POST", path, request);
725
+ }
726
+ sendToDestination(connectionId, request) {
727
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}/send`;
728
+ return this.request("POST", path, request);
729
+ }
730
+ reconcileDestinationExport(connectionId, exportId) {
731
+ let path = `/v1/connections/${encodeURIComponent(connectionId)}/exports/${encodeURIComponent(exportId)}/reconcile`;
732
+ return this.request("POST", path);
733
+ }
734
+ listDestinationExports() {
735
+ let path = `/v1/connections/exports`;
736
+ return this.request("GET", path);
737
+ }
738
+ createDestinationSync(request) {
739
+ let path = `/v1/destination-syncs`;
740
+ return this.request("POST", path, request);
741
+ }
742
+ updateDestinationSync(syncId, request) {
743
+ let path = `/v1/destination-syncs/${encodeURIComponent(syncId)}`;
744
+ return this.request("PATCH", path, request);
745
+ }
746
+ listDestinationSyncs() {
747
+ let path = `/v1/destination-syncs`;
748
+ return this.request("GET", path);
749
+ }
750
+ previewCloudList(request) {
751
+ let path = `/v1/imports/cloud/preview`;
752
+ return this.request("POST", path, request);
753
+ }
754
+ importCloudList(request) {
755
+ let path = `/v1/imports/cloud`;
756
+ return this.request("POST", path, request);
757
+ }
758
+ updateCloudImport(importId, request) {
759
+ let path = `/v1/imports/cloud/${encodeURIComponent(importId)}`;
760
+ return this.request("PATCH", path, request);
761
+ }
762
+ workspaceInviteMember(request) {
763
+ let path = `/v1/workspace/invitations`;
764
+ return this.request("POST", path, request);
765
+ }
766
+ importFileCommand(request) {
767
+ let path = `/v1/imports/file`;
768
+ return this.request("POST", path, request);
769
+ }
770
+ workspaceActivity(query = {}) {
771
+ let path = `/v1/activity`;
772
+ const queryString = new URLSearchParams();
773
+ for (const [key, value] of Object.entries(query))
774
+ if (value !== undefined && value !== null)
775
+ queryString.set(key, String(value));
776
+ if (queryString.size)
777
+ path += "?" + queryString.toString();
778
+ return this.request("GET", path);
779
+ }
780
+ workspaceRelationships(collectionId, query = {}) {
781
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/relationships`;
782
+ const queryString = new URLSearchParams();
783
+ for (const [key, value] of Object.entries(query))
784
+ if (value !== undefined && value !== null)
785
+ queryString.set(key, String(value));
786
+ if (queryString.size)
787
+ path += "?" + queryString.toString();
788
+ return this.request("GET", path);
789
+ }
790
+ workspaceSaveRelationships(collectionId, request) {
791
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/relationships`;
792
+ return this.request("PUT", path, request);
793
+ }
794
+ workspaceReportResult(collectionId, request) {
795
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/reports`;
796
+ return this.request("POST", path, request);
797
+ }
798
+ listRequestTemplates(query = {}) {
799
+ let path = `/v1/request-templates`;
800
+ const queryString = new URLSearchParams();
801
+ for (const [key, value] of Object.entries(query))
802
+ if (value !== undefined && value !== null)
803
+ queryString.set(key, String(value));
804
+ if (queryString.size)
805
+ path += "?" + queryString.toString();
806
+ return this.request("GET", path);
807
+ }
808
+ workspaceCollectionChanges(collectionId) {
809
+ let path = `/v1/workspace/collections/${encodeURIComponent(collectionId)}/changes`;
810
+ return this.request("GET", path);
811
+ }
812
+ workspaceListPasskeys() {
813
+ let path = `/v1/workspace/security/passkeys`;
814
+ return this.request("GET", path);
815
+ }
816
+ workspaceRegisterPasskeyOptions() {
817
+ let path = `/v1/workspace/security/passkeys/options`;
818
+ return this.request("POST", path);
819
+ }
820
+ workspaceRegisterPasskey(request) {
821
+ let path = `/v1/workspace/security/passkeys`;
822
+ return this.request("POST", path, request);
823
+ }
824
+ workspaceNamePasskey(credentialId, request) {
825
+ let path = `/v1/workspace/security/passkeys/${encodeURIComponent(credentialId)}`;
826
+ return this.request("PATCH", path, request);
827
+ }
828
+ workspaceDeletePasskey(credentialId) {
829
+ let path = `/v1/workspace/security/passkeys/${encodeURIComponent(credentialId)}`;
830
+ return this.request("DELETE", path);
831
+ }
832
+ workspacePasskeySignInOptions() {
833
+ let path = `/v1/workspace/auth/passkey/options`;
834
+ return this.request("POST", path);
835
+ }
836
+ workspacePasskeySignIn(request) {
837
+ let path = `/v1/workspace/auth/passkey/verify`;
838
+ return this.request("POST", path, request);
839
+ }
840
+ workspaceListSSODomains() {
841
+ let path = `/v1/workspace/security/sso`;
842
+ return this.request("GET", path);
843
+ }
844
+ workspaceAddSSODomain(request) {
845
+ let path = `/v1/workspace/security/sso`;
846
+ return this.request("POST", path, request);
847
+ }
848
+ workspaceVerifySSODomain(domainId) {
849
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/verify`;
850
+ return this.request("POST", path);
851
+ }
852
+ workspaceConfigureSSO(domainId, request) {
853
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/provider`;
854
+ return this.request("PUT", path, request);
855
+ }
856
+ workspaceSetSSOPolicy(domainId, request) {
857
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}`;
858
+ return this.request("PATCH", path, request);
859
+ }
860
+ workspaceStartSSO(request) {
861
+ let path = `/v1/workspace/auth/sso/start`;
862
+ return this.request("POST", path, request);
863
+ }
864
+ workspaceRotateSCIMToken(domainId) {
865
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/scim/token`;
866
+ return this.request("POST", path);
867
+ }
868
+ workspaceRevokeSCIMToken(domainId) {
869
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/scim/token`;
870
+ return this.request("DELETE", path);
871
+ }
872
+ workspaceReadSCIMMappings(domainId) {
873
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/scim/mappings`;
874
+ return this.request("GET", path);
875
+ }
876
+ workspaceSetSCIMMappings(domainId, request) {
877
+ let path = `/v1/workspace/security/sso/${encodeURIComponent(domainId)}/scim/mappings`;
878
+ return this.request("PUT", path, request);
879
+ }
880
+ workspaceReadPhoto() {
881
+ let path = `/v1/workspace/profile/photo`;
882
+ return this.request("GET", path);
883
+ }
884
+ workspaceDeletePhoto() {
885
+ let path = `/v1/workspace/profile/photo`;
886
+ return this.request("DELETE", path);
887
+ }
888
+ workspaceStartNativeProvider(request) {
889
+ let path = `/v1/workspace/auth/native/start`;
890
+ return this.request("POST", path, request);
891
+ }
892
+ workspaceRedeemNativeProvider(request) {
893
+ let path = `/v1/workspace/auth/native/redeem`;
894
+ return this.request("POST", path, request);
895
+ }
896
+ workspacePlacementAllowance() {
897
+ let path = `/v1/workspace/placement/allowance`;
898
+ return this.request("GET", path);
899
+ }
900
+ workspaceQuotePlacement(importId) {
901
+ let path = `/v1/workspace/imports/${encodeURIComponent(importId)}/placement/quote`;
902
+ return this.request("POST", path);
903
+ }
904
+ workspaceStartPlacement(importId, request) {
905
+ let path = `/v1/workspace/imports/${encodeURIComponent(importId)}/placement`;
906
+ return this.request("POST", path, request);
907
+ }
908
+ workspacePlacementStatus(importId, placementId) {
909
+ let path = `/v1/workspace/imports/${encodeURIComponent(importId)}/placement/${encodeURIComponent(placementId)}`;
910
+ return this.request("GET", path);
911
+ }
912
+ teachWebSource(request) {
913
+ let path = `/v1/imports/web/sources`;
914
+ return this.request("POST", path, request);
915
+ }
916
+ listWebSources() {
917
+ let path = `/v1/imports/web/sources`;
918
+ return this.request("GET", path);
919
+ }
920
+ getWebSource(sourceId) {
921
+ let path = `/v1/imports/web/sources/${encodeURIComponent(sourceId)}`;
922
+ return this.request("GET", path);
923
+ }
924
+ previewWebSource(sourceId) {
925
+ let path = `/v1/imports/web/sources/${encodeURIComponent(sourceId)}/previews`;
926
+ return this.request("POST", path);
927
+ }
928
+ getWebSourcePreview(previewId) {
929
+ let path = `/v1/imports/web/previews/${encodeURIComponent(previewId)}`;
930
+ return this.request("GET", path);
931
+ }
932
+ saveWebSourceList(request) {
933
+ let path = `/v1/imports/web/lists`;
934
+ return this.request("POST", path, request);
935
+ }
936
+ getReconciliationFields(collectionId) {
937
+ let path = `/v1/reconciliation/collections/${encodeURIComponent(collectionId)}/fields`;
938
+ return this.request("GET", path);
939
+ }
940
+ listReconciliations(collectionId) {
941
+ let path = `/v1/reconciliation/collections/${encodeURIComponent(collectionId)}/comparisons`;
942
+ return this.request("GET", path);
943
+ }
944
+ prepareReconciliation(request) {
945
+ let path = `/v1/reconciliation/comparisons`;
946
+ return this.request("POST", path, request);
947
+ }
948
+ getReconciliation(comparisonId) {
949
+ let path = `/v1/reconciliation/comparisons/${encodeURIComponent(comparisonId)}`;
950
+ return this.request("GET", path);
951
+ }
952
+ applyReconciliation(comparisonId, request) {
953
+ let path = `/v1/reconciliation/comparisons/${encodeURIComponent(comparisonId)}/apply`;
954
+ return this.request("POST", path, request);
955
+ }
956
+ getReconciledInput(importId) {
957
+ let path = `/v1/reconciliation/imports/${encodeURIComponent(importId)}`;
958
+ return this.request("GET", path);
959
+ }
960
+ // END GENERATED LIFECYCLE
961
+ headers() {
962
+ const token = this.apiKey.toLowerCase().startsWith("bearer ")
963
+ ? this.apiKey
964
+ : `Bearer ${this.apiKey}`;
965
+ return {
966
+ Authorization: token,
967
+ Accept: "application/json",
968
+ "Content-Type": "application/json",
969
+ "User-Agent": "specstream-typescript/1.1.0",
970
+ };
971
+ }
972
+ async request(method, path, body) {
973
+ const url = this.baseUrl + path;
974
+ let response;
975
+ let text;
976
+ try {
977
+ response = await this.fetchFn(url, {
978
+ method,
979
+ headers: this.headers(),
980
+ redirect: "error",
981
+ signal: AbortSignal.timeout(this.timeoutMs),
982
+ body: body === undefined ? undefined : JSON.stringify(body),
983
+ });
984
+ text = await response.text();
985
+ }
986
+ catch (error) {
987
+ throw new SpecstreamError(method + " " + path + " transport failed", null, error);
988
+ }
989
+ let parsed;
990
+ try {
991
+ parsed = JSON.parse(text);
992
+ }
993
+ catch {
994
+ throw new SpecstreamError(method + " " + path + " returned invalid JSON", response.status, text);
995
+ }
996
+ if (!response.ok) {
997
+ throw new SpecstreamError(method + " " + path + " failed with HTTP " + response.status, response.status, parsed);
998
+ }
999
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1000
+ throw new SpecstreamError(method + " " + path + " returned non-object JSON", response.status, parsed);
1001
+ }
1002
+ const envelope = parsed;
1003
+ if (envelope.error != null || !envelope.data || typeof envelope.data !== "object" || Array.isArray(envelope.data)) {
1004
+ throw new SpecstreamError(method + " " + path + " returned an invalid success envelope", response.status, parsed);
1005
+ }
1006
+ return envelope.data;
1007
+ }
1008
+ }
1009
+ export default Client;