Skip to content

Commit a9d3393

Browse files
committed
test(runtime): pin the package-less object_extension save refusal; name the item gate in the __c judge's door list
Regenerates the metadata-plugin reference page the merge left stale. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ad2bfc9 commit a9d3393

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎content/docs/references/kernel/metadata-plugin.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ const result = MetadataBulkResultSchema.parse(data);
334334
| **operation** | `Enum<'update'>` | optional | The declarative single-record field write, mirroring a list view's `bulkActionDefs`: `'update'` applies `patch` (merged under the collected `params`) to the current record on the data plane AS THE CALLER — never system-elevated — so the caller's permissions, the object's hooks and its validations fire as for a user edit. `type` stays at its default `'script'` (the platform action route the write is performed on); `target`/`body`/`method`/`bodyExtra` are refused beside it. `'delete'` and `'custom'` have no row-level form. |
335335
| **patch** | `Record<string, any>` | optional | For `operation: 'update'` — static field values written to the current record, merged UNDER the user-supplied `params` so a fixed value can be declared without exposing it in the dialog. Written on the data plane as the caller: object permissions, hooks and validations fire as for a user edit. Refused on an action without `operation: 'update'` (it would be silently dropped). |
336336
| **execution** | `Enum<'perRecord' \| 'aggregate'>` | optional | The bulk dispatch contract this action's BODY is written for, in `bulkActionDefs`' own vocabulary: 'perRecord' = one dispatch per selected row carrying that row's `recordId` (the view's `bulkActions: ['<name>']` bare-string form); 'aggregate' = ONE dispatch for the whole selection carrying every id in `params._selectedIds` (a `bulkActionDefs` entry with `execution: 'aggregate'`). Optional with NO default — omit it only when the body genuinely serves both. A list view wiring a declared action under the other contract is refused by `@objectstack/lint` (`action-dispatch-contract-mismatch`). |
337-
| **params** | `{ name?: string; field?: string; objectOverride?: string; label?: string \| Record<string, string>; … }[]` | optional | Input parameters required from user — an ActionParam[] DEFINITION array, never a payload map (a static request body goes in `bodyExtra`). |
337+
| **params** | `{ name?: string; field?: string; objectOverride?: string; label?: string \| Record<string, string>; … }[]` | optional | Input parameters required from user — an ActionParam[] DEFINITION array, never a payload map (a static request body goes in `bodyExtra`). A param name (its `name`, or the `field` a field-backed param reads) may repeat only for per-gate variants of ONE input (declarations that differ in `visible` / `requiresFeature`, e.g. one optional and one required); the params check treats the name as `required` only when EVERY declaration of it requires it, and judges its value by the FIRST declaration's shape (`type`, `multiple`, `options`), so keep that shape identical across them. |
338338
| **submitText** | `string \| Record<string, string>` | optional | Label of the submit button in the action's param dialog, the verb the button performs (e.g. "Send", "Log Call"), in place of the default "Confirm" — the default-language string, or an inline locale map; translated at `objects.OBJECT._actions.ACTION.submitText` (`globalActions.ACTION.submitText` for an object-less action). Only on an action with a non-empty `params`: without one no param dialog opens, so it is refused. Not `confirmText`, which is the message of a param-less action's confirm dialog. A blank label is refused. |
339339
| **variant** | `Enum<'primary' \| 'secondary' \| 'danger' \| 'ghost' \| 'link'>` | optional | Button visual variant for styling (primary = highlighted, danger = destructive, ghost = transparent) |
340340
| **order** | `number` | optional | Sort order within a location group (lower = higher). Promotes/demotes an action toward the record_header primary button; stable, so actions without `order` keep their registration order. |

‎packages/metadata-protocol/src/protocol-extension-field-suffix.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* protocol` (`saveMetaItem`, `rollbackMetaItem`, and the promotion
1414
* `publishMetaItem` / `publishPackageDrafts` share), for an `object` body,
1515
* through {@link objectBodyExtensionFieldSuffixRefusal};
16+
* - the same three doors for an `object_extension` item, as the package's one
17+
* `objectExtensions` entry, through {@link judgeExtensionFieldSuffix}
18+
* (`objectExtensionItemRefusal`, `protocol-object-extension-item.ts`);
1619
* - `duplicatePackage`, for every object the copy would write, judged against
1720
* the TARGET id before the copy mints anything;
1821
* - `os validate` (`@objectstack/cli`) and the marketplace install

‎packages/runtime/src/domains/meta-object-extension-item.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ describe('[#28574] a writable pair saves and publishes an extension of the base\
181181
const rig = await boot();
182182
await rig.saveAndPublish(PAIR, regionBody());
183183

184-
const created: any = await rig.engine.insert(TARGET, { name: 'Acme', region__c: 'EMEA', organization_id: 'org_1' }, { context: { isSystem: true } } as any);
185-
const back: any = await rig.engine.findOne(TARGET, { where: { id: created.id }, context: { isSystem: true } } as any);
184+
const created: any = await rig.engine.insert(TARGET, { name: 'Acme', region__c: 'EMEA', organization_id: 'org_1' }, { context: { isSystem: true } });
185+
const back: any = await rig.engine.findOne(TARGET, { where: { id: created.id }, context: { isSystem: true } });
186186
expect(back?.region__c).toBe('EMEA');
187187
}, 60_000);
188188

@@ -315,6 +315,20 @@ describe('[#28574] refused at the door, leaving no row', () => {
315315
expect(await rig.rows()).toEqual([]);
316316
}, 60_000);
317317

318+
it('a package-less write: an extension is an item of a package, so a save naming none is refused', async () => {
319+
const rig = await boot();
320+
let caught: any;
321+
try {
322+
await rig.protocol.saveMetaItem({ type: TYPE, name: TARGET, item: regionBody(), mode: 'draft' });
323+
} catch (e) {
324+
caught = e;
325+
}
326+
expect({ code: caught?.code, status: caught?.status }).toEqual({ code: 'VALIDATION_ERROR', status: 400 });
327+
expect(String(caught?.message)).toContain('names none');
328+
expect(await rig.rows()).toEqual([]);
329+
expect(rig.extenders()).toEqual([]);
330+
}, 60_000);
331+
318332
it('a row filed under a name other than its target', async () => {
319333
const rig = await boot();
320334
let caught: any;

0 commit comments

Comments
 (0)