Skip to content

Commit

Permalink
feat: Add batch and increment double operation (#88)
Browse files Browse the repository at this point in the history
* feat: Add batch and increment double operation

* delete file

* make operations Codable.

* improve documentation

* nits
  • Loading branch information
cbaker6 committed Apr 3, 2023
1 parent ad1cad2 commit a790bb7
Show file tree
Hide file tree
Showing 59 changed files with 648 additions and 272 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.3.3...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.4.0...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift)
* _Contributing to this repo? Add info about your change here to be included in the next release_

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

__New features__
* Add batch and increment double operations. All operations have also been made public so developers can build batch operations with ParseOperationBatch ([#88](https://github.com/netreconlab/Parse-Swift/pull/88)), thanks to [Corey Baker](https://github.com/cbaker6).

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

Expand Down
202 changes: 121 additions & 81 deletions ParseSwift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.package(url: "https://github.com/netreconlab/Parse-Swift", .upToNextMajor(from: "5.3.3")),
.package(url: "https://github.com/netreconlab/Parse-Swift", .upToNextMajor(from: "5.4.0")),
]
)
```
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/API/API+Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ParseSwift
//
// Created by Florent Vilmart on 17-09-24.
// Copyright © 2020 Network Reconnaissance Lab. All rights reserved.
// Copyright © 2020 Parse. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/API/BatchUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ParseSwift
//
// Created by Florent Vilmart on 17-08-19.
// Copyright © 2020 Network Reconnaissance Lab. All rights reserved.
// Copyright © 2020 Parse. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/API/Responses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ParseSwift
//
// Created by Florent Vilmart on 17-08-20.
// Copyright © 2020 Network Reconnaissance Lab. All rights reserved.
// Copyright © 2020 Parse. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public struct ParseApple<AuthenticatedUser: ParseUser>: ParseAuthentication {
"apple"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public struct ParseFacebook<AuthenticatedUser: ParseUser>: ParseAuthentication {
"facebook"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public struct ParseGitHub<AuthenticatedUser: ParseUser>: ParseAuthentication {
"github"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public struct ParseGoogle<AuthenticatedUser: ParseUser>: ParseAuthentication {
"google"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct ParseInstagram<AuthenticatedUser: ParseUser>: ParseAuthentication
"instagram"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct ParseLDAP<AuthenticatedUser: ParseUser>: ParseAuthentication {
"ldap"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct ParseLinkedIn<AuthenticatedUser: ParseUser>: ParseAuthentication {
"linkedin"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct ParseSpotify<AuthenticatedUser: ParseUser>: ParseAuthentication {
"spotify"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public struct ParseTwitter<AuthenticatedUser: ParseUser>: ParseAuthentication {
"twitter"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct ParseAnonymous<AuthenticatedUser: ParseUser>: ParseAuthentication
"anonymous"
}

public init() { }
public init() {}
}

// MARK: Login
Expand Down
14 changes: 0 additions & 14 deletions Sources/ParseSwift/Operations/Add.swift

This file was deleted.

18 changes: 0 additions & 18 deletions Sources/ParseSwift/Operations/AddRelation.swift

This file was deleted.

14 changes: 0 additions & 14 deletions Sources/ParseSwift/Operations/AddUnique.swift

This file was deleted.

13 changes: 0 additions & 13 deletions Sources/ParseSwift/Operations/Delete.swift

This file was deleted.

14 changes: 0 additions & 14 deletions Sources/ParseSwift/Operations/Increment.swift

This file was deleted.

19 changes: 0 additions & 19 deletions Sources/ParseSwift/Operations/Operation.swift

This file was deleted.

14 changes: 0 additions & 14 deletions Sources/ParseSwift/Operations/Remove.swift

This file was deleted.

18 changes: 0 additions & 18 deletions Sources/ParseSwift/Operations/RemoveRelation.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

enum ParseConstants {
static let sdk = "swift"
static let version = "5.3.3"
static let version = "5.4.0"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
static let fileManagementLibraryDirectory = "Library/"
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Protocols/ParseHookFunctionable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ extension ParseHookFunctionable {
}
}

func deleteCommand() throws -> API.NonParseBodyCommand<Delete, NoBody> {
func deleteCommand() throws -> API.NonParseBodyCommand<ParseOperationDelete, NoBody> {
let request = try FunctionRequest(hookFunction: self)
return API.NonParseBodyCommand(method: .PUT,
path: .hookFunction(request: request),
body: Delete()) { (data) -> NoBody in
body: ParseOperationDelete()) { (data) -> NoBody in
try ParseCoding.jsonDecoder().decode(NoBody.self, from: data)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Protocols/ParseHookTriggerable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ extension ParseHookTriggerable {
}
}

func deleteCommand() throws -> API.NonParseBodyCommand<Delete, NoBody> {
func deleteCommand() throws -> API.NonParseBodyCommand<ParseOperationDelete, NoBody> {
let request = try TriggerRequest(trigger: self)
return API.NonParseBodyCommand(method: .PUT,
path: .hookTrigger(request: request),
body: Delete()) { (data) -> NoBody in
body: ParseOperationDelete()) { (data) -> NoBody in
try ParseCoding.jsonDecoder().decode(NoBody.self, from: data)
}
}
Expand Down
36 changes: 36 additions & 0 deletions Sources/ParseSwift/Protocols/ParseOperationable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// ParseOperationable.swift
// ParseSwift
//
// Created by Corey Baker on 4/1/23.
// Copyright © 2023 Network Reconnaissance Lab. All rights reserved.
//

import Foundation

/// A protocol that allows a type to be a Parse operation.
public protocol ParseOperationable: Codable,
CustomDebugStringConvertible,
CustomStringConvertible {
/// The operation command for this operation.
var __op: ParseOperationCommand { get } // swiftlint:disable:this identifier_name
}

// MARK: CustomDebugStringConvertible
public extension ParseOperationable {
var debugDescription: String {
guard let descriptionData = try? ParseCoding.jsonEncoder().encode(self),
let descriptionString = String(data: descriptionData, encoding: .utf8) else {
return "()"
}

return "\(descriptionString)"
}
}

// MARK: CustomStringConvertible
public extension ParseOperationable {
var description: String {
debugDescription
}
}
15 changes: 15 additions & 0 deletions Sources/ParseSwift/Protocols/ParseRelationOperationable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ParseRelationOperationable.swift
// ParseSwift
//
// Created by Corey Baker on 4/1/23.
// Copyright © 2023 Network Reconnaissance Lab. All rights reserved.
//

import Foundation

public protocol ParseRelationOperationable: ParseOperationable {
associatedtype Object: ParseObject
var __op: ParseOperationCommand { get set } // swiftlint:disable:this identifier_name
var objects: [Pointer<Object>] { get set }
}
26 changes: 26 additions & 0 deletions Sources/ParseSwift/Types/Operations/ParseOperationAdd.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ParseOperationAdd.swift
// Parse
//
// Created by Florent Vilmart on 17-07-24.
// Copyright © 2017 Parse. All rights reserved.
//

import Foundation

/**
An operation that adds new objects to an array field.
*/
public struct ParseOperationAdd<T>: ParseOperationable where T: Codable {
public var __op: ParseOperationCommand = .add // swiftlint:disable:this identifier_name
/// The array of objects related to the operation.
public var objects: [T]

/**
Create an instance with an array of objects.
- parameter objects: The array of objects to add
*/
public init(objects: [T]) {
self.objects = objects
}
}
Loading

0 comments on commit a790bb7

Please sign in to comment.