telepact 1.0.0-alpha.120
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/README.md +71 -0
- package/dist/LICENSE +201 -0
- package/dist/NOTICE +15 -0
- package/dist/inc/auth.telepact.json +29 -0
- package/dist/inc/internal.telepact.json +258 -0
- package/dist/inc/json-schema.json +245 -0
- package/dist/inc/mock-internal.telepact.json +157 -0
- package/dist/index.cjs.js +5186 -0
- package/dist/index.esm.js +5167 -0
- package/dist/index.iife.js +5188 -0
- package/dist/src/Client.d.ts +20 -0
- package/dist/src/Client.js +59 -0
- package/dist/src/Client.js.map +1 -0
- package/dist/src/DefaultSerialization.d.ts +9 -0
- package/dist/src/DefaultSerialization.js +35 -0
- package/dist/src/DefaultSerialization.js.map +1 -0
- package/dist/src/Message.d.ts +7 -0
- package/dist/src/Message.js +32 -0
- package/dist/src/Message.js.map +1 -0
- package/dist/src/MockServer.d.ts +27 -0
- package/dist/src/MockServer.js +68 -0
- package/dist/src/MockServer.js.map +1 -0
- package/dist/src/MockTelepactSchema.d.ts +17 -0
- package/dist/src/MockTelepactSchema.js +45 -0
- package/dist/src/MockTelepactSchema.js.map +1 -0
- package/dist/src/RandomGenerator.d.ts +15 -0
- package/dist/src/RandomGenerator.js +107 -0
- package/dist/src/RandomGenerator.js.map +1 -0
- package/dist/src/Serialization.d.ts +13 -0
- package/dist/src/Serialization.js +17 -0
- package/dist/src/Serialization.js.map +1 -0
- package/dist/src/SerializationError.d.ts +3 -0
- package/dist/src/SerializationError.js +22 -0
- package/dist/src/SerializationError.js.map +1 -0
- package/dist/src/Serializer.d.ts +15 -0
- package/dist/src/Serializer.js +43 -0
- package/dist/src/Serializer.js.map +1 -0
- package/dist/src/Server.d.ts +22 -0
- package/dist/src/Server.js +61 -0
- package/dist/src/Server.js.map +1 -0
- package/dist/src/TelepactError.d.ts +4 -0
- package/dist/src/TelepactError.js +24 -0
- package/dist/src/TelepactError.js.map +1 -0
- package/dist/src/TelepactSchema.d.ts +21 -0
- package/dist/src/TelepactSchema.js +50 -0
- package/dist/src/TelepactSchema.js.map +1 -0
- package/dist/src/TelepactSchemaFiles.d.ts +5 -0
- package/dist/src/TelepactSchemaFiles.js +23 -0
- package/dist/src/TelepactSchemaFiles.js.map +1 -0
- package/dist/src/TelepactSchemaParseError.d.ts +9 -0
- package/dist/src/TelepactSchemaParseError.js +31 -0
- package/dist/src/TelepactSchemaParseError.js.map +1 -0
- package/dist/src/fileSystem.d.ts +18 -0
- package/dist/src/fileSystem.js +17 -0
- package/dist/src/fileSystem.js.map +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.js +35 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/ClientHandleMessage.d.ts +3 -0
- package/dist/src/internal/ClientHandleMessage.js +52 -0
- package/dist/src/internal/ClientHandleMessage.js.map +1 -0
- package/dist/src/internal/DeserializeInternal.d.ts +5 -0
- package/dist/src/internal/DeserializeInternal.js +65 -0
- package/dist/src/internal/DeserializeInternal.js.map +1 -0
- package/dist/src/internal/HandleMessage.d.ts +3 -0
- package/dist/src/internal/HandleMessage.js +168 -0
- package/dist/src/internal/HandleMessage.js.map +1 -0
- package/dist/src/internal/ObjectsAreEqual.d.ts +1 -0
- package/dist/src/internal/ObjectsAreEqual.js +40 -0
- package/dist/src/internal/ObjectsAreEqual.js.map +1 -0
- package/dist/src/internal/ParseRequestMessage.d.ts +4 -0
- package/dist/src/internal/ParseRequestMessage.js +46 -0
- package/dist/src/internal/ParseRequestMessage.js.map +1 -0
- package/dist/src/internal/ProcessBytes.d.ts +8 -0
- package/dist/src/internal/ProcessBytes.js +47 -0
- package/dist/src/internal/ProcessBytes.js.map +1 -0
- package/dist/src/internal/SelectStructFields.d.ts +4 -0
- package/dist/src/internal/SelectStructFields.js +87 -0
- package/dist/src/internal/SelectStructFields.js.map +1 -0
- package/dist/src/internal/SerializeInternal.d.ts +5 -0
- package/dist/src/internal/SerializeInternal.js +49 -0
- package/dist/src/internal/SerializeInternal.js.map +1 -0
- package/dist/src/internal/binary/Base64Encoder.d.ts +4 -0
- package/dist/src/internal/binary/Base64Encoder.js +18 -0
- package/dist/src/internal/binary/Base64Encoder.js.map +1 -0
- package/dist/src/internal/binary/Base64Util.d.ts +2 -0
- package/dist/src/internal/binary/Base64Util.js +36 -0
- package/dist/src/internal/binary/Base64Util.js.map +1 -0
- package/dist/src/internal/binary/BinaryEncoder.d.ts +4 -0
- package/dist/src/internal/binary/BinaryEncoder.js +18 -0
- package/dist/src/internal/binary/BinaryEncoder.js.map +1 -0
- package/dist/src/internal/binary/BinaryEncoderUnavailableError.d.ts +2 -0
- package/dist/src/internal/binary/BinaryEncoderUnavailableError.js +18 -0
- package/dist/src/internal/binary/BinaryEncoderUnavailableError.js.map +1 -0
- package/dist/src/internal/binary/BinaryEncoding.d.ts +6 -0
- package/dist/src/internal/binary/BinaryEncoding.js +30 -0
- package/dist/src/internal/binary/BinaryEncoding.js.map +1 -0
- package/dist/src/internal/binary/BinaryEncodingCache.d.ts +7 -0
- package/dist/src/internal/binary/BinaryEncodingCache.js +18 -0
- package/dist/src/internal/binary/BinaryEncodingCache.js.map +1 -0
- package/dist/src/internal/binary/BinaryEncodingMissing.d.ts +3 -0
- package/dist/src/internal/binary/BinaryEncodingMissing.js +21 -0
- package/dist/src/internal/binary/BinaryEncodingMissing.js.map +1 -0
- package/dist/src/internal/binary/BinaryPackNode.d.ts +5 -0
- package/dist/src/internal/binary/BinaryPackNode.js +24 -0
- package/dist/src/internal/binary/BinaryPackNode.js.map +1 -0
- package/dist/src/internal/binary/CannotPack.d.ts +3 -0
- package/dist/src/internal/binary/CannotPack.js +22 -0
- package/dist/src/internal/binary/CannotPack.js.map +1 -0
- package/dist/src/internal/binary/ClientBase64Decode.d.ts +1 -0
- package/dist/src/internal/binary/ClientBase64Decode.js +80 -0
- package/dist/src/internal/binary/ClientBase64Decode.js.map +1 -0
- package/dist/src/internal/binary/ClientBase64Encode.d.ts +1 -0
- package/dist/src/internal/binary/ClientBase64Encode.js +43 -0
- package/dist/src/internal/binary/ClientBase64Encode.js.map +1 -0
- package/dist/src/internal/binary/ClientBase64Encoder.d.ts +5 -0
- package/dist/src/internal/binary/ClientBase64Encoder.js +29 -0
- package/dist/src/internal/binary/ClientBase64Encoder.js.map +1 -0
- package/dist/src/internal/binary/ClientBinaryDecode.d.ts +3 -0
- package/dist/src/internal/binary/ClientBinaryDecode.js +42 -0
- package/dist/src/internal/binary/ClientBinaryDecode.js.map +1 -0
- package/dist/src/internal/binary/ClientBinaryEncode.d.ts +3 -0
- package/dist/src/internal/binary/ClientBinaryEncode.js +46 -0
- package/dist/src/internal/binary/ClientBinaryEncode.js.map +1 -0
- package/dist/src/internal/binary/ClientBinaryEncoder.d.ts +9 -0
- package/dist/src/internal/binary/ClientBinaryEncoder.js +33 -0
- package/dist/src/internal/binary/ClientBinaryEncoder.js.map +1 -0
- package/dist/src/internal/binary/ClientBinaryStrategy.d.ts +15 -0
- package/dist/src/internal/binary/ClientBinaryStrategy.js +84 -0
- package/dist/src/internal/binary/ClientBinaryStrategy.js.map +1 -0
- package/dist/src/internal/binary/ConstructBinaryEncoding.d.ts +3 -0
- package/dist/src/internal/binary/ConstructBinaryEncoding.js +85 -0
- package/dist/src/internal/binary/ConstructBinaryEncoding.js.map +1 -0
- package/dist/src/internal/binary/ConvertMapsToObjects.d.ts +1 -0
- package/dist/src/internal/binary/ConvertMapsToObjects.js +42 -0
- package/dist/src/internal/binary/ConvertMapsToObjects.js.map +1 -0
- package/dist/src/internal/binary/CreateChecksum.d.ts +1 -0
- package/dist/src/internal/binary/CreateChecksum.js +21 -0
- package/dist/src/internal/binary/CreateChecksum.js.map +1 -0
- package/dist/src/internal/binary/DecodeBody.d.ts +2 -0
- package/dist/src/internal/binary/DecodeBody.js +20 -0
- package/dist/src/internal/binary/DecodeBody.js.map +1 -0
- package/dist/src/internal/binary/DecodeKeys.d.ts +2 -0
- package/dist/src/internal/binary/DecodeKeys.js +37 -0
- package/dist/src/internal/binary/DecodeKeys.js.map +1 -0
- package/dist/src/internal/binary/DefaultBinaryEncodingCache.d.ts +10 -0
- package/dist/src/internal/binary/DefaultBinaryEncodingCache.js +38 -0
- package/dist/src/internal/binary/DefaultBinaryEncodingCache.js.map +1 -0
- package/dist/src/internal/binary/EncodeBody.d.ts +2 -0
- package/dist/src/internal/binary/EncodeBody.js +20 -0
- package/dist/src/internal/binary/EncodeBody.js.map +1 -0
- package/dist/src/internal/binary/EncodeKeys.d.ts +2 -0
- package/dist/src/internal/binary/EncodeKeys.js +36 -0
- package/dist/src/internal/binary/EncodeKeys.js.map +1 -0
- package/dist/src/internal/binary/LocalStorageBackedBinaryEncodingCache.d.ts +13 -0
- package/dist/src/internal/binary/LocalStorageBackedBinaryEncodingCache.js +65 -0
- package/dist/src/internal/binary/LocalStorageBackedBinaryEncodingCache.js.map +1 -0
- package/dist/src/internal/binary/Pack.d.ts +1 -0
- package/dist/src/internal/binary/Pack.js +32 -0
- package/dist/src/internal/binary/Pack.js.map +1 -0
- package/dist/src/internal/binary/PackBody.d.ts +1 -0
- package/dist/src/internal/binary/PackBody.js +25 -0
- package/dist/src/internal/binary/PackBody.js.map +1 -0
- package/dist/src/internal/binary/PackList.d.ts +4 -0
- package/dist/src/internal/binary/PackList.js +68 -0
- package/dist/src/internal/binary/PackList.js.map +1 -0
- package/dist/src/internal/binary/PackMap.d.ts +5 -0
- package/dist/src/internal/binary/PackMap.js +87 -0
- package/dist/src/internal/binary/PackMap.js.map +1 -0
- package/dist/src/internal/binary/ServerBase64Decode.d.ts +1 -0
- package/dist/src/internal/binary/ServerBase64Decode.js +76 -0
- package/dist/src/internal/binary/ServerBase64Decode.js.map +1 -0
- package/dist/src/internal/binary/ServerBase64Encode.d.ts +1 -0
- package/dist/src/internal/binary/ServerBase64Encode.js +76 -0
- package/dist/src/internal/binary/ServerBase64Encode.js.map +1 -0
- package/dist/src/internal/binary/ServerBase64Encoder.d.ts +5 -0
- package/dist/src/internal/binary/ServerBase64Encoder.js +28 -0
- package/dist/src/internal/binary/ServerBase64Encoder.js.map +1 -0
- package/dist/src/internal/binary/ServerBinaryDecode.d.ts +2 -0
- package/dist/src/internal/binary/ServerBinaryDecode.js +39 -0
- package/dist/src/internal/binary/ServerBinaryDecode.js.map +1 -0
- package/dist/src/internal/binary/ServerBinaryEncode.d.ts +2 -0
- package/dist/src/internal/binary/ServerBinaryEncode.js +42 -0
- package/dist/src/internal/binary/ServerBinaryEncode.js.map +1 -0
- package/dist/src/internal/binary/ServerBinaryEncoder.d.ts +8 -0
- package/dist/src/internal/binary/ServerBinaryEncoder.js +30 -0
- package/dist/src/internal/binary/ServerBinaryEncoder.js.map +1 -0
- package/dist/src/internal/binary/Unpack.d.ts +1 -0
- package/dist/src/internal/binary/Unpack.js +32 -0
- package/dist/src/internal/binary/Unpack.js.map +1 -0
- package/dist/src/internal/binary/UnpackBody.d.ts +1 -0
- package/dist/src/internal/binary/UnpackBody.js +25 -0
- package/dist/src/internal/binary/UnpackBody.js.map +1 -0
- package/dist/src/internal/binary/UnpackList.d.ts +1 -0
- package/dist/src/internal/binary/UnpackList.js +39 -0
- package/dist/src/internal/binary/UnpackList.js.map +1 -0
- package/dist/src/internal/binary/UnpackMap.d.ts +1 -0
- package/dist/src/internal/binary/UnpackMap.js +40 -0
- package/dist/src/internal/binary/UnpackMap.js.map +1 -0
- package/dist/src/internal/generation/GenerateContext.d.ts +16 -0
- package/dist/src/internal/generation/GenerateContext.js +33 -0
- package/dist/src/internal/generation/GenerateContext.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomAny.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomAny.js +28 -0
- package/dist/src/internal/generation/GenerateRandomAny.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomArray.d.ts +3 -0
- package/dist/src/internal/generation/GenerateRandomArray.js +37 -0
- package/dist/src/internal/generation/GenerateRandomArray.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomBoolean.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomBoolean.js +24 -0
- package/dist/src/internal/generation/GenerateRandomBoolean.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomBytes.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomBytes.js +24 -0
- package/dist/src/internal/generation/GenerateRandomBytes.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomInteger.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomInteger.js +24 -0
- package/dist/src/internal/generation/GenerateRandomInteger.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomMockCall.d.ts +5 -0
- package/dist/src/internal/generation/GenerateRandomMockCall.js +26 -0
- package/dist/src/internal/generation/GenerateRandomMockCall.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomMockStub.d.ts +5 -0
- package/dist/src/internal/generation/GenerateRandomMockStub.js +38 -0
- package/dist/src/internal/generation/GenerateRandomMockStub.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomNumber.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomNumber.js +24 -0
- package/dist/src/internal/generation/GenerateRandomNumber.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomObject.d.ts +3 -0
- package/dist/src/internal/generation/GenerateRandomObject.js +38 -0
- package/dist/src/internal/generation/GenerateRandomObject.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomSelect.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomSelect.js +49 -0
- package/dist/src/internal/generation/GenerateRandomSelect.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomString.d.ts +2 -0
- package/dist/src/internal/generation/GenerateRandomString.js +24 -0
- package/dist/src/internal/generation/GenerateRandomString.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomStruct.d.ts +5 -0
- package/dist/src/internal/generation/GenerateRandomStruct.js +60 -0
- package/dist/src/internal/generation/GenerateRandomStruct.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomUnion.d.ts +5 -0
- package/dist/src/internal/generation/GenerateRandomUnion.js +35 -0
- package/dist/src/internal/generation/GenerateRandomUnion.js.map +1 -0
- package/dist/src/internal/generation/GenerateRandomValueOfType.d.ts +4 -0
- package/dist/src/internal/generation/GenerateRandomValueOfType.js +24 -0
- package/dist/src/internal/generation/GenerateRandomValueOfType.js.map +1 -0
- package/dist/src/internal/mock/IsSubMap.d.ts +1 -0
- package/dist/src/internal/mock/IsSubMap.js +28 -0
- package/dist/src/internal/mock/IsSubMap.js.map +1 -0
- package/dist/src/internal/mock/IsSubMapEntryEqual.d.ts +1 -0
- package/dist/src/internal/mock/IsSubMapEntryEqual.js +37 -0
- package/dist/src/internal/mock/IsSubMapEntryEqual.js.map +1 -0
- package/dist/src/internal/mock/MockHandle.d.ts +6 -0
- package/dist/src/internal/mock/MockHandle.js +121 -0
- package/dist/src/internal/mock/MockHandle.js.map +1 -0
- package/dist/src/internal/mock/MockInvocation.d.ts +6 -0
- package/dist/src/internal/mock/MockInvocation.js +26 -0
- package/dist/src/internal/mock/MockInvocation.js.map +1 -0
- package/dist/src/internal/mock/MockStub.d.ts +8 -0
- package/dist/src/internal/mock/MockStub.js +30 -0
- package/dist/src/internal/mock/MockStub.js.map +1 -0
- package/dist/src/internal/mock/PartiallyMatches.d.ts +1 -0
- package/dist/src/internal/mock/PartiallyMatches.js +25 -0
- package/dist/src/internal/mock/PartiallyMatches.js.map +1 -0
- package/dist/src/internal/mock/Verify.d.ts +8 -0
- package/dist/src/internal/mock/Verify.js +94 -0
- package/dist/src/internal/mock/Verify.js.map +1 -0
- package/dist/src/internal/mock/VerifyNoMoreInteractions.d.ts +4 -0
- package/dist/src/internal/mock/VerifyNoMoreInteractions.js +30 -0
- package/dist/src/internal/mock/VerifyNoMoreInteractions.js.map +1 -0
- package/dist/src/internal/schema/ApplyErrorToParsedTypes.d.ts +13 -0
- package/dist/src/internal/schema/ApplyErrorToParsedTypes.js +61 -0
- package/dist/src/internal/schema/ApplyErrorToParsedTypes.js.map +1 -0
- package/dist/src/internal/schema/CatchErrorCollisions.d.ts +1 -0
- package/dist/src/internal/schema/CatchErrorCollisions.js +73 -0
- package/dist/src/internal/schema/CatchErrorCollisions.js.map +1 -0
- package/dist/src/internal/schema/CatchHeaderCollisions.d.ts +1 -0
- package/dist/src/internal/schema/CatchHeaderCollisions.js +74 -0
- package/dist/src/internal/schema/CatchHeaderCollisions.js.map +1 -0
- package/dist/src/internal/schema/CreateMockTelepactSchemaFromFileJsonMap.d.ts +2 -0
- package/dist/src/internal/schema/CreateMockTelepactSchemaFromFileJsonMap.js +25 -0
- package/dist/src/internal/schema/CreateMockTelepactSchemaFromFileJsonMap.js.map +1 -0
- package/dist/src/internal/schema/CreateTelepactSchemaFromFileJsonMap.d.ts +2 -0
- package/dist/src/internal/schema/CreateTelepactSchemaFromFileJsonMap.js +33 -0
- package/dist/src/internal/schema/CreateTelepactSchemaFromFileJsonMap.js.map +1 -0
- package/dist/src/internal/schema/DerivePossibleSelect.d.ts +2 -0
- package/dist/src/internal/schema/DerivePossibleSelect.js +87 -0
- package/dist/src/internal/schema/DerivePossibleSelect.js.map +1 -0
- package/dist/src/internal/schema/FindMatchingSchemaKey.d.ts +1 -0
- package/dist/src/internal/schema/FindMatchingSchemaKey.js +27 -0
- package/dist/src/internal/schema/FindMatchingSchemaKey.js.map +1 -0
- package/dist/src/internal/schema/FindSchemaKey.d.ts +1 -0
- package/dist/src/internal/schema/FindSchemaKey.js +40 -0
- package/dist/src/internal/schema/FindSchemaKey.js.map +1 -0
- package/dist/src/internal/schema/GetAuthTelepactJson.d.ts +1 -0
- package/dist/src/internal/schema/GetAuthTelepactJson.js +20 -0
- package/dist/src/internal/schema/GetAuthTelepactJson.js.map +1 -0
- package/dist/src/internal/schema/GetInternalTelepactJson.d.ts +1 -0
- package/dist/src/internal/schema/GetInternalTelepactJson.js +20 -0
- package/dist/src/internal/schema/GetInternalTelepactJson.js.map +1 -0
- package/dist/src/internal/schema/GetMockTelepactJson.d.ts +1 -0
- package/dist/src/internal/schema/GetMockTelepactJson.js +20 -0
- package/dist/src/internal/schema/GetMockTelepactJson.js.map +1 -0
- package/dist/src/internal/schema/GetOrParseType.d.ts +3 -0
- package/dist/src/internal/schema/GetOrParseType.js +108 -0
- package/dist/src/internal/schema/GetOrParseType.js.map +1 -0
- package/dist/src/internal/schema/GetPathDocumentCoordinatesPseudoJson.d.ts +7 -0
- package/dist/src/internal/schema/GetPathDocumentCoordinatesPseudoJson.js +218 -0
- package/dist/src/internal/schema/GetPathDocumentCoordinatesPseudoJson.js.map +1 -0
- package/dist/src/internal/schema/GetSchemaFileMap.d.ts +2 -0
- package/dist/src/internal/schema/GetSchemaFileMap.js +40 -0
- package/dist/src/internal/schema/GetSchemaFileMap.js.map +1 -0
- package/dist/src/internal/schema/GetTypeUnexpectedParseFailure.d.ts +2 -0
- package/dist/src/internal/schema/GetTypeUnexpectedParseFailure.js +26 -0
- package/dist/src/internal/schema/GetTypeUnexpectedParseFailure.js.map +1 -0
- package/dist/src/internal/schema/MapSchemaParseFailuresToPseudoJson.d.ts +2 -0
- package/dist/src/internal/schema/MapSchemaParseFailuresToPseudoJson.js +31 -0
- package/dist/src/internal/schema/MapSchemaParseFailuresToPseudoJson.js.map +1 -0
- package/dist/src/internal/schema/ParseContext.d.ts +41 -0
- package/dist/src/internal/schema/ParseContext.js +41 -0
- package/dist/src/internal/schema/ParseContext.js.map +1 -0
- package/dist/src/internal/schema/ParseErrorType.d.ts +5 -0
- package/dist/src/internal/schema/ParseErrorType.js +35 -0
- package/dist/src/internal/schema/ParseErrorType.js.map +1 -0
- package/dist/src/internal/schema/ParseField.d.ts +3 -0
- package/dist/src/internal/schema/ParseField.js +36 -0
- package/dist/src/internal/schema/ParseField.js.map +1 -0
- package/dist/src/internal/schema/ParseFunctionType.d.ts +8 -0
- package/dist/src/internal/schema/ParseFunctionType.js +75 -0
- package/dist/src/internal/schema/ParseFunctionType.js.map +1 -0
- package/dist/src/internal/schema/ParseHeadersType.d.ts +5 -0
- package/dist/src/internal/schema/ParseHeadersType.js +92 -0
- package/dist/src/internal/schema/ParseHeadersType.js.map +1 -0
- package/dist/src/internal/schema/ParseStructFields.d.ts +7 -0
- package/dist/src/internal/schema/ParseStructFields.js +58 -0
- package/dist/src/internal/schema/ParseStructFields.js.map +1 -0
- package/dist/src/internal/schema/ParseStructType.d.ts +5 -0
- package/dist/src/internal/schema/ParseStructType.js +53 -0
- package/dist/src/internal/schema/ParseStructType.js.map +1 -0
- package/dist/src/internal/schema/ParseTelepactSchema.d.ts +2 -0
- package/dist/src/internal/schema/ParseTelepactSchema.js +257 -0
- package/dist/src/internal/schema/ParseTelepactSchema.js.map +1 -0
- package/dist/src/internal/schema/ParseTypeDeclaration.d.ts +2 -0
- package/dist/src/internal/schema/ParseTypeDeclaration.js +84 -0
- package/dist/src/internal/schema/ParseTypeDeclaration.js.map +1 -0
- package/dist/src/internal/schema/ParseUnionType.d.ts +5 -0
- package/dist/src/internal/schema/ParseUnionType.js +138 -0
- package/dist/src/internal/schema/ParseUnionType.js.map +1 -0
- package/dist/src/internal/schema/SchemaParseFailure.d.ts +8 -0
- package/dist/src/internal/schema/SchemaParseFailure.js +29 -0
- package/dist/src/internal/schema/SchemaParseFailure.js.map +1 -0
- package/dist/src/internal/types/GetType.d.ts +1 -0
- package/dist/src/internal/types/GetType.js +39 -0
- package/dist/src/internal/types/GetType.js.map +1 -0
- package/dist/src/internal/types/TAny.d.ts +11 -0
- package/dist/src/internal/types/TAny.js +33 -0
- package/dist/src/internal/types/TAny.js.map +1 -0
- package/dist/src/internal/types/TArray.d.ts +12 -0
- package/dist/src/internal/types/TArray.js +34 -0
- package/dist/src/internal/types/TArray.js.map +1 -0
- package/dist/src/internal/types/TBoolean.d.ts +12 -0
- package/dist/src/internal/types/TBoolean.js +34 -0
- package/dist/src/internal/types/TBoolean.js.map +1 -0
- package/dist/src/internal/types/TBytes.d.ts +12 -0
- package/dist/src/internal/types/TBytes.js +34 -0
- package/dist/src/internal/types/TBytes.js.map +1 -0
- package/dist/src/internal/types/TError.d.ts +6 -0
- package/dist/src/internal/types/TError.js +24 -0
- package/dist/src/internal/types/TError.js.map +1 -0
- package/dist/src/internal/types/TFieldDeclaration.d.ts +7 -0
- package/dist/src/internal/types/TFieldDeclaration.js +26 -0
- package/dist/src/internal/types/TFieldDeclaration.js.map +1 -0
- package/dist/src/internal/types/THeaders.d.ts +15 -0
- package/dist/src/internal/types/THeaders.js +26 -0
- package/dist/src/internal/types/THeaders.js.map +1 -0
- package/dist/src/internal/types/TInteger.d.ts +12 -0
- package/dist/src/internal/types/TInteger.js +34 -0
- package/dist/src/internal/types/TInteger.js.map +1 -0
- package/dist/src/internal/types/TMockCall.d.ts +16 -0
- package/dist/src/internal/types/TMockCall.js +39 -0
- package/dist/src/internal/types/TMockCall.js.map +1 -0
- package/dist/src/internal/types/TMockStub.d.ts +18 -0
- package/dist/src/internal/types/TMockStub.js +39 -0
- package/dist/src/internal/types/TMockStub.js.map +1 -0
- package/dist/src/internal/types/TNumber.d.ts +12 -0
- package/dist/src/internal/types/TNumber.js +34 -0
- package/dist/src/internal/types/TNumber.js.map +1 -0
- package/dist/src/internal/types/TObject.d.ts +12 -0
- package/dist/src/internal/types/TObject.js +33 -0
- package/dist/src/internal/types/TObject.js.map +1 -0
- package/dist/src/internal/types/TSelect.d.ts +13 -0
- package/dist/src/internal/types/TSelect.js +34 -0
- package/dist/src/internal/types/TSelect.js.map +1 -0
- package/dist/src/internal/types/TString.d.ts +12 -0
- package/dist/src/internal/types/TString.js +34 -0
- package/dist/src/internal/types/TString.js.map +1 -0
- package/dist/src/internal/types/TStruct.d.ts +20 -0
- package/dist/src/internal/types/TStruct.js +39 -0
- package/dist/src/internal/types/TStruct.js.map +1 -0
- package/dist/src/internal/types/TType.d.ts +10 -0
- package/dist/src/internal/types/TType.js +18 -0
- package/dist/src/internal/types/TType.js.map +1 -0
- package/dist/src/internal/types/TTypeDeclaration.d.ts +12 -0
- package/dist/src/internal/types/TTypeDeclaration.js +34 -0
- package/dist/src/internal/types/TTypeDeclaration.js.map +1 -0
- package/dist/src/internal/types/TUnion.d.ts +25 -0
- package/dist/src/internal/types/TUnion.js +41 -0
- package/dist/src/internal/types/TUnion.js.map +1 -0
- package/dist/src/internal/validation/GetInvalidErrorMessage.d.ts +6 -0
- package/dist/src/internal/validation/GetInvalidErrorMessage.js +29 -0
- package/dist/src/internal/validation/GetInvalidErrorMessage.js.map +1 -0
- package/dist/src/internal/validation/GetTypeUnexpectedValidationFailure.d.ts +2 -0
- package/dist/src/internal/validation/GetTypeUnexpectedValidationFailure.js +26 -0
- package/dist/src/internal/validation/GetTypeUnexpectedValidationFailure.js.map +1 -0
- package/dist/src/internal/validation/InvalidMessage.d.ts +3 -0
- package/dist/src/internal/validation/InvalidMessage.js +21 -0
- package/dist/src/internal/validation/InvalidMessage.js.map +1 -0
- package/dist/src/internal/validation/InvalidMessageBody.d.ts +2 -0
- package/dist/src/internal/validation/InvalidMessageBody.js +18 -0
- package/dist/src/internal/validation/InvalidMessageBody.js.map +1 -0
- package/dist/src/internal/validation/MapValidationFailuresToInvalidFieldCases.d.ts +2 -0
- package/dist/src/internal/validation/MapValidationFailuresToInvalidFieldCases.js +27 -0
- package/dist/src/internal/validation/MapValidationFailuresToInvalidFieldCases.js.map +1 -0
- package/dist/src/internal/validation/ValidateArray.d.ts +4 -0
- package/dist/src/internal/validation/ValidateArray.js +42 -0
- package/dist/src/internal/validation/ValidateArray.js.map +1 -0
- package/dist/src/internal/validation/ValidateBoolean.d.ts +2 -0
- package/dist/src/internal/validation/ValidateBoolean.js +26 -0
- package/dist/src/internal/validation/ValidateBoolean.js.map +1 -0
- package/dist/src/internal/validation/ValidateBytes.d.ts +3 -0
- package/dist/src/internal/validation/ValidateBytes.js +56 -0
- package/dist/src/internal/validation/ValidateBytes.js.map +1 -0
- package/dist/src/internal/validation/ValidateContext.d.ts +13 -0
- package/dist/src/internal/validation/ValidateContext.js +32 -0
- package/dist/src/internal/validation/ValidateContext.js.map +1 -0
- package/dist/src/internal/validation/ValidateHeaders.d.ts +3 -0
- package/dist/src/internal/validation/ValidateHeaders.js +34 -0
- package/dist/src/internal/validation/ValidateHeaders.js.map +1 -0
- package/dist/src/internal/validation/ValidateInteger.d.ts +2 -0
- package/dist/src/internal/validation/ValidateInteger.js +33 -0
- package/dist/src/internal/validation/ValidateInteger.js.map +1 -0
- package/dist/src/internal/validation/ValidateMockCall.d.ts +4 -0
- package/dist/src/internal/validation/ValidateMockCall.js +50 -0
- package/dist/src/internal/validation/ValidateMockCall.js.map +1 -0
- package/dist/src/internal/validation/ValidateMockStub.d.ts +6 -0
- package/dist/src/internal/validation/ValidateMockStub.js +73 -0
- package/dist/src/internal/validation/ValidateMockStub.js.map +1 -0
- package/dist/src/internal/validation/ValidateNumber.d.ts +2 -0
- package/dist/src/internal/validation/ValidateNumber.js +33 -0
- package/dist/src/internal/validation/ValidateNumber.js.map +1 -0
- package/dist/src/internal/validation/ValidateObject.d.ts +4 -0
- package/dist/src/internal/validation/ValidateObject.js +40 -0
- package/dist/src/internal/validation/ValidateObject.js.map +1 -0
- package/dist/src/internal/validation/ValidateResult.d.ts +2 -0
- package/dist/src/internal/validation/ValidateResult.js +25 -0
- package/dist/src/internal/validation/ValidateResult.js.map +1 -0
- package/dist/src/internal/validation/ValidateSelect.d.ts +3 -0
- package/dist/src/internal/validation/ValidateSelect.js +56 -0
- package/dist/src/internal/validation/ValidateSelect.js.map +1 -0
- package/dist/src/internal/validation/ValidateString.d.ts +2 -0
- package/dist/src/internal/validation/ValidateString.js +26 -0
- package/dist/src/internal/validation/ValidateString.js.map +1 -0
- package/dist/src/internal/validation/ValidateStruct.d.ts +4 -0
- package/dist/src/internal/validation/ValidateStruct.js +28 -0
- package/dist/src/internal/validation/ValidateStruct.js.map +1 -0
- package/dist/src/internal/validation/ValidateStructFields.d.ts +4 -0
- package/dist/src/internal/validation/ValidateStructFields.js +53 -0
- package/dist/src/internal/validation/ValidateStructFields.js.map +1 -0
- package/dist/src/internal/validation/ValidateUnion.d.ts +4 -0
- package/dist/src/internal/validation/ValidateUnion.js +34 -0
- package/dist/src/internal/validation/ValidateUnion.js.map +1 -0
- package/dist/src/internal/validation/ValidateUnionStruct.d.ts +4 -0
- package/dist/src/internal/validation/ValidateUnionStruct.js +24 -0
- package/dist/src/internal/validation/ValidateUnionStruct.js.map +1 -0
- package/dist/src/internal/validation/ValidateUnionTags.d.ts +4 -0
- package/dist/src/internal/validation/ValidateUnionTags.js +46 -0
- package/dist/src/internal/validation/ValidateUnionTags.js.map +1 -0
- package/dist/src/internal/validation/ValidateValueOfType.d.ts +5 -0
- package/dist/src/internal/validation/ValidateValueOfType.js +28 -0
- package/dist/src/internal/validation/ValidateValueOfType.js.map +1 -0
- package/dist/src/internal/validation/ValidationFailure.d.ts +6 -0
- package/dist/src/internal/validation/ValidationFailure.js +26 -0
- package/dist/src/internal/validation/ValidationFailure.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Serializer } from './Serializer';
|
|
2
|
+
import { Message } from './Message';
|
|
3
|
+
import { Serialization } from './Serialization';
|
|
4
|
+
export declare class Client {
|
|
5
|
+
private adapter;
|
|
6
|
+
private useBinaryDefault;
|
|
7
|
+
private alwaysSendJson;
|
|
8
|
+
private timeoutMsDefault;
|
|
9
|
+
private serializer;
|
|
10
|
+
constructor(adapter: (message: Message, serializer: Serializer) => Promise<Message>, options: ClientOptions);
|
|
11
|
+
request(requestMessage: Message): Promise<Message>;
|
|
12
|
+
}
|
|
13
|
+
export declare class ClientOptions {
|
|
14
|
+
useBinary: boolean;
|
|
15
|
+
alwaysSendJson: boolean;
|
|
16
|
+
timeoutMsDefault: number;
|
|
17
|
+
serializationImpl: Serialization;
|
|
18
|
+
localStorageCacheNamespace: string;
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
import { DefaultSerialization } from './DefaultSerialization';
|
|
17
|
+
import { Serializer } from './Serializer';
|
|
18
|
+
import { ClientBinaryEncoder } from './internal/binary/ClientBinaryEncoder';
|
|
19
|
+
import { clientHandleMessage } from './internal/ClientHandleMessage';
|
|
20
|
+
import { DefaultBinaryEncodingCache } from './internal/binary/DefaultBinaryEncodingCache';
|
|
21
|
+
import { ClientBase64Encoder } from './internal/binary/ClientBase64Encoder';
|
|
22
|
+
import { LocalStorageBackedBinaryEncodingCache } from './internal/binary/LocalStorageBackedBinaryEncodingCache';
|
|
23
|
+
export class Client {
|
|
24
|
+
adapter;
|
|
25
|
+
useBinaryDefault;
|
|
26
|
+
alwaysSendJson;
|
|
27
|
+
timeoutMsDefault;
|
|
28
|
+
serializer;
|
|
29
|
+
constructor(adapter, options) {
|
|
30
|
+
this.adapter = adapter;
|
|
31
|
+
this.useBinaryDefault = options.useBinary;
|
|
32
|
+
this.alwaysSendJson = options.alwaysSendJson;
|
|
33
|
+
this.timeoutMsDefault = options.timeoutMsDefault;
|
|
34
|
+
const binaryEncodingCache = options.localStorageCacheNamespace
|
|
35
|
+
? new LocalStorageBackedBinaryEncodingCache(options.localStorageCacheNamespace)
|
|
36
|
+
: new DefaultBinaryEncodingCache();
|
|
37
|
+
const binaryEncoder = new ClientBinaryEncoder(binaryEncodingCache);
|
|
38
|
+
const base64Encoder = new ClientBase64Encoder();
|
|
39
|
+
this.serializer = new Serializer(options.serializationImpl, binaryEncoder, base64Encoder);
|
|
40
|
+
}
|
|
41
|
+
async request(requestMessage) {
|
|
42
|
+
return await clientHandleMessage(requestMessage, this.adapter, this.serializer, this.timeoutMsDefault, this.useBinaryDefault, this.alwaysSendJson);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ClientOptions {
|
|
46
|
+
useBinary;
|
|
47
|
+
alwaysSendJson;
|
|
48
|
+
timeoutMsDefault;
|
|
49
|
+
serializationImpl;
|
|
50
|
+
localStorageCacheNamespace;
|
|
51
|
+
constructor() {
|
|
52
|
+
this.useBinary = false;
|
|
53
|
+
this.alwaysSendJson = true;
|
|
54
|
+
this.timeoutMsDefault = 5000;
|
|
55
|
+
this.serializationImpl = new DefaultSerialization();
|
|
56
|
+
this.localStorageCacheNamespace = '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=Client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/Client.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,qCAAqC,EAAE,MAAM,yDAAyD,CAAC;AAEhH,MAAM,OAAO,MAAM;IACP,OAAO,CAAiE;IACxE,gBAAgB,CAAU;IAC1B,cAAc,CAAU;IACxB,gBAAgB,CAAS;IACzB,UAAU,CAAa;IAE/B,YAAY,OAAuE,EAAE,OAAsB;QACvG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;QAC1C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QAEjD,MAAM,mBAAmB,GAAG,OAAO,CAAC,0BAA0B;YAC1D,CAAC,CAAC,IAAI,qCAAqC,CAAC,OAAO,CAAC,0BAA0B,CAAC;YAC/E,CAAC,CAAC,IAAI,0BAA0B,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;QACnE,MAAM,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAEhD,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAC9F,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,cAAuB;QACjC,OAAO,MAAM,mBAAmB,CAC5B,cAAc,EACd,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,cAAc,CACtB,CAAC;IACN,CAAC;CACJ;AAED,MAAM,OAAO,aAAa;IACtB,SAAS,CAAU;IACnB,cAAc,CAAU;IACxB,gBAAgB,CAAS;IACzB,iBAAiB,CAAgB;IACjC,0BAA0B,CAAQ;IAElC;QACI,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,IAAI,oBAAoB,EAAE,CAAC;QACpD,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAA;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Serialization } from './Serialization';
|
|
2
|
+
export declare class DefaultSerialization implements Serialization {
|
|
3
|
+
private packr;
|
|
4
|
+
private unpackr;
|
|
5
|
+
toJson(telepactMessage: any): Uint8Array;
|
|
6
|
+
toMsgpack(telepactMessage: any): Uint8Array;
|
|
7
|
+
fromJson(bytes: Uint8Array): any;
|
|
8
|
+
fromMsgpack(bytes: Uint8Array): any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
import { Packr, Unpackr } from 'msgpackr';
|
|
17
|
+
export class DefaultSerialization {
|
|
18
|
+
packr = new Packr({ mapsAsObjects: false, useRecords: false });
|
|
19
|
+
unpackr = new Unpackr({ mapsAsObjects: false, useRecords: false });
|
|
20
|
+
toJson(telepactMessage) {
|
|
21
|
+
const jsonStr = JSON.stringify(telepactMessage);
|
|
22
|
+
return new TextEncoder().encode(jsonStr);
|
|
23
|
+
}
|
|
24
|
+
toMsgpack(telepactMessage) {
|
|
25
|
+
return this.packr.encode(telepactMessage);
|
|
26
|
+
}
|
|
27
|
+
fromJson(bytes) {
|
|
28
|
+
const jsonStr = new TextDecoder().decode(bytes);
|
|
29
|
+
return JSON.parse(jsonStr);
|
|
30
|
+
}
|
|
31
|
+
fromMsgpack(bytes) {
|
|
32
|
+
return this.unpackr.decode(bytes);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DefaultSerialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultSerialization.js","sourceRoot":"","sources":["../../src/DefaultSerialization.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,OAAO,oBAAoB;IACrB,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/D,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAEpE,MAAM,CAAC,eAAoB;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAChD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAEM,SAAS,CAAC,eAAoB;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC9C,CAAC;IAEM,QAAQ,CAAC,KAAiB;QAC7B,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,WAAW,CAAC,KAAiB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
export class Message {
|
|
17
|
+
headers;
|
|
18
|
+
body;
|
|
19
|
+
constructor(headers, body) {
|
|
20
|
+
this.headers = headers;
|
|
21
|
+
this.body = body;
|
|
22
|
+
}
|
|
23
|
+
getBodyTarget() {
|
|
24
|
+
const entry = Object.entries(this.body)[0];
|
|
25
|
+
return entry[0];
|
|
26
|
+
}
|
|
27
|
+
getBodyPayload() {
|
|
28
|
+
const entry = Object.entries(this.body)[0];
|
|
29
|
+
return entry[1];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../src/Message.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH,MAAM,OAAO,OAAO;IAEL;IACA;IAFX,YACW,OAA4B,EAC5B,IAAyB;QADzB,YAAO,GAAP,OAAO,CAAqB;QAC5B,SAAI,GAAJ,IAAI,CAAqB;IACjC,CAAC;IAEJ,aAAa;QACT,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,cAAc;QACV,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,KAAK,CAAC,CAAC,CAAwB,CAAC;IAC3C,CAAC;CACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MockTelepactSchema } from './MockTelepactSchema';
|
|
2
|
+
export declare class MockServer {
|
|
3
|
+
/**
|
|
4
|
+
* A Mock instance of a telepact server.
|
|
5
|
+
*/
|
|
6
|
+
constructor(mockTelepactSchema: MockTelepactSchema, options: MockServerOptions);
|
|
7
|
+
private random;
|
|
8
|
+
private enableGeneratedDefaultStub;
|
|
9
|
+
private enableOptionalFieldGeneration;
|
|
10
|
+
private randomizeOptionalFieldGeneration;
|
|
11
|
+
private stubs;
|
|
12
|
+
private invocations;
|
|
13
|
+
private server;
|
|
14
|
+
process(message: Uint8Array): Promise<Uint8Array>;
|
|
15
|
+
private handle;
|
|
16
|
+
}
|
|
17
|
+
export declare class MockServerOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Options for the MockServer.
|
|
20
|
+
*/
|
|
21
|
+
onError: (error: Error) => void;
|
|
22
|
+
enableMessageResponseGeneration: boolean;
|
|
23
|
+
enableOptionalFieldGeneration: boolean;
|
|
24
|
+
randomizeOptionalFieldGeneration: boolean;
|
|
25
|
+
generatedCollectionLengthMin: number;
|
|
26
|
+
generatedCollectionLengthMax: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
import { TelepactSchema } from './TelepactSchema';
|
|
17
|
+
import { Server, ServerOptions as ServerOptions } from './Server';
|
|
18
|
+
import { RandomGenerator } from './RandomGenerator';
|
|
19
|
+
import { mockHandle } from './internal/mock/MockHandle';
|
|
20
|
+
export class MockServer {
|
|
21
|
+
/**
|
|
22
|
+
* A Mock instance of a telepact server.
|
|
23
|
+
*/
|
|
24
|
+
constructor(mockTelepactSchema, options) {
|
|
25
|
+
this.random = new RandomGenerator(options.generatedCollectionLengthMin, options.generatedCollectionLengthMax);
|
|
26
|
+
this.enableGeneratedDefaultStub = options.enableMessageResponseGeneration;
|
|
27
|
+
this.enableOptionalFieldGeneration = options.enableOptionalFieldGeneration;
|
|
28
|
+
this.randomizeOptionalFieldGeneration = options.randomizeOptionalFieldGeneration;
|
|
29
|
+
this.stubs = [];
|
|
30
|
+
this.invocations = [];
|
|
31
|
+
const serverOptions = new ServerOptions();
|
|
32
|
+
serverOptions.onError = options.onError;
|
|
33
|
+
serverOptions.authRequired = false;
|
|
34
|
+
const telepactSchema = new TelepactSchema(mockTelepactSchema.original, mockTelepactSchema.full, mockTelepactSchema.parsed, mockTelepactSchema.parsedRequestHeaders, mockTelepactSchema.parsedResponseHeaders);
|
|
35
|
+
this.server = new Server(telepactSchema, this.handle, serverOptions);
|
|
36
|
+
}
|
|
37
|
+
random;
|
|
38
|
+
enableGeneratedDefaultStub;
|
|
39
|
+
enableOptionalFieldGeneration;
|
|
40
|
+
randomizeOptionalFieldGeneration;
|
|
41
|
+
stubs;
|
|
42
|
+
invocations;
|
|
43
|
+
server;
|
|
44
|
+
async process(message) {
|
|
45
|
+
/**
|
|
46
|
+
* Process a given telepact Request Message into a telepact Response Message.
|
|
47
|
+
*
|
|
48
|
+
* @param message - The telepact request message.
|
|
49
|
+
* @returns The telepact response message.
|
|
50
|
+
*/
|
|
51
|
+
return await this.server.process(message);
|
|
52
|
+
}
|
|
53
|
+
handle = async (requestMessage) => {
|
|
54
|
+
return await mockHandle(requestMessage, this.stubs, this.invocations, this.random, this.server.telepactSchema, this.enableGeneratedDefaultStub, this.enableOptionalFieldGeneration, this.randomizeOptionalFieldGeneration);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export class MockServerOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Options for the MockServer.
|
|
60
|
+
*/
|
|
61
|
+
onError = (e) => { };
|
|
62
|
+
enableMessageResponseGeneration = true;
|
|
63
|
+
enableOptionalFieldGeneration = true;
|
|
64
|
+
randomizeOptionalFieldGeneration = true;
|
|
65
|
+
generatedCollectionLengthMin = 0;
|
|
66
|
+
generatedCollectionLengthMax = 3;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=MockServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockServer.js","sourceRoot":"","sources":["../../src/MockServer.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,MAAM,OAAO,UAAU;IACnB;;OAEG;IAEH,YAAY,kBAAsC,EAAE,OAA0B;QAC1E,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,4BAA4B,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC9G,IAAI,CAAC,0BAA0B,GAAG,OAAO,CAAC,+BAA+B,CAAC;QAC1E,IAAI,CAAC,6BAA6B,GAAG,OAAO,CAAC,6BAA6B,CAAC;QAC3E,IAAI,CAAC,gCAAgC,GAAG,OAAO,CAAC,gCAAgC,CAAC;QAEjF,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QAEtB,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;QAC1C,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACxC,aAAa,CAAC,YAAY,GAAG,KAAK,CAAC;QAEnC,MAAM,cAAc,GAAG,IAAI,cAAc,CACrC,kBAAkB,CAAC,QAAQ,EAC3B,kBAAkB,CAAC,IAAI,EACvB,kBAAkB,CAAC,MAAM,EACzB,kBAAkB,CAAC,oBAAoB,EACvC,kBAAkB,CAAC,qBAAqB,CAC3C,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;IAEO,MAAM,CAAkB;IACxB,0BAA0B,CAAU;IACpC,6BAA6B,CAAU;IACvC,gCAAgC,CAAU;IAC1C,KAAK,CAAa;IAClB,WAAW,CAAmB;IAC9B,MAAM,CAAS;IAEvB,KAAK,CAAC,OAAO,CAAC,OAAmB;QAC7B;;;;;WAKG;QACH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAEO,MAAM,GAAG,KAAK,EAAE,cAAmB,EAAgB,EAAE;QACzD,OAAO,MAAM,UAAU,CACnB,cAAc,EACd,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,cAAc,EAC1B,IAAI,CAAC,0BAA0B,EAC/B,IAAI,CAAC,6BAA6B,EAClC,IAAI,CAAC,gCAAgC,CACxC,CAAC;IACN,CAAC,CAAC;CACL;AAED,MAAM,OAAO,iBAAiB;IAC1B;;OAEG;IAEH,OAAO,GAA2B,CAAC,CAAC,EAAE,EAAE,GAAE,CAAC,CAAC;IAC5C,+BAA+B,GAAG,IAAI,CAAC;IACvC,6BAA6B,GAAG,IAAI,CAAC;IACrC,gCAAgC,GAAG,IAAI,CAAC;IACxC,4BAA4B,GAAG,CAAC,CAAC;IACjC,4BAA4B,GAAG,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TFieldDeclaration } from './internal/types/TFieldDeclaration';
|
|
2
|
+
import { TType } from './internal/types/TType';
|
|
3
|
+
import { FsModule, PathModule } from './fileSystem';
|
|
4
|
+
export declare class MockTelepactSchema {
|
|
5
|
+
/**
|
|
6
|
+
* A parsed telepact schema.
|
|
7
|
+
*/
|
|
8
|
+
original: any[];
|
|
9
|
+
full: any[];
|
|
10
|
+
parsed: Record<string, TType>;
|
|
11
|
+
parsedRequestHeaders: Record<string, TFieldDeclaration>;
|
|
12
|
+
parsedResponseHeaders: Record<string, TFieldDeclaration>;
|
|
13
|
+
constructor(original: any[], full: any[], parsed: Record<string, TType>, parsedRequestHeaders: Record<string, TFieldDeclaration>, parsedResponseHeaders: Record<string, TFieldDeclaration>);
|
|
14
|
+
static fromJson(json: string): MockTelepactSchema;
|
|
15
|
+
static fromFileJsonMap(jsonDocuments: Record<string, string>): MockTelepactSchema;
|
|
16
|
+
static fromDirectory(directory: string, fs: FsModule, path: PathModule): MockTelepactSchema;
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
import { createMockTelepactSchemaFromFileJsonMap } from './internal/schema/CreateMockTelepactSchemaFromFileJsonMap';
|
|
17
|
+
import { getSchemaFileMap } from './internal/schema/GetSchemaFileMap';
|
|
18
|
+
export class MockTelepactSchema {
|
|
19
|
+
/**
|
|
20
|
+
* A parsed telepact schema.
|
|
21
|
+
*/
|
|
22
|
+
original;
|
|
23
|
+
full;
|
|
24
|
+
parsed;
|
|
25
|
+
parsedRequestHeaders;
|
|
26
|
+
parsedResponseHeaders;
|
|
27
|
+
constructor(original, full, parsed, parsedRequestHeaders, parsedResponseHeaders) {
|
|
28
|
+
this.original = original;
|
|
29
|
+
this.full = full;
|
|
30
|
+
this.parsed = parsed;
|
|
31
|
+
this.parsedRequestHeaders = parsedRequestHeaders;
|
|
32
|
+
this.parsedResponseHeaders = parsedResponseHeaders;
|
|
33
|
+
}
|
|
34
|
+
static fromJson(json) {
|
|
35
|
+
return createMockTelepactSchemaFromFileJsonMap({ auto_: json });
|
|
36
|
+
}
|
|
37
|
+
static fromFileJsonMap(jsonDocuments) {
|
|
38
|
+
return createMockTelepactSchemaFromFileJsonMap(jsonDocuments);
|
|
39
|
+
}
|
|
40
|
+
static fromDirectory(directory, fs, path) {
|
|
41
|
+
const m = getSchemaFileMap(directory, fs, path);
|
|
42
|
+
return createMockTelepactSchemaFromFileJsonMap(m);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=MockTelepactSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockTelepactSchema.js","sourceRoot":"","sources":["../../src/MockTelepactSchema.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAIH,OAAO,EAAE,uCAAuC,EAAE,MAAM,2DAA2D,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,MAAM,OAAO,kBAAkB;IAC3B;;OAEG;IAEH,QAAQ,CAAQ;IAChB,IAAI,CAAQ;IACZ,MAAM,CAAwB;IAC9B,oBAAoB,CAAoC;IACxD,qBAAqB,CAAoC;IAEzD,YACI,QAAe,EACf,IAAW,EACX,MAA6B,EAC7B,oBAAuD,EACvD,qBAAwD;QAExD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,OAAO,uCAAuC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,aAAqC;QACxD,OAAO,uCAAuC,CAAC,aAAa,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,SAAiB,EAAE,EAAY,EAAE,IAAgB;QAClE,MAAM,CAAC,GAAG,gBAAgB,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAChD,OAAO,uCAAuC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class RandomGenerator {
|
|
2
|
+
seed: number;
|
|
3
|
+
private collectionLengthMin;
|
|
4
|
+
private collectionLengthMax;
|
|
5
|
+
private count;
|
|
6
|
+
constructor(collectionLengthMin: number, collectionLengthMax: number);
|
|
7
|
+
setSeed(seed: number): void;
|
|
8
|
+
nextInt(): number;
|
|
9
|
+
nextIntWithCeiling(ceiling: number): number;
|
|
10
|
+
nextBoolean(): boolean;
|
|
11
|
+
nextBytes(): Uint8Array;
|
|
12
|
+
nextString(): string;
|
|
13
|
+
nextDouble(): number;
|
|
14
|
+
nextCollectionLength(): number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
/*
|
|
17
|
+
* For debeugging.
|
|
18
|
+
*/
|
|
19
|
+
function findStack() {
|
|
20
|
+
const e = new Error();
|
|
21
|
+
const stack = e.stack.split('\n');
|
|
22
|
+
for (let i = 3; i < stack.length; i += 1) {
|
|
23
|
+
const line = stack[i].split('(')[0];
|
|
24
|
+
if (!line.includes('RandomGenerator')) {
|
|
25
|
+
return line + stack[i - 1].split('(')[0];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw new Error();
|
|
29
|
+
}
|
|
30
|
+
const words = [
|
|
31
|
+
"alpha",
|
|
32
|
+
"beta",
|
|
33
|
+
"gamma",
|
|
34
|
+
"delta",
|
|
35
|
+
"epsilon",
|
|
36
|
+
"zeta",
|
|
37
|
+
"eta",
|
|
38
|
+
"theta",
|
|
39
|
+
"iota",
|
|
40
|
+
"kappa",
|
|
41
|
+
"lambda",
|
|
42
|
+
"mu",
|
|
43
|
+
"nu",
|
|
44
|
+
"xi",
|
|
45
|
+
"omicron",
|
|
46
|
+
"pi",
|
|
47
|
+
"rho",
|
|
48
|
+
"sigma",
|
|
49
|
+
"tau",
|
|
50
|
+
"upsilon",
|
|
51
|
+
"phi",
|
|
52
|
+
"chi",
|
|
53
|
+
"psi",
|
|
54
|
+
"omega"
|
|
55
|
+
];
|
|
56
|
+
export class RandomGenerator {
|
|
57
|
+
seed;
|
|
58
|
+
collectionLengthMin;
|
|
59
|
+
collectionLengthMax;
|
|
60
|
+
count = 0;
|
|
61
|
+
constructor(collectionLengthMin, collectionLengthMax) {
|
|
62
|
+
this.setSeed(0);
|
|
63
|
+
this.collectionLengthMin = collectionLengthMin;
|
|
64
|
+
this.collectionLengthMax = collectionLengthMax;
|
|
65
|
+
}
|
|
66
|
+
setSeed(seed) {
|
|
67
|
+
this.seed = seed === 0 ? 1 : seed;
|
|
68
|
+
}
|
|
69
|
+
nextInt() {
|
|
70
|
+
let x = this.seed;
|
|
71
|
+
x ^= x << 16;
|
|
72
|
+
x ^= x >> 11;
|
|
73
|
+
x ^= x << 5;
|
|
74
|
+
this.seed = x === 0 ? 1 : x;
|
|
75
|
+
this.count += 1;
|
|
76
|
+
const result = this.seed;
|
|
77
|
+
// console.log(`${this.count} ${result} ${findStack()}`);
|
|
78
|
+
return result & 0x7fffffff;
|
|
79
|
+
}
|
|
80
|
+
nextIntWithCeiling(ceiling) {
|
|
81
|
+
if (ceiling === 0) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
return this.nextInt() % ceiling;
|
|
85
|
+
}
|
|
86
|
+
nextBoolean() {
|
|
87
|
+
return this.nextIntWithCeiling(31) > 15;
|
|
88
|
+
}
|
|
89
|
+
nextBytes() {
|
|
90
|
+
const buffer = new ArrayBuffer(4);
|
|
91
|
+
const view = new DataView(buffer);
|
|
92
|
+
view.setInt32(0, this.nextInt());
|
|
93
|
+
const byteArray = new Uint8Array(buffer);
|
|
94
|
+
return byteArray;
|
|
95
|
+
}
|
|
96
|
+
nextString() {
|
|
97
|
+
const index = this.nextIntWithCeiling(words.length);
|
|
98
|
+
return words[index];
|
|
99
|
+
}
|
|
100
|
+
nextDouble() {
|
|
101
|
+
return (this.nextInt() & 0x7fffffff) / 0x7fffffff;
|
|
102
|
+
}
|
|
103
|
+
nextCollectionLength() {
|
|
104
|
+
return this.nextIntWithCeiling(this.collectionLengthMax - this.collectionLengthMin) + this.collectionLengthMin;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=RandomGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RandomGenerator.js","sourceRoot":"","sources":["../../src/RandomGenerator.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH;;GAEG;AACH,SAAS,SAAS;IACd,MAAM,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC;IACtB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACpC,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;IACD,MAAM,IAAI,KAAK,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,KAAK,GAAG;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;IACL,SAAS;IACT,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;CACV,CAAC;AAEF,MAAM,OAAO,eAAe;IACxB,IAAI,CAAS;IACL,mBAAmB,CAAS;IAC5B,mBAAmB,CAAS;IAC5B,KAAK,GAAW,CAAC,CAAC;IAE1B,YAAY,mBAA2B,EAAE,mBAA2B;QAChE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,IAAY;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,OAAO;QACH,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;QACzB,yDAAyD;QACzD,OAAO,MAAM,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,kBAAkB,CAAC,OAAe;QAC9B,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC;IACpC,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IAC5C,CAAC;IAED,SAAS;QACL,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAEjC,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAEzC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,UAAU;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,UAAU;QACN,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;IACtD,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC;IACnH,CAAC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Serialization {
|
|
2
|
+
/**
|
|
3
|
+
* A serialization implementation that converts between pseudo-JSON Objects and
|
|
4
|
+
* byte array JSON payloads.
|
|
5
|
+
*
|
|
6
|
+
* Pseudo-JSON objects are defined as data structures that represent JSON
|
|
7
|
+
* objects as dicts and JSON arrays as lists.
|
|
8
|
+
*/
|
|
9
|
+
toJson(message: any): Uint8Array;
|
|
10
|
+
toMsgpack(message: any): Uint8Array;
|
|
11
|
+
fromJson(bytes: Uint8Array): any;
|
|
12
|
+
fromMsgpack(bytes: Uint8Array): any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=Serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Serialization.js","sourceRoot":"","sources":["../../src/Serialization.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
export class SerializationError extends Error {
|
|
17
|
+
constructor(cause) {
|
|
18
|
+
super(cause.message);
|
|
19
|
+
Object.setPrototypeOf(this, SerializationError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SerializationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SerializationError.js","sourceRoot":"","sources":["../../src/SerializationError.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAEH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzC,YAAY,KAAY;QACpB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Message } from './Message';
|
|
2
|
+
import { Serialization } from './Serialization';
|
|
3
|
+
import { BinaryEncoder } from './internal/binary/BinaryEncoder';
|
|
4
|
+
import { Base64Encoder } from './internal/binary/Base64Encoder';
|
|
5
|
+
export declare class Serializer {
|
|
6
|
+
/**
|
|
7
|
+
* A serializer that converts a Message to and from a serialized form.
|
|
8
|
+
*/
|
|
9
|
+
private serializationImpl;
|
|
10
|
+
private binaryEncoder;
|
|
11
|
+
private base64Encoder;
|
|
12
|
+
constructor(serializationImpl: Serialization, binaryEncoder: BinaryEncoder, base64Encoder: Base64Encoder);
|
|
13
|
+
serialize(message: Message): Uint8Array;
|
|
14
|
+
deserialize(messageBytes: Uint8Array): Message;
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//|
|
|
2
|
+
//| Copyright The Telepact Authors
|
|
3
|
+
//|
|
|
4
|
+
//| Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
//| you may not use this file except in compliance with the License.
|
|
6
|
+
//| You may obtain a copy of the License at
|
|
7
|
+
//|
|
|
8
|
+
//| https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//|
|
|
10
|
+
//| Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
//| distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
//| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
//| See the License for the specific language governing permissions and
|
|
14
|
+
//| limitations under the License.
|
|
15
|
+
//|
|
|
16
|
+
import { serializeInternal } from './internal/SerializeInternal';
|
|
17
|
+
import { deserializeInternal } from './internal/DeserializeInternal';
|
|
18
|
+
export class Serializer {
|
|
19
|
+
/**
|
|
20
|
+
* A serializer that converts a Message to and from a serialized form.
|
|
21
|
+
*/
|
|
22
|
+
serializationImpl;
|
|
23
|
+
binaryEncoder;
|
|
24
|
+
base64Encoder;
|
|
25
|
+
constructor(serializationImpl, binaryEncoder, base64Encoder) {
|
|
26
|
+
this.serializationImpl = serializationImpl;
|
|
27
|
+
this.binaryEncoder = binaryEncoder;
|
|
28
|
+
this.base64Encoder = base64Encoder;
|
|
29
|
+
}
|
|
30
|
+
serialize(message) {
|
|
31
|
+
/**
|
|
32
|
+
* Serialize a Message into a byte array.
|
|
33
|
+
*/
|
|
34
|
+
return serializeInternal(message, this.binaryEncoder, this.base64Encoder, this.serializationImpl);
|
|
35
|
+
}
|
|
36
|
+
deserialize(messageBytes) {
|
|
37
|
+
/**
|
|
38
|
+
* Deserialize a Message from a byte array.
|
|
39
|
+
*/
|
|
40
|
+
return deserializeInternal(messageBytes, this.serializationImpl, this.binaryEncoder, this.base64Encoder);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../src/Serializer.ts"],"names":[],"mappings":"AAAA,GAAG;AACH,mCAAmC;AACnC,GAAG;AACH,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,GAAG;AACH,gDAAgD;AAChD,GAAG;AACH,wEAAwE;AACxE,sEAAsE;AACtE,6EAA6E;AAC7E,wEAAwE;AACxE,mCAAmC;AACnC,GAAG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,MAAM,OAAO,UAAU;IACnB;;OAEG;IAEK,iBAAiB,CAAgB;IACjC,aAAa,CAAgB;IAC7B,aAAa,CAAgB;IAErC,YAAY,iBAAgC,EAAE,aAA4B,EAAE,aAA4B;QACpG,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAEM,SAAS,CAAC,OAAgB;QAC7B;;WAEG;QACH,OAAO,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtG,CAAC;IAEM,WAAW,CAAC,YAAwB;QACvC;;WAEG;QACH,OAAO,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7G,CAAC;CACJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Serializer } from './Serializer';
|
|
2
|
+
import { Message } from './Message';
|
|
3
|
+
import { TelepactSchema } from './TelepactSchema';
|
|
4
|
+
import { Serialization } from './Serialization';
|
|
5
|
+
export declare class Server {
|
|
6
|
+
handler: (message: Message) => Promise<Message>;
|
|
7
|
+
onError: (error: any) => void;
|
|
8
|
+
onRequest: (message: Message) => void;
|
|
9
|
+
onResponse: (message: Message) => void;
|
|
10
|
+
telepactSchema: TelepactSchema;
|
|
11
|
+
serializer: Serializer;
|
|
12
|
+
constructor(telepactSchema: TelepactSchema, handler: (message: Message) => Promise<Message>, options: ServerOptions);
|
|
13
|
+
process(requestMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ServerOptions {
|
|
16
|
+
onError: (error: any) => void;
|
|
17
|
+
onRequest: (message: Message) => void;
|
|
18
|
+
onResponse: (message: Message) => void;
|
|
19
|
+
authRequired: boolean;
|
|
20
|
+
serialization: Serialization;
|
|
21
|
+
constructor();
|
|
22
|
+
}
|