Skip to content

Commit b9848b7

Browse files
authored
Merge branch 'main' into provide-methods-to-send-raw-payloads
2 parents 285b765 + a29ea75 commit b9848b7

File tree

17 files changed

+183
-67
lines changed

17 files changed

+183
-67
lines changed

.code-samples.meilisearch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ primary_field_guide_add_document_primary_key: |-
957957
getting_started_add_documents_md: |-
958958
```toml
959959
[dependencies]
960-
meilisearch-sdk = "0.21"
960+
meilisearch-sdk = "0.22"
961961
# futures: because we want to block on futures
962962
futures = "0.3"
963963
# serde: required if you are going to use documents

.github/scripts/check-release.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,36 @@
22

33
# Checking if current tag matches the package version
44
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | sed -r 's/^v//')
5-
major=$(echo $current_tag | cut -d '.' -f1 )
6-
minor=$(echo $current_tag | cut -d '.' -f2 )
5+
major=$(echo $current_tag | cut -d '.' -f1)
6+
minor=$(echo $current_tag | cut -d '.' -f2)
77
cropped_current_tag="$major.$minor"
88
file1='Cargo.toml'
99
file2='README.tpl'
1010
file3='.code-samples.meilisearch.yaml'
1111
file4='README.md'
12+
file5='./meilisearch-index-setting-macro/Cargo.toml'
1213

1314
file_tag1=$(grep '^version = ' $file1 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
15+
file_tag_1_1=$(grep '{ path = "meilisearch-index-setting-macro", version =' $file1 | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
1416
file_tag2=$(grep 'meilisearch-sdk = ' $file2 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
1517
file_tag3=$(grep 'meilisearch-sdk = ' $file3 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
1618
file_tag4=$(grep 'meilisearch-sdk = ' $file4 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
17-
if [ "$current_tag" != "$file_tag1" ] || [ "$current_tag" != "$file_tag2" ] || [ "$cropped_current_tag" != "$file_tag3" ] || [ "$current_tag" != "$file_tag4" ]; then
19+
file_tag5=$(grep '^version = ' $file5 | grep -Eo '[0-9]+.[0-9]+.[0-9]+')
20+
21+
if [ "$current_tag" != "$file_tag1" ] ||
22+
[ "$current_tag" != "$file_tag_1_1" ] ||
23+
[ "$current_tag" != "$file_tag2" ] ||
24+
[ "$cropped_current_tag" != "$file_tag3" ] ||
25+
[ "$current_tag" != "$file_tag4" ] ||
26+
[ "$current_tag" != "$file_tag5" ] \
27+
; then
1828
echo "Error: the current tag does not match the version in package file(s)."
1929
echo "$file1: found $file_tag1 - expected $current_tag"
30+
echo "$file1: found $file_tag_1_1 - expected $current_tag"
2031
echo "$file2: found $file_tag2 - expected $current_tag"
2132
echo "$file3: found $file_tag3 - expected $cropped_current_tag"
2233
echo "$file4: found $file_tag4 - expected $current_tag"
34+
echo "$file5: found $file_tag5 - expected $current_tag"
2335
exit 1
2436
fi
2537

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ Make a PR modifying the file [`Cargo.toml`](/Cargo.toml):
173173
version = "X.X.X"
174174
```
175175

176+
After the changes on `Cargo.toml`, run the following command:
177+
178+
```
179+
sh scripts/update_macro_versions.sh
180+
```
181+
176182
and the [`README.tpl`](/README.tpl):
177183

