Skip to content

Commit 61f2ac4

Browse files
committed
fix(protocol): tighten the goal state machine and /goal parsing
1 parent 79d7545 commit 61f2ac4

11 files changed

Lines changed: 430 additions & 1032 deletions

File tree

‎packages/client/src/effect/api/api.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ export type SessionGoalUpdateInput = {
13131313
readonly action: "set" | "clear" | "edit" | "pause" | "resume"
13141314
readonly objective?: string | undefined
13151315
readonly expectedRevision?: number | undefined
1316+
readonly expectedGoalID?: SessionGoal.ID | undefined
13161317
}
13171318
export type SessionGoalUpdateOutput = SessionGoal.Snapshot
13181319
export type SessionGoalUpdateOperation<E = never> = (
@@ -1322,6 +1323,8 @@ export type SessionGoalUpdateOperation<E = never> = (
13221323
export type SessionTodoReplaceInput = {
13231324
readonly sessionID: Session.ID
13241325
readonly todos: ReadonlyArray<SessionGoal.TodoInput>
1326+
readonly expectedRevision?: number | undefined
1327+
readonly expectedGoalID?: SessionGoal.ID | undefined
13251328
}
13261329
export type SessionTodoReplaceOutput = void
13271330
export type SessionTodoReplaceOperation<E = never> = (

‎packages/client/src/effect/generated/client.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,12 @@ const EndpointSessionGoalUpdate = (raw: RawClient["server.session"]) => (input:
739739
preserveEffect<SessionGoalUpdateOutput>()(
740740
raw["session.goal.update"]({
741741
params: { sessionID: input["sessionID"] },
742-
payload: { action: input["action"], objective: input["objective"], expectedRevision: input["expectedRevision"] },
742+
payload: {
743+
action: input["action"],
744+
objective: input["objective"],
745+
expectedRevision: input["expectedRevision"],
746+
expectedGoalID: input["expectedGoalID"],
747+
},
743748
}).pipe(
744749
Effect.mapError(mapClientError),
745750
Effect.map((value) => value.data),
@@ -748,9 +753,14 @@ const EndpointSessionGoalUpdate = (raw: RawClient["server.session"]) => (input:
748753

749754
const EndpointSessionTodoReplace = (raw: RawClient["server.session"]) => (input: SessionTodoReplaceInput) =>
750755
preserveEffect<SessionTodoReplaceOutput>()(
751-
raw["session.todo.replace"]({ params: { sessionID: input["sessionID"] }, payload: { todos: input["todos"] } }).pipe(
752-
Effect.mapError(mapClientError),
753-
),
756+
raw["session.todo.replace"]({
757+
params: { sessionID: input["sessionID"] },
758+
payload: {
759+
todos: input["todos"],
760+
expectedRevision: input["expectedRevision"],
761+
expectedGoalID: input["expectedGoalID"],
762+
},
763+
}).pipe(Effect.mapError(mapClientError)),
754764
)
755765

756766
const EndpointSessionMessageGet = (raw: RawClient["server.session"]) => (input: SessionMessageGetInput) =>

‎packages/client/src/promise/generated/client.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ export function make(options: ClientOptions) {
10411041
action: input["action"],
10421042
objective: input["objective"],
10431043
expectedRevision: input["expectedRevision"],
1044+
expectedGoalID: input["expectedGoalID"],
10441045
},
10451046
successStatus: 200,
10461047
declaredStatuses: [400, 401, 404, 409],
@@ -1055,7 +1056,11 @@ export function make(options: ClientOptions) {
10551056
{
10561057
method: "PUT",
10571058
path: `/api/session/${encodeURIComponent(input.sessionID)}/todo`,
1058-
body: { todos: input["todos"] },
1059+
body: {
1060+
todos: input["todos"],
1061+
expectedRevision: input["expectedRevision"],
1062+
expectedGoalID: input["expectedGoalID"],
1063+
},
10591064
successStatus: 204,
10601065
declaredStatuses: [400, 401, 404, 409],
10611066
empty: true,

0 commit comments

Comments
 (0)