-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
3,034 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/config/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
8 changes: 8 additions & 0 deletions
8
.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "bson", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/orlandos-nl/BSON.git", | ||
"state" : { | ||
"revision" : "944dfb3b0eb028f477c25ba6a071181de8ab903a", | ||
"version" : "8.0.10" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-atomics", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-atomics.git", | ||
"state" : { | ||
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036", | ||
"version" : "1.0.3" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-case-paths", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/pointfreeco/swift-case-paths", | ||
"state" : { | ||
"revision" : "870133b7b2387df136ad301ec67b2e864b51dda1", | ||
"version" : "0.14.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-collections", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-collections", | ||
"state" : { | ||
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", | ||
"version" : "1.0.4" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio.git", | ||
"state" : { | ||
"revision" : "9b2848d76f5caad08b97e71a04345aa5bdb23a06", | ||
"version" : "2.49.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-parsing", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/pointfreeco/swift-parsing", | ||
"state" : { | ||
"revision" : "c6e2241daa46e5c6e5027a93b161bca6ba692bcc", | ||
"version" : "0.12.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-url-routing", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/pointfreeco/swift-url-routing.git", | ||
"state" : { | ||
"revision" : "2f4f0404b3de0a0711feb7190f724d8a80bc1cfd", | ||
"version" : "0.5.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "xctest-dynamic-overlay", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", | ||
"state" : { | ||
"revision" : "ab8c9f45843694dd16be4297e6d44c0634fd9913", | ||
"version" : "0.8.4" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// swift-tools-version: 5.8 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "LPGSharedModels", | ||
platforms: [ | ||
.iOS(.v16), | ||
.macOS(.v12) | ||
], | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "LPGSharedModels", | ||
targets: ["LPGSharedModels"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/pointfreeco/swift-url-routing.git", from: "0.5.0"), | ||
.package(url: "https://github.com/orlandos-nl/BSON.git", from: "8.0.9") | ||
], | ||
targets: [ | ||
.target( | ||
name: "LPGSharedModels", | ||
dependencies: [ | ||
.product(name: "URLRouting", package: "swift-url-routing"), | ||
.product(name: "BSON", package: "BSON") | ||
] | ||
), | ||
.testTarget( | ||
name: "LPGSharedModelsTests", | ||
dependencies: ["LPGSharedModels"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Foundation | ||
|
||
extension Encodable { | ||
public var jsonData: Data? { | ||
let encoder = JSONEncoder() | ||
encoder.dateEncodingStrategy = .iso8601 | ||
do { | ||
return try encoder.encode(self) | ||
} catch { | ||
debugPrint("\(error)") | ||
return nil | ||
} | ||
} | ||
|
||
public var jsonString: String? { | ||
guard let data = self.jsonData else { return nil } | ||
return String(data: data, encoding: .utf8) | ||
} | ||
} | ||
|
||
|
||
|
||
extension Decodable { | ||
|
||
static public func from(json: String, using encoding: String.Encoding = .utf8) -> Self? { | ||
guard let data = json.data(using: encoding) else { return nil } | ||
return Self.from(data: data) | ||
} | ||
|
||
static public func from(data: Data) -> Self? { | ||
|
||
do { | ||
return try JSONDecoder().decode(Self.self, from: data) | ||
} catch { | ||
debugPrint("\(error)") | ||
return nil | ||
} | ||
} | ||
|
||
static public func decode(json: String, using usingForWebRtcingEncoding: String.Encoding = .utf8) -> Self? { | ||
guard let data = json.data(using: usingForWebRtcingEncoding) else { return nil } | ||
return Self.decode(data: data) | ||
} | ||
|
||
static public func decode(data usingForWebRtcingData: Data) -> Self? { | ||
let decoder = JSONDecoder() | ||
decoder.dateDecodingStrategy = .iso8601 | ||
|
||
do { | ||
return try decoder.decode(Self.self, from: usingForWebRtcingData) | ||
} catch { | ||
debugPrint("\(error)") | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Saroar Khandoker on 29.11.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Data { | ||
func toHexString() -> String { | ||
return map { String(format: "%02.2hhx", $0) }.joined() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Saroar Khandoker on 12.10.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
import Foundation | ||
|
||
extension String: CodingKey { | ||
public var stringValue: String { | ||
return self | ||
} | ||
|
||
public var intValue: Int? { | ||
return Int(self) | ||
} | ||
|
||
public init?(intValue: Int) { | ||
self.init(intValue.description) | ||
} | ||
|
||
public init?(stringValue: String) { | ||
self.init(stringValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Foundation | ||
|
||
extension URL { | ||
static public var home: URL { | ||
return .init(string: "http://0.0.0.0:8080")! | ||
} | ||
|
||
static public var empty: URL = .init(string: "")! | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public struct LPGSharedModels { | ||
public private(set) var text = "Hello, World!" | ||
|
||
public init() {} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
Sources/LPGSharedModels/Models/Attachment/Attachment.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
import Foundation | ||
import BSON | ||
|
||
public enum AttachmentType: String, Codable { | ||
case file, image, audio, video | ||
} | ||
|
||
public struct AttachmentInOutPut: Codable { | ||
|
||
public var id: ObjectId? | ||
public var type: AttachmentType | ||
public var userId: ObjectId? | ||
public var swapId: ObjectId? | ||
public var conversationId: ObjectId? | ||
public var imageUrlString: String? | ||
public var audioUrlString: String? | ||
public var videoUrlString: String? | ||
public var fileUrlString: String? | ||
public var createdAt: Date? | ||
public var updatedAt: Date? | ||
public var deletedAt: Date? | ||
|
||
public init( | ||
id: ObjectId? = nil, | ||
type: AttachmentType, | ||
userId: ObjectId? = nil, | ||
swapId: ObjectId? = nil, | ||
conversationId: ObjectId? = nil, | ||
imageUrlString: String? = nil, | ||
audioUrlString: String? = nil, | ||
videoUrlString: String? = nil, | ||
fileUrlString: String? = nil, | ||
createdAt: Date? = nil, | ||
updatedAt: Date? = nil, | ||
deletedAt: Date? = nil | ||
) { | ||
self.id = id | ||
self.type = type | ||
self.userId = userId | ||
self.swapId = swapId | ||
self.imageUrlString = imageUrlString | ||
self.audioUrlString = audioUrlString | ||
self.videoUrlString = videoUrlString | ||
self.fileUrlString = fileUrlString | ||
self.createdAt = createdAt | ||
self.updatedAt = updatedAt | ||
self.deletedAt = deletedAt | ||
} | ||
|
||
} | ||
|
||
extension AttachmentInOutPut: Identifiable {} | ||
|
||
extension AttachmentInOutPut: Equatable { | ||
public static func < (lhs: AttachmentInOutPut, rhs: AttachmentInOutPut) -> Bool { | ||
guard let lhsDate = lhs.updatedAt, let rhsDate = rhs.createdAt else { return false } | ||
return lhsDate > rhsDate | ||
} | ||
} | ||
|
||
extension AttachmentInOutPut: Hashable {} |
61 changes: 61 additions & 0 deletions
61
Sources/LPGSharedModels/Models/Attachment/AttachmentMocks.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Foundation | ||
import BSON | ||
|
||
extension AttachmentInOutPut { | ||
static public var image1: AttachmentInOutPut = .init( | ||
id: ObjectId("5fb6736c1432f950f8ea2d33"), | ||
type: .image, | ||
userId: UserOutput.withFirstName.id, | ||
imageUrlString: | ||
"https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/5fabb05d2470c17919b3c0e2_1605792619988.jpeg", | ||
audioUrlString: nil, | ||
videoUrlString: nil, | ||
fileUrlString: nil, | ||
createdAt: nil, | ||
updatedAt: nil | ||
) | ||
|
||
static public var image2: AttachmentInOutPut = .init( | ||
id: ObjectId("5fb681d6fb999dc956323a05"), | ||
type: .image, | ||
userId: UserOutput.withFirstName.id, | ||
imageUrlString: | ||
"https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb1ebaa5f5774ccfe48c3/1605876343603.jpeg", | ||
audioUrlString: nil, videoUrlString: nil, fileUrlString: nil, createdAt: nil, updatedAt: nil) | ||
|
||
static public var image3: AttachmentInOutPut = .init( | ||
id: ObjectId("5fb6bba4d62847cc58a5218a"), | ||
type: .image, | ||
userId: UserOutput.withNumber.id, | ||
imageUrlString: | ||
"https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/1605811106589.jpeg", | ||
createdAt: nil, updatedAt: nil | ||
) | ||
|
||
static public var image4: AttachmentInOutPut = .init( | ||
id: ObjectId("5fb6bc48d63734254b0eb777"), | ||
type: .image, | ||
userId: UserOutput.withNumber.id, | ||
imageUrlString: | ||
"https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/1605811270871.jpeg", | ||
fileUrlString: nil, | ||
createdAt: nil, updatedAt: nil | ||
) | ||
|
||
|
||
// Attachment( | ||
// id: "5fb7b5e0d54eaebe3d264ace", type: .image, userId: "5fabb05d2470c17919b3c0e2", | ||
// imageUrlString: | ||
// "https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/1605875164101.heic", | ||
// audioUrlString: nil, videoUrlString: nil, fileUrlString: nil, createdAt: nil, updatedAt: nil), | ||
// Attachment( | ||
// id: "5fce0931ed6264cb3536a7cb", type: .image, userId: "5fabb05d2470c17919b3c0e2", | ||
// imageUrlString: | ||
// "https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/1607338279849.heic", | ||
// audioUrlString: nil, videoUrlString: nil, fileUrlString: nil, createdAt: nil, updatedAt: nil), | ||
// Attachment( | ||
// id: "5fce094221b4a84f64924bf3", type: .image, userId: "5fabb05d2470c17919b3c0e2", | ||
// imageUrlString: | ||
// "https://adda.nyc3.digitaloceanspaces.com/uploads/images/5fabb05d2470c17919b3c0e2/1607338304864.heic", | ||
// audioUrlString: nil, videoUrlString: nil, fileUrlString: nil, createdAt: nil, updatedAt: nil), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
extension RefreshTokenResponse { | ||
static public var draff: RefreshTokenResponse = .init(accessToken: "", refreshToken: "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import BSON | ||
|
||
public struct NewUserInOutPut: Codable { | ||
public init(id: ObjectId?, firstName: String?, lastName: String?, phoneNumber: String) { | ||
self.id = id | ||
self.firstName = firstName | ||
self.lastName = lastName | ||
self.phoneNumber = phoneNumber | ||
} | ||
|
||
public let id: ObjectId? | ||
public let firstName, lastName: String? | ||
public let phoneNumber: String | ||
} |
Oops, something went wrong.