Skip to content

Commit 702f92a

Browse files
authored
Add missing docs for ParseError and Pointer (#125)
* Add missing docs for ParseError and Pointer * nits * Update .codecov.yml * prepare for release * Add entry in changelog * Update changelog * Add Pointer fetch publisher and docs * Sort files * codecov
1 parent d1d2ea1 commit 702f92a

File tree

13 files changed

+235
-24
lines changed

13 files changed

+235
-24
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ coverage:
55
status:
66
patch:
77
default:
8-
target: 49
8+
target: auto
99
changes: false
1010
project:
1111
default:

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Parse-Swift Changelog
22

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

7+
### 1.5.1
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.5.0...1.5.1)
9+
10+
__Improvements__
11+
- 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).
12+
713
### 1.5.0
814
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.4.0...1.5.0)
915

ParseSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ParseSwift"
3-
s.version = "1.5.0"
3+
s.version = "1.5.1"
44
s.summary = "Parse Pure Swift SDK"
55
s.homepage = "https://github.com/parse-community/Parse-Swift"
66
s.authors = {

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@
298298
70DFEA8A2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
299299
70DFEA8B2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
300300
70DFEA8C2618E77800F8EB4B /* InitializeSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */; };
301+
70E09E1C262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
302+
70E09E1D262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
303+
70E09E1E262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */; };
301304
70F2E255254F247000B2EA5C /* ParseSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AFDA7121F26D9A5002AE4FC /* ParseSwift.framework */; };
302305
70F2E2B3254F283000B2EA5C /* ParseUserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1D24D20E530050419B /* ParseUserTests.swift */; };
303306
70F2E2B4254F283000B2EA5C /* ParseQueryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70C7DC1F24D20F180050419B /* ParseQueryTests.swift */; };
@@ -636,6 +639,7 @@
636639
70D1BE0625BB2BF400A42E7C /* ParseConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseConfigTests.swift; sourceTree = "<group>"; };
637640
70D1BE7225BB43EB00A42E7C /* BaseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseConfig.swift; sourceTree = "<group>"; };
638641
70DFEA892618E77800F8EB4B /* InitializeSDKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitializeSDKTests.swift; sourceTree = "<group>"; };
642+
70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsePointerCombineTests.swift; sourceTree = "<group>"; };
639643
70F2E23E254F246000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
640644
70F2E250254F247000B2EA5C /* ParseSwiftTestsmacOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ParseSwiftTestsmacOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
641645
70F2E254254F247000B2EA5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -843,6 +847,7 @@
843847
911DB13524C4FC100027F3C7 /* ParseObjectTests.swift */,
844848
7044C1EB25C5CC930011F6E7 /* ParseOperationCombineTests.swift */,
845849
70C5508425B4A68700B5DBC2 /* ParseOperationTests.swift */,
850+
70E09E1B262F0634002DD451 /* ParsePointerCombineTests.swift */,
846851
70CE1D882545BF730018D572 /* ParsePointerTests.swift */,
847852
7044C20525C5D6780011F6E7 /* ParseQueryCombineTests.swift */,
848853
70C7DC1F24D20F180050419B /* ParseQueryTests.swift */,
@@ -1665,6 +1670,7 @@
16651670
buildActionMask = 2147483647;
16661671
files = (
16671672
911DB13624C4FC100027F3C7 /* ParseObjectTests.swift in Sources */,
1673+
70E09E1C262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
16681674
89899D592603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
16691675
70CE1D892545BF730018D572 /* ParsePointerTests.swift in Sources */,
16701676
89899D772603CF66002E2043 /* ParseFacebookTests.swift in Sources */,
@@ -1817,6 +1823,7 @@
18171823
buildActionMask = 2147483647;
18181824
files = (
18191825
709B98512556ECAA00507778 /* ParseEncoderTests.swift in Sources */,
1826+
70E09E1E262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
18201827
89899D642603CF3F002E2043 /* ParseTwitterTests.swift in Sources */,
18211828
709B98532556ECAA00507778 /* ParsePointerTests.swift in Sources */,
18221829
89899D822603CF67002E2043 /* ParseFacebookTests.swift in Sources */,
@@ -1872,6 +1879,7 @@
18721879
buildActionMask = 2147483647;
18731880
files = (
18741881
70F2E2B6254F283000B2EA5C /* ParseACLTests.swift in Sources */,
1882+
70E09E1D262F0634002DD451 /* ParsePointerCombineTests.swift in Sources */,
18751883
89899D632603CF3E002E2043 /* ParseTwitterTests.swift in Sources */,
18761884
70F2E2B7254F283000B2EA5C /* ParsePointerTests.swift in Sources */,
18771885
89899D812603CF67002E2043 /* ParseFacebookTests.swift in Sources */,
@@ -2329,7 +2337,7 @@
23292337
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
23302338
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23312339
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2332-
MARKETING_VERSION = 1.5.0;
2340+
MARKETING_VERSION = 1.5.1;
23332341
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
23342342
PRODUCT_NAME = ParseSwift;
23352343
SKIP_INSTALL = YES;
@@ -2353,7 +2361,7 @@
23532361
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
23542362
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23552363
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2356-
MARKETING_VERSION = 1.5.0;
2364+
MARKETING_VERSION = 1.5.1;
23572365
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
23582366
PRODUCT_NAME = ParseSwift;
23592367
SKIP_INSTALL = YES;
@@ -2419,7 +2427,7 @@
24192427
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24202428
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
24212429
MACOSX_DEPLOYMENT_TARGET = 10.13;
2422-
MARKETING_VERSION = 1.5.0;
2430+
MARKETING_VERSION = 1.5.1;
24232431
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24242432
PRODUCT_NAME = ParseSwift;
24252433
SDKROOT = macosx;
@@ -2445,7 +2453,7 @@
24452453
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24462454
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
24472455
MACOSX_DEPLOYMENT_TARGET = 10.13;
2448-
MARKETING_VERSION = 1.5.0;
2456+
MARKETING_VERSION = 1.5.1;
24492457
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24502458
PRODUCT_NAME = ParseSwift;
24512459
SDKROOT = macosx;
@@ -2592,7 +2600,7 @@
25922600
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
25932601
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
25942602
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2595-
MARKETING_VERSION = 1.5.0;
2603+
MARKETING_VERSION = 1.5.1;
25962604
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
25972605
MTL_FAST_MATH = YES;
25982606
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
@@ -2621,7 +2629,7 @@
26212629
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
26222630
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26232631
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2624-
MARKETING_VERSION = 1.5.0;
2632+
MARKETING_VERSION = 1.5.1;
26252633
MTL_FAST_MATH = YES;
26262634
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
26272635
PRODUCT_NAME = ParseSwift;
@@ -2648,7 +2656,7 @@
26482656
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
26492657
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26502658
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2651-
MARKETING_VERSION = 1.5.0;
2659+
MARKETING_VERSION = 1.5.1;
26522660
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
26532661
MTL_FAST_MATH = YES;
26542662
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
@@ -2676,7 +2684,7 @@
26762684
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
26772685
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26782686
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2679-
MARKETING_VERSION = 1.5.0;
2687+
MARKETING_VERSION = 1.5.1;
26802688
MTL_FAST_MATH = YES;
26812689
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
26822690
PRODUCT_NAME = ParseSwift;

Scripts/jazzy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bundle exec jazzy \
55
--author_url http://parseplatform.org \
66
--github_url https://github.com/parse-community/Parse-Swift \
77
--root-url http://parseplatform.org/Parse-Swift/api/ \
8-
--module-version 1.5.0 \
8+
--module-version 1.5.1 \
99
--theme fullwidth \
1010
--skip-undocumented \
1111
--output ./docs/api \

Sources/ParseSwift/Objects/ParseObject+combine.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public extension ParseObject {
2222
`includeAll` for `Query`.
2323
- parameter options: A set of header options sent to the server. Defaults to an empty set.
2424
- returns: A publisher that eventually produces a single value and then finishes or fails.
25-
- important: If an object fetched has the same objectId as current, it will automatically update the current.
2625
*/
2726
func fetchPublisher(includeKeys: [String]? = nil,
2827
options: API.Options = []) -> Future<Self, ParseError> {

Sources/ParseSwift/ParseConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
enum ParseConstants {
12-
static let parseVersion = "1.5.0"
12+
static let parseVersion = "1.5.1"
1313
static let hashingKey = "parseSwift"
1414
static let fileManagementDirectory = "parse/"
1515
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"

Sources/ParseSwift/Protocols/Fetchable.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
// Copyright © 2020 Parse. All rights reserved.
77
//
88

9+
import Foundation
10+
#if canImport(Combine)
11+
import Combine
12+
#endif
13+
914
public protocol Fetchable: Decodable {
1015
associatedtype FetchingType
1116

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

16-
extension Fetchable {
17-
public func fetch() throws -> FetchingType {
21+
public extension Fetchable {
22+
func fetch() throws -> FetchingType {
1823
try fetch(includeKeys: nil, options: [])
1924
}
2025
}

Sources/ParseSwift/Storage/ParseStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
// MARK: ParseStorage
9-
public struct ParseStorage {
9+
struct ParseStorage {
1010
public static var shared = ParseStorage()
1111

1212
private var backingStore: ParseKeyValueStore!

Sources/ParseSwift/Types/ParseError.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
import Foundation
1010

11+
/*
12+
An object with a Parse code and message.
13+
*/
1114
public struct ParseError: ParseType, Decodable, Swift.Error {
1215
public let code: Code
1316
public let message: String
1417

18+
/// A textual representation of this error.
1519
public var localizedDescription: String {
1620
return "ParseError code=\(code.rawValue) error=\(message)"
1721
}

Sources/ParseSwift/Types/Pointer.swift

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import Foundation
2+
#if canImport(Combine)
3+
import Combine
4+
#endif
25

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

20+
/// A Pointer referencing a ParseObject.
1721
public struct Pointer<T: ParseObject>: Fetchable, Encodable {
18-
public typealias FetchingType = T
1922

2023
private let __type: String = "Pointer" // swiftlint:disable:this identifier_name
24+
25+
/**
26+
The id of the object.
27+
*/
2128
public var objectId: String
29+
30+
/**
31+
The class name of the object.
32+
*/
2233
public var className: String
2334

35+
/**
36+
Create a Pointer type.
37+
- parameter target: Object to point to.
38+
*/
2439
public init(_ target: T) throws {
2540
self.objectId = try getObjectId(target: target)
2641
self.className = target.className
2742
}
2843

44+
/**
45+
Create a Pointer type.
46+
- parameter objectId: The id of the object.
47+
*/
2948
public init(objectId: String) {
3049
self.className = T.className
3150
self.objectId = objectId
@@ -42,17 +61,39 @@ public struct Pointer<T: ParseObject>: Fetchable, Encodable {
4261
}
4362
}
4463

45-
extension Pointer {
46-
public func fetch(includeKeys: [String]? = nil, options: API.Options = []) throws -> T {
64+
public extension Pointer {
65+
66+
/**
67+
Fetches the `ParseObject` *synchronously* with the current data from the server and sets an error if one occurs.
68+
- parameter includeKeys: The name(s) of the key(s) to include that are
69+
`ParseObject`s. Use `["*"]` to include all keys. This is similar to `include` and
70+
`includeAll` for `Query`.
71+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
72+
- throws: An error of `ParseError` type.
73+
*/
74+
func fetch(includeKeys: [String]? = nil,
75+
options: API.Options = []) throws -> T {
4776
let path = API.Endpoint.object(className: className, objectId: objectId)
4877
return try API.NonParseBodyCommand<NoBody, T>(method: .GET,
4978
path: path) { (data) -> T in
5079
try ParseCoding.jsonDecoder().decode(T.self, from: data)
5180
}.execute(options: options)
5281
}
5382

54-
public func fetch(options: API.Options = [], callbackQueue: DispatchQueue = .main,
55-
completion: @escaping (Result<T, ParseError>) -> Void) {
83+
/**
84+
Fetches the `ParseObject` *asynchronously* and executes the given callback block.
85+
- parameter includeKeys: The name(s) of the key(s) to include. Use `["*"]` to include
86+
all keys.
87+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
88+
- parameter callbackQueue: The queue to return to after completion. Default
89+
value of .main.
90+
- parameter completion: The block to execute when completed.
91+
It should have the following argument signature: `(Result<Self, ParseError>)`.
92+
*/
93+
func fetch(includeKeys: [String]? = nil,
94+
options: API.Options = [],
95+
callbackQueue: DispatchQueue = .main,
96+
completion: @escaping (Result<T, ParseError>) -> Void) {
5697
let path = API.Endpoint.object(className: className, objectId: objectId)
5798
API.NonParseBodyCommand<NoBody, T>(method: .GET,
5899
path: path) { (data) -> T in
@@ -63,6 +104,27 @@ extension Pointer {
63104
}
64105
}
65106
}
107+
108+
#if canImport(Combine)
109+
/**
110+
Fetches the `ParseObject` *aynchronously* with the current data from the server and sets an error if one occurs.
111+
Publishes when complete.
112+
- parameter includeKeys: The name(s) of the key(s) to include that are
113+
`ParseObject`s. Use `["*"]` to include all keys. This is similar to `include` and
114+
`includeAll` for `Query`.
115+
- parameter options: A set of header options sent to the server. Defaults to an empty set.
116+
- returns: A publisher that eventually produces a single value and then finishes or fails.
117+
*/
118+
@available(macOS 10.15, iOS 13.0, macCatalyst 13.0, watchOS 6.0, tvOS 13.0, *)
119+
func fetchPublisher(includeKeys: [String]? = nil,
120+
options: API.Options = []) -> Future<T, ParseError> {
121+
Future { promise in
122+
self.fetch(includeKeys: includeKeys,
123+
options: options,
124+
completion: promise)
125+
}
126+
}
127+
#endif
66128
}
67129

68130
internal struct PointerType: Encodable {

0 commit comments

Comments
 (0)