Skip to content

Commit a54ef14

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-l8wnbr
2 parents 6a01e80 + a364093 commit a54ef14

13 files changed

Lines changed: 1226 additions & 57 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
---
4+
5+
fix(plugin-detail): on a desktop the record page's enlarged related tab draws the child object's list grid, as the phone already does
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The enlarged related tab (the record page's active tab) drew a generic `data-table` on a desktop: rows about 65 px tall where the child object's list page draws 41 px, a name in plain text that did not open the record, and the count twice (on the 全部 chip and on the line under the toolbar). It now renders `object-grid` over the rows the related list already read, the branch the phone has taken since the phone card rows landed, so the tab is the child object's list face: the list page's row height and density, the name as a link that opens the record, and the grid's row actions.
11+
12+
The related list stays the source of truth. Its window, page and sort reach the grid as host props (the ones the list view hands the same grid), so paging and sort are still the server's `$top` / `$skip` / `$orderby`, and its own pager stays the one pager. The filter box, the 全部 / 我的 / 逾期 chips, 新建 and 导出 are unchanged. The host's row actions (`list_item`, and `record_related` inside a parent record) ride to the grid's row menu and still dispatch through the host against the child object and its row, which refreshes the list. While the 全部 chip is on and nothing narrows the rows, the line under the toolbar no longer repeats the chip's count.
13+
14+
One behaviour changes: while the filter box has text, the grid offers no header sort on a relational column (its stored value is an id), as on every list page; the data-table sorted that column by its label in that state. Compact panels in the right column and lists that are not enlarged are unchanged.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/metadata-protocol': patch
4+
---
5+
6+
fix(spec): the connector read withholds root keys the entry shape does not declare
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Read-side hardening of the built-in `connector` redactor. A stored connector body is served without any top-level key the authored connector entry (`DeclarativeConnectorEntrySchema`) does not declare — including a cleared one (`null`, `''`, `{}`) and one whose own name carries a dot; the declared set is read from that schema's own shape, and the read decorations (`_diagnostics`, `_draft`) are left alone. Under `providerConfig`, an array, or a key whose own name carries a dot, that holds a URL with credential parts is withheld whole rather than served. Each withheld position is named in `redactedKeys`, and the metadata protocol's carry-forward keeps the stored value at rest when the served form is saved — resolving a dotted key by the whole-string fallback when the dotted split resolves nowhere. The runtime's execution read is unchanged, and nothing an author can write changes.

‎packages/metadata-protocol/src/metadata-redaction.ts‎

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,41 @@ export function redactedPathsCarriedForward(type: string, incoming: unknown, sto
516516
* {@link redactedPathsCarriedForward}: the grafted body, and where each graft
517517
* landed. `landed` is empty exactly when `out` is `incoming` by reference.
518518
*/
519+
/**
520+
* A `redactedKeys` entry resolved against the STORED body into the container
521+
* hops that reach the key and the key itself — which may carry dots.
522+
*
523+
* `redactedKeys` joins each path on dots, so a key whose own name carries a dot
524+
* (a connector root key spelled `v1.url`, or one held under `providerConfig`)
525+
* is indistinguishable from a nested path by the string alone. The two are told
526+
* apart by what the stored body actually holds, trying the partitions in a
527+
* fixed order: the standard split FIRST — every dot a separator, the only
528+
* reading before dotted keys were withheld — then progressively longer trailing
529+
* keys, ending with the whole string as a single key. The first partition whose
530+
* stored container holds the key wins, so a nested position always shadows a
531+
* dotted-key alias of the same spelling (the alias is then left to the author's
532+
* word, never carried onto the wrong position). `undefined` when no partition
533+
* reaches a present value — the caller reads that as "nothing at rest to carry".
534+
*/
535+
function resolveRedactedPath(
536+
stored: unknown,
537+
path: string,
538+
): { hops: PathHop[]; key: string } | undefined {
539+
const segments = path.split('.');
540+
for (let cut = segments.length - 1; cut >= 0; cut -= 1) {
541+
const key = segments.slice(cut).join('.');
542+
// resolveHops reads the last entry as the key and the rest as container
543+
// hops, so a placeholder last entry leaves exactly `cut` container hops.
544+
const hops = resolveHops(stored, [...segments.slice(0, cut), key]);
545+
if (!hops) continue;
546+
const container = containerAt(stored, hops);
547+
if (container && Object.prototype.hasOwnProperty.call(container, key) && container[key] !== undefined) {
548+
return { hops, key };
549+
}
550+
}
551+
return undefined;
552+
}
553+
519554
function planCarryForward<T>(type: string, incoming: T, stored: unknown): { out: T; landed: string[] } {
520555
const unchanged = { out: incoming, landed: [] as string[] };
521556
if (!incoming || typeof incoming !== 'object' || Array.isArray(incoming)) return unchanged;
@@ -535,11 +570,15 @@ function planCarryForward<T>(type: string, incoming: T, stored: unknown): { out:
535570
// Dotted, item-relative — the registry's documented contract for
536571
// `redactedKeys` (`config.password`; an array hop is an index into the
537572
// stored body, `nodes.0.config.secret`, resolved to an identity by
538-
// {@link resolveHops}).
539-
const segments = path.split('.');
540-
const key = segments[segments.length - 1] as string;
541-
const hops = resolveHops(stored, segments);
542-
if (!hops) continue;
573+
// {@link resolveHops}). A key whose OWN name carries a dot (a connector
574+
// root key spelled `v1.url`, or one under `providerConfig`) cannot be
575+
// told from a nested path by the join alone, so the split is tried
576+
// first — every dot a separator, the existing reading — and only when
577+
// that resolves to nothing at rest is a longer trailing key tried,
578+
// ending with the whole string as a single key. {@link resolveRedactedPath}.
579+
const resolved = resolveRedactedPath(stored, path);
580+
if (!resolved) continue;
581+
const { hops, key } = resolved;
543582

544583
const storedParent = containerAt(stored, hops);
545584
const storedValue = storedParent?.[key];

‎packages/metadata-protocol/src/protocol.diff-credential-redaction.test.ts‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,75 @@ describe('#8671 — anti-vacuity: ablate the redactor', () => {
331331
expect(label.to).toBe('B');
332332
});
333333
});
334+
335+
describe('the connector history diff withholds root keys the entry shape does not declare', () => {
336+
const ROOT_V1 = 'TEST_PLACEHOLDER_ROOT_KEY_V1';
337+
const ROOT_V2 = 'TEST_PLACEHOLDER_ROOT_KEY_V2';
338+
const connector = (label: string, extra: Record<string, unknown>) => ({
339+
name: 'vendor_api',
340+
label,
341+
type: 'api',
342+
provider: 'rest',
343+
providerConfig: { baseUrl: 'https://api.vendor.example/v1' },
344+
auth: { type: 'bearer', credentialRef: 'VENDOR_API_TOKEN' },
345+
...extra,
346+
});
347+
const BUILTIN_CONNECTOR_REDACTOR = getMetadataTypeRedactor('connector')!;
348+
afterEach(() => registerMetadataTypeRedactor('connector', BUILTIN_CONNECTOR_REDACTOR));
349+
350+
async function connectorDiff(from: number, to: number) {
351+
const { engine, tables } = makeStubEngine();
352+
const base = { organization_id: null, type: 'connector', name: 'vendor_api' };
353+
const bodies = [
354+
connector('Vendor', {}),
355+
connector('Vendor', { apiKey: ROOT_V1 }),
356+
connector('Vendor API', { apiKey: ROOT_V2 }),
357+
];
358+
bodies.forEach((body, i) => {
359+
tables.sys_metadata_history!.push({
360+
...base,
361+
id: `h_${i + 1}`,
362+
version: i + 1,
363+
event_seq: i + 1,
364+
operation_type: i === 0 ? 'create' : 'update',
365+
metadata: JSON.stringify(body),
366+
checksum: hashSpec(body),
367+
recorded_at: new Date(i + 1).toISOString(),
368+
});
369+
});
370+
const protocol = new ObjectStackProtocolImplementation(engine);
371+
return await protocol.diffMetaItem({ type: 'connector', name: 'vendor_api', fromVersion: from, toVersion: to }) as any;
372+
}
373+
374+
const holdsRootValue = (payload: unknown) =>
375+
allStrings(payload).some((s) => s.includes(ROOT_V1) || s.includes(ROOT_V2));
376+
377+
it('withholds undeclared root keys on read: the history diff, all three buckets', async () => {
378+
const changed = await connectorDiff(2, 3);
379+
const rotated = entry(changed.changed, 'apiKey') as any;
380+
// The change is still reported; neither value is served.
381+
expect(rotated).toBeDefined();
382+
expect(rotated.from).toBeUndefined();
383+
expect(rotated.to).toBeUndefined();
384+
expect((entry(changed.changed, 'label') as any).to).toBe('Vendor API');
385+
expect(holdsRootValue(changed)).toBe(false);
386+
387+
const added = await connectorDiff(1, 2);
388+
expect(entry(added.added, 'apiKey')).toBeDefined();
389+
expect((entry(added.added, 'apiKey') as any).value).toBeUndefined();
390+
expect(holdsRootValue(added)).toBe(false);
391+
392+
const removed = await connectorDiff(2, 1);
393+
expect(entry(removed.removed, 'apiKey')).toBeDefined();
394+
expect((entry(removed.removed, 'apiKey') as any).value).toBeUndefined();
395+
expect(holdsRootValue(removed)).toBe(false);
396+
});
397+
398+
it('ABLATION — with an identity `connector` redactor the diff serves the values again', async () => {
399+
registerMetadataTypeRedactor('connector', (item) => ({ item, redactedKeys: [] }));
400+
const res = await connectorDiff(2, 3);
401+
const rotated = entry(res.changed, 'apiKey') as any;
402+
expect(rotated.from).toBe(ROOT_V1);
403+
expect(rotated.to).toBe(ROOT_V2);
404+
});
405+
});

0 commit comments

Comments
 (0)