Change ApiCall struct to a class and instead of passing the node configuration down to each method and each initializes a new ApiCall, pass the apiCall by reference to keep the node health state in sync.
Fix various tests that weren't written properly.
Multiple new instances of ApiCall still use the same currentNodeIndex.
Analytic methods weren't made public so the user can't access it.
Make the ApiKey _id field required.
Errors were not thrown on http status 5xx
Search grouping of multiple fields with different data type cause swift decode error
Features:
added update and update by filter for /documents endpoint
allow configuration of dirty data behaviors & import actions
allow multi-search & single collection search to return raw data #31
add analytics events endpoint
[!NOTE]
Breaking changes:
Allow search grouping of multiple fields with different data type. Currently we can only group string fields (because Swift array can only hold one type). This PR add support for mixing string fields with numeric, boolean fields and fields with missing values. Requires a lightweight dependency AnyCodable.
// type of num_employees is Int, country is String and metadata is Boolean
// before, if we try grouping these fields together, Swift will throw a decoding error
let searchParams = SearchParameters(q: "*", queryBy: "company_name", groupBy: "num_employees,country,metadata")
let (data, _) = try await client.collection(name: "companies").documents().search(searchParams, for: Company.self)
if let groupKey = data?.groupedHits?.first?.groupKey{
if let num_employees = groupKey[0].value as? Int{
print(num_employees)
}
// do the same for country and metadata
}
Throw better http client errors with status code and error message inside ApiCall. This will reduce a lot of boilerplate code as we don't have to manually define and throw error for each endpoint (in which the error is also not correct since it did not check for the status code and throw error accordingly).
do {
let (data, _) = try await client.keys().retrieve(id: 1)
// all endpoints will now throw HTTPError client & server error
} catch HTTPError.clientError(let code, let desc){
print(code, desc)
} catch HTTPError.serverError(let code, let desc){
print(code, desc)
// instead of ResponseError
// catch ResponseError.apiKeyNotFound(let desc) {
// print(desc)
// }
} catch (let error) {
print(error)
}
Update analytics rules schemas
// the `type` field is now an enum
AnalyticsRuleSchema(
name: "product_queries_aggregation",
type: .popularQueries,
// type: "popular_queries",
)
Change Summary
Fixes:
ApiCall
struct to a class and instead of passing the node configuration down to each method and each initializes a newApiCall
, pass the apiCall by reference to keep the node health state in sync.currentNodeIndex
._id
field required.Features:
added
update
and update by filter for/documents
endpointallow configuration of dirty data behaviors & import actions
allow multi-search & single collection search to return raw data #31
add analytics events endpoint
Allow search grouping of multiple fields with different data type. Currently we can only group string fields (because Swift array can only hold one type). This PR add support for mixing string fields with numeric, boolean fields and fields with missing values. Requires a lightweight dependency AnyCodable.
ApiCall
. This will reduce a lot of boilerplate code as we don't have to manually define and throw error for each endpoint (in which the error is also not correct since it did not check for the status code and throw error accordingly).Deprecation
PR Checklist