@kronor/dtv 0.2.9
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/.editorconfig +12 -0
- package/.github/copilot-instructions.md +64 -0
- package/.github/workflows/ci.yml +51 -0
- package/.husky/pre-commit +8 -0
- package/README.md +63 -0
- package/docs/api/README.md +32 -0
- package/docs/api/cell-renderers.md +121 -0
- package/docs/api/no-rows-component.md +71 -0
- package/docs/api/runtime.md +78 -0
- package/e2e/app.spec.ts +6 -0
- package/e2e/cell-renderer-setfilterstate.spec.ts +63 -0
- package/e2e/filter-sharing.spec.ts +113 -0
- package/e2e/filter-url-persistence.spec.ts +36 -0
- package/e2e/graphqlMock.ts +144 -0
- package/e2e/multi-field-filters.spec.ts +95 -0
- package/e2e/pagination.spec.ts +38 -0
- package/e2e/payment-request-email-filter.spec.ts +67 -0
- package/e2e/save-filter-splitbutton.spec.ts +68 -0
- package/e2e/simple-view-email-filter.spec.ts +67 -0
- package/e2e/simple-view-transforms.spec.ts +171 -0
- package/e2e/simple-view.spec.ts +104 -0
- package/e2e/transform-regression.spec.ts +108 -0
- package/eslint.config.js +30 -0
- package/index.html +17 -0
- package/jest.config.js +10 -0
- package/package.json +45 -0
- package/playwright.config.ts +54 -0
- package/public/vite.svg +1 -0
- package/src/App.externalRuntime.test.ts +190 -0
- package/src/App.tsx +540 -0
- package/src/assets/react.svg +1 -0
- package/src/components/AIAssistantForm.tsx +241 -0
- package/src/components/FilterForm.test.ts +82 -0
- package/src/components/FilterForm.tsx +375 -0
- package/src/components/PhoneNumberFilter.tsx +102 -0
- package/src/components/SavedFilterList.tsx +181 -0
- package/src/components/SpeechInput.tsx +67 -0
- package/src/components/Table.tsx +119 -0
- package/src/components/TablePagination.tsx +40 -0
- package/src/components/aiAssistant.test.ts +270 -0
- package/src/components/aiAssistant.ts +291 -0
- package/src/framework/cell-renderer-components/CurrencyAmount.tsx +30 -0
- package/src/framework/cell-renderer-components/LayoutHelpers.tsx +74 -0
- package/src/framework/cell-renderer-components/Link.tsx +28 -0
- package/src/framework/cell-renderer-components/Mapping.tsx +11 -0
- package/src/framework/cell-renderer-components.test.ts +353 -0
- package/src/framework/column-definition.tsx +85 -0
- package/src/framework/currency.test.ts +46 -0
- package/src/framework/currency.ts +62 -0
- package/src/framework/data.staticConditions.test.ts +46 -0
- package/src/framework/data.test.ts +167 -0
- package/src/framework/data.ts +162 -0
- package/src/framework/filter-form-state.test.ts +189 -0
- package/src/framework/filter-form-state.ts +185 -0
- package/src/framework/filter-sharing.test.ts +135 -0
- package/src/framework/filter-sharing.ts +118 -0
- package/src/framework/filters.ts +194 -0
- package/src/framework/graphql.buildHasuraConditions.test.ts +473 -0
- package/src/framework/graphql.paginationKey.test.ts +29 -0
- package/src/framework/graphql.test.ts +286 -0
- package/src/framework/graphql.ts +462 -0
- package/src/framework/native-runtime/index.tsx +33 -0
- package/src/framework/native-runtime/nativeComponents.test.ts +108 -0
- package/src/framework/runtime-reference.test.ts +172 -0
- package/src/framework/runtime.ts +15 -0
- package/src/framework/saved-filters.test.ts +422 -0
- package/src/framework/saved-filters.ts +293 -0
- package/src/framework/state.test.ts +86 -0
- package/src/framework/state.ts +148 -0
- package/src/framework/transform.test.ts +51 -0
- package/src/framework/view-parser-initialvalues.test.ts +228 -0
- package/src/framework/view-parser.ts +714 -0
- package/src/framework/view.test.ts +1805 -0
- package/src/framework/view.ts +38 -0
- package/src/index.css +6 -0
- package/src/main.tsx +99 -0
- package/src/views/index.ts +12 -0
- package/src/views/payment-requests/components/NoRowsExtendDateRange.tsx +37 -0
- package/src/views/payment-requests/components/PaymentMethod.tsx +184 -0
- package/src/views/payment-requests/components/PaymentStatusTag.tsx +61 -0
- package/src/views/payment-requests/index.ts +1 -0
- package/src/views/payment-requests/runtime.tsx +145 -0
- package/src/views/payment-requests/view.json +692 -0
- package/src/views/payment-requests-initial-values.test.ts +73 -0
- package/src/views/request-log/index.ts +2 -0
- package/src/views/request-log/runtime.tsx +47 -0
- package/src/views/request-log/view.json +123 -0
- package/src/views/simple-test-view/index.ts +3 -0
- package/src/views/simple-test-view/runtime.tsx +85 -0
- package/src/views/simple-test-view/view.json +191 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +7 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.jest.json +6 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +11 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Tag } from 'primereact/tag';
|
|
3
|
+
import { parseViewJson } from './framework/view-parser';
|
|
4
|
+
import { FlexRow, FlexColumn, DateTime } from './framework/cell-renderer-components/LayoutHelpers';
|
|
5
|
+
import { CurrencyAmount } from './framework/cell-renderer-components/CurrencyAmount';
|
|
6
|
+
import { Mapping } from './framework/cell-renderer-components/Mapping';
|
|
7
|
+
import { Link } from './framework/cell-renderer-components/Link';
|
|
8
|
+
|
|
9
|
+
describe('External Runtime Integration', () => {
|
|
10
|
+
it('should use external runtime when available', () => {
|
|
11
|
+
const builtInRuntime = {
|
|
12
|
+
cellRenderers: {},
|
|
13
|
+
queryTransforms: {},
|
|
14
|
+
noRowsComponents: {},
|
|
15
|
+
customFilterComponents: {},
|
|
16
|
+
initialValues: {}
|
|
17
|
+
};
|
|
18
|
+
const externalRuntime = {
|
|
19
|
+
cellRenderers: {
|
|
20
|
+
customCellRenderer: () => 'Custom Cell',
|
|
21
|
+
},
|
|
22
|
+
queryTransforms: {
|
|
23
|
+
customTransform: {
|
|
24
|
+
toQuery: (input: any) => ({ value: input }),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
noRowsComponents: {
|
|
28
|
+
customNoRows: () => 'No rows custom component',
|
|
29
|
+
},
|
|
30
|
+
customFilterComponents: {
|
|
31
|
+
customFilter: () => 'Custom filter',
|
|
32
|
+
},
|
|
33
|
+
initialValues: {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const testView = {
|
|
37
|
+
title: 'Test External Runtime View',
|
|
38
|
+
id: 'test-external-runtime',
|
|
39
|
+
collectionName: 'testCollection',
|
|
40
|
+
paginationKey: 'id',
|
|
41
|
+
boolExpType: 'TestBoolExp',
|
|
42
|
+
orderByType: '[TestOrderBy!]',
|
|
43
|
+
columns: [
|
|
44
|
+
{
|
|
45
|
+
data: [{ type: 'field', path: 'id' }],
|
|
46
|
+
name: 'ID',
|
|
47
|
+
cellRenderer: { section: 'cellRenderers', key: 'customCellRenderer' },
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
filterSchema: {
|
|
51
|
+
groups: [{ name: 'default', label: null }],
|
|
52
|
+
filters: [],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Test that parseViewJson works with external runtime
|
|
57
|
+
expect(() => {
|
|
58
|
+
const view = parseViewJson(testView, builtInRuntime, externalRuntime);
|
|
59
|
+
expect(view.title).toBe('Test External Runtime View');
|
|
60
|
+
expect(view.columnDefinitions).toHaveLength(1);
|
|
61
|
+
expect(view.columnDefinitions[0].name).toBe('ID');
|
|
62
|
+
expect(typeof view.columnDefinitions[0].cellRenderer).toBe('function');
|
|
63
|
+
}).not.toThrow();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should fall back to built-in runtime when external runtime key not found', () => {
|
|
67
|
+
const builtInRuntime = {
|
|
68
|
+
cellRenderers: {
|
|
69
|
+
text: () => 'Built-in Text Cell',
|
|
70
|
+
},
|
|
71
|
+
queryTransforms: {},
|
|
72
|
+
noRowsComponents: {},
|
|
73
|
+
customFilterComponents: {},
|
|
74
|
+
initialValues: {}
|
|
75
|
+
};
|
|
76
|
+
const externalRuntime = undefined; // No external runtime provided
|
|
77
|
+
|
|
78
|
+
const testView = {
|
|
79
|
+
title: 'Test Fallback Runtime View',
|
|
80
|
+
id: 'test-fallback-runtime',
|
|
81
|
+
collectionName: 'testCollection',
|
|
82
|
+
paginationKey: 'id',
|
|
83
|
+
boolExpType: 'TestBoolExp',
|
|
84
|
+
orderByType: '[TestOrderBy!]',
|
|
85
|
+
columns: [
|
|
86
|
+
{
|
|
87
|
+
data: [{ type: 'field', path: 'id' }],
|
|
88
|
+
name: 'ID',
|
|
89
|
+
cellRenderer: { section: 'cellRenderers', key: 'text' },
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
filterSchema: {
|
|
93
|
+
groups: [{ name: 'default', label: null }],
|
|
94
|
+
filters: [],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Test that built-in runtime is used when external doesn't have the key
|
|
99
|
+
expect(() => {
|
|
100
|
+
const view = parseViewJson(testView, builtInRuntime, externalRuntime);
|
|
101
|
+
expect(view.title).toBe('Test Fallback Runtime View');
|
|
102
|
+
// Test the cell renderer function
|
|
103
|
+
const cellRenderer = view.columnDefinitions[0].cellRenderer;
|
|
104
|
+
const mockProps = {
|
|
105
|
+
data: { id: 'test' },
|
|
106
|
+
setFilterState: () => { },
|
|
107
|
+
applyFilters: () => { },
|
|
108
|
+
updateFilterById: () => { },
|
|
109
|
+
createElement: React.createElement,
|
|
110
|
+
components: {
|
|
111
|
+
Badge: Tag,
|
|
112
|
+
FlexRow,
|
|
113
|
+
FlexColumn,
|
|
114
|
+
Mapping,
|
|
115
|
+
DateTime,
|
|
116
|
+
CurrencyAmount,
|
|
117
|
+
Link
|
|
118
|
+
},
|
|
119
|
+
currency: { majorToMinor: (n: number) => n, minorToMajor: (n: number) => n }
|
|
120
|
+
};
|
|
121
|
+
expect(cellRenderer(mockProps)).toBe('Built-in Text Cell');
|
|
122
|
+
}).not.toThrow();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should prefer external runtime over built-in when both have same key', () => {
|
|
126
|
+
const builtInRuntime = {
|
|
127
|
+
cellRenderers: {
|
|
128
|
+
text: () => 'Built-in Default',
|
|
129
|
+
},
|
|
130
|
+
queryTransforms: {},
|
|
131
|
+
noRowsComponents: {},
|
|
132
|
+
customFilterComponents: {},
|
|
133
|
+
initialValues: {}
|
|
134
|
+
};
|
|
135
|
+
const externalRuntime = {
|
|
136
|
+
cellRenderers: {
|
|
137
|
+
text: () => 'External Override',
|
|
138
|
+
},
|
|
139
|
+
queryTransforms: {},
|
|
140
|
+
noRowsComponents: {},
|
|
141
|
+
customFilterComponents: {},
|
|
142
|
+
initialValues: {}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const testView = {
|
|
146
|
+
title: 'Test Precedence View',
|
|
147
|
+
id: 'test-precedence',
|
|
148
|
+
collectionName: 'testCollection',
|
|
149
|
+
paginationKey: 'id',
|
|
150
|
+
boolExpType: 'TestBoolExp',
|
|
151
|
+
orderByType: '[TestOrderBy!]',
|
|
152
|
+
columns: [
|
|
153
|
+
{
|
|
154
|
+
data: [{ type: 'field', path: 'id' }],
|
|
155
|
+
name: 'ID',
|
|
156
|
+
cellRenderer: { section: 'cellRenderers', key: 'text' },
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
filterSchema: {
|
|
160
|
+
groups: [{ name: 'default', label: null }],
|
|
161
|
+
filters: [],
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
expect(() => {
|
|
166
|
+
const view = parseViewJson(testView, builtInRuntime, externalRuntime);
|
|
167
|
+
expect(view.title).toBe('Test Precedence View');
|
|
168
|
+
// Test that external runtime took precedence
|
|
169
|
+
const cellRenderer = view.columnDefinitions[0].cellRenderer;
|
|
170
|
+
const mockProps = {
|
|
171
|
+
data: { id: 'test' },
|
|
172
|
+
setFilterState: () => { },
|
|
173
|
+
applyFilters: () => { },
|
|
174
|
+
updateFilterById: () => { },
|
|
175
|
+
createElement: React.createElement,
|
|
176
|
+
components: {
|
|
177
|
+
Badge: Tag,
|
|
178
|
+
FlexRow,
|
|
179
|
+
FlexColumn,
|
|
180
|
+
Mapping,
|
|
181
|
+
DateTime,
|
|
182
|
+
CurrencyAmount,
|
|
183
|
+
Link
|
|
184
|
+
},
|
|
185
|
+
currency: { majorToMinor: (n: number) => n, minorToMajor: (n: number) => n }
|
|
186
|
+
};
|
|
187
|
+
expect(cellRenderer(mockProps)).toBe('External Override');
|
|
188
|
+
}).not.toThrow();
|
|
189
|
+
});
|
|
190
|
+
});
|