form0-core 0.1.23 → 0.1.25
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "form0-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"main": "src/index.js",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "node tests/form0-core.test.js && node tests/dataset-descriptors.test.js && node tests/structured-record.test.js && node tests/builtin-metadata.test.js && node tests/calculation-editor.test.js && node tests/form-event-editor.test.js && node tests/security-test.js",
|
|
11
|
+
"test": "node tests/form0-core.test.js && node tests/numeric-field-schema.test.js && node tests/dataset-descriptors.test.js && node tests/structured-record.test.js && node tests/builtin-metadata.test.js && node tests/calculation-editor.test.js && node tests/form-event-editor.test.js && node tests/security-test.js",
|
|
12
12
|
"format": "prettier --write \"**/*.{js,jsx,json,ts,tsx,md}\"",
|
|
13
13
|
"format:check": "prettier --check \"**/*.{js,jsx,json,ts,tsx,md}\""
|
|
14
14
|
},
|
package/src/index.js
CHANGED
|
@@ -202,7 +202,10 @@ export const FIELD_SPECS = {
|
|
|
202
202
|
schemaValidators: [
|
|
203
203
|
// Validate min/max relationship (cross-attribute validation)
|
|
204
204
|
(field) => {
|
|
205
|
-
|
|
205
|
+
const hasMin = field.min !== null && field.min !== undefined;
|
|
206
|
+
const hasMax = field.max !== null && field.max !== undefined;
|
|
207
|
+
|
|
208
|
+
if (hasMin && hasMax && field.min > field.max) {
|
|
206
209
|
return { isValid: false, error: `NumericField "${field.data_name}" has min > max` };
|
|
207
210
|
}
|
|
208
211
|
return { isValid: true };
|
|
@@ -237,6 +237,39 @@ const DISPLAY_ONLY_SEMANTICS = {
|
|
|
237
237
|
allowed_operators: [],
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
+
const MEDIA_FIELD_TYPES = new Set([
|
|
241
|
+
'PhotoField',
|
|
242
|
+
'VideoField',
|
|
243
|
+
'SignatureField',
|
|
244
|
+
'Photo',
|
|
245
|
+
'Video',
|
|
246
|
+
'Signature',
|
|
247
|
+
]);
|
|
248
|
+
const NON_DATA_FIELD_TYPES = new Set([
|
|
249
|
+
'LabelField',
|
|
250
|
+
'Section',
|
|
251
|
+
'RepeatableSection',
|
|
252
|
+
'BuildingPlanSection',
|
|
253
|
+
]);
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Exportability is intentionally independent from query semantics. Media fields are
|
|
257
|
+
* display-only in the query engine, but are first-class export columns whose values
|
|
258
|
+
* are resolved by an authorized media gateway.
|
|
259
|
+
*/
|
|
260
|
+
export function getFieldExportKind(field) {
|
|
261
|
+
const fieldType = toTrimmedString(field?.type ?? field?.field_type);
|
|
262
|
+
if (!fieldType || NON_DATA_FIELD_TYPES.has(fieldType)) {
|
|
263
|
+
return 'none';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (MEDIA_FIELD_TYPES.has(fieldType)) {
|
|
267
|
+
return 'media';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return 'value';
|
|
271
|
+
}
|
|
272
|
+
|
|
240
273
|
const getCalculatedFieldSemantics = (field) => {
|
|
241
274
|
const style = getCalculatedDisplayStyle(field);
|
|
242
275
|
|
|
@@ -402,6 +435,7 @@ const buildDatasetFieldDescriptor = (field, dataset) => {
|
|
|
402
435
|
data_name: toTrimmedString(field.data_name),
|
|
403
436
|
label: toFieldLabel(field),
|
|
404
437
|
field_type: toTrimmedString(field.type) ?? 'UnknownField',
|
|
438
|
+
export_kind: getFieldExportKind(field),
|
|
405
439
|
choices: Array.isArray(field.choices)
|
|
406
440
|
? field.choices.filter((choice) => isRecord(choice)).map((choice) => ({ ...choice }))
|
|
407
441
|
: undefined,
|