mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-01 17:15:46 +01:00
Update deserr to latest version + add new error codes for missing fields
- missing_api_key_indexes - missing_api_key_actions - missing_api_key_expires_at - missing_swap_indexes_indexes
This commit is contained in:
parent
436ae4e466
commit
766dd830ae
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -1025,8 +1025,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "deserr"
|
name = "deserr"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "86290491a2b5c21a1a5083da8dae831006761258fabd5617309c3eebc5f89468"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deserr-internal",
|
"deserr-internal",
|
||||||
"serde-cs",
|
"serde-cs",
|
||||||
@ -1036,8 +1034,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "deserr-internal"
|
name = "deserr-internal"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7131de1c27581bc376a22166c9f570be91b76cb096be2f6aecf224c27bf7c49a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"convert_case 0.5.0",
|
"convert_case 0.5.0",
|
||||||
"proc-macro2 1.0.49",
|
"proc-macro2 1.0.49",
|
||||||
@ -1315,8 +1311,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filter-parser"
|
name = "filter-parser"
|
||||||
version = "0.39.0"
|
version = "0.38.0"
|
||||||
source = "git+https://github.com/meilisearch/milli.git?tag=v0.39.0#e6bea999740b153871f665abce869ffbb5aa94c5"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nom",
|
"nom",
|
||||||
"nom_locate",
|
"nom_locate",
|
||||||
@ -1334,8 +1329,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flatten-serde-json"
|
name = "flatten-serde-json"
|
||||||
version = "0.39.0"
|
version = "0.38.0"
|
||||||
source = "git+https://github.com/meilisearch/milli.git?tag=v0.39.0#e6bea999740b153871f665abce869ffbb5aa94c5"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
@ -1899,8 +1893,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "json-depth-checker"
|
name = "json-depth-checker"
|
||||||
version = "0.39.0"
|
version = "0.38.0"
|
||||||
source = "git+https://github.com/meilisearch/milli.git?tag=v0.39.0#e6bea999740b153871f665abce869ffbb5aa94c5"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
@ -2448,8 +2441,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "milli"
|
name = "milli"
|
||||||
version = "0.39.0"
|
version = "0.38.0"
|
||||||
source = "git+https://github.com/meilisearch/milli.git?tag=v0.39.0#e6bea999740b153871f665abce869ffbb5aa94c5"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bimap",
|
"bimap",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
@ -9,14 +9,14 @@ actix-web = { version = "4.2.1", default-features = false }
|
|||||||
anyhow = "1.0.65"
|
anyhow = "1.0.65"
|
||||||
convert_case = "0.6.0"
|
convert_case = "0.6.0"
|
||||||
csv = "1.1.6"
|
csv = "1.1.6"
|
||||||
deserr = "0.1.4"
|
deserr = { path = "/Users/meilisearch/Documents/deserr" }
|
||||||
either = { version = "1.6.1", features = ["serde"] }
|
either = { version = "1.6.1", features = ["serde"] }
|
||||||
enum-iterator = "1.1.3"
|
enum-iterator = "1.1.3"
|
||||||
file-store = { path = "../file-store" }
|
file-store = { path = "../file-store" }
|
||||||
flate2 = "1.0.24"
|
flate2 = "1.0.24"
|
||||||
fst = "0.4.7"
|
fst = "0.4.7"
|
||||||
memmap2 = "0.5.7"
|
memmap2 = "0.5.7"
|
||||||
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.39.0", default-features = false }
|
milli = { path = "/Users/meilisearch/Documents/milli2/milli", default-features = false }
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { version = "1.0.0", optional = true }
|
||||||
proptest-derive = { version = "0.3.0", optional = true }
|
proptest-derive = { version = "0.3.0", optional = true }
|
||||||
roaring = { version = "0.10.0", features = ["serde"] }
|
roaring = { version = "0.10.0", features = ["serde"] }
|
||||||
|
@ -14,7 +14,9 @@ use serde_cs::vec::CS;
|
|||||||
|
|
||||||
use crate::star_or::StarOr;
|
use crate::star_or::StarOr;
|
||||||
|
|
||||||
use self::deserr_codes::MissingIndexUid;
|
use self::deserr_codes::{
|
||||||
|
MissingApiKeyActions, MissingApiKeyExpiresAt, MissingApiKeyIndexes, MissingIndexUid, InvalidSwapIndexes, MissingSwapIndexesIndexes,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@ -185,7 +187,6 @@ DumpAlreadyProcessing , invalid , CONFLICT;
|
|||||||
DumpNotFound , invalid , NOT_FOUND;
|
DumpNotFound , invalid , NOT_FOUND;
|
||||||
DumpProcessFailed , internal , INTERNAL_SERVER_ERROR;
|
DumpProcessFailed , internal , INTERNAL_SERVER_ERROR;
|
||||||
DuplicateIndexFound , invalid , BAD_REQUEST;
|
DuplicateIndexFound , invalid , BAD_REQUEST;
|
||||||
|
|
||||||
ImmutableApiKeyUid , invalid , BAD_REQUEST;
|
ImmutableApiKeyUid , invalid , BAD_REQUEST;
|
||||||
ImmutableApiKeyKey , invalid , BAD_REQUEST;
|
ImmutableApiKeyKey , invalid , BAD_REQUEST;
|
||||||
ImmutableApiKeyActions , invalid , BAD_REQUEST;
|
ImmutableApiKeyActions , invalid , BAD_REQUEST;
|
||||||
@ -193,11 +194,9 @@ ImmutableApiKeyIndexes , invalid , BAD_REQUEST;
|
|||||||
ImmutableApiKeyExpiresAt , invalid , BAD_REQUEST;
|
ImmutableApiKeyExpiresAt , invalid , BAD_REQUEST;
|
||||||
ImmutableApiKeyCreatedAt , invalid , BAD_REQUEST;
|
ImmutableApiKeyCreatedAt , invalid , BAD_REQUEST;
|
||||||
ImmutableApiKeyUpdatedAt , invalid , BAD_REQUEST;
|
ImmutableApiKeyUpdatedAt , invalid , BAD_REQUEST;
|
||||||
|
|
||||||
ImmutableIndexUid , invalid , BAD_REQUEST;
|
ImmutableIndexUid , invalid , BAD_REQUEST;
|
||||||
ImmutableIndexCreatedAt , invalid , BAD_REQUEST;
|
ImmutableIndexCreatedAt , invalid , BAD_REQUEST;
|
||||||
ImmutableIndexUpdatedAt , invalid , BAD_REQUEST;
|
ImmutableIndexUpdatedAt , invalid , BAD_REQUEST;
|
||||||
|
|
||||||
IndexAlreadyExists , invalid , CONFLICT ;
|
IndexAlreadyExists , invalid , CONFLICT ;
|
||||||
IndexCreationFailed , internal , INTERNAL_SERVER_ERROR;
|
IndexCreationFailed , internal , INTERNAL_SERVER_ERROR;
|
||||||
IndexNotFound , invalid , NOT_FOUND;
|
IndexNotFound , invalid , NOT_FOUND;
|
||||||
@ -281,6 +280,7 @@ MissingDocumentId , invalid , BAD_REQUEST ;
|
|||||||
MissingIndexUid , invalid , BAD_REQUEST ;
|
MissingIndexUid , invalid , BAD_REQUEST ;
|
||||||
MissingMasterKey , authentication, UNAUTHORIZED ;
|
MissingMasterKey , authentication, UNAUTHORIZED ;
|
||||||
MissingPayload , invalid , BAD_REQUEST ;
|
MissingPayload , invalid , BAD_REQUEST ;
|
||||||
|
MissingSwapIndexesIndexes , invalid , BAD_REQUEST ;
|
||||||
MissingTaskFilters , invalid , BAD_REQUEST ;
|
MissingTaskFilters , invalid , BAD_REQUEST ;
|
||||||
NoSpaceLeftOnDevice , system , UNPROCESSABLE_ENTITY;
|
NoSpaceLeftOnDevice , system , UNPROCESSABLE_ENTITY;
|
||||||
PayloadTooLarge , invalid , PAYLOAD_TOO_LARGE ;
|
PayloadTooLarge , invalid , PAYLOAD_TOO_LARGE ;
|
||||||
@ -478,6 +478,47 @@ impl DeserrJsonError<MissingIndexUid> {
|
|||||||
Self { msg: x.msg, code: MissingIndexUid.error_code(), _phantom: PhantomData }
|
Self { msg: x.msg, code: MissingIndexUid.error_code(), _phantom: PhantomData }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl DeserrJsonError<MissingApiKeyActions> {
|
||||||
|
pub fn missing_api_key_actions(field: &str, location: ValuePointerRef) -> Self {
|
||||||
|
let x = unwrap_any(Self::error::<Infallible>(
|
||||||
|
None,
|
||||||
|
deserr::ErrorKind::MissingField { field },
|
||||||
|
location,
|
||||||
|
));
|
||||||
|
Self { msg: x.msg, code: MissingApiKeyActions.error_code(), _phantom: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl DeserrJsonError<MissingApiKeyExpiresAt> {
|
||||||
|
pub fn missing_api_key_expires_at(field: &str, location: ValuePointerRef) -> Self {
|
||||||
|
let x = unwrap_any(Self::error::<Infallible>(
|
||||||
|
None,
|
||||||
|
deserr::ErrorKind::MissingField { field },
|
||||||
|
location,
|
||||||
|
));
|
||||||
|
Self { msg: x.msg, code: MissingApiKeyExpiresAt.error_code(), _phantom: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl DeserrJsonError<MissingApiKeyIndexes> {
|
||||||
|
pub fn missing_api_key_indexes(field: &str, location: ValuePointerRef) -> Self {
|
||||||
|
let x = unwrap_any(Self::error::<Infallible>(
|
||||||
|
None,
|
||||||
|
deserr::ErrorKind::MissingField { field },
|
||||||
|
location,
|
||||||
|
));
|
||||||
|
Self { msg: x.msg, code: MissingApiKeyIndexes.error_code(), _phantom: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeserrJsonError<InvalidSwapIndexes> {
|
||||||
|
pub fn missing_swap_indexes_indexes(field: &str, location: ValuePointerRef) -> Self {
|
||||||
|
let x = unwrap_any(Self::error::<Infallible>(
|
||||||
|
None,
|
||||||
|
deserr::ErrorKind::MissingField { field },
|
||||||
|
location,
|
||||||
|
));
|
||||||
|
Self { msg: x.msg, code: MissingSwapIndexesIndexes.error_code(), _phantom: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if the error happened in the root, then an empty string is returned.
|
// if the error happened in the root, then an empty string is returned.
|
||||||
pub fn location_json_description(location: ValuePointerRef, article: &str) -> String {
|
pub fn location_json_description(location: ValuePointerRef, article: &str) -> String {
|
||||||
|
@ -38,17 +38,17 @@ fn parse_uuid_from_str(s: &str) -> Result<Uuid, TakeErrorMessage<uuid::Error>> {
|
|||||||
#[derive(Debug, DeserializeFromValue)]
|
#[derive(Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct CreateApiKey {
|
pub struct CreateApiKey {
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyDescription>)]
|
#[deserr(default, error = DeserrJsonError<InvalidApiKeyDescription>)]
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyName>)]
|
#[deserr(default, error = DeserrJsonError<InvalidApiKeyName>)]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
#[deserr(default = Uuid::new_v4(), error = DeserrJsonError<InvalidApiKeyUid>, from(&String) = parse_uuid_from_str -> TakeErrorMessage<uuid::Error>)]
|
#[deserr(default = Uuid::new_v4(), error = DeserrJsonError<InvalidApiKeyUid>, from(&String) = parse_uuid_from_str -> TakeErrorMessage<uuid::Error>)]
|
||||||
pub uid: KeyId,
|
pub uid: KeyId,
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyActions>)]
|
#[deserr(error = DeserrJsonError<InvalidApiKeyActions>, missing_field_error = DeserrJsonError::missing_api_key_actions)]
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyIndexes>)]
|
#[deserr(error = DeserrJsonError<InvalidApiKeyIndexes>, missing_field_error = DeserrJsonError::missing_api_key_indexes)]
|
||||||
pub indexes: Vec<StarOr<IndexUid>>,
|
pub indexes: Vec<StarOr<IndexUid>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyExpiresAt>, default = None, from(&String) = parse_expiration_date -> TakeErrorMessage<ParseOffsetDateTimeError>)]
|
#[deserr(error = DeserrJsonError<InvalidApiKeyExpiresAt>, from(&String) = parse_expiration_date -> TakeErrorMessage<ParseOffsetDateTimeError>, missing_field_error = DeserrJsonError::missing_api_key_expires_at)]
|
||||||
pub expires_at: Option<OffsetDateTime>,
|
pub expires_at: Option<OffsetDateTime>,
|
||||||
}
|
}
|
||||||
impl CreateApiKey {
|
impl CreateApiKey {
|
||||||
@ -94,9 +94,9 @@ fn deny_immutable_fields_api_key(
|
|||||||
#[derive(Debug, DeserializeFromValue)]
|
#[derive(Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields = deny_immutable_fields_api_key)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields = deny_immutable_fields_api_key)]
|
||||||
pub struct PatchApiKey {
|
pub struct PatchApiKey {
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyDescription>)]
|
#[deserr(default, error = DeserrJsonError<InvalidApiKeyDescription>)]
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidApiKeyName>)]
|
#[deserr(default, error = DeserrJsonError<InvalidApiKeyName>)]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ pub mod star_or;
|
|||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
pub mod versioning;
|
pub mod versioning;
|
||||||
|
|
||||||
pub use deserr;
|
|
||||||
pub use milli;
|
pub use milli;
|
||||||
pub use milli::{heed, Index};
|
pub use milli::{heed, Index};
|
||||||
pub use serde_cs;
|
pub use serde_cs;
|
||||||
|
@ -69,8 +69,10 @@ fn validate_min_word_size_for_typo_setting<E: DeserializeError>(
|
|||||||
#[deserr(deny_unknown_fields, rename_all = camelCase, validate = validate_min_word_size_for_typo_setting -> DeserrJsonError<InvalidMinWordLengthForTypo>)]
|
#[deserr(deny_unknown_fields, rename_all = camelCase, validate = validate_min_word_size_for_typo_setting -> DeserrJsonError<InvalidMinWordLengthForTypo>)]
|
||||||
pub struct MinWordSizeTyposSetting {
|
pub struct MinWordSizeTyposSetting {
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub one_typo: Setting<u8>,
|
pub one_typo: Setting<u8>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub two_typos: Setting<u8>,
|
pub two_typos: Setting<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,13 +81,16 @@ pub struct MinWordSizeTyposSetting {
|
|||||||
#[deserr(deny_unknown_fields, rename_all = camelCase, where_predicate = __Deserr_E: deserr::MergeWithError<DeserrJsonError<InvalidMinWordLengthForTypo>>)]
|
#[deserr(deny_unknown_fields, rename_all = camelCase, where_predicate = __Deserr_E: deserr::MergeWithError<DeserrJsonError<InvalidMinWordLengthForTypo>>)]
|
||||||
pub struct TypoSettings {
|
pub struct TypoSettings {
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub enabled: Setting<bool>,
|
pub enabled: Setting<bool>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidMinWordLengthForTypo>)]
|
#[deserr(default, error = DeserrJsonError<InvalidMinWordLengthForTypo>)]
|
||||||
pub min_word_size_for_typos: Setting<MinWordSizeTyposSetting>,
|
pub min_word_size_for_typos: Setting<MinWordSizeTyposSetting>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub disable_on_words: Setting<BTreeSet<String>>,
|
pub disable_on_words: Setting<BTreeSet<String>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub disable_on_attributes: Setting<BTreeSet<String>>,
|
pub disable_on_attributes: Setting<BTreeSet<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +99,7 @@ pub struct TypoSettings {
|
|||||||
#[deserr(rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct FacetingSettings {
|
pub struct FacetingSettings {
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub max_values_per_facet: Setting<usize>,
|
pub max_values_per_facet: Setting<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +108,7 @@ pub struct FacetingSettings {
|
|||||||
#[deserr(rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct PaginationSettings {
|
pub struct PaginationSettings {
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
|
#[deserr(default)]
|
||||||
pub max_total_hits: Setting<usize>,
|
pub max_total_hits: Setting<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +142,7 @@ pub struct Settings<T> {
|
|||||||
serialize_with = "serialize_with_wildcard",
|
serialize_with = "serialize_with_wildcard",
|
||||||
skip_serializing_if = "Setting::is_not_set"
|
skip_serializing_if = "Setting::is_not_set"
|
||||||
)]
|
)]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsDisplayedAttributes>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsDisplayedAttributes>)]
|
||||||
pub displayed_attributes: Setting<Vec<String>>,
|
pub displayed_attributes: Setting<Vec<String>>,
|
||||||
|
|
||||||
#[serde(
|
#[serde(
|
||||||
@ -143,35 +150,35 @@ pub struct Settings<T> {
|
|||||||
serialize_with = "serialize_with_wildcard",
|
serialize_with = "serialize_with_wildcard",
|
||||||
skip_serializing_if = "Setting::is_not_set"
|
skip_serializing_if = "Setting::is_not_set"
|
||||||
)]
|
)]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsSearchableAttributes>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsSearchableAttributes>)]
|
||||||
pub searchable_attributes: Setting<Vec<String>>,
|
pub searchable_attributes: Setting<Vec<String>>,
|
||||||
|
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsFilterableAttributes>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsFilterableAttributes>)]
|
||||||
pub filterable_attributes: Setting<BTreeSet<String>>,
|
pub filterable_attributes: Setting<BTreeSet<String>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsSortableAttributes>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsSortableAttributes>)]
|
||||||
pub sortable_attributes: Setting<BTreeSet<String>>,
|
pub sortable_attributes: Setting<BTreeSet<String>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsRankingRules>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsRankingRules>)]
|
||||||
pub ranking_rules: Setting<Vec<RankingRuleView>>,
|
pub ranking_rules: Setting<Vec<RankingRuleView>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsStopWords>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsStopWords>)]
|
||||||
pub stop_words: Setting<BTreeSet<String>>,
|
pub stop_words: Setting<BTreeSet<String>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsSynonyms>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsSynonyms>)]
|
||||||
pub synonyms: Setting<BTreeMap<String, Vec<String>>>,
|
pub synonyms: Setting<BTreeMap<String, Vec<String>>>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsDistinctAttribute>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsDistinctAttribute>)]
|
||||||
pub distinct_attribute: Setting<String>,
|
pub distinct_attribute: Setting<String>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsTypoTolerance>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsTypoTolerance>)]
|
||||||
pub typo_tolerance: Setting<TypoSettings>,
|
pub typo_tolerance: Setting<TypoSettings>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsFaceting>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsFaceting>)]
|
||||||
pub faceting: Setting<FacetingSettings>,
|
pub faceting: Setting<FacetingSettings>,
|
||||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsPagination>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSettingsPagination>)]
|
||||||
pub pagination: Setting<PaginationSettings>,
|
pub pagination: Setting<PaginationSettings>,
|
||||||
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
@ -19,7 +19,7 @@ byte-unit = { version = "4.0.14", default-features = false, features = ["std", "
|
|||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
clap = { version = "4.0.9", features = ["derive", "env"] }
|
clap = { version = "4.0.9", features = ["derive", "env"] }
|
||||||
crossbeam-channel = "0.5.6"
|
crossbeam-channel = "0.5.6"
|
||||||
deserr = "0.1.4"
|
deserr = { path = "/Users/meilisearch/Documents/deserr" }
|
||||||
dump = { path = "../dump" }
|
dump = { path = "../dump" }
|
||||||
either = "1.8.0"
|
either = "1.8.0"
|
||||||
env_logger = "0.9.1"
|
env_logger = "0.9.1"
|
||||||
|
@ -55,10 +55,10 @@ pub async fn create_api_key(
|
|||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct ListApiKeys {
|
pub struct ListApiKeys {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidApiKeyOffset>, default, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidApiKeyOffset>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidApiKeyLimit>, default = PAGINATION_DEFAULT_LIMIT(), from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default = PAGINATION_DEFAULT_LIMIT(), error = DeserrQueryParamError<InvalidApiKeyLimit>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
pub limit: usize,
|
pub limit: usize,
|
||||||
}
|
}
|
||||||
impl ListApiKeys {
|
impl ListApiKeys {
|
||||||
|
@ -85,7 +85,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct GetDocument {
|
pub struct GetDocument {
|
||||||
// TODO: strongly typed argument here
|
// TODO: strongly typed argument here
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidDocumentFields>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentFields>)]
|
||||||
fields: Option<CS<StarOr<String>>>,
|
fields: Option<CS<StarOr<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,11 +122,11 @@ pub async fn delete_document(
|
|||||||
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct BrowseQuery {
|
pub struct BrowseQuery {
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidDocumentFields>, default, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<ParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentFields>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<ParseIntError>)]
|
||||||
offset: usize,
|
offset: usize,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidDocumentLimit>, default = crate::routes::PAGINATION_DEFAULT_LIMIT(), from(&String) = parse_usize_take_error_message -> TakeErrorMessage<ParseIntError>)]
|
#[deserr(default = crate::routes::PAGINATION_DEFAULT_LIMIT(), error = DeserrQueryParamError<InvalidDocumentLimit>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<ParseIntError>)]
|
||||||
limit: usize,
|
limit: usize,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidDocumentLimit>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidDocumentLimit>)]
|
||||||
fields: Option<CS<StarOr<String>>>,
|
fields: Option<CS<StarOr<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ pub async fn get_all_documents(
|
|||||||
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct UpdateDocumentsQuery {
|
pub struct UpdateDocumentsQuery {
|
||||||
#[deserr(error = DeserrJsonError<InvalidIndexPrimaryKey>)]
|
#[deserr(default, error = DeserrJsonError<InvalidIndexPrimaryKey>)]
|
||||||
pub primary_key: Option<String>,
|
pub primary_key: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ impl IndexView {
|
|||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct ListIndexes {
|
pub struct ListIndexes {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidIndexOffset>, default, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidIndexOffset>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidIndexLimit>, default = PAGINATION_DEFAULT_LIMIT(), from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default = PAGINATION_DEFAULT_LIMIT(), error = DeserrQueryParamError<InvalidIndexLimit>, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
pub limit: usize,
|
pub limit: usize,
|
||||||
}
|
}
|
||||||
impl ListIndexes {
|
impl ListIndexes {
|
||||||
|
@ -48,39 +48,39 @@ pub fn parse_bool_take_error_message(
|
|||||||
#[derive(Debug, deserr::DeserializeFromValue)]
|
#[derive(Debug, deserr::DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct SearchQueryGet {
|
pub struct SearchQueryGet {
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchQ>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchQ>)]
|
||||||
q: Option<String>,
|
q: Option<String>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchOffset>, default = DEFAULT_SEARCH_OFFSET(), from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default = DEFAULT_SEARCH_OFFSET(), error = DeserrQueryParamError<InvalidSearchOffset>, from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
offset: usize,
|
offset: usize,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchLimit>, default = DEFAULT_SEARCH_LIMIT(), from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default = DEFAULT_SEARCH_LIMIT(), error = DeserrQueryParamError<InvalidSearchLimit>, from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
limit: usize,
|
limit: usize,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchPage>, from(Option<String>) = parse_option_usize_query_param -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchPage>, from(Option<String>) = parse_option_usize_query_param -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchHitsPerPage>, from(Option<String>) = parse_option_usize_query_param -> TakeErrorMessage<std::num::ParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchHitsPerPage>, from(Option<String>) = parse_option_usize_query_param -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
hits_per_page: Option<usize>,
|
hits_per_page: Option<usize>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchAttributesToRetrieve>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchAttributesToRetrieve>)]
|
||||||
attributes_to_retrieve: Option<CS<String>>,
|
attributes_to_retrieve: Option<CS<String>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchAttributesToCrop>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchAttributesToCrop>)]
|
||||||
attributes_to_crop: Option<CS<String>>,
|
attributes_to_crop: Option<CS<String>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchCropLength>, default = DEFAULT_CROP_LENGTH(), from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default = DEFAULT_CROP_LENGTH(), error = DeserrQueryParamError<InvalidSearchCropLength>, from(String) = parse_usize_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
crop_length: usize,
|
crop_length: usize,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchAttributesToHighlight>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchAttributesToHighlight>)]
|
||||||
attributes_to_highlight: Option<CS<String>>,
|
attributes_to_highlight: Option<CS<String>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchFilter>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchFilter>)]
|
||||||
filter: Option<String>,
|
filter: Option<String>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchSort>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchSort>)]
|
||||||
sort: Option<String>,
|
sort: Option<String>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchShowMatchesPosition>, default, from(&String) = parse_bool_take_error_message -> TakeErrorMessage<std::str::ParseBoolError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchShowMatchesPosition>, from(&String) = parse_bool_take_error_message -> TakeErrorMessage<std::str::ParseBoolError>)]
|
||||||
show_matches_position: bool,
|
show_matches_position: bool,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchFacets>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchFacets>)]
|
||||||
facets: Option<CS<String>>,
|
facets: Option<CS<String>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchHighlightPreTag>, default = DEFAULT_HIGHLIGHT_PRE_TAG())]
|
#[deserr( default = DEFAULT_HIGHLIGHT_PRE_TAG(), error = DeserrQueryParamError<InvalidSearchHighlightPreTag>)]
|
||||||
highlight_pre_tag: String,
|
highlight_pre_tag: String,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchHighlightPostTag>, default = DEFAULT_HIGHLIGHT_POST_TAG())]
|
#[deserr( default = DEFAULT_HIGHLIGHT_POST_TAG(), error = DeserrQueryParamError<InvalidSearchHighlightPostTag>)]
|
||||||
highlight_post_tag: String,
|
highlight_post_tag: String,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchCropMarker>, default = DEFAULT_CROP_MARKER())]
|
#[deserr(default = DEFAULT_CROP_MARKER(), error = DeserrQueryParamError<InvalidSearchCropMarker>)]
|
||||||
crop_marker: String,
|
crop_marker: String,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidSearchMatchingStrategy>, default)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidSearchMatchingStrategy>)]
|
||||||
matching_strategy: MatchingStrategy,
|
matching_strategy: MatchingStrategy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
#[derive(DeserializeFromValue, Debug, Clone, PartialEq, Eq)]
|
#[derive(DeserializeFromValue, Debug, Clone, PartialEq, Eq)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct SwapIndexesPayload {
|
pub struct SwapIndexesPayload {
|
||||||
#[deserr(error = DeserrJsonError<InvalidSwapIndexes>)]
|
#[deserr(error = DeserrJsonError<InvalidSwapIndexes>, missing_field_error = DeserrJsonError::missing_swap_indexes_indexes)]
|
||||||
indexes: Vec<String>,
|
indexes: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,61 +169,61 @@ impl From<Details> for DetailsView {
|
|||||||
#[derive(Debug, DeserializeFromValue)]
|
#[derive(Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct TasksFilterQuery {
|
pub struct TasksFilterQuery {
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskLimit>, default = DEFAULT_LIMIT(), from(String) = parse_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default = DEFAULT_LIMIT(), error = DeserrQueryParamError<InvalidTaskLimit>, from(String) = parse_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub limit: u32,
|
pub limit: u32,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskFrom>, from(Option<String>) = parse_option_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskFrom>, from(Option<String>) = parse_option_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub from: Option<TaskId>,
|
pub from: Option<TaskId>,
|
||||||
|
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskUids>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskUids>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub uids: Option<Vec<u32>>,
|
pub uids: Option<Vec<u32>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskCanceledBy>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskCanceledBy>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub canceled_by: Option<Vec<u32>>,
|
pub canceled_by: Option<Vec<u32>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskTypes>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Kind> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskTypes>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Kind> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub types: Option<Vec<Kind>>,
|
pub types: Option<Vec<Kind>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskStatuses>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Status> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskStatuses>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Status> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub statuses: Option<Vec<Status>>,
|
pub statuses: Option<Vec<Status>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidIndexUid>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<IndexUid> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidIndexUid>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<IndexUid> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub index_uids: Option<Vec<IndexUid>>,
|
pub index_uids: Option<Vec<IndexUid>>,
|
||||||
|
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_enqueued_at: Option<OffsetDateTime>,
|
pub after_enqueued_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_enqueued_at: Option<OffsetDateTime>,
|
pub before_enqueued_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterStartedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterStartedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_started_at: Option<OffsetDateTime>,
|
pub after_started_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeStartedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeStartedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_started_at: Option<OffsetDateTime>,
|
pub before_started_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterFinishedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterFinishedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_finished_at: Option<OffsetDateTime>,
|
pub after_finished_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeFinishedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeFinishedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_finished_at: Option<OffsetDateTime>,
|
pub before_finished_at: Option<OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
#[derive(Deserialize, Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrQueryParamError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct TaskDeletionOrCancelationQuery {
|
pub struct TaskDeletionOrCancelationQuery {
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskUids>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskUids>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub uids: Option<Vec<u32>>,
|
pub uids: Option<Vec<u32>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskCanceledBy>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskCanceledBy>, from(Option<CS<String>>) = parse_option_vec_u32_query_param -> TakeErrorMessage<DetailedParseIntError>)]
|
||||||
pub canceled_by: Option<Vec<u32>>,
|
pub canceled_by: Option<Vec<u32>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskTypes>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Kind> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskTypes>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Kind> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub types: Option<Vec<Kind>>,
|
pub types: Option<Vec<Kind>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskStatuses>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Status> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskStatuses>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<Status> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub statuses: Option<Vec<Status>>,
|
pub statuses: Option<Vec<Status>>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidIndexUid>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<IndexUid> -> TakeErrorMessage<ResponseError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidIndexUid>, default = None, from(Option<CS<StarOr<String>>>) = parse_option_cs_star_or::<IndexUid> -> TakeErrorMessage<ResponseError>)]
|
||||||
pub index_uids: Option<Vec<IndexUid>>,
|
pub index_uids: Option<Vec<IndexUid>>,
|
||||||
|
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_enqueued_at: Option<OffsetDateTime>,
|
pub after_enqueued_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeEnqueuedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_enqueued_at: Option<OffsetDateTime>,
|
pub before_enqueued_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterStartedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterStartedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_started_at: Option<OffsetDateTime>,
|
pub after_started_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeStartedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeStartedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_started_at: Option<OffsetDateTime>,
|
pub before_started_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskAfterFinishedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskAfterFinishedAt>, default = None, from(Option<String>) = deserialize_date_after -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub after_finished_at: Option<OffsetDateTime>,
|
pub after_finished_at: Option<OffsetDateTime>,
|
||||||
#[deserr(error = DeserrQueryParamError<InvalidTaskBeforeFinishedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
#[deserr(default, error = DeserrQueryParamError<InvalidTaskBeforeFinishedAt>, default = None, from(Option<String>) = deserialize_date_before -> TakeErrorMessage<InvalidTaskDateError>)]
|
||||||
pub before_finished_at: Option<OffsetDateTime>,
|
pub before_finished_at: Option<OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ use std::collections::{BTreeMap, BTreeSet, HashSet};
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use deserr::DeserializeFromValue;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use meilisearch_types::deserr::DeserializeFromValue;
|
|
||||||
use meilisearch_types::error::deserr_codes::*;
|
use meilisearch_types::error::deserr_codes::*;
|
||||||
use meilisearch_types::error::DeserrJsonError;
|
use meilisearch_types::error::DeserrJsonError;
|
||||||
use meilisearch_types::settings::DEFAULT_PAGINATION_MAX_TOTAL_HITS;
|
use meilisearch_types::settings::DEFAULT_PAGINATION_MAX_TOTAL_HITS;
|
||||||
@ -32,39 +32,39 @@ pub const DEFAULT_HIGHLIGHT_POST_TAG: fn() -> String = || "</em>".to_string();
|
|||||||
#[derive(Debug, Clone, Default, PartialEq, DeserializeFromValue)]
|
#[derive(Debug, Clone, Default, PartialEq, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct SearchQuery {
|
pub struct SearchQuery {
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchQ>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchQ>)]
|
||||||
pub q: Option<String>,
|
pub q: Option<String>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchOffset>, default = DEFAULT_SEARCH_OFFSET())]
|
#[deserr(default = DEFAULT_SEARCH_OFFSET(), error = DeserrJsonError<InvalidSearchOffset>)]
|
||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchLimit>, default = DEFAULT_SEARCH_LIMIT())]
|
#[deserr(default = DEFAULT_SEARCH_LIMIT(), error = DeserrJsonError<InvalidSearchLimit>)]
|
||||||
pub limit: usize,
|
pub limit: usize,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchPage>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchPage>)]
|
||||||
pub page: Option<usize>,
|
pub page: Option<usize>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchHitsPerPage>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchHitsPerPage>)]
|
||||||
pub hits_per_page: Option<usize>,
|
pub hits_per_page: Option<usize>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchAttributesToRetrieve>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchAttributesToRetrieve>)]
|
||||||
pub attributes_to_retrieve: Option<BTreeSet<String>>,
|
pub attributes_to_retrieve: Option<BTreeSet<String>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchAttributesToCrop>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchAttributesToCrop>)]
|
||||||
pub attributes_to_crop: Option<Vec<String>>,
|
pub attributes_to_crop: Option<Vec<String>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchCropLength>, default = DEFAULT_CROP_LENGTH())]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchCropLength>, default = DEFAULT_CROP_LENGTH())]
|
||||||
pub crop_length: usize,
|
pub crop_length: usize,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchAttributesToHighlight>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchAttributesToHighlight>)]
|
||||||
pub attributes_to_highlight: Option<HashSet<String>>,
|
pub attributes_to_highlight: Option<HashSet<String>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchShowMatchesPosition>, default)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchShowMatchesPosition>, default)]
|
||||||
pub show_matches_position: bool,
|
pub show_matches_position: bool,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchFilter>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchFilter>)]
|
||||||
pub filter: Option<Value>,
|
pub filter: Option<Value>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchSort>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchSort>)]
|
||||||
pub sort: Option<Vec<String>>,
|
pub sort: Option<Vec<String>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchFacets>)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchFacets>)]
|
||||||
pub facets: Option<Vec<String>>,
|
pub facets: Option<Vec<String>>,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchHighlightPreTag>, default = DEFAULT_HIGHLIGHT_PRE_TAG())]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchHighlightPreTag>, default = DEFAULT_HIGHLIGHT_PRE_TAG())]
|
||||||
pub highlight_pre_tag: String,
|
pub highlight_pre_tag: String,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchHighlightPostTag>, default = DEFAULT_HIGHLIGHT_POST_TAG())]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchHighlightPostTag>, default = DEFAULT_HIGHLIGHT_POST_TAG())]
|
||||||
pub highlight_post_tag: String,
|
pub highlight_post_tag: String,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchCropMarker>, default = DEFAULT_CROP_MARKER())]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchCropMarker>, default = DEFAULT_CROP_MARKER())]
|
||||||
pub crop_marker: String,
|
pub crop_marker: String,
|
||||||
#[deserr(error = DeserrJsonError<InvalidSearchMatchingStrategy>, default)]
|
#[deserr(default, error = DeserrJsonError<InvalidSearchMatchingStrategy>, default)]
|
||||||
pub matching_strategy: MatchingStrategy,
|
pub matching_strategy: MatchingStrategy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,9 +249,9 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Missing field `indexes`",
|
"message": "Missing field `indexes`",
|
||||||
"code": "bad_request",
|
"code": "missing_api_key_indexes",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#bad-request"
|
"link": "https://docs.meilisearch.com/errors#missing-api-key-indexes"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
@ -266,9 +266,9 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Missing field `actions`",
|
"message": "Missing field `actions`",
|
||||||
"code": "bad_request",
|
"code": "missing_api_key_actions",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#bad-request"
|
"link": "https://docs.meilisearch.com/errors#missing-api-key-actions"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
@ -279,22 +279,13 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
"actions": ["documents.add"],
|
"actions": ["documents.add"],
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::snapshot!(code, @"201 Created");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"message": "Missing field `expiresAt`",
|
||||||
"description": "Indexing API key",
|
"code": "missing_api_key_expires_at",
|
||||||
"key": "[ignored]",
|
"type": "invalid_request",
|
||||||
"uid": "[ignored]",
|
"link": "https://docs.meilisearch.com/errors#missing-api-key-expires-at"
|
||||||
"actions": [
|
|
||||||
"documents.add"
|
|
||||||
],
|
|
||||||
"indexes": [
|
|
||||||
"products"
|
|
||||||
],
|
|
||||||
"expiresAt": null,
|
|
||||||
"createdAt": "[ignored]",
|
|
||||||
"updatedAt": "[ignored]"
|
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
@ -926,7 +926,7 @@ async fn error_primary_key_inference() {
|
|||||||
"indexedDocuments": 1
|
"indexedDocuments": 1
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": "The primary key inference failed as the engine did not find any field ending with `id` in its name. Please specify the primary key manually using the `primaryKey` query parameter.",
|
"message": "The primary key inference process failed because the engine did not find any field ending with `id` in its name. Please specify the primary key manually using the `primaryKey` query parameter.",
|
||||||
"code": "index_primary_key_no_candidate_found",
|
"code": "index_primary_key_no_candidate_found",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#index-primary-key-no-candidate-found"
|
"link": "https://docs.meilisearch.com/errors#index-primary-key-no-candidate-found"
|
||||||
@ -966,7 +966,7 @@ async fn error_primary_key_inference() {
|
|||||||
"indexedDocuments": 1
|
"indexedDocuments": 1
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": "The primary key inference failed as the engine found 3 fields ending with `id` in their names: 'id' and 'object_id'. Please specify the primary key manually using the `primaryKey` query parameter.",
|
"message": "The primary key inference process failed because the engine found 3 fields ending with `id` in their name, such as 'id' and 'object_id'. Please specify the primary key manually using the `primaryKey` query parameter.",
|
||||||
"code": "index_primary_key_multiple_candidates_found",
|
"code": "index_primary_key_multiple_candidates_found",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#index-primary-key-multiple-candidates-found"
|
"link": "https://docs.meilisearch.com/errors#index-primary-key-multiple-candidates-found"
|
||||||
|
Loading…
Reference in New Issue
Block a user