From d40c2e7634ec94af2253b39da19ea383ab98ac03 Mon Sep 17 00:00:00 2001 From: Mrudul Patil <91871222+mrudulpatil18@users.noreply.github.com> Date: Sun, 1 Dec 2024 04:43:31 +0530 Subject: [PATCH 1/6] preserve explicit component names in createUseComponent (#355) * preserve explicit component names in createUseComponent * tests for red leds with correct name * format * fix type error * added prop name and hook name validation, test file to test behaviour --- lib/hooks/create-use-component.tsx | 15 +- .../red-led-name-validation.test.tsx | 176 ++++++++++++++++++ 2 files changed, 186 insertions(+), 5 deletions(-) create mode 100644 tests/components/normal-components/red-led-name-validation.test.tsx diff --git a/lib/hooks/create-use-component.tsx b/lib/hooks/create-use-component.tsx index f531fdba..03747a50 100644 --- a/lib/hooks/create-use-component.tsx +++ b/lib/hooks/create-use-component.tsx @@ -56,13 +56,20 @@ export const createUseComponent: CreateUseComponentConstPinLabels & } else if (typeof pins === "object") { pinLabelsFlatArray.push( ...Object.values(pins as Record).flat(), + ...(Object.keys(pins) as string[]), ) - pinLabelsFlatArray.push(...(Object.keys(pins) as string[])) } const R: any = (props2: any) => { - const combinedProps = { ...props, ...props2, name } - const tracesToCreate: any[] = [] + // Explicitly throw an error if names don't match + if (props2?.name && props2.name !== name) { + throw new Error( + `Component name mismatch. Hook name: ${name}, ` + + `Component prop name: ${props2.name}`, + ) + } + const combinedProps = { ...props, ...props2, name: name } + const tracesToCreate: any[] = [] for (const portLabel of pinLabelsFlatArray) { if (combinedProps[portLabel]) { const from = `.${name} > .${portLabel}` @@ -71,7 +78,6 @@ export const createUseComponent: CreateUseComponentConstPinLabels & delete combinedProps[portLabel] } } - return ( <> @@ -85,7 +91,6 @@ export const createUseComponent: CreateUseComponentConstPinLabels & for (const port of pinLabelsFlatArray) { R[port] = `.${name} > .${port}` } - return R } } diff --git a/tests/components/normal-components/red-led-name-validation.test.tsx b/tests/components/normal-components/red-led-name-validation.test.tsx new file mode 100644 index 00000000..4219b800 --- /dev/null +++ b/tests/components/normal-components/red-led-name-validation.test.tsx @@ -0,0 +1,176 @@ +import { test, expect } from "bun:test" +import { createUseComponent } from "lib/hooks/create-use-component" +import type { CommonLayoutProps } from "@tscircuit/props" +import { getTestFixture } from "../../fixtures/get-test-fixture" + +const pinLabels = { + "1": "pos", + "2": "neg", +} as const +const pinNames = Object.values(pinLabels) + +interface Props extends CommonLayoutProps { + name: string +} + +const RedLed = (props: Props) => { + return ( + + + + + + + + + + + + + + + + + } + /> + ) +} + +const useRedLed = createUseComponent(RedLed, pinNames) + +test(" component name validation", async () => { + const { circuit } = getTestFixture() + const RedLedComp = useRedLed("LED") as typeof RedLed + + // Successful case with original name + expect(() => { + circuit.add( + + + , + ) + }).not.toThrow() + + // More explicit error catching + let errorThrown = false + try { + circuit.add( + + + , + ) + } catch (error: unknown) { + errorThrown = true + if (error instanceof Error) { + expect(error).toBeInstanceOf(Error) + expect(error.message).toMatch( + /Component name mismatch. Hook name: LED, Component prop name: different_led_name/, + ) + } else { + throw new Error("Unexpected error type") + } + } + expect(errorThrown).toBe(true) +}) From ccd917e7e48bb1b4ab9d4e38c8ca6e86f95eefef Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 30 Nov 2024 23:14:09 +0000 Subject: [PATCH 2/6] v0.0.209 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13531fa4..695887af 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@tscircuit/core", "type": "module", - "version": "0.0.208", + "version": "0.0.209", "types": "dist/index.d.ts", "main": "dist/index.js", "module": "dist/index.js", From 433c94db2537c4b3501fe70d9278e142ee2b7429 Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Mon, 2 Dec 2024 07:17:05 +0800 Subject: [PATCH 3/6] Introduce job autorouting mode (#373) * introduce job autorouting mode * Update tests/fixtures/get-test-autorouting-server.tsx * fix type error * fixes using production api as reference --- bun.lockb | Bin 123746 -> 123746 bytes .../base-components/NormalComponent.ts | 2 +- lib/components/base-components/Renderable.ts | 19 ++- .../primitive-components/Group/Group.ts | 127 +++++++++++++----- package.json | 6 +- .../renderable-dirty-pattern.test.tsx | 2 +- ...remote-autorouting-4-job-mode-pcb.snap.svg | 13 ++ tests/features/remote-autorouting-1.test.tsx | 7 +- .../remote-autorouting-4-job-mode.test.tsx | 37 +++++ ...emote-autorouting-5-job-mode-prod.test.tsx | 29 ++++ .../fixtures/get-test-autorouting-server.tsx | 102 +++++++++++--- 11 files changed, 277 insertions(+), 67 deletions(-) create mode 100644 tests/features/__snapshots__/remote-autorouting-4-job-mode-pcb.snap.svg create mode 100644 tests/features/remote-autorouting-4-job-mode.test.tsx create mode 100644 tests/features/remote-autorouting-5-job-mode-prod.test.tsx diff --git a/bun.lockb b/bun.lockb index 3b2ce29b50092eb304acefa8d9eaa1c3a1c81ef5..fc78bfca1df9ee82f4658c288ca4719ed7f50ece 100755 GIT binary patch delta 161 zcmV;S0ABy%#s}iY2aqlxmKF7vj0ZMK`$uE6A^3Bh4h>aSi$p1RF8-}4=eV`Tu};b) z0c(@N6ep4u2(w5fC2K&hcao3udGDoTCk%*rf+O02`UAi}JhbF&GMRW$M6I9W0W(Jr zohp(j0+`1*(IQ!G2-|_z%Okz7R_VAFRRd46t&lpw2?A_kbY*jN006h}Q32*cmr>IJ PAeS(d0SmVQl>uQ+*;GZ0 delta 156 zcmV;N0Av5+#s}iY2aqlxx@91LmWPkUJ`*)Il&Sv})*mn*F18M} { + this._queueAsyncEffect("get-supplier-part-numbers", async () => { this._asyncSupplierPartNumbers = await supplierPartNumbersMaybePromise this._markDirty("PartsEngineRender") }) diff --git a/lib/components/base-components/Renderable.ts b/lib/components/base-components/Renderable.ts index ed9a6a95..5be7b634 100644 --- a/lib/components/base-components/Renderable.ts +++ b/lib/components/base-components/Renderable.ts @@ -46,6 +46,7 @@ export type RenderPhaseStates = Record< > export type AsyncEffect = { + effectName: string promise: Promise phase: RenderPhase complete: boolean @@ -101,10 +102,11 @@ export abstract class Renderable implements IRenderable { } } - protected _queueAsyncEffect(effect: () => Promise) { + protected _queueAsyncEffect(effectName: string, effect: () => Promise) { const asyncEffect: AsyncEffect = { promise: effect(), // TODO don't start effects until end of render cycle phase: this._currentRenderPhase!, + effectName, complete: false, } this._asyncEffects.push(asyncEffect) @@ -116,20 +118,25 @@ export abstract class Renderable implements IRenderable { // HACK: emit to the root circuit component that an async effect has completed if ("root" in this && this.root) { ;(this.root as any).emit("asyncEffectComplete", { - component: this, - asyncEffect, + effectName, + componentDisplayName: this.getString(), + phase: asyncEffect.phase, }) } }) .catch((error) => { - console.error(`Async effect error in ${asyncEffect.phase}:`, error) + console.error( + `Async effect error in ${asyncEffect.phase} "${effectName}":\n${error.stack}`, + ) asyncEffect.complete = true // HACK: emit to the root circuit component that an async effect has completed if ("root" in this && this.root) { ;(this.root as any).emit("asyncEffectComplete", { - component: this, - asyncEffect, + effectName, + componentDisplayName: this.getString(), + phase: asyncEffect.phase, + error: error.toString(), }) } }) diff --git a/lib/components/primitive-components/Group/Group.ts b/lib/components/primitive-components/Group/Group.ts index 4e5ca87a..013ee6e2 100644 --- a/lib/components/primitive-components/Group/Group.ts +++ b/lib/components/primitive-components/Group/Group.ts @@ -25,6 +25,7 @@ import type { Trace } from "../Trace/Trace" import { ConnectivityMap } from "circuit-json-to-connectivity-map" import type { TraceI } from "../Trace/TraceI" import { getSimpleRouteJsonFromTracesAndDb } from "lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb" +import Debug from "debug" export class Group = typeof groupProps> extends NormalComponent @@ -114,50 +115,109 @@ export class Group = typeof groupProps> doInitialPcbTraceRender() { if (this._shouldUseTraceByTraceRouting()) return - let serverUrl = this.props.autorouter?.serverUrl + const serverUrl = + this.props.autorouter?.serverUrl ?? "https://registry-api.tscircuit.com" + const serverMode = this.props.autorouter?.serverMode ?? "job" - if (this.props.autorouter === "auto-cloud") { - // TODO this url should be inferred by scanning parent subcircuits, the - // default should be provided by the platform OR error - serverUrl = "https://registry-api.tscircuit.com/autorouting/solve" + const debug = Debug("tscircuit:core:autorouting") + + const fetchWithDebug = (url: string, options: RequestInit) => { + debug("fetching", url) + return fetch(url, options) } - if (serverUrl) { - // Make a request to the autorouter server - this._queueAsyncEffect(async () => { + // Queue the autorouting request + this._queueAsyncEffect("make-http-autorouting-request", async () => { + if (serverMode === "solve-endpoint") { + // Legacy solve endpoint mode if (this.props.autorouter?.inputFormat === "simplified") { - const { autorouting_result } = await fetch(serverUrl, { - method: "POST", - body: JSON.stringify({ - input_simple_route_json: this._getSimpleRouteJsonFromPcbTraces(), - }), - headers: { - "Content-Type": "application/json", + const { autorouting_result } = await fetchWithDebug( + `${serverUrl}/autorouting/solve`, + { + method: "POST", + body: JSON.stringify({ + input_simple_route_json: + this._getSimpleRouteJsonFromPcbTraces(), + }), + headers: { "Content-Type": "application/json" }, }, - }).then((r) => r.json()) + ).then((r) => r.json()) this._asyncAutoroutingResult = autorouting_result this._markDirty("PcbTraceRender") + return } - const arRes = await fetch(serverUrl, { + const { autorouting_result } = await fetchWithDebug( + `${serverUrl}/autorouting/solve`, + { + method: "POST", + body: JSON.stringify({ + input_circuit_json: this.root!.db.toArray(), + }), + headers: { "Content-Type": "application/json" }, + }, + ).then((r) => r.json()) + this._asyncAutoroutingResult = autorouting_result + this._markDirty("PcbTraceRender") + return + } + + const { autorouting_job } = await fetchWithDebug( + `${serverUrl}/autorouting/jobs/create`, + { method: "POST", body: JSON.stringify({ - // TODO filter such that we're only using this subcircuit's - // components input_circuit_json: this.root!.db.toArray(), + provider: "freerouting", + autostart: true, }), - headers: { - "Content-Type": "application/json", - }, - }) + headers: { "Content-Type": "application/json" }, + }, + ).then((r) => r.json()) + + // Poll until job is complete + while (true) { + const { autorouting_job: job } = (await fetchWithDebug( + `${serverUrl}/autorouting/jobs/get?autorouting_job_id=${autorouting_job.autorouting_job_id}`, + { method: "POST" }, + ).then((r) => r.json())) as { + autorouting_job: { + autorouting_job_id: string + is_running: boolean + is_started: boolean + is_finished: boolean + has_error: boolean + error: string | null + autorouting_provider: "freerouting" | "tscircuit" + created_at: string + started_at?: string + finished_at?: string + } + } - const resultText = await arRes.text() - // TODO handle errors - const { autorouting_result } = JSON.parse(resultText) - this._asyncAutoroutingResult = autorouting_result - this._markDirty("PcbTraceRender") - }) - } + if (job.is_finished) { + const { autorouting_job_output } = await fetchWithDebug( + `${serverUrl}/autorouting/jobs/get_output?autorouting_job_id=${autorouting_job.autorouting_job_id}`, + { method: "POST" }, + ).then((r) => r.json()) + + this._asyncAutoroutingResult = { + output_pcb_traces: autorouting_job_output.output_pcb_traces, + } + this._markDirty("PcbTraceRender") + break + } + + if (job.has_error) { + throw new Error( + `Autorouting job failed: ${JSON.stringify(job.error)}`, + ) + } + + // Wait before polling again + await new Promise((resolve) => setTimeout(resolve, 100)) + } + }) } updatePcbTraceRender() { @@ -284,9 +344,10 @@ export class Group = typeof groupProps> * or if using a "fullview" or "rip and replace" autorouting mode */ _shouldUseTraceByTraceRouting(): boolean { - // HACK: change when @tscircuit/props provides a spec for the autorouter - // prop - if (this.props.autorouter) return false + const props = this._parsedProps as SubcircuitGroupProps + if (props.autorouter === "auto-local") return true + if (props.autorouter === "sequential-trace") return true + if (props.autorouter) return false return true } } diff --git a/package.json b/package.json index 695887af..ad344ca5 100644 --- a/package.json +++ b/package.json @@ -41,11 +41,11 @@ "@tscircuit/footprinter": "^0.0.89", "@tscircuit/infgrid-ijump-astar": "^0.0.24", "@tscircuit/math-utils": "^0.0.5", - "circuit-json": "^0.0.108", - "circuit-json-to-connectivity-map": "^0.0.17", - "@tscircuit/props": "^0.0.106", + "@tscircuit/props": "^0.0.107", "@tscircuit/schematic-autolayout": "^0.0.6", "@tscircuit/soup-util": "^0.0.41", + "circuit-json": "^0.0.108", + "circuit-json-to-connectivity-map": "^0.0.17", "circuit-to-svg": "0.0.84", "format-si-unit": "^0.0.2", "nanoid": "^5.0.7", diff --git a/tests/components/base-components/renderable-dirty-pattern.test.tsx b/tests/components/base-components/renderable-dirty-pattern.test.tsx index 19a220f9..9e03822a 100644 --- a/tests/components/base-components/renderable-dirty-pattern.test.tsx +++ b/tests/components/base-components/renderable-dirty-pattern.test.tsx @@ -8,7 +8,7 @@ class TestComponent extends Renderable { doInitialSourceRender() { // Test async effect - this._queueAsyncEffect(async () => { + this._queueAsyncEffect("test-async-effect", async () => { await new Promise((resolve) => setTimeout(resolve, 100)) }) } diff --git a/tests/features/__snapshots__/remote-autorouting-4-job-mode-pcb.snap.svg b/tests/features/__snapshots__/remote-autorouting-4-job-mode-pcb.snap.svg new file mode 100644 index 00000000..7cbdb809 --- /dev/null +++ b/tests/features/__snapshots__/remote-autorouting-4-job-mode-pcb.snap.svg @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/tests/features/remote-autorouting-1.test.tsx b/tests/features/remote-autorouting-1.test.tsx index 29802b9a..b616974f 100644 --- a/tests/features/remote-autorouting-1.test.tsx +++ b/tests/features/remote-autorouting-1.test.tsx @@ -1,11 +1,8 @@ import { test, expect } from "bun:test" -import { serve } from "bun" import { getTestFixture } from "../fixtures/get-test-fixture" import { getTestAutoroutingServer } from "tests/fixtures/get-test-autorouting-server" -// This test uses the board autorouter={{ serverUrl: "http://..." }} prop to -// test the remote autorouter -test.skip("remote autorouter with simplified input", async () => { +test("remote-autorouter-1 with legacy solve endpoint", async () => { const { autoroutingServerUrl } = getTestAutoroutingServer() const { circuit } = getTestFixture() @@ -15,9 +12,9 @@ test.skip("remote autorouter with simplified input", async () => { diff --git a/tests/features/remote-autorouting-4-job-mode.test.tsx b/tests/features/remote-autorouting-4-job-mode.test.tsx new file mode 100644 index 00000000..c23886e8 --- /dev/null +++ b/tests/features/remote-autorouting-4-job-mode.test.tsx @@ -0,0 +1,37 @@ +import { test, expect } from "bun:test" +import { getTestFixture } from "../fixtures/get-test-fixture" +import { getTestAutoroutingServer } from "tests/fixtures/get-test-autorouting-server" + +test("remote-autorouter-4 with job mode", async () => { + const { autoroutingServerUrl } = getTestAutoroutingServer() + + const { circuit } = getTestFixture() + + // Create a basic circuit that needs routing + circuit.add( + + + + + , + ) + + await circuit.renderUntilSettled() + + // Verify routing request was made + expect(circuit.selectAll("trace").length).toBeGreaterThan(0) + expect(circuit).toMatchPcbSnapshot(import.meta.path) +}) diff --git a/tests/features/remote-autorouting-5-job-mode-prod.test.tsx b/tests/features/remote-autorouting-5-job-mode-prod.test.tsx new file mode 100644 index 00000000..0d0ca8ed --- /dev/null +++ b/tests/features/remote-autorouting-5-job-mode-prod.test.tsx @@ -0,0 +1,29 @@ +import { test, expect } from "bun:test" +import { getTestFixture } from "../fixtures/get-test-fixture" +import { getTestAutoroutingServer } from "tests/fixtures/get-test-autorouting-server" + +test.skip("remote-autorouter-5 with job mode against production server", async () => { + if (process.env.CI) return + const { circuit } = getTestFixture() + + // Create a basic circuit that needs routing + circuit.add( + + + + + , + ) + + await circuit.renderUntilSettled() + + // Verify routing request was made + expect(circuit.selectAll("trace").length).toBeGreaterThan(0) + expect(circuit).toMatchPcbSnapshot(import.meta.path) +}) diff --git a/tests/fixtures/get-test-autorouting-server.tsx b/tests/fixtures/get-test-autorouting-server.tsx index 1b088da1..68255276 100644 --- a/tests/fixtures/get-test-autorouting-server.tsx +++ b/tests/fixtures/get-test-autorouting-server.tsx @@ -5,6 +5,9 @@ import type { SimpleRouteJson } from "lib/utils/autorouting/SimpleRouteJson" import { getSimpleRouteJsonFromCircuitJson } from "lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson" export const getTestAutoroutingServer = () => { + let currentJobId = 0 + const jobResults = new Map() + const server = serve({ port: 0, fetch: async (req) => { @@ -12,22 +15,26 @@ export const getTestAutoroutingServer = () => { return new Response("Method not allowed", { status: 405 }) } - const body = await req.json() + const url = new URL(req.url) + const endpoint = url.pathname - let simpleRouteJson: SimpleRouteJson | undefined - if (body.input_simple_route_json) { - simpleRouteJson = body.input_simple_route_json as SimpleRouteJson - } else if (body.input_circuit_json) { - simpleRouteJson = getSimpleRouteJsonFromCircuitJson({ - circuitJson: body.input_circuit_json, - }) - } + // Legacy solve endpoint + if (endpoint === "/autorouting/solve") { + const body = await req.json() + let simpleRouteJson: SimpleRouteJson | undefined + + if (body.input_simple_route_json) { + simpleRouteJson = body.input_simple_route_json as SimpleRouteJson + } else if (body.input_circuit_json) { + simpleRouteJson = getSimpleRouteJsonFromCircuitJson({ + circuitJson: body.input_circuit_json, + }) + } - try { if (!simpleRouteJson) { return new Response( JSON.stringify({ - error: { message: "Missing simple_route_json in request body" }, + error: { message: "Missing input data" }, }), { status: 400 }, ) @@ -49,18 +56,77 @@ export const getTestAutoroutingServer = () => { }, }, }), - { - headers: { "Content-Type": "application/json" }, - }, + { headers: { "Content-Type": "application/json" } }, + ) + } + + // New job-based endpoints + if (endpoint === "/autorouting/jobs/create") { + const body = await req.json() + const jobId = `job_${currentJobId++}` + + const simpleRouteJson = getSimpleRouteJsonFromCircuitJson({ + circuitJson: body.input_circuit_json, + }) + + const autorouter = new MultilayerIjump({ + input: simpleRouteJson, + OBSTACLE_MARGIN: 0.2, + }) + + const traces = autorouter.solveAndMapToTraces() + + jobResults.set(jobId, { + is_finished: true, + is_started: true, + is_running: true, + output: { output_pcb_traces: traces }, + }) + + return new Response( + JSON.stringify({ + autorouting_job: { + autorouting_job_id: jobId, + is_running: true, + is_started: true, + }, + }), + { headers: { "Content-Type": "application/json" } }, ) - } catch (e: any) { + } + + if (endpoint === "/autorouting/jobs/get") { + const jobId = url.searchParams.get("autorouting_job_id") + const job = jobResults.get(jobId!) + return new Response( JSON.stringify({ - error: e.message, + autorouting_job: { + autorouting_job_id: jobId, + is_running: job?.is_running ?? false, + is_started: job?.is_started ?? false, + is_finished: job?.is_finished ?? false, + has_error: job?.has_error ?? false, + error: job?.error ?? null, + }, }), - { status: 500 }, + { headers: { "Content-Type": "application/json" } }, ) } + + if (endpoint === "/autorouting/jobs/get_output") { + const jobId = url.searchParams.get("autorouting_job_id") + const job = jobResults.get(jobId!) + + return new Response( + JSON.stringify({ + autorouting_job_output: job?.output, + }), + { headers: { "Content-Type": "application/json" } }, + ) + } + + return new Response("Not found", { status: 404 }) }, }) @@ -69,7 +135,7 @@ export const getTestAutoroutingServer = () => { }) return { - autoroutingServerUrl: `http://localhost:${server.port}/autorouting/solve`, + autoroutingServerUrl: `http://localhost:${server.port}/`, close: () => server.stop(), } } From 6f7c7e5b3d118971ce8a0c8022d28376e7249289 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sun, 1 Dec 2024 23:17:31 +0000 Subject: [PATCH 4/6] v0.0.210 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad344ca5..724e1a2e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@tscircuit/core", "type": "module", - "version": "0.0.209", + "version": "0.0.210", "types": "dist/index.d.ts", "main": "dist/index.js", "module": "dist/index.js", From b04a72aa89b8d04180cd5aa0e76db0aaa92a8b13 Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Mon, 2 Dec 2024 07:46:12 +0800 Subject: [PATCH 5/6] fix prod issues related to GET/POST request differences for autorouting job creation (#374) * fix prod issues related to GET/POST requests * emulate prod --- .../primitive-components/Group/Group.ts | 20 +++++++++++++++---- ...e-autorouting-5-job-mode-prod-pcb.snap.svg | 13 ++++++++++++ .../fixtures/get-test-autorouting-server.tsx | 6 ++++-- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 tests/features/__snapshots__/remote-autorouting-5-job-mode-prod-pcb.snap.svg diff --git a/lib/components/primitive-components/Group/Group.ts b/lib/components/primitive-components/Group/Group.ts index 013ee6e2..72e4ee7e 100644 --- a/lib/components/primitive-components/Group/Group.ts +++ b/lib/components/primitive-components/Group/Group.ts @@ -178,8 +178,14 @@ export class Group = typeof groupProps> // Poll until job is complete while (true) { const { autorouting_job: job } = (await fetchWithDebug( - `${serverUrl}/autorouting/jobs/get?autorouting_job_id=${autorouting_job.autorouting_job_id}`, - { method: "POST" }, + `${serverUrl}/autorouting/jobs/get`, + { + method: "POST", + body: JSON.stringify({ + autorouting_job_id: autorouting_job.autorouting_job_id, + }), + headers: { "Content-Type": "application/json" }, + }, ).then((r) => r.json())) as { autorouting_job: { autorouting_job_id: string @@ -197,8 +203,14 @@ export class Group = typeof groupProps> if (job.is_finished) { const { autorouting_job_output } = await fetchWithDebug( - `${serverUrl}/autorouting/jobs/get_output?autorouting_job_id=${autorouting_job.autorouting_job_id}`, - { method: "POST" }, + `${serverUrl}/autorouting/jobs/get_output`, + { + method: "POST", + body: JSON.stringify({ + autorouting_job_id: autorouting_job.autorouting_job_id, + }), + headers: { "Content-Type": "application/json" }, + }, ).then((r) => r.json()) this._asyncAutoroutingResult = { diff --git a/tests/features/__snapshots__/remote-autorouting-5-job-mode-prod-pcb.snap.svg b/tests/features/__snapshots__/remote-autorouting-5-job-mode-prod-pcb.snap.svg new file mode 100644 index 00000000..e54fc0d0 --- /dev/null +++ b/tests/features/__snapshots__/remote-autorouting-5-job-mode-prod-pcb.snap.svg @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/tests/fixtures/get-test-autorouting-server.tsx b/tests/fixtures/get-test-autorouting-server.tsx index 68255276..ebe83d76 100644 --- a/tests/fixtures/get-test-autorouting-server.tsx +++ b/tests/fixtures/get-test-autorouting-server.tsx @@ -96,7 +96,8 @@ export const getTestAutoroutingServer = () => { } if (endpoint === "/autorouting/jobs/get") { - const jobId = url.searchParams.get("autorouting_job_id") + const body = await req.json() + const jobId = body.autorouting_job_id const job = jobResults.get(jobId!) return new Response( @@ -115,7 +116,8 @@ export const getTestAutoroutingServer = () => { } if (endpoint === "/autorouting/jobs/get_output") { - const jobId = url.searchParams.get("autorouting_job_id") + const body = await req.json() + const jobId = body.autorouting_job_id const job = jobResults.get(jobId!) return new Response( From 71137e3fb0fe02665e55c5ea01273bb7fcde1e05 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sun, 1 Dec 2024 23:46:35 +0000 Subject: [PATCH 6/6] v0.0.211 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 724e1a2e..1712b12b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@tscircuit/core", "type": "module", - "version": "0.0.210", + "version": "0.0.211", "types": "dist/index.d.ts", "main": "dist/index.js", "module": "dist/index.js",