@8base/utils
Advanced tools
Comparing version 0.29.2 to 0.30.0
@@ -84,2 +84,9 @@ export declare const FIELD_TYPE: { | ||
export declare const MUTATION_FILE_FIELDS: string[]; | ||
export declare const APP_STATUS: { | ||
ACTIVE: 'ACTIVE'; | ||
INACTIVE: 'INACTIVE'; | ||
}; | ||
export declare const APP_TYPES: { | ||
SALESFORCE: string; | ||
}; | ||
//# sourceMappingURL=schemaConstants.d.ts.map |
@@ -86,2 +86,9 @@ "use strict"; | ||
exports.MUTATION_FILE_FIELDS = ['fileId', 'public', 'filename', 'meta', 'mods']; | ||
exports.APP_STATUS = { | ||
ACTIVE: 'ACTIVE', | ||
INACTIVE: 'INACTIVE', | ||
}; | ||
exports.APP_TYPES = { | ||
SALESFORCE: 'salesforce', | ||
}; | ||
//# sourceMappingURL=schemaConstants.js.map |
import { TableSchema, QueryGeneratorConfig } from '../types'; | ||
declare type QueryTableFilterConfig = { | ||
tableContentName?: string; | ||
appContentName?: string; | ||
} & QueryGeneratorConfig; | ||
@@ -5,0 +6,0 @@ export declare const createTableFilterGraphqlTag: (tablesList: TableSchema[], tableId: string, config?: QueryTableFilterConfig) => string; |
@@ -32,2 +32,11 @@ "use strict"; | ||
const upperFirst = (str) => R.toUpper(R.head(str)) + R.tail(str); | ||
const wrapInAppName = (appName, appContentName) => (queryString) => { | ||
if (!appName) { | ||
return queryString; | ||
} | ||
return ` | ||
${appContentName ? `${appContentName}: ` : ''}${appName} { | ||
${queryString} | ||
}`; | ||
}; | ||
const getTable = (tablesList, tableId) => { | ||
@@ -42,7 +51,8 @@ const table = selectors_1.tablesListSelectors.getTableById(tablesList, tableId); | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true } = config, restConfig = __rest(config, ["withResultData"]); | ||
return graphql_prettier_1.default(` | ||
query ${upperFirst(table.name)}TableContent( | ||
$filter: ${schema_name_generator_1.SchemaNameGenerator.getFilterInputTypeName(table.name)} | ||
$orderBy: [${schema_name_generator_1.SchemaNameGenerator.getOrderByInputTypeName(table.name)}] | ||
$filter: ${schema_name_generator_1.SchemaNameGenerator.getFilterInputTypeName(table.name, appName)} | ||
$orderBy: [${schema_name_generator_1.SchemaNameGenerator.getOrderByInputTypeName(table.name, appName)}] | ||
$after: String | ||
@@ -54,2 +64,3 @@ $before: String | ||
) { | ||
${wrapInAppName(appName, config.appContentName)(` | ||
${config.tableContentName ? `${config.tableContentName}: ` : ''}${schema_name_generator_1.SchemaNameGenerator.getTableListFieldName(table.name)}( | ||
@@ -70,3 +81,3 @@ filter: $filter | ||
count | ||
} | ||
}`)} | ||
}`); | ||
@@ -76,2 +87,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const hasNonMetaFields = tableSelectors.hasNonMetaFields(table); | ||
@@ -81,7 +93,8 @@ const { withResultData = true } = config, restConfig = __rest(config, ["withResultData"]); | ||
return graphql_prettier_1.default(` | ||
mutation ${upperFirst(table.name)}Create($data: ${schema_name_generator_1.SchemaNameGenerator.getCreateInputName(table.name)}!) { | ||
mutation ${upperFirst(table.name)}Create($data: ${schema_name_generator_1.SchemaNameGenerator.getCreateInputName(table.name, appName)}!) { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getCreateItemFieldName(table.name)}(data: $data) { | ||
id | ||
${withResultData ? createQueryString_1.createQueryString(tablesList, tableId, Object.assign({ withMeta: false }, restConfig)) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -91,6 +104,7 @@ } | ||
mutation ${upperFirst(table.name)}Create { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getCreateItemFieldName(table.name)} { | ||
id | ||
${withResultData ? createQueryString_1.createQueryString(tablesList, tableId, Object.assign({ withMeta: false }, restConfig)) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -100,9 +114,11 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const hasNonMetaFields = tableSelectors.hasNonMetaFields(table); | ||
if (hasNonMetaFields) { | ||
return graphql_prettier_1.default(` | ||
mutation ${upperFirst(table.name)}CreateMany($data: [${schema_name_generator_1.SchemaNameGenerator.getCreateManyInputName(table.name)}]!) { | ||
mutation ${upperFirst(table.name)}CreateMany($data: [${schema_name_generator_1.SchemaNameGenerator.getCreateManyInputName(table.name, appName)}]!) { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getCreateManyItemFieldName(table.name)}(data: $data) { | ||
count | ||
} | ||
}`)} | ||
}`); | ||
@@ -112,5 +128,6 @@ } | ||
mutation ${upperFirst(table.name)}CreateMany { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getCreateManyItemFieldName(table.name)} { | ||
count | ||
} | ||
}`)} | ||
}`; | ||
@@ -120,12 +137,14 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true } = config, restConfig = __rest(config, ["withResultData"]); | ||
return graphql_prettier_1.default(` | ||
mutation ${upperFirst(table.name)}Update( | ||
$data: ${schema_name_generator_1.SchemaNameGenerator.getUpdateInputName(table.name)}!, | ||
$filter: ${schema_name_generator_1.SchemaNameGenerator.getKeyFilterInputTypeName(table.name)} | ||
$data: ${schema_name_generator_1.SchemaNameGenerator.getUpdateInputName(table.name, appName)}!, | ||
$filter: ${schema_name_generator_1.SchemaNameGenerator.getKeyFilterInputTypeName(table.name, appName)} | ||
) { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getUpdateItemFieldName(table.name)}(data: $data, filter: $filter) { | ||
id | ||
${withResultData ? createQueryString_1.createQueryString(tablesList, tableId, Object.assign({ withMeta: false }, restConfig)) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -135,9 +154,11 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true } = config, restConfig = __rest(config, ["withResultData"]); | ||
return graphql_prettier_1.default(` | ||
query ${upperFirst(table.name)}Entity($id: ID!) { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getTableItemFieldName(table.name)}(id: $id) { | ||
id | ||
${withResultData ? createQueryString_1.createQueryString(tablesList, tableId, Object.assign({}, restConfig)) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -147,9 +168,11 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = selectors_1.tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
return graphql_prettier_1.default(` | ||
mutation ${upperFirst(table.name)}Delete($filter: ${schema_name_generator_1.SchemaNameGenerator.getKeyFilterInputTypeName(table.name)}!, $force: Boolean) { | ||
mutation ${upperFirst(table.name)}Delete($filter: ${schema_name_generator_1.SchemaNameGenerator.getKeyFilterInputTypeName(table.name, appName)}!, $force: Boolean) { | ||
${wrapInAppName(appName)(` | ||
${schema_name_generator_1.SchemaNameGenerator.getDeleteItemFieldName(table.name)}(filter: $filter, force: $force) { | ||
success | ||
} | ||
}`)} | ||
}`); | ||
}; | ||
//# sourceMappingURL=queryGenerators.js.map |
@@ -0,5 +1,6 @@ | ||
import * as tablesListSelectors from './tablesListSelectors'; | ||
import * as tableSelectors from './tableSelectors'; | ||
import * as tablesListSelectors from './tablesListSelectors'; | ||
import * as tableFieldSelectors from './tableFieldSelectors'; | ||
export { tableSelectors, tableFieldSelectors, tablesListSelectors }; | ||
import * as applicationsListSelectors from './applicationsListSelectors'; | ||
export { tableSelectors, applicationsListSelectors, tableFieldSelectors, tablesListSelectors }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,8 +10,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tablesListSelectors = __importStar(require("./tablesListSelectors")); | ||
exports.tablesListSelectors = tablesListSelectors; | ||
const tableSelectors = __importStar(require("./tableSelectors")); | ||
exports.tableSelectors = tableSelectors; | ||
const tablesListSelectors = __importStar(require("./tablesListSelectors")); | ||
exports.tablesListSelectors = tablesListSelectors; | ||
const tableFieldSelectors = __importStar(require("./tableFieldSelectors")); | ||
exports.tableFieldSelectors = tableFieldSelectors; | ||
const applicationsListSelectors = __importStar(require("./applicationsListSelectors")); | ||
exports.applicationsListSelectors = applicationsListSelectors; | ||
//# sourceMappingURL=index.js.map |
@@ -8,2 +8,3 @@ import { ParametricSelector } from 'reselect'; | ||
export declare const isSystemField: import("reselect").OutputSelector<TableSchema, boolean, (res: TableSchema) => boolean>; | ||
export declare const isIntegrationTable: import("reselect").OutputSelector<TableSchema, boolean, (res: TableSchema) => boolean>; | ||
export declare const isRelationField: ParametricSelector<TableSchema, string, boolean>; | ||
@@ -10,0 +11,0 @@ export declare const isFileField: import("reselect").OutputParametricSelector<TableSchema, string, boolean, (res: "FILE") => boolean>; |
@@ -19,2 +19,3 @@ "use strict"; | ||
exports.isSystemField = reselect_1.createSelector(exports.getTable, R.propEq('isSystem', true)); | ||
exports.isIntegrationTable = reselect_1.createSelector(exports.getTable, ({ application }) => !!application); | ||
exports.isRelationField = reselect_1.createSelector(exports.getFieldTypeById, R.equals(constants_1.FIELD_TYPE.RELATION)); | ||
@@ -21,0 +22,0 @@ exports.isFileField = reselect_1.createSelector(exports.getFieldTypeById, R.equals(constants_1.FIELD_TYPE.FILE)); |
@@ -1,12 +0,15 @@ | ||
import { TableSchema, FieldSchema } from '../types'; | ||
import { TableSchema, FieldSchema, Application } from '../types'; | ||
import { ParametricSelector } from 'reselect'; | ||
export declare const getTableList: (tables?: TableSchema[] | undefined) => TableSchema[]; | ||
export declare const getTableById: ParametricSelector<TableSchema[], string, TableSchema | void>; | ||
export declare const getTableByName: (state: TableSchema[], tableName: string) => TableSchema; | ||
export declare const getTableByName: ParametricSelector<TableSchema[], any, TableSchema | void>; | ||
export declare const getTableApplication: ParametricSelector<TableSchema[], string, Application | void>; | ||
export declare const getTableFields: ParametricSelector<TableSchema[], string, FieldSchema[]>; | ||
export declare const getTableApplicationName: ParametricSelector<TableSchema[], string, string>; | ||
export declare const getNoSystemTables: ParametricSelector<TableSchema[], void, TableSchema[]>; | ||
export declare const getSystemTables: ParametricSelector<TableSchema[], void, TableSchema[]>; | ||
export declare const hasNoSystemTables: ParametricSelector<TableSchema[], void, boolean>; | ||
export declare const getTablesByApplicationName: import("reselect").OutputSelector<TableSchema[] & string, TableSchema[], (res1: TableSchema[], res2: string) => TableSchema[]>; | ||
export declare const getUserTables: ParametricSelector<TableSchema[], void, TableSchema[]>; | ||
export declare const hasUserTables: ParametricSelector<TableSchema[], void, boolean>; | ||
//# sourceMappingURL=tablesListSelectors.d.ts.map |
@@ -10,9 +10,17 @@ "use strict"; | ||
exports.getTableById = reselect_1.createSelector(exports.getTableList, (_, tableId) => tableId, (tables, tableId) => tables && tables.find(({ id }) => id === tableId)); | ||
exports.getTableByName = reselect_1.createSelector(exports.getTableList, (_, tableName) => tableName, (tables, tableName) => tables && tables.find(({ name }) => name.toLowerCase() === tableName.toLowerCase())); | ||
exports.getTableByName = reselect_1.createSelector(exports.getTableList, (_, tableName) => tableName, (_, __, applicationName) => applicationName, (tables, tableName, applicationName) => tables && | ||
tables | ||
.filter(({ application }) => application && applicationName | ||
? application.name.toLowerCase() === applicationName.toLowerCase() | ||
: !applicationName) | ||
.find(({ name }) => name.toLowerCase() === tableName.toLowerCase())); | ||
exports.getTableApplication = reselect_1.createSelector(exports.getTableById, table => table && table.application); | ||
exports.getTableFields = reselect_1.createSelector(exports.getTableById, table => (table ? table.fields : [])); | ||
exports.getTableApplicationName = reselect_1.createSelector(exports.getTableApplication, table => (table ? table.name : '')); | ||
exports.getNoSystemTables = reselect_1.createSelector(exports.getTableList, tablesList => tablesList.filter(ramda_1.default.propEq('isSystem', false))); | ||
exports.getSystemTables = reselect_1.createSelector(exports.getTableList, tablesList => tablesList.filter(ramda_1.default.propEq('isSystem', true))); | ||
exports.hasNoSystemTables = reselect_1.createSelector(exports.getNoSystemTables, tables => tables.length > 0); | ||
exports.getUserTables = reselect_1.createSelector(exports.getTableList, tablesList => tablesList.filter(({ isSystem }) => !isSystem)); | ||
exports.getTablesByApplicationName = reselect_1.createSelector(exports.getTableList, (applicationName) => applicationName, (tablesList, applicationName) => tablesList.filter(({ application }) => application && application.name === applicationName)); | ||
exports.getUserTables = reselect_1.createSelector(exports.getTableList, tablesList => tablesList.filter(({ isSystem, application }) => !isSystem && !application)); | ||
exports.hasUserTables = reselect_1.createSelector(exports.getUserTables, tables => tables.length > 0); | ||
//# sourceMappingURL=tablesListSelectors.js.map |
@@ -1,2 +0,2 @@ | ||
import { FIELD_TYPE, SWITCH_FORMATS, TEXT_FORMATS, NUMBER_FORMATS, FILE_FORMATS, DATE_FORMATS, MUTATION_TYPE, SMART_FORMATS } from './constants'; | ||
import { FIELD_TYPE, SWITCH_FORMATS, TEXT_FORMATS, NUMBER_FORMATS, FILE_FORMATS, DATE_FORMATS, MUTATION_TYPE, SMART_FORMATS, APP_STATUS } from './constants'; | ||
export declare type MutationType = keyof typeof MUTATION_TYPE; | ||
@@ -34,5 +34,16 @@ export declare type FieldType = keyof typeof FIELD_TYPE; | ||
}; | ||
export declare type Application = { | ||
id: string; | ||
name: string; | ||
displayName: string; | ||
description: string; | ||
tableCount: number; | ||
resolverCount: number; | ||
status: keyof typeof APP_STATUS; | ||
appType: string; | ||
}; | ||
export declare type TableSchema = { | ||
id: string; | ||
name: string; | ||
application: Application; | ||
displayName?: string; | ||
@@ -39,0 +50,0 @@ isSystem?: boolean; |
{ | ||
"name": "@8base/utils", | ||
"version": "0.29.2", | ||
"version": "0.30.0", | ||
"repository": "https://github.com/8base/sdk", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme", |
@@ -166,1 +166,13 @@ export const FIELD_TYPE: { | ||
export const MUTATION_FILE_FIELDS = ['fileId', 'public', 'filename', 'meta', 'mods']; | ||
export const APP_STATUS: { | ||
ACTIVE: 'ACTIVE'; | ||
INACTIVE: 'INACTIVE'; | ||
} = { | ||
ACTIVE: 'ACTIVE', | ||
INACTIVE: 'INACTIVE', | ||
}; | ||
export const APP_TYPES = { | ||
SALESFORCE: 'salesforce', | ||
}; |
@@ -12,2 +12,3 @@ import * as R from 'ramda'; | ||
tableContentName?: string; | ||
appContentName?: string; | ||
} & QueryGeneratorConfig; | ||
@@ -17,2 +18,13 @@ | ||
const wrapInAppName = (appName: string, appContentName?: string) => (queryString: string) => { | ||
if (!appName) { | ||
return queryString; | ||
} | ||
return ` | ||
${appContentName ? `${appContentName}: ` : ''}${appName} { | ||
${queryString} | ||
}`; | ||
}; | ||
const getTable = (tablesList: TableSchema[], tableId: string) => { | ||
@@ -34,2 +46,3 @@ const table = tablesListSelectors.getTableById(tablesList, tableId); | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true, ...restConfig } = config; | ||
@@ -39,4 +52,4 @@ | ||
query ${upperFirst(table.name)}TableContent( | ||
$filter: ${SchemaNameGenerator.getFilterInputTypeName(table.name)} | ||
$orderBy: [${SchemaNameGenerator.getOrderByInputTypeName(table.name)}] | ||
$filter: ${SchemaNameGenerator.getFilterInputTypeName(table.name, appName)} | ||
$orderBy: [${SchemaNameGenerator.getOrderByInputTypeName(table.name, appName)}] | ||
$after: String | ||
@@ -48,2 +61,3 @@ $before: String | ||
) { | ||
${wrapInAppName(appName, config.appContentName)(` | ||
${config.tableContentName ? `${config.tableContentName}: ` : ''}${SchemaNameGenerator.getTableListFieldName( | ||
@@ -66,3 +80,3 @@ table.name, | ||
count | ||
} | ||
}`)} | ||
}`); | ||
@@ -77,2 +91,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const hasNonMetaFields = tableSelectors.hasNonMetaFields(table); | ||
@@ -83,7 +98,8 @@ const { withResultData = true, ...restConfig } = config; | ||
return gqlPrettier(` | ||
mutation ${upperFirst(table.name)}Create($data: ${SchemaNameGenerator.getCreateInputName(table.name)}!) { | ||
mutation ${upperFirst(table.name)}Create($data: ${SchemaNameGenerator.getCreateInputName(table.name, appName)}!) { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getCreateItemFieldName(table.name)}(data: $data) { | ||
id | ||
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -94,6 +110,7 @@ } | ||
mutation ${upperFirst(table.name)}Create { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getCreateItemFieldName(table.name)} { | ||
id | ||
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -104,2 +121,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const hasNonMetaFields = tableSelectors.hasNonMetaFields(table); | ||
@@ -109,6 +127,10 @@ | ||
return gqlPrettier(` | ||
mutation ${upperFirst(table.name)}CreateMany($data: [${SchemaNameGenerator.getCreateManyInputName(table.name)}]!) { | ||
mutation ${upperFirst(table.name)}CreateMany($data: [${SchemaNameGenerator.getCreateManyInputName( | ||
table.name, | ||
appName, | ||
)}]!) { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getCreateManyItemFieldName(table.name)}(data: $data) { | ||
count | ||
} | ||
}`)} | ||
}`); | ||
@@ -119,5 +141,6 @@ } | ||
mutation ${upperFirst(table.name)}CreateMany { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getCreateManyItemFieldName(table.name)} { | ||
count | ||
} | ||
}`)} | ||
}`; | ||
@@ -132,2 +155,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true, ...restConfig } = config; | ||
@@ -137,9 +161,10 @@ | ||
mutation ${upperFirst(table.name)}Update( | ||
$data: ${SchemaNameGenerator.getUpdateInputName(table.name)}!, | ||
$filter: ${SchemaNameGenerator.getKeyFilterInputTypeName(table.name)} | ||
$data: ${SchemaNameGenerator.getUpdateInputName(table.name, appName)}!, | ||
$filter: ${SchemaNameGenerator.getKeyFilterInputTypeName(table.name, appName)} | ||
) { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getUpdateItemFieldName(table.name)}(data: $data, filter: $filter) { | ||
id | ||
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -154,2 +179,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
const { withResultData = true, ...restConfig } = config; | ||
@@ -159,6 +185,7 @@ | ||
query ${upperFirst(table.name)}Entity($id: ID!) { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getTableItemFieldName(table.name)}(id: $id) { | ||
id | ||
${withResultData ? createQueryString(tablesList, tableId, { ...restConfig }) : ''} | ||
} | ||
}`)} | ||
}`); | ||
@@ -169,2 +196,3 @@ }; | ||
const table = getTable(tablesList, tableId); | ||
const appName = tablesListSelectors.getTableApplicationName(tablesList, tableId); | ||
@@ -174,7 +202,9 @@ return gqlPrettier(` | ||
table.name, | ||
appName, | ||
)}!, $force: Boolean) { | ||
${wrapInAppName(appName)(` | ||
${SchemaNameGenerator.getDeleteItemFieldName(table.name)}(filter: $filter, force: $force) { | ||
success | ||
} | ||
}`)} | ||
}`); | ||
}; |
@@ -0,5 +1,6 @@ | ||
import * as tablesListSelectors from './tablesListSelectors'; | ||
import * as tableSelectors from './tableSelectors'; | ||
import * as tablesListSelectors from './tablesListSelectors'; | ||
import * as tableFieldSelectors from './tableFieldSelectors'; | ||
import * as applicationsListSelectors from './applicationsListSelectors'; | ||
export { tableSelectors, tableFieldSelectors, tablesListSelectors }; | ||
export { tableSelectors, applicationsListSelectors, tableFieldSelectors, tablesListSelectors }; |
@@ -40,2 +40,7 @@ import * as R from 'ramda'; | ||
export const isIntegrationTable = createSelector( | ||
getTable, | ||
({ application }) => !!application, | ||
); | ||
export const isRelationField: ParametricSelector<TableSchema, string, boolean> = createSelector( | ||
@@ -42,0 +47,0 @@ getFieldTypeById, |
import R from 'ramda'; | ||
import { TableSchema, FieldSchema } from '../types'; | ||
import { TableSchema, FieldSchema, Application } from '../types'; | ||
import { createSelector, ParametricSelector } from 'reselect'; | ||
@@ -13,8 +13,22 @@ | ||
export const getTableByName: (state: TableSchema[], tableName: string) => TableSchema = createSelector( | ||
export const getTableByName: ParametricSelector<TableSchema[], any, TableSchema | void> = createSelector( | ||
getTableList, | ||
(_: any, tableName: string) => tableName, | ||
(tables, tableName) => tables && tables.find(({ name }) => name.toLowerCase() === tableName.toLowerCase()), | ||
) as any; | ||
(_: any, __: any, applicationName: string) => applicationName, | ||
(tables, tableName, applicationName) => | ||
tables && | ||
tables | ||
.filter(({ application }) => | ||
application && applicationName | ||
? application.name.toLowerCase() === applicationName.toLowerCase() | ||
: !applicationName, | ||
) | ||
.find(({ name }) => name.toLowerCase() === tableName.toLowerCase()), | ||
); | ||
export const getTableApplication: ParametricSelector<TableSchema[], string, Application | void> = createSelector( | ||
getTableById, | ||
table => table && table.application, | ||
); | ||
export const getTableFields: ParametricSelector<TableSchema[], string, FieldSchema[]> = createSelector( | ||
@@ -25,2 +39,7 @@ getTableById, | ||
export const getTableApplicationName: ParametricSelector<TableSchema[], string, string> = createSelector( | ||
getTableApplication, | ||
table => (table ? table.name : ''), | ||
); | ||
export const getNoSystemTables: ParametricSelector<TableSchema[], void, TableSchema[]> = createSelector( | ||
@@ -41,5 +60,12 @@ getTableList, | ||
export const getTablesByApplicationName = createSelector( | ||
getTableList, | ||
(applicationName: string) => applicationName, | ||
(tablesList, applicationName) => | ||
tablesList.filter(({ application }) => application && application.name === applicationName), | ||
); | ||
export const getUserTables: ParametricSelector<TableSchema[], void, TableSchema[]> = createSelector( | ||
getTableList, | ||
tablesList => tablesList.filter(({ isSystem }) => !isSystem), | ||
tablesList => tablesList.filter(({ isSystem, application }) => !isSystem && !application), | ||
); | ||
@@ -46,0 +72,0 @@ |
@@ -10,2 +10,3 @@ import { | ||
SMART_FORMATS, | ||
APP_STATUS, | ||
} from './constants'; | ||
@@ -53,5 +54,17 @@ | ||
export type Application = { | ||
id: string; | ||
name: string; | ||
displayName: string; | ||
description: string; | ||
tableCount: number; | ||
resolverCount: number; | ||
status: keyof typeof APP_STATUS; | ||
appType: string; | ||
}; | ||
export type TableSchema = { | ||
id: string; | ||
name: string; | ||
application: Application; | ||
displayName?: string; | ||
@@ -58,0 +71,0 @@ isSystem?: boolean; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
230076
214
3663