shyft
Version:
Model driven GraphQL API framework
159 lines (158 loc) • 5.66 kB
JavaScript
"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.StorageDataTypeDouble = exports.StorageDataTypeNumeric = exports.StorageDataTypeBigInt = exports.StorageDataTypeInteger = void 0;
var __1 = require("..");
var i18n_1 = require("./i18n");
var isNotSet = function (val) {
return val === null || typeof val === 'undefined';
};
var toString = function (val) {
return isNotSet(val) ? val : String(val);
};
var toInt = function (val) {
return isNotSet(val) ? val : parseInt(val, 10);
};
var toFloat = function (val) {
return isNotSet(val) ? val : parseFloat(val);
};
exports.StorageDataTypeInteger = new __1.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.StorageDataTypeBigInt = new __1.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.StorageDataTypeNumeric = new __1.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.StorageDataTypeDouble = new __1.StorageDataType({
name: 'StorageDataTypeDouble',
description: 'Data type representing a double precision value',
nativeDataType: 'double precision',
isSortable: true,
serialize: toFloat,
capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'],
});
exports.StorageDataTypeBoolean = new __1.StorageDataType({
name: 'StorageDataTypeBoolean',
description: 'Data type representing a boolean value',
nativeDataType: 'boolean',
isSortable: true,
serialize: function (val) { return val; },
capabilities: ['ne'],
});
exports.StorageDataTypeText = new __1.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.StorageDataTypeJSON = new __1.StorageDataType({
name: 'StorageDataTypeJSON',
description: 'Data type representing a json object',
nativeDataType: 'jsonb',
isSortable: false,
serialize: function (val) { return val; },
capabilities: ['includes', 'not_includes', 'is_null'],
});
exports.StorageDataTypeTimestamp = new __1.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.StorageDataTypeTimestampTz = new __1.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.StorageDataTypeDate = new __1.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.StorageDataTypeTime = new __1.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.StorageDataTypeTimeTz = new __1.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.StorageDataTypeUUID = new __1.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.StorageDataTypeI18n = new __1.StorageDataType({
name: 'StorageDataTypeI18n',
description: 'Data type representing a translation object',
nativeDataType: 'jsonb',
isSortable: false,
parse: i18n_1.i18nDataParser,
serialize: i18n_1.i18nDataSerializer,
enforceSerialize: true,
});