/**
 * @file documentField.ts - Type definitions for document template field instance types.
 * Use {@link DocumentFieldTypes} to reference type IDs, {@link DocumentFieldTypeName} for the string key, and {@link DocumentFieldTypesLabels} to reverse-lookup a numeric ID back to its human-readable name.
 */

/**
 * Const object mapping document field data type names to their numeric identifiers as defined in the Process Director system.
 */
export const DocumentFieldTypes = {
  Boolean: 1,
  Integer: 2,
  Number: 3,
  Date: 4,
  String: 5,
} as const;

/** String literal union of document field type names (e.g. `'Boolean'`, `'String'`) */
export type DocumentFieldTypeName = keyof typeof DocumentFieldTypes;

/** Numeric union of document field type identifiers (1 | 2 | 3 | 4 | 5) */
export type DocumentFieldType =
  (typeof DocumentFieldTypes)[keyof typeof DocumentFieldTypes];

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