Skip to content

Commit d5e6b20

Browse files
fix(metadata-core,objectql,cloud-connection,cli)!: the package upgrade plan counts the fields a package adds through objectExtensions (#34419)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XRT27U1unc64yMdYqqPWFjw)_ Fixes #34095 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — `git grep` of `skills/` finds no page that teaches the upgrade plan's field lists or the schema upgrade confirmation; `skills/objectstack-platform/references/operations.md` names `os diff` in one table row ("Compare two ObjectStack config files and detect breaking changes"), which stays true as written. This PR is the platform half of the card. The cloud half (service-cloud `upgradeSideOf`, in the cloud repository) stays with the cloud seat, as the card body says: it can pass `objectExtensions` beside `objects` in the side it builds, and the comparison in `@objectstack/metadata-core` then folds them the same way. ## 维护者速读 - 改了什么:升级预览(升级计划)现在把包通过 `objectExtensions` 加到对象上的字段也算进去:新增、删除、改类型都会出现在预览、受影响列的行数和升级确认判定里。 - 为什么改:HotCRM 6.2.0 升 6.4.0 时预览显示“没有新增字段”,实际升级却加了 7 列;预览漏掉改动,管理员就无法信任预览。 - 风险与回滚:以前直接装上的四种升级现在被拦:扩展字段改类型;同一对象删一个字段同时新增另一个(扩展与扩展,或对象自己的字段与扩展字段互相配对)——这三种回 409,用 `--confirm-upgrade` 确认即可;扩展字段带 `renamedFrom` 改成不存列的类型(如 formula)——回 422 `destructive_type`,确认令牌不管用,要保留可存储的类型或手工搬数据。回滚即还原本 PR,没有数据迁移。 - 席位路线 ①(席位定 A,非维护者裁决):外包拥有的字段被扩展重声明、新版本不再声明时,预览把它列为删除(与新增字段同对象时列为疑似改名),虽然拥有方的字段仍在服务。接受这个偏差并写进文档:它偏向多要一次确认,不会漏掉一次确认。 - 席位路线 ②(席位定 A,非维护者裁决):单删一个扩展字段只列出并计行数,不拒,与卡面「删扩展字段需确认」不同;依据是 `package-upgrade-verdict.ts` 的既有裁决(记录 6709061297):删除的字段由 dry run 报告,任何门都不拒。删字段只在已有规则要求确认处才要确认:同对象同时新增字段(疑似改名),或改成无存储列的类型。 - 先看:`packages/metadata-core/src/package-upgrade-plan.ts`(`objectsByName` 的合并和只读扩展对象的比较)、`packages/cli/src/commands/diff.ts`(扩展对象的打印)、`packages/cloud-connection/src/marketplace-install-rename-planner.ts`(安装门的取侧)。 - 两分钟验证:`pnpm --filter @objectstack/metadata-core exec vitest run src/package-upgrade-plan.test.ts`,应看到 `objectExtensions: an extension field counts like an owned one` 一组全部通过。 - 需要你做的:无,席位落地。 ## What changes - **The comparison** (`comparePackageVersions`, `@objectstack/metadata-core`): `PackageUpgradeSide` gains an optional `objectExtensions` list. Each side's objects are now the objects as the registry serves them from that version: the owner's declaration, with each extension's `fields` merged over it by name (a later writer replaces the whole field), in ascending `priority` (`200` when none is declared), equal priorities in the order the side lists them. This is the registry's own fold (`mergeObjectDefinitions`, applied by `foldExtendersOntoDefinition`), keyed by the `extend` string verbatim as the registry keys it. After the fold every existing rule applies to an extension field unchanged. No new verdict category is added. - **Objects reached only through an extension** (another package owns them) are compared by the fields the extensions add, against no fields when the other version does not reach the object at all. They are never listed in `plan.objects.added` / `removed`: the upgrade neither creates nor drops them. - **The side readers** read `objectExtensions` with the same collection reader as `objects`: `sideOf` in `@objectstack/objectql` (`planUpgrade`, the dry run's and the hosted door's plan) and `packageUpgradeSideOf` in `@objectstack/cloud-connection` (the install-local door's schema verdict at step 2c′ and the declared-rename planner). The fold itself lives in one place, the comparison. - **`os diff`** already passed the whole union stack to the comparison, so it now compares extension fields too. It also prints the field changes of an object it reaches only through an extension, under `objects.NAME.fields`. - **What the door now refuses that it installed before.** Four arms, each named in the changeset with its fix: - an extension field retyped `needs_confirm` or `destructive`: `409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`; fix: confirm with the token (`--confirm-upgrade`); - an extension field dropped while another stored extension field of the same object is added: `409`, a suspected rename; fix: the token, or `renamedFrom` when it is a rename; - a stored field dropped from an object's own declaration while an extension of the same object adds a stored field, or the reverse: `409`, a suspected rename. The owned and the extension fields of one object are one field map now, so they pair; on `main` they were never compared. Fix: the token, as for any suspected rename; - an extension field that declares `renamedFrom` and whose new type stores no column: `422 VALIDATION_ERROR`, `details.refusals[].reason: 'destructive_type'`, at step 2c″ before any write, because the plan's type change now reaches `planInstallDeclaredRenames`. No token answers it, so `--confirm-upgrade` is the wrong fix: keep a stored type for the renamed field, or carry the values by hand. Landing point: the fold went into the comparison (`package-upgrade-plan.ts`), not into each side reader, so the three callers that build a side (planUpgrade, install-local, `os diff`) share one fold and the cloud half needs only to pass the list. ## Tests - `packages/metadata-core/src/package-upgrade-plan.test.ts`, new top-level describe: an extension field added is listed in `fields.added`; the rollback lists it in `fields.removed`; an extension-only object is compared and never listed as an object; a retyped extension field is a `needs_confirm` / `destructive` type change and the verdict lists it; a dropped extension field is listed removed and, alone, is refused by nothing, while dropped beside an added one it is a suspected rename the verdict lists; the higher `priority` writes last; CONTROL: an owned-field plan is byte-identical with empty extension lists and with an unchanged extension of another object. - `packages/objectql/src/package-upgrade-environment.test.ts`, new describe, through the real `manifest` service's `planUpgrade` and a HotCRM-shaped two-package artifact: added extension fields listed; the rollback lists them and counts the rows holding a value; a retyped extension field is a type change whose column is read. - `packages/cloud-connection/src/marketplace-install-local-upgrade-plan.test.ts`, new describe, through the install-local door: a retyped extension field answers `409` with code `SCHEMA_UPGRADE_CONFIRMATION_REQUIRED` naming it and writes nothing; a drop beside an add answers `409` as a suspected rename; the dry run lists an added extension field, and adding one or dropping one alone installs unrefused. The file's test-only `fold` mirror reads `objectExtensions` too. - `packages/cloud-connection/src/marketplace-install-local-declared-rename.test.ts`, one new case beside the owned `destructive_type` one: an extension field renamed with `renamedFrom` into a `formula` answers `422` with code `VALIDATION_ERROR` and reason `destructive_type`, and nothing is registered, synced, carried or written to the ledger. - `packages/cli/test/diff-upgrade-plan.test.ts`, new describe: an extension field added to an owned object prints under it; an extension-only object prints its type change and is not an added or removed object. Red first, each against `origin/main`'s source with the fix committed (restore leg `git checkout HEAD`, proved by the HEAD blob hash and an empty `git status`): - `package-upgrade-plan.ts` at base: `Tests 6 failed | 18 passed (24)`; the six are the new non-control cases, the control passes. - `package-upgrade-environment.ts` at base (side without `objectExtensions`): `Tests 3 failed | 16 passed (19)`. - `marketplace-install-rename-planner.ts` at base: `Tests 2 failed | 25 passed (27)`, the two `409` cases (the dry run case reads the test's own fold). - `diff.ts` at base: `Tests 1 failed | 9 passed (10)`, the extension-only object. - The `destructive_type` extension case, by a one-off ablation (`node scripts/ablation-replace.mjs`, the `objectExtensions` read deleted from `packageUpgradeSideOf`; anchor 1 → 0, restored to the HEAD blob with `git diff HEAD` empty): `Tests 1 failed | 27 passed (28)`, the new case only, which then installed `200`. Restored: `Tests 28 passed (28)`. ## Acceptance notes - **The card asked for "dropped (requires confirmation)".** The ruling in `package-upgrade-verdict.ts` (ruling record 6709061297) says a removed field is reported by a dry run and refused by nothing, and this dispatch's ruling says extension fields count like owned ones with no new verdict category. So a dropped extension field is listed in `fields.removed` with its rows counted, and needs confirmation only where an owned drop does: beside an added stored field of the same object (a suspected rename), or as a retype to a type with no stored column (`destructive`). Both are pinned. Seat route ② (seat decision, not a maintainer ruling) keeps this reading. - **An extension that redeclares a field another, uninstalled-here package owns.** For an object owned outside the upgraded artifact, the comparison sees only the extension's fields, not the owner's. An extension that stops redeclaring an owner's field is then listed as a removed field (and can pair into a suspected rename), although the owner's field is still served. The registry warns about such redeclarations ("patch an owner field's display properties instead of redeclaring it"), and the error leans toward asking a confirmation, not toward skipping one. Seat route ① (seat decision, not a maintainer ruling): accepted as documented here. - **`fieldPatches`** change display properties only and store no column, so they stay out of the comparison. - `content/docs/deployment/cli.mdx` describes the schema confirmation in terms of "a stored field", which reads correctly for an extension field; it is not edited here. - Contract review: the upgrade door accepts less (the four arms under What changes), so a contract-review-tier L2 is owed before the queue. ## Verification Run on head `9b0824ae` (`origin/main` merged in), every command through `scripts/pm/os-verify-lock.sh`. <details><summary>Narrowing battery (full dogfood)</summary> - `pnpm --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test`, no shard: exit 0, `Test Files 475 passed | 3 skipped (478)`, `Tests 4019 passed | 42 skipped (4061)`. </details> <details><summary>Package tests and typecheck</summary> - metadata-core `vitest run`: `Test Files 27 passed (27)`, `Tests 1038 passed (1038)`. - objectql `vitest run --maxWorkers=2`: `Test Files 604 passed (604)`, `Tests 13478 passed (13478)`. - cloud-connection `vitest run --maxWorkers=2`: `Test Files 86 passed (86)`, `Tests 1258 passed (1258)`. - cli `vitest run --project unit --maxWorkers=2`: `Test Files 424 passed (424)`, `Tests 6029 passed (6029)`. - typecheck of metadata-core, objectql, cloud-connection and cli (each with its test layer): exit 0. </details> <details><summary>dispatch-gates</summary> - At `432c9d2c` (before the main merge, same changed paths): 72 families, 71 exit 0; `check:dual-build-cjs-loads` exit 3 (prerequisite: every package's `dist`), NOT MEASURED here, CI runs it. `--ran` reconciliation: 72 derived, 72 run, 0 unrun. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pNoRjsgMJKr5utN33)_ <!-- signed: repo:objectstack#1 · os-project-manager · session_01FEkQ5pNoRjsgMJKr5utN33 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d18d54b commit d5e6b20

10 files changed

Lines changed: 400 additions & 28 deletions
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
'@objectstack/metadata-core': patch
3+
'@objectstack/objectql': patch
4+
'@objectstack/cloud-connection': patch
5+
'@objectstack/cli': patch
6+
---
7+
8+
fix(metadata-core,objectql,cloud-connection,cli)!: the package upgrade plan counts the fields a package adds through `objectExtensions`
9+
10+
Clause-②: no (narrowing)
11+
Metadata-protocol: none
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) No key of any authorable schema is added, removed, renamed or re-shaped and no stored row changes: what moves is which fields the package upgrade comparison reads from each version, so there is nothing for `objectstack migrate meta` to rewrite. -->
14+
15+
**BREAKING** for an upgrade that changes a field the package adds to an object through `objectExtensions`. Four kinds of upgrade that installed without a question before are now refused, exactly as the same change to a field of an object the package declares is:
16+
17+
- an extension field retyped to a `needs_confirm` or `destructive` type: `409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`;
18+
- an extension field dropped while another stored extension field of the same object is added, with no `renamedFrom` linking them: `409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`, as a suspected rename;
19+
- a stored field dropped from an object's own declaration in the upgraded version while an extension of the same object adds a stored field, or an extension field dropped while the object's own declaration adds one: `409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`, as a suspected rename. The owned and the extension fields of one object are now one field map, so the two pair; before, they were never compared;
20+
- an extension field that declares `renamedFrom` and whose new type stores no column (a `formula`, for example): `422 VALIDATION_ERROR` with `details.refusals[].reason: 'destructive_type'`, before anything is written, as for an owned field. No token answers this refusal.
21+
22+
The package upgrade plan (`comparePackageVersions`) read only a version's `objects` and `data`. A field an `objectExtensions` entry adds, retypes or drops was therefore missing from the upgrade preview, from the rows counted per touched column, and from the schema upgrade verdict. A preview of an upgrade that added seven columns through extensions listed no added field, and its rollback listed no removed one.
23+
24+
Now each side of the comparison is the objects as the registry serves them from that version: the owner's declaration, with every extension's `fields` merged over it by name, in ascending `priority` (`200` when none is declared). The existing rules then apply to an extension field unchanged:
25+
26+
- an extension field added is listed in `plan.fields.added`, and one dropped in `plan.fields.removed`, with the rows holding a value counted in `environment.columns`;
27+
- an extension field retyped is a type change; `needs_confirm` and `destructive` changes need the confirmation, and a `safe` one does not;
28+
- an extension field dropped while another stored field of the same object is added, with no `renamedFrom` linking them, is a suspected rename and needs the confirmation; a field dropped alone is listed and refused by nothing, as an owned one is.
29+
30+
An object a version reaches only through an extension (another package owns it) is compared by the fields the extension adds. It is never listed in `plan.objects.added` or `plan.objects.removed`, because the upgrade neither creates nor drops it. `os diff` prints the field changes of such an object under `objects.<name>.fields`.
31+
32+
`PackageUpgradeSide` (`@objectstack/metadata-core`) gains an optional `objectExtensions` list. A caller that builds a side itself passes the version's `objectExtensions` beside its `objects`, read with the same collection reader; a side without the key compares as before.
33+
34+
Who moves, and the fix for each:
35+
36+
- An installer upgrading a package whose new version retypes an extension field, or drops a field of an object while another stored field of the same object is added (extension or owned, in either pairing): the `409`. Confirm the findings with the token the refusal names (`--confirm-upgrade <token>` on `os deploy` and `os package install`); for a suspected rename the refusal names the other way forward too.
37+
- A package author whose new version renames an extension field with `renamedFrom` into a type that stores no column: the `422`. `--confirm-upgrade` does not answer it. Keep a stored type for the renamed field, or carry the values by hand, as the refusal's message says.
38+
39+
Unchanged: a plan over packages that declare no `objectExtensions` is the same plan as before; seed datasets are compared as before; `fieldPatches` changes display properties only and stays out of the comparison.

‎packages/cli/src/commands/diff.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,18 @@ function diffObjectsAndSeeds(beforeConfig: any, afterConfig: any): DiffEntry[] {
101101
for (const name of plan.objects.removed) entries.push({ type: 'removed', category: 'objects', name, breaking: true });
102102
for (const name of plan.objects.added) entries.push({ type: 'added', category: 'objects', name, breaking: false });
103103

104+
const beforeObjects = getNames(beforeConfig.objects);
104105
const afterObjects = getNames(afterConfig.objects);
105-
for (const [name, beforeObj] of getNames(beforeConfig.objects)) {
106+
// Every object both configs declare, then (#34095) each object the plan
107+
// lists field changes on that a config reaches only through
108+
// `objectExtensions`: the plan compares those too, and they print alike.
109+
const compared = [...beforeObjects.keys()].filter((name) => afterObjects.has(name));
110+
for (const list of [plan.fields.removed, plan.fields.added, plan.declaredRenames, plan.typeChanges, plan.suspectedRenames]) {
111+
for (const item of list) if (!compared.includes(item.object)) compared.push(item.object);
112+
}
113+
for (const name of compared) {
114+
const beforeObj = beforeObjects.get(name);
106115
const afterObj = afterObjects.get(name);
107-
if (!afterObj) continue;
108116
const category = `objects.${name}.fields`;
109117
const mine = <T extends { object: string }>(list: T[]): T[] => list.filter((item) => item.object === name);
110118

@@ -138,7 +146,7 @@ function diffObjectsAndSeeds(beforeConfig: any, afterConfig: any): DiffEntry[] {
138146
}
139147

140148
// Label / ownership changes on the object itself
141-
if (beforeObj.label !== afterObj.label) {
149+
if (beforeObj && afterObj && beforeObj.label !== afterObj.label) {
142150
entries.push({
143151
type: 'modified',
144152
category: 'objects',

‎packages/cli/test/diff-upgrade-plan.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,27 @@ describe('os diff — what the upgrade plan adds', () => {
178178
]);
179179
});
180180
});
181+
182+
describe('os diff — objectExtensions fields, as the plan compares them (#34095)', () => {
183+
const ACCOUNT = { name: 'crm_account', label: 'Account', fields: { name: { type: 'text' } } };
184+
185+
it('an extension field added to an object the config owns prints under that object', () => {
186+
const entries = diffStacks(
187+
{ objects: [ACCOUNT] },
188+
{ objects: [ACCOUNT], objectExtensions: [{ extend: 'crm_account', fields: { invoiced_amount: { type: 'number' } } }] },
189+
);
190+
expect(entries).toEqual([
191+
{ type: 'added', category: 'objects.crm_account.fields', name: 'invoiced_amount', breaking: false, detail: 'optional field added' },
192+
]);
193+
});
194+
195+
it('an object reached only through an extension prints its field changes, and is never an added or removed object', () => {
196+
const entries = diffStacks(
197+
{ objectExtensions: [{ extend: 'crm_contact', fields: { tier: { type: 'text' } } }] },
198+
{ objectExtensions: [{ extend: 'crm_contact', fields: { tier: { type: 'number' } } }] },
199+
);
200+
expect(entries).toEqual([
201+
{ type: 'modified', category: 'objects.crm_contact.fields', name: 'tier', breaking: true, detail: 'type changed: text → number' },
202+
]);
203+
});
204+
});

‎packages/cloud-connection/src/marketplace-install-local-declared-rename.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,28 @@ describe('a declared rename that cannot be carried is refused 422 before any wri
290290
await refusedBefore(door, driver, before);
291291
});
292292

293+
it('`destructive_type` on an extension field: the renamed field an `objectExtensions` entry adds turns a type that stores no column (#34095)', async () => {
294+
// The upgrade plan folds the extension's fields onto `acme_lead`, so the
295+
// destructive retype on the declared rename reaches the planner as it
296+
// does for an owned field: refused by name, which no token answers.
297+
const driver = fakeDriver({ acme_lead: new Set(['id', 'company']) });
298+
const ext = (version: string, fields: Row) => ({
299+
id: 'com.acme.ext', namespace: 'acmeext', version, objectExtensions: [{ extend: 'acme_lead', fields }],
300+
});
301+
const served = { acme_lead: lead({ company: { type: 'text' } }) };
302+
const door = await mount({ installed: ext('1.0.0', { company: { type: 'text' } }), driver, served });
303+
const before = ledgerFiles();
304+
const res = await door.install(makeC({
305+
manifest: ext('2.0.0', { account_name: { type: 'formula', expression: '1', renamedFrom: ['company'] } }),
306+
}));
307+
expect(res.status).toBe(422);
308+
expect(res.payload.error.code).toBe('VALIDATION_ERROR');
309+
expect(res.payload.error.details.refusals).toEqual([expect.objectContaining({
310+
object: 'acme_lead', field: 'account_name', from: ['company'], reason: 'destructive_type',
311+
})]);
312+
await refusedBefore(door, driver, before);
313+
});
314+
293315
it('`outside_package`: an extension\'s field names a column its own package never contributed (the owner\'s just-dropped key)', async () => {
294316
// The owner's table still holds `company` (the owner dropped it); this
295317
// package only ever extended the object with `nickname`.

‎packages/cloud-connection/src/marketplace-install-local-upgrade-plan.test.ts‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ afterEach(() => {
8181
vi.restoreAllMocks();
8282
});
8383

84-
const fold = (artifact: unknown) => ({ objects: resolveStackCollection(artifact, 'objects'), data: resolveStackCollection(artifact, 'data') });
84+
const fold = (artifact: unknown) => ({
85+
objects: resolveStackCollection(artifact, 'objects'),
86+
objectExtensions: resolveStackCollection(artifact, 'objectExtensions'),
87+
data: resolveStackCollection(artifact, 'data'),
88+
});
8589

8690
async function mount(options: { installed?: Row; planUpgrade?: false; columns?: Row[]; overrides?: unknown; registryPackages?: Row[]; driver?: unknown } = {}) {
8791
const register = vi.fn();
@@ -494,3 +498,51 @@ describe('step 2c′: the schema upgrade verdict on a managed re-install', () =>
494498
expect(entry()?.schemaUpgradeConfirmation).toBeUndefined();
495499
});
496500
});
501+
502+
describe('step 2c′ judges an objectExtensions field like an owned one (#34095)', () => {
503+
/** The vendor package, adding fields to an object another package owns. */
504+
const extending = (version: string, fields: Row) => ({
505+
...vendorBody(version, { company: { type: 'text' } }),
506+
objectExtensions: [{ extend: 'crm_account', fields }],
507+
});
508+
509+
it('a retyped extension field answers 409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED naming it, and writes nothing', async () => {
510+
const door = await mount({ installed: extending('1.0.0', { tier: { type: 'text' } }) });
511+
const before = ledgerFiles();
512+
513+
const res = await door.install(makeC({ manifest: extending('2.0.0', { tier: { type: 'number' } }) }));
514+
515+
expect(res.status).toBe(409);
516+
expect(res.payload.error.code).toBe('SCHEMA_UPGRADE_CONFIRMATION_REQUIRED');
517+
expect(res.payload.error.details.findings).toEqual([expect.objectContaining({
518+
kind: 'type_change', object: 'crm_account', field: 'tier', from: 'text', to: 'number', category: 'needs_confirm',
519+
})]);
520+
expect(door.register).not.toHaveBeenCalled();
521+
expect(ledgerFiles()).toEqual(before);
522+
});
523+
524+
it('an extension field dropped beside one added answers 409 as a suspected rename', async () => {
525+
const door = await mount({ installed: extending('1.0.0', { tier: { type: 'text' } }) });
526+
const res = await door.install(makeC({ manifest: extending('2.0.0', { segment: { type: 'text' } }) }));
527+
expect(res.status).toBe(409);
528+
expect(res.payload.error.code).toBe('SCHEMA_UPGRADE_CONFIRMATION_REQUIRED');
529+
expect(res.payload.error.details.findings).toEqual([expect.objectContaining({
530+
kind: 'suspected_rename', object: 'crm_account', field: 'tier', candidates: [{ field: 'segment', type: 'text' }],
531+
})]);
532+
});
533+
534+
it('the dry run lists an added extension field; adding it, or dropping one alone, installs unrefused as an owned field does', async () => {
535+
const door = await mount({ installed: extending('1.0.0', { tier: { type: 'text' } }) });
536+
const preview = await door.install(makeC({ manifest: extending('2.0.0', { tier: { type: 'text' }, invoiced_amount: { type: 'number' } }), dryRun: true }));
537+
expect(preview.status).toBe(200);
538+
expect(preview.payload.data.plan.fields.added).toEqual([
539+
{ object: 'crm_account', field: 'invoiced_amount', type: 'number', required: false, stored: true },
540+
]);
541+
542+
const added = await door.install(makeC({ manifest: extending('2.0.0', { tier: { type: 'text' }, invoiced_amount: { type: 'number' } }) }));
543+
expect(added.status).toBe(200);
544+
const dropped = await door.install(makeC({ manifest: extending('3.0.0', { tier: { type: 'text' } }) }));
545+
expect(dropped.status).toBe(200);
546+
expect(new LocalManifestSource(dir).read(VENDOR).entry?.schemaUpgradeConfirmation).toBeUndefined();
547+
});
548+
});

‎packages/cloud-connection/src/marketplace-install-rename-planner.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ export function convertPackageBodyForward(ctx: PluginContext, manifest: unknown)
4646
return typeof ql?.convertPackageBodyForward === 'function' ? ql.convertPackageBodyForward(manifest) : manifest;
4747
}
4848

49-
/** One side of a package version comparison, a multi-package artifact folded as `planUpgrade` folds it. */
49+
/**
50+
* One side of a package version comparison, a multi-package artifact folded as
51+
* `planUpgrade` folds it: `objects`, `objectExtensions` (#34095: the comparison
52+
* merges each extension's fields onto its target, so the verdict judges an
53+
* extension field like an owned one) and `data`.
54+
*/
5055
export function packageUpgradeSideOf(artifact: unknown): PackageUpgradeSide {
51-
return { objects: resolveStackCollection(artifact, 'objects'), data: resolveStackCollection(artifact, 'data') };
56+
return {
57+
objects: resolveStackCollection(artifact, 'objects'),
58+
objectExtensions: resolveStackCollection(artifact, 'objectExtensions'),
59+
data: resolveStackCollection(artifact, 'data'),
60+
};
5261
}
5362

5463
/**

0 commit comments

Comments
 (0)