Skip to content

Commit 16a96ac

Browse files
feat(rest): Change Owner endpoint, single and bulk, gated by the object switch (#36154)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XTCm3Tiq5siADJ7ktfMSAiu)_ Fixes #35402 Clause-②: yes (widening): new error code `CHANGE_OWNER_DISABLED` (403); new routes `POST /api/v1/data/:object/:id/change-owner` and `POST /api/v1/data/:object/change-owner`; new client methods `data.changeOwner` and `data.changeOwnerMany`. Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:本卡用户无感;它提供改负责人的服务端操作(单条和批量),界面按钮由后续的界面卡接上。 - 为什么做:改负责人三张卡的第二张,落实你定的「专门的改负责人操作,按对象开关开放」。 - 出错会怎样:只影响新增的改负责人请求;普通编辑和导入改负责人的规则不变,可以直接撤回。 - 要你做什么:无。 ## What changes Two new doors under the data surface. Both run as the caller, and both read the object switch from #35401 first. - `POST /api/v1/data/:object/:id/change-owner` with `{ ownerId | queue, notify? }` hands one record to a person, or moves it into an ownership queue (ADR-0142). It answers `{ object, id, ownerId, queue?, notified }`. - `POST /api/v1/data/:object/change-owner` with `{ ids, ownerId | queue, notify? }` does the same for up to 500 ids, one by-id update per row. It answers the #30205 report shape (`updated`, `failed`, `failures[]` with each row's id, code and sentence) plus the target and `notified`. Every row that did not move is listed; none is skipped or sampled. Order of checks, per request: 1. The authenticated-caller floor, the closed query set (no parameters), and the object's API exposure for `update`: the same gates every `/data` write passes. 2. The object switch. An object the platform gives no reassignable owner, or whose `userActions.transfer` is off (explicitly, or by the `controlled_by_parent` default), is refused as a whole with `403 CHANGE_OWNER_DISABLED`, whoever asks, a `modifyAllRecords` holder included, before any read or write. 3. The target. A person must be one the caller can read, and not banned (the hand-over's own check, now shared as `assertAssignableUser`). The check follows the write path's rule for a user reference (#29029): a user the caller cannot read answers as one that does not exist (`404`, `reference_not_found`), on Change Owner and on the hand-over alike. A queue target needs the object to carry the `queue` column. 4. Each record goes through the ordinary engine update under the caller's context. So the owner guard in the security plugin decides it as it decides a hand edit of `owner_id`: edit on the record plus `allowTransfer` or `modifyAllRecords`, and the ADR-0142 queue admissions. Without the grant the answer is the data door's own `403 PERMISSION_DENIED` and the owner stays. There is deliberately no second permission check in the endpoint. The write gate is the same verdict the explain engine's record-level `transfer` operation reports, so a pre-check would only restate it. `notify: true` sends the new owner one notification under the new `record.owner_changed` topic, naming the record (or the count, for a bulk move). Its title rides `keyedText` (`messages.recordOwnerChangedTitle` / `messages.recordsOwnerChangedTitle`, the object's label itself keyed as `objects.<object>.label`), so it renders in the new owner's own language at delivery; the English sentence is the literal delivered when no entry renders. It is skipped for a queue target, when the caller is the new owner, when nothing moved, or when no messaging service is mounted. A failing send never fails the transfer; `notified` reports what happened. A plain `owner_id` update is untouched: the switch gates this action only, so imports and hooks still need only the transfer grant (ruling 7000907189 point 2). Package by package: - `@objectstack/core`: `changeRecordOwner`, `changeRecordsOwner`, `changeOwnerOffReason`, `changeOwnerOffRefusal`, `CHANGE_OWNER_DISABLED`, `CHANGE_OWNER_NOTIFICATION_TOPIC`, `CHANGE_OWNER_NOTIFICATION_TEXT`, and `assertAssignableUser` (extracted from the assigned-work hand-over; it now reads the target through the caller's own read first, as above). - `@objectstack/rest`: the `change-owner-routes.ts` registrar, its two route-ledger rows (`data-actions` family, sdk disposition), and its entries in the REST censuses (query slots, docblock floors, objectQL slot consumers, write-echo dispositions, hook-sentence rows, route envelope). - `@objectstack/client`: `data.changeOwner` and `data.changeOwnerMany`. - `@objectstack/spec`: `CHANGE_OWNER_DISABLED` in the error-code ledger, under `@objectstack/core` because core stamps it (the provenance gate requires the stamping package's key). The `userActions.transfer` liveness row is now `live`. Two docblocks (`user-action-transfer.ts`, `object.zod.ts`) now say the endpoint reads the switch instead of "nothing reads it yet": prose only. - `@objectstack/service-messaging`: `record.owner_changed` in the platform topic list, and the notice's two title entries in every shipped locale of its `messages` bundle (the `en` entries are core's own English, so they cannot drift). - Docs: `content/docs/api/data-api.mdx` documents both routes, their bodies, the 500 cap, the per-row report and `CHANGE_OWNER_DISABLED`. The row cap is the existing `USER_WORK_TRANSFER_ROW_CAP` (500), as the seat asked; no new constant. ## Tests - `packages/core/src/security/change-record-owner.test.ts`: off and ineligible objects (switched off, `controlled_by_parent` default, `ownership: 'org'`, a `sys_*` object, a `managedBy` object) refused for single and bulk with no engine call; the opted-in detail; unknown object 404; person and queue writes; queue on an object with no `queue` column 400; `PERMISSION_DENIED` and `RECORD_NOT_FOUND` passthrough; banned and unknown targets; a target the caller cannot read, active or banned, answers as unknown and its ban is never read (single, bulk, and the hand-over); the mixed bulk report; empty, over-cap and duplicate ids refused before any write; notify cases. - `packages/rest/src/change-owner-routes.test.ts`: the HTTP faces, every refusal pinned by status and code in the nested envelope, and the closed body. - `packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts`: the real showcase, real security plugin, real sharing, on the `private` `showcase_private_note`. ## Acceptance notes The rulings, quoted from #35315. 7000556646: "**Chosen: a dedicated Change Owner action, the Salesforce / Dynamics 365 shape. Not a plain editable owner field.**" … "**Sharing.** Sharing is recomputed on transfer. The previous owner's access follows the sharing rules, not the old ownership." 7000907189, point 2: "**The switch gates the dedicated action, not the raw write.** The Change Owner endpoint (single, bulk and cascade) refuses an object whose switch is off. A plain `owner_id` update stays governed by `allowTransfer` alone, so import mappings and hooks are unaffected. An author who wants a hard block declares `owner_id` `readonly`." 7000907189, Bulk: "The bulk form issues per-row by-id updates under the caller's context and reports per-row failures. A predicate update carrying `owner_id` has no pre-image and is refused by the owner guard (`security-plugin-authz-middleware.ts` ~1778–1783). Reuse the #30205 report shape and row cap (`UserWorkTransferReport`, `USER_WORK_TRANSFER_ROW_CAP`)." Done-when, each pinned by code and status: | Done-when | Answer | Where | |---|---|---| | Ineligible or switched-off object, even for `modifyAllRecords` | `403 CHANGE_OWNER_DISABLED`, single and bulk, owner unchanged | core unit, rest, dogfood (admin on `showcase_invoice_line`) | | Edit without transfer | `403 PERMISSION_DENIED`, owner unchanged; in bulk, the row's failure code | rest, dogfood | | Mixed bulk batch | `200` with a per-row report. Dogfood: `updated: 2, failed: 1`, the other member's note listed as `RECORD_NOT_FOUND`. Core and rest: one moves, a `PERMISSION_DENIED` row and a `RECORD_NOT_FOUND` row listed | core unit, rest, dogfood | | Queue target (ADR-0142) | `200`, `owner_id: null, queue: note_triage`; refused `403 PERMISSION_DENIED` without the grant | core unit, dogfood | | Notify | one `sys_notification` event for this record, delivered to the new owner's inbox alone; title keyed | core unit, dogfood | **Measured, not assumed:** on the showcase, after alice (holding the transfer grant) hands her private note to bob: - `created_by` stays alice; `owner_id` is bob. - bob: `GET` 200, `PATCH` 200. - alice: `GET` 404, `PATCH` 404. The `private` OWD gives her no row access once she is not the owner, and being the creator, which the `owner_only_writes` floor keys on, does not give it back. Read from the code, not measured separately: the floor narrows writes on rows the caller can already reach and grants no access of its own. Cascade (ruling point 4) is phase 2 and not here. Known and left as they are: a Change Owner to the record's current owner is written like any other and counted as moved; the two route-ledger rows carry no `responseSchema` (the client's result types are written by hand, as for the hand-over); no pin yet for a grant holder who can read a record but not edit it (the owner guard decides it as for a `PATCH`). Prior rulings read: change,owner,server,single,bulk,endpoint,gated,object,switch,per-row,report → 349 hits; ADR-0027 Decision §12, ADR-0081 Decision §3, ADR-0139 D4, ADR-0029 D3, ADR-0029 D9.5, ADR-0057 D9, ADR-0061 D2, ADR-0071 Decision §1, ADR-0093 D7; thread: none; repo: objectstack-ai/objectstack Both counts: 349 ADR hits by keyword, 9 decisions surfaced, 0 bearing on this change (they match on words like "change", "object" and "switch"); the rulings this change follows are the two #35315 comments above. ## Verification Read first: `packages/core/src/security/change-record-owner.ts` (the order of checks and the change set), then `packages/rest/src/change-owner-routes.ts` (the refusal envelope), then the dogfood file's MEASURED case. Two-minute check: `pnpm --filter @objectstack/dogfood exec vitest run test/change-owner-endpoint.dogfood.test.ts` after a dogfood closure build. Expect 6 of 6 passing. <details><summary>Local runs</summary> On 06b053c: - core `vitest run` (full): Test Files 164 passed, Tests 3810 passed. - rest `vitest run` (full): 8 census failures on the first run, each naming the new module; fixed and re-run: Test Files 7 passed, Tests 960 passed. - spec error-code ledger tests 36/36; rest ledger conformance 23/23; client URL and ledger coverage 12/12; service-messaging full 1060/1060. - typecheck: core, rest, client, service-messaging clean. - Derived local gates (`dispatch-gates --commands`, 127): failures found and fixed: `check:docs`, `check:liveness`, `check:dispatcher-error-vocabulary`, `check:engine-double-contract`; all exit 0 on re-run. Not measurable here: `check-plugin-teardown-shape --self-test` (shallow clone), `check:dual-build-cjs-loads` and `check:i18n` (whole-repo build); left to CI. Review round 1 (L1 7068420281, contract 7068497336), on the commits after a8787f4: - core `src/security` 75 files, 1455 tests passed; the target-read pins fail with the caller read removed (ablation: 3 failed) and pass with it. - rest `user-work-routes`, `change-owner-routes`, hook-sentence ledger: 730 passed. - service-messaging translations + keyed notification text: 29 passed. - dogfood `change-owner-endpoint.dogfood.test.ts`: 6 of 6 (lock VERDICT command-exit 0). - `check:where-matcher`, `check:test-source-alias`, `check:keyed-text-bounds`, `check:i18n-stale-fill`, `check:liveness`, `check:doc-authoring`, `check:doc-route-spelling` exit 0. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi)_ https://claude.ai/code/session_01FEkQ5pJZvcko4CsCLefrvi <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5pJZvcko4CsCLefrvi --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ab2c82 commit 16a96ac

31 files changed

Lines changed: 1833 additions & 49 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/core': patch
3+
'@objectstack/rest': patch
4+
'@objectstack/client': patch
5+
'@objectstack/spec': patch
6+
'@objectstack/service-messaging': patch
7+
---
8+
9+
feat(rest): Change Owner endpoint — hand one record or a list of records to another owner, on objects that offer the action
10+
11+
Clause-②: yes (widening)
12+
Metadata-protocol: none
13+
14+
Two new doors under the data surface, both run as the caller:
15+
16+
- `POST /api/v1/data/:object/:id/change-owner` with `{ ownerId | queue, notify? }` hands one record to a person or moves it to an ownership queue (ADR-0142), and answers the record's new owner.
17+
- `POST /api/v1/data/:object/change-owner` with `{ ids, ownerId | queue, notify? }` does the same for up to 500 records, one update per record, and answers a per-row report that lists every record that did not move with its code and sentence.
18+
19+
An object offers Change Owner when the platform gives it a reassignable owner and its `userActions.transfer` switch is on (on by default, off on a `controlled_by_parent` detail). Any other object is refused as a whole, `403 CHANGE_OWNER_DISABLED`, whoever asks — a holder of `modifyAllRecords` included. The switch gates this action only: a plain `owner_id` update still needs the transfer grant and nothing else, so imports and hooks are unaffected. On an object that offers it, each record moves through the ordinary write path, so the caller needs edit on the record and the transfer grant (`allowTransfer` or `modifyAllRecords`); without the grant the record keeps its owner and the answer is the data door's own `403 PERMISSION_DENIED`. `notify: true` sends the new owner one notification under the `record.owner_changed` topic, its title keyed so it renders in the new owner's own language (English when no entry renders).
20+
21+
`@objectstack/core` exports `changeRecordOwner`, `changeRecordsOwner`, `changeOwnerOffReason`, `changeOwnerOffRefusal`, `CHANGE_OWNER_DISABLED`, `CHANGE_OWNER_NOTIFICATION_TOPIC`, `CHANGE_OWNER_NOTIFICATION_TEXT` and `assertAssignableUser` (the assigned-work hand-over's target check, now shared). That check now reads the target user the way the write path reads a user reference: a user the caller cannot read answers as one that does not exist (`404`, `reference_not_found`), on Change Owner and on the hand-over alike. `@objectstack/client` adds `data.changeOwner` and `data.changeOwnerMany`. `@objectstack/spec` registers `CHANGE_OWNER_DISABLED` in the error-code ledger, and the `userActions.transfer` liveness row is now `live`. `@objectstack/service-messaging` lists `record.owner_changed` among the platform's notification topics and carries the notice's title in every shipped locale (`messages.recordOwnerChangedTitle`, `messages.recordsOwnerChangedTitle`).

‎content/docs/api/data-api.mdx‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,85 @@ single create.
455455

456456
---
457457

458+
### `POST /data/:object/:id/change-owner`
459+
460+
Hand one record to another person, or move it into an ownership queue
461+
(ADR-0142). The record is written by id, as the caller, through the ordinary
462+
write path: the caller needs edit on the record **and** the transfer grant
463+
(`allowTransfer` on the object, or `modifyAllRecords`). Without the grant the
464+
record keeps its owner and the answer is the data door's own
465+
`403 PERMISSION_DENIED`, exactly as a `PATCH` of `owner_id` would answer.
466+
467+
Offered only on an object the platform gives a reassignable owner and whose
468+
`userActions.transfer` switch is on. The switch defaults to on, and to off on a
469+
`controlled_by_parent` detail. Any other object is refused as a whole with
470+
`403 CHANGE_OWNER_DISABLED`, whoever asks, a `modifyAllRecords` holder
471+
included. The switch gates this action only: a plain `owner_id` update (an
472+
import, a hook, a `PATCH`) still needs the transfer grant and nothing else.
473+
474+
**Body**: exactly one target, and an optional notification.
475+
476+
```json
477+
{ "ownerId": "usr_123", "notify": true }
478+
```
479+
480+
```json
481+
{ "queue": "support_triage" }
482+
```
483+
484+
- `ownerId`: the new owner. A user the caller cannot read, or one that does
485+
not exist, is refused `404 RESOURCE_NOT_FOUND`; a banned user `400
486+
VALIDATION_ERROR`. Both name `ownerId` in `details.fields`.
487+
- `queue`: an ownership queue's name. The record is written with no owner and
488+
that queue; an object without a `queue` column refuses it `400`.
489+
- `notify` (default `false`): send the new owner one notification under the
490+
`record.owner_changed` topic, in their own language. Not allowed with
491+
`queue`. A notification that cannot be sent never fails the transfer.
492+
493+
**Response** `200`:
494+
495+
```json
496+
{ "success": true, "data": { "object": "lead", "id": "lead_1", "ownerId": "usr_123", "notified": true } }
497+
```
498+
499+
A queue move answers `"ownerId": null, "queue": "support_triage"`.
500+
501+
### `POST /data/:object/change-owner`
502+
503+
The same for a list of records: one by-id update per record, each under the
504+
same rules as the single route. Takes up to **500** ids; an empty list, a list
505+
over 500 and a list naming an id twice are refused `400` before anything is
506+
written. An object that does not offer Change Owner is refused as a whole,
507+
`403 CHANGE_OWNER_DISABLED`, before any record is read.
508+
509+
**Body**: `{ "ids": ["lead_1", "lead_2"], "ownerId": "usr_123", "notify": true }`
510+
(or `queue` in place of `ownerId`).
511+
512+
**Response** `200`, with a report: every record that did not move is listed
513+
with the code and sentence its own update was refused with. None is skipped.
514+
515+
```json
516+
{
517+
"success": true,
518+
"data": {
519+
"object": "lead",
520+
"field": "owner_id",
521+
"ownerId": "usr_123",
522+
"updated": 1,
523+
"failed": 1,
524+
"failures": [
525+
{ "id": "lead_2", "code": "PERMISSION_DENIED", "message": "…" }
526+
],
527+
"notified": true
528+
}
529+
}
530+
```
531+
532+
With `notify`, the new owner gets one notification for all the records that
533+
moved, and none when nothing moved.
534+
535+
---
536+
458537
## Analytics
459538

460539
Semantic BI queries using a cube-style API. Provided by `@objectstack/service-analytics` —

‎content/docs/references/api/automation-api.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ const result = AutomationApiErrorCode.parse(data);
424424

425425
| Property | Type | Required | Description |
426426
| :--- | :--- | :--- | :--- |
427-
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +377 more>` | ✅ | The inner refusal's code in its WIRE spelling - the ADR-0112 member a record save of the same write answers in `error.code` (e.g. `UNIQUE_VIOLATION`); the closed set `ApiErrorSchema.code` parses against |
427+
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +378 more>` | ✅ | The inner refusal's code in its WIRE spelling - the ADR-0112 member a record save of the same write answers in `error.code` (e.g. `UNIQUE_VIOLATION`); the closed set `ApiErrorSchema.code` parses against |
428428
| **message** | `string` | ✅ | The inner refusal's own diagnostic text, verbatim, without the node and operation prefixes the run's failure text adds |
429429

430430
### Allowed Values: `FlowInnerRefusal.code`
@@ -517,6 +517,7 @@ const result = AutomationApiErrorCode.parse(data);
517517
* `BATCH_TOO_LARGE`
518518
* `BATCH_UNRESOLVED_REF`
519519
* `BLANK_MATCH_KEY`
520+
* `CHANGE_OWNER_DISABLED`
520521
* `CLONE_DISABLED`
521522
* `CLOUD_FETCH_FAILED`
522523
* `CLOUD_UNCONFIGURED`

‎content/docs/references/api/contract.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const result = ApiErrorSchema.parse(data);
2828

2929
| Property | Type | Required | Description |
3030
| :--- | :--- | :--- | :--- |
31-
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +377 more>` | ✅ | Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages) |
31+
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +378 more>` | ✅ | Error code (e.g. VALIDATION_ERROR; StandardErrorCode ∪ the ledger the serving side registers — ERROR_CODE_LEDGER for framework packages) |
3232
| **declaredCode** | `string` | optional | The producer-declared code, verbatim, when it is not a member of the closed `code` vocabulary — the open, author-authored channel (app-specific spellings; ADR-0112) |
3333
| **message** | `string` | ✅ | Readable error message |
3434
| **userMessage** | `string` | optional | Producer-marked user-facing refusal text, verbatim, in the request's locale: platform-composed text falls back to the workspace default locale, then `en`; an app-authored refusal falls back to its declared wording. Present exactly when the producer opted in at throw time; consumers render it to end users as received and keep their generic substitution for anything unmarked. Status-agnostic; never replaces `message`. |
@@ -128,6 +128,7 @@ const result = ApiErrorSchema.parse(data);
128128
* `BATCH_TOO_LARGE`
129129
* `BATCH_UNRESOLVED_REF`
130130
* `BLANK_MATCH_KEY`
131+
* `CHANGE_OWNER_DISABLED`
131132
* `CLONE_DISABLED`
132133
* `CLOUD_FETCH_FAILED`
133134
* `CLOUD_UNCONFIGURED`

‎content/docs/references/api/error-code-ledger.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ const result = ErrorCode.parse(data);
295295
* `BATCH_TOO_LARGE`
296296
* `BATCH_UNRESOLVED_REF`
297297
* `BLANK_MATCH_KEY`
298+
* `CHANGE_OWNER_DISABLED`
298299
* `CLONE_DISABLED`
299300
* `CLOUD_FETCH_FAILED`
300301
* `CLOUD_UNCONFIGURED`

‎packages/client/src/index.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,40 @@ export interface UserWorkTransferReport {
276276
remaining: number;
277277
}
278278

279+
/**
280+
* [#35402] Who takes the records in `data.changeOwner` / `data.changeOwnerMany`:
281+
* a person (`ownerId`), or an ownership queue (`queue`, ADR-0142) — exactly
282+
* one. `notify` tells a person target; a queue target refuses it.
283+
*/
284+
export type ChangeOwnerRequest =
285+
| { ownerId: string; queue?: undefined; notify?: boolean }
286+
| { queue: string; ownerId?: undefined; notify?: undefined };
287+
288+
/** [#35402] `data.changeOwner`'s answer: the record's new owner, or the queue it now sits in. */
289+
export interface ChangeOwnerResult {
290+
object: string;
291+
id: string;
292+
/** `null` when the record now sits in `queue`. */
293+
ownerId: string | null;
294+
queue?: string;
295+
notified: boolean;
296+
}
297+
298+
/**
299+
* [#35402] `data.changeOwnerMany`'s answer — the #30205 hand-over's per-object
300+
* outcome, with every row that did not move listed by id.
301+
*/
302+
export interface ChangeOwnerReport {
303+
object: string;
304+
field: string;
305+
ownerId: string | null;
306+
queue?: string;
307+
updated: number;
308+
failed: number;
309+
failures: Array<{ id: string; code: string; message: string }>;
310+
notified: boolean;
311+
}
312+
279313
/**
280314
* [#30237] One page of `recycleBin.list`: an object's recycle-bin entries,
281315
* newest first. Each snapshot row carries only the fields the caller may see
@@ -8255,6 +8289,40 @@ export class ObjectStackClient {
82558289
return this.unwrapResponse<CloneDataResult<T>>(res);
82568290
},
82578291

8292+
/**
8293+
* [#35402] Change Owner on ONE record — `POST /data/:object/:id/change-owner`:
8294+
* hand it to a person (`ownerId`) or move it to an ownership queue
8295+
* (`queue`), as the caller. Refused `403 CHANGE_OWNER_DISABLED` on an object
8296+
* that does not offer the action (`userActions.transfer`); a caller without
8297+
* the transfer grant on the record gets the `/data` write door's own `403`,
8298+
* and a record out of reach its `404`.
8299+
*/
8300+
changeOwner: async (object: string, id: string, request: ChangeOwnerRequest): Promise<ChangeOwnerResult> => {
8301+
const route = this.getRoute('data');
8302+
const res = await this.fetch(
8303+
`${this.baseUrl}${route}/${encodeURIComponent(object)}/${encodeURIComponent(id)}/change-owner`,
8304+
{ method: 'POST', body: JSON.stringify(request) },
8305+
);
8306+
return this.unwrapResponse<ChangeOwnerResult>(res);
8307+
},
8308+
8309+
/**
8310+
* [#35402] Change Owner on a list of up to 500 records —
8311+
* `POST /data/:object/change-owner`: each moves by its own update as the
8312+
* caller, and the answer lists every row that did not move with its code
8313+
* and sentence. The whole call is refused before any write on an object
8314+
* that does not offer the action, a repeated or empty id list, a list past
8315+
* the cap, and an unknown or banned person.
8316+
*/
8317+
changeOwnerMany: async (object: string, ids: string[], request: ChangeOwnerRequest): Promise<ChangeOwnerReport> => {
8318+
const route = this.getRoute('data');
8319+
const res = await this.fetch(
8320+
`${this.baseUrl}${route}/${encodeURIComponent(object)}/change-owner`,
8321+
{ method: 'POST', body: JSON.stringify({ ...request, ids }) },
8322+
);
8323+
return this.unwrapResponse<ChangeOwnerReport>(res);
8324+
},
8325+
82588326
/**
82598327
* [#26594] The field projection of ONE record —
82608328
* `GET /data/:object/:id/field-access`, declared by

0 commit comments

Comments
 (0)