From bed2332886431d9d771f8a9d3a697bbe64111e4c Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Thu, 17 Sep 2020 14:50:04 -0400 Subject: [PATCH] Move parseTypes function to utils --- app/src/types/fields.ts | 9 --------- app/src/utils/get-js-type.ts | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 app/src/utils/get-js-type.ts diff --git a/app/src/types/fields.ts b/app/src/types/fields.ts index 7726896a02..03decabbee 100644 --- a/app/src/types/fields.ts +++ b/app/src/types/fields.ts @@ -27,15 +27,6 @@ export const types = [ 'unknown', ] as const; -export function parseTypes(type: typeof types[number]) { - if (['bigInteger', 'integer', 'float', 'decimal'].includes(type)) return 'number'; - if (['string', 'text', 'uuid'].includes(type)) return 'string'; - if (['boolean'].includes(type)) return 'boolean'; - if (['time', 'timestamp', 'date', 'dateTime'].includes(type)) return 'string'; - if (['json', 'csv'].includes(type)) return 'object'; - return 'undefined'; -} - export type FieldSchema = { /** @todo import this from knex-schema-inspector when that's launched */ name: string; diff --git a/app/src/utils/get-js-type.ts b/app/src/utils/get-js-type.ts new file mode 100644 index 0000000000..aed687ef92 --- /dev/null +++ b/app/src/utils/get-js-type.ts @@ -0,0 +1,10 @@ +import { types } from '@/types'; + +export function getJSType(type: typeof types[number]) { + if (['bigInteger', 'integer', 'float', 'decimal'].includes(type)) return 'number'; + if (['string', 'text', 'uuid'].includes(type)) return 'string'; + if (['boolean'].includes(type)) return 'boolean'; + if (['time', 'timestamp', 'date', 'dateTime'].includes(type)) return 'string'; + if (['json', 'csv'].includes(type)) return 'object'; + return 'undefined'; +}