Skip to content

Commit 0b9c0ff

Browse files
authored
refactor: rename functions method parameters (#144)
1 parent 5914dea commit 0b9c0ff

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

Sources/Functions/FunctionsClient.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ public actor FunctionsClient {
5151
///
5252
/// - Parameters:
5353
/// - functionName: The name of the function to invoke.
54-
/// - invokeOptions: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
54+
/// - options: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
5555
/// - decode: A closure to decode the response data and HTTPURLResponse into a `Response`
5656
/// object.
5757
/// - Returns: The decoded `Response` object.
5858
public func invoke<Response>(
59-
functionName: String,
60-
invokeOptions: FunctionInvokeOptions = .init(),
59+
_ functionName: String,
60+
options: FunctionInvokeOptions = .init(),
6161
decode: (Data, HTTPURLResponse) throws -> Response
6262
) async throws -> Response {
6363
let (data, response) = try await rawInvoke(
64-
functionName: functionName, invokeOptions: invokeOptions
64+
functionName: functionName, invokeOptions: options
6565
)
6666
return try decode(data, response)
6767
}
@@ -70,15 +70,15 @@ public actor FunctionsClient {
7070
///
7171
/// - Parameters:
7272
/// - functionName: The name of the function to invoke.
73-
/// - invokeOptions: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
73+
/// - options: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
7474
/// - decoder: The JSON decoder to use for decoding the response. (Default: `JSONDecoder()`)
7575
/// - Returns: The decoded object of type `T`.
7676
public func invoke<T: Decodable>(
77-
functionName: String,
78-
invokeOptions: FunctionInvokeOptions = .init(),
77+
_ functionName: String,
78+
options: FunctionInvokeOptions = .init(),
7979
decoder: JSONDecoder = JSONDecoder()
8080
) async throws -> T {
81-
try await invoke(functionName: functionName, invokeOptions: invokeOptions) { data, _ in
81+
try await invoke(functionName, options: options) { data, _ in
8282
try decoder.decode(T.self, from: data)
8383
}
8484
}
@@ -87,12 +87,12 @@ public actor FunctionsClient {
8787
///
8888
/// - Parameters:
8989
/// - functionName: The name of the function to invoke.
90-
/// - invokeOptions: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
90+
/// - options: Options for invoking the function. (Default: empty `FunctionInvokeOptions`)
9191
public func invoke(
92-
functionName: String,
93-
invokeOptions: FunctionInvokeOptions = .init()
92+
_ functionName: String,
93+
options: FunctionInvokeOptions = .init()
9494
) async throws {
95-
try await invoke(functionName: functionName, invokeOptions: invokeOptions) { _, _ in () }
95+
try await invoke(functionName, options: options) { _, _ in () }
9696
}
9797

9898
private func rawInvoke(

Sources/PostgREST/PostgrestFilterBuilder.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
2222
return self
2323
}
2424

25-
public func or(filters: URLQueryRepresentable) -> PostgrestFilterBuilder {
25+
public func or(_ filters: URLQueryRepresentable) -> PostgrestFilterBuilder {
2626
mutableState.withValue {
2727
$0.request.query.append(URLQueryItem(name: "or", value: "(\(filters.queryValue.queryValue))"))
2828
}
@@ -139,8 +139,10 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
139139
return self
140140
}
141141

142-
public func rangeAdjacent(_ column: String, range: URLQueryRepresentable) -> PostgrestFilterBuilder
143-
{
142+
public func rangeAdjacent(
143+
_ column: String,
144+
range: URLQueryRepresentable
145+
) -> PostgrestFilterBuilder {
144146
mutableState.withValue {
145147
$0.request.query.append(URLQueryItem(name: column, value: "adj.\(range.queryValue)"))
146148
}
@@ -162,7 +164,8 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
162164
}
163165

164166
public func textSearch(
165-
_ column: String, query: URLQueryRepresentable, config: String? = nil, type: TextSearchType? = nil
167+
_ column: String, query: URLQueryRepresentable, config: String? = nil,
168+
type: TextSearchType? = nil
166169
) -> PostgrestFilterBuilder {
167170
mutableState.withValue {
168171
$0.request.query.append(
@@ -234,7 +237,7 @@ public class PostgrestFilterBuilder: PostgrestTransformBuilder {
234237
return self
235238
}
236239

237-
public func match(query: [String: URLQueryRepresentable]) -> PostgrestFilterBuilder {
240+
public func match(_ query: [String: URLQueryRepresentable]) -> PostgrestFilterBuilder {
238241
mutableState.withValue { mutableState in
239242
query.forEach { key, value in
240243
mutableState.request.query.append(URLQueryItem(

Tests/FunctionsTests/FunctionsClientTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ final class FunctionsClientTests: XCTestCase {
2222
let body = ["name": "Supabase"]
2323

2424
try await sut.invoke(
25-
functionName: "hello_world",
26-
invokeOptions: .init(headers: ["X-Custom-Key": "value"], body: body)
25+
"hello_world",
26+
options: .init(headers: ["X-Custom-Key": "value"], body: body)
2727
)
2828

2929
let request = await _request.value
@@ -44,7 +44,7 @@ final class FunctionsClientTests: XCTestCase {
4444
}
4545

4646
do {
47-
try await sut.invoke(functionName: "hello_world")
47+
try await sut.invoke("hello_world")
4848
} catch let urlError as URLError {
4949
XCTAssertEqual(urlError.code, .badServerResponse)
5050
} catch {
@@ -63,7 +63,7 @@ final class FunctionsClientTests: XCTestCase {
6363
}
6464

6565
do {
66-
try await sut.invoke(functionName: "hello_world")
66+
try await sut.invoke("hello_world")
6767
XCTFail("Invoke should fail.")
6868
} catch let FunctionsError.httpError(code, data) {
6969
XCTAssertEqual(code, 300)
@@ -86,7 +86,7 @@ final class FunctionsClientTests: XCTestCase {
8686
}
8787

8888
do {
89-
try await sut.invoke(functionName: "hello_world")
89+
try await sut.invoke("hello_world")
9090
XCTFail("Invoke should fail.")
9191
} catch FunctionsError.relayError {
9292
} catch {

0 commit comments

Comments
 (0)