Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/24309-approval-current-step-label.md
Original file line number Diff line number Diff line change
@@ -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.
53 changes: 53 additions & 0 deletions packages/spec/src/contracts/approval-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApprovalRequestRow, 'current_step_label'> ? true : false
>;

/** A plain string label — not nullable, not an object. */
export type CurrentStepLabelIsAString = Assert<Eq<ApprovalRequestRow['current_step_label'], string | undefined>>;

/** `step_label` stays beside it, at the same shape: no reader moves. */
export type StepLabelStays = Assert<Eq<ApprovalRequestRow['step_label'], ApprovalRequestRow['current_step_label']>>;

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<ApprovalRequestRow['current_step_label']>().toEqualTypeOf<string | undefined>();

// 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.
Expand Down
14 changes: 14 additions & 0 deletions packages/spec/src/contracts/approval-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading