Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createTest = name =>
builders.test({
NAME: t.stringLiteral(constantCase(name)),
FUNC: t.identifier(_.camelCase(name)),
})
function parseActionType(actionType, domainIdentifier, propertyName) {
if (actionType === ACTION_TYPE_DYNAMIC) {
return `@@provider/${constantCase(domainIdentifier)}/action/${constantCase(propertyName)}`;
}
return actionType;
}
function extractSaga(propertyName: string, dataBag: DataBag) {
const { ProviderClass, sagaList } = dataBag;
const property = ProviderClass[propertyName];
const metadata = getPropertyMetadata(property);
let callActionHandler;
const actionBuilder = installActionBuilder(dataBag, propertyName);
if (metadata.trackStatus) {
const { initialState, addActionListener } = dataBag;
const trackActionType = `@@provider/${dataBag.domainIdentifier}/setRunning/${constantCase(propertyName)}`;
callActionHandler = function *callActionHandlerWithTracking(action) {
try {
yield put({ type: trackActionType, payload: true });
yield* property.apply(ProviderClass, action.payload);
} finally {
yield put({ type: trackActionType, payload: false });
}
};
const runningPropertyName = `${propertyName}.running`;
installSelector(runningPropertyName, dataBag);
initialState[runningPropertyName] = false;
Object.defineProperty(actionBuilder, 'running', Object.getOwnPropertyDescriptor(ProviderClass, runningPropertyName));
addActionListener(trackActionType, function changeRunningStatus(runningStatus) {
STATUSES.forEach(function mapStatusConstants(status) {
const statusName = status === 'starting' ? '' : status;
const constantName = constantCase(`${methodName} ${statusName}`);
methodConstantMappings[status] = constants[constantName];
});
});
method => constantCase(methodNames[method])
);
const performChangeCase = (type: EnumTypeCase, value: string): string => {
switch (type) {
case EnumTypeCase.Constant:
return constantCase(value);
case EnumTypeCase.Pascal:
return pascalCase(value);
}
};