export function objectToKeyValueArray(obj: { [key: string]: any } | null | undefined): Array<{ key: string; value: any }> {
  if (!obj) {
    return [{ key: '', value: '' }]
  }
  return Object.entries(obj).map(([key, value]) => ({
    key,
    value
  }));
}

export function collectionObjectToArray(collection: { name: string; collectionParams: { key: string; value: string } } | null | undefined): Array<{ name: string; collectionParams: { key: string; value: string } }> {
  if (!collection) {
    return [{ name: '', collectionParams: { key: '', value: '' } }];
  }

  return [{
    name: collection.name,
    collectionParams: {
      key: collection.collectionParams.key,
      value: collection.collectionParams.value,
    },
  }];
}