Skip to content

Commit 332beed

Browse files
committed
fix(metadata-protocol): the guard runner and audit writer members delegate to their facet bodies
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 645c951 commit 332beed

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

‎packages/metadata-protocol/src/protocol-package-uninstall.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export async function deletePackage(this: Pick<PackageUninstallHost, 'deleteMeta
101101
// guard's own throw propagates as is — an uninstall a guard could not
102102
// judge does not proceed. With no guard registered nothing is asked, and
103103
// the verb behaves exactly as it did before guards existed.
104-
await runUninstallGuards.call(this, request);
104+
await runUninstallGuards(this, request);
105105

106106
const where: Record<string, unknown> = { package_id: request.packageId };
107107
// [#8136] This read is the uninstall's FIRST database touch, and until
@@ -392,7 +392,7 @@ export async function deletePackage(this: Pick<PackageUninstallHost, 'deleteMeta
392392
// registry did not hold and the store bound no metadata to was not a
393393
// package, so it writes none either: the `DELETE` door answers that `404`.
394394
if (installed.held || deleted.length > 0 || failed.length > 0) {
395-
await recordPackageUninstall.call(this, {
395+
await recordPackageUninstall(this, {
396396
packageId: request.packageId,
397397
...(installed.version ? { version: installed.version } : {}),
398398
...(request.actor ? { actor: request.actor } : {}),
@@ -414,22 +414,22 @@ export async function deletePackage(this: Pick<PackageUninstallHost, 'deleteMeta
414414

415415
/** The body of `ObjectStackProtocolImplementation#runUninstallGuards`; the method's docblock there is its contract. */
416416
export async function runUninstallGuards(
417-
this: Pick<PackageUninstallHost, 'uninstallGuards'>,
417+
host: Pick<PackageUninstallHost, 'uninstallGuards'>,
418418
request: Pick<DeletePackageRequest, 'packageId' | 'actor'>,
419419
): Promise<void> {
420-
await askUninstallGuards(this.uninstallGuards, request);
420+
await askUninstallGuards(host.uninstallGuards, request);
421421
}
422422

423423
/** The body of `ObjectStackProtocolImplementation#recordPackageUninstall`; the method's docblock there is its contract. */
424424
export async function recordPackageUninstall(
425-
this: Pick<PackageUninstallHost, 'environmentId' | 'getServicesRegistry'>,
425+
host: Pick<PackageUninstallHost, 'environmentId' | 'getServicesRegistry'>,
426426
record: PackageUninstallRecord,
427427
): Promise<void> {
428-
await writePackageUninstallEvent(this.getServicesRegistry?.()?.get('audit'), {
428+
await writePackageUninstallEvent(host.getServicesRegistry?.()?.get('audit'), {
429429
action: 'package_uninstall',
430430
packageId: record.packageId,
431431
...(record.version ? { version: record.version } : {}),
432-
...(this.environmentId ? { environmentId: this.environmentId } : {}),
432+
...(host.environmentId ? { environmentId: host.environmentId } : {}),
433433
...(record.actor ? { actor: record.actor } : {}),
434434
...(record.keepData === true ? { keepData: true } : {}),
435435
itemsRemoved: record.itemsRemoved,

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,7 @@ export class ObjectStackProtocolImplementation implements
14611461
* holds a copy of it.
14621462
*/
14631463
async runUninstallGuards(request: Pick<DeletePackageRequest, 'packageId' | 'actor'>): Promise<void> {
1464-
const readUninstallGuards = () => this.uninstallGuards;
1465-
return runUninstallGuards.call({ get uninstallGuards() { return readUninstallGuards(); } }, request);
1464+
return runUninstallGuards(protocolHost(this), request);
14661465
}
14671466

14681467
/**
@@ -1480,12 +1479,7 @@ export class ObjectStackProtocolImplementation implements
14801479
* uninstall completed and never after a refusal.
14811480
*/
14821481
async recordPackageUninstall(record: PackageUninstallRecord): Promise<void> {
1483-
const readGetServicesRegistry = () => this.getServicesRegistry;
1484-
const readEnvironmentId = () => this.environmentId;
1485-
return recordPackageUninstall.call({
1486-
get environmentId() { return readEnvironmentId(); },
1487-
get getServicesRegistry() { return readGetServicesRegistry(); },
1488-
}, record);
1482+
return recordPackageUninstall(protocolHost(this), record);
14891483
}
14901484

14911485
/**

0 commit comments

Comments
 (0)