@finos/legend-query-builder 4.16.19 → 4.16.21
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/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts +21 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.d.ts.map +1 -1
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js +16 -2
- package/lib/components/__test-utils__/QueryBuilderComponentTestUtils.js.map +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +1 -1
- package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js +1 -1
- package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts +155 -4
- package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -1
- package/lib/components/shared/BasicValueSpecificationEditor.js +239 -158
- package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -1
- package/lib/components/shared/CustomDatePicker.d.ts +8 -55
- package/lib/components/shared/CustomDatePicker.d.ts.map +1 -1
- package/lib/components/shared/CustomDatePicker.js +31 -415
- package/lib/components/shared/CustomDatePicker.js.map +1 -1
- package/lib/components/shared/CustomDatePickerHelper.d.ts +145 -0
- package/lib/components/shared/CustomDatePickerHelper.d.ts.map +1 -0
- package/lib/components/shared/CustomDatePickerHelper.js +517 -0
- package/lib/components/shared/CustomDatePickerHelper.js.map +1 -0
- package/lib/components/shared/QueryBuilderVariableSelector.js +1 -1
- package/lib/components/shared/QueryBuilderVariableSelector.js.map +1 -1
- package/lib/components/shared/V1_BasicValueSpecificationEditor.d.ts +36 -0
- package/lib/components/shared/V1_BasicValueSpecificationEditor.d.ts.map +1 -0
- package/lib/components/shared/V1_BasicValueSpecificationEditor.js +166 -0
- package/lib/components/shared/V1_BasicValueSpecificationEditor.js.map +1 -0
- package/lib/index.css +16 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/shared/V1_ValueSpecificationEditorHelper.d.ts +23 -0
- package/lib/stores/shared/V1_ValueSpecificationEditorHelper.d.ts.map +1 -0
- package/lib/stores/shared/V1_ValueSpecificationEditorHelper.js +69 -0
- package/lib/stores/shared/V1_ValueSpecificationEditorHelper.js.map +1 -0
- package/lib/stores/shared/V1_ValueSpecificationModifierHelper.d.ts +20 -0
- package/lib/stores/shared/V1_ValueSpecificationModifierHelper.d.ts.map +1 -0
- package/lib/stores/shared/V1_ValueSpecificationModifierHelper.js +38 -0
- package/lib/stores/shared/V1_ValueSpecificationModifierHelper.js.map +1 -0
- package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts +4 -1
- package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -1
- package/lib/stores/shared/ValueSpecificationEditorHelper.js +23 -2
- package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -1
- package/package.json +5 -5
- package/src/components/__test-utils__/QueryBuilderComponentTestUtils.tsx +101 -12
- package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +1 -1
- package/src/components/filter/QueryBuilderFilterPanel.tsx +1 -1
- package/src/components/shared/BasicValueSpecificationEditor.tsx +1417 -1085
- package/src/components/shared/CustomDatePicker.tsx +136 -902
- package/src/components/shared/CustomDatePickerHelper.ts +984 -0
- package/src/components/shared/QueryBuilderVariableSelector.tsx +1 -1
- package/src/components/shared/V1_BasicValueSpecificationEditor.tsx +396 -0
- package/src/index.ts +5 -0
- package/src/stores/shared/V1_ValueSpecificationEditorHelper.ts +113 -0
- package/src/stores/shared/V1_ValueSpecificationModifierHelper.ts +76 -0
- package/src/stores/shared/ValueSpecificationEditorHelper.ts +71 -2
- package/tsconfig.json +4 -0
@@ -42,7 +42,7 @@ import {
|
|
42
42
|
QUERY_BUILDER_VARIABLE_DND_TYPE,
|
43
43
|
VariableInfoTooltip,
|
44
44
|
} from './BasicValueSpecificationEditor.js';
|
45
|
-
import { buildDatePickerOption } from './
|
45
|
+
import { buildDatePickerOption } from './CustomDatePickerHelper.js';
|
46
46
|
import { QueryBuilderSimpleConstantExpressionState } from '../../stores/QueryBuilderConstantsState.js';
|
47
47
|
import { forwardRef, useRef, useState } from 'react';
|
48
48
|
|
@@ -0,0 +1,396 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import { type SelectComponent } from '@finos/legend-art';
|
18
|
+
import {
|
19
|
+
type Type,
|
20
|
+
type V1_AppliedFunction,
|
21
|
+
type V1_CDate,
|
22
|
+
type V1_Enumeration,
|
23
|
+
type V1_Multiplicity,
|
24
|
+
type V1_ValueSpecification,
|
25
|
+
PRIMITIVE_TYPE,
|
26
|
+
V1_AppliedProperty,
|
27
|
+
V1_CBoolean,
|
28
|
+
V1_CDateTime,
|
29
|
+
V1_CDecimal,
|
30
|
+
V1_CFloat,
|
31
|
+
V1_CInteger,
|
32
|
+
V1_CLatestDate,
|
33
|
+
V1_Collection,
|
34
|
+
V1_CStrictDate,
|
35
|
+
V1_CString,
|
36
|
+
V1_EnumValue,
|
37
|
+
V1_observe_AppliedProperty,
|
38
|
+
V1_observe_ValueSpecification,
|
39
|
+
V1_PackageableType,
|
40
|
+
V1_PrimitiveValueSpecification,
|
41
|
+
} from '@finos/legend-graph';
|
42
|
+
import {
|
43
|
+
csvStringify,
|
44
|
+
guaranteeNonNullable,
|
45
|
+
guaranteeType,
|
46
|
+
isNonNullable,
|
47
|
+
} from '@finos/legend-shared';
|
48
|
+
import React, { forwardRef } from 'react';
|
49
|
+
import {
|
50
|
+
type BasicValueSpecificationEditorSelectorConfig,
|
51
|
+
BooleanPrimitiveInstanceValueEditor,
|
52
|
+
CollectionValueInstanceValueEditor,
|
53
|
+
DateInstanceValueEditor,
|
54
|
+
EnumInstanceValueEditor,
|
55
|
+
NumberPrimitiveInstanceValueEditor,
|
56
|
+
StringPrimitiveInstanceValueEditor,
|
57
|
+
} from './BasicValueSpecificationEditor.js';
|
58
|
+
import {
|
59
|
+
V1_AppliedProperty_setProperty,
|
60
|
+
V1_Collection_setValues,
|
61
|
+
V1_PrimitiveValue_setValue,
|
62
|
+
} from '../../stores/shared/V1_ValueSpecificationModifierHelper.js';
|
63
|
+
import {
|
64
|
+
type CustomDatePickerUpdateValueSpecification,
|
65
|
+
buildV1PureAdjustDateFunction,
|
66
|
+
buildV1PureDateFunctionExpression,
|
67
|
+
CustomDateOption,
|
68
|
+
CustomFirstDayOfOption,
|
69
|
+
CustomPreviousDayOfWeekOption,
|
70
|
+
DatePickerOption,
|
71
|
+
} from './CustomDatePickerHelper.js';
|
72
|
+
import {
|
73
|
+
_elementPtr,
|
74
|
+
_primitiveValue,
|
75
|
+
_property,
|
76
|
+
isPrimitiveType,
|
77
|
+
} from '@finos/legend-data-cube';
|
78
|
+
import {
|
79
|
+
getV1_ValueSpecificationStringValue,
|
80
|
+
isValidV1_ValueSpecification,
|
81
|
+
} from '../../stores/shared/V1_ValueSpecificationEditorHelper.js';
|
82
|
+
import { useApplicationStore } from '@finos/legend-application';
|
83
|
+
|
84
|
+
export interface V1_TypeCheckOption {
|
85
|
+
expectedType: V1_PackageableType;
|
86
|
+
match?: boolean;
|
87
|
+
}
|
88
|
+
|
89
|
+
// Placeholder for unsupported value specifications
|
90
|
+
const V1_UnsupportedValueSpecificationEditor: React.FC<{ type: string }> = (
|
91
|
+
props,
|
92
|
+
) => (
|
93
|
+
<div className="value-spec-editor--unsupported">
|
94
|
+
Unsupported V1 type: {props.type}
|
95
|
+
</div>
|
96
|
+
);
|
97
|
+
|
98
|
+
// Helper functions for collection values
|
99
|
+
const V1_stringifyValue = (values: V1_ValueSpecification[]): string => {
|
100
|
+
if (values.length === 0) {
|
101
|
+
return '';
|
102
|
+
}
|
103
|
+
return csvStringify([
|
104
|
+
values
|
105
|
+
.map((val) => {
|
106
|
+
if (val instanceof V1_PrimitiveValueSpecification) {
|
107
|
+
if (!(val instanceof V1_CLatestDate)) {
|
108
|
+
return (val as unknown as { value: unknown }).value;
|
109
|
+
} else {
|
110
|
+
return val;
|
111
|
+
}
|
112
|
+
} else if (val instanceof V1_EnumValue) {
|
113
|
+
return val.value;
|
114
|
+
} else if (val instanceof V1_AppliedProperty) {
|
115
|
+
return val.property;
|
116
|
+
}
|
117
|
+
return undefined;
|
118
|
+
})
|
119
|
+
.filter(isNonNullable),
|
120
|
+
]).trim();
|
121
|
+
};
|
122
|
+
|
123
|
+
// Main component
|
124
|
+
export const V1_BasicValueSpecificationEditor = forwardRef<
|
125
|
+
HTMLInputElement | null,
|
126
|
+
{
|
127
|
+
valueSpecification: V1_ValueSpecification;
|
128
|
+
multiplicity: V1_Multiplicity;
|
129
|
+
typeCheckOption: V1_TypeCheckOption;
|
130
|
+
className?: string | undefined;
|
131
|
+
setValueSpecification: (val: V1_ValueSpecification) => void;
|
132
|
+
resetValue: () => void;
|
133
|
+
selectorConfig?: BasicValueSpecificationEditorSelectorConfig | undefined;
|
134
|
+
handleBlur?: (() => void) | undefined;
|
135
|
+
handleKeyDown?:
|
136
|
+
| ((event: React.KeyboardEvent<HTMLInputElement>) => void)
|
137
|
+
| undefined;
|
138
|
+
displayDateEditorAsEditableValue?: boolean | undefined;
|
139
|
+
enumeration?: V1_Enumeration | undefined;
|
140
|
+
}
|
141
|
+
>(function V1_BasicValueSpecificationEditor(props, ref) {
|
142
|
+
const {
|
143
|
+
className,
|
144
|
+
valueSpecification,
|
145
|
+
multiplicity,
|
146
|
+
typeCheckOption,
|
147
|
+
setValueSpecification,
|
148
|
+
resetValue,
|
149
|
+
handleBlur,
|
150
|
+
handleKeyDown,
|
151
|
+
enumeration,
|
152
|
+
selectorConfig,
|
153
|
+
} = props;
|
154
|
+
|
155
|
+
const applicationStore = useApplicationStore();
|
156
|
+
const errorChecker = (_valueSpecification: V1_PrimitiveValueSpecification) =>
|
157
|
+
!isValidV1_ValueSpecification(_valueSpecification);
|
158
|
+
|
159
|
+
// Handle non-collection editors
|
160
|
+
if (multiplicity.upperBound !== undefined) {
|
161
|
+
if (typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.STRING) {
|
162
|
+
return (
|
163
|
+
<StringPrimitiveInstanceValueEditor<V1_CString>
|
164
|
+
valueSpecification={guaranteeType(valueSpecification, V1_CString)}
|
165
|
+
valueSelector={(val: V1_CString) => val.value}
|
166
|
+
updateValueSpecification={(
|
167
|
+
_valueSpecification: V1_CString,
|
168
|
+
value: string | null,
|
169
|
+
) => {
|
170
|
+
V1_PrimitiveValue_setValue(_valueSpecification, value ?? '');
|
171
|
+
setValueSpecification(_valueSpecification);
|
172
|
+
}}
|
173
|
+
className={className}
|
174
|
+
resetValue={resetValue}
|
175
|
+
ref={
|
176
|
+
ref as React.ForwardedRef<HTMLInputElement | SelectComponent | null>
|
177
|
+
}
|
178
|
+
handleBlur={handleBlur}
|
179
|
+
handleKeyDown={handleKeyDown}
|
180
|
+
errorChecker={errorChecker}
|
181
|
+
selectorConfig={selectorConfig}
|
182
|
+
/>
|
183
|
+
);
|
184
|
+
} else if (
|
185
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.BOOLEAN
|
186
|
+
) {
|
187
|
+
return (
|
188
|
+
<BooleanPrimitiveInstanceValueEditor<V1_CBoolean>
|
189
|
+
valueSpecification={guaranteeType(valueSpecification, V1_CBoolean)}
|
190
|
+
valueSelector={(val: V1_CBoolean) => val.value}
|
191
|
+
updateValueSpecification={(
|
192
|
+
_valueSpecification: V1_CBoolean,
|
193
|
+
value: boolean,
|
194
|
+
) => {
|
195
|
+
V1_PrimitiveValue_setValue(_valueSpecification, value);
|
196
|
+
setValueSpecification(_valueSpecification);
|
197
|
+
}}
|
198
|
+
className={className}
|
199
|
+
resetValue={resetValue}
|
200
|
+
/>
|
201
|
+
);
|
202
|
+
} else if (
|
203
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.BINARY ||
|
204
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.BYTE ||
|
205
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.DECIMAL ||
|
206
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.FLOAT ||
|
207
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.INTEGER ||
|
208
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.NUMBER
|
209
|
+
) {
|
210
|
+
const numericValueSpecification =
|
211
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.INTEGER
|
212
|
+
? guaranteeType(valueSpecification, V1_CInteger)
|
213
|
+
: typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.DECIMAL
|
214
|
+
? guaranteeType(valueSpecification, V1_CDecimal)
|
215
|
+
: guaranteeType(valueSpecification, V1_CFloat);
|
216
|
+
return (
|
217
|
+
<NumberPrimitiveInstanceValueEditor<
|
218
|
+
V1_CInteger | V1_CDecimal | V1_CFloat
|
219
|
+
>
|
220
|
+
valueSpecification={numericValueSpecification}
|
221
|
+
valueSelector={(val: V1_CInteger | V1_CDecimal | V1_CFloat) =>
|
222
|
+
val.value
|
223
|
+
}
|
224
|
+
isInteger={valueSpecification instanceof V1_CInteger}
|
225
|
+
updateValueSpecification={(
|
226
|
+
_valueSpecification: V1_CInteger | V1_CDecimal | V1_CFloat,
|
227
|
+
value: number | null,
|
228
|
+
) => {
|
229
|
+
V1_PrimitiveValue_setValue(_valueSpecification, value);
|
230
|
+
setValueSpecification(_valueSpecification);
|
231
|
+
}}
|
232
|
+
className={className}
|
233
|
+
resetValue={resetValue}
|
234
|
+
ref={ref}
|
235
|
+
handleBlur={handleBlur}
|
236
|
+
handleKeyDown={handleKeyDown}
|
237
|
+
errorChecker={errorChecker}
|
238
|
+
/>
|
239
|
+
);
|
240
|
+
} else if (
|
241
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.DATE ||
|
242
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.STRICTDATE ||
|
243
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.DATETIME ||
|
244
|
+
typeCheckOption.expectedType.fullPath === PRIMITIVE_TYPE.LATESTDATE
|
245
|
+
) {
|
246
|
+
const dateValueSelector = (
|
247
|
+
_valueSpecification: V1_CDate | V1_AppliedFunction | V1_CString,
|
248
|
+
) =>
|
249
|
+
_valueSpecification instanceof V1_CDateTime ||
|
250
|
+
_valueSpecification instanceof V1_CStrictDate ||
|
251
|
+
_valueSpecification instanceof V1_CString
|
252
|
+
? _valueSpecification.value
|
253
|
+
: '';
|
254
|
+
const dateUpdateValueSpecification: CustomDatePickerUpdateValueSpecification<
|
255
|
+
V1_CDateTime | V1_CStrictDate | V1_CLatestDate | undefined
|
256
|
+
> = (_valueSpecification, value, options): void => {
|
257
|
+
if (value instanceof CustomDateOption) {
|
258
|
+
setValueSpecification(buildV1PureAdjustDateFunction(value));
|
259
|
+
} else if (value instanceof CustomFirstDayOfOption) {
|
260
|
+
setValueSpecification(buildV1PureDateFunctionExpression(value));
|
261
|
+
} else if (value instanceof CustomPreviousDayOfWeekOption) {
|
262
|
+
setValueSpecification(buildV1PureDateFunctionExpression(value));
|
263
|
+
} else if (value instanceof DatePickerOption) {
|
264
|
+
setValueSpecification(buildV1PureDateFunctionExpression(value));
|
265
|
+
} else {
|
266
|
+
const _type = guaranteeNonNullable(options?.primitiveTypeEnum);
|
267
|
+
setValueSpecification(_primitiveValue(_type, value));
|
268
|
+
}
|
269
|
+
};
|
270
|
+
return (
|
271
|
+
<DateInstanceValueEditor<V1_CDate | V1_AppliedFunction | V1_CString>
|
272
|
+
valueSpecification={
|
273
|
+
valueSpecification as V1_CDate | V1_AppliedFunction | V1_CString
|
274
|
+
}
|
275
|
+
valueSelector={dateValueSelector}
|
276
|
+
updateValueSpecification={dateUpdateValueSpecification}
|
277
|
+
typeCheckOption={typeCheckOption}
|
278
|
+
resetValue={resetValue}
|
279
|
+
className={className}
|
280
|
+
errorChecker={errorChecker}
|
281
|
+
/>
|
282
|
+
);
|
283
|
+
}
|
284
|
+
// Enum editors should have enumeration passed in the props
|
285
|
+
if (enumeration) {
|
286
|
+
const options = enumeration.values.map((enumValue) => ({
|
287
|
+
label: enumValue.value,
|
288
|
+
value: enumValue.value,
|
289
|
+
}));
|
290
|
+
return (
|
291
|
+
<EnumInstanceValueEditor<V1_AppliedProperty>
|
292
|
+
valueSpecification={guaranteeType(
|
293
|
+
valueSpecification,
|
294
|
+
V1_AppliedProperty,
|
295
|
+
)}
|
296
|
+
valueSelector={(val: V1_AppliedProperty) => val.property}
|
297
|
+
options={options}
|
298
|
+
className={className}
|
299
|
+
resetValue={resetValue}
|
300
|
+
updateValueSpecification={(
|
301
|
+
_valueSpecification: V1_AppliedProperty,
|
302
|
+
value: string | null,
|
303
|
+
) => {
|
304
|
+
V1_AppliedProperty_setProperty(
|
305
|
+
_valueSpecification,
|
306
|
+
guaranteeNonNullable(value),
|
307
|
+
);
|
308
|
+
setValueSpecification(_valueSpecification);
|
309
|
+
}}
|
310
|
+
handleBlur={handleBlur}
|
311
|
+
errorChecker={errorChecker}
|
312
|
+
selectorConfig={selectorConfig}
|
313
|
+
/>
|
314
|
+
);
|
315
|
+
}
|
316
|
+
} else {
|
317
|
+
// Handle collection editors
|
318
|
+
const collectionValueSpecification = guaranteeType(
|
319
|
+
valueSpecification,
|
320
|
+
V1_Collection,
|
321
|
+
);
|
322
|
+
const updateValueSpecification = (
|
323
|
+
_collectionValueSpecification: V1_Collection,
|
324
|
+
valueSpecifications: V1_ValueSpecification[],
|
325
|
+
) => {
|
326
|
+
V1_Collection_setValues(
|
327
|
+
_collectionValueSpecification,
|
328
|
+
valueSpecifications,
|
329
|
+
);
|
330
|
+
setValueSpecification(_collectionValueSpecification);
|
331
|
+
};
|
332
|
+
const stringifyCollectionValueSpecification = (
|
333
|
+
_collectionValueSpecification: V1_Collection,
|
334
|
+
): string => {
|
335
|
+
return V1_stringifyValue(_collectionValueSpecification.values);
|
336
|
+
};
|
337
|
+
const convertValueSpecificationToText = (
|
338
|
+
_valueSpecification: V1_ValueSpecification,
|
339
|
+
): string | undefined => {
|
340
|
+
return getV1_ValueSpecificationStringValue(
|
341
|
+
_valueSpecification,
|
342
|
+
applicationStore,
|
343
|
+
);
|
344
|
+
};
|
345
|
+
const convertTextToValueSpecification = (
|
346
|
+
_type: Type | V1_PackageableType,
|
347
|
+
text: string,
|
348
|
+
): V1_ValueSpecification | null => {
|
349
|
+
const packageableType = guaranteeType(
|
350
|
+
_type,
|
351
|
+
V1_PackageableType,
|
352
|
+
'Cannot convert text to V1_ValueSpecification. Expected type to be a V1_PackageableType',
|
353
|
+
);
|
354
|
+
if (isPrimitiveType(packageableType.fullPath)) {
|
355
|
+
const primitiveVal = _primitiveValue(
|
356
|
+
packageableType.fullPath,
|
357
|
+
text,
|
358
|
+
true,
|
359
|
+
);
|
360
|
+
return V1_observe_ValueSpecification(primitiveVal);
|
361
|
+
} else {
|
362
|
+
// If not a primitive, assume it is an enum
|
363
|
+
const typeParam = _elementPtr(packageableType.fullPath);
|
364
|
+
return V1_observe_AppliedProperty(_property(text, [typeParam]));
|
365
|
+
}
|
366
|
+
};
|
367
|
+
const enumOptions = enumeration?.values.map((enumValue) => ({
|
368
|
+
label: enumValue.value,
|
369
|
+
value: enumValue.value,
|
370
|
+
}));
|
371
|
+
|
372
|
+
return (
|
373
|
+
<CollectionValueInstanceValueEditor<V1_ValueSpecification, V1_Collection>
|
374
|
+
valueSpecification={collectionValueSpecification}
|
375
|
+
updateValueSpecification={updateValueSpecification}
|
376
|
+
expectedType={typeCheckOption.expectedType}
|
377
|
+
stringifyCollectionValueSpecification={
|
378
|
+
stringifyCollectionValueSpecification
|
379
|
+
}
|
380
|
+
convertValueSpecificationToText={convertValueSpecificationToText}
|
381
|
+
convertTextToValueSpecification={convertTextToValueSpecification}
|
382
|
+
enumOptions={enumOptions}
|
383
|
+
errorChecker={errorChecker}
|
384
|
+
className={className}
|
385
|
+
selectorConfig={selectorConfig}
|
386
|
+
/>
|
387
|
+
);
|
388
|
+
}
|
389
|
+
|
390
|
+
// Default case for unsupported value specifications
|
391
|
+
return (
|
392
|
+
<V1_UnsupportedValueSpecificationEditor
|
393
|
+
type={typeCheckOption.expectedType.fullPath}
|
394
|
+
/>
|
395
|
+
);
|
396
|
+
});
|
package/src/index.ts
CHANGED
@@ -111,9 +111,14 @@ export * from './stores/shared/LambdaParameterState.js';
|
|
111
111
|
export * from './components/shared/BasicValueSpecificationEditor.js';
|
112
112
|
export * from './components/shared/LambdaParameterValuesEditor.js';
|
113
113
|
|
114
|
+
export * from './components/shared/V1_BasicValueSpecificationEditor.js';
|
115
|
+
|
114
116
|
export * from './stores/shared/ValueSpecificationModifierHelper.js';
|
115
117
|
export * from './stores/shared/ValueSpecificationEditorHelper.js';
|
116
118
|
|
119
|
+
export * from './stores/shared/V1_ValueSpecificationModifierHelper.js';
|
120
|
+
export * from './stores/shared/V1_ValueSpecificationEditorHelper.js';
|
121
|
+
|
117
122
|
export * from './components/execution-plan/ExecutionPlanViewer.js';
|
118
123
|
export * from './stores/execution-plan/ExecutionPlanState.js';
|
119
124
|
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import {
|
18
|
+
type V1_ValueSpecification,
|
19
|
+
V1_AppliedProperty,
|
20
|
+
V1_CBoolean,
|
21
|
+
V1_CByteArray,
|
22
|
+
V1_CDate,
|
23
|
+
V1_CDateTime,
|
24
|
+
V1_CDecimal,
|
25
|
+
V1_CFloat,
|
26
|
+
V1_CInteger,
|
27
|
+
V1_Collection,
|
28
|
+
V1_CStrictDate,
|
29
|
+
V1_CStrictTime,
|
30
|
+
V1_CString,
|
31
|
+
V1_EnumValue,
|
32
|
+
V1_PrimitiveValueSpecification,
|
33
|
+
} from '@finos/legend-graph';
|
34
|
+
import { buildDatePickerOption } from '../../components/shared/CustomDatePickerHelper.js';
|
35
|
+
import type {
|
36
|
+
ApplicationStore,
|
37
|
+
LegendApplicationConfig,
|
38
|
+
LegendApplicationPluginManager,
|
39
|
+
LegendApplicationPlugin,
|
40
|
+
} from '@finos/legend-application';
|
41
|
+
|
42
|
+
export const getV1_ValueSpecificationStringValue = (
|
43
|
+
valueSpecification: V1_ValueSpecification,
|
44
|
+
applicationStore: ApplicationStore<
|
45
|
+
LegendApplicationConfig,
|
46
|
+
LegendApplicationPluginManager<LegendApplicationPlugin>
|
47
|
+
>,
|
48
|
+
options?: {
|
49
|
+
omitEnumOwnerName?: boolean;
|
50
|
+
wrapStringInDoubleQuotes?: boolean;
|
51
|
+
},
|
52
|
+
): string | undefined => {
|
53
|
+
if (
|
54
|
+
valueSpecification instanceof V1_CDate ||
|
55
|
+
valueSpecification instanceof V1_CStrictTime
|
56
|
+
) {
|
57
|
+
return buildDatePickerOption(valueSpecification, applicationStore).label;
|
58
|
+
} else if (valueSpecification instanceof V1_CString) {
|
59
|
+
return options?.wrapStringInDoubleQuotes
|
60
|
+
? `"${valueSpecification.value.toString()}"`
|
61
|
+
: valueSpecification.value.toString();
|
62
|
+
} else if (
|
63
|
+
valueSpecification instanceof V1_CBoolean ||
|
64
|
+
valueSpecification instanceof V1_CByteArray ||
|
65
|
+
valueSpecification instanceof V1_CDecimal ||
|
66
|
+
valueSpecification instanceof V1_CFloat ||
|
67
|
+
valueSpecification instanceof V1_CInteger ||
|
68
|
+
valueSpecification instanceof V1_EnumValue
|
69
|
+
) {
|
70
|
+
return valueSpecification.value.toString();
|
71
|
+
} else if (valueSpecification instanceof V1_AppliedProperty) {
|
72
|
+
return valueSpecification.property;
|
73
|
+
} else if (valueSpecification instanceof V1_Collection) {
|
74
|
+
return valueSpecification.values
|
75
|
+
.map((valueSpec) =>
|
76
|
+
getV1_ValueSpecificationStringValue(
|
77
|
+
valueSpec,
|
78
|
+
applicationStore,
|
79
|
+
options,
|
80
|
+
),
|
81
|
+
)
|
82
|
+
.join(',');
|
83
|
+
}
|
84
|
+
return undefined;
|
85
|
+
};
|
86
|
+
|
87
|
+
export const isValidV1_ValueSpecification = (
|
88
|
+
valueSpecification: V1_ValueSpecification,
|
89
|
+
): boolean => {
|
90
|
+
if (valueSpecification instanceof V1_PrimitiveValueSpecification) {
|
91
|
+
const isRequired = valueSpecification.multiplicity.lowerBound >= 1;
|
92
|
+
// required and no values provided. LatestDate doesn't have any values so we skip that check for it.
|
93
|
+
if (
|
94
|
+
isRequired &&
|
95
|
+
(valueSpecification instanceof V1_CBoolean ||
|
96
|
+
valueSpecification instanceof V1_CByteArray ||
|
97
|
+
valueSpecification instanceof V1_CDecimal ||
|
98
|
+
valueSpecification instanceof V1_CFloat ||
|
99
|
+
valueSpecification instanceof V1_CInteger ||
|
100
|
+
valueSpecification instanceof V1_CStrictTime ||
|
101
|
+
valueSpecification instanceof V1_CString ||
|
102
|
+
valueSpecification instanceof V1_CDateTime ||
|
103
|
+
valueSpecification instanceof V1_CStrictDate)
|
104
|
+
) {
|
105
|
+
return true;
|
106
|
+
}
|
107
|
+
} else if (valueSpecification instanceof V1_Collection) {
|
108
|
+
// collection instance must have all valid values.
|
109
|
+
return valueSpecification.values.every(isValidV1_ValueSpecification);
|
110
|
+
}
|
111
|
+
|
112
|
+
return true;
|
113
|
+
};
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
import {
|
18
|
+
type V1_AppliedProperty,
|
19
|
+
type V1_CByteArray,
|
20
|
+
type V1_CDateTime,
|
21
|
+
type V1_Collection,
|
22
|
+
type V1_CStrictDate,
|
23
|
+
type V1_CStrictTime,
|
24
|
+
type V1_CString,
|
25
|
+
type V1_ValueSpecification,
|
26
|
+
V1_CBoolean,
|
27
|
+
V1_CDecimal,
|
28
|
+
V1_CFloat,
|
29
|
+
V1_CInteger,
|
30
|
+
} from '@finos/legend-graph';
|
31
|
+
import {
|
32
|
+
guaranteeIsBoolean,
|
33
|
+
guaranteeIsNumber,
|
34
|
+
guaranteeIsString,
|
35
|
+
} from '@finos/legend-shared';
|
36
|
+
import { action } from 'mobx';
|
37
|
+
|
38
|
+
export const V1_PrimitiveValue_setValue = action(
|
39
|
+
(
|
40
|
+
target:
|
41
|
+
| V1_CBoolean
|
42
|
+
| V1_CByteArray
|
43
|
+
| V1_CDateTime
|
44
|
+
| V1_CDecimal
|
45
|
+
| V1_CFloat
|
46
|
+
| V1_CInteger
|
47
|
+
| V1_CStrictDate
|
48
|
+
| V1_CStrictTime
|
49
|
+
| V1_CString,
|
50
|
+
val: unknown,
|
51
|
+
) => {
|
52
|
+
if (target instanceof V1_CBoolean) {
|
53
|
+
target.value = guaranteeIsBoolean(val);
|
54
|
+
} else if (
|
55
|
+
target instanceof V1_CDecimal ||
|
56
|
+
target instanceof V1_CFloat ||
|
57
|
+
target instanceof V1_CInteger
|
58
|
+
) {
|
59
|
+
target.value = guaranteeIsNumber(val);
|
60
|
+
} else {
|
61
|
+
target.value = guaranteeIsString(val);
|
62
|
+
}
|
63
|
+
},
|
64
|
+
);
|
65
|
+
|
66
|
+
export const V1_AppliedProperty_setProperty = action(
|
67
|
+
(target: V1_AppliedProperty, val: string) => {
|
68
|
+
target.property = val;
|
69
|
+
},
|
70
|
+
);
|
71
|
+
|
72
|
+
export const V1_Collection_setValues = action(
|
73
|
+
(target: V1_Collection, val: V1_ValueSpecification[]) => {
|
74
|
+
target.values = val;
|
75
|
+
},
|
76
|
+
);
|