@objectstack/plugin-approvals 15.1.1 → 16.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/plugin-approvals@15.1.1 build /home/runner/work/framework/framework/packages/plugins/plugin-approvals
2
+ > @objectstack/plugin-approvals@16.0.0-rc.1 build /home/runner/work/framework/framework/packages/plugins/plugin-approvals
3
3
  > tsup --config ../../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- CJS dist/index.js 123.99 KB
14
- CJS dist/index.js.map 220.47 KB
15
- CJS ⚡️ Build success in 211ms
16
- ESM dist/index.mjs 122.33 KB
17
- ESM dist/index.mjs.map 219.27 KB
18
- ESM ⚡️ Build success in 257ms
13
+ ESM dist/index.mjs 156.89 KB
14
+ ESM dist/index.mjs.map 275.84 KB
15
+ ESM ⚡️ Build success in 231ms
16
+ CJS dist/index.js 158.72 KB
17
+ CJS dist/index.js.map 277.08 KB
18
+ CJS ⚡️ Build success in 235ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 32099ms
21
- DTS dist/index.d.mts 397.05 KB
22
- DTS dist/index.d.ts 397.05 KB
20
+ DTS ⚡️ Build success in 21940ms
21
+ DTS dist/index.d.mts 418.30 KB
22
+ DTS dist/index.d.ts 418.30 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,173 @@
1
1
  # @objectstack/plugin-approvals
2
2
 
