form0-core 0.1.23 → 0.1.24

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.23",
3
+ "version": "0.1.24",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
package/src/index.js CHANGED
@@ -36,6 +36,7 @@ export { buildRepeatableMetadata } from './utilities/repeatable-helpers.js';
36
36
  export {
37
37
  buildDatasetDescriptors,
38
38
  buildFieldIdentityMap,
39
+ getFieldExportKind,
39
40
  getFieldQuerySemantics,
40
41
  projectDatasetRowValues,
41
42
  resolveDatasetDescriptorById,
@@ -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,