@nodii/dev 0.6.67 → 0.6.69

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/figma.js CHANGED
@@ -663,9 +663,49 @@ export function isChangeSetId(value) {
663
663
  return true;
664
664
  }
665
665
 
666
- export async function figmaPublishPlan(value, { request = devRequest } = {}) {
666
+ // The plan reads the design file for minutes on a large library, so Dev works it
667
+ // out as a job (DESIGN-SYSTEM-PARITY-153): the POST answers 202, here it's polled
668
+ // until it ends. Dev's job stops itself after an hour; stop a little later.
669
+ const PLAN_JOB_WAIT_MS = 65 * 60_000;
670
+ const planJobPath = (key, id) => `/api/v1/design/files/${encode(key)}/publish-plan/jobs/${encode(id)}`;
671
+
672
+ /** A finished plan job as the plan itself: the plan, or the refusal Dev ended it with. */
673
+ export function planJobOutcome(job) {
674
+ if (job.state === "succeeded") return { data: job.result };
675
+ const e = job.error ?? {};
676
+ if (e.code === "PUBLISH_PLAN_JOB_LOST") throw new CliError(e.code, `${e.message ?? "Dev lost this job"} (job ${job.id} on ${job.fileKey}). Run the same command again.`, 1, e.details);
677
+ throw new CliError(!e.code || GATEWAY.has(e.code) ? "PUBLISH_PLAN_JOB_FAILED" : e.code, e.message ?? `Dev's publish plan job ${job.id} failed with HTTP ${job.httpStatus}`, 1, e.details);
678
+ }
679
+
680
+ /** Starts or joins the file's plan job (startDesignPublishPlan) and polls it until it ends, printing progress. */
681
+ export async function figmaPublishPlan(value, { request = devRequest, sleep = delay, progress = stderrLine, now = Date.now } = {}) {
667
682
  const key = figmaFileKey(value);
668
- return fileCall(key, request)("GET", `/api/v1/design/files/${encode(key)}/publish-plan`);
683
+ const call = fileCall(key, request);
684
+ let job = (await call("POST", `/api/v1/design/files/${encode(key)}/publish-plan`, {})).data;
685
+ const start = now();
686
+ let printed = start;
687
+ let misses = 0;
688
+ for (let n = 0; !DONE.has(job.state); n++) {
689
+ if (now() - start > PLAN_JOB_WAIT_MS)
690
+ throw new CliError("PUBLISH_PLAN_JOB_TIMEOUT", `Dev's publish plan job ${job.id} on ${key} is still running after ${Math.round(PLAN_JOB_WAIT_MS / 60_000)} minutes. Run the same command again to join it.`, 1);
691
+ await sleep(JOB_POLL_MS[Math.min(n, JOB_POLL_MS.length - 1)]);
692
+ try {
693
+ job = (await call("GET", planJobPath(key, job.id))).data;
694
+ misses = 0;
695
+ } catch (error) {
696
+ if (!TRANSIENT.has(error?.code)) throw error;
697
+ // A poll that hit the edge's gateway or a blip retries; the job runs on in Dev.
698
+ if (++misses > 5) throw new CliError("PUBLISH_PLAN_JOB_UNREACHABLE", `Lost touch with Dev (${error.code}) while its publish plan job ${job.id} on ${key} runs. Run the same command again to join it.`, 1);
699
+ progress(`polling ${job.id} again (${error.code})`);
700
+ continue;
701
+ }
702
+ if (!DONE.has(job.state) && now() - printed >= JOB_PROGRESS_MS) {
703
+ printed = now();
704
+ const done = job.progress ? `, ${job.progress.compared} of ${job.progress.total} components compared` : "";
705
+ progress(`${key}: publish plan job ${job.id} still running (${Math.round((printed - start) / 1000)} s${done})`);
706
+ }
707
+ }
708
+ return planJobOutcome(job);
669
709
  }
670
710
 
671
711
  const planLine = (x) => ` ${x.nodeId ?? (x.kind ? scopeText(x) : "(no node)")} ${x.name ?? ""} (${x.changeSetId} ${x.state}${x.title ? `: ${x.title}` : ""})`;
@@ -30,7 +30,7 @@
30
30
  // it until it returns [] (each round can reveal instances inside slot
31
31
  // content).
32
32
 
33
- export const VERSION = "1.0.11";
33
+ export const VERSION = "1.0.12";
34
34
 
35
35
  /** @typedef {{ nodeId: string, check: string, detail: string }} Finding */
36
36
  /**
@@ -828,8 +828,13 @@ export function checkConformance({
828
828
  // notFromLibrary: local parts and hand-drawn stand-ins, off the library.
829
829
  if (!library && own) {
830
830
  if (n.type === "COMPONENT" || n.type === "COMPONENT_SET") {
831
+ // A submitted variant is its own root, so its set is not in the
832
+ // walked tree; Figma's components map still names the set.
831
833
  const setName =
832
- n.type === "COMPONENT" ? a.parent.get(n.id)?.name : null;
834
+ n.type === "COMPONENT"
835
+ ? (a.parent.get(n.id)?.name ??
836
+ a.componentSets[a.components[n.id]?.componentSetId]?.name)
837
+ : null;
833
838
  if (!SURFACE_NAME.test(n.name) && !SURFACE_NAME.test(setName ?? ""))
834
839
  push(
835
840
  findings,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.67",
3
+ "version": "0.6.69",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,6 +20,8 @@
20
20
  "format": "git diff --check",
21
21
  "test": "node --test test/*.test.js",
22
22
  "pack:smoke": "node scripts/pack-smoke.mjs",
23
+ "edge-routes:refresh": "node scripts/edge-routes.mjs",
24
+ "edge-routes:check": "node scripts/edge-routes.mjs --check",
23
25
  "openapi:snapshot": "node scripts/openapi-snapshot.mjs",
24
26
  "openapi:ad-era": "node scripts/ad-era-openapi-snapshot.mjs",
25
27
  "openapi:watchdog": "node scripts/watchdog-openapi-snapshot.mjs"