Skip to content

Commit 562bf26

Browse files
Copilothotlong
andcommitted
fix: resolve TypeScript build errors in data-objectstack and DetailView
- data-objectstack: expand entries now include required `object` property to satisfy QueryAST type; findOne uses `where` instead of `filters` - DetailView: convert resourceId to string before calling startsWith/slice Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 7fb4205 commit 562bf26

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

packages/data-objectstack/src/expand.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ describe('ObjectStackAdapter $expand support', () => {
5656

5757
expect(mockClient.data.query).toHaveBeenCalledWith('order', expect.objectContaining({
5858
expand: {
59-
customer: {},
60-
account: {},
59+
customer: { object: 'customer' },
60+
account: { object: 'account' },
6161
},
6262
limit: 10,
6363
}));
@@ -82,7 +82,7 @@ describe('ObjectStackAdapter $expand support', () => {
8282
sort: ['name'],
8383
limit: 50,
8484
offset: 10,
85-
expand: { customer: {} },
85+
expand: { customer: { object: 'customer' } },
8686
}));
8787
});
8888

@@ -117,10 +117,10 @@ describe('ObjectStackAdapter $expand support', () => {
117117
});
118118

119119
expect(mockClient.data.query).toHaveBeenCalledWith('order', expect.objectContaining({
120-
filters: [['_id', '=', 'order-1']],
120+
where: { _id: 'order-1' },
121121
expand: {
122-
customer: {},
123-
account: {},
122+
customer: { object: 'customer' },
123+
account: { object: 'account' },
124124
},
125125
limit: 1,
126126
}));

packages/data-objectstack/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
277277
// because data.get() (GET) does not support expand through the client SDK.
278278
if (params?.$expand && params.$expand.length > 0) {
279279
try {
280-
const expand: Record<string, object> = {};
280+
const expand: Record<string, { object: string }> = {};
281281
for (const field of params.$expand) {
282-
expand[field] = {};
282+
expand[field] = { object: field };
283283
}
284284
const result: unknown = await this.client.data.query<T>(resource, {
285-
filters: [['_id', '=', String(id)]],
285+
where: { _id: String(id) },
286286
expand,
287287
limit: 1,
288-
});
288+
} as any);
289289
const resultObj = result as { records?: T[] };
290290
const records = resultObj.records || [];
291291
return records[0] || null;
@@ -576,9 +576,9 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
576576

577577
// Expand — build expand map for query AST
578578
if (params.$expand && params.$expand.length > 0) {
579-
const expand: Record<string, object> = {};
579+
const expand: Record<string, { object: string }> = {};
580580
for (const field of params.$expand) {
581-
expand[field] = {};
581+
expand[field] = { object: field };
582582
}
583583
query.expand = expand;
584584
}

packages/plugin-detail/src/DetailView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ export const DetailView: React.FC<DetailViewProps> = ({
122122
return;
123123
}
124124
// Fallback: try alternate ID format for backward compatibility
125-
const altId = resourceId.startsWith(prefix)
126-
? resourceId.slice(prefix.length) // strip prefix
127-
: `${prefix}${resourceId}`; // prepend prefix
125+
const resIdStr = String(resourceId);
126+
const altId = resIdStr.startsWith(prefix)
127+
? resIdStr.slice(prefix.length) // strip prefix
128+
: `${prefix}${resIdStr}`; // prepend prefix
128129
return dataSource.findOne(objectName, altId, params).then((fallbackResult) => {
129130
if (isMounted) {
130131
setData(fallbackResult);

0 commit comments

Comments
 (0)