@cccsaurora/clue-ui 1.5.0-dev.477 → 1.5.0-dev.484
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/{ActionForm-DIAUGhSr.js → ActionForm-BMIAp7pf.js} +3 -3
- package/{AnnotationDetails-DmrYK0Qc.js → AnnotationDetails-Dmk8kpl3.js} +1 -1
- package/{AnnotationPreview-DAswA7fu.js → AnnotationPreview-CIya3ByE.js} +1 -1
- package/{ClueEnrichContext-B76X-cLH.js → ClueEnrichContext-BqzlMW0c.js} +5 -20
- package/components/AnnotationDetailPopover.js +1 -1
- package/components/AnnotationDetails.js +2 -2
- package/components/AnnotationPreview.js +1 -1
- package/components/EnrichedCard.js +1 -1
- package/components/EnrichedChip.js +2 -2
- package/components/EnrichedTypography.js +2 -2
- package/components/RetryFailedEnrichments.js +1 -1
- package/components/SourcePicker.js +1 -1
- package/components/actions/ActionForm.js +1 -1
- package/components/actions/ExecutePopover.js +1 -1
- package/components/actions/ResultModal.js +1 -1
- package/components/enrichment/EnrichPopover.js +1 -1
- package/components/fetchers/Fetcher.js +1 -1
- package/components/group/GroupControl.js +1 -1
- package/components/stats/QueryStatus.js +1 -1
- package/database/errors.d.ts +11 -0
- package/database/errors.js +18 -0
- package/database/index.js +2 -2
- package/database/replication.js +3 -2
- package/database/types.d.ts +22 -0
- package/hooks/ClueActionContext.js +2 -2
- package/hooks/ClueDatabaseContext.js +1 -1
- package/hooks/ClueEnrichContext.js +3 -2
- package/hooks/ClueEnrichContextType.d.ts +1 -1
- package/hooks/ClueFetcherContext.js +1 -1
- package/hooks/ClueGroupContext.js +1 -1
- package/hooks/CluePopupContext.js +2 -2
- package/hooks/ClueProvider.js +3 -3
- package/hooks/selectors.js +2 -2
- package/hooks/useActionResult.js +1 -1
- package/hooks/useAnnotations.js +2 -2
- package/hooks/useClue.js +1 -1
- package/hooks/useClueActions.js +1 -1
- package/hooks/useClueTypeConfig.d.ts +2 -0
- package/hooks/useClueTypeConfig.js +9 -13
- package/hooks/useErrors.js +1 -1
- package/hooks/useFetcherResult.js +1 -1
- package/icons/Action.js +2 -2
- package/icons/Assessment.js +1 -1
- package/icons/Context.js +1 -1
- package/icons/Opinion.js +1 -1
- package/{index-8lXdRRpV.js → index-CdqmWKik.js} +2 -2
- package/{index-DT_sunCV.js → index-CgvdVEs-.js} +1 -1
- package/{index-CPetQxOc.js → index-Dd7KdsT8.js} +113 -89
- package/main.d.ts +5 -4
- package/main.js +7 -5
- package/package.json +1 -1
- package/{replication-DDxxY_CX.js → replication-Ck5s0Yg-.js} +115 -43
- package/types/lookup.d.ts +10 -1
- package/utils/typeDetection.d.ts +7 -0
- package/utils/typeDetection.js +13 -0
|
@@ -9,7 +9,8 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var _hashFn, _keyMap, _unpack, _options, _root, _local, _operators, _iteratees, _yieldedValues, _getNext, _a, _source, _predicate, _projection, _options2, _operators2, _result, _buffer, _compiled, _options3, _condition;
|
|
12
|
-
import { a as api, j as joinAllUri, u as uri } from "./index-
|
|
12
|
+
import { a as api, j as joinAllUri, u as uri } from "./index-Dd7KdsT8.js";
|
|
13
|
+
import { ClueReplicationError } from "./database/errors.js";
|
|
13
14
|
import { REPLICATORS } from "./database/globals.js";
|
|
14
15
|
import { l as last$1 } from "./last-CUCl67Im.js";
|
|
15
16
|
function _typeof(o) {
|
|
@@ -11538,74 +11539,145 @@ const buildRequestConfig = (config2) => {
|
|
|
11538
11539
|
}
|
|
11539
11540
|
return requestConfig;
|
|
11540
11541
|
};
|
|
11542
|
+
const parseStreamEvent = (line) => {
|
|
11543
|
+
var _a2, _b, _c;
|
|
11544
|
+
try {
|
|
11545
|
+
const event = JSON.parse(line);
|
|
11546
|
+
const lastUpdated = ((_a2 = event == null ? void 0 : event.checkpoint) == null ? void 0 : _a2.last_updated) ?? ((_b = event == null ? void 0 : event.checkpoint) == null ? void 0 : _b.updated_at);
|
|
11547
|
+
const checkpoint = (event == null ? void 0 : event.checkpoint) === null ? null : typeof ((_c = event == null ? void 0 : event.checkpoint) == null ? void 0 : _c.id) === "string" && Number.isFinite(lastUpdated) ? { id: event.checkpoint.id, last_updated: lastUpdated } : void 0;
|
|
11548
|
+
if (!Number.isFinite(event == null ? void 0 : event.id) || !Array.isArray(event.documents) || checkpoint === void 0) {
|
|
11549
|
+
return null;
|
|
11550
|
+
}
|
|
11551
|
+
return { ...event, checkpoint };
|
|
11552
|
+
} catch {
|
|
11553
|
+
return null;
|
|
11554
|
+
}
|
|
11555
|
+
};
|
|
11541
11556
|
const stream = (collection, config2) => {
|
|
11542
11557
|
const stream$ = new Subject();
|
|
11543
11558
|
const MAX_RETRY_DELAY = 6e4;
|
|
11559
|
+
const INITIAL_RETRY_DELAY = 1e3;
|
|
11544
11560
|
const loggedEvents = [];
|
|
11545
11561
|
let currentXhr = null;
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
const
|
|
11562
|
+
let retryTimer = null;
|
|
11563
|
+
let closed = false;
|
|
11564
|
+
const isClosed = () => closed || collection.closed;
|
|
11565
|
+
const getToken = () => {
|
|
11550
11566
|
var _a2;
|
|
11567
|
+
try {
|
|
11568
|
+
return (_a2 = config2.getToken) == null ? void 0 : _a2.call(config2);
|
|
11569
|
+
} catch {
|
|
11570
|
+
return void 0;
|
|
11571
|
+
}
|
|
11572
|
+
};
|
|
11573
|
+
const reportHttpFailure = async (error) => {
|
|
11574
|
+
try {
|
|
11575
|
+
if (!config2.onReplicationError) {
|
|
11576
|
+
console.error(error);
|
|
11577
|
+
return false;
|
|
11578
|
+
}
|
|
11579
|
+
return await config2.onReplicationError(error) === true;
|
|
11580
|
+
} catch {
|
|
11581
|
+
return false;
|
|
11582
|
+
}
|
|
11583
|
+
};
|
|
11584
|
+
const emitResyncIfNeeded = () => {
|
|
11585
|
+
if (!isClosed() && collection.synced) {
|
|
11586
|
+
stream$.next("RESYNC");
|
|
11587
|
+
}
|
|
11588
|
+
};
|
|
11589
|
+
const connect = (timeout = INITIAL_RETRY_DELAY, token = getToken()) => {
|
|
11590
|
+
if (isClosed()) {
|
|
11591
|
+
return;
|
|
11592
|
+
}
|
|
11551
11593
|
let lastProcessedIndex = 0;
|
|
11552
|
-
|
|
11553
|
-
|
|
11594
|
+
let done = false;
|
|
11595
|
+
const xhr = new XMLHttpRequest();
|
|
11596
|
+
currentXhr = xhr;
|
|
11597
|
+
const fullUrl = (config2.baseURL ?? "") + joinAllUri(uri(), collection.name, "stream");
|
|
11598
|
+
xhr.open("GET", fullUrl, true);
|
|
11599
|
+
xhr.setRequestHeader("Accept", "text/event-stream");
|
|
11600
|
+
if (token) {
|
|
11601
|
+
xhr.setRequestHeader("Authorization", `Bearer ${token}`);
|
|
11602
|
+
}
|
|
11554
11603
|
const reconnect = () => {
|
|
11555
|
-
if (
|
|
11604
|
+
if (isClosed()) {
|
|
11556
11605
|
return;
|
|
11557
11606
|
}
|
|
11558
11607
|
{
|
|
11559
11608
|
console.log(`Retrying live connection in ${timeout}ms...`);
|
|
11560
11609
|
}
|
|
11561
|
-
setTimeout(() => {
|
|
11610
|
+
retryTimer = setTimeout(() => {
|
|
11611
|
+
retryTimer = null;
|
|
11562
11612
|
connect(Math.min(timeout * 2, MAX_RETRY_DELAY));
|
|
11563
11613
|
}, timeout);
|
|
11614
|
+
emitResyncIfNeeded();
|
|
11564
11615
|
};
|
|
11565
|
-
const
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
if (token) {
|
|
11570
|
-
_xhr.setRequestHeader("Authorization", `Bearer ${token}`);
|
|
11571
|
-
}
|
|
11572
|
-
_xhr.onload = () => {
|
|
11573
|
-
reconnect();
|
|
11574
|
-
if (collection.synced) {
|
|
11575
|
-
stream$.next("RESYNC");
|
|
11616
|
+
const processLines = (flush = false) => {
|
|
11617
|
+
var _a2;
|
|
11618
|
+
if (done || isClosed() || xhr.status < 200 || xhr.status >= 300) {
|
|
11619
|
+
return;
|
|
11576
11620
|
}
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11621
|
+
const lines = xhr.responseText.slice(lastProcessedIndex).split("\n");
|
|
11622
|
+
lastProcessedIndex = xhr.responseText.length - (flush ? 0 : ((_a2 = lines.pop()) == null ? void 0 : _a2.length) ?? 0);
|
|
11623
|
+
for (const line of lines) {
|
|
11624
|
+
const event = line.trim() ? parseStreamEvent(line) : null;
|
|
11625
|
+
if (!event) {
|
|
11626
|
+
continue;
|
|
11627
|
+
}
|
|
11628
|
+
timeout = INITIAL_RETRY_DELAY;
|
|
11629
|
+
if (loggedEvents.includes(event.id)) {
|
|
11630
|
+
continue;
|
|
11631
|
+
}
|
|
11632
|
+
if (loggedEvents.length >= 1e3) {
|
|
11633
|
+
loggedEvents.shift();
|
|
11634
|
+
}
|
|
11635
|
+
loggedEvents.push(event.id);
|
|
11636
|
+
stream$.next(event);
|
|
11582
11637
|
}
|
|
11583
11638
|
};
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
|
|
11639
|
+
const handleEnd = async () => {
|
|
11640
|
+
var _a2;
|
|
11641
|
+
if (done || isClosed()) {
|
|
11642
|
+
return;
|
|
11587
11643
|
}
|
|
11588
|
-
|
|
11589
|
-
|
|
11590
|
-
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
|
|
11644
|
+
if (xhr.status < 400) {
|
|
11645
|
+
processLines(true);
|
|
11646
|
+
}
|
|
11647
|
+
done = true;
|
|
11648
|
+
if (xhr.status >= 400) {
|
|
11649
|
+
const error = new ClueReplicationError(xhr.status, fullUrl, collection.name);
|
|
11650
|
+
if (xhr.status >= 500) {
|
|
11651
|
+
void reportHttpFailure(error);
|
|
11652
|
+
reconnect();
|
|
11653
|
+
} else if (xhr.status === 401) {
|
|
11654
|
+
if (await reportHttpFailure(error)) {
|
|
11655
|
+
const refreshedToken = (_a2 = getToken()) == null ? void 0 : _a2.trim();
|
|
11656
|
+
if (refreshedToken && refreshedToken !== token && !isClosed()) {
|
|
11657
|
+
connect(INITIAL_RETRY_DELAY, refreshedToken);
|
|
11658
|
+
emitResyncIfNeeded();
|
|
11659
|
+
}
|
|
11598
11660
|
}
|
|
11599
|
-
|
|
11600
|
-
|
|
11661
|
+
} else {
|
|
11662
|
+
void reportHttpFailure(error);
|
|
11601
11663
|
}
|
|
11602
|
-
} catch {
|
|
11603
11664
|
return;
|
|
11604
11665
|
}
|
|
11605
|
-
|
|
11666
|
+
reconnect();
|
|
11606
11667
|
};
|
|
11607
|
-
|
|
11668
|
+
xhr.onload = () => void handleEnd();
|
|
11669
|
+
xhr.onerror = () => void handleEnd();
|
|
11670
|
+
xhr.onprogress = () => processLines();
|
|
11671
|
+
xhr.send();
|
|
11608
11672
|
};
|
|
11673
|
+
collection.onClose.push(() => {
|
|
11674
|
+
closed = true;
|
|
11675
|
+
if (retryTimer !== null) {
|
|
11676
|
+
clearTimeout(retryTimer);
|
|
11677
|
+
retryTimer = null;
|
|
11678
|
+
}
|
|
11679
|
+
currentXhr == null ? void 0 : currentXhr.abort();
|
|
11680
|
+
});
|
|
11609
11681
|
connect();
|
|
11610
11682
|
return stream$;
|
|
11611
11683
|
};
|
package/types/lookup.d.ts
CHANGED
|
@@ -57,6 +57,15 @@ export type EnrichResponses = {
|
|
|
57
57
|
|
|
58
58
|
export type BulkEnrichResponses = { [type: string]: { [value: string]: EnrichResponses } };
|
|
59
59
|
|
|
60
|
-
export type TypesDetectionResponse = { [type: string]: string };
|
|
60
|
+
export type TypesDetectionResponse = { [type: string]: string | null };
|
|
61
|
+
|
|
62
|
+
export interface SupportedType {
|
|
63
|
+
regex: string | null;
|
|
64
|
+
case_sensitive: boolean;
|
|
65
|
+
/** Higher values win. Omission defaults to zero; ties use registry insertion order. */
|
|
66
|
+
priority?: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type TypesDetectionV2Response = { [type: string]: SupportedType };
|
|
61
70
|
|
|
62
71
|
export type TypesResponse = { [type: string]: string[] };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TypesDetectionV2Response } from "../types/lookup";
|
|
2
|
+
|
|
3
|
+
export type TypeDetector = [type: string, regex: RegExp];
|
|
4
|
+
/** Compile in descending priority order, retaining registry order for ties. */
|
|
5
|
+
export declare const compileTypeDetectors: (definitions: TypesDetectionV2Response) => TypeDetector[];
|
|
6
|
+
/** Match without altering the input or retrying case-sensitive patterns in lowercase. */
|
|
7
|
+
export declare const detectType: (value: string, detectors: TypeDetector[]) => string | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const compileTypeDetectors = (definitions) => {
|
|
2
|
+
return Object.entries(definitions).sort(([, left], [, right]) => (right.priority ?? 0) - (left.priority ?? 0)).flatMap(
|
|
3
|
+
([type, definition]) => definition.regex === null ? [] : [[type, new RegExp(definition.regex, definition.case_sensitive ? "" : "i")]]
|
|
4
|
+
);
|
|
5
|
+
};
|
|
6
|
+
const detectType = (value, detectors) => {
|
|
7
|
+
var _a;
|
|
8
|
+
return value ? ((_a = detectors.find(([, regex]) => regex.test(value))) == null ? void 0 : _a[0]) ?? null : null;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
compileTypeDetectors,
|
|
12
|
+
detectType
|
|
13
|
+
};
|