@mionjs/run-types 0.8.6 → 0.8.8
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/cjs/index.d.ts +1 -0
- package/.dist/cjs/index.d.ts.map +1 -0
- package/.dist/cjs/src/constants.d.ts +1 -0
- package/.dist/cjs/src/constants.d.ts.map +1 -0
- package/.dist/cjs/src/constants.functions.d.ts +1 -0
- package/.dist/cjs/src/constants.functions.d.ts.map +1 -0
- package/.dist/cjs/src/constants.kind.d.ts +1 -0
- package/.dist/cjs/src/constants.kind.d.ts.map +1 -0
- package/.dist/cjs/src/createRunType.d.ts +1 -0
- package/.dist/cjs/src/createRunType.d.ts.map +1 -0
- package/.dist/cjs/src/createRunTypeFunctions.d.ts +1 -0
- package/.dist/cjs/src/createRunTypeFunctions.d.ts.map +1 -0
- package/.dist/cjs/src/formats.runtype.d.ts +1 -0
- package/.dist/cjs/src/formats.runtype.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
- package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts +1 -0
- package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
- package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts +1 -0
- package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts.map +1 -0
- package/.dist/cjs/src/lib/baseRunTypes.d.ts +1 -0
- package/.dist/cjs/src/lib/baseRunTypes.d.ts.map +1 -0
- package/.dist/cjs/src/lib/createJitFunction.d.ts +1 -0
- package/.dist/cjs/src/lib/createJitFunction.d.ts.map +1 -0
- package/.dist/cjs/src/lib/dkProxy.d.ts +1 -0
- package/.dist/cjs/src/lib/dkProxy.d.ts.map +1 -0
- package/.dist/cjs/src/lib/formats.d.ts +1 -0
- package/.dist/cjs/src/lib/formats.d.ts.map +1 -0
- package/.dist/cjs/src/lib/guards.d.ts +1 -0
- package/.dist/cjs/src/lib/guards.d.ts.map +1 -0
- package/.dist/cjs/src/lib/jitFnCompiler.d.ts +1 -0
- package/.dist/cjs/src/lib/jitFnCompiler.d.ts.map +1 -0
- package/.dist/cjs/src/lib/jitFnsRegistry.d.ts +1 -0
- package/.dist/cjs/src/lib/jitFnsRegistry.d.ts.map +1 -0
- package/.dist/cjs/src/lib/typeId.d.ts +1 -0
- package/.dist/cjs/src/lib/typeId.d.ts.map +1 -0
- package/.dist/cjs/src/lib/utils.d.ts +1 -0
- package/.dist/cjs/src/lib/utils.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/constants.mock.d.ts +1 -0
- package/.dist/cjs/src/mocking/constants.mock.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockRegistry.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockRegistry.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockType.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockType.d.ts.map +1 -0
- package/.dist/cjs/src/mocking/mockUtils.d.ts +1 -0
- package/.dist/cjs/src/mocking/mockUtils.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/any.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/any.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/bigInt.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/bigInt.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/boolean.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/boolean.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/date.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/date.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/enum.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/enum.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/enumMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/enumMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/literal.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/literal.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/never.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/never.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/null.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/null.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/number.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/number.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/object.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/object.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/regexp.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/regexp.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/string.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/string.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/symbol.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/symbol.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/undefined.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/undefined.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/unknown.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/unknown.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/atomic/void.d.ts +1 -0
- package/.dist/cjs/src/nodes/atomic/void.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/class.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/class.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/functionParams.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/functionParams.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/interface.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/interface.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/intersection.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/intersection.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/tuple.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/tuple.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/union.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/union.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts +1 -0
- package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/function/function.d.ts +1 -0
- package/.dist/cjs/src/nodes/function/function.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/array.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/array.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/callSignature.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/callSignature.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/genericMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/genericMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/indexProperty.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/indexProperty.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/method.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/method.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/methodSignature.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/methodSignature.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/param.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/param.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/property.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/property.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/restParams.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/restParams.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/member/tupleMember.d.ts +1 -0
- package/.dist/cjs/src/nodes/member/tupleMember.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/Iterable.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/Iterable.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/map.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/map.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/nonSerializable.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/nonSerializable.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/promise.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/promise.d.ts.map +1 -0
- package/.dist/cjs/src/nodes/native/set.d.ts +1 -0
- package/.dist/cjs/src/nodes/native/set.d.ts.map +1 -0
- package/.dist/cjs/src/run-types-pure-fns.d.ts +1 -0
- package/.dist/cjs/src/run-types-pure-fns.d.ts.map +1 -0
- package/.dist/cjs/src/types.d.ts +1 -0
- package/.dist/cjs/src/types.d.ts.map +1 -0
- package/.dist/esm/index.d.ts +1 -0
- package/.dist/esm/index.d.ts.map +1 -0
- package/.dist/esm/src/constants.d.ts +1 -0
- package/.dist/esm/src/constants.d.ts.map +1 -0
- package/.dist/esm/src/constants.functions.d.ts +1 -0
- package/.dist/esm/src/constants.functions.d.ts.map +1 -0
- package/.dist/esm/src/constants.kind.d.ts +1 -0
- package/.dist/esm/src/constants.kind.d.ts.map +1 -0
- package/.dist/esm/src/createRunType.d.ts +1 -0
- package/.dist/esm/src/createRunType.d.ts.map +1 -0
- package/.dist/esm/src/createRunTypeFunctions.d.ts +1 -0
- package/.dist/esm/src/createRunTypeFunctions.d.ts.map +1 -0
- package/.dist/esm/src/formats.runtype.d.ts +1 -0
- package/.dist/esm/src/formats.runtype.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
- package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts +1 -0
- package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
- package/.dist/esm/src/lib/baseRunTypeFormat.d.ts +1 -0
- package/.dist/esm/src/lib/baseRunTypeFormat.d.ts.map +1 -0
- package/.dist/esm/src/lib/baseRunTypes.d.ts +1 -0
- package/.dist/esm/src/lib/baseRunTypes.d.ts.map +1 -0
- package/.dist/esm/src/lib/createJitFunction.d.ts +1 -0
- package/.dist/esm/src/lib/createJitFunction.d.ts.map +1 -0
- package/.dist/esm/src/lib/dkProxy.d.ts +1 -0
- package/.dist/esm/src/lib/dkProxy.d.ts.map +1 -0
- package/.dist/esm/src/lib/formats.d.ts +1 -0
- package/.dist/esm/src/lib/formats.d.ts.map +1 -0
- package/.dist/esm/src/lib/guards.d.ts +1 -0
- package/.dist/esm/src/lib/guards.d.ts.map +1 -0
- package/.dist/esm/src/lib/jitFnCompiler.d.ts +1 -0
- package/.dist/esm/src/lib/jitFnCompiler.d.ts.map +1 -0
- package/.dist/esm/src/lib/jitFnsRegistry.d.ts +1 -0
- package/.dist/esm/src/lib/jitFnsRegistry.d.ts.map +1 -0
- package/.dist/esm/src/lib/typeId.d.ts +1 -0
- package/.dist/esm/src/lib/typeId.d.ts.map +1 -0
- package/.dist/esm/src/lib/utils.d.ts +1 -0
- package/.dist/esm/src/lib/utils.d.ts.map +1 -0
- package/.dist/esm/src/mocking/constants.mock.d.ts +1 -0
- package/.dist/esm/src/mocking/constants.mock.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockRegistry.d.ts +1 -0
- package/.dist/esm/src/mocking/mockRegistry.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockType.d.ts +1 -0
- package/.dist/esm/src/mocking/mockType.d.ts.map +1 -0
- package/.dist/esm/src/mocking/mockUtils.d.ts +1 -0
- package/.dist/esm/src/mocking/mockUtils.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/any.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/any.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/bigInt.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/bigInt.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/boolean.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/boolean.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/date.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/date.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/enum.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/enum.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/enumMember.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/enumMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/literal.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/literal.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/never.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/never.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/null.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/null.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/number.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/number.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/object.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/object.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/regexp.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/regexp.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/string.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/string.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/symbol.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/symbol.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/undefined.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/undefined.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/unknown.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/unknown.d.ts.map +1 -0
- package/.dist/esm/src/nodes/atomic/void.d.ts +1 -0
- package/.dist/esm/src/nodes/atomic/void.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/class.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/class.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/functionParams.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/functionParams.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/interface.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/interface.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/intersection.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/intersection.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/tuple.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/tuple.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/union.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/union.d.ts.map +1 -0
- package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts +1 -0
- package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
- package/.dist/esm/src/nodes/function/function.d.ts +1 -0
- package/.dist/esm/src/nodes/function/function.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/array.d.ts +1 -0
- package/.dist/esm/src/nodes/member/array.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/callSignature.d.ts +1 -0
- package/.dist/esm/src/nodes/member/callSignature.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/genericMember.d.ts +1 -0
- package/.dist/esm/src/nodes/member/genericMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/indexProperty.d.ts +1 -0
- package/.dist/esm/src/nodes/member/indexProperty.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/method.d.ts +1 -0
- package/.dist/esm/src/nodes/member/method.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/methodSignature.d.ts +1 -0
- package/.dist/esm/src/nodes/member/methodSignature.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/param.d.ts +1 -0
- package/.dist/esm/src/nodes/member/param.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/property.d.ts +1 -0
- package/.dist/esm/src/nodes/member/property.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/restParams.d.ts +1 -0
- package/.dist/esm/src/nodes/member/restParams.d.ts.map +1 -0
- package/.dist/esm/src/nodes/member/tupleMember.d.ts +1 -0
- package/.dist/esm/src/nodes/member/tupleMember.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/Iterable.d.ts +1 -0
- package/.dist/esm/src/nodes/native/Iterable.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/map.d.ts +1 -0
- package/.dist/esm/src/nodes/native/map.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/nonSerializable.d.ts +1 -0
- package/.dist/esm/src/nodes/native/nonSerializable.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/promise.d.ts +1 -0
- package/.dist/esm/src/nodes/native/promise.d.ts.map +1 -0
- package/.dist/esm/src/nodes/native/set.d.ts +1 -0
- package/.dist/esm/src/nodes/native/set.d.ts.map +1 -0
- package/.dist/esm/src/run-types-pure-fns.d.ts +1 -0
- package/.dist/esm/src/run-types-pure-fns.d.ts.map +1 -0
- package/.dist/esm/src/types.d.ts +1 -0
- package/.dist/esm/src/types.d.ts.map +1 -0
- package/index.ts +70 -0
- package/package.json +11 -4
- package/src/constants.functions.ts +196 -0
- package/src/constants.kind.ts +76 -0
- package/src/constants.ts +85 -0
- package/src/createRunType.ts +323 -0
- package/src/createRunTypeFunctions.ts +93 -0
- package/src/formats.runtype.ts +35 -0
- package/src/jitCompilers/binary/binarySPEC.md +138 -0
- package/src/jitCompilers/binary/binarySpec/binaryHelpers.ts +118 -0
- package/src/jitCompilers/binary/fromBinary.ts +492 -0
- package/src/jitCompilers/binary/toBinary.ts +435 -0
- package/src/jitCompilers/equalsHelpers.ts +62 -0
- package/src/jitCompilers/json/jsonSpec/jsonHelpers.ts +64 -0
- package/src/jitCompilers/json/stringifyJson.ts +475 -0
- package/src/jitCompilers/json/stringifySpec/stringifyHelpers.ts +59 -0
- package/src/jitCompilers/json/toJsCode.ts +182 -0
- package/src/jitCompilers/serialization-suite.ts +1637 -0
- package/src/jitCompilers/xyz-Template/fromXYZ.ts +211 -0
- package/src/jitCompilers/xyz-Template/toXYZ.ts +216 -0
- package/src/jitCompilers/xyz-Template/xyzReadme.md +6 -0
- package/src/jitCompilers/xyz-Template/xyzSpec/xyzHelpers.ts +66 -0
- package/src/lib/baseRunTypeFormat.ts +320 -0
- package/src/lib/baseRunTypes.ts +367 -0
- package/src/lib/createJitFunction.ts +87 -0
- package/src/lib/dkProxy.ts +47 -0
- package/src/lib/formats.ts +144 -0
- package/src/lib/guards.ts +290 -0
- package/src/lib/jitFnCompiler.ts +783 -0
- package/src/lib/jitFnsRegistry.ts +53 -0
- package/src/lib/typeId.ts +225 -0
- package/src/lib/utils.ts +402 -0
- package/src/mocking/constants.mock.ts +87 -0
- package/src/mocking/mockRegistry.ts +20 -0
- package/src/mocking/mockType.ts +354 -0
- package/src/mocking/mockUtils.ts +82 -0
- package/src/nodes/atomic/any.ts +22 -0
- package/src/nodes/atomic/bigInt.ts +26 -0
- package/src/nodes/atomic/boolean.ts +26 -0
- package/src/nodes/atomic/date.ts +26 -0
- package/src/nodes/atomic/enum.ts +23 -0
- package/src/nodes/atomic/enumMember.ts +29 -0
- package/src/nodes/atomic/literal.ts +125 -0
- package/src/nodes/atomic/never.ts +26 -0
- package/src/nodes/atomic/null.ts +26 -0
- package/src/nodes/atomic/number.ts +26 -0
- package/src/nodes/atomic/object.ts +20 -0
- package/src/nodes/atomic/regexp.ts +29 -0
- package/src/nodes/atomic/string.ts +20 -0
- package/src/nodes/atomic/symbol.ts +31 -0
- package/src/nodes/atomic/undefined.ts +23 -0
- package/src/nodes/atomic/unknown.ts +10 -0
- package/src/nodes/atomic/void.ts +26 -0
- package/src/nodes/collection/class.ts +36 -0
- package/src/nodes/collection/functionParams.ts +42 -0
- package/src/nodes/collection/interface.ts +300 -0
- package/src/nodes/collection/intersection.ts +30 -0
- package/src/nodes/collection/tuple.ts +80 -0
- package/src/nodes/collection/union.ts +205 -0
- package/src/nodes/collection/unionDiscriminator.ts +259 -0
- package/src/nodes/function/function.ts +166 -0
- package/src/nodes/member/array.ts +150 -0
- package/src/nodes/member/callSignature.ts +34 -0
- package/src/nodes/member/genericMember.ts +63 -0
- package/src/nodes/member/indexProperty.ts +125 -0
- package/src/nodes/member/method.ts +30 -0
- package/src/nodes/member/methodSignature.ts +31 -0
- package/src/nodes/member/param.ts +22 -0
- package/src/nodes/member/property.ts +75 -0
- package/src/nodes/member/restParams.ts +22 -0
- package/src/nodes/member/tupleMember.ts +93 -0
- package/src/nodes/native/Iterable.ts +153 -0
- package/src/nodes/native/map.ts +91 -0
- package/src/nodes/native/nonSerializable.ts +42 -0
- package/src/nodes/native/promise.ts +43 -0
- package/src/nodes/native/set.ts +56 -0
- package/src/run-types-pure-fns.ts +116 -0
- package/src/types.ts +206 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
|
|
8
|
+
import type {TypeClass, TypeObjectLiteral} from '@deepkit/type';
|
|
9
|
+
import {JitCode} from '../../types.ts';
|
|
10
|
+
import {InterfaceRunType} from '../collection/interface.ts';
|
|
11
|
+
|
|
12
|
+
// Non serializable types might not be Atomic but will be skipped so it doesn't matter
|
|
13
|
+
export class NonSerializableRunType extends InterfaceRunType<TypeObjectLiteral | TypeClass> {
|
|
14
|
+
skipJit() {
|
|
15
|
+
// skip return false so we ensure the compile functions will throw when a NonSerializable type is used
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
emitIsType(): JitCode {
|
|
19
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
20
|
+
}
|
|
21
|
+
emitTypeErrors(): JitCode {
|
|
22
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
23
|
+
}
|
|
24
|
+
emitPrepareForJson(): JitCode {
|
|
25
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
26
|
+
}
|
|
27
|
+
emitRestoreFromJson(): JitCode {
|
|
28
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
29
|
+
}
|
|
30
|
+
emitHasUnknownKeys(): JitCode {
|
|
31
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
32
|
+
}
|
|
33
|
+
emitUnknownKeyErrors(): JitCode {
|
|
34
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
35
|
+
}
|
|
36
|
+
emitStripUnknownKeys(): JitCode {
|
|
37
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
38
|
+
}
|
|
39
|
+
emitUnknownKeysToUndefined(): JitCode {
|
|
40
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import {type TypePromise} from '@deepkit/type';
|
|
8
|
+
import type {JitCode} from '../../types.ts';
|
|
9
|
+
import {MemberRunType} from '../../lib/baseRunTypes.ts';
|
|
10
|
+
import {JitFunctions} from '../../constants.functions.ts';
|
|
11
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
12
|
+
|
|
13
|
+
export class PromiseRunType extends MemberRunType<TypePromise> {
|
|
14
|
+
skipJit(comp: JitFnCompiler): boolean {
|
|
15
|
+
return comp?.fnID !== JitFunctions.toJSCode.id;
|
|
16
|
+
}
|
|
17
|
+
emitIsType(): JitCode {
|
|
18
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
19
|
+
}
|
|
20
|
+
emitTypeErrors(): JitCode {
|
|
21
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
22
|
+
}
|
|
23
|
+
emitPrepareForJson(): JitCode {
|
|
24
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
25
|
+
}
|
|
26
|
+
emitRestoreFromJson(): JitCode {
|
|
27
|
+
throw new Error(`Jit compilation disabled for Non Serializable types.`);
|
|
28
|
+
}
|
|
29
|
+
isOptional(): boolean {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
getChildVarName(comp: JitFnCompiler): string | number {
|
|
34
|
+
return comp.getLocalVarName('p', this);
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
+
getChildLiteral(comp: JitFnCompiler): string | number {
|
|
38
|
+
return this.getChildVarName(comp);
|
|
39
|
+
}
|
|
40
|
+
useArrayAccessor(): boolean {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import type {SrcType} from '../../types.ts';
|
|
8
|
+
import {ReflectionSubKind} from '../../constants.kind.ts';
|
|
9
|
+
import {ReflectionKind, type TypeClass} from '@deepkit/type';
|
|
10
|
+
import {GenericMemberRunType} from '../member/genericMember.ts';
|
|
11
|
+
import {IterableRunType} from './Iterable.ts';
|
|
12
|
+
import {JitFunctions} from '../../constants.functions.ts';
|
|
13
|
+
import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
|
|
14
|
+
import {cpf_safeIterableKey} from '../../run-types-pure-fns.ts';
|
|
15
|
+
export class SetRunType extends IterableRunType {
|
|
16
|
+
keyRT = new SetKeyRunType();
|
|
17
|
+
children = [this.keyRT];
|
|
18
|
+
constructorName = 'Set';
|
|
19
|
+
onCreated(src: SrcType<TypeClass>): void {
|
|
20
|
+
const types = src.arguments;
|
|
21
|
+
if (!types || types.length !== 1) throw new Error(`Set expects 1 type argument: ie: Set<number>`);
|
|
22
|
+
super.onCreated(src);
|
|
23
|
+
this.keyRT.onCreated({
|
|
24
|
+
kind: ReflectionKind.parameter,
|
|
25
|
+
parent: src,
|
|
26
|
+
type: types[0],
|
|
27
|
+
subKind: ReflectionSubKind.setItem,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getCustomVλl(comp: JitFnCompiler) {
|
|
31
|
+
// restoreFromJson is decoding a regular array so no need to use an special case for vλl as other operations
|
|
32
|
+
if (comp.fnID === JitFunctions.restoreFromJson.id)
|
|
33
|
+
return {vλl: comp.getLocalVarName('it', this), isStandalone: false, useArrayAccessor: true};
|
|
34
|
+
// other operations use an special case for vλl where all parents are skipped
|
|
35
|
+
return {vλl: comp.getLocalVarName('it', this), isStandalone: true};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class SetKeyRunType extends GenericMemberRunType<any> {
|
|
40
|
+
index = 0;
|
|
41
|
+
skipSettingAccessor() {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
getStaticPathLiteral(comp: JitFnCompiler): string {
|
|
45
|
+
const parent = this.getParent()! as SetRunType;
|
|
46
|
+
const custom = parent.getCustomVλl(comp)!;
|
|
47
|
+
const safeKeyFn = comp.addPureFunction(cpf_safeIterableKey);
|
|
48
|
+
return `{key:${safeKeyFn}(${custom.vλl}),index:${parent.getIndexVarName(comp)}}`;
|
|
49
|
+
}
|
|
50
|
+
getCustomVλl(comp: JitFnCompiler) {
|
|
51
|
+
if (comp.fnID === JitFunctions.fromBinary.id)
|
|
52
|
+
return {vλl: comp.getLocalVarName('sK', this), isStandalone: true, useArrayAccessor: false};
|
|
53
|
+
// other operations use an special case for vλl where all parents are skipped
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2025 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
import type {TypeFormatError, StrNumber, RunTypeError} from '@mionjs/core';
|
|
8
|
+
import {registerPureFnFactory} from '@mionjs/core';
|
|
9
|
+
|
|
10
|
+
export const cpf_asJSONString = registerPureFnFactory('mion', 'asJSONString', function () {
|
|
11
|
+
// @ts-expect-error 2867
|
|
12
|
+
if (typeof Bun !== 'undefined') return JSON.stringify; // bun has a faster JSON.stringify
|
|
13
|
+
// eslint-disable-next-line no-control-regex
|
|
14
|
+
const STR_ESCAPE = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
|
|
15
|
+
const MAX_SCAPE_TEST_LENGTH = 1000;
|
|
16
|
+
return function _asJSONStringRegexOnly(str) {
|
|
17
|
+
// Always use regex test for strings >= 42 chars (n o for loop)
|
|
18
|
+
if (str.length < MAX_SCAPE_TEST_LENGTH && STR_ESCAPE.test(str) === false) {
|
|
19
|
+
return '"' + str + '"';
|
|
20
|
+
} else {
|
|
21
|
+
return JSON.stringify(str);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const cpf_getUnknownKeysFromArray = registerPureFnFactory('mion', 'getUnknownKeysFromArray', function () {
|
|
27
|
+
const MAX_UNKNOWN_KEYS = 10;
|
|
28
|
+
return function _getUnknownKeysFromArray(obj: Record<StrNumber, any>, keys: StrNumber[]): StrNumber[] {
|
|
29
|
+
const unknownKeys: StrNumber[] = [];
|
|
30
|
+
for (const prop in obj) {
|
|
31
|
+
let found = false;
|
|
32
|
+
for (let j = 0; j < keys.length; j++) {
|
|
33
|
+
if (keys[j] === prop) {
|
|
34
|
+
found = true;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!found) {
|
|
39
|
+
unknownKeys.push(prop as string);
|
|
40
|
+
if (unknownKeys.length >= MAX_UNKNOWN_KEYS) throw new Error('Too many unknown keys');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return unknownKeys;
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const cpf_hasUnknownKeysFromArray = registerPureFnFactory('mion', 'hasUnknownKeysFromArray', function () {
|
|
48
|
+
return function _hasUnknownKeysFromArray(obj: Record<StrNumber, any>, keys: StrNumber[]): boolean {
|
|
49
|
+
for (const prop in obj) {
|
|
50
|
+
// iterates over the object keys and if not found prop adds to unknownKeys
|
|
51
|
+
let found = false;
|
|
52
|
+
for (let j = 0; j < keys.length; j++) {
|
|
53
|
+
if (keys[j] === prop) {
|
|
54
|
+
found = true;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!found) return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const cpf_newRunTypeErr = registerPureFnFactory('mion', 'newRunTypeErr', function () {
|
|
65
|
+
return function _err(
|
|
66
|
+
pλth: readonly StrNumber[],
|
|
67
|
+
εrr: RunTypeError[],
|
|
68
|
+
expected: string,
|
|
69
|
+
accessPath?: readonly StrNumber[]
|
|
70
|
+
): void {
|
|
71
|
+
const path = accessPath?.length ? [...pλth, ...accessPath] : [...pλth];
|
|
72
|
+
const runTypeErr: RunTypeError = {expected, path};
|
|
73
|
+
εrr.push(runTypeErr);
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const cpf_formatErr = registerPureFnFactory('mion', 'formatErr', function () {
|
|
78
|
+
return function _formatErr(
|
|
79
|
+
pλth: StrNumber[],
|
|
80
|
+
εrr: RunTypeError[],
|
|
81
|
+
expected: string,
|
|
82
|
+
fmtName: string,
|
|
83
|
+
paramName: string,
|
|
84
|
+
paramVal: string | number | boolean | bigint,
|
|
85
|
+
fmtPath: StrNumber[],
|
|
86
|
+
accessPath?: StrNumber[],
|
|
87
|
+
fmtAccessPath?: StrNumber[]
|
|
88
|
+
): void {
|
|
89
|
+
const path = accessPath?.length ? [...pλth, ...accessPath] : [...pλth];
|
|
90
|
+
const formatPath = fmtAccessPath?.length ? [...fmtPath, ...fmtAccessPath, paramName] : [...fmtPath, paramName];
|
|
91
|
+
const format: TypeFormatError = {name: fmtName, formatPath: formatPath, val: paramVal};
|
|
92
|
+
const runTypeErr: Required<RunTypeError> = {expected, path, format};
|
|
93
|
+
εrr.push(runTypeErr);
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const cpf_safeIterableKey = registerPureFnFactory('mion', 'safeIterableKey', function () {
|
|
98
|
+
return function _safeKey(value: any): any {
|
|
99
|
+
if (value === undefined) return null;
|
|
100
|
+
if (value === null) return null;
|
|
101
|
+
const type = typeof value;
|
|
102
|
+
if (type === 'number' || type === 'string' || type === 'boolean') return value;
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** @reflection never */
|
|
108
|
+
export const cpf_sanitizeCompiledFn = registerPureFnFactory('mion', 'sanitizeCompiledFn', function () {
|
|
109
|
+
const anonymousRegex = /^\s*function\s+anonymous\s*\(/;
|
|
110
|
+
return function sanitizeCompiled(fnCode: string): string {
|
|
111
|
+
if (anonymousRegex.test(fnCode)) {
|
|
112
|
+
return fnCode.replace(anonymousRegex, 'function (');
|
|
113
|
+
}
|
|
114
|
+
return fnCode;
|
|
115
|
+
};
|
|
116
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/* ########
|
|
2
|
+
* 2024 mion
|
|
3
|
+
* Author: Ma-jerez
|
|
4
|
+
* License: MIT
|
|
5
|
+
* The software is provided "as is", without warranty of any kind.
|
|
6
|
+
* ######## */
|
|
7
|
+
// ###### !IMPORTANT: all imports should be types only to prevent circular dependencies ######
|
|
8
|
+
import type {Type, TypeCallSignature, TypeFunction, TypeMethod, TypeMethodSignature, TypeTuple} from '@deepkit/type';
|
|
9
|
+
import type {TypeFormatParams} from '@mionjs/core';
|
|
10
|
+
import type {JitFunctions} from './constants.functions.ts';
|
|
11
|
+
import type {ReflectionSubKind} from './constants.kind.ts';
|
|
12
|
+
import type {BaseRunTypeFormat} from './lib/baseRunTypeFormat.ts';
|
|
13
|
+
import type {JitFnCompiler} from './lib/jitFnCompiler.ts';
|
|
14
|
+
import type {CodeType} from './constants.functions.ts';
|
|
15
|
+
|
|
16
|
+
export type StrNumber = string | number;
|
|
17
|
+
|
|
18
|
+
/** Result of a jit compilation, contains the code and metadata about the code */
|
|
19
|
+
export type JitCode = {
|
|
20
|
+
code: string | undefined;
|
|
21
|
+
type: CodeType;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// ############################################ RunTypes ############################################
|
|
25
|
+
|
|
26
|
+
export type SrcType<T extends Type = Type> = T & {
|
|
27
|
+
readonly _rt: RunType;
|
|
28
|
+
readonly _typeId?: StrNumber; // Cached type ID to avoid recalculation (preserves number for atomic types)
|
|
29
|
+
readonly _formatId?: string; // Cached format ID (empty string means no format, undefined means not computed yet)
|
|
30
|
+
readonly subKind?: SubKind;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RunTypeFamily = 'A' | 'C' | 'M' | 'F'; // Atomic, Collection, Member, Function
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Runtime Metadata for a typescript types.
|
|
37
|
+
*/
|
|
38
|
+
export interface RunType {
|
|
39
|
+
readonly src: SrcType<any>;
|
|
40
|
+
getKindName(): string;
|
|
41
|
+
getFamily(): RunTypeFamily; // Atomic, Collection, Member, Function
|
|
42
|
+
mock: (options?: DeepPartial<RunTypeOptions>) => Promise<any>;
|
|
43
|
+
|
|
44
|
+
// ######## JIT functions ########
|
|
45
|
+
/** Returns a unique id for the type. it can be a long string similar to the typescript type itself but as shorter as possible */
|
|
46
|
+
getTypeID(): StrNumber;
|
|
47
|
+
getJitHash(opts: RunTypeOptions): string;
|
|
48
|
+
createJitFunction(jitFn: JitFn, opts?: RunTypeOptions): (...args: any[]) => any;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SubKind = (typeof ReflectionSubKind)[keyof typeof ReflectionSubKind];
|
|
52
|
+
export type RunTypeVisitor = (deepkitType: Type, parents: RunType[], opts: RunTypeOptions) => RunType;
|
|
53
|
+
export type SrcCollection = Type & {types: Type[]};
|
|
54
|
+
export type SrcMember = Type & {type: Type};
|
|
55
|
+
|
|
56
|
+
export interface JitCompilerOpts {
|
|
57
|
+
readonly fnID: string;
|
|
58
|
+
readonly typeID: StrNumber;
|
|
59
|
+
readonly jitFnHash: string;
|
|
60
|
+
readonly opts: RunTypeOptions;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface RunTypeChildAccessor extends RunType {
|
|
64
|
+
/**
|
|
65
|
+
* Returns the position of the child within the parent type.
|
|
66
|
+
*/
|
|
67
|
+
getChildIndex(comp: JitFnCompiler): number;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the variable name for the compiled child
|
|
70
|
+
* ie: for an object property, it should return the property name
|
|
71
|
+
* ie: for an array member, it should return the index variable name
|
|
72
|
+
*/
|
|
73
|
+
getChildVarName(comp: JitFnCompiler): StrNumber;
|
|
74
|
+
/** Returns the static member name or literal as it should be inserted in source code.
|
|
75
|
+
* ie: for an object property, it should return the property name as a string encapsulated in quotes, ie: prop => 'prop'
|
|
76
|
+
* ie: for an array member, it should return the varName as is a dynamic value, ie: index => index
|
|
77
|
+
*/
|
|
78
|
+
getChildLiteral(comp: JitFnCompiler): StrNumber;
|
|
79
|
+
/** Returns true if the property name is safe to use as a property accessor in source code
|
|
80
|
+
* ie: return false if a property can be accessed using the dot notation, ie: obj.prop, for properties that are numbers return false
|
|
81
|
+
* ie: for an array member return true as it should be accessed using the array accessor, ie: obj[index]
|
|
82
|
+
*/
|
|
83
|
+
useArrayAccessor(): boolean;
|
|
84
|
+
/** Returns true if the property is optional */
|
|
85
|
+
isOptional(): boolean;
|
|
86
|
+
/** Some runType nodes might have some logic or being par of the AST, but we might not want to modify current stack variable vλl.
|
|
87
|
+
* Ie: (Rest params) is alway a child of a tupleMember, in this case we want vλl to point to the rest param and not the tuple member.
|
|
88
|
+
* so we want to skip setting the accessor in the parent. */
|
|
89
|
+
skipSettingAccessor?(): boolean;
|
|
90
|
+
/** used to compile json stringify, items with the flag set will omit outputting comma after the item */
|
|
91
|
+
skipCommas?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface CustomVλl {
|
|
94
|
+
vλl: string;
|
|
95
|
+
isStandalone?: boolean;
|
|
96
|
+
useArrayAccessor?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface RunTypeOptions {
|
|
100
|
+
/** Slice parameters when parsing functions, so some parameter can be omitted from jit generation */
|
|
101
|
+
paramsSlice?: {start?: number; end?: number};
|
|
102
|
+
mock?: MockOptions;
|
|
103
|
+
/**
|
|
104
|
+
* When compiling literals will use the Literal's type instead of the literal value.
|
|
105
|
+
* ie `type A = 'a'` will be compiled as it was `type A = string` so will accept any string value not only 'a'
|
|
106
|
+
*/
|
|
107
|
+
noLiterals?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Skip checking array and just check for items type
|
|
110
|
+
* this speeds up isType and typeErrors functions but will not validate array length.
|
|
111
|
+
*/
|
|
112
|
+
noIsArrayCheck?: boolean;
|
|
113
|
+
/** When true, isType and typeErrors will also reject objects with unknown/extra properties */
|
|
114
|
+
strictTypes?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type PartialRunTypeOptions = DeepPartial<RunTypeOptions>;
|
|
118
|
+
|
|
119
|
+
// ############################################ JIT FUNCTIONS ############################################
|
|
120
|
+
|
|
121
|
+
export type JitFn = (typeof JitFunctions)[keyof typeof JitFunctions];
|
|
122
|
+
|
|
123
|
+
// one of the existing jit functions ids
|
|
124
|
+
export type JitFnID = JitFn['id'];
|
|
125
|
+
|
|
126
|
+
export type AnyFunction = TypeMethodSignature | TypeCallSignature | TypeFunction | TypeMethod;
|
|
127
|
+
export type AnyParameterListRunType = AnyFunction | TypeTuple;
|
|
128
|
+
|
|
129
|
+
// ############################################ MOCKING ############################################
|
|
130
|
+
|
|
131
|
+
export interface MockOptions {
|
|
132
|
+
anyValuesList: any[];
|
|
133
|
+
minNumber?: number;
|
|
134
|
+
maxNumber?: number;
|
|
135
|
+
minDate?: number;
|
|
136
|
+
maxDate?: number;
|
|
137
|
+
enumIndex?: number;
|
|
138
|
+
objectList: object[];
|
|
139
|
+
promiseTimeOut: number;
|
|
140
|
+
promiseReject?: string | Error | any;
|
|
141
|
+
regexpList: RegExp[];
|
|
142
|
+
maxRandomStringLength: number;
|
|
143
|
+
stringLength?: number;
|
|
144
|
+
stringCharSet: string;
|
|
145
|
+
symbolLength?: number;
|
|
146
|
+
symbolCharSet?: string;
|
|
147
|
+
symbolName?: string;
|
|
148
|
+
maxRandomItemsLength: number;
|
|
149
|
+
arrayLength?: number;
|
|
150
|
+
/** probability to generate options types, number between 0 and 1,
|
|
151
|
+
* bigger values have bigger probability of generate the optional property */
|
|
152
|
+
optionalProbability: number;
|
|
153
|
+
/** probability to generate an specific property of an object, number between 0 and 1 */
|
|
154
|
+
optionalPropertyProbability?: Record<StrNumber, number>; // TODO change to a record of MockOptions
|
|
155
|
+
parentObj?: Record<StrNumber | symbol, any>;
|
|
156
|
+
/** the index of the object to mock withing the union */
|
|
157
|
+
unionIndex?: number;
|
|
158
|
+
tupleOptions?: MockOptions[];
|
|
159
|
+
paramsOptions?: MockOptions[];
|
|
160
|
+
maxStackDepth: number;
|
|
161
|
+
maxMockRecursion: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface MockOperation extends MockOptions {
|
|
165
|
+
/** Used for mocking object with circular references */
|
|
166
|
+
stack: RunType[];
|
|
167
|
+
fnID: JitFnID;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type DKAnnotation = {
|
|
171
|
+
name: string;
|
|
172
|
+
options: SrcType;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export type FormatAnnotation = DKAnnotation & {
|
|
176
|
+
params?: TypeFormatParams;
|
|
177
|
+
formatter: BaseRunTypeFormat;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type RunTypeAnnotation = {
|
|
181
|
+
name: string;
|
|
182
|
+
options: RunType;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// ############################################ OTHERS ############################################
|
|
186
|
+
|
|
187
|
+
/** Any Class */
|
|
188
|
+
export interface AnyClass<T = any> {
|
|
189
|
+
new (...args: any[]): T;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type Mutable<T> = {
|
|
193
|
+
-readonly [K in keyof T]: T[K];
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type DeepRequired<T> = T extends object
|
|
197
|
+
? {
|
|
198
|
+
[P in keyof T]?: DeepRequired<T[P]>;
|
|
199
|
+
}
|
|
200
|
+
: T;
|
|
201
|
+
|
|
202
|
+
export type DeepPartial<T> = T extends object
|
|
203
|
+
? {
|
|
204
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
205
|
+
}
|
|
206
|
+
: T;
|