@braze/sanity-plugin-ai-translation 0.2.82 → 0.2.83
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 +11 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3441,7 +3441,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
3441
3441
|
} = useTranslationContext(), client = useClient({ apiVersion: "vX" }), [scanKey, setScanKey] = useState(0), [validationResults, setValidationResults] = useState(/* @__PURE__ */ new Map()), [sourceRefsWithDrafts, setSourceRefsWithDrafts] = useState([]), [isSourceDraftCheckLoading, setIsSourceDraftCheckLoading] = useState(!0), [staleDrafts, setStaleDrafts] = useState([]), [isDraftCheckLoading, setIsDraftCheckLoading] = useState(!0), [draftAction, setDraftAction] = useState("none"), [isDraftActionInProgress, setIsDraftActionInProgress] = useState(!1), [conflictContext, setConflictContext] = useState(null), [isCheckingConflicts, setIsCheckingConflicts] = useState(!0), filteredReferences = useMemo(
|
|
3442
3442
|
() => references.filter((ref) => selectedReferenceIds.has(ref._id)),
|
|
3443
3443
|
[references, selectedReferenceIds]
|
|
3444
|
-
),
|
|
3444
|
+
), documentsToValidate = useMemo(() => {
|
|
3445
3445
|
const docs = [
|
|
3446
3446
|
{
|
|
3447
3447
|
_id: document._id,
|
|
@@ -3449,20 +3449,19 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
3449
3449
|
title: document.title || document.name || document._id
|
|
3450
3450
|
}
|
|
3451
3451
|
];
|
|
3452
|
-
if (shouldTranslateReferences)
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
if (count >= MAX_REFERENCE_VALIDATORS) break;
|
|
3456
|
-
selectedReferenceIds.has(ref._id) && (docs.push(ref), count++);
|
|
3457
|
-
}
|
|
3458
|
-
}
|
|
3452
|
+
if (shouldTranslateReferences)
|
|
3453
|
+
for (const ref of references)
|
|
3454
|
+
selectedReferenceIds.has(ref._id) && docs.push(ref);
|
|
3459
3455
|
return docs;
|
|
3460
|
-
}, [document, references, selectedReferenceIds, shouldTranslateReferences]),
|
|
3456
|
+
}, [document, references, selectedReferenceIds, shouldTranslateReferences]), CONCURRENT_VALIDATORS = 10, handleValidationResult = useCallback((id, result) => {
|
|
3461
3457
|
setValidationResults((prev) => {
|
|
3462
3458
|
const next = new Map(prev);
|
|
3463
3459
|
return next.set(id, result), next;
|
|
3464
3460
|
});
|
|
3465
|
-
}, []),
|
|
3461
|
+
}, []), activeValidators = useMemo(() => documentsToValidate.filter((doc) => {
|
|
3462
|
+
const result = validationResults.get(doc._id);
|
|
3463
|
+
return !result || result.isValidating;
|
|
3464
|
+
}).slice(0, CONCURRENT_VALIDATORS), [documentsToValidate, validationResults]), { hasValidationErrors, someStillValidating, documentsWithErrors } = useMemo(() => {
|
|
3466
3465
|
const allValidated = documentsToValidate.every((doc) => validationResults.has(doc._id)), validating = [...validationResults.values()].some((r) => r.isValidating) || !allValidated, docsWithErrors = [];
|
|
3467
3466
|
for (const doc of documentsToValidate) {
|
|
3468
3467
|
const result = validationResults.get(doc._id);
|
|
@@ -3648,7 +3647,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
3648
3647
|
onSkipConflicts: handleSkipConflicts
|
|
3649
3648
|
}
|
|
3650
3649
|
) }) : /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
3651
|
-
|
|
3650
|
+
activeValidators.map((doc) => /* @__PURE__ */ jsx(
|
|
3652
3651
|
DocumentValidator,
|
|
3653
3652
|
{
|
|
3654
3653
|
documentId: doc._id,
|
|
@@ -3673,15 +3672,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
3673
3672
|
/* @__PURE__ */ jsx(Card, { padding: 4, border: !0, radius: 2, tone: hasValidationErrors ? "critical" : void 0, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
3674
3673
|
/* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
|
|
3675
3674
|
someStillValidating ? /* @__PURE__ */ jsx(Spinner, { muted: !0 }) : hasValidationErrors ? /* @__PURE__ */ jsx(Text, { size: 2, children: /* @__PURE__ */ jsx(ErrorOutlineIcon, {}) }) : /* @__PURE__ */ jsx(Text, { size: 2, children: /* @__PURE__ */ jsx(CheckmarkIcon, {}) }),
|
|
3676
|
-
/* @__PURE__ */ jsx(Text, { weight: "semibold", children: someStillValidating ?
|
|
3677
|
-
] }),
|
|
3678
|
-
skippedValidationCount > 0 && !someStillValidating && /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
3679
|
-
skippedValidationCount,
|
|
3680
|
-
" additional reference",
|
|
3681
|
-
skippedValidationCount !== 1 ? "s were" : " was",
|
|
3682
|
-
" not validated (limit: ",
|
|
3683
|
-
MAX_REFERENCE_VALIDATORS,
|
|
3684
|
-
")."
|
|
3675
|
+
/* @__PURE__ */ jsx(Text, { weight: "semibold", children: someStillValidating ? `Validating documents (${validationResults.size}/${documentsToValidate.length})\u2026` : hasValidationErrors ? `Validation errors in ${documentsWithErrors.length} document${documentsWithErrors.length !== 1 ? "s" : ""}` : "All documents pass validation" })
|
|
3685
3676
|
] }),
|
|
3686
3677
|
documentsWithErrors.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3687
3678
|
/* @__PURE__ */ jsx(Text, { size: 1, children: "Documents must pass validation before they can be translated. Click a document to open it and fix the errors." }),
|