Skip to content

Commit 490aad2

Browse files
committed
Merge origin/main into claude/issue-36897-list-objectgrid
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNtKtppbRbXmHGH8x
2 parents 11733ca + 144d368 commit 490aad2

38 files changed

Lines changed: 7556 additions & 6367 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/core': patch
3+
'@objectstack/metadata-protocol': patch
4+
'@objectstack/spec': patch
5+
'@objectstack/rest': patch
6+
---
7+
8+
fix(core)!: Change Owner refuses an object of a disabled package with the data door's `404 OBJECT_PACKAGE_DISABLED`
9+
10+
Clause-②: yes (narrowing) — `@objectstack/core` gains the root export `objectPackageDisabledError`, and all three Change Owner doors newly answer `404 OBJECT_PACKAGE_DISABLED` for an object of a disabled package, which they answered `200` before
11+
Metadata-protocol: none
12+
Skills-docs: none — no page under `skills/` teaches Change Owner; the refusal carries the data door's own sentence, which names the fix
13+
14+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no stored row, registry key or authored value changes. What moves is the answer the three Change Owner doors give for an object whose owning package is disabled, an answer that returns to what it was the moment the package is re-enabled; there is nothing for a migration to rewrite and no tombstone. -->
15+
16+
**BREAKING** for a caller that changes owners on a disabled package's object.
17+
18+
- FROM: `POST /api/v1/data/:object/:id/change-owner` and `POST /api/v1/data/:object/change-owner` answered `200` for an object of a disabled package: the owner changed (and, when a cascade was named, its child rows), and when asked the notification was sent; `GET /api/v1/data/:object/change-owner/cascades` answered `200` with the object's cascade candidates.
19+
- TO: all three doors answer `404 OBJECT_PACKAGE_DISABLED`, naming the object, in the data door's words; nothing is read, written or sent. The fix for a caller: re-enable the package.
20+
21+
`POST /api/v1/data/:object/:id/change-owner` and `POST /api/v1/data/:object/change-owner` changed owners (and cascaded child rows), and sent owner-change notifications, on records of an object whose owning package was disabled, although every `/data` write refuses such an object. `changeRecordOwner` and `changeRecordsOwner` now ask the engine registry's `isObjectPackageDisabled` before the object's Change Owner switch is read, and refuse the whole call with the data door's own envelope (`code: 'OBJECT_PACKAGE_DISABLED'`, `status: 404`, the object name on `object`) before any user lookup, write or notification. Re-enabling the package restores the action; nothing is cached. `GET /api/v1/data/:object/change-owner/cascades` asks the same predicate in the same order (after the object resolves, before the switch), so the dialog lists nothing for such an object.
22+
23+
The refusal's constructor, `objectPackageDisabledError`, now lives in `@objectstack/core` and is exported from it; `@objectstack/metadata-protocol` re-exports the same function under the same name, so its importers are unchanged and the code, status and sentence stay one. The error-code ledger (`@objectstack/spec`) records `OBJECT_PACKAGE_DISABLED` under `@objectstack/core` as a provenance row; the code itself, its status and its wire shape are unchanged.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
`objectstack-data`'s hook reference (`references/data-hooks.md`) no longer says every regex pattern the checking engine refuses is a warning. It now says what the compile rules do: a pattern the runtime refuses too is the same `hook-body-does-not-compile` / `job-body-does-not-compile` error, and only a duplicate named capture group, a modifier group such as `(?i:a)` or a Unicode property name only the runtime knows is a warning (on a host whose Unicode tables are older than 17.0, every property name it refuses). The file stays inside its token ceiling and its line count by tightening the same paragraph: it drops the note that the finding names the hook, the `SyntaxError` and its line, and the spelled-out rename example.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
internal: move-only — Studio's Data, Automations and Access pillars move out of `StudioDesignSurface.tsx` into their own modules, taking it from 8,010 to 1,715 lines
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
No behaviour change. Under `views/studio-design/`, `DataPillar.tsx` holds the Data pillar with its records-grid slot (`renderStudioGridList`) and its object draft-save shape. `AutomationsPillar.tsx` holds the Automations pillar and the published-flow-names read only it makes. `AccessPillar.tsx` holds the Access pillar with its "New similar" arrival reader and the list-row name label only it draws. The moved code is byte-identical apart from its imports. `StudioDesignSurface.tsx` imports the three pillars from there and re-exports them, with `renderStudioGridList`, so every import of them keeps working. The package's public exports are unchanged.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/metadata-protocol': minor
4+
'@objectstack/rest': minor
5+
---
6+
7+
feat(metadata): the metadata list answers when each listed item last changed, as `changedAt` beside its items
8+
9+
Clause-②: yes
10+
Metadata-protocol: added
11+
Skills-docs: none — a read-only field of the list response that no author writes; no skill documents the list envelope's sibling fields (`registrations`, `disabledActions`)
12+
13+
`GET /api/v1/meta/:type` now answers `changedAt` beside `items` (`GetMetaItemsResponseSchema.changedAt`): for each listed item served from a stored row, the `updated_at` of that row, keyed by the item's `name`, as an ISO-8601 instant in UTC written with `Z`. A list can show a "changed" column without one read per item.
14+
15+
- Only an item served from a stored row has an entry. A code-shipped or file-loaded item has no recorded change time and no entry: never the read time or the boot time standing in. The field is absent when no listed item is served from a row.
16+
- The time is the row whose content is listed. Of several stored rows in scope for one item (its package's own row, the package-less row, the package's declared override), on the list naming no package and on the list scoped to one, it is the row the list serves, the instant the by-name read serves as `Last-Modified` for it.
17+
- On `?preview=draft`, an item whose pending draft is served (`_draft: true`) has the draft row's time.
18+
- Several listed items of one name (a name two or more packages ship, the members of a bundle) answer the latest of their times.
19+
- The `/meta` list chain (REST and the runtime dispatcher) keys only the names of which it still lists every item: where the per-caller gate withholds an item, or a query filter leaves one out, that name has no entry, so the time of an item the caller is not shown is never served, under its own name or a name another listed item shares.
20+
- The items themselves are unchanged. The execution face and the per-package layer answer no `changedAt`, and the MCP `list_metadata_items` summary is unchanged.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/plugin-markdown': patch
3+
'@object-ui/plugin-chatbot': patch
4+
---
5+
6+
fix(plugin-markdown): bold that ends in full-width punctuation renders bold before a CJK letter
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The markdown renderer the console's manual reader uses (`@object-ui/plugin-markdown`) left a `**bold**` run as literal asterisks when the run ended in full-width punctuation and a CJK letter followed it, as in `**解决耗时(小时)**会被清空`, `**每个项目一张报销单。**每个项目` or `**它跳过和拒绝什么:**已经`. CommonMark counts full-width punctuation as punctuation, so such a closer is not right-flanking; a Chinese or Japanese sentence puts no space there.
12+
13+
The renderer now runs `remark-cjk-friendly` (its `parseOnly` entry, a new MIT dependency at `^2.3.4`) ahead of remark-gfm, the rule the chat surface already runs. It reads a CJK character beside a `**` run the way it reads the whitespace an English sentence would have there. ASCII emphasis, code spans, backslash escapes, GFM tables and GitHub-style alerts render as before, and the output still passes the same sanitize schema.
14+
15+
`@object-ui/plugin-chatbot` changes a comment only: its CJK rule now names the renderer's copy, since neither package depends on the other and each imports the plugin itself. No props or exports change in either package; nothing to migrate.

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ Offered only on an object the platform gives a reassignable owner and whose
475475
included. The switch gates this action only: a plain `owner_id` update (an
476476
import, a hook, a `PATCH`) still needs the transfer grant and nothing else.
477477

