Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ coverage:
status:
patch:
default:
target: 49
target: auto
changes: false
project:
default:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.5.0...main)
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.5.1...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_

### 1.5.1
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.5.0...1.5.1)

__Improvements__
- Update ParseError to match server and make ParseError and ParseObject Pointer documentation public ([#125](https://github.com/parse-community/Parse-Swift/pull/125)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.5.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.4.0...1.5.0)

Expand Down
2 changes: 1 addition & 1 deletion ParseSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ParseSwift"
s.version = "1.5.0"
s.version = "1.5.1"
s.summary = "Parse Pure Swift SDK"
s.homepage = "https://github.com/parse-community/Parse-Swift"
s.authors = {
Expand Down
24 changes: 16 additions & 8 deletions ParseSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@
70DFEA8A2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
70DFEA8B2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
70DFEA8C2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
70E09E1C262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
70E09E1D262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
70E09E1E262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
70F2E255254F247000B2EA5C /* ParseSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFDA7121F26D9A5002AE4FC /* ParseSwift.framework */; };
70F2E2B3254F283000B2EA5C /* ParseUserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1D24D20E530050419B /* ParseUserTests.swift */; };
70F2E2B4254F283000B2EA5C /* ParseQueryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1F24D20F180050419B /* ParseQueryTests.swift */; };
Expand Down Expand Up @@ -636,6 +639,7 @@
70D1BE0625BB2BF400A42E7C /* ParseConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseConfigTests.swift; sourceTree = "<group>"; };
70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseConfig.swift; sourceTree = "<group>"; };
70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitializeSDKTests.swift; sourceTree = "<group>"; };
70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsePointerCombineTests.swift; sourceTree = "<group>"; };
70F2E23E254F246000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
70F2E250254F247000B2EA5C /* ParseSwiftTestsmacOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ParseSwiftTestsmacOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
70F2E254254F247000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -843,6 +847,7 @@
911DB13524C4FC100027F3C7 /* ParseObjectTests.swift */,
7044C1EB25C5CC930011F6E7 /* ParseOperationCombineTests.swift */,
70C5508425B4A68700B5DBC2 /* ParseOperationTests.swift */,
70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */,
70CE1D882545BF730018D572 /* ParsePointerTests.swift */,
7044C20525C5D6780011F6E7 /* ParseQueryCombineTests.swift */,
70C7DC1F24D20F180050419B /* ParseQueryTests.swift */,
Expand Down Expand Up @@ -1665,6 +1670,7 @@
buildActionMask = 2147483647;
files = (
911DB13624C4FC100027F3C7 /* ParseObjectTests.swift in Sources */,
70E09E1C262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D592603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
70CE1D892545BF730018D572 /* ParsePointerTests.swift in Sources */,
89899D772603CF66002E2043 /* ParseFacebookTests.swift in Sources */,
Expand Down Expand Up @@ -1817,6 +1823,7 @@
buildActionMask = 2147483647;
files = (
709B98512556ECAA00507778 /* ParseEncoderTests.swift in Sources */,
70E09E1E262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D642603CF3F002E2043 /* ParseTwitterTests.swift in Sources */,
709B98532556ECAA00507778 /* ParsePointerTests.swift in Sources */,
89899D822603CF67002E2043 /* ParseFacebookTests.swift in Sources */,
Expand Down Expand Up @@ -1872,6 +1879,7 @@
buildActionMask = 2147483647;
files = (
70F2E2B6254F283000B2EA5C /* ParseACLTests.swift in Sources */,
70E09E1D262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
89899D632603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
70F2E2B7254F283000B2EA5C /* ParsePointerTests.swift in Sources */,
89899D812603CF67002E2043 /* ParseFacebookTests.swift in Sources */,
Expand Down Expand Up @@ -2329,7 +2337,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand All @@ -2353,7 +2361,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -2419,7 +2427,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand All @@ -2445,7 +2453,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand Down Expand Up @@ -2592,7 +2600,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
Expand Down Expand Up @@ -2621,7 +2629,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
PRODUCT_NAME = ParseSwift;
Expand All @@ -2648,7 +2656,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
Expand Down Expand Up @@ -2676,7 +2684,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.5.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
PRODUCT_NAME = ParseSwift;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/jazzy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bundle exec jazzy \
--author_url http://parseplatform.org \
--github_url https://github.com/parse-community/Parse-Swift \
--root-url http://parseplatform.org/Parse-Swift/api/ \
--module-version 1.5.0 \
--module-version 1.5.1 \
--theme fullwidth \
--skip-undocumented \
--output ./docs/api \
Expand Down
1 change: 0 additions & 1 deletion Sources/ParseSwift/Objects/ParseObject+combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public extension ParseObject {
`includeAll` for `Query`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
- important: If an object fetched has the same objectId as current, it will automatically update the current.
*/
func fetchPublisher(includeKeys: [String]? = nil,
options: API.Options = []) -> Future<Self, ParseError> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

enum ParseConstants {
static let parseVersion = "1.5.0"
static let parseVersion = "1.5.1"
static let hashingKey = "parseSwift"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
Expand Down
9 changes: 7 additions & 2 deletions Sources/ParseSwift/Protocols/Fetchable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
// Copyright © 2020 Parse. All rights reserved.
//

import Foundation
#if canImport(Combine)
import Combine
#endif

public protocol Fetchable: Decodable {
associatedtype FetchingType

func fetch(includeKeys: [String]?, options: API.Options) throws -> FetchingType
func fetch() throws -> FetchingType
}

extension Fetchable {
public func fetch() throws -> FetchingType {
public extension Fetchable {
func fetch() throws -> FetchingType {
try fetch(includeKeys: nil, options: [])
}
}
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Storage/ParseStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

// MARK: ParseStorage
public struct ParseStorage {
struct ParseStorage {
public static var shared = ParseStorage()

private var backingStore: ParseKeyValueStore!
Expand Down
4 changes: 4 additions & 0 deletions Sources/ParseSwift/Types/ParseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

import Foundation

/*
An object with a Parse code and message.
*/
public struct ParseError: ParseType, Decodable, Swift.Error {
public let code: Code
public let message: String

/// A textual representation of this error.
public var localizedDescription: String {
return "ParseError code=\(code.rawValue) error=\(message)"
}
Expand Down
72 changes: 67 additions & 5 deletions Sources/ParseSwift/Types/Pointer.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if canImport(Combine)
import Combine
#endif

private func getObjectId<T: ParseObject>(target: T) throws -> String {
guard let objectId = target.objectId else {
Expand All @@ -14,18 +17,34 @@ private func getObjectId(target: Objectable) throws -> String {
return objectId
}

/// A Pointer referencing a ParseObject.
public struct Pointer<T: ParseObject>: Fetchable, Encodable {
public typealias FetchingType = T

private let __type: String = "Pointer" // swiftlint:disable:this identifier_name

/**
The id of the object.
*/
public var objectId: String

/**
The class name of the object.
*/
public var className: String

/**
Create a Pointer type.
- parameter target: Object to point to.
*/
public init(_ target: T) throws {
self.objectId = try getObjectId(target: target)
self.className = target.className
}

/**
Create a Pointer type.
- parameter objectId: The id of the object.
*/
public init(objectId: String) {
self.className = T.className
self.objectId = objectId
Expand All @@ -42,17 +61,39 @@ public struct Pointer<T: ParseObject>: Fetchable, Encodable {
}
}

extension Pointer {
public func fetch(includeKeys: [String]? = nil, options: API.Options = []) throws -> T {
public extension Pointer {

/**
Fetches the `ParseObject` *synchronously* with the current data from the server and sets an error if one occurs.
- parameter includeKeys: The name(s) of the key(s) to include that are
`ParseObject`s. Use `["*"]` to include all keys. This is similar to `include` and
`includeAll` for `Query`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- throws: An error of `ParseError` type.
*/
func fetch(includeKeys: [String]? = nil,
options: API.Options = []) throws -> T {
let path = API.Endpoint.object(className: className, objectId: objectId)
return try API.NonParseBodyCommand<NoBody, T>(method: .GET,
path: path) { (data) -> T in
try ParseCoding.jsonDecoder().decode(T.self, from: data)
}.execute(options: options)
}

public func fetch(options: API.Options = [], callbackQueue: DispatchQueue = .main,
completion: @escaping (Result<T, ParseError>) -> Void) {
/**
Fetches the `ParseObject` *asynchronously* and executes the given callback block.
- parameter includeKeys: The name(s) of the key(s) to include. Use `["*"]` to include
all keys.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- parameter callbackQueue: The queue to return to after completion. Default
value of .main.
- parameter completion: The block to execute when completed.
It should have the following argument signature: `(Result<Self, ParseError>)`.
*/
func fetch(includeKeys: [String]? = nil,
options: API.Options = [],
callbackQueue: DispatchQueue = .main,
completion: @escaping (Result<T, ParseError>) -> Void) {
let path = API.Endpoint.object(className: className, objectId: objectId)
API.NonParseBodyCommand<NoBody, T>(method: .GET,
path: path) { (data) -> T in
Expand All @@ -63,6 +104,27 @@ extension Pointer {
}
}
}

#if canImport(Combine)
/**
Fetches the `ParseObject` *aynchronously* with the current data from the server and sets an error if one occurs.
Publishes when complete.
- parameter includeKeys: The name(s) of the key(s) to include that are
`ParseObject`s. Use `["*"]` to include all keys. This is similar to `include` and
`includeAll` for `Query`.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
@available(macOS 10.15, iOS 13.0, macCatalyst 13.0, watchOS 6.0, tvOS 13.0, *)
func fetchPublisher(includeKeys: [String]? = nil,
options: API.Options = []) -> Future<T, ParseError> {
Future { promise in
self.fetch(includeKeys: includeKeys,
options: options,
completion: promise)
}
}
#endif
}

internal struct PointerType: Encodable {
Expand Down
Loading