@sanity/ailf-studio 2.1.0 → 2.2.1

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 (2) hide show
  1. package/dist/index.js +106 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -783,11 +783,21 @@ var RAW_EVAL_MODES = [
783
783
 
784
784
  // ../shared/dist/owner-teams.js
785
785
  var KNOWN_OWNER_TEAMS = [
786
+ "ai-growth",
787
+ "billing-and-integrations",
788
+ "content-agent",
786
789
  "content-lake",
787
- "core-docs",
788
- "growth",
789
- "media",
790
- "platform",
790
+ "data",
791
+ "design-and-research",
792
+ "docs",
793
+ "editorial-experience",
794
+ "engineering",
795
+ "identity",
796
+ "media-library",
797
+ "product",
798
+ "runtime",
799
+ "sdk",
800
+ "ssi",
791
801
  "studio"
792
802
  ];
793
803
 
@@ -5205,6 +5215,7 @@ function readSearchParam(params, key) {
5205
5215
 
5206
5216
  // src/queries.ts
5207
5217
  var REPORT_TYPE = "ailf.report";
5218
+ var TASK_TYPE = "ailf.task";
5208
5219
  var latestReportsQuery = (
5209
5220
  /* groq */
5210
5221
  `
@@ -5527,6 +5538,34 @@ var distinctFilterValuesQuery = (
5527
5538
  }
5528
5539
  `
5529
5540
  );
5541
+ var releaseArticlesQuery = (
5542
+ /* groq */
5543
+ `
5544
+ *[_type == "article" && sanity::partOfRelease($releaseId)] {
5545
+ "id": string::split(_id, ".")[2],
5546
+ "slug": slug.current,
5547
+ "path": select(
5548
+ defined(primarySection) => primarySection->slug.current + "/" + slug.current
5549
+ )
5550
+ }
5551
+ `
5552
+ );
5553
+ var releaseTaskCoverageQuery = (
5554
+ /* groq */
5555
+ `
5556
+ count(*[
5557
+ _type == "${TASK_TYPE}"
5558
+ && status == "active"
5559
+ && !(_id in path("drafts.**"))
5560
+ && defined(contextDocs)
5561
+ && (
5562
+ count(contextDocs[refType == "id" && doc._ref in $articleIds]) > 0
5563
+ || count(contextDocs[refType == "path" && path in $articlePaths]) > 0
5564
+ || count(contextDocs[refType == "perspective" && perspective == $releaseId]) > 0
5565
+ )
5566
+ ])
5567
+ `
5568
+ );
5530
5569
  function filterModeClause(param) {
5531
5570
  return `&& (${param} == null || provenance.mode == ${param})`;
5532
5571
  }
@@ -15847,6 +15886,42 @@ function buildReleaseEvalPipelineRequest(args) {
15847
15886
  variant: mode
15848
15887
  };
15849
15888
  }
15889
+ function buildCoverageQueryParams(articles, releaseId) {
15890
+ return {
15891
+ articleIds: articles.map((a) => a.id),
15892
+ articlePaths: articles.map((a) => a.path).filter((p) => p !== null),
15893
+ releaseId
15894
+ };
15895
+ }
15896
+ var COVERAGE_CACHE_TTL_MS = 3e4;
15897
+ var coverageCache = /* @__PURE__ */ new Map();
15898
+ function getOrStartCoverageCheck(perspectiveId, baseClient, ailfClient) {
15899
+ const entry = coverageCache.get(perspectiveId);
15900
+ if (entry && entry.expiresAt > Date.now()) return entry.promise;
15901
+ const promise = (async () => {
15902
+ try {
15903
+ const articles = await baseClient.fetch(
15904
+ releaseArticlesQuery,
15905
+ { releaseId: perspectiveId }
15906
+ );
15907
+ if (!articles || articles.length === 0) return "uncovered";
15908
+ const params = buildCoverageQueryParams(articles, perspectiveId);
15909
+ const count = await ailfClient.fetch(
15910
+ releaseTaskCoverageQuery,
15911
+ params
15912
+ );
15913
+ if (typeof count !== "number") return "unknown";
15914
+ return count > 0 ? "covered" : "uncovered";
15915
+ } catch {
15916
+ return "unknown";
15917
+ }
15918
+ })();
15919
+ coverageCache.set(perspectiveId, {
15920
+ expiresAt: Date.now() + COVERAGE_CACHE_TTL_MS,
15921
+ promise
15922
+ });
15923
+ return promise;
15924
+ }
15850
15925
  var API_VERSION2 = "2026-03-11";
15851
15926
  var EVAL_REQUEST_TYPE3 = "ailf.evalRequest";
15852
15927
  var POLL_INTERVAL_MS2 = 3e4;
@@ -15875,8 +15950,29 @@ function createRunEvaluationAction(options = {}) {
15875
15950
  [baseClient, sourceDataset]
15876
15951
  );
15877
15952
  const [state, setState] = useState33({ status: "loading" });
15953
+ const [coverage, setCoverage] = useState33("loading");
15878
15954
  const requestedAtRef = useRef10(null);
15879
15955
  const perspectiveId = getReleaseIdFromReleaseDocumentId3(release._id);
15956
+ const baseClientRef = useRef10(baseClient);
15957
+ baseClientRef.current = baseClient;
15958
+ const ailfClientRef = useRef10(ailfClient);
15959
+ ailfClientRef.current = ailfClient;
15960
+ useEffect19(() => {
15961
+ let cancelled = false;
15962
+ const promise = getOrStartCoverageCheck(
15963
+ perspectiveId,
15964
+ baseClientRef.current,
15965
+ ailfClientRef.current
15966
+ );
15967
+ promise.then((status) => {
15968
+ if (!cancelled) setCoverage(status);
15969
+ }).catch(() => {
15970
+ if (!cancelled) setCoverage("unknown");
15971
+ });
15972
+ return () => {
15973
+ cancelled = true;
15974
+ };
15975
+ }, [perspectiveId]);
15880
15976
  useEffect19(() => {
15881
15977
  let cancelled = false;
15882
15978
  ailfClient.fetch(contentImpactQuery, buildReportQueryParams(perspectiveId)).then((results) => {
@@ -16019,11 +16115,11 @@ function createRunEvaluationAction(options = {}) {
16019
16115
  release.metadata?.title
16020
16116
  ]);
16021
16117
  return {
16022
- disabled: state.status === "loading" || state.status === "requested" || state.status === "polling",
16118
+ disabled: state.status === "loading" || state.status === "requested" || state.status === "polling" || coverage === "uncovered",
16023
16119
  icon: BarChartIcon2,
16024
16120
  label: getLabel2(state),
16025
16121
  onHandle: handleRequest,
16026
- title: getTitle2(state, perspectiveId)
16122
+ title: getTitle2(state, perspectiveId, coverage)
16027
16123
  };
16028
16124
  };
16029
16125
  RunEvaluationAction.displayName = "RunEvaluationAction";
@@ -16047,7 +16143,10 @@ function getLabel2(state) {
16047
16143
  return "Eval Failed";
16048
16144
  }
16049
16145
  }
16050
- function getTitle2(state, perspectiveId) {
16146
+ function getTitle2(state, perspectiveId, coverage) {
16147
+ if (coverage === "uncovered" && (state.status === "idle" || state.status === "ready")) {
16148
+ return `No active task references any document in this release (${perspectiveId}). Add a task that targets one of these docs before evaluating.`;
16149
+ }
16051
16150
  switch (state.status) {
16052
16151
  case "loading":
16053
16152
  return "Checking for existing evaluation results\u2026";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf-studio",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "AI Literacy Framework — Sanity Studio dashboard plugin",
5
5
  "type": "module",
6
6
  "license": "MIT",