478+
An object whose owning package is disabled is refused first, before its switch
479+
is read, with the data door's own `404 OBJECT_PACKAGE_DISABLED`: nothing is
480+
written and nobody is notified. Re-enable the package to change owners again.
481+
478482
**Body**: exactly one target, and an optional notification.
479483

480484
```json
@@ -509,8 +513,10 @@ A queue move answers `"ownerId": null, "queue": "support_triage"`.
509513
The same for a list of records: one by-id update per record, each under the
510514
same rules as the single route. Takes up to **500** ids; an empty list, a list
511515
over 500 and a list naming an id twice are refused `400` before anything is
512-
written. An object that does not offer Change Owner is refused as a whole,
513-
`403 CHANGE_OWNER_DISABLED`, before any record is read.
516+
written. An object of a disabled package is refused as a whole,
517+
`404 OBJECT_PACKAGE_DISABLED`, and an object that does not offer Change Owner
518+
`403 CHANGE_OWNER_DISABLED`, both before any record is read, written or
519+
notified.
514520

515521
**Body**: `{ "ids": ["lead_1", "lead_2"], "ownerId": "usr_123", "notify": true }`
516522
(or `queue` in place of `ownerId`).
@@ -591,9 +597,10 @@ that offers Change Owner itself. Two more filters apply: a child whose declared
591597
API exposure does not serve `update` is left out, and so is a child that belongs
592598
to a disabled package. Whether the caller may transfer on each child
593599
is the explain engine's `transfer` operation (`POST /security/explain`), which
594-
the Console's dialog asks before it offers a tick. Takes no query parameter;
595-
an object that does not offer Change Owner is refused `403
596-
CHANGE_OWNER_DISABLED`.
600+
the Console's dialog asks before it offers a tick. Takes no query parameter.
601+
An object of a disabled package is refused `404 OBJECT_PACKAGE_DISABLED`, as by
602+
the two write doors above, and an object that does not offer Change Owner is
603+
refused `403 CHANGE_OWNER_DISABLED`.
597604

598605
```json
599606
{ "success": true, "data": { "object": "account", "cascades": [

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ One changed key path of the pending draft, and the last write that changed it.
16571657
| **items** | `any[]` | ✅ | Array of metadata items |
16581658
| **registrations** | `Record<string, { state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }>` | optional | The automation engine's verdict on each listed flow, keyed by the item's `name`: one entry per listed item that is not a pending draft. Present only on a `flow` list answered by a process that runs an automation service; absent otherwise, and absence means no engine judged them, never `registered`. The verdict is the answering process's engine. Beside the items, never inside one: an item's `status` stays what its author declared. |
16591659
| **disabledActions** | `Record<string, string[]>` | optional | For each listed object, keyed by the item's `name`: the names in its `actions` that this deployment's activation ledger switches off, so a call to any of them is refused 409 `ACTION_DISABLED` (the item read's `disabledActions`). One entry per listed object that is not a pending draft, `[]` when none of its actions is switched off. Present only on an `object` list answered by a process whose data engine has an activation ledger attached; absent otherwise, and absence means no ledger answered, never that nothing is switched off. Beside the items, never inside one: each item's `actions` is served as declared. |
1660+
| **changedAt** | `Record<string, string>` | optional | When each listed item last changed, keyed by the item's `name`: the `updated_at` of the stored row whose content the list serves for that item, an ISO-8601 instant in UTC written with `Z`. One entry per listed item served from a stored row; an item the list serves from code (a code-shipped or file-loaded definition) has no recorded change time and no entry, never a stand-in such as the read time. Where an item has several stored layers in scope (its package's own row, the package-less row, the package's declared override, environment-wide or scoped to one package), the time is the effective layer's: the row whose content is the listed item. On a `?preview=draft` list an item whose pending draft is served (`_draft: true`) has the draft row's time, since the draft is its content. Where several listed items share a name (a name two or more packages ship, the members of a bundle), the latest of their times. Only the names of items in this answer are keyed, and a door that leaves out some item of a name (the per-caller read gate, a query filter) answers no entry for that name, since the entry may be the time of the item it left out. A view a stored view container expands is not served from a row of its own name and has no entry. Absent when no listed item is served from a stored row. Beside the items, never inside one: an item's body is served as stored. |
16601661

16611662
### Nested Shape: `GetMetaItemsResponse.registrations[string][state='registered']`
16621663

‎packages/core/src/index.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ export * from './utils/operation-user-message.js';
237237
// resolve with it (one name space for both doors).
238238
export * from './utils/object-not-found.js';
239239

240+
// The one `OBJECT_PACKAGE_DISABLED` envelope: the data door, the by-name
241+
// `/meta` reads and the Change Owner doors refuse an object of a disabled
242+
// package with it. `@objectstack/metadata-protocol` re-exports it.
243+
export * from './utils/object-package-disabled.js';
244+
240245
// [#22777] The one walk that finds a filter's nested-relation conditions and
241246
// their target objects: the data door (`@objectstack/metadata-protocol`) and
242247
// the MCP stdio data bridge (`@objectstack/mcp`) ask each target its exposure

‎packages/core/src/security/change-record-owner.test.ts‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const CALLER = { userId: 'u_manager', tenantId: 'org_1' };
5050
* without, answering the stored row; refused before any write, as
5151
* `ERR_READONLY_FIELD_REJECTED`, under `strictReadonlyWrites`.
5252
*/
53-
function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: string[]; locked?: (row: Row) => string[] } = {}) {
53+
function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: string[]; locked?: (row: Row) => string[]; disabledPackageObjects?: string[] } = {}) {
5454
/** Per update call, in order: whether it passed `strictReadonlyWrites: true`. */
5555
const strictWrites: boolean[] = [];
5656
const tables: Record<string, Row[]> = {
@@ -79,6 +79,8 @@ function fakeEngine(opts: { refuse?: (id: string) => unknown; hiddenUsers?: stri
7979
calls,
8080
strictWrites,
8181
getSchema: (name) => SCHEMAS[name],
82+
// The engine registry's package predicate: a disabled package's object stays registered (getSchema resolves it).
83+
registry: { isObjectPackageDisabled: (name: string) => (opts.disabledPackageObjects ?? []).includes(name) },
8284
getConfigs: () => SCHEMAS,
8385
async count(object, q) {
8486
calls.push({ op: 'count', object, where: q?.where, context: q?.context });
@@ -421,6 +423,57 @@ describe('[#35402] notify', () => {
421423
});
422424
});
423425

426+
describe('[#36261] an object of a disabled package', () => {
427+
const DISABLED = { code: 'OBJECT_PACKAGE_DISABLED', status: 404 };
428+
429+
it('single: refused 404 OBJECT_PACKAGE_DISABLED, nothing read, written or sent', async () => {
430+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
431+
const messaging = { emit: vi.fn(async () => SENT) };
432+
const err = await refusalOf(changeRecordOwner(engine, 'lead', 'l1', { ownerId: 'u_next' }, CALLER, { notify: true, messaging }));
433+
expect({ code: err.code, status: err.status, object: err.object }).toEqual({ ...DISABLED, object: 'lead' });
434+
expect(engine.calls).toEqual([]);
435+
expect(messaging.emit).not.toHaveBeenCalled();
436+
expect(engine.tables.lead[0]!.owner_id).toBe('u_a');
437+
});
438+
439+
it('bulk: refused as a whole, 404 OBJECT_PACKAGE_DISABLED, nothing read, written or sent', async () => {
440+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
441+
const messaging = { emit: vi.fn(async () => SENT) };
442+
const err = await refusalOf(changeRecordsOwner(engine, 'lead', ['l1', 'l2'], { ownerId: 'u_next' }, CALLER, { notify: true, messaging }));
443+
expect({ code: err.code, status: err.status, object: err.object }).toEqual({ ...DISABLED, object: 'lead' });
444+
expect(engine.calls).toEqual([]);
445+
expect(messaging.emit).not.toHaveBeenCalled();
446+
});
447+
448+
it('is asked before the object\'s switch: a switched-off object of a disabled package answers the package refusal', async () => {
449+
const engine = fakeEngine({ disabledPackageObjects: ['pinned_lead'] });
450+
const err = await refusalOf(changeRecordOwner(engine, 'pinned_lead', 'x1', { ownerId: 'u_next' }, CALLER));
451+
expect({ code: err.code, status: err.status }).toEqual(DISABLED);
452+
});
453+
454+
it('a request naming a cascade is refused the same way, before any parent or child read or write', async () => {
455+
const rel = { object: 'lead_task', field: 'lead' };
456+
for (const run of [
457+
(e: ReturnType<typeof fakeEngine>) => changeRecordOwner(e, 'lead', 'l1', { ownerId: 'u_next' }, CALLER, { cascade: [rel] }),
458+
(e: ReturnType<typeof fakeEngine>) => changeRecordsOwner(e, 'lead', ['l1', 'l2'], { ownerId: 'u_next' }, CALLER, { cascade: [rel] }),
459+
]) {
460+
const engine = fakeEngine({ disabledPackageObjects: ['lead'] });
461+
const err = await refusalOf(run(engine));
462+
expect({ code: err.code, status: err.status }).toEqual(DISABLED);
463+
expect(engine.calls).toEqual([]);
464+
expect(engine.tables.lead_task!.map((r) => r.owner_id)).toEqual(['u_a', 'u_b', 'u_a', 'u_b']);
465+
}
466+
});
467+
468+
it('control: the same object with its package enabled takes the change', async () => {
469+
const engine = fakeEngine({ disabledPackageObjects: ['memo'] });
470+
const result = await changeRecordOwner(engine, 'lead', 'l1', { ownerId: 'u_next' }, CALLER);
471+
expect(result).toEqual({ object: 'lead', id: 'l1', ownerId: 'u_next', notified: false });
472+
const report = await changeRecordsOwner(engine, 'lead', ['l2'], { ownerId: 'u_next' }, CALLER);
473+
expect({ updated: report.updated, failed: report.failed }).toEqual({ updated: 1, failed: 0 });
474+
});
475+
});
476+
424477
describe('[#35315 phase 2] the Change Owner cascade', () => {
425478
const ownersOf = (engine: ReturnType<typeof fakeEngine>, object: string) =>
426479
Object.fromEntries(engine.tables[object]!.map((r) => [r.id, r.owner_id]));

0 commit comments

Comments
 (0)