Skip to content

Commit b9b7a27

Browse files
authored
Merge pull request #362 from objectstack-ai/copilot/fix-ci-build-and-test
2 parents ad5623d + 4bad192 commit b9b7a27

11 files changed

Lines changed: 49 additions & 26 deletions

File tree

packages/drivers/sdk/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,19 +545,19 @@ export class RemoteDriver implements Driver {
545545
* @example
546546
* ```typescript
547547
* // Execute a custom workflow
548-
* const result = await driver.execute('/api/workflows/approve', {
548+
* const result = await driver.executeCustomEndpoint('/api/workflows/approve', {
549549
* workflowId: 'wf_123',
550550
* comment: 'Approved'
551551
* });
552552
*
553553
* // Use default execute endpoint
554-
* const result = await driver.execute(undefined, {
554+
* const result = await driver.executeCustomEndpoint(undefined, {
555555
* action: 'calculateMetrics',
556556
* params: { year: 2024 }
557557
* });
558558
* ```
559559
*/
560-
async execute(endpoint?: string, payload?: any, _options?: any): Promise<any> {
560+
async executeCustomEndpoint(endpoint?: string, payload?: any, _options?: any): Promise<any> {
561561
return this.retryWithBackoff(async () => {
562562
const targetEndpoint = endpoint
563563
? this.buildEndpoint(endpoint)

packages/drivers/sdk/test/remote-driver.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ describe('RemoteDriver', () => {
688688
json: async () => mockResponse
689689
});
690690

691-
const result = await driver.execute('/api/custom', payload);
691+
const result = await driver.executeCustomEndpoint('/api/custom', payload);
692692

693693
expect(global.fetch).toHaveBeenCalledWith(
694694
'http://localhost:3000/api/custom',
@@ -708,7 +708,7 @@ describe('RemoteDriver', () => {
708708
json: async () => ({ success: true })
709709
});
710710

711-
await driver.execute(undefined, payload);
711+
await driver.executeCustomEndpoint(undefined, payload);
712712

713713
expect(global.fetch).toHaveBeenCalledWith(
714714
'http://localhost:3000/api/execute',
@@ -729,7 +729,7 @@ describe('RemoteDriver', () => {
729729
})
730730
});
731731

732-
await expect(driver.execute('/api/test', {}))
732+
await expect(driver.executeCustomEndpoint('/api/test', {}))
733733
.rejects
734734
.toThrow('Server error');
735735
});

packages/foundation/core/src/query/query-analyzer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class QueryAnalyzer {
271271
* @private
272272
*/
273273
private getSchema(objectName: string): ObjectConfig {
274-
const obj = this.metadata.get('object', objectName);
274+
const obj = this.metadata.get<ObjectConfig>('object', objectName);
275275
if (!obj) {
276276
throw new ObjectQLError({ code: 'NOT_FOUND', message: `Object '${objectName}' not found` });
277277
}

packages/foundation/core/src/query/query-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class QueryService {
132132
* @private
133133
*/
134134
private getSchema(objectName: string): ObjectConfig {
135-
const obj = this.metadata.get('object', objectName);
135+
const obj = this.metadata.get<ObjectConfig>('object', objectName);
136136
if (!obj) {
137137
throw new ObjectQLError({ code: 'NOT_FOUND', message: `Object '${objectName}' not found in metadata` });
138138
}

packages/foundation/core/src/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ObjectRepository {
2828
}
2929

3030
private getKernel(): ObjectKernel {
31-
return this.app.getKernel();
31+
return this.app.getKernel() as ObjectKernel;
3232
}
3333

3434
private getOptions(extra: Record<string, unknown> = {}) {

packages/foundation/platform-node/src/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ObjectLoader {
4444
// Object name does not match filename — using doc.name
4545
}
4646

47-
const packageEntry = ctx.registry.getEntry('package-map', ctx.file);
47+
const packageEntry = ctx.registry.getEntry<{ package?: string }>('package-map', ctx.file);
4848
registerObject(ctx.registry, doc, ctx.file, ctx.packageName || (packageEntry && packageEntry.package));
4949
return;
5050
}
@@ -295,7 +295,7 @@ function registerObject(registry: MetadataRegistry, obj: any, file: string, pack
295295
// --- End Smart Defaults ---
296296

297297
// Check for existing object to Merge
298-
const existing = registry.getEntry('object', obj.name);
298+
const existing = registry.getEntry<{ content?: ObjectConfig }>('object', obj.name);
299299
if (existing) {
300300
const base = existing.content as ObjectConfig;
301301

packages/foundation/plugin-security/src/storage-database.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ import type { IPermissionStorage, SecurityPluginConfig } from './types';
2222
/** Default table name for storing permission metadata */
2323
const DEFAULT_TABLE = 'objectql_permissions';
2424

25+
/**
26+
* Interface for permission storage row structure
27+
*/
28+
interface PermissionRow {
29+
_id?: string | number;
30+
id?: string | number;
31+
object_name: string;
32+
config: string;
33+
updated_at?: string;
34+
}
35+
2536
/**
2637
* Resolver function that locates a Driver instance by datasource name.
2738
* Typically wired from the ObjectQL application layer.
@@ -118,7 +129,7 @@ export class DatabasePermissionStorage implements IPermissionStorage {
118129
filters: [['object_name', '=', objectName]],
119130
top: 1,
120131
});
121-
const row = Array.isArray(rows) ? rows[0] : undefined;
132+
const row = Array.isArray(rows) ? rows[0] as unknown as PermissionRow | undefined : undefined;
122133
if (!row) return undefined;
123134
return JSON.parse(row.config) as PermissionConfig;
124135
} catch {
@@ -131,7 +142,7 @@ export class DatabasePermissionStorage implements IPermissionStorage {
131142
const result = new Map<string, PermissionConfig>();
132143
try {
133144
const rows = await driver.find(this.tableName, {});
134-
const items = Array.isArray(rows) ? rows : [];
145+
const items = Array.isArray(rows) ? rows as unknown as PermissionRow[] : [];
135146
for (const row of items) {
136147
try {
137148
const config = JSON.parse(row.config) as PermissionConfig;
@@ -152,10 +163,11 @@ export class DatabasePermissionStorage implements IPermissionStorage {
152163
try {
153164
const rows = await driver.find(this.tableName, {});
154165
// Create a shallow copy to avoid issues when deleting during iteration
155-
const items = Array.isArray(rows) ? [...rows] : [];
166+
const items = Array.isArray(rows) ? rows as unknown as PermissionRow[] : [];
156167
for (const row of items) {
157-
if (row._id || row.id || row.object_name) {
158-
await driver.delete(this.tableName, row._id ?? row.id ?? row.object_name, {});
168+
const id = row._id ?? row.id ?? row.object_name;
169+
if (id !== undefined) {
170+
await driver.delete(this.tableName, id, {});
159171
}
160172
}
161173
} catch {
@@ -185,13 +197,15 @@ export class DatabasePermissionStorage implements IPermissionStorage {
185197
filters: [['object_name', '=', config.object]],
186198
top: 1,
187199
});
188-
const row = Array.isArray(rows) ? rows[0] : undefined;
200+
const row = Array.isArray(rows) ? rows[0] as unknown as PermissionRow | undefined : undefined;
189201
if (row) {
190202
const id = row._id ?? row.id ?? row.object_name;
191-
await driver.update(this.tableName, id, {
203+
if (id !== undefined) {
204+
await driver.update(this.tableName, id, {
192205
config: JSON.stringify(config),
193206
updated_at: new Date().toISOString(),
194207
}, {});
208+
}
195209
}
196210
} else {
197211
await driver.create(this.tableName, {
@@ -212,10 +226,12 @@ export class DatabasePermissionStorage implements IPermissionStorage {
212226
filters: [['object_name', '=', objectName]],
213227
top: 1,
214228
});
215-
const row = Array.isArray(rows) ? rows[0] : undefined;
229+
const row = Array.isArray(rows) ? rows[0] as unknown as PermissionRow | undefined : undefined;
216230
if (row) {
217231
const id = row._id ?? row.id ?? row.object_name;
218-
await driver.delete(this.tableName, id, {});
232+
if (id !== undefined) {
233+
await driver.delete(this.tableName, id, {});
234+
}
219235
}
220236
} catch {
221237
// Row may not exist

packages/foundation/plugin-validator/src/validator.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ import {
2727
ValidationOperator,
2828
} from '@objectql/types';
2929

30+
/**
31+
* Minimal API interface expected by validation context
32+
*/
33+
interface ValidationApi {
34+
count(objectName: string, filters: Record<string, unknown>): Promise<number>;
35+
}
36+
3037
/**
3138
* Configuration options for the Validator.
3239
*/
@@ -364,7 +371,7 @@ export class Validator {
364371
}
365372

366373
// Check if transition is allowed
367-
const transitions = rule.transitions?.[oldState];
374+
const transitions = rule.transitions?.[oldState as string];
368375
if (!transitions) {
369376
return {
370377
rule: rule.name,
@@ -384,7 +391,7 @@ export class Validator {
384391
allowedNext = transitions.allowed_next || [];
385392
}
386393

387-
const isAllowed = allowedNext.includes(newState);
394+
const isAllowed = allowedNext.includes(newState as string);
388395

389396
return {
390397
rule: rule.name,
@@ -480,7 +487,7 @@ export class Validator {
480487

481488
try {
482489
// Query database to count existing records with same field values
483-
const count = await context.api.count(objectName, filters);
490+
const count = await (context.api as ValidationApi).count(objectName, filters);
484491

485492
const valid = count === 0;
486493

packages/foundation/plugin-workflow/__tests__/workflow-plugin.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { describe, it, expect, beforeEach } from 'vitest';
1010
import { WorkflowPlugin } from '../src/workflow-plugin';
11-
import type { _StateMachineConfig } from '@objectql/types';
11+
import type { StateMachineConfig } from '@objectql/types';
1212

1313
describe('WorkflowPlugin', () => {
1414
let plugin: WorkflowPlugin;

packages/foundation/plugin-workflow/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* These complement the protocol types from @objectql/types
1212
*/
1313

14-
import type { _StateMachineConfig } from '@objectql/types';
14+
import type { StateMachineConfig } from '@objectql/types';
1515

1616
/**
1717
* Execution context for state machine operations

0 commit comments

Comments
 (0)