UNPKG

shyft-storage-connector

Version:
149 lines (141 loc) 5.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StorageDataTypeI18n = exports.StorageDataTypeUUID = exports.StorageDataTypeTimeTz = exports.StorageDataTypeTime = exports.StorageDataTypeDate = exports.StorageDataTypeTimestampTz = exports.StorageDataTypeTimestamp = exports.StorageDataTypeJSON = exports.StorageDataTypeText = exports.StorageDataTypeBoolean = exports.StorageDataTypeNumeric = exports.StorageDataTypeBigInt = exports.StorageDataTypeInteger = void 0; var _shyft = require("shyft"); var _i18n = require("./i18n"); var isNotSet = function isNotSet(val) { return val === null || typeof val === 'undefined'; }; var toString = function toString(val) { return isNotSet(val) ? val : String(val); }; var toInt = function toInt(val) { return isNotSet(val) ? val : parseInt(val, 10); }; var toFloat = function toFloat(val) { return isNotSet(val) ? val : parseFloat(val); }; var StorageDataTypeInteger = new _shyft.StorageDataType({ name: 'StorageDataTypeInteger', description: 'Data type representing a 32-bit integer value', nativeDataType: 'int', isSortable: true, serialize: toInt, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeInteger = StorageDataTypeInteger; var StorageDataTypeBigInt = new _shyft.StorageDataType({ name: 'StorageDataTypeBigInt', description: 'Data type representing a 64-bit integer value', nativeDataType: 'bigint', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeBigInt = StorageDataTypeBigInt; var StorageDataTypeNumeric = new _shyft.StorageDataType({ name: 'StorageDataTypeNumeric', description: 'Data type representing a floating-point value', nativeDataType: 'numeric', isSortable: true, serialize: toFloat, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeNumeric = StorageDataTypeNumeric; var StorageDataTypeBoolean = new _shyft.StorageDataType({ name: 'StorageDataTypeBoolean', description: 'Data type representing a boolean value', nativeDataType: 'boolean', isSortable: true, serialize: function serialize(value) { return value; }, capabilities: ['ne'] }); exports.StorageDataTypeBoolean = StorageDataTypeBoolean; var StorageDataTypeText = new _shyft.StorageDataType({ name: 'StorageDataTypeText', description: 'Data type representing a text value', nativeDataType: 'text', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'contains', 'starts_with', 'ends_with', 'ne', 'not_in', 'not_contains', 'not_starts_with', 'not_ends_with'] }); exports.StorageDataTypeText = StorageDataTypeText; var StorageDataTypeJSON = new _shyft.StorageDataType({ name: 'StorageDataTypeJSON', description: 'Data type representing a json object', nativeDataType: 'jsonb', isSortable: false, serialize: function serialize(val) { return val; }, capabilities: ['includes', 'not_includes', 'is_null'] }); exports.StorageDataTypeJSON = StorageDataTypeJSON; var StorageDataTypeTimestamp = new _shyft.StorageDataType({ name: 'StorageDataTypeTimestamp', description: 'Data type representing a timestamp without timezone', nativeDataType: 'timestamp without time zone', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeTimestamp = StorageDataTypeTimestamp; var StorageDataTypeTimestampTz = new _shyft.StorageDataType({ name: 'StorageDataTypeTimestampTz', description: 'Data type representing a timestamp with timezone', nativeDataType: 'timestamp with time zone', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeTimestampTz = StorageDataTypeTimestampTz; var StorageDataTypeDate = new _shyft.StorageDataType({ name: 'StorageDataTypeDate', description: 'Data type representing a date', nativeDataType: 'date', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeDate = StorageDataTypeDate; var StorageDataTypeTime = new _shyft.StorageDataType({ name: 'StorageDataTypeTime', description: 'Data type representing time without timezone', nativeDataType: 'time without time zone', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeTime = StorageDataTypeTime; var StorageDataTypeTimeTz = new _shyft.StorageDataType({ name: 'StorageDataTypeTimeTz', description: 'Data type representing time with timezone', nativeDataType: 'time with time zone', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'] }); exports.StorageDataTypeTimeTz = StorageDataTypeTimeTz; var StorageDataTypeUUID = new _shyft.StorageDataType({ name: 'StorageDataTypeUUID', description: 'Data type representing a UUID', nativeDataType: 'uuid', isSortable: true, serialize: toString, capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'contains', 'starts_with', 'ends_with', 'ne', 'not_in', 'not_contains', 'not_starts_with', 'not_ends_with'] }); exports.StorageDataTypeUUID = StorageDataTypeUUID; var StorageDataTypeI18n = new _shyft.StorageDataType({ name: 'StorageDataTypeI18n', description: 'Data type representing a translation object', nativeDataType: 'jsonb', isSortable: false, parse: _i18n.i18nDataParser, serialize: _i18n.i18nDataSerializer, enforceSerialize: true }); exports.StorageDataTypeI18n = StorageDataTypeI18n;