/**
 * @file fieldInstance.ts - Type definitions for folder field instance types.
 * Use {@link FieldInstanceTypes} to reference type IDs, {@link FieldInstanceTypeName} for the string key, and {@link FieldInstanceTypesLabels} to reverse-lookup a numeric ID back to its human-readable name.
 */

/**
 * Const object mapping field instance data type names to their numeric identifiers as defined in the Process Director system.
 */
export const FieldInstanceTypes = {
  Date: 6,
  Number: 1,
  String: 5,
  Option: 7,
} as const;

/** String literal union of field instance type names (e.g. `'Date'`, `'Option'`) */
export type FieldInstanceTypeName = keyof typeof FieldInstanceTypes;

/** Numeric union of field instance type identifiers (1 | 5 | 6 | 7) */
export type FieldInstanceType =
  (typeof FieldInstanceTypes)[keyof typeof FieldInstanceTypes];

/**
 * Reverse lookup map that resolves a numeric {@link FieldInstanceType} value back to its corresponding type name string.
 */
export const FieldInstanceTypesLabels = Object.fromEntries(
  Object.entries(FieldInstanceTypes).map(([key, value]) => [value, key])
) as Record<FieldInstanceType, keyof typeof FieldInstanceTypes>;
