Skip to content

Commit e331c19

Browse files
committed
fix(protocol): tighten the goal state machine and /goal parsing
1 parent 9406ac6 commit e331c19

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
@@ -741,7 +741,12 @@ const EndpointSessionGoalUpdate = (raw: RawClient["server.session"]) => (input:
741741
preserveEffect<SessionGoalUpdateOutput>()(
742742
raw["session.goal.update"]({
743743
params: { sessionID: input["sessionID"] },
744-
payload: { action: input["action"], objective: input["objective"], expectedRevision: input["expectedRevision"] },
744+
payload: {
745+
action: input["action"],
746+
objective: input["objective"],
747+
expectedRevision: input["expectedRevision"],
748+
expectedGoalID: input["expectedGoalID"],
749+
},
745750
}).pipe(
746751
Effect.mapError(mapClientError),
747752
Effect.map((value) => value.data),
@@ -750,9 +755,14 @@ const EndpointSessionGoalUpdate = (raw: RawClient["server.session"]) => (input:
750755

751756
const EndpointSessionTodoReplace = (raw: RawClient["server.session"]) => (input: SessionTodoReplaceInput) =>
752757
preserveEffect<SessionTodoReplaceOutput>()(
753-
raw["session.todo.replace"]({ params: { sessionID: input["sessionID"] }, payload: { todos: input["todos"] } }).pipe(
754-
Effect.mapError(mapClientError),
755-
),
758+
raw["session.todo.replace"]({
759+
params: { sessionID: input["sessionID"] },
760+
payload: {
761+
todos: input["todos"],
762+
expectedRevision: input["expectedRevision"],
763+
expectedGoalID: input["expectedGoalID"],
764+
},
765+
}).pipe(Effect.mapError(mapClientError)),
756766
)
757767

758768
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
@@ -1043,6 +1043,7 @@ export function make(options: ClientOptions) {
10431043
action: input["action"],
10441044
objective: input["objective"],
10451045
expectedRevision: input["expectedRevision"],
1046+
expectedGoalID: input["expectedGoalID"],
10461047
},
10471048
successStatus: 200,
10481049
declaredStatuses: [400, 401, 404, 409],
@@ -1057,7 +1058,11 @@ export function make(options: ClientOptions) {
10571058
{
10581059
method: "PUT",
10591060
path: `/api/session/${encodeURIComponent(input.sessionID)}/todo`,
1060-
body: { todos: input["todos"] },
1061+
body: {
1062+
todos: input["todos"],
1063+
expectedRevision: input["expectedRevision"],
1064+
expectedGoalID: input["expectedGoalID"],
1065+
},
10611066
successStatus: 204,
10621067
declaredStatuses: [400, 401, 404, 409],
10631068
empty: true,

0 commit comments

Comments
 (0)