Skip to content

Commit 8843529

Browse files
authored
chore(docs): update documentation for PostgREST (#339)
* code format * chore: update postgrest documentation * test: add test for query with nil value * revert: removal of returning param was breaking change
1 parent 7329528 commit 8843529

24 files changed

+440
-232
lines changed

.swiftformat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--swiftversion 5.7
1+
--swiftversion 5.9
22
--binarygrouping none
33
--decimalgrouping none
44
--hexgrouping none
@@ -9,4 +9,3 @@
99
--wrapcollections before-first
1010
--wrapparameters before-first
1111
--extensionacl on-declarations
12-
--maxwidth 100

Examples/Examples/AnyJSONView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ extension AnyJSON {
5858
var isPrimitive: Bool {
5959
switch self {
6060
case .null, .bool, .integer, .double, .string:
61-
return true
61+
true
6262
case .object, .array:
63-
return false
63+
false
6464
}
6565
}
6666
}

Sources/Auth/AuthError.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public enum AuthError: LocalizedError, Sendable, Equatable {
4545

4646
public var errorDescription: String? {
4747
switch self {
48-
case let .api(error): return error.errorDescription ?? error.msg ?? error.error
49-
case .missingExpClaim: return "Missing expiration claim on access token."
50-
case .malformedJWT: return "A malformed JWT received."
51-
case .sessionNotFound: return "Unable to get a valid session."
52-
case .pkce(.codeVerifierNotFound): return "A code verifier wasn't found in PKCE flow."
53-
case .pkce(.invalidPKCEFlowURL): return "Not a valid PKCE flow url."
54-
case .invalidImplicitGrantFlowURL: return "Not a valid implicit grant flow url."
55-
case .missingURL: return "Missing URL."
56-
case .invalidRedirectScheme: return "Invalid redirect scheme."
48+
case let .api(error): error.errorDescription ?? error.msg ?? error.error
49+
case .missingExpClaim: "Missing expiration claim on access token."
50+
case .malformedJWT: "A malformed JWT received."
51+
case .sessionNotFound: "Unable to get a valid session."
52+
case .pkce(.codeVerifierNotFound): "A code verifier wasn't found in PKCE flow."
53+
case .pkce(.invalidPKCEFlowURL): "Not a valid PKCE flow url."
54+
case .invalidImplicitGrantFlowURL: "Not a valid implicit grant flow url."
55+
case .missingURL: "Missing URL."
56+
case .invalidRedirectScheme: "Invalid redirect scheme."
5757
}
5858
}
5959
}

Sources/Auth/Types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ public enum AuthResponse: Codable, Hashable, Sendable {
413413

414414
public var user: User {
415415
switch self {
416-
case let .session(session): return session.user
417-
case let .user(user): return user
416+
case let .session(session): session.user
417+
case let .user(user): user
418418
}
419419
}
420420

Sources/Functions/Types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public enum FunctionsError: Error, LocalizedError {
1111
public var errorDescription: String? {
1212
switch self {
1313
case .relayError:
14-
return "Relay Error invoking the Edge Function"
14+
"Relay Error invoking the Edge Function"
1515
case let .httpError(code, _):
16-
return "Edge Function returned a non-2xx status code: \(code)"
16+
"Edge Function returned a non-2xx status code: \(code)"
1717
}
1818
}
1919
}

Sources/PostgREST/Deprecated.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,3 @@ extension PostgrestClient {
7878
)
7979
}
8080
}
81-
82-
extension PostgrestFilterBuilder {
83-
@available(*, deprecated, renamed: "textSearch(_:value:)")
84-
public func textSearch(
85-
_ column: String,
86-
range: any URLQueryRepresentable
87-
) -> PostgrestFilterBuilder {
88-
textSearch(column, value: range)
89-
}
90-
}

Sources/PostgREST/PostgrestClient.swift

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public final class PostgrestClient: Sendable {
2626

2727
let logger: (any SupabaseLogger)?
2828

29-
/// Initializes a new configuration for the PostgREST client.
29+
/// Creates a PostgREST client.
3030
/// - Parameters:
31-
/// - url: The URL of the PostgREST server.
32-
/// - schema: The schema to use.
33-
/// - headers: The headers to include in requests.
31+
/// - url: URL of the PostgREST endpoint.
32+
/// - schema: Postgres schema to switch to.
33+
/// - headers: Custom headers.
3434
/// - logger: The logger to use.
35-
/// - fetch: The fetch handler to use for requests.
35+
/// - fetch: Custom fetch.
3636
/// - encoder: The JSONEncoder to use for encoding.
3737
/// - decoder: The JSONDecoder to use for decoding.
3838
public init(
@@ -68,11 +68,11 @@ public final class PostgrestClient: Sendable {
6868

6969
/// Creates a PostgREST client with the specified parameters.
7070
/// - Parameters:
71-
/// - url: The URL of the PostgREST server.
72-
/// - schema: The schema to use.
73-
/// - headers: The headers to include in requests.
71+
/// - url: URL of the PostgREST endpoint.
72+
/// - schema: Postgres schema to switch to.
73+
/// - headers: Custom headers.
7474
/// - logger: The logger to use.
75-
/// - session: The URLSession to use for requests.
75+
/// - fetch: Custom fetch.
7676
/// - encoder: The JSONEncoder to use for encoding.
7777
/// - decoder: The JSONDecoder to use for decoding.
7878
public convenience init(
@@ -110,24 +110,20 @@ public final class PostgrestClient: Sendable {
110110
return self
111111
}
112112

113-
/// Performs a query on a table or a view.
113+
/// Perform a query on a table or a view.
114114
/// - Parameter table: The table or view name to query.
115-
/// - Returns: A PostgrestQueryBuilder instance.
116115
public func from(_ table: String) -> PostgrestQueryBuilder {
117116
PostgrestQueryBuilder(
118117
configuration: configuration,
119118
request: .init(path: table, method: .get, headers: configuration.headers)
120119
)
121120
}
122121

123-
/// Performs a function call.
122+
/// Perform a function call.
124123
/// - Parameters:
125124
/// - fn: The function name to call.
126125
/// - params: The parameters to pass to the function call.
127-
/// - count: Count algorithm to use to count rows returned by the function.
128-
/// Only applicable for set-returning functions.
129-
/// - Returns: A PostgrestFilterBuilder instance.
130-
/// - Throws: An error if the function call fails.
126+
/// - count: Count algorithm to use to count rows returned by the function. Only applicable for [set-returning functions](https://www.postgresql.org/docs/current/functions-srf.html).
131127
public func rpc(
132128
_ fn: String,
133129
params: some Encodable & Sendable,
@@ -139,13 +135,10 @@ public final class PostgrestClient: Sendable {
139135
).rpc(params: params, count: count)
140136
}
141137

142-
/// Performs a function call.
138+
/// Perform a function call.
143139
/// - Parameters:
144140
/// - fn: The function name to call.
145-
/// - count: Count algorithm to use to count rows returned by the function.
146-
/// Only applicable for set-returning functions.
147-
/// - Returns: A PostgrestFilterBuilder instance.
148-
/// - Throws: An error if the function call fails.
141+
/// - count: Count algorithm to use to count rows returned by the function. Only applicable for [set-returning functions](https://www.postgresql.org/docs/current/functions-srf.html).
149142
public func rpc(
150143
_ fn: String,
151144
count: CountOption? = nil

0 commit comments

Comments
 (0)