@anzenjs/extra
Advanced tools
Comparing version 0.0.4-alpha.1 to 0.0.4-alpha.3
@@ -1,7 +0,7 @@ | ||
import { Resolve, Schema } from '@anzenjs/core'; | ||
import { Resolve, SchemaLike } from '@anzenjs/core'; | ||
export interface IEncoder<O extends unknown> { | ||
encode<S extends Schema>(schema: S): (value: Resolve<S>) => O; | ||
encode<S extends SchemaLike>(schema: S): (value: Resolve<S>) => O; | ||
} | ||
export interface IDecoder<I extends unknown> { | ||
decode<S extends Schema>(schema: S): (value: I) => Resolve<S>; | ||
decode<S extends SchemaLike>(schema: S): (value: I) => Resolve<S>; | ||
} | ||
@@ -8,0 +8,0 @@ export interface ICodec<I extends unknown, O extends unknown> extends IEncoder<O>, IDecoder<I> { |
@@ -1,4 +0,4 @@ | ||
import { Constructor } from '@anzenjs/core'; | ||
import { Constructor, IBrandSchema } from '@anzenjs/core'; | ||
export declare const idSymbol: unique symbol; | ||
export declare const Id: <T>(value: Constructor<T>) => import("../../core/src").IBrandSchema<string, typeof idSymbol, Constructor<T>> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof idSymbol, Constructor<T>>>; | ||
export declare const Id: <T>(value: Constructor<T>) => IBrandSchema<string, typeof idSymbol, Constructor<T>>; | ||
export declare type Id<T> = string & { | ||
@@ -5,0 +5,0 @@ [idSymbol]: Constructor<T>; |
@@ -1,22 +0,22 @@ | ||
import { ResolveBrand } from '@anzenjs/core'; | ||
import { IBrandSchema, ResolveBrand } from '@anzenjs/core'; | ||
export declare const emailSymbol: unique symbol; | ||
export declare const Email: import("../../core/src").IBrandSchema<string, typeof emailSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof emailSymbol, true>>; | ||
export declare const Email: IBrandSchema<string, typeof emailSymbol, true>; | ||
export declare type Email = ResolveBrand<typeof Email>; | ||
export declare const uriSymbol: unique symbol; | ||
export declare const Uri: import("../../core/src").IBrandSchema<string, typeof uriSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof uriSymbol, true>>; | ||
export declare const Uri: IBrandSchema<string, typeof uriSymbol, true>; | ||
export declare type Uri = ResolveBrand<typeof Uri>; | ||
export declare const integerSymbol: unique symbol; | ||
export declare const Integer: import("../../core/src").IBrandSchema<number, typeof integerSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<number, typeof integerSymbol, true>>; | ||
export declare const Integer: IBrandSchema<number, typeof integerSymbol, true>; | ||
export declare type Integer = ResolveBrand<typeof Integer>; | ||
export declare const portSymbol: unique symbol; | ||
export declare const Port: import("../../core/src").IBrandSchema<any, typeof portSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<any, typeof portSymbol, true>>; | ||
export declare const Port: IBrandSchema<Integer, typeof portSymbol, true>; | ||
export declare type Port = ResolveBrand<typeof Port>; | ||
export declare const ipSymbol: unique symbol; | ||
export declare const Ip: import("../../core/src").IBrandSchema<string, typeof ipSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof ipSymbol, true>>; | ||
export declare const Ip: IBrandSchema<string, typeof ipSymbol, true>; | ||
export declare type Ip = ResolveBrand<typeof Ip>; | ||
export declare const hostnameSymbol: unique symbol; | ||
export declare const Hostname: import("../../core/src").IBrandSchema<string, typeof hostnameSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof hostnameSymbol, true>>; | ||
export declare const Hostname: IBrandSchema<string, typeof hostnameSymbol, true>; | ||
export declare type Hostname = ResolveBrand<typeof Hostname>; | ||
export declare const uuidSymbol: unique symbol; | ||
export declare const Uuid: import("../../core/src").IBrandSchema<string, typeof uuidSymbol, true> & import("../../core/src").BrandDecorator<import("../../core/src").IBrandSchema<string, typeof uuidSymbol, true>>; | ||
export declare const Uuid: IBrandSchema<string, typeof uuidSymbol, true>; | ||
export declare type Uuid = ResolveBrand<typeof Uuid>; | ||
@@ -23,0 +23,0 @@ export { IEncoder, IDecoder, ICodec } from './codec'; |
{ | ||
"name": "@anzenjs/extra", | ||
"version": "0.0.4-alpha.1", | ||
"version": "0.0.4-alpha.3", | ||
"main": "cjs/src/index.js", | ||
@@ -15,3 +15,3 @@ "types": "cjs/src/index.d.ts", | ||
}, | ||
"gitHead": "5022259a40c0508dae37df5404853765c18200dd" | ||
"gitHead": "734908eb45107c55aa2570f38d334c09fa3395be" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Brand, Constructor } from '@anzenjs/core' | ||
import { Brand, Constructor, IBrandSchema } from '@anzenjs/core' | ||
@@ -21,6 +21,10 @@ type Transformer<T, U> = (value: T) => U | ||
export const Id = cache(<T>(ctor: Constructor<T>) => { | ||
return Brand(String, idSymbol, ctor) | ||
}) | ||
export const Id = cache( | ||
<T>( | ||
ctor: Constructor<T>, | ||
): IBrandSchema<string, typeof idSymbol, Constructor<T>> => { | ||
return Brand(String, idSymbol, ctor) | ||
}, | ||
) | ||
export type Id<T> = string & { [idSymbol]: Constructor<T> } |
@@ -1,6 +0,9 @@ | ||
import { Brand, ResolveBrand } from '@anzenjs/core' | ||
import { Brand, IBrandSchema, ResolveBrand } from '@anzenjs/core' | ||
export const emailSymbol = Symbol('email') | ||
export const Email = Brand(String, emailSymbol) | ||
export const Email: IBrandSchema<string, typeof emailSymbol, true> = Brand( | ||
String, | ||
emailSymbol, | ||
) | ||
@@ -11,3 +14,6 @@ export type Email = ResolveBrand<typeof Email> | ||
export const Uri = Brand(String, uriSymbol) | ||
export const Uri: IBrandSchema<string, typeof uriSymbol, true> = Brand( | ||
String, | ||
uriSymbol, | ||
) | ||
@@ -18,3 +24,6 @@ export type Uri = ResolveBrand<typeof Uri> | ||
export const Integer = Brand(Number, integerSymbol) | ||
export const Integer: IBrandSchema<number, typeof integerSymbol, true> = Brand( | ||
Number, | ||
integerSymbol, | ||
) | ||
@@ -25,3 +34,6 @@ export type Integer = ResolveBrand<typeof Integer> | ||
export const Port = Brand(Integer, portSymbol) | ||
export const Port: IBrandSchema<Integer, typeof portSymbol, true> = Brand( | ||
Integer, | ||
portSymbol, | ||
) | ||
@@ -32,3 +44,6 @@ export type Port = ResolveBrand<typeof Port> | ||
export const Ip = Brand(String, ipSymbol) | ||
export const Ip: IBrandSchema<string, typeof ipSymbol, true> = Brand( | ||
String, | ||
ipSymbol, | ||
) | ||
@@ -39,3 +54,7 @@ export type Ip = ResolveBrand<typeof Ip> | ||
export const Hostname = Brand(String, hostnameSymbol) | ||
export const Hostname: IBrandSchema< | ||
string, | ||
typeof hostnameSymbol, | ||
true | ||
> = Brand(String, hostnameSymbol) | ||
@@ -46,3 +65,6 @@ export type Hostname = ResolveBrand<typeof Hostname> | ||
export const Uuid = Brand(String, uuidSymbol) | ||
export const Uuid: IBrandSchema<string, typeof uuidSymbol, true> = Brand( | ||
String, | ||
uuidSymbol, | ||
) | ||
@@ -49,0 +71,0 @@ export type Uuid = ResolveBrand<typeof Uuid> |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162
11733