integreat
Version:
Node.js integration layer
20 lines • 726 B
JavaScript
export const getCastFn = (schemas, type) => (typeof type === 'string' ? schemas.get(type)?.castFn : undefined);
export const castPayload = (action, endpoint, castFn) => ({
...action,
payload: !endpoint.allowRawRequest && castFn
? {
...action.payload,
data: castFn(action.payload.data, false, endpoint.castWithoutDefaults),
}
: action.payload,
});
export const castResponse = (action, endpoint, castFn) => !endpoint.allowRawResponse && castFn
? {
...action,
response: {
...action.response,
data: castFn(action.response?.data, false, endpoint.castWithoutDefaults),
},
}
: action;
//# sourceMappingURL=cast.js.map