refs https://github.com/TryGhost/Team/issues/1666
- it seems like we may have a situation where `.activateTheme()` can be called simultaneously resulting in unexpected behaviour in the sync such as duplicate theme setting records
- adjusted behaviour to keep track of the currently running activation within the service and if `.activateTheme()` is called again whilst it's in progress it will wait for completion of the first sync before exiting early or continuing with a new activation
**Note:** There is a known edge-case if there are _more_ than 2 parallel `.activateTheme()` calls. We don't believe that will be an issue but calling it out in case we do still see duplicated custom setting records being created.
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
no issue
- we were passing the theme name directly in the model query filter string without any surrounding `'` chars meaning we were generating invalid filters
no issue
Ghost allows multiple themes with the same `name` value in `package.json` so it assigns custom names based on the file name. When syncing we were only looking at the package.json `name` value so there could be a syncing clash when swapping between active themes.
- added `name` as the first argument to `.activateTheme(name, theme)` so that the service's consumer is in control of settings sync applying to it's known theme name
refs https://github.com/TryGhost/Team/issues/1104
- better matches the context of the request as we're validating known keys and valid options from multiple settings
- "404 Not Found" didn't make sense because `/custom_theme_settings/` _does_ exist, it's just that one setting key wasn't known
- "400 Bad Request" didn't make sense because the request was understood, it just failed validation of the setting values
refs https://github.com/TryGhost/Team/issues/1104
- there was a mismatch of template options when throwing error on invalid select value meaning we were erroring but with the wrong error type and message
- added missing `lodash` dependency in package.json
refs https://github.com/TryGhost/Team/issues/1104
- `.get('key')` would error because it was incorrectly expecting the internal content object to contain `{key, value}` objects
- changed `.getAll()` to return a shallow copy of the internal content object so we don't leak references that can result in unexpected changes to the cache content
- changed the internal content object naming to `_content` to highlight that it's an internal/private implementation detail rather than a public API