Skip to content

Commit f124d0a

Browse files
cbaker6TomWFox
andauthored
Add cloud function/job calls and user password reset. (#43)
* Add cloud function/job calls and user password reset. - Also adds more command tests for User and cleans up user docs * Fixed bug. Make sure the right encoders are always used * Add results response for Cloud Code * Clean up docs * Fix Password Reset error. Add playgrounds example * Fix CloudCode server response error * Add Cloud function/job error tests * Improve server error responses (established priority of errors). - Added ResultsResponse for explain and hint * Bug fix: User logout was calling incorrect endpoint for server * Clean up docs * Added direct calls to Users and Installations endpoints. Added requestEmiailVerificaiton * Fixed URL error * Bump codecov * Update Sources/ParseSwift/Types/ParseFile.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Types/ParseFile.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Types/ParseFile.swift Co-authored-by: Tom Fox <[email protected]> * Resolve review, fix playground project * Fix backwards compatability with Swift < 5.3. Add a build to CI for Swift 5.2 * make Swift 5.2 build go after others * make other CI builds go after watchOS build since it never tests * Add LocallyIdentifiable protocol * wip * Improved batch and encoder * Remove json encoder from ParseEncoder * Reduce codecov * Update .codecov.yml * clean up * Improve LocallyIdentifiable protocol, change file structure of project * Save for later: ParseObject with localID, but doesn't work. This will be reverted back * cleaned up code * Switch to localId * Batch in waves of 50 by default. * Update Sources/ParseSwift/Objects/ParseObject.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseObject.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseObject.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseInstallation.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseInstallation.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseInstallation.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseInstallation.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseUser.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseUser.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseUser.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseObject.swift Co-authored-by: Tom Fox <[email protected]> * Update Sources/ParseSwift/Objects/ParseUser.swift Co-authored-by: Tom Fox <[email protected]> Co-authored-by: Tom Fox <[email protected]>
1 parent 3f1c897 commit f124d0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2782
-719
lines changed

.codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ coverage:
55
status:
66
patch:
77
default:
8-
target: auto
8+
target: 73
99
changes: false
1010
project:
1111
default:
12-
target: 72
12+
target: 74
1313
comment:
1414
require_changes: true

.github/workflows/ci.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,29 @@ jobs:
6666
run: xcrun llvm-cov export -format="lcov" .build/debug/ParseSwiftPackageTests.xctest/Contents/MacOS/ParseSwiftPackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov
6767
- name: Send codecov
6868
run: bash <(curl https://codecov.io/bash)
69-
69+
70+
spm-test-5_2:
71+
needs: xcode-build-watchos
72+
runs-on: macos-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: Create and set the default keychain
76+
run: |
77+
security create-keychain -p "" temporary
78+
security default-keychain -s temporary
79+
security unlock-keychain -p "" temporary
80+
security set-keychain-settings -lut 7200 temporary
81+
- name: Build
82+
run: swift build -v
83+
env:
84+
DEVELOPER_DIR: ${{ env.CI_XCODE_VER }}
85+
- name: Test
86+
run: swift test --enable-code-coverage -v
87+
env:
88+
DEVELOPER_DIR: ${{ env.CI_XCODE_VER }}
89+
7090
docs:
71-
needs: spm-test
91+
needs: xcode-build-watchos
7292
runs-on: macos-latest
7393
steps:
7494
- uses: actions/checkout@v2
@@ -94,15 +114,15 @@ jobs:
94114
publish_dir: ./docs
95115

96116
cocoapods:
97-
needs: spm-test
117+
needs: xcode-build-watchos
98118
runs-on: macos-latest
99119
steps:
100120
- uses: actions/checkout@v2
101121
- name: CocoaPods
102122
run: pod lib lint --allow-warnings
103123

104124
carthage:
105-
needs: spm-test
125+
needs: xcode-build-watchos
106126
runs-on: macos-latest
107127
steps:
108128
- uses: actions/checkout@v2
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//: [Previous](@previous)
2+
3+
import PlaygroundSupport
4+
import Foundation
5+
import ParseSwift
6+
7+
PlaygroundPage.current.needsIndefiniteExecution = true
8+
initializeParse()
9+
10+
//: Create your own ValueTyped ParseCloud type
11+
struct Cloud: ParseCloud {
12+
//: These are required for Object
13+
var functionJobName: String
14+
15+
//: If your cloud function takes arguments, they can be passed by creating properties
16+
//var argument1: [String: Int] = ["test": 5]
17+
}
18+
19+
/*: Assuming you have the Cloud Function named "hello" on your parse-server:
20+
// main.js
21+
Parse.Cloud.define('hello', async () => {
22+
return 'Hello world!';
23+
});
24+
*/
25+
let cloud = Cloud(functionJobName: "hello")
26+
27+
cloud.callFunction { result in
28+
switch result {
29+
case .success(let response):
30+
print("Response from cloud function: \(response)")
31+
case .failure(let error):
32+
assertionFailure("Error calling cloud function: \(error)")
33+
}
34+
}
35+
36+
//: Jobs can be run the same way by using the method `callJob()`
37+
38+
//: [Next](@next)

ParseSwift.playground/Pages/4 - User - Continued.xcplaygroundpage/Contents.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ User.current?.save { results in
3535
case .success(let updatedUser):
3636
print("Successfully save myCustomKey to ParseServer: \(updatedUser)")
3737
case .failure(let error):
38-
assertionFailure("Failed to update user: \(error)")
38+
print("Failed to update user: \(error)")
3939
}
4040
}
4141

@@ -44,7 +44,7 @@ do {
4444
try User.logout()
4545
print("Successfully logged out")
4646
} catch let error {
47-
assertionFailure("Error logging out: \(error)")
47+
print("Error logging out: \(error)")
4848
}
4949

5050
/*: Login - asynchronously - Performs work on background
@@ -64,7 +64,7 @@ User.login(username: "hello", password: "world") { results in
6464
print("Successfully logged in as user: \(user)")
6565

6666
case .failure(let error):
67-
assertionFailure("Error logging in: \(error)")
67+
print("Error logging in: \(error)")
6868
}
6969
}
7070

@@ -73,7 +73,23 @@ do {
7373
try User.logout()
7474
print("Successfully logged out")
7575
} catch let error {
76-
assertionFailure("Error logging out: \(error)")
76+
print("Error logging out: \(error)")
77+
}
78+
79+
//: Password Reset Request - synchronously
80+
do {
81+
try User.verificationEmailRequest(email: "[email protected]")
82+
print("Successfully requested verification email be sent")
83+
} catch let error {
84+
print("Error requesting verification email be sent: \(error)")
85+
}
86+
87+
//: Password Reset Request - synchronously
88+
do {
89+
try User.passwordReset(email: "[email protected]")
90+
print("Successfully requested password reset")
91+
} catch let error {
92+
print("Error requesting password reset: \(error)")
7793
}
7894

7995
//: Another way to sign up
@@ -88,7 +104,7 @@ newUser.signup { result in
88104
print("Parse signup successful: \(user)")
89105

90106
case .failure(let error):
91-
assertionFailure("Error logging in: \(error)")
107+
print("Error logging in: \(error)")
92108
}
93109
}
94110

ParseSwift.playground/Pages/9 - Files.xcplaygroundpage/Contents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ score.save { result in
9090
}
9191
}
9292

93-
/*: Files can also be saved from data. Below is how to do it synchrously, but async is similar to above
93+
/*: Files can also be saved from data. Below is how to do it synchronously, but async is similar to above
9494
Create a new ParseFile for your data
9595
*/
9696
let sampleData = "Hello World".data(using: .utf8)!
@@ -116,7 +116,7 @@ do {
116116
print("The file is saved to your Parse Server at: \(url)")
117117
print("The full details of your data file are: \(myData)")
118118

119-
//: If you need to download your profilePicture
119+
//: If you need to download your file
120120
let fetchedFile = try myData.fetch()
121121
if fetchedFile.localURL != nil {
122122
print("The file is now saved at: \(fetchedFile.localURL!)")

ParseSwift.playground/contents.xcplayground

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<page name='7 - GeoPoint'/>
1111
<page name='8 - Pointers'/>
1212
<page name='9 - Files'/>
13+
<page name='10 - Cloud Code'/>
1314
</pages>
1415
</playground>

0 commit comments

Comments
 (0)