From 9304c2c4f5ae44d07e3e1ff3aa86302e98fe7c8b Mon Sep 17 00:00:00 2001 From: Andrey Frolov Date: Mon, 8 Apr 2024 17:19:14 +0200 Subject: [PATCH] SPT-1998 append missing file --- NodeKit.xcodeproj/project.pbxproj | 8 ++-- .../xcshareddata/swiftpm/Package.resolved | 15 +++++++ .../EntryInputDtoOutputNode.swift | 42 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 NodeKit/Layers/InputProcessingLayer/EntryInputDtoOutputNode.swift diff --git a/NodeKit.xcodeproj/project.pbxproj b/NodeKit.xcodeproj/project.pbxproj index 01f446c46..fe0dd55d4 100644 --- a/NodeKit.xcodeproj/project.pbxproj +++ b/NodeKit.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 5060A4902BC43A4A004E84E2 /* VoidOutputNodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5060A48F2BC43A4A004E84E2 /* VoidOutputNodeTests.swift */; }; 5060A4922BC43D71004E84E2 /* LoggerStreamNodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5060A4912BC43D71004E84E2 /* LoggerStreamNodeTests.swift */; }; 5060A4942BC43FBD004E84E2 /* LoggerNodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5060A4932BC43FBD004E84E2 /* LoggerNodeTests.swift */; }; + 5060A4962BC44225004E84E2 /* EntryInputDtoOutputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5060A4952BC44225004E84E2 /* EntryInputDtoOutputNode.swift */; }; 50B6838F2BBF3615001F7EA3 /* AccessSafeNodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B6838E2BBF3615001F7EA3 /* AccessSafeNodeTests.swift */; }; 50B683922BBF3816001F7EA3 /* TransportUrlRequest+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B683912BBF3816001F7EA3 /* TransportUrlRequest+Equatable.swift */; }; 50C8EB282BBD7A2200C5CB93 /* AsyncStreamCombineNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50C8EB272BBD7A2200C5CB93 /* AsyncStreamCombineNode.swift */; }; @@ -144,7 +145,6 @@ 90B60996283E1287006F4309 /* VoidIONode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B60945283E1287006F4309 /* VoidIONode.swift */; }; 90B60997283E1287006F4309 /* VoidOutputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B60946283E1287006F4309 /* VoidOutputNode.swift */; }; 90B60998283E1287006F4309 /* ModelInputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B60947283E1287006F4309 /* ModelInputNode.swift */; }; - 90B60999283E1287006F4309 /* EntryInputDtoOutputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B60948283E1287006F4309 /* EntryInputDtoOutputNode.swift */; }; 90B6099A283E1287006F4309 /* VoidInputNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B60949283E1287006F4309 /* VoidInputNode.swift */; }; 90B6099B283E1287006F4309 /* RequestAborterNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B6094B283E1287006F4309 /* RequestAborterNode.swift */; }; 90B6099C283E1287006F4309 /* LoadIndicatorNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B6094C283E1287006F4309 /* LoadIndicatorNode.swift */; }; @@ -291,6 +291,7 @@ 5060A48F2BC43A4A004E84E2 /* VoidOutputNodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidOutputNodeTests.swift; sourceTree = ""; }; 5060A4912BC43D71004E84E2 /* LoggerStreamNodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerStreamNodeTests.swift; sourceTree = ""; }; 5060A4932BC43FBD004E84E2 /* LoggerNodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerNodeTests.swift; sourceTree = ""; }; + 5060A4952BC44225004E84E2 /* EntryInputDtoOutputNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryInputDtoOutputNode.swift; sourceTree = ""; }; 50B6838E2BBF3615001F7EA3 /* AccessSafeNodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessSafeNodeTests.swift; sourceTree = ""; }; 50B683912BBF3816001F7EA3 /* TransportUrlRequest+Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TransportUrlRequest+Equatable.swift"; sourceTree = ""; }; 50C8EB272BBD7A2200C5CB93 /* AsyncStreamCombineNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncStreamCombineNode.swift; sourceTree = ""; }; @@ -365,7 +366,6 @@ 90B60945283E1287006F4309 /* VoidIONode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VoidIONode.swift; sourceTree = ""; }; 90B60946283E1287006F4309 /* VoidOutputNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VoidOutputNode.swift; sourceTree = ""; }; 90B60947283E1287006F4309 /* ModelInputNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelInputNode.swift; sourceTree = ""; }; - 90B60948283E1287006F4309 /* EntryInputDtoOutputNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntryInputDtoOutputNode.swift; sourceTree = ""; }; 90B60949283E1287006F4309 /* VoidInputNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VoidInputNode.swift; sourceTree = ""; }; 90B6094B283E1287006F4309 /* RequestAborterNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestAborterNode.swift; sourceTree = ""; }; 90B6094C283E1287006F4309 /* LoadIndicatorNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadIndicatorNode.swift; sourceTree = ""; }; @@ -842,8 +842,8 @@ 90B60945283E1287006F4309 /* VoidIONode.swift */, 90B60946283E1287006F4309 /* VoidOutputNode.swift */, 90B60947283E1287006F4309 /* ModelInputNode.swift */, - 90B60948283E1287006F4309 /* EntryInputDtoOutputNode.swift */, 90B60949283E1287006F4309 /* VoidInputNode.swift */, + 5060A4952BC44225004E84E2 /* EntryInputDtoOutputNode.swift */, ); path = InputProcessingLayer; sourceTree = ""; @@ -1377,7 +1377,6 @@ 90B6098E283E1287006F4309 /* RoutableRequestModel.swift in Sources */, 90B6098B283E1287006F4309 /* URLQueryConfigModel.swift in Sources */, 5019CCF22BC024F60050B6DF /* MultipartFormDataProtocol.swift in Sources */, - 90B60999283E1287006F4309 /* EntryInputDtoOutputNode.swift in Sources */, 90B60921283E1268006F4309 /* MultipartModel.swift in Sources */, 90B609A9283E1287006F4309 /* TransportUrlRequest.swift in Sources */, 390E69712A136586007F2304 /* RequestEncodingNodeError.swift in Sources */, @@ -1458,6 +1457,7 @@ 90B60917283E1268006F4309 /* UrlChainsBuilder.swift in Sources */, 90B60915283E1268006F4309 /* UrlETagReaderNode.swift in Sources */, 90B60985283E1287006F4309 /* UrlRequestTrasformatorNode.swift in Sources */, + 5060A4962BC44225004E84E2 /* EntryInputDtoOutputNode.swift in Sources */, 390E69702A136586007F2304 /* NodeParameterEncoding.swift in Sources */, 502F9DA92BAB0CF000151A8D /* TokenRefresherActor.swift in Sources */, 90B60928283E1268006F4309 /* CancelableContext.swift in Sources */, diff --git a/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..e73431ffa --- /dev/null +++ b/NodeKit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "1d2e6911b0388532b33f83466feee8deadacbc6241719180eb45fd871a5091ac", + "pins" : [ + { + "identity" : "coreevents", + "kind" : "remoteSourceControl", + "location" : "https://github.com/surfstudio/CoreEvents", + "state" : { + "revision" : "35ea2dac82e61d7fa1fab1b10e0038d31ff3fd53", + "version" : "2.0.2" + } + } + ], + "version" : 3 +} diff --git a/NodeKit/Layers/InputProcessingLayer/EntryInputDtoOutputNode.swift b/NodeKit/Layers/InputProcessingLayer/EntryInputDtoOutputNode.swift new file mode 100644 index 000000000..296bc528d --- /dev/null +++ b/NodeKit/Layers/InputProcessingLayer/EntryInputDtoOutputNode.swift @@ -0,0 +1,42 @@ +// +// EntryinputDtoOutputNode.swift +// CoreNetKit +// +// Created by Александр Кравченков on 15/04/2019. +// Copyright © 2019 Кравченков Александр. All rights reserved. +// + +import Foundation + +open class EntryInputDtoOutputNode: AsyncNode + where Input: RawEncodable, Output: DTODecodable { + + open var next: any AsyncNode + + init(next: any AsyncNode) { + self.next = next + } + + open func processLegacy(_ data: Input) -> Observer { + do { + let raw = try data.toRaw() + return self.next.processLegacy(raw).map { try Output.from(dto: Output.DTO.from(raw: $0) ) } + } catch { + return .emit(error: error) + } + } + + open func process( + _ data: Input, + logContext: LoggingContextProtocol + ) async -> NodeResult { + return await .withMappedExceptions { + let raw = try data.toRaw() + return try await next.process(raw, logContext: logContext).map { + let dto = try Output.DTO.from(raw: $0) + return try Output.from(dto: dto) + } + } + } + +}