@object-ui/data-objectstack 17.5.0 → 17.6.0
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/CHANGELOG.md +219 -0
- package/dist/index.cjs +262 -357
- package/dist/index.d.cts +385 -448
- package/dist/index.d.ts +385 -448
- package/dist/index.js +258 -350
- package/package.json +5 -6
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/aggregate-capability.test.ts +0 -177
- package/src/apiAccessDenied.test.ts +0 -233
- package/src/appAccessProbe.test.ts +0 -147
- package/src/bulkDelete.test.ts +0 -75
- package/src/bulkUpdate.test.ts +0 -93
- package/src/cache/MetadataCache.test.ts +0 -477
- package/src/cache/MetadataCache.ts +0 -289
- package/src/cloud-surface-retired-4152.pin.test.ts +0 -171
- package/src/connection.test.ts +0 -188
- package/src/contracts.ts +0 -115
- package/src/deleteView.homes.test.ts +0 -389
- package/src/deleteViewContract.types.test.ts +0 -246
- package/src/errors.test.ts +0 -426
- package/src/errors.ts +0 -293
- package/src/exportDownload.test.ts +0 -141
- package/src/filter-entry-translation.test.ts +0 -360
- package/src/filter-operator-ast-parity.test.ts +0 -135
- package/src/getObjectSchema.test.ts +0 -145
- package/src/httpFailureLogging.test.ts +0 -109
- package/src/importJob.test.ts +0 -71
- package/src/index.ts +0 -4442
- package/src/integration.ts +0 -200
- package/src/listViewOverrides.test.ts +0 -241
- package/src/listViews.test.ts +0 -175
- package/src/metadata-client.get-envelope.test.ts +0 -171
- package/src/metadata-client.saveAdvisories.test.ts +0 -226
- package/src/metadata-client.test.ts +0 -303
- package/src/metadata-client.ts +0 -1046
- package/src/occ.test.ts +0 -101
- package/src/onMutation.test.ts +0 -589
- package/src/onSaveAdvisory.test.ts +0 -311
- package/src/onWriteWarning.test.ts +0 -273
- package/src/orderby-serialization.test.ts +0 -115
- package/src/queryDataset.test.ts +0 -543
- package/src/searchAll.test.ts +0 -120
- package/src/security.ts +0 -243
- package/src/spec-symbol-batch6.test.ts +0 -326
- package/src/studio.ts +0 -152
- package/src/updateView.draft.test.ts +0 -242
- package/src/userState.test.ts +0 -315
- package/src/userState.ts +0 -238
- package/src/v3-compat.test.ts +0 -229
- package/src/validation-error.test.ts +0 -94
- package/src/viewCacheInvalidation.pin.test.ts +0 -260
- package/src/viewInvalidationSeam.pin.test.ts +0 -162
package/src/occ.test.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from 'vitest';
|
|
10
|
-
import {
|
|
11
|
-
ConcurrentUpdateError,
|
|
12
|
-
isConcurrentUpdateError,
|
|
13
|
-
normaliseClientError,
|
|
14
|
-
} from './index';
|
|
15
|
-
|
|
16
|
-
describe('Optimistic Concurrency Control errors', () => {
|
|
17
|
-
describe('ConcurrentUpdateError', () => {
|
|
18
|
-
it('carries currentVersion + currentRecord and a stable shape', () => {
|
|
19
|
-
const e = new ConcurrentUpdateError({
|
|
20
|
-
currentVersion: '2026-05-22T07:14:00.000Z',
|
|
21
|
-
currentRecord: { id: 'rec_1', name: 'Acme', updated_at: '2026-05-22T07:14:00.000Z' },
|
|
22
|
-
message: 'stale write',
|
|
23
|
-
});
|
|
24
|
-
expect(e).toBeInstanceOf(Error);
|
|
25
|
-
expect(e.name).toBe('ConcurrentUpdateError');
|
|
26
|
-
expect(e.code).toBe('CONCURRENT_UPDATE');
|
|
27
|
-
expect(e.httpStatus).toBe(409);
|
|
28
|
-
expect(e.currentVersion).toBe('2026-05-22T07:14:00.000Z');
|
|
29
|
-
expect((e.currentRecord as any).name).toBe('Acme');
|
|
30
|
-
expect(e.message).toBe('stale write');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('defaults to a generic message when none is supplied', () => {
|
|
34
|
-
const e = new ConcurrentUpdateError({ currentVersion: null, currentRecord: null });
|
|
35
|
-
expect(e.message).toMatch(/modified/i);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('isConcurrentUpdateError', () => {
|
|
40
|
-
it('returns true for our typed instances', () => {
|
|
41
|
-
const e = new ConcurrentUpdateError({ currentVersion: null, currentRecord: null });
|
|
42
|
-
expect(isConcurrentUpdateError(e)).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('returns true for plain objects with the canonical code', () => {
|
|
46
|
-
expect(isConcurrentUpdateError({ code: 'CONCURRENT_UPDATE' })).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('returns false for unrelated errors', () => {
|
|
50
|
-
expect(isConcurrentUpdateError(new Error('boom'))).toBe(false);
|
|
51
|
-
expect(isConcurrentUpdateError({ code: 'NOT_FOUND' })).toBe(false);
|
|
52
|
-
expect(isConcurrentUpdateError(null)).toBe(false);
|
|
53
|
-
expect(isConcurrentUpdateError(undefined)).toBe(false);
|
|
54
|
-
expect(isConcurrentUpdateError('CONCURRENT_UPDATE')).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('normaliseClientError', () => {
|
|
59
|
-
it('returns the original error when it is not a 409 CONCURRENT_UPDATE', () => {
|
|
60
|
-
const generic = Object.assign(new Error('not found'), {
|
|
61
|
-
code: 'NOT_FOUND',
|
|
62
|
-
httpStatus: 404,
|
|
63
|
-
});
|
|
64
|
-
expect(normaliseClientError(generic)).toBe(generic);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('returns the original error for non-object inputs', () => {
|
|
68
|
-
expect(normaliseClientError(null)).toBe(null);
|
|
69
|
-
expect(normaliseClientError(undefined)).toBe(undefined);
|
|
70
|
-
expect(normaliseClientError('boom')).toBe('boom');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('wraps an upstream 409 CONCURRENT_UPDATE into a typed ConcurrentUpdateError', () => {
|
|
74
|
-
const upstream = Object.assign(new Error('Record was modified by another user'), {
|
|
75
|
-
code: 'CONCURRENT_UPDATE',
|
|
76
|
-
httpStatus: 409,
|
|
77
|
-
details: {
|
|
78
|
-
currentVersion: '2026-05-22T07:14:00.000Z',
|
|
79
|
-
currentRecord: { id: 'rec_1', name: 'Acme' },
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
const normalised = normaliseClientError(upstream);
|
|
83
|
-
expect(isConcurrentUpdateError(normalised)).toBe(true);
|
|
84
|
-
const typed = normalised as ConcurrentUpdateError;
|
|
85
|
-
expect(typed.currentVersion).toBe('2026-05-22T07:14:00.000Z');
|
|
86
|
-
expect((typed.currentRecord as any).name).toBe('Acme');
|
|
87
|
-
expect(typed.message).toBe('Record was modified by another user');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('tolerates a missing details payload', () => {
|
|
91
|
-
const upstream = Object.assign(new Error('stale'), {
|
|
92
|
-
code: 'CONCURRENT_UPDATE',
|
|
93
|
-
httpStatus: 409,
|
|
94
|
-
});
|
|
95
|
-
const normalised = normaliseClientError(upstream) as ConcurrentUpdateError;
|
|
96
|
-
expect(isConcurrentUpdateError(normalised)).toBe(true);
|
|
97
|
-
expect(normalised.currentVersion).toBeNull();
|
|
98
|
-
expect(normalised.currentRecord).toBeNull();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|