From bdd24a75f34965d71c26a60a9209444703672e2a Mon Sep 17 00:00:00 2001 From: Underthestars-zhy Date: Sat, 29 Apr 2023 21:03:13 +0800 Subject: [PATCH] makeing things public --- .../Collection/CollectionPlatformCount.swift | 16 +- .../Collection/CreateCollection.swift | 2 +- .../Collection/DeleteCollection.swift | 2 +- .../MobbinAPI/Collection/EditCollection.swift | 2 +- .../Collection/QueryAppsInCollection.swift | 2 +- .../Collection/QueryFlowsInCollection.swift | 2 +- .../Collection/QueryScreensInCollection.swift | 2 +- .../Collection/QureyCollections.swift | 2 +- Sources/MobbinAPI/Error/HTTPError.swift | 2 +- Sources/MobbinAPI/Error/MobbinError.swift | 2 +- Sources/MobbinAPI/IOS/GetIiOSApps.swift | 4 +- Sources/MobbinAPI/IOS/GetiOSDetails.swift | 4 +- Sources/MobbinAPI/IOS/iOSCount.swift | 6 +- Sources/MobbinAPI/MobbinAPI.swift | 4 +- Sources/MobbinAPI/Model/App.swift | 32 ++-- Sources/MobbinAPI/Model/Collection.swift | 168 +++++++++--------- Sources/MobbinAPI/Model/Flow.swift | 36 ++-- Sources/MobbinAPI/Model/Screen.swift | 18 +- Sources/MobbinAPI/Model/Token.swift | 4 +- Sources/MobbinAPI/Model/UserInfo.swift | 6 +- Sources/MobbinAPI/Model/Workspace.swift | 2 +- 21 files changed, 159 insertions(+), 159 deletions(-) diff --git a/Sources/MobbinAPI/Collection/CollectionPlatformCount.swift b/Sources/MobbinAPI/Collection/CollectionPlatformCount.swift index 5776eed..cf22b55 100644 --- a/Sources/MobbinAPI/Collection/CollectionPlatformCount.swift +++ b/Sources/MobbinAPI/Collection/CollectionPlatformCount.swift @@ -8,17 +8,17 @@ import Foundation import SwiftyJSON -struct PlatformCount: Equatable { - let mobileAppsCount: Int - let webAppsCount: Int - let mobileScreensCount: Int - let webScreensCount: Int - let mobileFlowsCount: Int - let webFlowsCount: Int +public struct PlatformCount: Equatable { + public let mobileAppsCount: Int + public let webAppsCount: Int + public let mobileScreensCount: Int + public let webScreensCount: Int + public let mobileFlowsCount: Int + public let webFlowsCount: Int } extension MobbinAPI { - func platformCount(of collection: Collection) async throws -> PlatformCount { + public func platformCount(of collection: Collection) async throws -> PlatformCount { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/collections_with_platform_counts") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Collection/CreateCollection.swift b/Sources/MobbinAPI/Collection/CreateCollection.swift index 18bb8e0..b4b1bec 100644 --- a/Sources/MobbinAPI/Collection/CreateCollection.swift +++ b/Sources/MobbinAPI/Collection/CreateCollection.swift @@ -8,7 +8,7 @@ import Foundation extension MobbinAPI { - func createCollection(in workspace: Workspace, name: String, description: String) async throws { + public func createCollection(in workspace: Workspace, name: String, description: String) async throws { guard let token else { throw MobbinError.cannotFindToken } guard let userInfo else { throw MobbinError.cannotFindToken } diff --git a/Sources/MobbinAPI/Collection/DeleteCollection.swift b/Sources/MobbinAPI/Collection/DeleteCollection.swift index 0cff320..fa360df 100644 --- a/Sources/MobbinAPI/Collection/DeleteCollection.swift +++ b/Sources/MobbinAPI/Collection/DeleteCollection.swift @@ -8,7 +8,7 @@ import Foundation extension MobbinAPI { - func delete(collection: Collection) async throws { + public func delete(collection: Collection) async throws { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/collections") else {return} diff --git a/Sources/MobbinAPI/Collection/EditCollection.swift b/Sources/MobbinAPI/Collection/EditCollection.swift index 5447d05..1a1b6f1 100644 --- a/Sources/MobbinAPI/Collection/EditCollection.swift +++ b/Sources/MobbinAPI/Collection/EditCollection.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func edit(collection: Collection, name: String?, description: String?) async throws -> Collection { + public func edit(collection: Collection, name: String?, description: String?) async throws -> Collection { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/collections") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Collection/QueryAppsInCollection.swift b/Sources/MobbinAPI/Collection/QueryAppsInCollection.swift index 622b461..d9eb708 100644 --- a/Sources/MobbinAPI/Collection/QueryAppsInCollection.swift +++ b/Sources/MobbinAPI/Collection/QueryAppsInCollection.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func queryApps(in collection: Collection) async throws -> [Collection.App] { + public func queryApps(in collection: Collection) async throws -> [Collection.App] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_apps_with_preview_screens_collection_filter") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Collection/QueryFlowsInCollection.swift b/Sources/MobbinAPI/Collection/QueryFlowsInCollection.swift index 354a368..21a8845 100644 --- a/Sources/MobbinAPI/Collection/QueryFlowsInCollection.swift +++ b/Sources/MobbinAPI/Collection/QueryFlowsInCollection.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func queryFlows(in collection: Collection) async throws -> [Collection.Flow] { + public func queryFlows(in collection: Collection) async throws -> [Collection.Flow] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_app_sections_with_app_screens_collection_filter") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Collection/QueryScreensInCollection.swift b/Sources/MobbinAPI/Collection/QueryScreensInCollection.swift index b847b92..05065ff 100644 --- a/Sources/MobbinAPI/Collection/QueryScreensInCollection.swift +++ b/Sources/MobbinAPI/Collection/QueryScreensInCollection.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func queryScreens(in collection: Collection) async throws -> [Collection.Screen] { + public func queryScreens(in collection: Collection) async throws -> [Collection.Screen] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_app_screens_with_app_info_collection_filter") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Collection/QureyCollections.swift b/Sources/MobbinAPI/Collection/QureyCollections.swift index 1d209ab..842a8d3 100644 --- a/Sources/MobbinAPI/Collection/QureyCollections.swift +++ b/Sources/MobbinAPI/Collection/QureyCollections.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func queryCollections() async throws -> [Collection] { + public func queryCollections() async throws -> [Collection] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/workspaces") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/Error/HTTPError.swift b/Sources/MobbinAPI/Error/HTTPError.swift index 0966b02..a8d497f 100644 --- a/Sources/MobbinAPI/Error/HTTPError.swift +++ b/Sources/MobbinAPI/Error/HTTPError.swift @@ -7,7 +7,7 @@ import Foundation -enum HTTPError: Error { +public enum HTTPError: Error { case wrongUrlFormat case badResponse } diff --git a/Sources/MobbinAPI/Error/MobbinError.swift b/Sources/MobbinAPI/Error/MobbinError.swift index 9e470cc..eb22b56 100644 --- a/Sources/MobbinAPI/Error/MobbinError.swift +++ b/Sources/MobbinAPI/Error/MobbinError.swift @@ -7,7 +7,7 @@ import Foundation -enum MobbinError: Error { +public enum MobbinError: Error { case emailProblem case cannotFindToken case cannotFindUserInfo diff --git a/Sources/MobbinAPI/IOS/GetIiOSApps.swift b/Sources/MobbinAPI/IOS/GetIiOSApps.swift index 5a3e7d4..76789bc 100644 --- a/Sources/MobbinAPI/IOS/GetIiOSApps.swift +++ b/Sources/MobbinAPI/IOS/GetIiOSApps.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func getAlliOSApps() async throws -> [App] { + public func getAlliOSApps() async throws -> [App] { guard let token else { throw MobbinError.cannotFindToken } var lastAppPublishedDate: Date? = nil @@ -115,7 +115,7 @@ extension MobbinAPI { return res } - func queryNextPage(_ app: App?) async throws -> [App] { + public func queryNextPage(_ app: App?) async throws -> [App] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_apps_with_preview_screens_filter") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/IOS/GetiOSDetails.swift b/Sources/MobbinAPI/IOS/GetiOSDetails.swift index 73e67f9..d82d666 100644 --- a/Sources/MobbinAPI/IOS/GetiOSDetails.swift +++ b/Sources/MobbinAPI/IOS/GetiOSDetails.swift @@ -9,7 +9,7 @@ import Foundation import SwiftyJSON extension MobbinAPI { - func getiOSScreens(of app: App) async throws -> [Screen] { + public func getiOSScreens(of app: App) async throws -> [Screen] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_app_screens_filter") else { throw HTTPError.wrongUrlFormat } @@ -83,7 +83,7 @@ extension MobbinAPI { } ?? [] } - func getiOSFlows(of app: App) async throws -> [Flow] { + public func getiOSFlows(of app: App) async throws -> [Flow] { guard let token else { throw MobbinError.cannotFindToken } guard var URL = URL(string: "https://ujasntkfphywizsdaapi.supabase.co/rest/v1/rpc/get_app_sections_filter") else { throw HTTPError.wrongUrlFormat } diff --git a/Sources/MobbinAPI/IOS/iOSCount.swift b/Sources/MobbinAPI/IOS/iOSCount.swift index 114adf9..a99b5ae 100644 --- a/Sources/MobbinAPI/IOS/iOSCount.swift +++ b/Sources/MobbinAPI/IOS/iOSCount.swift @@ -9,19 +9,19 @@ import Foundation import SwiftyJSON extension MobbinAPI { - var iOSAppsCount: Int { + public var iOSAppsCount: Int { get async throws { try await getiOSMetaInfo().0 } } - var iOSScreensCount: Int { + public var iOSScreensCount: Int { get async throws { try await getiOSMetaInfo().1 } } - var iOSFlowCount: Int { + public var iOSFlowCount: Int { get async throws { try await getiOSMetaInfo().2 } diff --git a/Sources/MobbinAPI/MobbinAPI.swift b/Sources/MobbinAPI/MobbinAPI.swift index 9cea35e..3e07ed6 100644 --- a/Sources/MobbinAPI/MobbinAPI.swift +++ b/Sources/MobbinAPI/MobbinAPI.swift @@ -6,12 +6,12 @@ public class MobbinAPI { var token: Token? = nil var userInfo: UserInfo? = nil - init(email: String, token: Token? = nil) { + public init(email: String, token: Token? = nil) { self.email = email self.token = token } - init(userInfo: UserInfo, token: Token? = nil) { + public init(userInfo: UserInfo, token: Token? = nil) { self.email = userInfo.email self.userInfo = userInfo self.token = token diff --git a/Sources/MobbinAPI/Model/App.swift b/Sources/MobbinAPI/Model/App.swift index a8e63cd..8eb47a4 100644 --- a/Sources/MobbinAPI/Model/App.swift +++ b/Sources/MobbinAPI/Model/App.swift @@ -7,20 +7,20 @@ import Foundation -struct App { - let id: String - let appName: String - let appCategory: String - let appStyle: String? - let appLogoUrl: URL - let appTagline: String - let companyHqRegion: String - let companyStage: String - let platform: String - let createdAt: Date - let appVersionId: String - let appVersionCreatedAt: Date - let appVersionUpdatedAt: Date - let appVersionPublishedAt: Date - let previewScreenUrls: [URL] +public struct App { + public let id: String + public let appName: String + public let appCategory: String + public let appStyle: String? + public let appLogoUrl: URL + public let appTagline: String + public let companyHqRegion: String + public let companyStage: String + public let platform: String + public let createdAt: Date + public let appVersionId: String + public let appVersionCreatedAt: Date + public let appVersionUpdatedAt: Date + public let appVersionPublishedAt: Date + public let previewScreenUrls: [URL] } diff --git a/Sources/MobbinAPI/Model/Collection.swift b/Sources/MobbinAPI/Model/Collection.swift index 101227b..a284f72 100644 --- a/Sources/MobbinAPI/Model/Collection.swift +++ b/Sources/MobbinAPI/Model/Collection.swift @@ -7,96 +7,96 @@ import Foundation -struct Collection { - let name: String - let id: String - let description: String - let updatedAt: Date - let createdAt: Date +public struct Collection { + public let name: String + public let id: String + public let description: String + public let updatedAt: Date + public let createdAt: Date - struct App { - let id: String - let appName: String - let appCategory: String - let appStyle: String? - let appLogoURL: URL - let appTagline: String - let companyHqRegion: String - let companyStage: String - let platform: String - let createdAt: Date - let appVersionID: String - let appVersionCreatedAt: Date - let appVersionUpdatedAt: Date - let appVersionPublishedAt: Date - let collectionAppID: String - let collectionID: String - let collectionAppCreatedAt: Date - let collectionAppUpdatedAt: Date - let previewScreenUrls: [URL] + public struct App { + public let id: String + public let appName: String + public let appCategory: String + public let appStyle: String? + public let appLogoURL: URL + public let appTagline: String + public let companyHqRegion: String + public let companyStage: String + public let platform: String + public let createdAt: Date + public let appVersionID: String + public let appVersionCreatedAt: Date + public let appVersionUpdatedAt: Date + public let appVersionPublishedAt: Date + public let collectionAppID: String + public let collectionID: String + public let collectionAppCreatedAt: Date + public let collectionAppUpdatedAt: Date + public let previewScreenUrls: [URL] } - struct Screen { - let id: String - let appID: String - let appName: String - let appCategory: String - let appStyle: String? - let appLogoURL: URL - let appTagline: String - let companyHqRegion: String - let companyStage: String - let platform: String - let appVersionID: String - let appVersionCreatedAt: Date - let appVersionUpdatedAt: Date - let appVersionPublishedAt: Date - let screenNumber: Int - let screenElements: [String] - let screenPatterns: [String] - let screenURL: URL - let createdAt: Date - let updatedAt: Date - let collectionID: String - let collectionAppScreenID: String - let collectionAppScreenUpdatedAt: Date + public struct Screen { + public let id: String + public let appID: String + public let appName: String + public let appCategory: String + public let appStyle: String? + public let appLogoURL: URL + public let appTagline: String + public let companyHqRegion: String + public let companyStage: String + public let platform: String + public let appVersionID: String + public let appVersionCreatedAt: Date + public let appVersionUpdatedAt: Date + public let appVersionPublishedAt: Date + public let screenNumber: Int + public let screenElements: [String] + public let screenPatterns: [String] + public let screenURL: URL + public let createdAt: Date + public let updatedAt: Date + public let collectionID: String + public let collectionAppScreenID: String + public let collectionAppScreenUpdatedAt: Date } - struct Flow: Codable { - struct Screen: Codable { - let id: String - let order: Int - let hotspotType: String? - let hotspotX: Double? - let hotspotY: Double? - let hotspotWidth: Double? - let hotspotHeight: Double? - let screenID: String - let screenElements: [String] - let screenPatterns: [String] - let screenURL: URL + public struct Flow: Codable { + public struct Screen: Codable { + public let id: String + public let order: Int + public let hotspotType: String? + public let hotspotX: Double? + public let hotspotY: Double? + public let hotspotWidth: Double? + public let hotspotHeight: Double? + public let screenID: String + public let screenElements: [String] + public let screenPatterns: [String] + public let screenURL: URL } - let id: String - let name: String - let actions: [String] - let order: Int - let appID: String - let appName: String - let appCategory: String - let appStyle: String? - let appLogoURL: URL - let appTagline: String - let companyHqRegion: String - let companyStage: String - let platform: String - let appVersionID: String - let appVersionCreatedAt: Date - let appVersionUpdatedAt: Date - let appVersionPublishedAt: Date - let collectionID: String - let collectionAppSectionID: String - let collectionAppSectionUpdatedAt: Date - let screens: [Screen] + public let id: String + public let name: String + public let actions: [String] + public let order: Int + public let appID: String + public let appName: String + public let appCategory: String + public let appStyle: String? + public let appLogoURL: URL + public let appTagline: String + public let companyHqRegion: String + public let companyStage: String + public let platform: String + public let appVersionID: String + public let appVersionCreatedAt: Date + public let appVersionUpdatedAt: Date + public let appVersionPublishedAt: Date + public let collectionID: String + public let collectionAppSectionID: String + public let collectionAppSectionUpdatedAt: Date + public let screens: [Screen] } } diff --git a/Sources/MobbinAPI/Model/Flow.swift b/Sources/MobbinAPI/Model/Flow.swift index 25751ef..b8b2130 100644 --- a/Sources/MobbinAPI/Model/Flow.swift +++ b/Sources/MobbinAPI/Model/Flow.swift @@ -7,24 +7,24 @@ import Foundation -struct Flow { - let id: String - let name: String - let actions: [String] - let parentAppSectionId: String? - let order: Int - let updatedAt: Date - let appVersionId: String - let screens: [Screen] +public struct Flow { + public let id: String + public let name: String + public let actions: [String] + public let parentAppSectionId: String? + public let order: Int + public let updatedAt: Date + public let appVersionId: String + public let screens: [Screen] - struct Screen { - let appScreenId: String - let order: Int - let hotspotWidth: Double? - let hotspotHeight: Double? - let hotspotX: Double? - let hotspotY: Double? - let hotspotType: String? - let screenUrl: URL + public struct Screen { + public let appScreenId: String + public let order: Int + public let hotspotWidth: Double? + public let hotspotHeight: Double? + public let hotspotX: Double? + public let hotspotY: Double? + public let hotspotType: String? + public let screenUrl: URL } } diff --git a/Sources/MobbinAPI/Model/Screen.swift b/Sources/MobbinAPI/Model/Screen.swift index 7c9d857..17182a4 100644 --- a/Sources/MobbinAPI/Model/Screen.swift +++ b/Sources/MobbinAPI/Model/Screen.swift @@ -7,13 +7,13 @@ import Foundation -struct Screen { - let screenNumber: Int - let screenUrl: URL - let appVersionId: String - let id: String - let screenElements: [String] - let screenPatterns: [String] - let updatedAt: Date - let createdAt: Date +public struct Screen { + public let screenNumber: Int + public let screenUrl: URL + public let appVersionId: String + public let id: String + public let screenElements: [String] + public let screenPatterns: [String] + public let updatedAt: Date + public let createdAt: Date } diff --git a/Sources/MobbinAPI/Model/Token.swift b/Sources/MobbinAPI/Model/Token.swift index 32e5597..1f505b5 100644 --- a/Sources/MobbinAPI/Model/Token.swift +++ b/Sources/MobbinAPI/Model/Token.swift @@ -8,12 +8,12 @@ import Foundation import SwiftyJSON -struct Token: Codable { +public struct Token: Codable { var accessToken: String var refreshToken: String var generatedTime: Date - init(accessToken: String, refreshToken: String) { + public init(accessToken: String, refreshToken: String) { self.accessToken = accessToken self.refreshToken = refreshToken self.generatedTime = Date() diff --git a/Sources/MobbinAPI/Model/UserInfo.swift b/Sources/MobbinAPI/Model/UserInfo.swift index 4a7b937..632981f 100644 --- a/Sources/MobbinAPI/Model/UserInfo.swift +++ b/Sources/MobbinAPI/Model/UserInfo.swift @@ -7,7 +7,7 @@ import Foundation -struct UserInfo { +public struct UserInfo: Codable { let id: String let aud: String let role: String @@ -18,7 +18,7 @@ struct UserInfo { let avatarUrl: URL let fullName: String - init(id: String, aud: String, role: String, email: String, emailConfirmedAt: Date, recoverySentAt: Date, lastSignInAt: Date, avatarUrl: URL, fullName: String) { + public init(id: String, aud: String, role: String, email: String, emailConfirmedAt: Date, recoverySentAt: Date, lastSignInAt: Date, avatarUrl: URL, fullName: String) { self.id = id self.aud = aud self.role = role @@ -30,7 +30,7 @@ struct UserInfo { self.fullName = fullName } - init?(id: String, aud: String, role: String, email: String, emailConfirmedAt: String, recoverySentAt: String, lastSignInAt: String, avatarUrl: String, fullName: String) { + public init?(id: String, aud: String, role: String, email: String, emailConfirmedAt: String, recoverySentAt: String, lastSignInAt: String, avatarUrl: String, fullName: String) { guard let emailConfirmedAt = Date.create(login: emailConfirmedAt) else { return nil } guard let recoverySentAt = Date.create(login: recoverySentAt) else { return nil } guard let lastSignInAt = Date.create(login: lastSignInAt) else { return nil } diff --git a/Sources/MobbinAPI/Model/Workspace.swift b/Sources/MobbinAPI/Model/Workspace.swift index 8c98cb7..4a8ee84 100644 --- a/Sources/MobbinAPI/Model/Workspace.swift +++ b/Sources/MobbinAPI/Model/Workspace.swift @@ -7,7 +7,7 @@ import Foundation -struct Workspace { +public struct Workspace { let name: String let id: String let type: String