@object-ui/core 3.3.0 → 3.3.1
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 +6 -0
- package/README.md +20 -1
- package/dist/actions/ActionRunner.d.ts +9 -0
- package/dist/actions/ActionRunner.js +41 -4
- package/dist/adapters/ValueDataSource.js +3 -1
- package/dist/utils/filter-converter.js +25 -5
- package/package.json +32 -8
- package/.turbo/turbo-build.log +0 -4
- package/src/__benchmarks__/core.bench.ts +0 -64
- package/src/__tests__/protocols/DndProtocol.test.ts +0 -186
- package/src/__tests__/protocols/KeyboardProtocol.test.ts +0 -177
- package/src/__tests__/protocols/NotificationProtocol.test.ts +0 -142
- package/src/__tests__/protocols/ResponsiveProtocol.test.ts +0 -176
- package/src/__tests__/protocols/SharingProtocol.test.ts +0 -188
- package/src/actions/ActionEngine.ts +0 -268
- package/src/actions/ActionRunner.ts +0 -717
- package/src/actions/TransactionManager.ts +0 -521
- package/src/actions/UndoManager.ts +0 -215
- package/src/actions/__tests__/ActionEngine.test.ts +0 -206
- package/src/actions/__tests__/ActionRunner.params.test.ts +0 -134
- package/src/actions/__tests__/ActionRunner.test.ts +0 -711
- package/src/actions/__tests__/TransactionManager.test.ts +0 -447
- package/src/actions/__tests__/UndoManager.test.ts +0 -320
- package/src/actions/index.ts +0 -12
- package/src/adapters/ApiDataSource.ts +0 -376
- package/src/adapters/README.md +0 -180
- package/src/adapters/ValueDataSource.ts +0 -459
- package/src/adapters/__tests__/ApiDataSource.test.ts +0 -418
- package/src/adapters/__tests__/ValueDataSource.test.ts +0 -571
- package/src/adapters/__tests__/resolveDataSource.test.ts +0 -144
- package/src/adapters/index.ts +0 -15
- package/src/adapters/resolveDataSource.ts +0 -79
- package/src/builder/__tests__/schema-builder.test.ts +0 -235
- package/src/builder/schema-builder.ts +0 -584
- package/src/data-scope/DataScopeManager.ts +0 -269
- package/src/data-scope/ViewDataProvider.ts +0 -282
- package/src/data-scope/__tests__/DataScopeManager.test.ts +0 -211
- package/src/data-scope/__tests__/ViewDataProvider.test.ts +0 -270
- package/src/data-scope/index.ts +0 -24
- package/src/errors/__tests__/errors.test.ts +0 -292
- package/src/errors/index.ts +0 -269
- package/src/evaluator/ExpressionCache.ts +0 -206
- package/src/evaluator/ExpressionContext.ts +0 -118
- package/src/evaluator/ExpressionEvaluator.ts +0 -315
- package/src/evaluator/FormulaFunctions.ts +0 -398
- package/src/evaluator/SafeExpressionParser.ts +0 -893
- package/src/evaluator/__tests__/ExpressionCache.test.ts +0 -135
- package/src/evaluator/__tests__/ExpressionContext.test.ts +0 -110
- package/src/evaluator/__tests__/ExpressionEvaluator.test.ts +0 -558
- package/src/evaluator/__tests__/FormulaFunctions.test.ts +0 -447
- package/src/evaluator/index.ts +0 -13
- package/src/index.ts +0 -38
- package/src/protocols/DndProtocol.ts +0 -168
- package/src/protocols/KeyboardProtocol.ts +0 -181
- package/src/protocols/NotificationProtocol.ts +0 -150
- package/src/protocols/ResponsiveProtocol.ts +0 -210
- package/src/protocols/SharingProtocol.ts +0 -185
- package/src/protocols/index.ts +0 -13
- package/src/query/__tests__/query-ast.test.ts +0 -211
- package/src/query/__tests__/window-functions.test.ts +0 -275
- package/src/query/index.ts +0 -7
- package/src/query/query-ast.ts +0 -341
- package/src/registry/PluginScopeImpl.ts +0 -259
- package/src/registry/PluginSystem.ts +0 -206
- package/src/registry/Registry.ts +0 -219
- package/src/registry/WidgetRegistry.ts +0 -316
- package/src/registry/__tests__/PluginSystem.test.ts +0 -309
- package/src/registry/__tests__/Registry.test.ts +0 -293
- package/src/registry/__tests__/WidgetRegistry.test.ts +0 -321
- package/src/registry/__tests__/plugin-scope-integration.test.ts +0 -283
- package/src/theme/ThemeEngine.ts +0 -530
- package/src/theme/__tests__/ThemeEngine.test.ts +0 -668
- package/src/theme/index.ts +0 -24
- package/src/types/index.ts +0 -21
- package/src/utils/__tests__/debug-collector.test.ts +0 -102
- package/src/utils/__tests__/debug.test.ts +0 -134
- package/src/utils/__tests__/expand-fields.test.ts +0 -120
- package/src/utils/__tests__/extract-records.test.ts +0 -50
- package/src/utils/__tests__/filter-converter.test.ts +0 -118
- package/src/utils/__tests__/merge-views-into-objects.test.ts +0 -110
- package/src/utils/__tests__/normalize-quick-filter.test.ts +0 -123
- package/src/utils/debug-collector.ts +0 -100
- package/src/utils/debug.ts +0 -148
- package/src/utils/expand-fields.ts +0 -76
- package/src/utils/extract-records.ts +0 -33
- package/src/utils/filter-converter.ts +0 -133
- package/src/utils/merge-views-into-objects.ts +0 -36
- package/src/utils/normalize-quick-filter.ts +0 -78
- package/src/validation/__tests__/object-validation-engine.test.ts +0 -567
- package/src/validation/__tests__/schema-validator.test.ts +0 -118
- package/src/validation/__tests__/validation-engine.test.ts +0 -102
- package/src/validation/index.ts +0 -10
- package/src/validation/schema-validator.ts +0 -344
- package/src/validation/validation-engine.ts +0 -528
- package/src/validation/validators/index.ts +0 -25
- package/src/validation/validators/object-validation-engine.ts +0 -722
- package/tsconfig.json +0 -15
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -2
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI — resolveDataSource Tests
|
|
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 { resolveDataSource } from '../resolveDataSource';
|
|
11
|
-
import { ApiDataSource } from '../ApiDataSource';
|
|
12
|
-
import { ValueDataSource } from '../ValueDataSource';
|
|
13
|
-
import type { DataSource, ViewData } from '@object-ui/types';
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Minimal mock DataSource for "object" provider fallback
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
const mockFallback: DataSource<any> = {
|
|
20
|
-
find: async () => ({ data: [], total: 0 }),
|
|
21
|
-
findOne: async () => null,
|
|
22
|
-
create: async (_r, d) => d as any,
|
|
23
|
-
update: async (_r, _id, d) => d as any,
|
|
24
|
-
delete: async () => true,
|
|
25
|
-
getObjectSchema: async (name) => ({ name, fields: {} }),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// Tests
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
describe('resolveDataSource', () => {
|
|
33
|
-
it('should return null when viewData is null and no fallback', () => {
|
|
34
|
-
const ds = resolveDataSource(null);
|
|
35
|
-
expect(ds).toBeNull();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should return fallback when viewData is null', () => {
|
|
39
|
-
const ds = resolveDataSource(null, mockFallback);
|
|
40
|
-
expect(ds).toBe(mockFallback);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should return null when viewData is undefined and no fallback', () => {
|
|
44
|
-
const ds = resolveDataSource(undefined);
|
|
45
|
-
expect(ds).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// -----------------------------------------------------------------------
|
|
49
|
-
// provider: 'object'
|
|
50
|
-
// -----------------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
it('should return fallback for provider: "object"', () => {
|
|
53
|
-
const viewData: ViewData = { provider: 'object', object: 'contacts' };
|
|
54
|
-
const ds = resolveDataSource(viewData, mockFallback);
|
|
55
|
-
expect(ds).toBe(mockFallback);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should return null for provider: "object" without fallback', () => {
|
|
59
|
-
const viewData: ViewData = { provider: 'object', object: 'contacts' };
|
|
60
|
-
const ds = resolveDataSource(viewData);
|
|
61
|
-
expect(ds).toBeNull();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// -----------------------------------------------------------------------
|
|
65
|
-
// provider: 'api'
|
|
66
|
-
// -----------------------------------------------------------------------
|
|
67
|
-
|
|
68
|
-
it('should create ApiDataSource for provider: "api"', () => {
|
|
69
|
-
const viewData: ViewData = {
|
|
70
|
-
provider: 'api',
|
|
71
|
-
read: { url: '/api/contacts' },
|
|
72
|
-
};
|
|
73
|
-
const ds = resolveDataSource(viewData);
|
|
74
|
-
expect(ds).toBeInstanceOf(ApiDataSource);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should create ApiDataSource with read and write configs', () => {
|
|
78
|
-
const viewData: ViewData = {
|
|
79
|
-
provider: 'api',
|
|
80
|
-
read: { url: '/api/contacts', method: 'GET' },
|
|
81
|
-
write: { url: '/api/contacts', method: 'POST' },
|
|
82
|
-
};
|
|
83
|
-
const ds = resolveDataSource(viewData);
|
|
84
|
-
expect(ds).toBeInstanceOf(ApiDataSource);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should pass adapter options to ApiDataSource', () => {
|
|
88
|
-
const viewData: ViewData = {
|
|
89
|
-
provider: 'api',
|
|
90
|
-
read: { url: '/api/contacts' },
|
|
91
|
-
};
|
|
92
|
-
const ds = resolveDataSource(viewData, null, {
|
|
93
|
-
defaultHeaders: { Authorization: 'Bearer test' },
|
|
94
|
-
});
|
|
95
|
-
expect(ds).toBeInstanceOf(ApiDataSource);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// -----------------------------------------------------------------------
|
|
99
|
-
// provider: 'value'
|
|
100
|
-
// -----------------------------------------------------------------------
|
|
101
|
-
|
|
102
|
-
it('should create ValueDataSource for provider: "value"', () => {
|
|
103
|
-
const viewData: ViewData = {
|
|
104
|
-
provider: 'value',
|
|
105
|
-
items: [{ id: '1', name: 'Test' }],
|
|
106
|
-
};
|
|
107
|
-
const ds = resolveDataSource(viewData);
|
|
108
|
-
expect(ds).toBeInstanceOf(ValueDataSource);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should handle empty items array', () => {
|
|
112
|
-
const viewData: ViewData = {
|
|
113
|
-
provider: 'value',
|
|
114
|
-
items: [],
|
|
115
|
-
};
|
|
116
|
-
const ds = resolveDataSource(viewData);
|
|
117
|
-
expect(ds).toBeInstanceOf(ValueDataSource);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should pass idField option to ValueDataSource', () => {
|
|
121
|
-
const viewData: ViewData = {
|
|
122
|
-
provider: 'value',
|
|
123
|
-
items: [{ code: 'A', label: 'Alpha' }],
|
|
124
|
-
};
|
|
125
|
-
const ds = resolveDataSource(viewData, null, { idField: 'code' });
|
|
126
|
-
expect(ds).toBeInstanceOf(ValueDataSource);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// -----------------------------------------------------------------------
|
|
130
|
-
// Unknown provider
|
|
131
|
-
// -----------------------------------------------------------------------
|
|
132
|
-
|
|
133
|
-
it('should return fallback for unknown provider', () => {
|
|
134
|
-
const viewData = { provider: 'graphql' } as unknown as ViewData;
|
|
135
|
-
const ds = resolveDataSource(viewData, mockFallback);
|
|
136
|
-
expect(ds).toBe(mockFallback);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should return null for unknown provider without fallback', () => {
|
|
140
|
-
const viewData = { provider: 'unknown' } as unknown as ViewData;
|
|
141
|
-
const ds = resolveDataSource(viewData);
|
|
142
|
-
expect(ds).toBeNull();
|
|
143
|
-
});
|
|
144
|
-
});
|
package/src/adapters/index.ts
DELETED
|
@@ -1,15 +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
|
-
// export { ObjectStackAdapter, createObjectStackAdapter } from './objectstack-adapter';
|
|
10
|
-
// ObjectStack adapter has been moved to @object-ui/data-objectstack
|
|
11
|
-
|
|
12
|
-
// Generic data source adapters (no external SDK dependencies)
|
|
13
|
-
export { ApiDataSource, type ApiDataSourceConfig } from './ApiDataSource.js';
|
|
14
|
-
export { ValueDataSource, type ValueDataSourceConfig } from './ValueDataSource.js';
|
|
15
|
-
export { resolveDataSource, type ResolveDataSourceOptions } from './resolveDataSource.js';
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI — resolveDataSource
|
|
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
|
-
* Factory function to create the right DataSource from a ViewData config.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { DataSource, ViewData } from '@object-ui/types';
|
|
12
|
-
import { ApiDataSource, type ApiDataSourceConfig } from './ApiDataSource.js';
|
|
13
|
-
import { ValueDataSource } from './ValueDataSource.js';
|
|
14
|
-
|
|
15
|
-
export interface ResolveDataSourceOptions {
|
|
16
|
-
/** Custom fetch implementation passed to ApiDataSource */
|
|
17
|
-
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
18
|
-
/** Default headers for API requests */
|
|
19
|
-
defaultHeaders?: Record<string, string>;
|
|
20
|
-
/** Custom ID field for ValueDataSource */
|
|
21
|
-
idField?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Resolve a ViewData configuration into a concrete DataSource instance.
|
|
26
|
-
*
|
|
27
|
-
* - `provider: 'object'` → returns `fallback` (the context DataSource — typically ObjectStackAdapter)
|
|
28
|
-
* - `provider: 'api'` → returns a new `ApiDataSource`
|
|
29
|
-
* - `provider: 'value'` → returns a new `ValueDataSource`
|
|
30
|
-
*
|
|
31
|
-
* @param viewData - The ViewData configuration from the schema
|
|
32
|
-
* @param fallback - The default DataSource from context (for `provider: 'object'`)
|
|
33
|
-
* @param options - Additional options for adapter construction
|
|
34
|
-
* @returns A DataSource instance, or null if neither viewData nor fallback is available
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```ts
|
|
38
|
-
* const ds = resolveDataSource(
|
|
39
|
-
* { provider: 'api', read: { url: '/api/users' } },
|
|
40
|
-
* contextDataSource,
|
|
41
|
-
* );
|
|
42
|
-
* const result = await ds.find('users');
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export function resolveDataSource<T = any>(
|
|
46
|
-
viewData: ViewData | null | undefined,
|
|
47
|
-
fallback?: DataSource<T> | null,
|
|
48
|
-
options?: ResolveDataSourceOptions,
|
|
49
|
-
): DataSource<T> | null {
|
|
50
|
-
if (!viewData) {
|
|
51
|
-
return fallback ?? null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
switch (viewData.provider) {
|
|
55
|
-
case 'object':
|
|
56
|
-
// Delegate to the context DataSource (ObjectStackAdapter, etc.)
|
|
57
|
-
return fallback ?? null;
|
|
58
|
-
|
|
59
|
-
case 'api': {
|
|
60
|
-
const config: ApiDataSourceConfig = {
|
|
61
|
-
read: viewData.read,
|
|
62
|
-
write: viewData.write,
|
|
63
|
-
fetch: options?.fetch,
|
|
64
|
-
defaultHeaders: options?.defaultHeaders,
|
|
65
|
-
};
|
|
66
|
-
return new ApiDataSource<T>(config);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
case 'value':
|
|
70
|
-
return new ValueDataSource<T>({
|
|
71
|
-
items: (viewData.items ?? []) as T[],
|
|
72
|
-
idField: options?.idField,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
default:
|
|
76
|
-
// Unknown provider — fall back to context
|
|
77
|
-
return fallback ?? null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { form, crud, button, input, card, grid, flex } from '../../builder/schema-builder';
|
|
3
|
-
|
|
4
|
-
describe('SchemaBuilder', () => {
|
|
5
|
-
describe('form()', () => {
|
|
6
|
-
it('creates a basic form schema', () => {
|
|
7
|
-
const schema = form().id('test-form').build();
|
|
8
|
-
expect(schema).toBeDefined();
|
|
9
|
-
expect(schema.type).toBe('form');
|
|
10
|
-
expect(schema.id).toBe('test-form');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('supports field definitions', () => {
|
|
14
|
-
const schema = form()
|
|
15
|
-
.field({ name: 'email', label: 'Email', type: 'string' })
|
|
16
|
-
.build();
|
|
17
|
-
expect(schema.fields).toHaveLength(1);
|
|
18
|
-
expect(schema.fields![0].name).toBe('email');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('supports bulk fields', () => {
|
|
22
|
-
const schema = form()
|
|
23
|
-
.fields([
|
|
24
|
-
{ name: 'first_name', label: 'First Name', type: 'string' },
|
|
25
|
-
{ name: 'last_name', label: 'Last Name', type: 'string' },
|
|
26
|
-
])
|
|
27
|
-
.build();
|
|
28
|
-
expect(schema.fields).toHaveLength(2);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('supports default values', () => {
|
|
32
|
-
const schema = form()
|
|
33
|
-
.defaultValues({ status: 'active' })
|
|
34
|
-
.build();
|
|
35
|
-
expect(schema.defaultValues).toEqual({ status: 'active' });
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('supports submit label', () => {
|
|
39
|
-
const schema = form()
|
|
40
|
-
.submitLabel('Create')
|
|
41
|
-
.build();
|
|
42
|
-
expect(schema.submitLabel).toBe('Create');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('supports layout option', () => {
|
|
46
|
-
const schema = form()
|
|
47
|
-
.layout('vertical')
|
|
48
|
-
.build();
|
|
49
|
-
expect(schema.layout).toBe('vertical');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('supports columns', () => {
|
|
53
|
-
const schema = form()
|
|
54
|
-
.columns(2)
|
|
55
|
-
.build();
|
|
56
|
-
expect(schema.columns).toBe(2);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('supports chaining', () => {
|
|
60
|
-
const schema = form()
|
|
61
|
-
.id('chained')
|
|
62
|
-
.field({ name: 'name', label: 'Name', type: 'string' })
|
|
63
|
-
.submitLabel('Submit')
|
|
64
|
-
.layout('horizontal')
|
|
65
|
-
.columns(3)
|
|
66
|
-
.build();
|
|
67
|
-
expect(schema.id).toBe('chained');
|
|
68
|
-
expect(schema.fields).toHaveLength(1);
|
|
69
|
-
expect(schema.submitLabel).toBe('Submit');
|
|
70
|
-
expect(schema.layout).toBe('horizontal');
|
|
71
|
-
expect(schema.columns).toBe(3);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe('crud()', () => {
|
|
76
|
-
it('creates a basic CRUD schema', () => {
|
|
77
|
-
const schema = crud().id('test-crud').build();
|
|
78
|
-
expect(schema).toBeDefined();
|
|
79
|
-
expect(schema.type).toBe('crud');
|
|
80
|
-
expect(schema.id).toBe('test-crud');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('supports resource definition', () => {
|
|
84
|
-
const schema = crud()
|
|
85
|
-
.resource('users')
|
|
86
|
-
.build();
|
|
87
|
-
expect(schema.resource).toBe('users');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('supports column definitions', () => {
|
|
91
|
-
const schema = crud()
|
|
92
|
-
.column({ name: 'name', label: 'Name' })
|
|
93
|
-
.build();
|
|
94
|
-
expect(schema.columns).toHaveLength(1);
|
|
95
|
-
expect(schema.columns![0].name).toBe('name');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('supports bulk columns', () => {
|
|
99
|
-
const schema = crud()
|
|
100
|
-
.columns([
|
|
101
|
-
{ name: 'id', label: 'ID' },
|
|
102
|
-
{ name: 'name', label: 'Name' },
|
|
103
|
-
])
|
|
104
|
-
.build();
|
|
105
|
-
expect(schema.columns).toHaveLength(2);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('supports CRUD operations', () => {
|
|
109
|
-
const schema = crud()
|
|
110
|
-
.api('/api/users')
|
|
111
|
-
.enableCreate()
|
|
112
|
-
.enableUpdate()
|
|
113
|
-
.enableDelete()
|
|
114
|
-
.build();
|
|
115
|
-
expect(schema.operations).toBeDefined();
|
|
116
|
-
expect(schema.operations!.create.enabled).toBe(true);
|
|
117
|
-
expect(schema.operations!.update.enabled).toBe(true);
|
|
118
|
-
expect(schema.operations!.delete.enabled).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('supports pagination', () => {
|
|
122
|
-
const schema = crud()
|
|
123
|
-
.pagination(25)
|
|
124
|
-
.build();
|
|
125
|
-
expect(schema.pagination).toBeDefined();
|
|
126
|
-
expect(schema.pagination!.enabled).toBe(true);
|
|
127
|
-
expect(schema.pagination!.pageSize).toBe(25);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe('button()', () => {
|
|
132
|
-
it('creates a button schema', () => {
|
|
133
|
-
const schema = button().id('btn').build();
|
|
134
|
-
expect(schema).toBeDefined();
|
|
135
|
-
expect(schema.type).toBe('button');
|
|
136
|
-
expect(schema.id).toBe('btn');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('supports label', () => {
|
|
140
|
-
const schema = button()
|
|
141
|
-
.label('Click Me')
|
|
142
|
-
.build();
|
|
143
|
-
expect(schema.label).toBe('Click Me');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('supports variant', () => {
|
|
147
|
-
const schema = button()
|
|
148
|
-
.variant('destructive')
|
|
149
|
-
.build();
|
|
150
|
-
expect(schema.variant).toBe('destructive');
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('input()', () => {
|
|
155
|
-
it('creates an input schema', () => {
|
|
156
|
-
const schema = input().id('my-input').build();
|
|
157
|
-
expect(schema).toBeDefined();
|
|
158
|
-
expect(schema.type).toBe('input');
|
|
159
|
-
expect(schema.id).toBe('my-input');
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('supports label and placeholder', () => {
|
|
163
|
-
const schema = input()
|
|
164
|
-
.label('Username')
|
|
165
|
-
.placeholder('Enter username')
|
|
166
|
-
.build();
|
|
167
|
-
expect(schema.label).toBe('Username');
|
|
168
|
-
expect(schema.placeholder).toBe('Enter username');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('card()', () => {
|
|
173
|
-
it('creates a card schema', () => {
|
|
174
|
-
const schema = card().id('my-card').build();
|
|
175
|
-
expect(schema).toBeDefined();
|
|
176
|
-
expect(schema.type).toBe('card');
|
|
177
|
-
expect(schema.id).toBe('my-card');
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
describe('grid()', () => {
|
|
182
|
-
it('creates a grid schema', () => {
|
|
183
|
-
const schema = grid().id('my-grid').build();
|
|
184
|
-
expect(schema).toBeDefined();
|
|
185
|
-
expect(schema.type).toBe('grid');
|
|
186
|
-
expect(schema.id).toBe('my-grid');
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('flex()', () => {
|
|
191
|
-
it('creates a flex schema', () => {
|
|
192
|
-
const schema = flex().id('my-flex').build();
|
|
193
|
-
expect(schema).toBeDefined();
|
|
194
|
-
expect(schema.type).toBe('flex');
|
|
195
|
-
expect(schema.id).toBe('my-flex');
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it('supports direction', () => {
|
|
199
|
-
const schema = flex()
|
|
200
|
-
.direction('row')
|
|
201
|
-
.build();
|
|
202
|
-
expect(schema.direction).toBe('row');
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe('common builder properties', () => {
|
|
207
|
-
it('supports className', () => {
|
|
208
|
-
const schema = button()
|
|
209
|
-
.className('my-class')
|
|
210
|
-
.build();
|
|
211
|
-
expect(schema.className).toBe('my-class');
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('supports visible', () => {
|
|
215
|
-
const schema = button()
|
|
216
|
-
.visible(false)
|
|
217
|
-
.build();
|
|
218
|
-
expect(schema.visible).toBe(false);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it('supports disabled', () => {
|
|
222
|
-
const schema = button()
|
|
223
|
-
.disabled(true)
|
|
224
|
-
.build();
|
|
225
|
-
expect(schema.disabled).toBe(true);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('supports testId', () => {
|
|
229
|
-
const schema = button()
|
|
230
|
-
.testId('test-btn')
|
|
231
|
-
.build();
|
|
232
|
-
expect(schema.testId).toBe('test-btn');
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
});
|