@nmtjs/type 0.4.5 → 0.4.6
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/types/number.js +6 -6
- package/dist/types/number.js.map +1 -1
- package/package.json +3 -3
- package/src/types/number.ts +6 -6
package/dist/types/number.js
CHANGED
|
@@ -57,7 +57,7 @@ export class NumberType extends BaseType {
|
|
|
57
57
|
return new NumberType(...this._with({
|
|
58
58
|
options: {
|
|
59
59
|
maximum: value,
|
|
60
|
-
|
|
60
|
+
...!exclusive ? {} : {
|
|
61
61
|
exclusiveMaximum: value
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -67,7 +67,7 @@ export class NumberType extends BaseType {
|
|
|
67
67
|
return new NumberType(...this._with({
|
|
68
68
|
options: {
|
|
69
69
|
minimum: value,
|
|
70
|
-
|
|
70
|
+
...!exclusive ? {} : {
|
|
71
71
|
exclusiveMinimum: value
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -129,7 +129,7 @@ export class IntegerType extends BaseType {
|
|
|
129
129
|
return new IntegerType(...this._with({
|
|
130
130
|
options: {
|
|
131
131
|
maximum: value,
|
|
132
|
-
|
|
132
|
+
...!exclusive ? {} : {
|
|
133
133
|
exclusiveMaximum: value
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -139,7 +139,7 @@ export class IntegerType extends BaseType {
|
|
|
139
139
|
return new IntegerType(...this._with({
|
|
140
140
|
options: {
|
|
141
141
|
minimum: value,
|
|
142
|
-
|
|
142
|
+
...!exclusive ? {} : {
|
|
143
143
|
exclusiveMinimum: value
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -213,7 +213,7 @@ export class BigIntType extends BaseType {
|
|
|
213
213
|
return new BigIntType(...this._with({
|
|
214
214
|
options: {
|
|
215
215
|
maximum: this.encode(value),
|
|
216
|
-
|
|
216
|
+
...!exclusive ? {} : {
|
|
217
217
|
exclusiveMaximum: this.encode(value)
|
|
218
218
|
}
|
|
219
219
|
}
|
|
@@ -223,7 +223,7 @@ export class BigIntType extends BaseType {
|
|
|
223
223
|
return new BigIntType(...this._with({
|
|
224
224
|
options: {
|
|
225
225
|
minimum: `${value}`,
|
|
226
|
-
|
|
226
|
+
...!exclusive ? {} : {
|
|
227
227
|
exclusiveMinimum: `${value}`
|
|
228
228
|
}
|
|
229
229
|
}
|
package/dist/types/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/number.ts"],"sourcesContent":["import {\n type IntegerOptions,\n type NumberOptions,\n type StringOptions,\n type TInteger,\n type TNumber,\n type TString,\n type TTransform,\n Type,\n TypeBoxError,\n} from '@sinclair/typebox'\nimport { BaseType } from './base.ts'\n\nexport class NumberType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TNumber, N, O, D, NumberOptions> {\n constructor(\n protected readonly options: NumberOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: NumberOptions): TNumber {\n return Type.Number(options)\n }\n\n nullable() {\n return new NumberType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new NumberType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new NumberType(...this._with({ isNullable: true, isOptional: true }))\n }\n\n default(value: number) {\n return new NumberType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new NumberType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [number, ...number[]]) {\n return new NumberType(...this._with({ options: { examples } }))\n }\n\n positive() {\n return this.min(0, true)\n }\n\n negative() {\n return this.max(0, true)\n }\n\n max(value: number, exclusive?: true) {\n return new NumberType(\n ...this._with({\n options: {\n maximum: value,\n ...(exclusive ? {} : { exclusiveMaximum: value }),\n },\n }),\n )\n }\n\n min(value: number, exclusive?: true) {\n return new NumberType(\n ...this._with({\n options: {\n minimum: value,\n ...(exclusive ? {} : { exclusiveMinimum: value }),\n },\n }),\n )\n }\n}\n\nexport class IntegerType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TInteger, N, O, D, IntegerOptions> {\n constructor(\n options: IntegerOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: IntegerOptions): TInteger {\n return Type.Integer(options)\n }\n\n nullable() {\n return new IntegerType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new IntegerType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new IntegerType(\n ...this._with({ isNullable: true, isOptional: true }),\n )\n }\n\n default(value: number) {\n return new IntegerType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new IntegerType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [number, ...number[]]) {\n return new IntegerType(...this._with({ options: { examples } }))\n }\n\n positive() {\n return this.min(0, true)\n }\n\n negative() {\n return this.max(0, true)\n }\n\n max(value: number, exclusive?: true) {\n return new IntegerType(\n ...this._with({\n options: {\n maximum: value,\n ...(exclusive ? {} : { exclusiveMaximum: value }),\n },\n }),\n )\n }\n\n min(value: number, exclusive?: true) {\n return new IntegerType(\n ...this._with({\n options: {\n minimum: value,\n ...(exclusive ? {} : { exclusiveMinimum: value }),\n },\n }),\n )\n }\n}\n\nexport class BigIntType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TTransform<TString, bigint>, N, O, D, StringOptions> {\n constructor(\n options: StringOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: StringOptions) {\n return Type.Transform(Type.String({ ...options, pattern: '^\\\\d$' }))\n .Decode((v: string) => {\n try {\n return BigInt(v)\n } catch (error) {\n throw new TypeBoxError('Invalid bigint value')\n }\n })\n .Encode(this.encode)\n }\n\n protected encode = (value: bigint): string => {\n return value.toString()\n }\n\n nullable() {\n return new BigIntType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new BigIntType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new BigIntType(...this._with({ isNullable: true, isOptional: true }))\n }\n\n default(value: bigint) {\n return new BigIntType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new BigIntType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [bigint, ...bigint[]]) {\n return new BigIntType(\n ...this._with({ options: { examples: examples.map(this.encode) } }),\n )\n }\n\n positive() {\n return this.min(0n, true)\n }\n\n negative() {\n return this.max(0n, true)\n }\n\n max(value: bigint, exclusive?: true) {\n return new BigIntType(\n ...this._with({\n options: {\n maximum: this.encode(value),\n ...(exclusive ? {} : { exclusiveMaximum: this.encode(value) }),\n },\n }),\n )\n }\n\n min(value: bigint, exclusive?: true) {\n return new BigIntType(\n ...this._with({\n options: {\n minimum: `${value}`,\n ...(exclusive ? {} : { exclusiveMinimum: `${value}` }),\n },\n }),\n )\n }\n}\n"],"names":["Type","TypeBoxError","BaseType","NumberType","constructor","options","isNullable","isOptional","hasDefault","_constructSchema","Number","nullable","_with","optional","nullish","default","value","description","examples","positive","min","negative","max","exclusive","maximum","exclusiveMaximum","minimum","exclusiveMinimum","IntegerType","Integer","BigIntType","Transform","String","pattern","Decode","v","BigInt","error","Encode","encode","toString","map"],"mappings":"AAAA,SAQEA,IAAI,EACJC,YAAY,QACP,oBAAmB;AAC1B,SAASC,QAAQ,QAAQ,YAAW;AAEpC,OAAO,MAAMC,mBAIHD;;IACRE,YACE,AAAmBC,UAAyB,CAAC,CAAC,EAC9CC,aAAgB,KAAU,EAC1BC,aAAgB,KAAU,EAC1BC,aAAgB,KAAU,CAC1B;QACA,KAAK,CAACH,SAASC,YAAYC,YAAYC;aALpBH,UAAAA;IAMrB;IAEUI,iBAAiBJ,OAAsB,EAAW;QAC1D,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IACjE;IAEAC,SAAS,GAAGA,QAA+B,EAAE;QAC3C,OAAO,IAAIY,cACN,IAAI,CAAClB,KAAK,CAAC;YAAEP,SAAS;gBAAEa,UAAUA,SAASuB,GAAG,CAAC,IAAI,CAACF,MAAM;YAAE;QAAE;IAErE;IAEApB,WAAW;QACT,OAAO,IAAI,CAACC,GAAG,CAAC,EAAE,EAAE;IACtB;IAEAC,WAAW;QACT,OAAO,IAAI,CAACC,GAAG,CAAC,EAAE,EAAE;IACtB;IAEAA,IAAIN,KAAa,EAAEO,SAAgB,EAAE;QACnC,OAAO,IAAIO,cACN,IAAI,CAAClB,KAAK,CAAC;YACZP,SAAS;gBACPmB,SAAS,IAAI,CAACe,MAAM,CAACvB;gBACrB,GAAIO,YAAY,CAAC,IAAI;oBAAEE,kBAAkB,IAAI,CAACc,MAAM,CAACvB;gBAAO,CAAC;YAC/D;QACF;IAEJ;IAEAI,IAAIJ,KAAa,EAAEO,SAAgB,EAAE;QACnC,OAAO,IAAIO,cACN,IAAI,CAAClB,KAAK,CAAC;YACZP,SAAS;gBACPqB,SAAS,CAAC,EAAEV,MAAM,CAAC;gBACnB,GAAIO,YAAY,CAAC,IAAI;oBAAEI,kBAAkB,CAAC,EAAEX,MAAM,CAAC;gBAAC,CAAC;YACvD;QACF;IAEJ;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/types/number.ts"],"sourcesContent":["import {\n type IntegerOptions,\n type NumberOptions,\n type StringOptions,\n type TInteger,\n type TNumber,\n type TString,\n type TTransform,\n Type,\n TypeBoxError,\n} from '@sinclair/typebox'\nimport { BaseType } from './base.ts'\n\nexport class NumberType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TNumber, N, O, D, NumberOptions> {\n constructor(\n protected readonly options: NumberOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: NumberOptions): TNumber {\n return Type.Number(options)\n }\n\n nullable() {\n return new NumberType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new NumberType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new NumberType(...this._with({ isNullable: true, isOptional: true }))\n }\n\n default(value: number) {\n return new NumberType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new NumberType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [number, ...number[]]) {\n return new NumberType(...this._with({ options: { examples } }))\n }\n\n positive() {\n return this.min(0, true)\n }\n\n negative() {\n return this.max(0, true)\n }\n\n max(value: number, exclusive?: true) {\n return new NumberType(\n ...this._with({\n options: {\n maximum: value,\n ...(!exclusive ? {} : { exclusiveMaximum: value }),\n },\n }),\n )\n }\n\n min(value: number, exclusive?: true) {\n return new NumberType(\n ...this._with({\n options: {\n minimum: value,\n ...(!exclusive ? {} : { exclusiveMinimum: value }),\n },\n }),\n )\n }\n}\n\nexport class IntegerType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TInteger, N, O, D, IntegerOptions> {\n constructor(\n options: IntegerOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: IntegerOptions): TInteger {\n return Type.Integer(options)\n }\n\n nullable() {\n return new IntegerType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new IntegerType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new IntegerType(\n ...this._with({ isNullable: true, isOptional: true }),\n )\n }\n\n default(value: number) {\n return new IntegerType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new IntegerType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [number, ...number[]]) {\n return new IntegerType(...this._with({ options: { examples } }))\n }\n\n positive() {\n return this.min(0, true)\n }\n\n negative() {\n return this.max(0, true)\n }\n\n max(value: number, exclusive?: true) {\n return new IntegerType(\n ...this._with({\n options: {\n maximum: value,\n ...(!exclusive ? {} : { exclusiveMaximum: value }),\n },\n }),\n )\n }\n\n min(value: number, exclusive?: true) {\n return new IntegerType(\n ...this._with({\n options: {\n minimum: value,\n ...(!exclusive ? {} : { exclusiveMinimum: value }),\n },\n }),\n )\n }\n}\n\nexport class BigIntType<\n N extends boolean = false,\n O extends boolean = false,\n D extends boolean = false,\n> extends BaseType<TTransform<TString, bigint>, N, O, D, StringOptions> {\n constructor(\n options: StringOptions = {},\n isNullable: N = false as N,\n isOptional: O = false as O,\n hasDefault: D = false as D,\n ) {\n super(options, isNullable, isOptional, hasDefault)\n }\n\n protected _constructSchema(options: StringOptions) {\n return Type.Transform(Type.String({ ...options, pattern: '^\\\\d$' }))\n .Decode((v: string) => {\n try {\n return BigInt(v)\n } catch (error) {\n throw new TypeBoxError('Invalid bigint value')\n }\n })\n .Encode(this.encode)\n }\n\n protected encode = (value: bigint): string => {\n return value.toString()\n }\n\n nullable() {\n return new BigIntType(...this._with({ isNullable: true }))\n }\n\n optional() {\n return new BigIntType(...this._with({ isOptional: true }))\n }\n\n nullish() {\n return new BigIntType(...this._with({ isNullable: true, isOptional: true }))\n }\n\n default(value: bigint) {\n return new BigIntType(\n ...this._with({ options: { default: value }, hasDefault: true }),\n )\n }\n\n description(description: string) {\n return new BigIntType(...this._with({ options: { description } }))\n }\n\n examples(...examples: [bigint, ...bigint[]]) {\n return new BigIntType(\n ...this._with({ options: { examples: examples.map(this.encode) } }),\n )\n }\n\n positive() {\n return this.min(0n, true)\n }\n\n negative() {\n return this.max(0n, true)\n }\n\n max(value: bigint, exclusive?: true) {\n return new BigIntType(\n ...this._with({\n options: {\n maximum: this.encode(value),\n ...(!exclusive ? {} : { exclusiveMaximum: this.encode(value) }),\n },\n }),\n )\n }\n\n min(value: bigint, exclusive?: true) {\n return new BigIntType(\n ...this._with({\n options: {\n minimum: `${value}`,\n ...(!exclusive ? {} : { exclusiveMinimum: `${value}` }),\n },\n }),\n )\n }\n}\n"],"names":["Type","TypeBoxError","BaseType","NumberType","constructor","options","isNullable","isOptional","hasDefault","_constructSchema","Number","nullable","_with","optional","nullish","default","value","description","examples","positive","min","negative","max","exclusive","maximum","exclusiveMaximum","minimum","exclusiveMinimum","IntegerType","Integer","BigIntType","Transform","String","pattern","Decode","v","BigInt","error","Encode","encode","toString","map"],"mappings":"AAAA,SAQEA,IAAI,EACJC,YAAY,QACP,oBAAmB;AAC1B,SAASC,QAAQ,QAAQ,YAAW;AAEpC,OAAO,MAAMC,mBAIHD;;IACRE,YACE,AAAmBC,UAAyB,CAAC,CAAC,EAC9CC,aAAgB,KAAU,EAC1BC,aAAgB,KAAU,EAC1BC,aAAgB,KAAU,CAC1B;QACA,KAAK,CAACH,SAASC,YAAYC,YAAYC;aALpBH,UAAAA;IAMrB;IAEUI,iBAAiBJ,OAAsB,EAAW;QAC1D,OAAOL,KAAKU,MAAM,CAACL;IACrB;IAEAM,WAAW;QACT,OAAO,IAAIR,cAAc,IAAI,CAACS,KAAK,CAAC;YAAEN,YAAY;QAAK;IACzD;IAEAO,WAAW;QACT,OAAO,IAAIV,cAAc,IAAI,CAACS,KAAK,CAAC;YAAEL,YAAY;QAAK;IACzD;IAEAO,UAAU;QACR,OAAO,IAAIX,cAAc,IAAI,CAACS,KAAK,CAAC;YAAEN,YAAY;YAAMC,YAAY;QAAK;IAC3E;IAEAQ,QAAQC,KAAa,EAAE;QACrB,OAAO,IAAIb,cACN,IAAI,CAACS,KAAK,CAAC;YAAEP,SAAS;gBAAEU,SAASC;YAAM;YAAGR,YAAY;QAAK;IAElE;IAEAS,YAAYA,WAAmB,EAAE;QAC/B,OAAO,IAAId,cAAc,IAAI,CAACS,KAAK,CAAC;YAAEP,SAAS;gBAAEY;YAAY;QAAE;IACjE;IAEAC,SAAS,GAAGA,QAA+B,EAAE;QAC3C,OAAO,IAAIf,cAAc,IAAI,CAACS,KAAK,CAAC;YAAEP,SAAS;gBAAEa;YAAS;QAAE;IAC9D;I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ACPqB,SAAS,CAAC,EAAEV,MAAM,CAAC;gBACnB,GAAI,CAACO,YAAY,CAAC,IAAI;oBAAEI,kBAAkB,CAAC,EAAEX,MAAM,CAAC;gBAAC,CAAC;YACxD;QACF;IAEJ;AACF"}
|
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.4.
|
|
24
|
+
"@nmtjs/common": "0.4.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@sinclair/typebox": "^0.33.7",
|
|
28
28
|
"temporal-polyfill": "^0.2.5",
|
|
29
|
-
"@nmtjs/common": "0.4.
|
|
29
|
+
"@nmtjs/common": "0.4.6"
|
|
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.4.
|
|
38
|
+
"version": "0.4.6",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "neemata-build -p neutral --root=./src './**/*.ts'",
|
|
41
41
|
"type-check": "tsc --noEmit"
|
package/src/types/number.ts
CHANGED
|
@@ -68,7 +68,7 @@ export class NumberType<
|
|
|
68
68
|
...this._with({
|
|
69
69
|
options: {
|
|
70
70
|
maximum: value,
|
|
71
|
-
...(exclusive ? {} : { exclusiveMaximum: value }),
|
|
71
|
+
...(!exclusive ? {} : { exclusiveMaximum: value }),
|
|
72
72
|
},
|
|
73
73
|
}),
|
|
74
74
|
)
|
|
@@ -79,7 +79,7 @@ export class NumberType<
|
|
|
79
79
|
...this._with({
|
|
80
80
|
options: {
|
|
81
81
|
minimum: value,
|
|
82
|
-
...(exclusive ? {} : { exclusiveMinimum: value }),
|
|
82
|
+
...(!exclusive ? {} : { exclusiveMinimum: value }),
|
|
83
83
|
},
|
|
84
84
|
}),
|
|
85
85
|
)
|
|
@@ -145,7 +145,7 @@ export class IntegerType<
|
|
|
145
145
|
...this._with({
|
|
146
146
|
options: {
|
|
147
147
|
maximum: value,
|
|
148
|
-
...(exclusive ? {} : { exclusiveMaximum: value }),
|
|
148
|
+
...(!exclusive ? {} : { exclusiveMaximum: value }),
|
|
149
149
|
},
|
|
150
150
|
}),
|
|
151
151
|
)
|
|
@@ -156,7 +156,7 @@ export class IntegerType<
|
|
|
156
156
|
...this._with({
|
|
157
157
|
options: {
|
|
158
158
|
minimum: value,
|
|
159
|
-
...(exclusive ? {} : { exclusiveMinimum: value }),
|
|
159
|
+
...(!exclusive ? {} : { exclusiveMinimum: value }),
|
|
160
160
|
},
|
|
161
161
|
}),
|
|
162
162
|
)
|
|
@@ -234,7 +234,7 @@ export class BigIntType<
|
|
|
234
234
|
...this._with({
|
|
235
235
|
options: {
|
|
236
236
|
maximum: this.encode(value),
|
|
237
|
-
...(exclusive ? {} : { exclusiveMaximum: this.encode(value) }),
|
|
237
|
+
...(!exclusive ? {} : { exclusiveMaximum: this.encode(value) }),
|
|
238
238
|
},
|
|
239
239
|
}),
|
|
240
240
|
)
|
|
@@ -245,7 +245,7 @@ export class BigIntType<
|
|
|
245
245
|
...this._with({
|
|
246
246
|
options: {
|
|
247
247
|
minimum: `${value}`,
|
|
248
|
-
...(exclusive ? {} : { exclusiveMinimum: `${value}` }),
|
|
248
|
+
...(!exclusive ? {} : { exclusiveMinimum: `${value}` }),
|
|
249
249
|
},
|
|
250
250
|
}),
|
|
251
251
|
)
|