From 53e8ef47cc2622b04520469688f7e6937697313b Mon Sep 17 00:00:00 2001 From: Theresa Kamerman Date: Wed, 27 Sep 2023 13:05:11 -0700 Subject: [PATCH 1/4] Add planId to Action definition --- deployment/hasura/metadata/actions.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/hasura/metadata/actions.graphql b/deployment/hasura/metadata/actions.graphql index 025d9c2c8a..dd40b0ea1f 100644 --- a/deployment/hasura/metadata/actions.graphql +++ b/deployment/hasura/metadata/actions.graphql @@ -89,7 +89,7 @@ type Query { } type Query { - schedulingDslTypescript(missionModelId: Int!): DslTypescriptResponse + schedulingDslTypescript(missionModelId: Int!, planId: Int): DslTypescriptResponse } type Query { From 6e5f18e339674d49f403ece994ff21b7b7c2e08a Mon Sep 17 00:00:00 2001 From: Theresa Kamerman Date: Wed, 27 Sep 2023 13:05:59 -0700 Subject: [PATCH 2/4] Fix parser for SchedulingDSLTS --- .../jpl/aerie/scheduler/server/http/SchedulerParsers.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java index cd61ec5acf..328791b352 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java @@ -12,6 +12,7 @@ import static gov.nasa.jpl.aerie.json.BasicParsers.anyP; import static gov.nasa.jpl.aerie.json.BasicParsers.longP; +import static gov.nasa.jpl.aerie.json.BasicParsers.nullableP; import static gov.nasa.jpl.aerie.json.BasicParsers.productP; import static gov.nasa.jpl.aerie.json.BasicParsers.stringP; import static gov.nasa.jpl.aerie.json.Uncurry.tuple; @@ -101,8 +102,8 @@ private static JsonParser> hasura public static final JsonParser> hasuraMissionModelIdActionP = hasuraActionF(productP .field("missionModelId", missionModelIdP) - .optionalField("planId", planIdP) + .optionalField("planId", nullableP(planIdP)) .map( - untuple(HasuraAction.MissionModelIdInput::new), - input -> tuple(input.missionModelId(), input.planId()))); + untuple((missionModelId, planId) -> new HasuraAction.MissionModelIdInput(missionModelId, planId.flatMap($->$))), + input -> tuple(input.missionModelId(), Optional.of(input.planId())))); } From a2a3cfd2c3fac99dae9427cd80c9f041f1e8aae9 Mon Sep 17 00:00:00 2001 From: Theresa Kamerman Date: Wed, 27 Sep 2023 13:07:00 -0700 Subject: [PATCH 3/4] Update name of the SchedulingDSLTS action parser --- .../jpl/aerie/scheduler/server/http/SchedulerBindings.java | 4 ++-- .../jpl/aerie/scheduler/server/http/SchedulerParsers.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerBindings.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerBindings.java index b919f4e13e..bfb4b44280 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerBindings.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerBindings.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Objects; import static gov.nasa.jpl.aerie.scheduler.server.http.ResponseSerializers.*; -import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraMissionModelIdActionP; +import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraSchedulingDSLTypescriptActionP; import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraSpecificationActionP; import static io.javalin.apibuilder.ApiBuilder.*; import gov.nasa.jpl.aerie.json.JsonParser; @@ -116,7 +116,7 @@ private void schedule(final Context ctx) { */ private void getSchedulingDslTypescript(final Context ctx) { try { - final var body = parseJson(ctx.body(), hasuraMissionModelIdActionP); + final var body = parseJson(ctx.body(), hasuraSchedulingDSLTypescriptActionP); final var missionModelId = body.input().missionModelId(); final var planId = body.input().planId(); final var response = this.generateSchedulingLibAction.run(missionModelId, planId); diff --git a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java index 328791b352..21d2b1a770 100644 --- a/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java +++ b/scheduler-server/src/main/java/gov/nasa/jpl/aerie/scheduler/server/http/SchedulerParsers.java @@ -99,7 +99,7 @@ private static JsonParser> hasura /** * parser for a hasura action that accepts a mission model id as its sole input, along with normal hasura session details */ - public static final JsonParser> hasuraMissionModelIdActionP + public static final JsonParser> hasuraSchedulingDSLTypescriptActionP = hasuraActionF(productP .field("missionModelId", missionModelIdP) .optionalField("planId", nullableP(planIdP)) From 7a292b38524ba72978401f4c0faf0cc1d868eec8 Mon Sep 17 00:00:00 2001 From: Theresa Kamerman Date: Wed, 27 Sep 2023 13:23:12 -0700 Subject: [PATCH 4/4] Update GQL --- e2e-tests/src/utilities/gql.ts | 4 ++-- e2e-tests/src/utilities/requests.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e-tests/src/utilities/gql.ts b/e2e-tests/src/utilities/gql.ts index 6bc8c704d6..ac8d4288fe 100644 --- a/e2e-tests/src/utilities/gql.ts +++ b/e2e-tests/src/utilities/gql.ts @@ -185,8 +185,8 @@ const gql = { `, GET_SCHEDULING_DSL_TYPESCRIPT: `#graphql - query GetSchedulingDslTypeScript($missionModelId: Int!) { - schedulingDslTypescript(missionModelId: $missionModelId) { + query GetSchedulingDslTypeScript($missionModelId: Int!, $planId: Int) { + schedulingDslTypescript(missionModelId: $missionModelId, planId: $planId) { reason status typescriptFiles { diff --git a/e2e-tests/src/utilities/requests.ts b/e2e-tests/src/utilities/requests.ts index 7fe1310dd8..f4dea239e2 100644 --- a/e2e-tests/src/utilities/requests.ts +++ b/e2e-tests/src/utilities/requests.ts @@ -278,8 +278,9 @@ const req = { async getSchedulingDslTypeScript( request: APIRequestContext, missionModelId: number, + planId?: number ): Promise { - const data = await req.hasura(request, gql.GET_SCHEDULING_DSL_TYPESCRIPT, { missionModelId: missionModelId }); + const data = await req.hasura(request, gql.GET_SCHEDULING_DSL_TYPESCRIPT, { missionModelId: missionModelId, planId: planId }); const { schedulingDslTypescript } = data; return schedulingDslTypescript; },