Skip to content

Commit

Permalink
Add selector_mode field to chains
Browse files Browse the repository at this point in the history
This opens up more options for handling selector results. It also allows us to simplify the dynamic select chain input process, to just a single template.
  • Loading branch information
LucasPickering committed Sep 19, 2024
1 parent 1d16067 commit c97904e
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 386 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- When using the CLI, the `--profile` argument can be omitted to use the default profile
- Reset edited recipe values to their default using `r`
- You can [customize the key](https://slumber.lucaspickering.me/book/api/configuration/input_bindings.html) to whatever you want
- Add `selector_mode` field to chains, to control how single vs multiple results from a JSONPath selector are handled
- Previously, if a selector returned multiple results, an error was returned. Now, the result list will be rendered as a JSON array. To return to the previous behavior, set `selector_mode: single` in your chain.
- [See docs for more](https://slumber.lucaspickering.me/book/api/request_collection/chain.html#selector-mode)

### Changed

Expand Down
17 changes: 17 additions & 0 deletions crates/core/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ mod tests {
source: ChainSource::command(["whoami"]),
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -291,6 +292,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -299,6 +301,7 @@ mod tests {
source: ChainSource::command(["whoami"]),
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -307,6 +310,7 @@ mod tests {
source: ChainSource::command(["whoami"]),
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::Start,
},
Expand All @@ -315,6 +319,7 @@ mod tests {
source: ChainSource::command(["whoami"]),
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::End,
},
Expand All @@ -323,6 +328,7 @@ mod tests {
source: ChainSource::command(["whoami"]),
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::Both,
},
Expand All @@ -334,6 +340,7 @@ mod tests {
},
sensitive: true,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -345,6 +352,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -355,6 +363,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -365,6 +374,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: Some(ContentType::Json),
trim: ChainOutputTrim::None,
},
Expand All @@ -377,6 +387,7 @@ mod tests {
},
sensitive: false,
selector: Some("$.data".parse().unwrap()),
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -389,6 +400,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -401,6 +413,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -415,6 +428,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -427,6 +441,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -439,6 +454,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand All @@ -453,6 +469,7 @@ mod tests {
},
sensitive: false,
selector: None,
selector_mode: SelectorMode::default(),
content_type: None,
trim: ChainOutputTrim::None,
},
Expand Down
Loading

0 comments on commit c97904e

Please sign in to comment.