From ef7bb1a93dc655ac024517df6c4e6039cb3c9e01 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 11:25:02 +0000 Subject: [PATCH] feat(spec): ApprovalRequestRow declares current_step_label beside step_label The declared sys_approval_request column's own name for the step's label, so a page bound to sys_approval_request can list the step by its label instead of by current_step, the node's machine id. step_label stays, so no reader moves. Optional member of a TypeScript interface: no runtime accept set changes. Claude-Session: https://claude.ai/code/session_019oFY6Hi35J7atvgVFnmoaK Co-authored-by: Claude --- .../24309-approval-current-step-label.md | 11 ++++ .../src/contracts/approval-service.test.ts | 53 +++++++++++++++++++ .../spec/src/contracts/approval-service.ts | 14 +++++ 3 files changed, 78 insertions(+) create mode 100644 .changeset/24309-approval-current-step-label.md diff --git a/.changeset/24309-approval-current-step-label.md b/.changeset/24309-approval-current-step-label.md new file mode 100644 index 00000000000..2f43e681423 --- /dev/null +++ b/.changeset/24309-approval-current-step-label.md @@ -0,0 +1,11 @@ +--- +"@objectstack/spec": minor +--- + +feat(spec): `ApprovalRequestRow` declares `current_step_label`, the `sys_approval_request` column's own name for the step's label + +Clause-②: yes (widening) + +- **The member.** `ApprovalRequestRow` (`@objectstack/spec/contracts`) gains an optional `current_step_label?: string` beside `step_label`. It names the declared `sys_approval_request.current_step_label` column: the Approval node's authored label as it stood when the request reached the step. A page bound to `sys_approval_request` names the object's declared fields, and `step_label` is not one, so a served row that carries this member lets such a page list the step by its label instead of by `current_step`, the node's machine id. +- **Nothing moves.** `step_label` stays, at the same shape and with the same value, so no reader changes. The member is optional, so every existing implementer and every row built without it still conforms. It is a member of a TypeScript interface: no Zod schema and no runtime accept set changes. +- **Its producer.** `@objectstack/plugin-approvals`' request read mapping is the producer; serving the member there is that package's own change. diff --git a/packages/spec/src/contracts/approval-service.test.ts b/packages/spec/src/contracts/approval-service.test.ts index 39fc16877a0..3c233d3b4bb 100644 --- a/packages/spec/src/contracts/approval-service.test.ts +++ b/packages/spec/src/contracts/approval-service.test.ts @@ -110,6 +110,59 @@ describe('ApprovalActionRow.acted_as — the slot an approval action was taken a }); }); +// --------------------------------------------------------------------------- +// [#24309] `ApprovalRequestRow.current_step_label` — the step's label under the +// declared `sys_approval_request` column's own name, beside `step_label`. +// +// A page bound to `sys_approval_request` names the object's declared fields, +// and `step_label` is not one, so the row declares the column's own name. The +// pins hold what the card decided: the member is OPTIONAL and a STRING (the +// column is a text field, and `step_label` carries the same value at the same +// shape), and `step_label` stays, so no reader moves. Same optionality-alias +// reasoning as the `acted_as` block above. +// --------------------------------------------------------------------------- + +/** Optional: a row may omit it. A required member turns this alias red. */ +export type CurrentStepLabelIsOptional = Assert< + {} extends Pick ? true : false +>; + +/** A plain string label — not nullable, not an object. */ +export type CurrentStepLabelIsAString = Assert>; + +/** `step_label` stays beside it, at the same shape: no reader moves. */ +export type StepLabelStays = Assert>; + +describe('ApprovalRequestRow.current_step_label — the step label under the declared column name', () => { + it('is optional and string-typed: a row without it still conforms, and one with it reads back', () => { + const read = (row: ApprovalRequestRow): string | undefined => row.current_step_label; + + expectTypeOf().toEqualTypeOf(); + + // The shape a producer that does not serve it returns: no member at all. + // This literal failing to compile is the regression. + const withoutLabel: ApprovalRequestRow = { + id: 'req_1', + process_name: 'flow:expense_review', + object_name: 'expense', + record_id: 'rec_1', + status: 'pending', + current_step: 'approve_step', + }; + expect(read(withoutLabel)).toBeUndefined(); + + // The machine id and both label spellings side by side, each in its own member. + const withLabel: ApprovalRequestRow = { + ...withoutLabel, + step_label: 'Manager Review', + current_step_label: 'Manager Review', + }; + expect(read(withLabel)).toBe('Manager Review'); + expect(withLabel.step_label).toBe('Manager Review'); + expect(withLabel.current_step).toBe('approve_step'); + }); +}); + // --------------------------------------------------------------------------- // [#15389] `continueRestoredRun` — the approvals half of the operator repair // pair, declared on the contract. diff --git a/packages/spec/src/contracts/approval-service.ts b/packages/spec/src/contracts/approval-service.ts index 26f0fb6bc3d..e1e2e9274c2 100644 --- a/packages/spec/src/contracts/approval-service.ts +++ b/packages/spec/src/contracts/approval-service.ts @@ -221,6 +221,20 @@ export interface ApprovalRequestRow { process_label?: string; /** Human label of the approval step / node (e.g. "Manager Review"). */ step_label?: string; + /** + * The step's label under the declared column's own name: + * `sys_approval_request.current_step_label`, the Approval node's authored + * label as it stood when the request reached the step (the value + * {@link ApprovalRequestRow.step_label} carries). Served so a page bound to + * `sys_approval_request` can list the step by its label. Such a page names + * the object's declared fields, and `step_label` is not one, so without this + * member it can list only `current_step`, the node's machine id. + * + * Declared ahead of its producer: plugin-approvals' `rowFromRequest` serves + * it from #24281 on, the card this declaration unblocks. `step_label` stays + * for its existing readers. + */ + current_step_label?: string; /** Display name of the target record (its name/title field), when resolvable. */ record_title?: string; /** Display name of the submitter (`sys_user.name`), when resolvable. */