graphql-scalar
Advanced tools
Comparing version 0.0.11 to 0.1.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getValueFromValueNode = exports.defaultSerialize = exports.defaultErrorHandler = void 0; | ||
var graphql_1 = require("graphql"); | ||
var error_1 = require("graphql/error"); | ||
exports.defaultErrorHandler = function (_a) { | ||
var defaultErrorHandler = function (_a) { | ||
var code = _a.code, ast = _a.ast; | ||
throw new error_1.GraphQLError("code=" + code, ast ? [ast] : []); | ||
throw new error_1.GraphQLError("code=".concat(code), ast ? [ast] : []); | ||
}; | ||
exports.defaultSerialize = function (x) { return x; }; | ||
exports.getValueFromValueNode = function (ast) { | ||
exports.defaultErrorHandler = defaultErrorHandler; | ||
var defaultSerialize = function (x) { return x; }; | ||
exports.defaultSerialize = defaultSerialize; | ||
var getValueFromValueNode = function (ast) { | ||
switch (ast.kind) { | ||
@@ -27,2 +30,3 @@ case graphql_1.Kind.BOOLEAN: | ||
}; | ||
exports.getValueFromValueNode = getValueFromValueNode; | ||
//# sourceMappingURL=common.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IFloatScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IFloatScalarConfig<TInternal, TExternal>, FloatScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFloatScalar = exports.isSafeFloat = void 0; | ||
var tslib_1 = require("tslib"); | ||
var graphql_1 = require("graphql"); | ||
var common_1 = require("./common"); | ||
exports.isSafeFloat = function (n) { | ||
var isSafeFloat = function (n) { | ||
return typeof n === 'number' && isFinite(n); | ||
}; | ||
exports.createFloatScalar = function (config) { | ||
exports.isSafeFloat = isSafeFloat; | ||
var createFloatScalar = function (config) { | ||
var coerce = config.coerce, errorHandler = config.errorHandler, maximum = config.maximum, minimum = config.minimum, parse = config.parse, sanitize = config.sanitize, validate = config.validate, serialize = config.serialize, scalarConfig = tslib_1.__rest(config, ["coerce", "errorHandler", "maximum", "minimum", "parse", "sanitize", "validate", "serialize"]); | ||
@@ -17,3 +19,3 @@ var handleError = errorHandler || common_1.defaultErrorHandler; | ||
var value; | ||
if (exports.isSafeFloat(unknownValue)) { | ||
if ((0, exports.isSafeFloat)(unknownValue)) { | ||
value = unknownValue; | ||
@@ -79,5 +81,6 @@ } | ||
return new graphql_1.GraphQLScalarType(tslib_1.__assign(tslib_1.__assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue: parseValue, parseLiteral: function (ast) { | ||
return parseValue(common_1.getValueFromValueNode(ast), ast); | ||
return parseValue((0, common_1.getValueFromValueNode)(ast), ast); | ||
} })); | ||
}; | ||
exports.createFloatScalar = createFloatScalar; | ||
//# sourceMappingURL=float.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStringScalar = exports.isSafeInteger = exports.createIntScalar = exports.isSafeFloat = exports.createFloatScalar = exports.getValueFromValueNode = exports.defaultSerialize = exports.defaultErrorHandler = void 0; | ||
var common_1 = require("./common"); | ||
exports.defaultErrorHandler = common_1.defaultErrorHandler; | ||
exports.defaultSerialize = common_1.defaultSerialize; | ||
exports.getValueFromValueNode = common_1.getValueFromValueNode; | ||
Object.defineProperty(exports, "defaultErrorHandler", { enumerable: true, get: function () { return common_1.defaultErrorHandler; } }); | ||
Object.defineProperty(exports, "defaultSerialize", { enumerable: true, get: function () { return common_1.defaultSerialize; } }); | ||
Object.defineProperty(exports, "getValueFromValueNode", { enumerable: true, get: function () { return common_1.getValueFromValueNode; } }); | ||
var float_1 = require("./float"); | ||
exports.createFloatScalar = float_1.createFloatScalar; | ||
exports.isSafeFloat = float_1.isSafeFloat; | ||
Object.defineProperty(exports, "createFloatScalar", { enumerable: true, get: function () { return float_1.createFloatScalar; } }); | ||
Object.defineProperty(exports, "isSafeFloat", { enumerable: true, get: function () { return float_1.isSafeFloat; } }); | ||
var int_1 = require("./int"); | ||
exports.createIntScalar = int_1.createIntScalar; | ||
exports.isSafeInteger = int_1.isSafeInteger; | ||
Object.defineProperty(exports, "createIntScalar", { enumerable: true, get: function () { return int_1.createIntScalar; } }); | ||
Object.defineProperty(exports, "isSafeInteger", { enumerable: true, get: function () { return int_1.isSafeInteger; } }); | ||
var string_1 = require("./string"); | ||
exports.createStringScalar = string_1.createStringScalar; | ||
Object.defineProperty(exports, "createStringScalar", { enumerable: true, get: function () { return string_1.createStringScalar; } }); | ||
//# sourceMappingURL=index.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IIntScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IIntScalarConfig<TInternal, TExternal>, IntScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createIntScalar = exports.isSafeInteger = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -8,3 +9,3 @@ var graphql_1 = require("graphql"); | ||
var MIN_INT = -2147483648; | ||
exports.isSafeInteger = function (n) { | ||
var isSafeInteger = function (n) { | ||
return typeof n === 'number' && | ||
@@ -16,3 +17,4 @@ isFinite(n) && | ||
}; | ||
exports.createIntScalar = function (config) { | ||
exports.isSafeInteger = isSafeInteger; | ||
var createIntScalar = function (config) { | ||
var coerce = config.coerce, errorHandler = config.errorHandler, maximum = config.maximum, minimum = config.minimum, parse = config.parse, sanitize = config.sanitize, validate = config.validate, serialize = config.serialize, scalarConfig = tslib_1.__rest(config, ["coerce", "errorHandler", "maximum", "minimum", "parse", "sanitize", "validate", "serialize"]); | ||
@@ -25,3 +27,3 @@ var handleError = errorHandler || common_1.defaultErrorHandler; | ||
var value; | ||
if (exports.isSafeInteger(unknownValue)) { | ||
if ((0, exports.isSafeInteger)(unknownValue)) { | ||
value = unknownValue; | ||
@@ -87,5 +89,6 @@ } | ||
return new graphql_1.GraphQLScalarType(tslib_1.__assign(tslib_1.__assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue: parseValue, parseLiteral: function (ast) { | ||
return parseValue(common_1.getValueFromValueNode(ast), ast); | ||
return parseValue((0, common_1.getValueFromValueNode)(ast), ast); | ||
} })); | ||
}; | ||
exports.createIntScalar = createIntScalar; | ||
//# sourceMappingURL=int.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export interface IStringScalarConfig<TInternal = string, TExternal = string> extends IScalarConfig<IStringScalarConfig<TInternal, TExternal>, StringScalarErrorCode, string, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ capitalize?: 'characters' | 'words' | 'sentences' | 'first'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStringScalar = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -17,3 +18,3 @@ var graphql_1 = require("graphql"); | ||
}; | ||
exports.createStringScalar = function (config) { | ||
var createStringScalar = function (config) { | ||
var capitalize = config.capitalize, coerce = config.coerce, collapseWhitespace = config.collapseWhitespace, errorHandler = config.errorHandler, lowercase = config.lowercase, maxEmptyLines = config.maxEmptyLines, maxLength = config.maxLength, minLength = config.minLength, nonEmpty = config.nonEmpty, parse = config.parse, pattern = config.pattern, sanitize = config.sanitize, serialize = config.serialize, singleline = config.singleline, trim = config.trim, trimLeft = config.trimLeft, trimRight = config.trimRight, truncate = config.truncate, uppercase = config.uppercase, validate = config.validate, scalarConfig = tslib_1.__rest(config, ["capitalize", "coerce", "collapseWhitespace", "errorHandler", "lowercase", "maxEmptyLines", "maxLength", "minLength", "nonEmpty", "parse", "pattern", "sanitize", "serialize", "singleline", "trim", "trimLeft", "trimRight", "truncate", "uppercase", "validate"]); | ||
@@ -25,3 +26,3 @@ var regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern; | ||
if (maxEmptyLines) { | ||
emptyLineRegex = new RegExp("\n{" + (maxEmptyLines + 2) + ",}", 'g'); | ||
emptyLineRegex = new RegExp("\n{".concat(maxEmptyLines + 2, ",}"), 'g'); | ||
emptyLineString = '\n'.repeat(maxEmptyLines + 1); | ||
@@ -83,6 +84,3 @@ } | ||
else { | ||
value = value | ||
.split(newlineWithWSRegex) | ||
.map(collapseWS) | ||
.join('\n'); | ||
value = value.split(newlineWithWSRegex).map(collapseWS).join('\n'); | ||
} | ||
@@ -176,5 +174,6 @@ } | ||
return new graphql_1.GraphQLScalarType(tslib_1.__assign(tslib_1.__assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue: parseValue, parseLiteral: function (ast) { | ||
return parseValue(common_1.getValueFromValueNode(ast), ast); | ||
return parseValue((0, common_1.getValueFromValueNode)(ast), ast); | ||
} })); | ||
}; | ||
exports.createStringScalar = createStringScalar; | ||
//# sourceMappingURL=string.js.map |
@@ -10,8 +10,8 @@ import { GraphQLScalarTypeConfig, ValueNode } from 'graphql'; | ||
} | ||
export declare type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export declare type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export declare type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export declare type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export declare type ScalarParseFunction<T, U> = (value: T) => U; | ||
export declare type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export type ScalarParseFunction<T, U> = (value: T) => U; | ||
export type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export interface IScalarConfig<TConfig, TErrorCode, TValue, TInternal, TExternal> extends ExcludeKeys<GraphQLScalarTypeConfig<TInternal, TExternal>, 'serialize' | 'parseValue' | 'parseLiteral'> { | ||
@@ -18,0 +18,0 @@ coerce?: ScalarCoerceFunction<TValue>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getValueFromValueNode = exports.defaultSerialize = exports.defaultErrorHandler = void 0; | ||
const graphql_1 = require("graphql"); | ||
const error_1 = require("graphql/error"); | ||
exports.defaultErrorHandler = ({ code, ast, }) => { | ||
const defaultErrorHandler = ({ code, ast, }) => { | ||
throw new error_1.GraphQLError(`code=${code}`, ast ? [ast] : []); | ||
}; | ||
exports.defaultSerialize = (x) => x; | ||
exports.getValueFromValueNode = (ast) => { | ||
exports.defaultErrorHandler = defaultErrorHandler; | ||
const defaultSerialize = (x) => x; | ||
exports.defaultSerialize = defaultSerialize; | ||
const getValueFromValueNode = (ast) => { | ||
switch (ast.kind) { | ||
@@ -26,2 +29,3 @@ case graphql_1.Kind.BOOLEAN: | ||
}; | ||
exports.getValueFromValueNode = getValueFromValueNode; | ||
//# sourceMappingURL=common.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IFloatScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IFloatScalarConfig<TInternal, TExternal>, FloatScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFloatScalar = exports.isSafeFloat = void 0; | ||
const tslib_1 = require("tslib"); | ||
const graphql_1 = require("graphql"); | ||
const common_1 = require("./common"); | ||
exports.isSafeFloat = (n) => typeof n === 'number' && isFinite(n); | ||
exports.createFloatScalar = (config) => { | ||
const isSafeFloat = (n) => typeof n === 'number' && isFinite(n); | ||
exports.isSafeFloat = isSafeFloat; | ||
const createFloatScalar = (config) => { | ||
const { coerce, errorHandler, maximum, minimum, parse, sanitize, validate, serialize } = config, scalarConfig = tslib_1.__rest(config, ["coerce", "errorHandler", "maximum", "minimum", "parse", "sanitize", "validate", "serialize"]); | ||
@@ -15,3 +17,3 @@ const handleError = errorHandler || common_1.defaultErrorHandler; | ||
let value; | ||
if (exports.isSafeFloat(unknownValue)) { | ||
if ((0, exports.isSafeFloat)(unknownValue)) { | ||
value = unknownValue; | ||
@@ -76,4 +78,5 @@ } | ||
}; | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue(common_1.getValueFromValueNode(ast), ast) })); | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue((0, common_1.getValueFromValueNode)(ast), ast) })); | ||
}; | ||
exports.createFloatScalar = createFloatScalar; | ||
//# sourceMappingURL=float.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStringScalar = exports.isSafeInteger = exports.createIntScalar = exports.isSafeFloat = exports.createFloatScalar = exports.getValueFromValueNode = exports.defaultSerialize = exports.defaultErrorHandler = void 0; | ||
var common_1 = require("./common"); | ||
exports.defaultErrorHandler = common_1.defaultErrorHandler; | ||
exports.defaultSerialize = common_1.defaultSerialize; | ||
exports.getValueFromValueNode = common_1.getValueFromValueNode; | ||
Object.defineProperty(exports, "defaultErrorHandler", { enumerable: true, get: function () { return common_1.defaultErrorHandler; } }); | ||
Object.defineProperty(exports, "defaultSerialize", { enumerable: true, get: function () { return common_1.defaultSerialize; } }); | ||
Object.defineProperty(exports, "getValueFromValueNode", { enumerable: true, get: function () { return common_1.getValueFromValueNode; } }); | ||
var float_1 = require("./float"); | ||
exports.createFloatScalar = float_1.createFloatScalar; | ||
exports.isSafeFloat = float_1.isSafeFloat; | ||
Object.defineProperty(exports, "createFloatScalar", { enumerable: true, get: function () { return float_1.createFloatScalar; } }); | ||
Object.defineProperty(exports, "isSafeFloat", { enumerable: true, get: function () { return float_1.isSafeFloat; } }); | ||
var int_1 = require("./int"); | ||
exports.createIntScalar = int_1.createIntScalar; | ||
exports.isSafeInteger = int_1.isSafeInteger; | ||
Object.defineProperty(exports, "createIntScalar", { enumerable: true, get: function () { return int_1.createIntScalar; } }); | ||
Object.defineProperty(exports, "isSafeInteger", { enumerable: true, get: function () { return int_1.isSafeInteger; } }); | ||
var string_1 = require("./string"); | ||
exports.createStringScalar = string_1.createStringScalar; | ||
Object.defineProperty(exports, "createStringScalar", { enumerable: true, get: function () { return string_1.createStringScalar; } }); | ||
//# sourceMappingURL=index.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IIntScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IIntScalarConfig<TInternal, TExternal>, IntScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createIntScalar = exports.isSafeInteger = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -8,3 +9,3 @@ const graphql_1 = require("graphql"); | ||
const MIN_INT = -2147483648; | ||
exports.isSafeInteger = (n) => typeof n === 'number' && | ||
const isSafeInteger = (n) => typeof n === 'number' && | ||
isFinite(n) && | ||
@@ -14,3 +15,4 @@ Math.floor(n) === n && | ||
n >= MIN_INT; | ||
exports.createIntScalar = (config) => { | ||
exports.isSafeInteger = isSafeInteger; | ||
const createIntScalar = (config) => { | ||
const { coerce, errorHandler, maximum, minimum, parse, sanitize, validate, serialize } = config, scalarConfig = tslib_1.__rest(config, ["coerce", "errorHandler", "maximum", "minimum", "parse", "sanitize", "validate", "serialize"]); | ||
@@ -23,3 +25,3 @@ const handleError = errorHandler || common_1.defaultErrorHandler; | ||
let value; | ||
if (exports.isSafeInteger(unknownValue)) { | ||
if ((0, exports.isSafeInteger)(unknownValue)) { | ||
value = unknownValue; | ||
@@ -84,4 +86,5 @@ } | ||
}; | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue(common_1.getValueFromValueNode(ast), ast) })); | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue((0, common_1.getValueFromValueNode)(ast), ast) })); | ||
}; | ||
exports.createIntScalar = createIntScalar; | ||
//# sourceMappingURL=int.js.map |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export interface IStringScalarConfig<TInternal = string, TExternal = string> extends IScalarConfig<IStringScalarConfig<TInternal, TExternal>, StringScalarErrorCode, string, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ capitalize?: 'characters' | 'words' | 'sentences' | 'first'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStringScalar = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -15,3 +16,3 @@ const graphql_1 = require("graphql"); | ||
const trimAndCollapseWS = (str) => str.trim().replace(whitespace, ' '); | ||
exports.createStringScalar = (config) => { | ||
const createStringScalar = (config) => { | ||
const { capitalize, coerce, collapseWhitespace, errorHandler, lowercase, maxEmptyLines, maxLength, minLength, nonEmpty, parse, pattern, sanitize, serialize, singleline, trim, trimLeft, trimRight, truncate, uppercase, validate } = config, scalarConfig = tslib_1.__rest(config, ["capitalize", "coerce", "collapseWhitespace", "errorHandler", "lowercase", "maxEmptyLines", "maxLength", "minLength", "nonEmpty", "parse", "pattern", "sanitize", "serialize", "singleline", "trim", "trimLeft", "trimRight", "truncate", "uppercase", "validate"]); | ||
@@ -80,6 +81,3 @@ const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern; | ||
else { | ||
value = value | ||
.split(newlineWithWSRegex) | ||
.map(collapseWS) | ||
.join('\n'); | ||
value = value.split(newlineWithWSRegex).map(collapseWS).join('\n'); | ||
} | ||
@@ -172,4 +170,5 @@ } | ||
}; | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue(common_1.getValueFromValueNode(ast), ast) })); | ||
return new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, scalarConfig), { serialize: serialize || common_1.defaultSerialize, parseValue, parseLiteral: (ast) => parseValue((0, common_1.getValueFromValueNode)(ast), ast) })); | ||
}; | ||
exports.createStringScalar = createStringScalar; | ||
//# sourceMappingURL=string.js.map |
@@ -10,8 +10,8 @@ import { GraphQLScalarTypeConfig, ValueNode } from 'graphql'; | ||
} | ||
export declare type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export declare type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export declare type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export declare type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export declare type ScalarParseFunction<T, U> = (value: T) => U; | ||
export declare type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export type ScalarParseFunction<T, U> = (value: T) => U; | ||
export type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export interface IScalarConfig<TConfig, TErrorCode, TValue, TInternal, TExternal> extends ExcludeKeys<GraphQLScalarTypeConfig<TInternal, TExternal>, 'serialize' | 'parseValue' | 'parseLiteral'> { | ||
@@ -18,0 +18,0 @@ coerce?: ScalarCoerceFunction<TValue>; |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type FloatScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IFloatScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IFloatScalarConfig<TInternal, TExternal>, FloatScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export type IntScalarErrorCode = 'type' | 'minimum' | 'maximum' | 'validate'; | ||
export interface IIntScalarConfig<TInternal = number, TExternal = number> extends IScalarConfig<IIntScalarConfig<TInternal, TExternal>, IntScalarErrorCode, number, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ maximum?: number; |
import { GraphQLScalarType } from 'graphql'; | ||
import { IScalarConfig } from './ts'; | ||
export declare type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export type StringScalarErrorCode = 'type' | 'empty' | 'minLength' | 'maxLength' | 'pattern' | 'validate'; | ||
export interface IStringScalarConfig<TInternal = string, TExternal = string> extends IScalarConfig<IStringScalarConfig<TInternal, TExternal>, StringScalarErrorCode, string, TInternal, TExternal> { | ||
@@ -5,0 +5,0 @@ capitalize?: 'characters' | 'words' | 'sentences' | 'first'; |
@@ -77,6 +77,3 @@ import { __rest } from "tslib"; | ||
else { | ||
value = value | ||
.split(newlineWithWSRegex) | ||
.map(collapseWS) | ||
.join('\n'); | ||
value = value.split(newlineWithWSRegex).map(collapseWS).join('\n'); | ||
} | ||
@@ -83,0 +80,0 @@ } |
@@ -10,8 +10,8 @@ import { GraphQLScalarTypeConfig, ValueNode } from 'graphql'; | ||
} | ||
export declare type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export declare type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export declare type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export declare type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export declare type ScalarParseFunction<T, U> = (value: T) => U; | ||
export declare type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export type ScalarParseErrorHandler<TInternal, TConfig, TCode = string> = (errorInfo: IScalarParseError<TConfig, TCode>) => TInternal; | ||
export type ScalarCoerceFunction<T> = (raw: unknown) => T | null | undefined; | ||
export type ScalarSanitizeFunction<T> = (value: T) => T | null | undefined; | ||
export type ScalarValidateFunction<T> = (value: T) => boolean; | ||
export type ScalarParseFunction<T, U> = (value: T) => U; | ||
export type ScalarSerializeFunction<T, U> = (value: T) => U; | ||
export interface IScalarConfig<TConfig, TErrorCode, TValue, TInternal, TExternal> extends ExcludeKeys<GraphQLScalarTypeConfig<TInternal, TExternal>, 'serialize' | 'parseValue' | 'parseLiteral'> { | ||
@@ -18,0 +18,0 @@ coerce?: ScalarCoerceFunction<TValue>; |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=ts.js.map |
{ | ||
"name": "graphql-scalar", | ||
"version": "0.0.11", | ||
"version": "0.1.0", | ||
"description": "Configurable custom GraphQL Scalars (string, number, date, etc) with sanitization / validation / transformation in TypeScript.", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"build:node": "tsc -p ./tsconfig.node.json && tscpaths -p ./tsconfig.node.json -s ./src -o ./dist/node", | ||
"clean": "rm -rf ./lib ./dist ./coverage", | ||
"clean": "shx rm -rf ./lib ./dist ./coverage", | ||
"format": "prettier --write \"./*.{js,jsx,ts,tsx}\" \"./src/**/*.{js,jsx,ts,tsx}\"", | ||
@@ -50,3 +50,3 @@ "lint": "tslint -c ./tslint.json \"src/**/*.ts\"", | ||
"prepublishOnly": "npm run all", | ||
"reinstall": "rm -rf ./node_modules ./package-lock.json ./yarn.lock && yarn", | ||
"reinstall": "shx rm -rf ./node_modules ./package-lock.json ./yarn.lock && yarn", | ||
"start": "npm run test", | ||
@@ -59,2 +59,5 @@ "test": "jest", | ||
"pre-commit": "precommit", | ||
"dependencies": { | ||
"tsdef": "^0.0.14" | ||
}, | ||
"peerDependencies": { | ||
@@ -66,16 +69,16 @@ "graphql": "*", | ||
"@types/graphql": "^14.5.0", | ||
"@types/jest": "^24.0.23", | ||
"@types/node": "^12.12.8", | ||
"coveralls": "^3.0.7", | ||
"graphql": "^14.5.8", | ||
"jest": "^24.9.0", | ||
"@types/jest": "^29.5.0", | ||
"@types/node": "^18.15.5", | ||
"coveralls": "^3.1.1", | ||
"graphql": "^14.*.*", | ||
"jest": "^29.5.0", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^1.19.1", | ||
"ts-jest": "^24.1.0", | ||
"prettier": "^2.8.6", | ||
"shx": "^0.3.4", | ||
"ts-jest": "^29.0.5", | ||
"tscpaths": "^0.0.9", | ||
"tsdef": "^0.0.13", | ||
"tslint": "^5.20.1", | ||
"tslint-config-airbnb": "^5.11.2", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^3.7.2" | ||
"typescript": "^5.0.2" | ||
}, | ||
@@ -82,0 +85,0 @@ "engines": { |
@@ -0,0 +0,0 @@ # graphql-scalar |
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
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
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
108463
1341
3
+ Addedtsdef@^0.0.14
+ Addedtsdef@0.0.14(transitive)