178184
```rust
@@ -181,13 +187,13 @@ and the [`README.tpl`](/README.tpl):
181187

182188
with the right version.
183189

184-
You should run the following command after the changes applied to `lib.rs`:
190+
After the changes on `lib.rs`, run the following command:
185191

186192
```bash
187193
sh scripts/update-readme.sh
188194
```
189195

190-
Also, you might need to change the [code-samples file](/.code-samples.meilisearch.yaml) if the minor has been upgraded:
196+
You might need to change the [code-samples file](/.code-samples.meilisearch.yaml) if the minor has been upgraded:
191197

192198
```yml
193199
meilisearch-sdk = "X.X"

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "meilisearch-sdk"
3-
version = "0.21.2"
3+
version = "0.22.0"
44
authors = ["Mubelotix <[email protected]>"]
55
edition = "2018"
66
description = "Rust wrapper for the Meilisearch API. Meilisearch is a powerful, fast, open-source, easy to use and deploy search engine."
@@ -22,7 +22,7 @@ jsonwebtoken = { version = "8", default-features = false }
2222
yaup = "0.2.0"
2323
either = { version = "1.8.0", features = ["serde"] }
2424
thiserror = "1.0.37"
25-
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.1.0" }
25+
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.22.0" }
2626

2727

2828
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ To use `meilisearch-sdk`, add this to your `Cargo.toml`:
5252

5353
```toml
5454
[dependencies]
55-
meilisearch-sdk = "0.21.2"
55+
meilisearch-sdk = "0.22.0"
5656
```
5757

5858
The following optional dependencies may also be useful:
@@ -244,7 +244,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi
244244

245245
## 🤖 Compatibility with Meilisearch
246246

247-
This package only guarantees the compatibility with the [version v0.30.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.30.0).
247+
This package only guarantees the compatibility with the [version v1.0.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v1.0.0).
248248

249249
## ⚙️ Contributing
250250

README.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ To use `meilisearch-sdk`, add this to your `Cargo.toml`:
5252

5353
```toml
5454
[dependencies]
55-
meilisearch-sdk = "0.21.2"
55+
meilisearch-sdk = "0.22.0"
5656
```
5757

5858
The following optional dependencies may also be useful:
@@ -99,7 +99,7 @@ WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extensi
9999

100100
## 🤖 Compatibility with Meilisearch
101101

102-
This package only guarantees the compatibility with the [version v0.30.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.30.0).
102+
This package only guarantees the compatibility with the [version v1.0.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v1.0.0).
103103

104104
## ⚙️ Contributing
105105

examples/cli-app/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "cli-app"
3-
version = "0.1.0"
3+
version = "0.0.0"
44
edition = "2021"
5+
publish = false
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

examples/web_app/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "web_app"
3-
version = "0.1.0"
3+
version = "0.0.0"
44
authors = ["Mubelotix <[email protected]>"]
55
edition = "2018"
6+
publish = false
67

78
[lib]
89
crate-type = ["cdylib", "rlib"]

meilisearch-index-setting-macro/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "meilisearch-index-setting-macro"
3-
version = "0.1.0"
3+
version = "0.22.0"
44
description = "Helper tool to generate settings of an Meilisearch index"
55
edition = "2021"
66
license = "MIT"
@@ -16,6 +16,3 @@ quote = "1.0.21"
1616
proc-macro2 = "1.0.46"
1717
convert_case = "0.6.0"
1818

19-
[dev-dependencies]
20-
meilisearch-sdk = "0.20.1"
21-

