bigriver
Advanced tools
Comparing version 1.0.37 to 1.0.38
@@ -0,1 +1,2 @@ | ||
import { TValue } from '@sinclair/typebox'; | ||
import { ObjectID } from 'bson'; | ||
@@ -17,2 +18,6 @@ export declare type Nullable<T> = T | null; | ||
} | ||
export declare class LiteralType { | ||
static of<T extends TValue>(literal: T): import("@sinclair/typebox").TLiteral<T>; | ||
static anyOf<T extends TValue[]>(...literals: [...T]): import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<T[number]>[]>; | ||
} | ||
export declare class StringType { | ||
@@ -25,3 +30,2 @@ static Boolean: import("@sinclair/typebox").TString; | ||
static Url: import("@sinclair/typebox").TString; | ||
static In: (items: string[]) => import("@sinclair/typebox").TString; | ||
} | ||
@@ -28,0 +32,0 @@ export declare class StringTo { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StringTo = exports.StringType = exports.StringPattern = exports.isNotEmpty = exports.isEmpty = exports.isNullOrUndefined = void 0; | ||
exports.StringTo = exports.StringType = exports.LiteralType = exports.StringPattern = exports.isNotEmpty = exports.isEmpty = exports.isNullOrUndefined = void 0; | ||
const typebox_1 = require("@sinclair/typebox"); | ||
const bson_1 = require("bson"); | ||
const lodash_1 = require("lodash"); | ||
const isNullOrUndefined = (obj) => obj === undefined || obj === null; | ||
@@ -21,2 +22,11 @@ exports.isNullOrUndefined = isNullOrUndefined; | ||
StringPattern.ObjectID = '^[0-9a-fA-F]{24}$'; | ||
class LiteralType { | ||
static of(literal) { | ||
return typebox_1.Type.Literal(literal); | ||
} | ||
static anyOf(...literals) { | ||
return typebox_1.Type.Union(lodash_1.map(literals, item => typebox_1.Type.Literal(item))); | ||
} | ||
} | ||
exports.LiteralType = LiteralType; | ||
class StringType { | ||
@@ -31,3 +41,2 @@ } | ||
StringType.Url = typebox_1.Type.String({ format: 'uri' }); | ||
StringType.In = (items) => typebox_1.Type.String({ pattern: `^(${items.join('|')})$` }); | ||
class StringTo { | ||
@@ -34,0 +43,0 @@ static Boolean(str) { |
{ | ||
"name": "bigriver", | ||
"version": "1.0.37", | ||
"version": "1.0.38", | ||
"description": "A fast well-typed back-end prototyping framework", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,3 +0,4 @@ | ||
import { Type } from '@sinclair/typebox' | ||
import { TValue, Type } from '@sinclair/typebox' | ||
import { ObjectID } from 'bson' | ||
import { map } from 'lodash' | ||
@@ -28,2 +29,12 @@ export type Nullable<T> = T | null | ||
export class LiteralType { | ||
static of<T extends TValue>(literal: T) { | ||
return Type.Literal(literal) | ||
} | ||
static anyOf<T extends TValue[]>(...literals: [...T]) { | ||
return Type.Union(map(literals, item => Type.Literal(item))) | ||
} | ||
} | ||
export class StringType { | ||
@@ -36,5 +47,2 @@ static Boolean = Type.String({ pattern: StringPattern.Boolean }) | ||
static Url = Type.String({ format: 'uri' }) | ||
static In = (items: string[]) => | ||
Type.String({ pattern: `^(${items.join('|')})$` }) | ||
} | ||
@@ -41,0 +49,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
177350
1544