@nmtjs/type 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +3 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { TLiteralValue } from '@sinclair/typebox'\nimport { ArrayType } from './types/array.ts'\nimport type { BaseType } from './types/base.ts'\nimport { BooleanType } from './types/boolean.ts'\nimport { CustomType } from './types/custom.ts'\nimport { DateType } from './types/datetime.ts'\nimport {\n type AnyEnumType,\n type AnyObjectEnumType,\n EnumType,\n ObjectEnumType,\n} from './types/enum.ts'\nimport { type AnyLiteralType, LiteralType } from './types/literal.ts'\nimport { BigIntType, IntegerType, NumberType } from './types/number.ts'\nimport { ObjectType, RecordType } from './types/object.ts'\nimport { type AnyStringType, StringType } from './types/string.ts'\nimport {\n type AnyUnionType,\n IntersactionType,\n UnionType,\n} from './types/union.ts'\n\nimport type { typeStatic } from './constants.ts'\nimport { AnyType } from './types/any.ts'\nimport { NeverType } from './types/never.ts'\n\n// register ajv formats\nimport { register } from './formats.ts'\nregister()\n\nexport * from './schemas/native-enum.ts'\nexport * from './schemas/union-enum.ts'\nexport * from './schemas/nullable.ts'\nexport {\n BaseType,\n getTypeSchema,\n} from './types/base.ts'\nexport { type TSchema } from '@sinclair/typebox'\nexport {\n ArrayType,\n BooleanType,\n CustomType,\n DateType,\n EnumType,\n LiteralType,\n IntegerType,\n NumberType,\n ObjectType,\n StringType,\n IntersactionType,\n UnionType,\n AnyType,\n NeverType,\n}\n\nexport namespace t {\n export namespace infer {\n export type
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { TLiteralValue } from '@sinclair/typebox'\nimport { ArrayType } from './types/array.ts'\nimport type { BaseType } from './types/base.ts'\nimport { BooleanType } from './types/boolean.ts'\nimport { CustomType } from './types/custom.ts'\nimport { DateType } from './types/datetime.ts'\nimport {\n type AnyEnumType,\n type AnyObjectEnumType,\n EnumType,\n ObjectEnumType,\n} from './types/enum.ts'\nimport { type AnyLiteralType, LiteralType } from './types/literal.ts'\nimport { BigIntType, IntegerType, NumberType } from './types/number.ts'\nimport { ObjectType, RecordType } from './types/object.ts'\nimport { type AnyStringType, StringType } from './types/string.ts'\nimport {\n type AnyUnionType,\n IntersactionType,\n UnionType,\n} from './types/union.ts'\n\nimport type { typeStatic } from './constants.ts'\nimport { AnyType } from './types/any.ts'\nimport { NeverType } from './types/never.ts'\n\n// register ajv formats\nimport { register } from './formats.ts'\nregister()\n\nexport * from './schemas/native-enum.ts'\nexport * from './schemas/union-enum.ts'\nexport * from './schemas/nullable.ts'\nexport {\n BaseType,\n getTypeSchema,\n} from './types/base.ts'\nexport { type TSchema } from '@sinclair/typebox'\nexport {\n ArrayType,\n BooleanType,\n CustomType,\n DateType,\n EnumType,\n LiteralType,\n IntegerType,\n NumberType,\n ObjectType,\n StringType,\n IntersactionType,\n UnionType,\n AnyType,\n NeverType,\n}\n\nexport namespace t {\n export namespace infer {\n export type staticType<T extends BaseType> = T[typeStatic]\n export type decoded<T extends BaseType> = staticType<T>['decoded']\n export type encoded<T extends BaseType> = staticType<T>['encoded']\n }\n export const never = () => new NeverType()\n export const boolean = () => new BooleanType()\n export const string = () => new StringType()\n export const number = () => new NumberType()\n export const integer = () => new IntegerType()\n export const bitint = () => new BigIntType()\n export const literal = <T extends TLiteralValue>(value: T) =>\n new LiteralType(value)\n export const objectEnum = <T extends { [K in string]: K }>(enumLike: T) =>\n new ObjectEnumType(enumLike)\n export const arrayEnum = <T extends (string | number)[]>(enumLike: [...T]) =>\n new EnumType(enumLike)\n export const date = () => new DateType()\n export const array = <T extends BaseType>(element: T) =>\n new ArrayType(element)\n export const object = <T extends Record<string, BaseType>>(properties: T) =>\n new ObjectType(properties)\n export const record = <\n K extends\n | AnyLiteralType\n | AnyEnumType\n | AnyObjectEnumType\n | AnyStringType\n | AnyUnionType,\n E extends BaseType,\n >(\n key: K,\n value: E,\n ) => new RecordType(key, value)\n export const any = () => new AnyType()\n export const or = <T extends [BaseType, BaseType, ...BaseType[]]>(\n ...types: T\n ) => new UnionType(types)\n export const and = <T extends [BaseType, BaseType, ...BaseType[]]>(\n ...types: T\n ) => new IntersactionType(types)\n export const custom = <T>(\n decode: (value: any) => T,\n encode: (value: T) => any,\n ) => new CustomType<T>(decode, encode)\n}\n"],"names":["ArrayType","BooleanType","CustomType","DateType","EnumType","ObjectEnumType","LiteralType","BigIntType","IntegerType","NumberType","ObjectType","RecordType","StringType","IntersactionType","UnionType","AnyType","NeverType","register","BaseType","getTypeSchema","t","never","boolean","string","number","integer","bitint","literal","value","objectEnum","enumLike","arrayEnum","date","array","element","object","properties","record","key","any","or","types","and","custom","decode","encode"],"mappings":"AACA,SAASA,SAAS,QAAQ,mBAAkB;AAE5C,SAASC,WAAW,QAAQ,qBAAoB;AAChD,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAGEC,QAAQ,EACRC,cAAc,QACT,kBAAiB;AACxB,SAA8BC,WAAW,QAAQ,qBAAoB;AACrE,SAASC,UAAU,EAAEC,WAAW,EAAEC,UAAU,QAAQ,oBAAmB;AACvE,SAASC,UAAU,EAAEC,UAAU,QAAQ,oBAAmB;AAC1D,SAA6BC,UAAU,QAAQ,oBAAmB;AAClE,SAEEC,gBAAgB,EAChBC,SAAS,QACJ,mBAAkB;AAGzB,SAASC,OAAO,QAAQ,iBAAgB;AACxC,SAASC,SAAS,QAAQ,mBAAkB;AAG5C,SAASC,QAAQ,QAAQ,eAAc;AACvCA;AAEA,cAAc,2BAA0B;AACxC,cAAc,0BAAyB;AACvC,cAAc,wBAAuB;AACrC,SACEC,QAAQ,EACRC,aAAa,QACR,kBAAiB;AAExB,SACEnB,SAAS,EACTC,WAAW,EACXC,UAAU,EACVC,QAAQ,EACRC,QAAQ,EACRE,WAAW,EACXE,WAAW,EACXC,UAAU,EACVC,UAAU,EACVE,UAAU,EACVC,gBAAgB,EAChBC,SAAS,EACTC,OAAO,EACPC,SAAS,KACV;;UAEgBI;MAMFC,QAAQ,IAAM,IAAIL;MAClBM,UAAU,IAAM,IAAIrB;MACpBsB,SAAS,IAAM,IAAIX;MACnBY,SAAS,IAAM,IAAIf;MACnBgB,UAAU,IAAM,IAAIjB;MACpBkB,SAAS,IAAM,IAAInB;MACnBoB,UAAU,CAA0BC,QAC/C,IAAItB,YAAYsB;MACLC,aAAa,CAAiCC,WACzD,IAAIzB,eAAeyB;MACRC,YAAY,CAAgCD,WACvD,IAAI1B,SAAS0B;MACFE,OAAO,IAAM,IAAI7B;MACjB8B,QAAQ,CAAqBC,UACxC,IAAIlC,UAAUkC;MACHC,SAAS,CAAqCC,aACzD,IAAI1B,WAAW0B;MACJC,SAAS,CASpBC,KACAV,QACG,IAAIjB,WAAW2B,KAAKV;MACZW,MAAM,IAAM,IAAIxB;MAChByB,KAAK,CAChB,GAAGC,QACA,IAAI3B,UAAU2B;MACNC,MAAM,CACjB,GAAGD,QACA,IAAI5B,iBAAiB4B;MACbE,SAAS,CACpBC,QACAC,SACG,IAAI3C,WAAc0C,QAAQC;AACjC,GA9CiBzB,MAAAA"}
|
package/package.json
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@sinclair/typebox": "^0.33.7",
|
|
23
23
|
"temporal-polyfill": "^0.2.5",
|
|
24
|
-
"@nmtjs/common": "0.3.
|
|
24
|
+
"@nmtjs/common": "0.3.7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@sinclair/typebox": "^0.33.7",
|
|
28
28
|
"temporal-polyfill": "^0.2.5",
|
|
29
|
-
"@nmtjs/common": "0.3.
|
|
29
|
+
"@nmtjs/common": "0.3.7"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"src",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"LICENSE.md",
|
|
36
36
|
"README.md"
|
|
37
37
|
],
|
|
38
|
-
"version": "0.3.
|
|
38
|
+
"version": "0.3.7",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "neemata-build -p neutral --root=./src './**/*.ts'",
|
|
41
41
|
"type-check": "tsc --noEmit"
|
package/src/index.ts
CHANGED
|
@@ -55,8 +55,9 @@ export {
|
|
|
55
55
|
|
|
56
56
|
export namespace t {
|
|
57
57
|
export namespace infer {
|
|
58
|
-
export type
|
|
59
|
-
export type
|
|
58
|
+
export type staticType<T extends BaseType> = T[typeStatic]
|
|
59
|
+
export type decoded<T extends BaseType> = staticType<T>['decoded']
|
|
60
|
+
export type encoded<T extends BaseType> = staticType<T>['encoded']
|
|
60
61
|
}
|
|
61
62
|
export const never = () => new NeverType()
|
|
62
63
|
export const boolean = () => new BooleanType()
|