Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Observable.of(model).flatMap((m) => {
const modelDefinition = m.modelDefinition;
if (!modelDefinition && !modelDefinition.name) {
return Promise.reject(new Error(`Can not find modelDefinition for ${m.id}`));
}
return getInstance().then((d2) => {
const api = d2.Api.getApi();
return api.get(`${getModelHref(m)}/translations`);
});
});
}
export const saveTranslations = Action.create('saveTranslations');
saveTranslations.subscribe(({ data: [model, translations], complete, error }) => {
const translationHref = `${getModelHref(model)}/translations`;
getInstance().then((d2) => {
const api = d2.Api.getApi();
api
.update(translationHref, { translations }, { dataType: 'text' })
.then(() => complete(translations))
.catch(error);
});
});