meilisearch-index-setting-macro/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ fn extract_all_attr_values(
176176
return std::result::Result::Err(
177177
syn::Error::new(
178178
ident.span(),
179-
format!(
180-
"`{}` already exists for this field",
181-
ident
182-
),
179+
format!("`{ident}` already exists for this field"),
183180
)
184181
.to_compile_error(),
185182
);
@@ -190,8 +187,7 @@ fn extract_all_attr_values(
190187
syn::Error::new(
191188
ident.span(),
192189
format!(
193-
"Property `{}` does not exist for type `document`",
194-
ident
190+
"Property `{ident}` does not exist for type `document`"
195191
),
196192
)
197193
.to_compile_error(),
@@ -213,7 +209,6 @@ fn extract_all_attr_values(
213209
}
214210
}
215211
std::result::Result::Err(e) => {
216-
println!("{:#?}", attr);
217212
for token_stream in attr.tokens.clone().into_iter() {
218213
if let TokenTree::Group(group) = token_stream {
219214
for token in group.stream() {

meilisearch-test-macro/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "meilisearch-test-macro"
3-
version = "0.1.0"
3+
version = "0.0.0"
44
edition = "2021"
5+
publish = false
56

67
[lib]
78
proc-macro = true

scripts/update_macro_versions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
new_version=$(cat Cargo.toml | grep '^version = ')
3+
4+
# Updates the versions in meilisearch-rust and meilisearch-index-setting-macro of the latter, with the latest meilisearch-rust version.
5+
6+
old_index_macro_version=$(cat ./meilisearch-index-setting-macro/Cargo.toml | grep '^version = ')
7+
old_macro_in_sdk_version=$(cat ./Cargo.toml | grep '{ path = "meilisearch-index-setting-macro", version =')
8+
9+
sed -i '' -e "s/^$old_index_macro_version/$new_version/g" './meilisearch-index-setting-macro/Cargo.toml'
10+
sed -i '' -e "s/$old_macro_in_sdk_version/meilisearch-index-setting-macro = { path = \"meilisearch-index-setting-macro\", $new_version }/g" './Cargo.toml'

src/client.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,38 @@ impl Client {
6363
Ok(indexes_results)
6464
}
6565

66+
/// Return the host associated with this index.
67+
///
68+
/// # Example
69+
///
70+
/// ```
71+
/// # use meilisearch_sdk::{client::*};
72+
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
73+
/// // create the client
74+
/// let client = Client::new("http://doggo.dog", MEILISEARCH_API_KEY);
75+
///
76+
/// assert_eq!(client.get_host(), "http://doggo.dog");
77+
/// ```
78+
pub fn get_host(&self) -> &str {
79+
&self.host
80+
}
81+
82+
/// Return the api key associated with this index.
83+
///
84+
/// # Example
85+
///
86+
/// ```
87+
/// # use meilisearch_sdk::{client::*};
88+
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
89+
/// // create the client
90+
/// let client = Client::new(MEILISEARCH_URL, "doggo");
91+
///
92+
/// assert_eq!(client.get_api_key(), "doggo");
93+
/// ```
94+
pub fn get_api_key(&self) -> &str {
95+
&self.api_key
96+
}
97+
6698
/// List all [Index]es with query parameters and returns values as instances of [Index].
6799
///
68100
/// # Example

src/errors.rs

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,15 @@ pub enum ErrorCode {
122122
InvalidState,
123123
PrimaryKeyInferenceFailed,
124124
IndexPrimaryKeyAlreadyPresent,
125-
InvalidRankingRule,
126125
InvalidStoreFile,
127126
MaxFieldsLimitExceeded,
128127
MissingDocumentId,
129128
InvalidDocumentId,
130-
InvalidFilter,
131-
InvalidSort,
132129
BadParameter,
133130
BadRequest,
134131
DatabaseSizeLimitReached,
135132
DocumentNotFound,
136133
InternalError,
137-
InvalidGeoField,
138134
InvalidApiKey,
139135
MissingAuthorizationHeader,
140136
TaskNotFound,
@@ -151,18 +147,81 @@ pub enum ErrorCode {
151147
MalformedPayload,
152148
InvalidContentType,
153149
MissingPayload,
154-
MissingParameter,
155150
InvalidApiKeyDescription,
156151
InvalidApiKeyActions,
157152
InvalidApiKeyIndexes,
158153
InvalidApiKeyExpiresAt,
159154
ApiKeyNotFound,
160-
InvalidTaskTypesFilter,
161-
InvalidTaskStatusesFilter,
162-
InvalidTaskCanceledByFilter,
163-
InvalidTaskUidsFilter,
164-
InvalidTaskDateFilter,
165155
MissingTaskFilters,
156+
MissingIndexUid,
157+
InvalidIndexOffset,
158+
InvalidIndexLimit,
159+
InvalidIndexPrimaryKey,
160+
InvalidDocumentFields,
161+
InvalidDocumentLimit,
162+
InvalidDocumentOffset,
163+
InvalidDocumentGeoField,
164+
InvalidSearchQ,
165+
InvalidSearchOffset,
166+
InvalidSearchLimit,
167+
InvalidSearchPage,
168+
InvalidSearchHitsPerPage,
169+
InvalidSearchAttributesToRetrieve,
170+
InvalidSearchAttributesToCrop,
171+
InvalidSearchCropLength,
172+
InvalidSearchAttributesToHighlight,
173+
InvalidSearchShowMatchesPosition,
174+
InvalidSearchFilter,
175+
InvalidSearchSort,
176+
InvalidSearchFacets,
177+
InvalidSearchHighlightPreTag,
178+
InvalidSearchHighlightPostTag,
179+
InvalidSearchCropMarker,
180+
InvalidSearchMatchingStrategy,
181+
ImmutableApiKeyUid,
182+
ImmutableApiKeyActions,
183+
ImmutableApiKeyIndexes,
184+
ImmutableExpiresAt,
185+
ImmutableCreatedAt,
186+
ImmutableUpdatedAt,
187+
InvalidSwapDuplicateIndexFound,
188+
InvalidSwapIndexes,
189+
MissingSwapIndexes,
190+
InvalidTaskTypes,
191+
InvalidTaskUids,
192+
InvalidTaskStatuses,
193+
InvalidTaskLimit,
194+
InvalidTaskFrom,
195+
InvalidTaskCanceledBy,
196+
InvalidTaskFilters,
197+
TooManyOpenFiles,
198+
IoError,
199+
InvalidTaskIndexUids,
200+
ImmutableIndexUid,
201+
ImmutableIndexCreatedAt,
202+
ImmutableIndexUpdatedAt,
203+
InvalidSettingsDisplayedAttributes,
204+
InvalidSettingsSearchableAttributes,
205+
InvalidSettingsFilterableAttributes,
206+
InvalidSettingsSortableAttributes,
207+
InvalidSettingsRankingRules,
208+
InvalidSettingsStopWords,
209+
InvalidSettingsSynonyms,
210+
InvalidSettingsDistinctAttributes,
211+
InvalidSettingsTypoTolerance,
212+
InvalidSettingsFaceting,
213+
InvalidSettingsPagination,
214+
InvalidTaskBeforeEnqueuedAt,
215+
InvalidTaskAfterEnqueuedAt,
216+
InvalidTaskBeforeStartedAt,
217+
InvalidTaskAfterStartedAt,
218+
InvalidTaskBeforeFinishedAt,
219+
InvalidTaskAfterFinishedAt,
220+
MissingApiKeyActions,
221+
MissingApiKeyIndexes,
222+
MissingApiKeyExpiresAt,
223+
InvalidApiKeyLimit,
224+
InvalidApiKeyOffset,
166225

167226
/// That's unexpected. Please open a GitHub issue after ensuring you are
168227
/// using the supported version of the Meilisearch server.

src/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn add_query_parameters<Query: Serialize>(url: &str, query: &Query) -> Resul
1919
if query.is_empty() {
2020
Ok(url.to_string())
2121
} else {
22-
Ok(format!("{}?{}", url, query))
22+
Ok(format!("{url}?{query}"))
2323
}
2424
}
2525

@@ -37,7 +37,7 @@ pub(crate) async fn request<
3737
use isahc::http::header;
3838
use isahc::*;
3939

40-
let auth = format!("Bearer {}", apikey);
40+
let auth = format!("Bearer {apikey}");
4141
let user_agent = qualified_version();
4242

4343
let mut response = match &method {

0 commit comments

Comments
 (0)