@object-ui/data-objectstack 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -901,7 +901,6 @@ var ObjectStackAdapter = class {
901
901
  if (error?.status === 404) {
902
902
  return null;
903
903
  }
904
- throw error;
905
904
  }
906
905
  }
907
906
  try {
package/dist/index.js CHANGED
@@ -861,7 +861,6 @@ var ObjectStackAdapter = class {
861
861
  if (error?.status === 404) {
862
862
  return null;
863
863
  }
864
- throw error;
865
864
  }
866
865
  }
867
866
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/data-objectstack",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "ObjectStack Data Adapter for Object UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@objectstack/client": "^3.2.1",
24
- "@object-ui/core": "3.1.1",
25
- "@object-ui/types": "3.1.1"
24
+ "@object-ui/core": "3.1.2",
25
+ "@object-ui/types": "3.1.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.5.1",
@@ -177,6 +177,28 @@ describe('ObjectStackAdapter $expand support', () => {
177
177
 
178
178
  expect(result).toBeNull();
179
179
  });
180
+
181
+ it('should fall through to data.get() when $expand raw request fails with non-404 error', async () => {
182
+ // The raw populate request fails (e.g., server doesn't support the filter+populate API)
183
+ mockFetch.mockResolvedValue({
184
+ ok: false,
185
+ status: 500,
186
+ statusText: 'Internal Server Error',
187
+ json: () => Promise.resolve({ message: 'unsupported' }),
188
+ });
189
+ // But the direct data.get() call succeeds
190
+ mockClient.data.get.mockResolvedValue({ record: { _id: 'order-1', name: 'Order 1' } });
191
+
192
+ const result = await adapter.findOne('order', 'order-1', {
193
+ $expand: ['customer'],
194
+ });
195
+
196
+ // Should have tried raw request first
197
+ expect(mockFetch).toHaveBeenCalled();
198
+ // Then fell through to data.get()
199
+ expect(mockClient.data.get).toHaveBeenCalledWith('order', 'order-1');
200
+ expect(result).toEqual({ _id: 'order-1', name: 'Order 1' });
201
+ });
180
202
  });
181
203
 
182
204
  describe('raw request format', () => {
package/src/index.ts CHANGED
@@ -300,7 +300,9 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
300
300
  if ((error as Record<string, unknown>)?.status === 404) {
301
301
  return null;
302
302
  }
303
- throw error;
303
+ // Fall through to direct GET without $expand — some servers don't
304
+ // support the filter+populate API, so gracefully degrade to a
305
+ // simple data.get() call below rather than failing with "Record not found".
304
306
  }
305
307
  }
306
308