@stackfactor/client-api 1.1.252 → 1.1.253

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.
@@ -0,0 +1,855 @@
1
+ import { client } from "./axiosClient.js";
2
+ // ── Knowledge Base CRUD ───────────────────────────────────────────────────────
3
+ /**
4
+ * List the knowledge bases the caller can see.
5
+ * GET /api/v1/knowledge-base
6
+ * @param {String} authToken Authentication token
7
+ * @returns {Promise<object>}
8
+ */
9
+ export const listKnowledgeBases = (authToken) => {
10
+ return new Promise((resolve, reject) => {
11
+ const request = client.get(`/api/v1/knowledge-base`, {
12
+ headers: { authorization: authToken },
13
+ });
14
+ request
15
+ .then((response) => {
16
+ resolve(response.data);
17
+ })
18
+ .catch((error) => {
19
+ reject(error);
20
+ });
21
+ });
22
+ };
23
+ /**
24
+ * Create a knowledge base (the creator becomes owner automatically). Requires the
25
+ * global CREATE_KNOWLEDGE_BASE capability.
26
+ * POST /api/v1/knowledge-base
27
+ * @param {KnowledgeBaseInput} data KB metadata (at minimum `name`)
28
+ * @param {String} authToken Authentication token
29
+ * @returns {Promise<object>}
30
+ */
31
+ export const createKnowledgeBase = (data, authToken) => {
32
+ return new Promise((resolve, reject) => {
33
+ const request = client.post(`/api/v1/knowledge-base`, data, {
34
+ headers: { authorization: authToken },
35
+ });
36
+ request
37
+ .then((response) => {
38
+ resolve(response.data);
39
+ })
40
+ .catch((error) => {
41
+ reject(error);
42
+ });
43
+ });
44
+ };
45
+ /**
46
+ * Get a single knowledge base (plus stats).
47
+ * GET /api/v1/knowledge-base/:id
48
+ * @param {String} id The knowledge base id
49
+ * @param {String} authToken Authentication token
50
+ * @returns {Promise<object>}
51
+ */
52
+ export const getKnowledgeBase = (id, authToken) => {
53
+ return new Promise((resolve, reject) => {
54
+ const request = client.get(`/api/v1/knowledge-base/${id}`, {
55
+ headers: { authorization: authToken },
56
+ });
57
+ request
58
+ .then((response) => {
59
+ resolve(response.data);
60
+ })
61
+ .catch((error) => {
62
+ reject(error);
63
+ });
64
+ });
65
+ };
66
+ /**
67
+ * Update a knowledge base's metadata. Owner or editor only. Does not touch
68
+ * `access[]`, `sources`, or `createdBy` — those have their own gated flows.
69
+ * PUT /api/v1/knowledge-base/:id
70
+ * @param {String} id The knowledge base id
71
+ * @param {KnowledgeBaseInput} data The fields to update
72
+ * @param {String} authToken Authentication token
73
+ * @returns {Promise<object>}
74
+ */
75
+ export const updateKnowledgeBase = (id, data, authToken) => {
76
+ return new Promise((resolve, reject) => {
77
+ const request = client.put(`/api/v1/knowledge-base/${id}`, data, {
78
+ headers: { authorization: authToken },
79
+ });
80
+ request
81
+ .then((response) => {
82
+ resolve(response.data);
83
+ })
84
+ .catch((error) => {
85
+ reject(error);
86
+ });
87
+ });
88
+ };
89
+ /**
90
+ * Delete a knowledge base (cascades to its chunks). Owner only.
91
+ * DELETE /api/v1/knowledge-base/:id
92
+ * @param {String} id The knowledge base id
93
+ * @param {String} authToken Authentication token
94
+ * @returns {Promise<object>}
95
+ */
96
+ export const deleteKnowledgeBase = (id, authToken) => {
97
+ return new Promise((resolve, reject) => {
98
+ const request = client.delete(`/api/v1/knowledge-base/${id}`, {
99
+ headers: { authorization: authToken },
100
+ });
101
+ request
102
+ .then((response) => {
103
+ resolve(response.data);
104
+ })
105
+ .catch((error) => {
106
+ reject(error);
107
+ });
108
+ });
109
+ };
110
+ // ── Source Management ─────────────────────────────────────────────────────────
111
+ /**
112
+ * List the available KB_SOURCE_CONNECTOR integrations (enabled integrations +
113
+ * capability manifests for the source-creation form).
114
+ * GET /api/v1/knowledge-base/source-connectors
115
+ * @param {String} authToken Authentication token
116
+ * @returns {Promise<object>}
117
+ */
118
+ export const listSourceConnectors = (authToken) => {
119
+ return new Promise((resolve, reject) => {
120
+ const request = client.get(`/api/v1/knowledge-base/source-connectors`, {
121
+ headers: { authorization: authToken },
122
+ });
123
+ request
124
+ .then((response) => {
125
+ resolve(response.data);
126
+ })
127
+ .catch((error) => {
128
+ reject(error);
129
+ });
130
+ });
131
+ };
132
+ /**
133
+ * Add a source to a knowledge base (`integrationId` + credentials +
134
+ * `syncFrequencyDays`, default 7). Publishes a kb-source-event (changeType="add").
135
+ * POST /api/v1/knowledge-base/:id/sources
136
+ * @param {String} id The knowledge base id
137
+ * @param {object} source The source configuration
138
+ * @param {String} authToken Authentication token
139
+ * @returns {Promise<object>}
140
+ */
141
+ export const addSource = (id, source, authToken) => {
142
+ return new Promise((resolve, reject) => {
143
+ const request = client.post(`/api/v1/knowledge-base/${id}/sources`, source, { headers: { authorization: authToken } });
144
+ request
145
+ .then((response) => {
146
+ resolve(response.data);
147
+ })
148
+ .catch((error) => {
149
+ reject(error);
150
+ });
151
+ });
152
+ };
153
+ /**
154
+ * Update a knowledge base source. Publishes a kb-source-event per changed source.
155
+ * PUT /api/v1/knowledge-base/:id/sources/:sourceId
156
+ * @param {String} id The knowledge base id
157
+ * @param {String} sourceId The source id
158
+ * @param {object} source The updated source configuration
159
+ * @param {String} authToken Authentication token
160
+ * @returns {Promise<object>}
161
+ */
162
+ export const updateSource = (id, sourceId, source, authToken) => {
163
+ return new Promise((resolve, reject) => {
164
+ const request = client.put(`/api/v1/knowledge-base/${id}/sources/${sourceId}`, source, { headers: { authorization: authToken } });
165
+ request
166
+ .then((response) => {
167
+ resolve(response.data);
168
+ })
169
+ .catch((error) => {
170
+ reject(error);
171
+ });
172
+ });
173
+ };
174
+ /**
175
+ * Remove a source from a knowledge base. Publishes a kb-source-event
176
+ * (changeType="delete").
177
+ * DELETE /api/v1/knowledge-base/:id/sources/:sourceId
178
+ * @param {String} id The knowledge base id
179
+ * @param {String} sourceId The source id
180
+ * @param {String} authToken Authentication token
181
+ * @returns {Promise<object>}
182
+ */
183
+ export const deleteSource = (id, sourceId, authToken) => {
184
+ return new Promise((resolve, reject) => {
185
+ const request = client.delete(`/api/v1/knowledge-base/${id}/sources/${sourceId}`, { headers: { authorization: authToken } });
186
+ request
187
+ .then((response) => {
188
+ resolve(response.data);
189
+ })
190
+ .catch((error) => {
191
+ reject(error);
192
+ });
193
+ });
194
+ };
195
+ /**
196
+ * Trigger a manual re-sync of a source. Publishes a kb-source-event
197
+ * (changeType="update", trigger="manual_sync").
198
+ * POST /api/v1/knowledge-base/:id/sources/:sourceId/sync
199
+ * @param {String} id The knowledge base id
200
+ * @param {String} sourceId The source id
201
+ * @param {String} authToken Authentication token
202
+ * @returns {Promise<object>}
203
+ */
204
+ export const syncSource = (id, sourceId, authToken) => {
205
+ return new Promise((resolve, reject) => {
206
+ const request = client.post(`/api/v1/knowledge-base/${id}/sources/${sourceId}/sync`, {}, { headers: { authorization: authToken } });
207
+ request
208
+ .then((response) => {
209
+ resolve(response.data);
210
+ })
211
+ .catch((error) => {
212
+ reject(error);
213
+ });
214
+ });
215
+ };
216
+ /**
217
+ * Test a source's connector credentials (dispatches TEST_CONNECTION).
218
+ * POST /api/v1/knowledge-base/:id/sources/:sourceId/test
219
+ * @param {String} id The knowledge base id
220
+ * @param {String} sourceId The source id
221
+ * @param {String} authToken Authentication token
222
+ * @returns {Promise<object>}
223
+ */
224
+ export const testSource = (id, sourceId, authToken) => {
225
+ return new Promise((resolve, reject) => {
226
+ const request = client.post(`/api/v1/knowledge-base/${id}/sources/${sourceId}/test`, {}, { headers: { authorization: authToken } });
227
+ request
228
+ .then((response) => {
229
+ resolve(response.data);
230
+ })
231
+ .catch((error) => {
232
+ reject(error);
233
+ });
234
+ });
235
+ };
236
+ // ── Document Management ───────────────────────────────────────────────────────
237
+ /**
238
+ * List a knowledge base's documents (paginated, with status + lastSync). There is
239
+ * no upload endpoint — documents are only ingested via configured sources.
240
+ * GET /api/v1/knowledge-base/:id/documents
241
+ * @param {String} id The knowledge base id
242
+ * @param {DocumentListParams} params Optional pagination / status filters
243
+ * @param {String} authToken Authentication token
244
+ * @returns {Promise<object>}
245
+ */
246
+ export const listDocuments = (id, params, authToken) => {
247
+ return new Promise((resolve, reject) => {
248
+ const request = client.get(`/api/v1/knowledge-base/${id}/documents`, {
249
+ headers: { authorization: authToken },
250
+ params: params,
251
+ });
252
+ request
253
+ .then((response) => {
254
+ resolve(response.data);
255
+ })
256
+ .catch((error) => {
257
+ reject(error);
258
+ });
259
+ });
260
+ };
261
+ /**
262
+ * Delete a single document (cascades to chunks + S3 images + dependent entity
263
+ * flags).
264
+ * DELETE /api/v1/knowledge-base/:id/documents/:docId
265
+ * @param {String} id The knowledge base id
266
+ * @param {String} docId The document id
267
+ * @param {String} authToken Authentication token
268
+ * @returns {Promise<object>}
269
+ */
270
+ export const deleteDocument = (id, docId, authToken) => {
271
+ return new Promise((resolve, reject) => {
272
+ const request = client.delete(`/api/v1/knowledge-base/${id}/documents/${docId}`, { headers: { authorization: authToken } });
273
+ request
274
+ .then((response) => {
275
+ resolve(response.data);
276
+ })
277
+ .catch((error) => {
278
+ reject(error);
279
+ });
280
+ });
281
+ };
282
+ // ── KB Access Management (owner only) ─────────────────────────────────────────
283
+ /**
284
+ * List a knowledge base's access entries.
285
+ * GET /api/v1/knowledge-base/:id/access
286
+ * @param {String} id The knowledge base id
287
+ * @param {String} authToken Authentication token
288
+ * @returns {Promise<object>}
289
+ */
290
+ export const listAccess = (id, authToken) => {
291
+ return new Promise((resolve, reject) => {
292
+ const request = client.get(`/api/v1/knowledge-base/${id}/access`, {
293
+ headers: { authorization: authToken },
294
+ });
295
+ request
296
+ .then((response) => {
297
+ resolve(response.data);
298
+ })
299
+ .catch((error) => {
300
+ reject(error);
301
+ });
302
+ });
303
+ };
304
+ /**
305
+ * Grant (upsert) an access entry. Owner only. Access is keyed by
306
+ * `(subjectType, subjectId)`, so re-granting a subject that already has an entry
307
+ * updates its role — there is no separate "update role" endpoint.
308
+ * POST /api/v1/knowledge-base/:id/access
309
+ * @param {String} id The knowledge base id
310
+ * @param {AccessEntryInput} entry The `{ subjectType, subjectId, role }` grant
311
+ * @param {String} authToken Authentication token
312
+ * @returns {Promise<object>}
313
+ */
314
+ export const grantAccess = (id, entry, authToken) => {
315
+ return new Promise((resolve, reject) => {
316
+ const request = client.post(`/api/v1/knowledge-base/${id}/access`, entry, {
317
+ headers: { authorization: authToken },
318
+ });
319
+ request
320
+ .then((response) => {
321
+ resolve(response.data);
322
+ })
323
+ .catch((error) => {
324
+ reject(error);
325
+ });
326
+ });
327
+ };
328
+ /**
329
+ * Revoke a subject's access. Owner only. Keyed by `(subjectType, subjectId)` — the
330
+ * same composite key `grantAccess` upserts on. The backend refuses to remove the
331
+ * last owner.
332
+ * DELETE /api/v1/knowledge-base/:id/access
333
+ * @param {String} id The knowledge base id
334
+ * @param {String} subjectType One of `KNOWLEDGE_BASE.SUBJECT_TYPE`
335
+ * @param {String} subjectId The subject whose access is revoked
336
+ * @param {String} authToken Authentication token
337
+ * @returns {Promise<object>}
338
+ */
339
+ export const revokeAccess = (id, subjectType, subjectId, authToken) => {
340
+ return new Promise((resolve, reject) => {
341
+ const request = client.delete(`/api/v1/knowledge-base/${id}/access`, {
342
+ headers: { authorization: authToken },
343
+ data: { subjectType: subjectType, subjectId: subjectId },
344
+ });
345
+ request
346
+ .then((response) => {
347
+ resolve(response.data);
348
+ })
349
+ .catch((error) => {
350
+ reject(error);
351
+ });
352
+ });
353
+ };
354
+ // ── Compliance + Redaction Configuration ──────────────────────────────────────
355
+ /**
356
+ * Read a knowledge base's redaction policy.
357
+ * GET /api/v1/knowledge-base/:id/redaction-policy
358
+ * @param {String} id The knowledge base id
359
+ * @param {String} authToken Authentication token
360
+ * @returns {Promise<object>}
361
+ */
362
+ export const getRedactionPolicy = (id, authToken) => {
363
+ return new Promise((resolve, reject) => {
364
+ const request = client.get(`/api/v1/knowledge-base/${id}/redaction-policy`, { headers: { authorization: authToken } });
365
+ request
366
+ .then((response) => {
367
+ resolve(response.data);
368
+ })
369
+ .catch((error) => {
370
+ reject(error);
371
+ });
372
+ });
373
+ };
374
+ /**
375
+ * Set a knowledge base's per-KB redaction behavior + DLP provider.
376
+ * PUT /api/v1/knowledge-base/:id/redaction-policy
377
+ * @param {String} id The knowledge base id
378
+ * @param {object} policy The redaction policy
379
+ * @param {String} authToken Authentication token
380
+ * @returns {Promise<object>}
381
+ */
382
+ export const updateRedactionPolicy = (id, policy, authToken) => {
383
+ return new Promise((resolve, reject) => {
384
+ const request = client.put(`/api/v1/knowledge-base/${id}/redaction-policy`, policy, { headers: { authorization: authToken } });
385
+ request
386
+ .then((response) => {
387
+ resolve(response.data);
388
+ })
389
+ .catch((error) => {
390
+ reject(error);
391
+ });
392
+ });
393
+ };
394
+ /**
395
+ * Read the tenant's compliance profile (admin only). Governs which RAG processors
396
+ * a KB may route to (e.g. HIPAA tenants → BAA-eligible processors only).
397
+ * GET /api/v1/tenant/compliance-profile
398
+ * @param {String} authToken Authentication token
399
+ * @returns {Promise<object>}
400
+ */
401
+ export const getComplianceProfile = (authToken) => {
402
+ return new Promise((resolve, reject) => {
403
+ const request = client.get(`/api/v1/tenant/compliance-profile`, {
404
+ headers: { authorization: authToken },
405
+ });
406
+ request
407
+ .then((response) => {
408
+ resolve(response.data);
409
+ })
410
+ .catch((error) => {
411
+ reject(error);
412
+ });
413
+ });
414
+ };
415
+ /**
416
+ * Update the tenant's compliance profile (admin only; not exposed via the KB UI).
417
+ * PUT /api/v1/tenant/compliance-profile
418
+ * @param {object} profile The compliance profile
419
+ * @param {String} authToken Authentication token
420
+ * @returns {Promise<object>}
421
+ */
422
+ export const updateComplianceProfile = (profile, authToken) => {
423
+ return new Promise((resolve, reject) => {
424
+ const request = client.put(`/api/v1/tenant/compliance-profile`, profile, { headers: { authorization: authToken } });
425
+ request
426
+ .then((response) => {
427
+ resolve(response.data);
428
+ })
429
+ .catch((error) => {
430
+ reject(error);
431
+ });
432
+ });
433
+ };
434
+ /**
435
+ * Trigger a GDPR subject-purge ("right to be forgotten"; admin only).
436
+ * POST /api/v1/compliance/right-to-be-forgotten
437
+ * @param {object} data The subject-purge request
438
+ * @param {String} authToken Authentication token
439
+ * @returns {Promise<object>}
440
+ */
441
+ export const rightToBeForgotten = (data, authToken) => {
442
+ return new Promise((resolve, reject) => {
443
+ const request = client.post(`/api/v1/compliance/right-to-be-forgotten`, data, { headers: { authorization: authToken } });
444
+ request
445
+ .then((response) => {
446
+ resolve(response.data);
447
+ })
448
+ .catch((error) => {
449
+ reject(error);
450
+ });
451
+ });
452
+ };
453
+ // ── Review Center — overview ──────────────────────────────────────────────────
454
+ /**
455
+ * Overview of all Review Center streams + counts for a knowledge base.
456
+ * GET /api/v1/knowledge-base/:id/review
457
+ * @param {String} id The knowledge base id
458
+ * @param {String} authToken Authentication token
459
+ * @returns {Promise<object>}
460
+ */
461
+ export const getReviewOverview = (id, authToken) => {
462
+ return new Promise((resolve, reject) => {
463
+ const request = client.get(`/api/v1/knowledge-base/${id}/review`, {
464
+ headers: { authorization: authToken },
465
+ });
466
+ request
467
+ .then((response) => {
468
+ resolve(response.data);
469
+ })
470
+ .catch((error) => {
471
+ reject(error);
472
+ });
473
+ });
474
+ };
475
+ // ── Review Center — Stream 1: Quarantine release ──────────────────────────────
476
+ /**
477
+ * List QUARANTINED documents (Review Center stream 1).
478
+ * GET /api/v1/knowledge-base/:id/review/quarantine
479
+ * @param {String} id The knowledge base id
480
+ * @param {String} authToken Authentication token
481
+ * @returns {Promise<object>}
482
+ */
483
+ export const listQuarantine = (id, authToken) => {
484
+ return new Promise((resolve, reject) => {
485
+ const request = client.get(`/api/v1/knowledge-base/${id}/review/quarantine`, { headers: { authorization: authToken } });
486
+ request
487
+ .then((response) => {
488
+ resolve(response.data);
489
+ })
490
+ .catch((error) => {
491
+ reject(error);
492
+ });
493
+ });
494
+ };
495
+ /**
496
+ * Release a quarantined document. Requires RELEASE_QUARANTINE + owner|editor.
497
+ * POST /api/v1/knowledge-base/:id/review/quarantine/:docId/release
498
+ * @param {String} id The knowledge base id
499
+ * @param {String} docId The document id
500
+ * @param {String} authToken Authentication token
501
+ * @returns {Promise<object>}
502
+ */
503
+ export const releaseQuarantine = (id, docId, authToken) => {
504
+ return new Promise((resolve, reject) => {
505
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/quarantine/${docId}/release`, {}, { headers: { authorization: authToken } });
506
+ request
507
+ .then((response) => {
508
+ resolve(response.data);
509
+ })
510
+ .catch((error) => {
511
+ reject(error);
512
+ });
513
+ });
514
+ };
515
+ /**
516
+ * Re-ingest a quarantined document (optionally with an updated redaction policy).
517
+ * Publishes a kb-source-event (trigger="quarantine_re_ingest"). Requires
518
+ * RELEASE_QUARANTINE + owner.
519
+ * POST /api/v1/knowledge-base/:id/review/quarantine/:docId/re-ingest
520
+ * @param {String} id The knowledge base id
521
+ * @param {String} docId The document id
522
+ * @param {object} data Optional body, e.g. `{ updatedRedactionPolicy }`
523
+ * @param {String} authToken Authentication token
524
+ * @returns {Promise<object>}
525
+ */
526
+ export const reingestQuarantine = (id, docId, data, authToken) => {
527
+ return new Promise((resolve, reject) => {
528
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/quarantine/${docId}/re-ingest`, data, { headers: { authorization: authToken } });
529
+ request
530
+ .then((response) => {
531
+ resolve(response.data);
532
+ })
533
+ .catch((error) => {
534
+ reject(error);
535
+ });
536
+ });
537
+ };
538
+ /**
539
+ * Delete a quarantined document. Requires RELEASE_QUARANTINE + owner.
540
+ * POST /api/v1/knowledge-base/:id/review/quarantine/:docId/delete
541
+ * @param {String} id The knowledge base id
542
+ * @param {String} docId The document id
543
+ * @param {String} authToken Authentication token
544
+ * @returns {Promise<object>}
545
+ */
546
+ export const deleteQuarantine = (id, docId, authToken) => {
547
+ return new Promise((resolve, reject) => {
548
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/quarantine/${docId}/delete`, {}, { headers: { authorization: authToken } });
549
+ request
550
+ .then((response) => {
551
+ resolve(response.data);
552
+ })
553
+ .catch((error) => {
554
+ reject(error);
555
+ });
556
+ });
557
+ };
558
+ // ── Review Center — Stream 2: Generated content review ────────────────────────
559
+ /**
560
+ * List generated artifacts awaiting review (needsReview=true).
561
+ * Requires GENERATE_FROM_KB + owner|editor.
562
+ * GET /api/v1/knowledge-base/:id/review/generated
563
+ * @param {String} id The knowledge base id
564
+ * @param {String} authToken Authentication token
565
+ * @returns {Promise<object>}
566
+ */
567
+ export const listGeneratedReview = (id, authToken) => {
568
+ return new Promise((resolve, reject) => {
569
+ const request = client.get(`/api/v1/knowledge-base/${id}/review/generated`, { headers: { authorization: authToken } });
570
+ request
571
+ .then((response) => {
572
+ resolve(response.data);
573
+ })
574
+ .catch((error) => {
575
+ reject(error);
576
+ });
577
+ });
578
+ };
579
+ /**
580
+ * Approve a generated artifact. Requires GENERATE_FROM_KB + owner|editor.
581
+ * POST /api/v1/knowledge-base/:id/review/generated/:entityId/approve
582
+ * @param {String} id The knowledge base id
583
+ * @param {String} entityId The artifact/entity id
584
+ * @param {object} data Body `{ entityType, notes? }`
585
+ * @param {String} authToken Authentication token
586
+ * @returns {Promise<object>}
587
+ */
588
+ export const approveGenerated = (id, entityId, data, authToken) => {
589
+ return new Promise((resolve, reject) => {
590
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/generated/${entityId}/approve`, data, { headers: { authorization: authToken } });
591
+ request
592
+ .then((response) => {
593
+ resolve(response.data);
594
+ })
595
+ .catch((error) => {
596
+ reject(error);
597
+ });
598
+ });
599
+ };
600
+ /**
601
+ * Approve a generated artifact with edits.
602
+ * Requires GENERATE_FROM_KB + owner|editor.
603
+ * POST /api/v1/knowledge-base/:id/review/generated/:entityId/edit-approve
604
+ * @param {String} id The knowledge base id
605
+ * @param {String} entityId The artifact/entity id
606
+ * @param {object} data Body `{ entityType, edits, notes? }`
607
+ * @param {String} authToken Authentication token
608
+ * @returns {Promise<object>}
609
+ */
610
+ export const editApproveGenerated = (id, entityId, data, authToken) => {
611
+ return new Promise((resolve, reject) => {
612
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/generated/${entityId}/edit-approve`, data, { headers: { authorization: authToken } });
613
+ request
614
+ .then((response) => {
615
+ resolve(response.data);
616
+ })
617
+ .catch((error) => {
618
+ reject(error);
619
+ });
620
+ });
621
+ };
622
+ /**
623
+ * Reject a generated artifact. Requires GENERATE_FROM_KB + owner|editor.
624
+ * POST /api/v1/knowledge-base/:id/review/generated/:entityId/reject
625
+ * @param {String} id The knowledge base id
626
+ * @param {String} entityId The artifact/entity id
627
+ * @param {object} data Body `{ entityType, reason }`
628
+ * @param {String} authToken Authentication token
629
+ * @returns {Promise<object>}
630
+ */
631
+ export const rejectGenerated = (id, entityId, data, authToken) => {
632
+ return new Promise((resolve, reject) => {
633
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/generated/${entityId}/reject`, data, { headers: { authorization: authToken } });
634
+ request
635
+ .then((response) => {
636
+ resolve(response.data);
637
+ })
638
+ .catch((error) => {
639
+ reject(error);
640
+ });
641
+ });
642
+ };
643
+ /**
644
+ * Regenerate a generated artifact using current chunks.
645
+ * Requires GENERATE_FROM_KB + owner|editor.
646
+ * POST /api/v1/knowledge-base/:id/review/generated/:entityId/regenerate
647
+ * @param {String} id The knowledge base id
648
+ * @param {String} entityId The artifact/entity id
649
+ * @param {object} data Body `{ entityType, regenerationHints? }`
650
+ * @param {String} authToken Authentication token
651
+ * @returns {Promise<object>}
652
+ */
653
+ export const regenerateGenerated = (id, entityId, data, authToken) => {
654
+ return new Promise((resolve, reject) => {
655
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/generated/${entityId}/regenerate`, data, { headers: { authorization: authToken } });
656
+ request
657
+ .then((response) => {
658
+ resolve(response.data);
659
+ })
660
+ .catch((error) => {
661
+ reject(error);
662
+ });
663
+ });
664
+ };
665
+ // ── Review Center — Stream 3: Contradiction flags ─────────────────────────────
666
+ /**
667
+ * List chunks with non-empty contradictionFlags[].
668
+ * Requires GENERATE_FROM_KB + owner|editor.
669
+ * GET /api/v1/knowledge-base/:id/review/contradictions
670
+ * @param {String} id The knowledge base id
671
+ * @param {String} authToken Authentication token
672
+ * @returns {Promise<object>}
673
+ */
674
+ export const listContradictions = (id, authToken) => {
675
+ return new Promise((resolve, reject) => {
676
+ const request = client.get(`/api/v1/knowledge-base/${id}/review/contradictions`, { headers: { authorization: authToken } });
677
+ request
678
+ .then((response) => {
679
+ resolve(response.data);
680
+ })
681
+ .catch((error) => {
682
+ reject(error);
683
+ });
684
+ });
685
+ };
686
+ /**
687
+ * Decide a contradiction between two chunks.
688
+ * Requires GENERATE_FROM_KB + owner|editor.
689
+ * POST /api/v1/knowledge-base/:id/review/contradictions/:chunkId/decide
690
+ * @param {String} id The knowledge base id
691
+ * @param {String} chunkId The chunk id carrying the contradiction flag
692
+ * @param {object} data Body `{ decision, otherChunkId, notes }` — `decision` is one
693
+ * of `KNOWLEDGE_BASE.CONTRADICTION_DECISION`
694
+ * @param {String} authToken Authentication token
695
+ * @returns {Promise<object>}
696
+ */
697
+ export const decideContradiction = (id, chunkId, data, authToken) => {
698
+ return new Promise((resolve, reject) => {
699
+ const request = client.post(`/api/v1/knowledge-base/${id}/review/contradictions/${chunkId}/decide`, data, { headers: { authorization: authToken } });
700
+ request
701
+ .then((response) => {
702
+ resolve(response.data);
703
+ })
704
+ .catch((error) => {
705
+ reject(error);
706
+ });
707
+ });
708
+ };
709
+ // ── Out-of-Sync Notification Actions ──────────────────────────────────────────
710
+ // (design §14 / §14A — surfaced as notifications, acted on per-artifact.
711
+ // Requires GENERATE_FROM_KB + owner|editor on the KB.)
712
+ /**
713
+ * Regenerate a stale artifact from a notification using current chunks.
714
+ * POST /api/v1/notifications/:notificationId/artifacts/:artifactId/regenerate
715
+ * @param {String} notificationId The notification id
716
+ * @param {String} artifactId The artifact id
717
+ * @param {object} data Body `{ entityType }`
718
+ * @param {String} authToken Authentication token
719
+ * @returns {Promise<object>}
720
+ */
721
+ export const regenerateArtifact = (notificationId, artifactId, data, authToken) => {
722
+ return new Promise((resolve, reject) => {
723
+ const request = client.post(`/api/v1/notifications/${notificationId}/artifacts/${artifactId}/regenerate`, data, { headers: { authorization: authToken } });
724
+ request
725
+ .then((response) => {
726
+ resolve(response.data);
727
+ })
728
+ .catch((error) => {
729
+ reject(error);
730
+ });
731
+ });
732
+ };
733
+ /**
734
+ * Retire (soft-delete) a stale artifact from a notification.
735
+ * POST /api/v1/notifications/:notificationId/artifacts/:artifactId/retire
736
+ * @param {String} notificationId The notification id
737
+ * @param {String} artifactId The artifact id
738
+ * @param {object} data Body `{ entityType }`
739
+ * @param {String} authToken Authentication token
740
+ * @returns {Promise<object>}
741
+ */
742
+ export const retireArtifact = (notificationId, artifactId, data, authToken) => {
743
+ return new Promise((resolve, reject) => {
744
+ const request = client.post(`/api/v1/notifications/${notificationId}/artifacts/${artifactId}/retire`, data, { headers: { authorization: authToken } });
745
+ request
746
+ .then((response) => {
747
+ resolve(response.data);
748
+ })
749
+ .catch((error) => {
750
+ reject(error);
751
+ });
752
+ });
753
+ };
754
+ /**
755
+ * Dismiss a stale-artifact flag (mark the staleness acceptable).
756
+ * POST /api/v1/notifications/:notificationId/artifacts/:artifactId/dismiss
757
+ * @param {String} notificationId The notification id
758
+ * @param {String} artifactId The artifact id
759
+ * @param {object} data Body `{ entityType, reason? }`
760
+ * @param {String} authToken Authentication token
761
+ * @returns {Promise<object>}
762
+ */
763
+ export const dismissArtifact = (notificationId, artifactId, data, authToken) => {
764
+ return new Promise((resolve, reject) => {
765
+ const request = client.post(`/api/v1/notifications/${notificationId}/artifacts/${artifactId}/dismiss`, data, { headers: { authorization: authToken } });
766
+ request
767
+ .then((response) => {
768
+ resolve(response.data);
769
+ })
770
+ .catch((error) => {
771
+ reject(error);
772
+ });
773
+ });
774
+ };
775
+ /**
776
+ * Dismiss an entire out-of-sync notification (all artifacts).
777
+ * POST /api/v1/notifications/:notificationId/dismiss-all
778
+ * @param {String} notificationId The notification id
779
+ * @param {String} authToken Authentication token
780
+ * @returns {Promise<object>}
781
+ */
782
+ export const dismissAllArtifacts = (notificationId, authToken) => {
783
+ return new Promise((resolve, reject) => {
784
+ const request = client.post(`/api/v1/notifications/${notificationId}/dismiss-all`, {}, { headers: { authorization: authToken } });
785
+ request
786
+ .then((response) => {
787
+ resolve(response.data);
788
+ })
789
+ .catch((error) => {
790
+ reject(error);
791
+ });
792
+ });
793
+ };
794
+ // ── Identity Mapping ──────────────────────────────────────────────────────────
795
+ // (design §14 — maps source-side principals to tenant users for KB source ACLs.)
796
+ /**
797
+ * List the current user's source-side identities.
798
+ * GET /api/v1/identity/source-mappings
799
+ * @param {String} authToken Authentication token
800
+ * @returns {Promise<object>}
801
+ */
802
+ export const listSourceMappings = (authToken) => {
803
+ return new Promise((resolve, reject) => {
804
+ const request = client.get(`/api/v1/identity/source-mappings`, {
805
+ headers: { authorization: authToken },
806
+ });
807
+ request
808
+ .then((response) => {
809
+ resolve(response.data);
810
+ })
811
+ .catch((error) => {
812
+ reject(error);
813
+ });
814
+ });
815
+ };
816
+ /**
817
+ * Tenant-admin override for a user's source identity mapping.
818
+ * PUT /api/v1/identity/source-mappings/:sourceType
819
+ * @param {String} sourceType The source type key
820
+ * @param {object} data The mapping override
821
+ * @param {String} authToken Authentication token
822
+ * @returns {Promise<object>}
823
+ */
824
+ export const updateSourceMapping = (sourceType, data, authToken) => {
825
+ return new Promise((resolve, reject) => {
826
+ const request = client.put(`/api/v1/identity/source-mappings/${sourceType}`, data, { headers: { authorization: authToken } });
827
+ request
828
+ .then((response) => {
829
+ resolve(response.data);
830
+ })
831
+ .catch((error) => {
832
+ reject(error);
833
+ });
834
+ });
835
+ };
836
+ /**
837
+ * Bulk-resolve source principal IDs → tenant users (internal / service-to-service).
838
+ * POST /api/v1/identity/source-mappings/resolve
839
+ * @param {object} data Body carrying the principal IDs to resolve
840
+ * @param {String} authToken Authentication token
841
+ * @returns {Promise<object>}
842
+ */
843
+ export const resolveSourceMappings = (data, authToken) => {
844
+ return new Promise((resolve, reject) => {
845
+ const request = client.post(`/api/v1/identity/source-mappings/resolve`, data, { headers: { authorization: authToken } });
846
+ request
847
+ .then((response) => {
848
+ resolve(response.data);
849
+ })
850
+ .catch((error) => {
851
+ reject(error);
852
+ });
853
+ });
854
+ };
855
+ //# sourceMappingURL=knowledgeBase.js.map