Skip to content

Commit

Permalink
feat: Improve ParseVersion and SDK Initialization (#49)
Browse files Browse the repository at this point in the history
* fix: improve threading support

* improve installation

* improve gets

* try class func

* move URLSession static methods to utility

* add random delay to networking

* improve mocker delay

* swift multiple threads to 3

* add changelog

* don't run windows latest test

* use random delay by default when testing

* lower random delay range

* use larger delay range for threaded tests

* nits

* improve ParseVersion

* fix tests for new ParseVersion

* Fix migrating Keychain

* fix failing tests

* add tests

* bump version to beta2

* nits

* Update Playgrounds and Changelog

* add documentation for throwing errors

* run swiftLint on tvOS

* update DocC

* add delay to some network tests

* don't lint markdown

* fix docc warning
  • Loading branch information
cbaker6 authored Jan 18, 2023
1 parent 1e2d713 commit c7c83f1
Show file tree
Hide file tree
Showing 141 changed files with 1,218 additions and 865 deletions.
41 changes: 19 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,37 @@
### 5.0.0
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.2...5.0.0), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.0.0/documentation/parseswift)

__New features__

* Adds the the ability to watch particular keys with LiveQueries. Requires Parse-Server 6.0.0 ([#47](https://github.com/netreconlab/Parse-Swift/pull/47)), thanks to [Corey Baker](https://github.com/cbaker6).

* (Breaking Change) Added a new ParseHealth.Status enum to support Parse Server.
Developers can access the new status values (Status.initialized, Status.starting)
using the ParseHealth.check callback or Combine methods. The new status values
are not available for async/await and synchounous methods. Connecting to Parse
Servers < 6.0.0, using async/await, or synchronous methods only returns
Status.ok or throws an error
__Breaking Changes__
* ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
* Added a new ParseHealth.Status enum to support new feature in Parse Server 6.0.0.
Developers can now receive intermediate status updates (Status.initialized, Status.starting)
using the ParseHealth.check callback or Combine methods. Status.initialized and
Status.starting will only show for async/await and synchronous methods if they are the
last value reported from the server after maxConnectionAttempts. Connecting to Parse
Servers < 6.0.0 only returns Status.ok or a ParseError
([#43](https://github.com/netreconlab/Parse-Swift/pull/43)),
thanks to [Corey Baker](https://github.com/cbaker6).
* Add and update ParseError codes. unknownError has been renamed
to otherCause. invalidImageData now has the correct error code of 150. webhookError has
the correct error code of 143 ([#23](https://github.com/netreconlab/Parse-Swift/pull/23)),
thanks to [Corey Baker](https://github.com/cbaker6).
* Remove all deprecated code. Be sure to follow the suggestions of all
deprecation warnings when building your app in Xcode before upgrading
([#23](https://github.com/netreconlab/Parse-Swift/pull/23)), thanks
to [Corey Baker](https://github.com/cbaker6).

__New features__
* ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6).
* Adds the the ability to watch particular keys with LiveQueries. Requires Parse-Server 6.0.0 ([#48](https://github.com/netreconlab/Parse-Swift/pull/48)), thanks to [Corey Baker](https://github.com/cbaker6).
* The Swift SDK can now properly handle HTTP Status codes 429 and 503 and will retry after the delay specified in the respective header ([#43](https://github.com/netreconlab/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6).

* The max connection attempts for LiveQuery can now be changed when initializing the SDK ([#43](https://github.com/netreconlab/Parse-Swift/pull/43)), thanks to [Corey Baker](https://github.com/cbaker6).

__Fixes__

* Fixed issues that can cause cache misses when querying ([#46](https://github.com/netreconlab/Parse-Swift/pull/46)), thanks to [Corey Baker](https://github.com/cbaker6).

* Fixed a threading issue with .current objects that can cause apps to crash
([#45](https://github.com/netreconlab/Parse-Swift/pull/45)), thanks
to [Corey Baker](https://github.com/cbaker6).

* (Breaking Change) Add and update ParseError codes. unknownError has been renamed
to otherCause. invalidImageData now has the error code of 150. webhookError has
the error code of 143 ([#23](https://github.com/netreconlab/Parse-Swift/pull/23)),
thanks to [Corey Baker](https://github.com/cbaker6).

* (Breaking Change) Remove deprecated code
([#23](https://github.com/netreconlab/Parse-Swift/pull/23)), thanks
to [Corey Baker](https://github.com/cbaker6).

### 4.16.2
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/4.16.1...4.16.2), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/4.16.2/documentation/parseswift)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true

/*: start parse-server with
npm start -- --appId applicationId --clientKey clientKey --masterKey masterKey --mountPath /1
/*:
Start your parse-server with:
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
*/

//: In Xcode, make sure you are building the "ParseSwift (macOS)" framework.

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Get current SDK version
if let version = ParseVersion.current {
Expand All @@ -26,7 +30,7 @@ if let version = ParseVersion.current {
do {
print("Server health is: \(try ParseHealth.check())")
} catch {
print(error)
assertionFailure("Error checking the server health: \(error)")
}

//: Create your own value typed `ParseObject`.
Expand Down Expand Up @@ -79,7 +83,7 @@ struct GameData: ParseObject {
//: Your own properties.
var polygon: ParsePolygon?
//: `ParseBytes` needs to be a part of the original schema
//: or else you will need your masterKey to force an upgrade.
//: or else you will need your primaryKey to force an upgrade.
var bytes: ParseBytes?

/*:
Expand Down Expand Up @@ -125,6 +129,10 @@ score.save { result in
assert(savedScore.createdAt != nil)
assert(savedScore.updatedAt != nil)
assert(savedScore.points == 10)
print("""
Saved \"\(savedScore.className)\" with the following info:
\(savedScore)
""")

/*:
To modify, you need to make it a var as the value type
Expand All @@ -141,6 +149,10 @@ score.save { result in
case .success(let savedChangedScore):
assert(savedChangedScore.points == 200)
assert(savedScore.objectId == savedChangedScore.objectId)
print("""
Updated \"\(savedScore.className)\" with the following info:
\(savedChangedScore)
""")

case .failure(let error):
assertionFailure("Error saving: \(error)")
Expand All @@ -154,7 +166,7 @@ score.save { result in
//: This will store the second batch score to be used later.
var score2ForFetchedLater: GameScore?

//: Saving multiple GameScores at once.
//: Saving multiple GameScores at once with batching.
[score, score2].saveAll { results in
switch results {
case .success(let otherResults):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed `ParseCloudable` type.
struct Hello: ParseCloudable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import SwiftUI

PlaygroundPage.current.needsIndefiniteExecution = true

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed ParseObject.
struct GameScore: ParseObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

struct User: ParseUser {
//: These are required by `ParseObject`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

struct GameScore: ParseObject {
//: These are required by ParseObject.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create a value typed `ParseConfig` that matches your server config.
struct Config: ParseConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true

/*:
start parse-server with
npm start -- --appId applicationId --clientKey clientKey --masterKey masterKey --mountPath /1
Start parse-server with:
npm start -- --appId applicationId --clientKey clientKey --masterKey primaryKey --mountPath /1
*/

/*:
In Xcode, make sure you are building the "ParseSwift (macOS)" framework.
*/

initializeParse(customObjectId: true)
do {
try initializeParse(customObjectId: true)
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed `ParseObject`.
struct GameScore: ParseObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: To track when the app has been opened, do the following.
ParseAnalytics.trackAppOpened { result in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import SwiftUI

PlaygroundPage.current.needsIndefiniteExecution = true

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed ParseObject.
struct GameScore: ParseObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import Combine

PlaygroundPage.current.needsIndefiniteExecution = true

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed ParseObject.
struct GameScore: ParseObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import SwiftUI

PlaygroundPage.current.needsIndefiniteExecution = true

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed ParseObject.
struct GameScore: ParseObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true

initializeParse()
do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

struct GameScore: ParseObject {
var objectId: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
/*:
The code in this Playground is intended to run at the
server level only. It is not intended to be run in client
applications as it requires the use of the master key.
applications as it requires the use of the primary key.
*/

import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Youe specific _User value type.
struct User: ParseUser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
/*:
The code in this Playground is intended to run at the
server level only. It is not intended to be run in client
applications as it requires the use of the master key.
applications as it requires the use of the primary key.
*/

import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

struct Installation: ParseInstallation {
//: These are required by `ParseObject`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
/*:
The code in this Playground is intended to run at the
server level only. It is not intended to be run in client
applications as it requires the use of the master key.
applications as it requires the use of the primary key.
*/

import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

/*:
Parse Hook Functions can be created by conforming to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
/*:
The code in this Playground is intended to run at the
server level only. It is not intended to be run in client
applications as it requires the use of the master key.
applications as it requires the use of the primary key.
*/

import PlaygroundSupport
import Foundation
import ParseSwift

PlaygroundPage.current.needsIndefiniteExecution = true
initializeParse()

do {
try initializeParse()
} catch {
assertionFailure("Error initializing Parse-Swift: \(error)")
}

//: Create your own value typed `ParseObject`.
struct GameScore: ParseObject {
Expand Down
Loading

0 comments on commit c7c83f1

Please sign in to comment.