Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw response.error;
}
if (response.status === 204) {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return record;
} else if (response.status === 202) {
const responseRecord = response.data as T;
setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);
return responseRecord;
} else {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return response.replaceData(record).data as T;
}
});
}
return action((response: LibResponse): T => {
if (response.error) {
throw response.error;
}
if (response.status === 204) {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return record;
} else if (response.status === 202) {
const responseRecord = response.data as T;
setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);
return responseRecord;
} else {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return response.replaceData(record).data as T;
}
});
}
return responseObj.then((response) => {
const related = getModelMetaKey(model, MODEL_RELATED_FIELD);
const prop = getModelMetaKey(model, MODEL_PROP_FIELD);
const record = response.data;
const recordType = record && getModelType(record);
if (record && recordType !== getModelType(model) && recordType === getModelType(related)) {
if (prop) {
related[prop] = record;
return response;
}
setModelMetaKey(related, MODEL_PERSISTED_FIELD, true);
return response.replaceData(related);
}
return response;
});
}
return action((response: LibResponse): T => {
if (response.error) {
throw response.error;
}
if (response.status === 204) {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return record;
} else if (response.status === 202) {
const responseRecord = response.data as T;
setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);
return responseRecord;
} else {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return response.replaceData(record).data as T;
}
});
}
return action((response: LibResponse): T => {
if (response.error) {
throw response.error;
}
if (response.status === 204) {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return record;
} else if (response.status === 202) {
const responseRecord = response.data as T;
setModelMetaKey(responseRecord, MODEL_PROP_FIELD, prop);
setModelMetaKey(responseRecord, MODEL_QUEUE_FIELD, true);
setModelMetaKey(responseRecord, MODEL_RELATED_FIELD, record);
return responseRecord;
} else {
setModelMetaKey(record, MODEL_PERSISTED_FIELD, true);
return response.replaceData(record).data as T;
}
});
}
function setModelPersisted(model: PureModel, status: boolean) {
setModelMetaKey(model, MODEL_PERSISTED_FIELD, status);
}