Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@8base/utils

Package Overview
Dependencies
Maintainers
3
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@8base/utils - npm Package Compare versions

Comparing version 0.34.0 to 0.35.0

2

dist/constants/schemaConstants.d.ts

@@ -6,3 +6,5 @@ export declare const FIELD_TYPE: {

JSON: 'JSON';
MISSING_RELATION: 'MISSING_RELATION';
NUMBER: 'NUMBER';
ONE_WAY_RELATION: 'ONE_WAY_RELATION';
RELATION: 'RELATION';

@@ -9,0 +11,0 @@ SMART: 'SMART';

@@ -8,3 +8,5 @@ "use strict";

JSON: 'JSON',
MISSING_RELATION: 'MISSING_RELATION',
NUMBER: 'NUMBER',
ONE_WAY_RELATION: 'ONE_WAY_RELATION',
RELATION: 'RELATION',

@@ -11,0 +13,0 @@ SMART: 'SMART',

3

dist/formatters/formatDataAfterQuery.d.ts
import { Schema, FormatDataAfterQueryOptions } from '../types';
interface IFormatDataAfterQueryMeta {
tableName: string;
appName?: string;
schema: Schema;

@@ -15,4 +16,4 @@ }

[key: string]: any;
}, { tableName, schema }: IFormatDataAfterQueryMeta, options?: FormatDataAfterQueryOptions) => {};
}, { tableName, appName, schema }: IFormatDataAfterQueryMeta, options?: FormatDataAfterQueryOptions) => {};
export { formatDataAfterQuery };
//# sourceMappingURL=formatDataAfterQuery.d.ts.map

@@ -21,4 +21,4 @@ "use strict";

