Skip to content

Commit b0f42b5

Browse files
committed
chore(objectql): changeset for the refused-upgrade restore; pin catalog and default-page claims in the upgrade fixture
1 parent fb15f13 commit b0f42b5

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@objectstack/objectql": patch
3+
---
4+
5+
Clause-②: yes (widening) — the published `SchemaRegistry` gains one public method, `restoringOnRefusal`
6+
Metadata-protocol: none
7+
8+
fix(objectql): a refused upgrade leaves the installed version serving
9+
10+
When `ObjectQL.registerApp` re-registers a package that is already installed and the registry refuses the new version, the installed version keeps serving, whole, whatever point of the registration the refusal came from.
11+
12+
- The package record, every object, app and item, picklist options and extensions, namespaces, permission-set names and default record pages read as they did before the refused upgrade.
13+
- Another package's extension of the installed version's objects and a tenant's overlay of them are untouched and still served. The restore never goes through uninstall.
14+
- What is refused, and every refusal's code, status and words, is unchanged. A clean upgrade and a refused first install behave as before.
15+
- `SchemaRegistry.restoringOnRefusal(register)` runs one synchronous registration and, when it throws, puts back exactly the registry entries it wrote, then throws the same error. The engine runs an upgrade's registration through it.

‎packages/objectql/src/package-refused-upgrade-keeps-installed.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
*
88
* An installed `1.0.0` of a package (a v1-only object, a shared object, an
99
* object a tenant has overlaid, an object another package extends, an app, a
10-
* page, a picklist, a datasource) is re-registered as a `2.0.0` that the
10+
* page, a default record page, a permission set, a picklist, a datasource) is
11+
* re-registered as a `2.0.0` that the
1112
* registry refuses part-way, once for each refusal the registry raises after
1213
* the new package record is written:
1314
*
@@ -51,7 +52,8 @@ const V1 = () => ({
5152
version: '1.0.0',
5253
objects: [object('probeup_a'), object('probeup_shared', { label: 'v1 shared' }), object('probeup_old')],
5354
apps: [app('probeup_app', 'probeup_a')],
54-
pages: [{ name: 'probeup_v1_page', type: 'app' }],
55+
pages: [{ name: 'probeup_v1_page', type: 'app' }, { name: 'probeup_v1_record', type: 'record', object: 'probeup_a', isDefault: true }],
56+
permissions: [{ name: 'probeup_v1_ps', objects: {} }],
5557
picklists: [{ name: 'probeup_tier', label: 'Tier', options: [{ label: 'Gold', value: 'gold' }] }],
5658
datasources: [{ name: 'probeup_ds_v1', driver: 'memory' }],
5759
});
@@ -71,7 +73,8 @@ const V2 = (fault: Record<string, unknown> = {}) => {
7173
...faultObjects,
7274
],
7375
apps: [app('probeup_app_v2', 'probeup_new')],
74-
pages: [{ name: 'probeup_v2_page', type: 'app' }],
76+
pages: [{ name: 'probeup_v2_page', type: 'app' }, { name: 'probeup_v2_record', type: 'record', object: 'probeup_new', isDefault: true }],
77+
permissions: [{ name: 'probeup_v2_ps', objects: {} }],
7578
datasources: [{ name: 'probeup_ds_v2', driver: 'memory' }],
7679
...rest,
7780
};
@@ -123,7 +126,7 @@ function served(engine: ObjectQL) {
123126
picklists: Object.fromEntries(['probeup_tier', 'probeup_industry', 'probeup_list'].map((p) => [p, registry.resolvePicklistOptions(p)])),
124127
namespaces: Object.fromEntries([NS, 'probeupinner'].map((ns) => [ns, registry.getNamespaceOwners(ns)])),
125128
catalog: (['permission', 'position', 'capability'] as const).map((type) => registry.securityCatalogNamesHeldBy(PKG, type as any)),
126-
defaultPages: ['probeup_a', 'probeup_held'].map((o) => registry.defaultRecordPageHoldersOf(o)),
129+
defaultPages: ['probeup_a', 'probeup_new', 'probeup_held'].map((o) => registry.defaultRecordPageHoldersOf(o)),
127130
datasources: engine.listDatasourceDefs().map((d) => d.name).filter((n) => n.startsWith('probeup_')).sort(),
128131
};
129132
}
@@ -228,6 +231,8 @@ describe('[#28697] refused-upgrade controls', () => {
228231
expect(Object.keys((registry.getObject('probeup_old') as any)?.fields ?? {})).toContain('ext_note');
229232
expect(registry.listItems('app').map((a: any) => a.name)).toContain('probeup_app_v2');
230233
expect(engine.listDatasourceDefs().map((d) => d.name)).toContain('probeup_ds_v2');
234+
expect(registry.securityCatalogNamesHeldBy(PKG, 'permission' as any)).toEqual(['probeup_v1_ps', 'probeup_v2_ps']);
235+
expect(registry.defaultRecordPageHoldersOf('probeup_new').map((h: any) => h.page)).toEqual(['probeup_v2_record']);
231236
});
232237

233238
it('a refusal the package door raises before its first write leaves v1 as before', () => {

‎packages/objectql/src/registry.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,12 +3463,9 @@ export class SchemaRegistry {
34633463
* writes, such as an upgrade of an installed package — and, when it throws,
34643464
* put back exactly the entries it wrote, then throw the same error.
34653465
*
3466-
* Every refusal a verb below raises keeps its code and words; this changes
3467-
* only what is left afterwards. A refusal raised after some of the run's
3468-
* writes (an object another package owns, a field with no `type`, a
3469-
* picklist value already added, …) would otherwise leave those writes
3470-
* serving beside the entries they replaced: an upgrade's new package record
3471-
* and the objects it reached, next to the installed version's remainder.
3466+
* Every refusal a verb below raises keeps its code and words; this decides
3467+
* only what is left afterwards, wherever in the run the refusal came from:
3468+
* the entries as they were before the run.
34723469
*
34733470
* What is recorded, each entry before the run's first write to it: an
34743471
* object's contributor list (an `extend` or overlay layer of another package

0 commit comments

Comments
 (0)