3
+ ## 16.0.0-rc.1
4
+
5
+ ### Minor Changes
6
+
7
+ - e412fb6: feat(approvals): declare file attachments on approve/reject decisions
8
+
9
+ The declared `approval_approve` / `approval_reject` actions on
10
+ `sys_approval_request` gain an optional multi-file `attachments` param
11
+ (`type: 'file'`, `multiple`). The console renders `type:'file'` action params
12
+ through the shared upload widget (objectui ADR-0059) and POSTs the resolved
13
+ `attachments: string[]`, so a reviewer can attach supporting files to a
14
+ decision through the generic declared-action dialog — letting the approvals
15
+ inbox retire its hand-wired attachment composer (objectui#2698).
16
+
17
+ Purely additive metadata: the decision route already forwards
18
+ `body.attachments` to `ApprovalService.decide`, and the
19
+ `sys_approval_action.attachments` column (file, multiple) already persists them
20
+ (#3266/#3274). No service or route change.
21
+
22
+ - 8efa395: feat(approvals): server-computed `viewer` capability for precise decision-action gating
23
+
24
+ `getRequest` / `listRequests` now attach a per-viewer block —
25
+ `viewer: { can_act, is_submitter }` — computed from the caller's context
26
+ (`ApprovalRequestRow.viewer`):
27
+
28
+ - `can_act` — the caller is a _current pending approver_ (their user id is in the
29
+ request's resolved `pending_approvers` while it is still `pending`). This is
30
+ the same check the decision methods authorize with, so it already reflects
31
+ position/team/manager resolution — strictly more accurate than a client-side
32
+ identity guess.
33
+ - `is_submitter` — the caller submitted the request.
34
+
35
+ The declared decision actions on `sys_approval_request` now gate on it: approver
36
+ actions (approve/reject/reassign/send-back/request-info) use
37
+ `record.viewer.can_act`; submitter levers (remind/recall/resubmit) use
38
+ `record.viewer.is_submitter`. Previously approver actions only trimmed the
39
+ non-pending case, so a submitter viewing their own pending request saw buttons
40
+ they couldn't use (the backend 403'd); a position-addressed approver could be
41
+ wrongly hidden by the old client heuristic. Where `viewer` is absent (a row
42
+ surfaced outside a service read with a user context), the predicate fails closed.
43
+
44
+ ### Patch Changes
45
+
46
+ - 62a2117: **Split the overloaded `managedBy: 'system'` bucket with an explicit `engine-owned` value (ADR-0103 addendum, #3343).** ADR-0103 deferred the enum split ("revisitable later as a rename") because a new `managedBy` value would fall through to the fully-editable `platform` default on deployed Console clients. Both reasons against it are now retired — the server-side write guard / `apiMethods` reconciliation / `/me/permissions` clamp make that fallthrough cosmetic (the write is rejected regardless of what the client renders), and objectui#2712 closed the UI union — so v16 lands it, **additively**.
47
+
48
+ - **New enum value `engine-owned`** with the same all-locked default affordance row as `system` (`create/import/edit/delete: false`, `exportCsv: true`). It joins `ENGINE_OWNED_BUCKETS` (the engine write guard) and `GUARDED_WRITE_BUCKETS` (the `/me/permissions` clamp); the guard, `reconcileManagedApiMethods`, and the clamp mechanisms are unchanged — `engine-owned` is an explicit member of the set they already covered by resolved affordance.
49
+ - **20 objects relabelled `system → engine-owned`** — the ones the engine owns end to end and that declared no write-opening `userActions` (the metadata store, jobs, approval runtime rows, sharing rows, `sys_automation_run`, the messaging delivery/receipt pipeline, `sys_secret`, settings). One-line, behaviour-identical per object.
50
+ - **8 admin/user-writable objects keep `managedBy: 'system'`** (the RBAC link tables, `sys_user_preference`, `sys_approval_delegation`, the messaging config grids) — `system` now reads as "engine-managed schema, writable via `userActions`".
51
+
52
+ Behaviour-, enforcement- and wire-identical: resolved affordances, the guard verdict, the 405 `apiMethods` reconciliation, and the permissions clamp are the same before and after — this is a self-documenting relabel, not a policy change. No data migration (`managedBy` is schema metadata) and no code branches on the `'system'` literal. Retiring the overloaded `system` entirely (moving the 8 writable objects to a dedicated bucket) is a breaking rename deferred to v17.
53
+
54
+ - Updated dependencies [6289ec3]
55
+ - Updated dependencies [8efa395]
56
+ - Updated dependencies [bfa3c3f]
57
+ - Updated dependencies [7125007]
58
+ - Updated dependencies [62a2117]
59
+ - Updated dependencies [06ff734]
60
+ - @objectstack/spec@16.0.0-rc.1
61
+ - @objectstack/platform-objects@16.0.0-rc.1
62
+ - @objectstack/formula@16.0.0-rc.1
63
+ - @objectstack/metadata-core@16.0.0-rc.1
64
+ - @objectstack/core@16.0.0-rc.1
65
+
66
+ ## 16.0.0-rc.0
67
+
68
+ ### Minor Changes
69
+
70
+ - 3a18b60: feat(approvals): rename the `role` approver type to `org_membership_level` (#3133)
71
+
72
+ `ApproverType.role` was the last platform surface projecting the reserved word
73
+ "role" (ADR-0090 D3). It is not covered by D3's better-auth exception: that
74
+ exception protects better-auth's own `sys_member.role` **column**, which we do
75
+ not own — `ApproverType` is our own enum, an authoring surface, and D3 mandates
76
+ that the projection of that concept is spelled `org_membership_level` and
77
+ labelled "organization membership", **never "role"**.
78
+
79
+ The sentence licensing the leak was also false: ADR-0090 D3 claims
80
+ `sys_member.role` is "already relabelled `org_membership_level` in the platform
81
+ projection", but `org_membership_level` existed nowhere in the codebase and
82
+ ADR-0057 D7 lists that relabel under "Deferred (evidence-gated, P4)". The
83
+ projection never landed, so the word reached authors.
84
+
85
+ The name manufactured a real, silent failure — "hotcrm class": every other
86
+ surface renamed to `position` (`sys_role`, `ShareRecipientType.role`,
87
+ `ctx.roles[]`), so `{ type: 'role', value: 'sales_manager' }` reads as the
88
+ legacy spelling of a position. It resolves against the membership tier, finds
89
+ no member row, falls back to an inert `role:sales_manager` literal, and the
90
+ request waits forever on an approver that cannot exist.
91
+
92
+ - **spec**: `ApproverType` gains `org_membership_level`; `role` stays as a
93
+ deprecated alias for one window (a published 15.x flow keeps loading) with
94
+ `DEPRECATED_APPROVER_TYPES` + `canonicalApproverType()` as the single source
95
+ for the mapping. Removed in the next major.
96
+ - **plugin-approvals**: resolves on the canonical type and warns on the
97
+ deprecated spelling. The `type:value` fallback literal keeps the **authored**
98
+ spelling — stored `sys_approval_approver` rows and `pending_approvers` slots
99
+ from 15.x carry `role:<v>`, and rewriting it would orphan them.
100
+ - **lint**: `approval-role-not-membership-tier` → `approval-approver-not-membership-tier`
101
+ (the rule id carried the reserved word too), plus a new
102
+ `approval-approver-type-deprecated`. The two are mutually exclusive: a bad
103
+ _value_ wins, because prescribing `org_membership_level` for a position name
104
+ would be wrong advice — the fix there is `position`.
105
+
106
+ Authoring `type: 'role'` keeps working and now says so out loud. Rewrite it as
107
+ `org_membership_level`; if the value is an org position, the fix is `position`.
108
+
109
+ ### Patch Changes
110
+
111
+ - 22013aa: **Split the overloaded `managedBy: 'system'` bucket into engine-owned vs. admin-writable, and enforce engine-owned writes (ADR-0103, #3220).** The `system` bucket conflated two incompatible write policies: rows a platform service owns end to end (never user-written), and platform-defined schema whose rows are legitimately admin/user-writable. It carried the same all-false affordance row as `better-auth`/`append-only` but, unlike `better-auth`, had no engine enforcement — a wildcard admin could raw-write these rows through the generic data API (ADR-0049 gap).
112
+
113
+ Rather than add a new `managedBy` enum value (which would fall through to fully-editable `platform` defaults on already-deployed Console clients), the write policy is now the **resolved affordance** (`resolveCrudAffordances` = bucket default + `userActions`), and _engine-owned_ is defined as a `system`/`append-only` object that grants no write:
114
+
115
+ - **Writable set declares `userActions`** — the RBAC link tables (`sys_user_position`, `sys_user_permission_set`, `sys_position_permission_set`), `sys_user_preference`, `sys_approval_delegation`, and the messaging config grids (`sys_notification_preference` / `…_subscription` / `…_template`) now declare `userActions: { create, edit, delete: true }`. The affordance is a declaration only — the `DelegatedAdminGate` / RLS / permission sets remain the authz.
116
+ - **Engine-owned objects locked to reads** — `apiMethods: ['get','list']` added where absent (jobs, notifications, approval request/approver/token/action, `sys_record_share`, `sys_automation_run`, mail/settings/secret audit, the messaging delivery pipeline). `sys_secret` is explicitly read-locked (an empty `apiMethods` array fails open).
117
+ - **`sys_import_job`** stays engine-owned: the REST import route now writes its job rows `isSystem`-elevated (attribution preserved via the explicit `created_by` stamp) and the object is locked to `['get','list']`.
118
+ - **New engine write guard** (`assertEngineOwnedWriteAllowed`, plugin-security) fail-closed rejects user-context generic writes to engine-owned `system`/`append-only` objects, keyed off the resolved affordance; `isSystem` and context-less engine/service writes bypass by construction. Wired into the security middleware alongside the other data-layer gates.
119
+ - **`reconcileManagedApiMethods`** (objectql registry) now runs for **every** managed bucket, not just `better-auth`: any advertised write verb an object's resolved affordances forbid is stripped at registration with a warning (the drift backstop, ADR-0049).
120
+ - **`/me/permissions` clamp** (plugin-hono-server) now clamps `system`/`append-only` as well as `better-auth`, so the client hint reflects `permission ∩ guard`.
121
+
122
+ **Potentially breaking:** a downstream/third-party `system` object that advertised generic write verbs relying on today's fail-open behaviour will have those verbs stripped (with a warning) and user-context generic writes to it rejected. Declare `userActions` opening the verbs the object legitimately takes from a user context. `better-auth` keeps plugin-auth's identity write guard unchanged; the row-level `managed_by` provenance vocabulary (ADR-0066) is a different axis and is untouched.
123
+
124
+ - Updated dependencies [f972574]
125
+ - Updated dependencies [22013aa]
126
+ - Updated dependencies [3ad3dd5]
127
+ - Updated dependencies [3a18b60]
128
+ - Updated dependencies [a8aa34c]
129
+ - Updated dependencies [e057f42]
130
+ - Updated dependencies [a3823b2]
131
+ - Updated dependencies [bc65105]
132
+ - Updated dependencies [43a3efb]
133
+ - Updated dependencies [524696a]
134
+ - Updated dependencies [6b51346]
135
+ - Updated dependencies [80273c8]
136
+ - Updated dependencies [5e3301d]
137
+ - Updated dependencies [dd9f223]
138
+ - Updated dependencies [46e876c]
139
+ - Updated dependencies [5f05de2]
140
+ - Updated dependencies [021ba4c]
141
+ - Updated dependencies [158aa14]
142
+ - Updated dependencies [d2723e2]
143
+ - Updated dependencies [fefcd54]
144
+ - Updated dependencies [beaf2de]
145
+ - Updated dependencies [06cb319]
146
+ - Updated dependencies [369eb6e]
147
+ - Updated dependencies [b659111]
148
+ - Updated dependencies [5754a23]
149
+ - Updated dependencies [6c270a6]
150
+ - Updated dependencies [290e2f0]
151
+ - Updated dependencies [668dd17]
152
+ - Updated dependencies [8abf133]
153
+ - Updated dependencies [e0859b1]
154
+ - Updated dependencies [04ecd4e]
155
+ - Updated dependencies [4d5a892]
156
+ - Updated dependencies [16cebeb]
157
+ - Updated dependencies [86d30af]
158
+ - Updated dependencies [8923843]
159
+ - Updated dependencies [ea32ec7]
160
+ - Updated dependencies [a2795f6]
161
+ - Updated dependencies [f16b492]
162
+ - Updated dependencies [4b6fde8]
163
+ - Updated dependencies [2018df9]
164
+ - Updated dependencies [fc5a3a2]
165
+ - @objectstack/spec@16.0.0-rc.0
166
+ - @objectstack/platform-objects@16.0.0-rc.0
167
+ - @objectstack/core@16.0.0-rc.0
168
+ - @objectstack/formula@16.0.0-rc.0
169
+ - @objectstack/metadata-core@16.0.0-rc.0
170
+
3
171
  ## 15.1.1
4
172
 
5
173
  ### Patch Changes