*/
const formatDataAfterQuery = (data, { tableName, schema }, options = {}) => {
const tableSchema = selectors_1.tablesListSelectors.getTableByName(schema, tableName);
const formatDataAfterQuery = (data, { tableName, appName, schema }, options = {}) => {
const tableSchema = selectors_1.tablesListSelectors.getTableByName(schema, tableName, appName);
if (!tableSchema) {

@@ -25,0 +25,0 @@ throw new errors_1.SDKError(errors_1.ERROR_CODES.TABLE_NOT_FOUND, errors_1.PACKAGES.UTILS, `Table schema with ${tableName} name not found in schema.`);

@@ -42,2 +42,4 @@ "use strict";

const isRelation = selectors_1.tableFieldSelectors.isRelationField(field);
const isMissingRelation = selectors_1.tableFieldSelectors.isMissingRelationField(field);
const isOneWayRelationField = selectors_1.tableFieldSelectors.isOneWayRelationField(field);
const isFile = selectors_1.tableFieldSelectors.isFileField(field);

@@ -59,3 +61,8 @@ const isSmart = selectors_1.tableFieldSelectors.isSmartField(field);

}
else if (isRelation) {
else if (isMissingRelation) {
fieldContent = `{
table
}`;
}
else if (isRelation || isOneWayRelationField) {
if (deep <= 1 || !refTableId || !refTable) {

@@ -62,0 +69,0 @@ fieldContent = `{

import { ParametricSelector } from 'reselect';
import { FieldSchema } from '../types';
export declare const getTableField: (tableField: void | FieldSchema) => void | FieldSchema;
export declare const getTableField: (tableField: void | FieldSchema) => FieldSchema;
export declare const getFieldType: any;
export declare const getFieldTypesAttributes: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: void | FieldSchema) => unknown>;
export declare const getFieldTypesAttributes: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: FieldSchema) => unknown>;
export declare const isRelationField: import("reselect").OutputSelector<unknown, boolean, (res: "RELATION") => boolean>;
export declare const isMissingRelationField: import("reselect").OutputSelector<unknown, boolean, (res: "MISSING_RELATION") => boolean>;
export declare const isOneWayRelationField: import("reselect").OutputSelector<unknown, boolean, (res: "ONE_WAY_RELATION") => boolean>;
export declare const isFileField: import("reselect").OutputSelector<unknown, boolean, (res: "FILE") => boolean>;
export declare const isSmartField: import("reselect").OutputSelector<unknown, boolean, (res: "SMART") => boolean>;
export declare const isIdField: import("reselect").OutputSelector<unknown, boolean, (res: "ID") => boolean>;
export declare const isMetaField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: void | FieldSchema) => boolean>;
export declare const isListField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: void | FieldSchema) => boolean>;
export declare const isSystemField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: void | FieldSchema) => boolean>;
export declare const getFieldId: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: void | FieldSchema) => unknown>;
export declare const getFieldName: import("reselect").OutputSelector<void | FieldSchema, string, (res: void | FieldSchema) => string>;
export declare const getFieldDisplayName: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: void | FieldSchema) => unknown>;
export declare const getTableId: import("reselect").OutputSelector<void | FieldSchema, any, (res: void | FieldSchema) => any>;
export declare const getTableName: import("reselect").OutputSelector<void | FieldSchema, any, (res: void | FieldSchema) => any>;
export declare const getTableDisplayName: import("reselect").OutputSelector<void | FieldSchema, any, (res: void | FieldSchema) => any>;
export declare const isMetaField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: FieldSchema) => boolean>;
export declare const isListField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: FieldSchema) => boolean>;
export declare const isSystemField: import("reselect").OutputSelector<void | FieldSchema, boolean, (res: FieldSchema) => boolean>;
export declare const getFieldId: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: FieldSchema) => unknown>;
export declare const getFieldName: import("reselect").OutputSelector<void | FieldSchema, string, (res: FieldSchema) => string>;
export declare const getFieldDisplayName: import("reselect").OutputSelector<void | FieldSchema, unknown, (res: FieldSchema) => unknown>;
export declare const getTableId: import("reselect").OutputSelector<void | FieldSchema, any, (res: FieldSchema) => any>;
export declare const getTableName: import("reselect").OutputSelector<void | FieldSchema, any, (res: FieldSchema) => any>;
export declare const getTableDisplayName: import("reselect").OutputSelector<void | FieldSchema, any, (res: FieldSchema) => any>;
export declare const getRelationTableId: ParametricSelector<FieldSchema, void, string>;
export declare const getRelationTableName: ParametricSelector<FieldSchema, void, string>;
export declare const getRelationTableDisplayName: ParametricSelector<FieldSchema, void, string>;
export declare const getSchemaFeatures: import("reselect").OutputSelector<void | FieldSchema, {
update: boolean;
delete: boolean;
}, (res: FieldSchema) => {
update: boolean;
delete: boolean;
}>;
export declare const getDataFeatures: import("reselect").OutputSelector<void | FieldSchema, {
create: boolean;
update: boolean;
}, (res: FieldSchema) => {
create: boolean;
update: boolean;
}>;
//# sourceMappingURL=tableFieldSelectors.d.ts.map

@@ -17,2 +17,4 @@ "use strict";

exports.isRelationField = reselect_1.createSelector(exports.getFieldType, R.equals(constants_1.FIELD_TYPE.RELATION));
exports.isMissingRelationField = reselect_1.createSelector(exports.getFieldType, R.equals(constants_1.FIELD_TYPE.MISSING_RELATION));
exports.isOneWayRelationField = reselect_1.createSelector(exports.getFieldType, R.equals(constants_1.FIELD_TYPE.ONE_WAY_RELATION));
exports.isFileField = reselect_1.createSelector(exports.getFieldType, R.equals(constants_1.FIELD_TYPE.FILE));

@@ -33,2 +35,4 @@ exports.isSmartField = reselect_1.createSelector(exports.getFieldType, R.equals(constants_1.FIELD_TYPE.SMART));

exports.getRelationTableDisplayName = reselect_1.createSelector(exports.getTableField, R.path(['relation', 'refTable', 'displayName']));
exports.getSchemaFeatures = reselect_1.createSelector(exports.getTableField, R.prop('schemaFeatures'));
exports.getDataFeatures = reselect_1.createSelector(exports.getTableField, R.prop('dataFeatures'));
//# sourceMappingURL=tableFieldSelectors.js.map
import { ParametricSelector } from 'reselect';
import { TableSchema, FieldSchema } from '../types';
export declare const getTable: (table: TableSchema) => TableSchema;
export declare const getTableName: import("reselect").OutputSelector<TableSchema, string, (res: TableSchema) => string>;
export declare const getTableDisplayName: import("reselect").OutputSelector<TableSchema, string, (res: TableSchema) => string>;
export declare const getTableId: import("reselect").OutputSelector<TableSchema, string, (res: TableSchema) => string>;
export declare const getFieldById: ParametricSelector<TableSchema, string, FieldSchema | void>;
export declare const getFieldByName: ParametricSelector<TableSchema, string, FieldSchema | void>;
export declare const getFieldTypeById: ParametricSelector<TableSchema, string, any>;
export declare const getTableApplication: import("reselect").OutputSelector<TableSchema, import("../types").Application, (res: TableSchema) => import("../types").Application>;
export declare const getTableAppName: import("reselect").OutputSelector<TableSchema, unknown, (res: import("../types").Application) => unknown>;
export declare const getTableAppDisplayName: import("reselect").OutputSelector<TableSchema, unknown, (res: import("../types").Application) => unknown>;
export declare const isSystemField: import("reselect").OutputSelector<TableSchema, boolean, (res: TableSchema) => boolean>;

@@ -25,2 +31,44 @@ export declare const isIntegrationTable: import("reselect").OutputSelector<TableSchema, boolean, (res: TableSchema) => boolean>;

export declare const hasPhoneFields: (x0: TableSchema) => boolean;
export declare const getSchemaFeatures: import("reselect").OutputSelector<TableSchema, {
create: {
DATE: boolean;
FILE: boolean;
JSON: boolean;
NUMBER: boolean;
RELATION: boolean;
SMART: boolean;
SWITCH: boolean;
TEXT: boolean;
UUID: boolean;
};
update: {
displayName: boolean;
name: boolean;
};
}, (res: TableSchema) => {
create: {
DATE: boolean;
FILE: boolean;
JSON: boolean;
NUMBER: boolean;
RELATION: boolean;
SMART: boolean;
SWITCH: boolean;
TEXT: boolean;
UUID: boolean;
};
update: {
displayName: boolean;
name: boolean;
};
}>;
export declare const getDataFeatures: import("reselect").OutputSelector<TableSchema, {
create: boolean;
update: boolean;
delete: boolean;
}, (res: TableSchema) => {
create: boolean;
update: boolean;
delete: boolean;
}>;
//# sourceMappingURL=tableSelectors.d.ts.map

@@ -13,3 +13,6 @@ "use strict";

const constants_1 = require("../constants");
exports.getTable = (table) => table;
exports.getTable = (table) => table || {};
exports.getTableName = reselect_1.createSelector(exports.getTable, R.prop('name'));
exports.getTableDisplayName = reselect_1.createSelector(exports.getTable, R.prop('displayName'));
exports.getTableId = reselect_1.createSelector(exports.getTable, R.prop('id'));
exports.getFieldById = ({ fields }, fieldId) => R.find(R.pipe(R.prop('id'), R.equals(fieldId)), fields);

@@ -19,2 +22,5 @@ exports.getFieldByName = (tableSchema, fieldName) => R.find(R.propEq('name', fieldName), tableSchema.fields);

exports.getFieldTypeById = reselect_1.createSelector(getFieldByIdOrEmpty, R.propOr('', 'fieldType'));
exports.getTableApplication = reselect_1.createSelector(exports.getTable, R.prop('application'));
exports.getTableAppName = reselect_1.createSelector(exports.getTableApplication, R.propOr(null, 'name'));
exports.getTableAppDisplayName = reselect_1.createSelector(exports.getTableApplication, R.propOr(null, 'displayName'));
exports.isSystemField = reselect_1.createSelector(exports.getTable, R.propEq('isSystem', true));

@@ -38,2 +44,4 @@ exports.isIntegrationTable = reselect_1.createSelector(exports.getTable, ({ application }) => !!application);

exports.hasPhoneFields = R.pipe(exports.getTable, ({ fields }) => !!fields.find(({ fieldTypeAttributes = {} }) => fieldTypeAttributes && fieldTypeAttributes.format === constants_1.SMART_FORMATS.PHONE));
exports.getSchemaFeatures = reselect_1.createSelector(exports.getTable, R.prop('schemaFeatures'));
exports.getDataFeatures = reselect_1.createSelector(exports.getTable, R.prop('dataFeatures'));
//# sourceMappingURL=tableSelectors.js.map
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: ParametricSelector<TableSchema[], any, TableSchema | void>;
export declare const getTableById: ParametricSelector<TableSchema[], string, TableSchema>;
export declare const getTableByName: (schema: TableSchema[], tableName: string, appName?: string | null) => TableSchema;
export declare const getTableApplication: ParametricSelector<TableSchema[], string, Application | void>;

@@ -7,0 +7,0 @@ export declare const getTableFields: ParametricSelector<TableSchema[], string, FieldSchema[]>;

@@ -9,9 +9,8 @@ "use strict";

exports.getTableList = (tables) => tables || [];
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, (_, __, applicationName) => applicationName, (tables, tableName, applicationName) => tables &&
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, (_, __, applicationName) => applicationName, (tables, tableName, appName) => (tables &&
tables
.filter(({ application }) => application && applicationName
? application.name.toLowerCase() === applicationName.toLowerCase()
: !applicationName)
.find(({ name }) => name.toLowerCase() === tableName.toLowerCase()));
.filter(({ application }) => application && appName ? application.name.toLowerCase() === appName.toLowerCase() : !appName)
.find(({ name }) => name.toLowerCase() === tableName.toLowerCase())) ||
{});
exports.getTableApplication = reselect_1.createSelector(exports.getTableById, table => table && table.application);

@@ -18,0 +17,0 @@ exports.getTableFields = reselect_1.createSelector(exports.getTableById, table => (table ? table.fields : []));

@@ -39,2 +39,10 @@ import { FIELD_TYPE, SWITCH_FORMATS, TEXT_FORMATS, NUMBER_FORMATS, FILE_FORMATS, DATE_FORMATS, MUTATION_TYPE, SMART_FORMATS, APP_STATUS } from './constants';

};
schemaFeatures: {
update: boolean;
delete: boolean;
};
dataFeatures: {
create: boolean;
update: boolean;
};
};

@@ -55,5 +63,27 @@ export declare type Application = {

application: Application;
displayName?: string;
displayName: string;
isSystem?: boolean;
fields: FieldSchema[];
schemaFeatures: {
create: {
DATE: boolean;
FILE: boolean;
JSON: boolean;
NUMBER: boolean;
RELATION: boolean;
SMART: boolean;
SWITCH: boolean;
TEXT: boolean;
UUID: boolean;
};
update: {
displayName: boolean;
name: boolean;
};
};
dataFeatures: {
create: boolean;
update: boolean;
delete: boolean;
};
};

@@ -60,0 +90,0 @@ export declare type Schema = TableSchema[];

{
"name": "@8base/utils",
"version": "0.34.0",
"version": "0.35.0",
"repository": "https://github.com/8base/sdk",

@@ -19,2 +19,4 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme",

"graphql-prettier": "^1.0.5",
"os": "^0.1.1",
"prettier": "^1.17.0",
"ramda": "^0.26.1",

@@ -21,0 +23,0 @@ "reselect": "^4.0.0"

@@ -6,3 +6,5 @@ export const FIELD_TYPE: {

JSON: 'JSON';
MISSING_RELATION: 'MISSING_RELATION';
NUMBER: 'NUMBER';
ONE_WAY_RELATION: 'ONE_WAY_RELATION';
RELATION: 'RELATION';

@@ -17,3 +19,5 @@ SMART: 'SMART';

JSON: 'JSON',
MISSING_RELATION: 'MISSING_RELATION',
NUMBER: 'NUMBER',
ONE_WAY_RELATION: 'ONE_WAY_RELATION',
RELATION: 'RELATION',

@@ -20,0 +24,0 @@ SMART: 'SMART',

@@ -11,2 +11,3 @@ import * as R from 'ramda';

tableName: string;
appName?: string;
schema: Schema;

@@ -24,6 +25,6 @@ }

data: { [key: string]: any },
{ tableName, schema }: IFormatDataAfterQueryMeta,
{ tableName, appName, schema }: IFormatDataAfterQueryMeta,
options: FormatDataAfterQueryOptions = {},
) => {
const tableSchema = tablesListSelectors.getTableByName(schema, tableName);
const tableSchema = tablesListSelectors.getTableByName(schema, tableName, appName);

@@ -30,0 +31,0 @@ if (!tableSchema) {

@@ -67,2 +67,4 @@ import * as R from 'ramda';

const isRelation = tableFieldSelectors.isRelationField(field);
const isMissingRelation = tableFieldSelectors.isMissingRelationField(field);
const isOneWayRelationField = tableFieldSelectors.isOneWayRelationField(field);
const isFile = tableFieldSelectors.isFileField(field);

@@ -89,3 +91,7 @@ const isSmart = tableFieldSelectors.isSmartField(field);

}`;
} else if (isRelation) {
} else if (isMissingRelation) {
fieldContent = `{
table
}`;
} else if (isRelation || isOneWayRelationField) {
if (deep <= 1 || !refTableId || !refTable) {

@@ -92,0 +98,0 @@ fieldContent = `{

@@ -6,3 +6,3 @@ import * as R from 'ramda';

export const getTableField = (tableField: FieldSchema | void) => tableField;
export const getTableField = (tableField: FieldSchema | void): FieldSchema => tableField as any;

@@ -24,2 +24,12 @@ export const getFieldType: any = createSelector(

export const isMissingRelationField = createSelector(
getFieldType,
R.equals(FIELD_TYPE.MISSING_RELATION),
);
export const isOneWayRelationField = createSelector(
getFieldType,
R.equals(FIELD_TYPE.ONE_WAY_RELATION),
);
export const isFileField = createSelector(

@@ -99,1 +109,11 @@ getFieldType,

);
export const getSchemaFeatures = createSelector(
getTableField,
R.prop('schemaFeatures'),
);
export const getDataFeatures = createSelector(
getTableField,
R.prop('dataFeatures'),
);

@@ -6,4 +6,19 @@ import * as R from 'ramda';

export const getTable = (table: TableSchema) => table;
export const getTable = (table: TableSchema) => table || {};
export const getTableName = createSelector(
getTable,
R.prop('name'),
);
export const getTableDisplayName = createSelector(
getTable,
R.prop('displayName'),
);
export const getTableId = createSelector(
getTable,
R.prop('id'),
);
export const getFieldById: ParametricSelector<TableSchema, string, FieldSchema | void> = (

@@ -36,2 +51,17 @@ { fields }: TableSchema,

export const getTableApplication = createSelector(
getTable,
R.prop('application'),
);
export const getTableAppName = createSelector(
getTableApplication,
R.propOr(null, 'name'),
);
export const getTableAppDisplayName = createSelector(
getTableApplication,
R.propOr(null, 'displayName'),
);
export const isSystemField = createSelector(

@@ -133,1 +163,11 @@ getTable,

);
export const getSchemaFeatures = createSelector(
getTable,
R.prop('schemaFeatures'),
);
export const getDataFeatures = createSelector(
getTable,
R.prop('dataFeatures'),
);

@@ -7,21 +7,24 @@ import R from 'ramda';

export const getTableById: ParametricSelector<TableSchema[], string, TableSchema | void> = createSelector(
export const getTableById: ParametricSelector<TableSchema[], string, TableSchema> = createSelector(
getTableList,
(_: any, tableId: string) => tableId,
(tables, tableId) => tables && tables.find(({ id }) => id === tableId),
(tables, tableId): any => (tables && tables.find(({ id }) => id === tableId)) || {},
);
export const getTableByName: ParametricSelector<TableSchema[], any, TableSchema | void> = createSelector(
export const getTableByName: (
schema: TableSchema[],
tableName: string,
appName?: string | null,
) => TableSchema = createSelector(
getTableList,
(_: any, tableName: string) => tableName,
(_: 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()),
(tables, tableName, appName): any =>
(tables &&
tables
.filter(({ application }) =>
application && appName ? application.name.toLowerCase() === appName.toLowerCase() : !appName,
)
.find(({ name }) => name.toLowerCase() === tableName.toLowerCase())) ||
{},
);

@@ -28,0 +31,0 @@

@@ -57,2 +57,10 @@ import {

};
schemaFeatures: {
update: boolean;
delete: boolean;
};
dataFeatures: {
create: boolean;
update: boolean;
};
};

@@ -75,5 +83,27 @@

application: Application;
displayName?: string;
displayName: string;
isSystem?: boolean;
fields: FieldSchema[];
schemaFeatures: {
create: {
DATE: boolean;
FILE: boolean;
JSON: boolean;
NUMBER: boolean;
RELATION: boolean;
SMART: boolean;
SWITCH: boolean;
TEXT: boolean;
UUID: boolean;
};
update: {
displayName: boolean;
name: boolean;
};
};
dataFeatures: {
create: boolean;
update: boolean;
delete: boolean;
};
};

@@ -80,0 +110,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc