Skip to content

Commit 31100d0

Browse files
committed
fix(plugin-approvals): type the mirror's record read and the pin's engine lookup
Claude-Session: https://claude.ai/code/session_01LR1cD9JqgkeqY7k9rrZH8s Co-authored-by: Claude <noreply@anthropic.com>
1 parent c737d22 commit 31100d0

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎packages/plugins/plugin-approvals/src/approval-service.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5131,8 +5131,8 @@ describe('status mirror identity (#3783)', () => {
51315131
// `organizationId`, which is not an envelope field. The record-organisation
51325132
// read and the end-to-end envelope are pinned in
51335133
// `status-mirror-envelope.integration.test.ts`.
5134-
const req = await open();
5135-
expect(req.organization_id).toBe('t1');
5134+
await open();
5135+
expect(engine._tables['sys_approval_request'][0].organization_id).toBe('t1');
51365136
expect(mirrorContext()).toEqual({ isSystem: true, userId: 'u1', tenantId: 't1' });
51375137
});
51385138
});

‎packages/plugins/plugin-approvals/src/approval-service.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,8 +3243,8 @@ export class ApprovalService implements IApprovalService {
32433243
if (column) {
32443244
const rows = await this.engine.find(object, {
32453245
where: { id: recordId }, fields: ['id', column], limit: 1, context: SYSTEM_CTX,
3246-
} as any);
3247-
organization = this.recordOrgResolver.organizationOf(object, Array.isArray(rows) ? rows[0] : rows);
3246+
});
3247+
organization = this.recordOrgResolver.organizationOf(object, Array.isArray(rows) ? rows[0] : undefined);
32483248
}
32493249
if (!organization && requestOrg != null && String(requestOrg) !== '') organization = String(requestOrg);
32503250
return { isSystem: true, userId: actorId, ...(organization ? { tenantId: organization } : {}) };

‎packages/plugins/plugin-approvals/src/status-mirror-envelope.integration.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
4545
import { ObjectKernel, resolveUserAuthzGrants } from '@objectstack/core';
46-
import { ObjectQLPlugin, bindHooksToEngine } from '@objectstack/objectql';
46+
import { ObjectQLPlugin, bindHooksToEngine, type ObjectQL } from '@objectstack/objectql';
4747
import { SqlDriver } from '@objectstack/driver-sql';
4848
import { AutomationServicePlugin, type AutomationEngine } from '@objectstack/service-automation';
4949
import { RecordChangeTriggerPlugin } from '@objectstack/trigger-record-change';
@@ -123,7 +123,7 @@ const envelopeOf = (c: any): Envelope => ({
123123

124124
describe("the status mirror hands a runAs:'user' cascade the person's own request envelope in the record's organisation (#24519)", () => {
125125
let kernel: ObjectKernel;
126-
let ql: any;
126+
let ql: ObjectQL;
127127
let svc: ApprovalService;
128128
let openNode: (recordId: string, submitter: string, approvers: string[], config?: Record<string, unknown>) => Promise<string>;
129129
/** The context of every write to the business object, in order. */
@@ -145,7 +145,7 @@ describe("the status mirror hands a runAs:'user' cascade the person's own reques
145145
await kernel.use(new AutomationServicePlugin());
146146
await kernel.use(new RecordChangeTriggerPlugin());
147147
await kernel.bootstrap();
148-
ql = kernel.getService('objectql');
148+
ql = kernel.getService<ObjectQL>('objectql');
149149
const automation = kernel.getService<AutomationEngine>('automation');
150150

151151
const driver = new SqlDriver({ client: 'better-sqlite3', connection: { filename: ':memory:' }, useNullAsDefault: true });

0 commit comments

Comments
 (0)