Skip to content

Commit 47b1c37

Browse files
committed
test(objectql): a non-bundle control beside the member-grain cases; changeset names any other package's member
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5m2Ryfx2Wubuz716mw
1 parent f085057 commit 47b1c37

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

‎.changeset/28802-bundle-member-base-address.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Metadata-protocol: semantic
1212
**BREAKING** read-side narrowing on a base's address, with one widening beside it. An email template is one item per `(name, locale)` (`ITEM_KEY_DISCRIMINATORS`), and since #28746 a locale the base does not ship is admitted as an addition, from the base's `.custom` pair (no `overrides`) and from a dependent package. The reads decided at name grain.
1313

1414
- **Widened.** The pair's own added locale is served on the base's address: the env-wide `GET /meta/email_template`, the list scoped to the base, `getMetaItemsForExecution` (which the email template loader reads) and the by-name reads naming the base or no package, stamped with the pair's id. So `renderTemplate` / `sendTemplate` in that locale renders the customer's template. It was read by name but never listed, so a send rendered the base's `en-US`.
15-
- **Narrowed.** A dependent package's added locale under a base template's name is no longer served by the by-name reads naming the base or no package (`404`): those reads fell to the registry's cross-package first match (ADR-0048 §3.3) and answered the dependent's body. It is still served by the read naming the dependent and the list scoped to it; the base's lists already left it out.
15+
- **Narrowed.** Another package's added locale under a base template's name (a dependent's, or any package other than the base and its pair) is no longer served by the by-name reads naming the base or no package (`404`): those reads fell to the registry's cross-package first match (ADR-0048 §3.3) and answered that package's body. It is still served by the read naming that package and the list scoped to it; the base's lists already left it out.
1616
- **Unchanged.** The base's own locales and the pair's declared overrides of them; the list scoped to the pair; the write gate (#28746); every type whose identity is its name alone.

‎packages/objectql/src/protocol-bundle-member-base-address.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const NAME = 'task_done_email';
3535
/** Shipped in `fr-FR` only: a bundle with no canonical member. */
3636
const FR_ONLY = 'task_late_email';
3737
const TYPE = 'email_template';
38+
/** A non-bundle type's item the base ships, for the control: its identity is its name alone. */
39+
const VIEW = 'showcase_task.default';
40+
const BASE_COLUMNS = ['title', 'status'];
3841

3942
const sysMetadataObject: ServiceObject = {
4043
name: 'sys_metadata',
@@ -143,6 +146,21 @@ function baseManifest(): Record<string, unknown> {
143146
version: '1.0.0',
144147
namespace: 'showcase',
145148
emailTemplates: [template(NAME, 'en-US', 'Base EN'), template(FR_ONLY, 'fr-FR', 'Base late FR')],
149+
objects: [{
150+
name: 'showcase_task',
151+
label: 'Task',
152+
sharingModel: 'private',
153+
fields: Object.fromEntries(BASE_COLUMNS.map((f) => [f, { name: f, label: f, type: 'text' }])),
154+
}],
155+
views: [{
156+
object: 'showcase_task',
157+
list: {
158+
label: 'All Tasks',
159+
type: 'grid',
160+
data: { provider: 'object', object: 'showcase_task' },
161+
columns: BASE_COLUMNS.map((field) => ({ field })),
162+
},
163+
}],
146164
};
147165
}
148166

@@ -217,6 +235,12 @@ const listed = async (protocol: ObjectStackProtocolImplementation, name: string,
217235
const executing = async (protocol: ObjectStackProtocolImplementation, name: string) =>
218236
rowsOf(((await protocol.getMetaItemsForExecution({ type: TYPE })) as any).items, name);
219237

238+
/** The control's view items of a list, as `[_packageId, columns]`. */
239+
const listedViews = async (protocol: ObjectStackProtocolImplementation, packageId?: string) =>
240+
(((await protocol.getMetaItems({ type: 'view', ...(packageId ? { packageId } : {}) })) as any).items as any[])
241+
.filter((i) => i?.name === VIEW)
242+
.map((i) => [i._packageId, (i?.config?.columns ?? i?.columns ?? []).map((c: any) => c?.field ?? c)]);
243+
220244
const BASE_EN = ['en-US', BASE, 'Base EN'];
221245
const PAIR_FR = ['fr-FR', PAIR, 'Pair FR'];
222246

@@ -276,6 +300,38 @@ describe('[#28802] a bundle member on the base\'s address, at member grain', ()
276300
expect(await byName(protocol, FR_ONLY, 'en-US', DEPENDENT)).toEqual(['Dependent late EN', 'en-US', DEPENDENT]);
277301
});
278302

303+
it('control: a non-bundle type keeps name grain: a pair\'s and a dependent\'s same-named view stay out of the base\'s lists', async () => {
304+
const { protocol } = await boot();
305+
await install(protocol, PAIR);
306+
await install(protocol, DEPENDENT);
307+
// Rows the override write gate refuses today (an undeclared pair row, a
308+
// dependent's row under the name the base ships), laid down as stored before it.
309+
for (const [packageId, columns] of [[PAIR, ['title']], [DEPENDENT, ['status']]] as const) {
310+
const item = {
311+
name: VIEW, object: 'showcase_task', viewKind: 'list', label: 'All Tasks',
312+
config: { type: 'grid', data: { provider: 'object', object: 'showcase_task' }, columns: columns.map((field) => ({ field })) },
313+
};
314+
const gated = protocol as any;
315+
gated.overrideWriteVerdict = () => ({ verdict: 'not_concerned' });
316+
try {
317+
await protocol.saveMetaItem({ type: 'view', name: VIEW, item, mode: 'draft', packageId } as any);
318+
await protocol.publishMetaItem({ type: 'view', name: VIEW, packageId } as any);
319+
} finally {
320+
delete gated.overrideWriteVerdict;
321+
}
322+
}
323+
// The rows reach the list read: the per-package layer carries all three bodies.
324+
const perPackage = (((await (protocol as any).getMetaItemsPerPackage({ type: 'view' })) as any).items as any[])
325+
.filter((i) => i?.name === VIEW)
326+
.map((i) => (i?.config?.columns ?? []).map((c: any) => c?.field ?? c).join(','))
327+
.sort();
328+
expect(perPackage).toEqual(['status', 'title', 'title,status']);
329+
expect(await listedViews(protocol)).toEqual([[BASE, BASE_COLUMNS]]);
330+
expect(await listedViews(protocol, BASE)).toEqual([[BASE, BASE_COLUMNS]]);
331+
// Beside it, the bundle's members on the same reads are untouched by the view rows.
332+
expect(await listed(protocol, NAME)).toEqual([BASE_EN]);
333+
});
334+
279335
it('control: the pair\'s declared override of the base\'s member is served as the base\'s; the pair\'s own member beside it too', async () => {
280336
const { protocol } = await boot();
281337
await install(protocol, PAIR);

0 commit comments

Comments
 (0)