tag', () => {
8 | const renderedComponent = shallow(
);
9 | expect(renderedComponent.type()).toEqual('div');
10 | });
11 |
12 | it('should have a className attribute', () => {
13 | const renderedComponent = shallow(
);
14 | expect(renderedComponent.prop('className')).toBeDefined();
15 | });
16 |
17 | it('should adopt a valid attribute', () => {
18 | const id = 'test';
19 | const renderedComponent = shallow(
);
20 | expect(renderedComponent.prop('id')).toEqual(id);
21 | });
22 |
23 | it('should not adopt an invalid attribute', () => {
24 | const renderedComponent = shallow(
);
25 | expect(renderedComponent.prop('attribute')).toBeUndefined();
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/Auth.js:
--------------------------------------------------------------------------------
1 | class Auth {
2 | /**
3 | * Authenticate a user. Save a token string in Local Storage
4 | *
5 | * @param {string} token
6 | */
7 | static authenticateUser({ token, user }) {
8 | localStorage.setItem('token', token);
9 | localStorage.setItem('user', JSON.stringify(user));
10 | }
11 |
12 | /**
13 | * Check if a user is authenticated - check if a token is saved in Local Storage
14 | *
15 | * @returns {boolean}
16 | */
17 | static isUserAuthenticated() {
18 | return localStorage.getItem('token') !== null;
19 | }
20 |
21 | /**
22 | * Deauthenticate a user. Remove a token from Local Storage.
23 | *
24 | */
25 | static deauthenticateUser() {
26 | localStorage.removeItem('token');
27 | }
28 |
29 | /**
30 | * Get a token value.
31 | *
32 | * @returns {string}
33 | */
34 |
35 | static getToken() {
36 | return localStorage.getItem('token');
37 | }
38 | }
39 |
40 | export default Auth;
41 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for LoginPage
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/actions.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * LoginPage actions
4 | *
5 | */
6 |
7 | import * as c from './constants';
8 |
9 | export const loginRequest = () => ({
10 | type: c.LOGIN_REQUEST,
11 | });
12 |
13 | export const registerRequest = () => ({
14 | type: c.REGISTER_REQUEST,
15 | });
16 |
17 | export const registerRequestFailure = error => ({
18 | type: c.REGISTER_REQUEST_ERROR,
19 | error,
20 | });
21 |
22 | export const loginRequestFailure = error => ({
23 | type: c.LOGIN_REQUEST_ERROR,
24 | error,
25 | });
26 |
27 | export const loading = toggle => ({
28 | type: c.SET_LOADING,
29 | toggle,
30 | });
31 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * LoginPage constants
4 | *
5 | */
6 |
7 | export const DEFAULT = 'loginPage/';
8 |
9 | export const LOGIN_REQUEST = `${DEFAULT}LOGIN_REQUEST`;
10 | export const SENDING_REQUEST = `${DEFAULT}SENDING_REQUEST`;
11 | export const LOGIN_REQUEST_ERROR = `${DEFAULT}LOGIN_REQUEST_ERROR`;
12 | export const REGISTER_REQUEST_ERROR = `${DEFAULT}REGISTER_REQUEST_ERROR`;
13 |
14 | export const REGISTER_REQUEST = `${DEFAULT}REGISTER_REQUEST`;
15 |
16 | export const LOGOUT = `${DEFAULT}LOGOUT`;
17 |
18 | export const CHANGE_FORM = `${DEFAULT}CHANGE_FORM`;
19 |
20 | export const SET_AUTH = `${DEFAULT}SET_AUTH`;
21 |
22 | export const SET_LOADING = `${DEFAULT}SET_LOADING`;
23 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LoginPage Messages
3 | *
4 | * This contains all the text for the LoginPage component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.LoginPage.header',
11 | defaultMessage: 'This is LoginPage container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 | /**
4 | * Direct selector to the loginPage state domain
5 | */
6 | const selectLoginPageDomain = state => state.get('loginPage', initialState);
7 |
8 | /**
9 | * Other specific selectors
10 | */
11 | const selectForm = state => state.get('form');
12 |
13 | const makeSelectLogin = () =>
14 | createSelector(selectForm, formState => formState.getIn('Login', 'values'));
15 |
16 | /**
17 | * Default selector used by LoginPage
18 | */
19 |
20 | const makeSelectLoginPage = () =>
21 | createSelector(selectLoginPageDomain, substate => {
22 | const toJS = substate.toJS();
23 | return toJS;
24 | });
25 |
26 | export {
27 | selectForm,
28 | makeSelectLogin,
29 | selectLoginPageDomain,
30 | makeSelectLoginPage,
31 | };
32 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { LoginPage } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import loginPageReducer from '../reducer';
3 | import Auth from '../Auth';
4 |
5 | describe('loginPageReducer', () => {
6 | let state;
7 | beforeEach(() => {
8 | state = fromJS({
9 | loggedIn: Auth.isUserAuthenticated(),
10 | loading: false,
11 | loginError: '',
12 | registerError: '',
13 | });
14 | });
15 | it('returns the initial state', () => {
16 | const expected = state;
17 | expect(loginPageReducer(undefined, {})).toEqual(expected);
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/LoginPage/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectLoginPageDomain } from '../selectors';
3 |
4 | describe('selectLoginPageDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/NotFoundPage/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Asynchronously loads the component for NotFoundPage
3 | */
4 | import Loadable from 'react-loadable';
5 |
6 | import LoadingIndicator from 'components/LoadingIndicator';
7 |
8 | export default Loadable({
9 | loader: () => import('./index'),
10 | loading: LoadingIndicator,
11 | });
12 |
--------------------------------------------------------------------------------
/app/containers/NotFoundPage/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * NotFoundPage
3 | *
4 | * This is the page we show when the user visits a url that doesn't have a route
5 | */
6 |
7 | import React from 'react';
8 | import { FormattedMessage } from 'react-intl';
9 |
10 | import H1 from 'components/H1';
11 | import messages from './messages';
12 |
13 | export default function NotFound() {
14 | return (
15 |
16 |
17 |
18 |
19 |
20 | );
21 | }
22 |
--------------------------------------------------------------------------------
/app/containers/NotFoundPage/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * NotFoundPage Messages
3 | *
4 | * This contains all the text for the NotFoundPage component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'boilerplate.containers.NotFoundPage.header',
11 | defaultMessage: 'Page not found.',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/NotFoundPage/tests/index.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Testing the NotFoundPage
3 | */
4 |
5 | import React from 'react';
6 | import { shallow } from 'enzyme';
7 | import { FormattedMessage } from 'react-intl';
8 |
9 | import H1 from 'components/H1';
10 | import NotFound from '../index';
11 |
12 | describe('
', () => {
13 | it('should render the Page Not Found text', () => {
14 | const renderedComponent = shallow(
);
15 | expect(
16 | renderedComponent.contains(
17 |
18 |
22 |
,
23 | ),
24 | ).toEqual(true);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/app/containers/Permissions/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for Permissions
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/Permissions/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Permissions constants
4 | *
5 | */
6 |
7 | export const DEFAULT = 'Permissions/';
8 |
9 | export const GET_PERMISSIONS = `${DEFAULT}GET_PERMISSIONS`;
10 | export const GETTING_PERMISSIONS = `${DEFAULT}GETTING_PERMISSIONS`;
11 | export const GET_PERMISSIONS_SUCCESS = `${DEFAULT}GET_PERMISSIONS_SUCCESS`;
12 | export const GET_PERMISSIONS_FAILURE = `${DEFAULT}GET_PERMISSIONS_FAILURE`;
13 |
14 | export const SET_PERMISSIONS = `${DEFAULT}SET_PERMISSIONS`;
15 | export const SETTING_PERMISSIONS = `${DEFAULT}SETTING_PERMISSIONS`;
16 | export const SET_PERMISSIONS_SUCCESS = `${DEFAULT}SET_PERMISSIONS_SUCCESS`;
17 | export const SET_PERMISSIONS_FAILURE = `${DEFAULT}SET_PERMISSIONS_FAILURE`;
18 |
19 | export const SET_USER = `${DEFAULT}SET_USER`;
20 | export const SET_USER_SUCCESS = `${DEFAULT}SET_USER_SUCCESS`;
21 | export const SET_USER_FAILURE = `${DEFAULT}SET_USER_FAILURE`;
22 |
--------------------------------------------------------------------------------
/app/containers/Permissions/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Permissions Messages
3 | *
4 | * This contains all the text for the Permissions component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.Permissions.header',
11 | defaultMessage: 'This is Permissions container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/Permissions/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { Permissions } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/Permissions/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import permissionsReducer from '../reducer';
3 |
4 | describe('permissionsReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | groups: [],
9 | roles: [],
10 | permissions: [],
11 | users: [],
12 | loading: true,
13 | savingRole: false,
14 | savingGroup: false,
15 | savingUser: false,
16 | error: '',
17 | });
18 | });
19 | it('returns the initial state', () => {
20 | const expected = state;
21 | expect(permissionsReducer(undefined, {})).toEqual(expected);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/app/containers/Permissions/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/Permissions/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectPermissionsDomain } from '../selectors';
3 |
4 | describe('selectPermissionsDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for RightSidebar
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * RightSidebar Messages
3 | *
4 | * This contains all the text for the RightSidebar component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.RightSidebar.header',
11 | defaultMessage: 'This is RightSidebar container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the rightSidebar state domain
6 | */
7 | const selectRightSidebarDomain = state =>
8 | state.get('rightSidebar', initialState);
9 |
10 | /**
11 | * Other specific selectors
12 | */
13 |
14 | export const selectStatus = () =>
15 | createSelector(selectRightSidebarDomain, state => state.get('status'));
16 | export const selectInfo = () =>
17 | createSelector(selectRightSidebarDomain, state => ({
18 | project: state.get('project'),
19 | model: state.get('model'),
20 | q: state.get('q'),
21 | }));
22 |
23 | export const selectParse = () =>
24 | createSelector(selectRightSidebarDomain, state => ({
25 | response: state.get('response'),
26 | sending: state.get('sending'),
27 | }));
28 |
29 | /**
30 | * Default selector used by RightSidebar
31 | */
32 |
33 | const makeSelectRightSidebar = () =>
34 | createSelector(selectRightSidebarDomain, substate => substate.toJS());
35 |
36 | export default makeSelectRightSidebar;
37 | export { selectRightSidebarDomain };
38 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { RightSidebar } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import rightSidebarReducer from '../reducer';
3 |
4 | describe('rightSidebarReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | status: {
9 | available_projects: {},
10 | },
11 |
12 | project: localStorage.getItem('RightSidebar-agent')
13 | ? localStorage.getItem('RightSidebar-agent')
14 | : '',
15 | model: '',
16 | q: '',
17 | response: false, // {}
18 | sending: false,
19 | messages: [], // []
20 | typing: false,
21 | });
22 | });
23 | it('returns the initial state', () => {
24 | const expectedResult = state;
25 | expect(rightSidebarReducer(undefined, {})).toEqual(expectedResult);
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/RightSidebar/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectRightSidebarDomain } from '../selectors';
3 |
4 | describe('selectRightSidebarDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for SingleTalkFlow
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * SingleTalkFlow Messages
3 | *
4 | * This contains all the text for the SingleTalkFlow component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.SingleTalkFlow.header',
11 | defaultMessage: 'This is SingleTalkFlow container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the talkFlow state domain
6 | */
7 | const stfd = state => state.get('talkFlow', initialState);
8 |
9 | /**
10 | * Other specific selectors
11 | */
12 |
13 | export const makeSelectFamily = () =>
14 | createSelector(stfd, substate => ({
15 | name: substate.get('name'),
16 | uid: substate.get('parentNode'),
17 | children: substate.get('children'),
18 | enabled: substate.get('enabled'),
19 | }));
20 |
21 | export const selectEditNode = () =>
22 | createSelector(stfd, state => state.get('editNode'));
23 |
24 | export const selectTalkWrapper = () =>
25 | createSelector(stfd, s => s.get('talkWrapper'));
26 |
27 | export const selectHead = () =>
28 | createSelector(stfd, state => state.get('parentNode'));
29 |
30 | export default makeSelectFamily;
31 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { SingleTalkFlow } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import talkFlowReducer from '../reducer';
3 |
4 | describe('talkFlowReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | editNode: '',
9 |
10 | name: '',
11 | parentNode: '',
12 | children: [],
13 | enabled: false,
14 | talkWrapper: '',
15 |
16 | details: {
17 | responses: 0,
18 | slots: 0,
19 | },
20 | error: '',
21 | loading: true,
22 | selectedNode: '',
23 | });
24 | });
25 | it('returns the initial state', () => {
26 | const expected = state;
27 | const reducer = talkFlowReducer(undefined, {});
28 | expect(reducer).toEqual(expected);
29 | });
30 | });
31 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/SingleTalkFlow/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectTalkFlowDomain } from '../selectors';
3 |
4 | describe('selectTalkFlowDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for SmallTalk
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/actions.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * SmallTalk actions
4 | *
5 | */
6 |
7 | import { DEFAULT_ACTION } from './constants';
8 |
9 | export function defaultAction() {
10 | return {
11 | type: DEFAULT_ACTION,
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * SmallTalk constants
4 | *
5 | */
6 |
7 | export const DEFAULT_ACTION = 'app/SmallTalk/DEFAULT_ACTION';
8 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * SmallTalk Messages
3 | *
4 | * This contains all the text for the SmallTalk component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.SmallTalk.header',
11 | defaultMessage: 'This is SmallTalk container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/reducer.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * SmallTalk reducer
4 | *
5 | */
6 |
7 | import { fromJS } from 'immutable';
8 | import { DEFAULT_ACTION } from './constants';
9 |
10 | export const initialState = fromJS({});
11 |
12 | function smallTalkReducer(state = initialState, action) {
13 | switch (action.type) {
14 | case DEFAULT_ACTION:
15 | return state;
16 | default:
17 | return state;
18 | }
19 | }
20 |
21 | export default smallTalkReducer;
22 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/saga.js:
--------------------------------------------------------------------------------
1 | // import { take, call, put, select } from 'redux-saga/effects';
2 |
3 | // Individual exports for testing
4 | export default function* defaultSaga() {
5 | // See example in containers/HomePage/saga.js
6 | }
7 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the smallTalk state domain
6 | */
7 | const selectSmallTalkDomain = state => state.get('smallTalk', initialState);
8 |
9 | /**
10 | * Other specific selectors
11 | */
12 |
13 | /**
14 | * Default selector used by SmallTalk
15 | */
16 |
17 | const makeSelectSmallTalk = () =>
18 | createSelector(selectSmallTalkDomain, substate => substate.toJS());
19 |
20 | export default makeSelectSmallTalk;
21 | export { selectSmallTalkDomain };
22 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/tests/actions.test.js:
--------------------------------------------------------------------------------
1 | import { defaultAction } from '../actions';
2 | import { DEFAULT_ACTION } from '../constants';
3 |
4 | describe('SmallTalk actions', () => {
5 | describe('Default Action', () => {
6 | it('has a type of DEFAULT_ACTION', () => {
7 | const expected = {
8 | type: DEFAULT_ACTION,
9 | };
10 | expect(defaultAction()).toEqual(expected);
11 | });
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { SmallTalk } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import smallTalkReducer from '../reducer';
3 |
4 | describe('smallTalkReducer', () => {
5 | it('returns the initial state', () => {
6 | expect(smallTalkReducer(undefined, {})).toEqual(fromJS({}));
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/SmallTalk/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectSmallTalkDomain } from '../selectors';
3 |
4 | describe('selectSmallTalkDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for Synonyms
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Synonyms Messages
3 | *
4 | * This contains all the text for the Synonyms component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.Synonyms.header',
11 | defaultMessage: 'This is Synonyms container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 | /**
4 | * Direct selector to the synonyms state domain
5 | */
6 | const selectSynonymsDomain = state => state.get('synonyms', initialState);
7 |
8 | /**
9 | * Other specific selectors
10 | */
11 |
12 | /**
13 | * Default selector used by Synonyms
14 | */
15 |
16 | const makeSelectSynonyms = () =>
17 | createSelector(selectSynonymsDomain, substate => substate.toJS());
18 |
19 | export default makeSelectSynonyms;
20 | export { selectSynonymsDomain };
21 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { Synonyms } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import synonymsReducer from '../reducer';
3 |
4 | describe('synonymsReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | loading: false,
9 | synonyms: [],
10 | error: '',
11 | addingSyn: false,
12 | });
13 | });
14 |
15 | it('returns the initial state', () => {
16 | const expectedResult = state;
17 | expect(synonymsReducer(undefined, {})).toEqual(expectedResult);
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/Synonyms/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectSynonymsDomain } from '../selectors';
3 |
4 | describe('selectSynonymsDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/Talk/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for Talk
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/Talk/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Talk constants
4 | *
5 | */
6 |
7 | export const DEFAULT_ACTION = 'app/Talk';
8 | export const LOAD_PARENTS = `${DEFAULT_ACTION}/LOAD_PARENTS`;
9 | export const REQUESTING_PARENTS = `${DEFAULT_ACTION}/REQUESTING_PARENTS`;
10 | export const REQUESTING_PARENTS_SUCCESS = `${DEFAULT_ACTION}/REQUESTING_PARENTS_SUCCESS`;
11 | export const REQUESTING_PARENTS_FAILURE = `${DEFAULT_ACTION}/REQUESTING_PARENTS_FAILURE`;
12 |
13 | export const ADD_NODE = `${DEFAULT_ACTION}/ADD_NODE`;
14 | export const ADDING_NODE = `${DEFAULT_ACTION}/ADDING_NODE`;
15 | export const ADD_NODE_SUCCESS = `${DEFAULT_ACTION}/ADD_NODE_SUCCESS`;
16 | export const ADD_NODE_FAILURE = `${DEFAULT_ACTION}/ADD_NODE_FAILURE`;
17 |
--------------------------------------------------------------------------------
/app/containers/Talk/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Talk Messages
3 | *
4 | * This contains all the text for the Talk component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.Talk.header',
11 | defaultMessage: 'This is Talk container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/Talk/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the talk state domain
6 | */
7 | const selectTalk = state => state.get('talk', initialState);
8 |
9 | /**
10 | * Other specific selectors
11 | */
12 |
13 | /**
14 | * Default selector used by Talk
15 | */
16 |
17 | const makeSelectTalk = () =>
18 | createSelector(selectTalk, substate => substate.toJS());
19 |
20 | const selectParents = () =>
21 | createSelector(selectTalk, state => state.get('parents'));
22 |
23 | const selectLoading = () =>
24 | createSelector(selectTalk, state => state.get('loading'));
25 |
26 | const selectUpdating = () =>
27 | createSelector(selectTalk, state => state.get('updating'));
28 |
29 | export default makeSelectTalk;
30 | export { selectTalk, selectParents, selectLoading, selectUpdating };
31 |
--------------------------------------------------------------------------------
/app/containers/Talk/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { Talk } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/Talk/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import talkReducer from '../reducer';
3 |
4 | describe('talkReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | parentsLoaded: false,
9 | errorMessage: '',
10 | parents: [],
11 | loading: true,
12 | goTo: '',
13 | updating: false,
14 | });
15 | });
16 | it('returns the initial state', () => {
17 | const expected = state;
18 | expect(talkReducer(undefined, {})).toEqual(expected);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/app/containers/Talk/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/Talk/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectTalk } from '../selectors';
3 |
4 | describe('selectTalk', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for TalkWrapper
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * TalkWrapper constants
4 | *
5 | */
6 |
7 | const DEFAULT = 'app/TalkWrapper/';
8 |
9 | export const ADD_TALK_WRAPPERS = `${DEFAULT}ADD_TALK_WRAPPERS`;
10 | export const ADDING_TALK_WRAPPERS = `${DEFAULT}ADDING_TALK_WRAPPERS`;
11 | export const ADD_TALK_WRAPPERS_SUCCESS = `${DEFAULT}ADD_TALK_WRAPPERS_SUCCESS`;
12 | export const ADD_TALK_WRAPPERS_FAILURE = `${DEFAULT}ADD_TALK_WRAPPERS_FAILURE`;
13 |
14 | export const UPDATE_TALK_WRAPPERS = `${DEFAULT}UPDATE_TALK_WRAPPERS`;
15 | export const UPDATING_TALK_WRAPPERS = `${DEFAULT}UPDATING_TALK_WRAPPERS`;
16 | export const UPDATE_TALK_WRAPPERS_SUCCESS = `${DEFAULT}UPDATE_TALK_WRAPPERS_SUCCESS`;
17 | export const UPDATE_TALK_WRAPPERS_FAILURE = `${DEFAULT}UPDATE_TALK_WRAPPERS_FAILURE`;
18 |
19 | export const DELETE_TALK_WRAPPERS = `${DEFAULT}DELETE_TALK_WRAPPERS`;
20 | export const DELETING_TALK_WRAPPERS = `${DEFAULT}DELETING_TALK_WRAPPERS`;
21 | export const DELETE_TALK_WRAPPERS_SUCCESS = `${DEFAULT}DELETE_TALK_WRAPPERS_SUCCESS`;
22 | export const DELETE_TALK_WRAPPERS_FAILURE = `${DEFAULT}DELETE_TALK_WRAPPERS_FAILURE`;
23 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * TalkWrapper Messages
3 | *
4 | * This contains all the text for the TalkWrapper component.
5 | */
6 |
7 | import { defineMessages } from 'react-intl';
8 |
9 | export default defineMessages({
10 | header: {
11 | id: 'app.containers.TalkWrapper.header',
12 | defaultMessage: 'This is TalkWrapper container !',
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/reducer.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * TalkWrapper reducer
4 | *
5 | */
6 |
7 | import { fromJS } from 'immutable';
8 | import * as c from './constants';
9 |
10 | export const initialState = fromJS({
11 | adding: false,
12 | groups: [],
13 | });
14 |
15 | function TalkWrapperReducer(state = initialState, action) {
16 | switch (action.type) {
17 | case c.ADDING_TALK_WRAPPERS:
18 | return state.set('adding', action.toggle);
19 | default:
20 | return state;
21 | }
22 | }
23 |
24 | export default TalkWrapperReducer;
25 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 | /**
4 | * Direct selector to the TalkWrapper state domain
5 | */
6 |
7 | const selectTalkWrapperDomain = state => state.get('talkWrapper', initialState);
8 |
9 | /**
10 | * Other specific selectors
11 | */
12 |
13 | /**
14 | * Default selector used by TalkWrapper
15 | */
16 |
17 | export const makeSelectTalkWrapper = () =>
18 | createSelector(selectTalkWrapperDomain, substate => substate.toJS());
19 |
20 | export default makeSelectTalkWrapper;
21 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { TalkWrapper } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import TalkWrapperReducer from '../reducer';
3 |
4 | describe('TalkWrapperReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | adding: false,
9 | groups: [],
10 | });
11 | });
12 | it('returns the initial state', () => {
13 | const expected = state;
14 | expect(TalkWrapperReducer(undefined, {})).toEqual(expected);
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/TalkWrapper/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectTalkWrapperDomain } from '../selectors';
3 |
4 | describe('selectTalkWrapperDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for ThirdParty
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/constants.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * ThirdParty constants
4 | *
5 | */
6 |
7 | export const DEFAULT_ACTION = 'app/ThirdParty/DEFAULT_ACTION';
8 | export const DEFAULT = 'app/ThirdParty/';
9 |
10 | export const UPDATE_FORM = `${DEFAULT}UPDATE_FORM`;
11 |
12 | export const GET_ALL = `${DEFAULT}GET_ALL`;
13 | export const GETTING_ALL = `${DEFAULT}GETTING_ALL`;
14 | export const GET_ALL_SUCCESS = `${DEFAULT}GET_ALL_SUCCESS`;
15 | export const GET_ALL_FAILURE = `${DEFAULT}GET_ALL_FAILURE`;
16 |
17 | export const SAVE_FACEBOOK = `${DEFAULT}SAVE_FACEBOOK`;
18 | export const SAVING_FACEBOOK = `${DEFAULT}SAVEING_FACEBOOK`;
19 | export const SAVE_FACEBOOK_SUCCESS = `${DEFAULT}SAVE_FACEBOOK_SUCCESS`;
20 | export const SAVE_FACEBOOK_FAILURE = `${DEFAULT}SAVE_FACEBOOK_FAILURE`;
21 |
22 | export const SAVE_TELEGRAM = `${DEFAULT}SAVE_TELEGRAM`;
23 | export const SAVING_TELEGRAM = `${DEFAULT}SAVEING_TELEGRAM`;
24 | export const SAVE_TELEGRAM_SUCCESS = `${DEFAULT}SAVE_TELEGRAM_SUCCESS`;
25 | export const SAVE_TELEGRAM_FAILURE = `${DEFAULT}SAVE_TELEGRAM_FAILURE`;
26 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * ThirdParty Messages
3 | *
4 | * This contains all the text for the ThirdParty component.
5 | */
6 |
7 | import { defineMessages } from 'react-intl';
8 |
9 | export default defineMessages({
10 | header: {
11 | id: 'app.containers.ThirdParty.header',
12 | defaultMessage: 'This is ThirdParty container !',
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the thirdParty state domain
6 | */
7 |
8 | const selectThirdPartyDomain = state => state.get('thirdParty', initialState);
9 |
10 | /**
11 | * Other specific selectors
12 | */
13 |
14 | const selectFacebook = () =>
15 | createSelector(selectThirdPartyDomain, s => s.get('facebook').toJS());
16 |
17 | const selectTelegram = () =>
18 | createSelector(selectThirdPartyDomain, s => s.get('telegram').toJS());
19 |
20 | /**
21 | * Default selector used by ThirdParty
22 | */
23 |
24 | const makeSelectThirdParty = () =>
25 | createSelector(selectThirdPartyDomain, substate => substate.toJS());
26 |
27 | export default makeSelectThirdParty;
28 | export { selectThirdPartyDomain, selectFacebook, selectTelegram };
29 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { ThirdParty } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import thirdPartyReducer from '../reducer';
3 |
4 | describe('thirdPartyReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | facebook: {
9 | enabled: true,
10 | agent: '',
11 | talkWrapper: '',
12 | access_token: '',
13 | verify_token: '',
14 | },
15 | });
16 | });
17 | it('returns the initial state', () => {
18 | const expected = state;
19 | expect(thirdPartyReducer(undefined, {})).toEqual(expected);
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/ThirdParty/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectThirdPartyDomain } from '../selectors';
3 |
4 | describe('selectThirdPartyDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/containers/Training/Loadable.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for Training
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/app/containers/Training/messages.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Training Messages
3 | *
4 | * This contains all the text for the Training component.
5 | */
6 | import { defineMessages } from 'react-intl';
7 |
8 | export default defineMessages({
9 | header: {
10 | id: 'app.containers.Training.header',
11 | defaultMessage: 'This is Training container !',
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/app/containers/Training/selectors.js:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 | /**
4 | * Direct selector to the training state domain
5 | */
6 | const selectTrainingDomain = state => state.get('training', initialState);
7 |
8 | /**
9 | * Other specific selectors
10 | */
11 |
12 | export const selectLoading = () =>
13 | createSelector(selectTrainingDomain, state => state.get('loading'));
14 | export const selectGetting = () =>
15 | createSelector(selectTrainingDomain, state => state.get('getting'));
16 | export const selectJSON = () =>
17 | createSelector(selectTrainingDomain, state => state.get('json'));
18 | export const selectTraining = () =>
19 | createSelector(selectTrainingDomain, state => state.get('training'));
20 | export const selectInTraining = () =>
21 | createSelector(selectTrainingDomain, state => state.get('inTraining'));
22 |
23 | /**
24 | * Default selector used by Training
25 | */
26 |
27 | const makeSelectTraining = () =>
28 | createSelector(selectTrainingDomain, substate => substate.toJS());
29 |
30 | export default makeSelectTraining;
31 | export { selectTrainingDomain };
32 |
--------------------------------------------------------------------------------
/app/containers/Training/tests/index.test.js:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { Training } from '../index';
5 |
6 | describe('
', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/app/containers/Training/tests/reducer.test.js:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import trainingReducer from '../reducer';
3 |
4 | describe('trainingReducer', () => {
5 | let state;
6 | beforeEach(() => {
7 | state = fromJS({
8 | loading: true,
9 | loadingError: '',
10 | getting: false,
11 | json: {},
12 | training: [],
13 | inTraining: false,
14 | });
15 | });
16 | it('returns the initial state', () => {
17 | const expected = state;
18 | expect(trainingReducer(undefined, {})).toEqual(expected);
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/app/containers/Training/tests/saga.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/app/containers/Training/tests/selectors.test.js:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { selectTrainingDomain } from '../selectors';
3 |
4 | describe('selectTrainingDomain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/app/global-styles.js:
--------------------------------------------------------------------------------
1 | import { injectGlobal } from 'styled-components';
2 |
3 | /* eslint no-unused-expressions: 0 */
4 | injectGlobal`
5 | html,
6 | body {
7 | height: 100%;
8 | width: 100%;
9 | }
10 |
11 | body {
12 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13 | }
14 |
15 | body.fontLoaded {
16 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
17 | }
18 |
19 | #app {
20 | background-color: #fafafa;
21 | min-height: 100%;
22 | min-width: 100%;
23 | }
24 |
25 | p,
26 | label {
27 | font-family: Georgia, Times, 'Times New Roman', serif;
28 | line-height: 1.5em;
29 | }
30 | `;
31 |
--------------------------------------------------------------------------------
/app/images/agent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/agent.png
--------------------------------------------------------------------------------
/app/images/button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/button.png
--------------------------------------------------------------------------------
/app/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/favicon.ico
--------------------------------------------------------------------------------
/app/images/iIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/iIcon.png
--------------------------------------------------------------------------------
/app/images/iIcon.svg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/iIcon.svg
--------------------------------------------------------------------------------
/app/images/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/icon-512x512.png
--------------------------------------------------------------------------------
/app/images/link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/link.png
--------------------------------------------------------------------------------
/app/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/logo.png
--------------------------------------------------------------------------------
/app/images/logoText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdh/RasaTalk/757630b3ce9ba9e7ee827a6ff35b400158961e84/app/images/logoText.png
--------------------------------------------------------------------------------
/app/reducers.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Combine all reducers in this file and export the combined reducers.
3 | */
4 |
5 | import { combineReducers } from 'redux-immutable';
6 | import { connectRouter } from 'connected-react-router/immutable';
7 |
8 | import history from 'utils/history';
9 | import globalReducer from 'containers/App/reducer';
10 | import { reducer as formReducer } from 'redux-form/immutable';
11 | import languageProviderReducer from 'containers/LanguageProvider/reducer';
12 |
13 | /*
14 | * routeReducer
15 | *
16 | * The reducer merges route location changes into our immutable state.
17 | * The change is necessitated by moving to react-router-redux@5
18 | *
19 | */
20 |
21 | export default function createReducer(injectedReducers = {}) {
22 | const rootReducer = combineReducers({
23 | global: globalReducer,
24 | form: formReducer,
25 | language: languageProviderReducer,
26 | ...injectedReducers,
27 | });
28 | // Wrap the root reducer and return a new root reducer with router state
29 | const mergeWithRouterState = connectRouter(history);
30 | return mergeWithRouterState(rootReducer);
31 | }
32 |
--------------------------------------------------------------------------------
/app/tests/i18n.test.js:
--------------------------------------------------------------------------------
1 | import { formatTranslationMessages } from '../i18n';
2 |
3 | jest.mock('../translations/en.json', () => ({
4 | message1: 'default message',
5 | message2: 'default message 2',
6 | }));
7 |
8 | const esTranslationMessages = {
9 | message1: 'mensaje predeterminado',
10 | message2: '',
11 | };
12 |
13 | describe('formatTranslationMessages', () => {
14 | it('should build only defaults when DEFAULT_LOCALE', () => {
15 | const result = formatTranslationMessages('en', { a: 'a' });
16 |
17 | expect(result).toEqual({ a: 'a' });
18 | });
19 |
20 | it('should combine default locale and current locale when not DEFAULT_LOCALE', () => {
21 | const result = formatTranslationMessages('', esTranslationMessages);
22 |
23 | expect(result).toEqual({
24 | message1: 'mensaje predeterminado',
25 | message2: 'default message 2',
26 | });
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/app/utils/checkStore.js:
--------------------------------------------------------------------------------
1 | import conformsTo from 'lodash/conformsTo';
2 | import isFunction from 'lodash/isFunction';
3 | import isObject from 'lodash/isObject';
4 | import invariant from 'invariant';
5 |
6 | /**
7 | * Validate the shape of redux store
8 | */
9 | export default function checkStore(store) {
10 | const shape = {
11 | dispatch: isFunction,
12 | subscribe: isFunction,
13 | getState: isFunction,
14 | replaceReducer: isFunction,
15 | runSaga: isFunction,
16 | injectedReducers: isObject,
17 | injectedSagas: isObject,
18 | };
19 | invariant(
20 | conformsTo(store, shape),
21 | '(app/utils...) injectors: Expected a valid redux store',
22 | );
23 | }
24 |
--------------------------------------------------------------------------------
/app/utils/constants.js:
--------------------------------------------------------------------------------
1 | export const RESTART_ON_REMOUNT = '@@saga-injector/restart-on-remount';
2 | export const DAEMON = '@@saga-injector/daemon';
3 | export const ONCE_TILL_UNMOUNT = '@@saga-injector/once-till-unmount';
4 |
--------------------------------------------------------------------------------
/app/utils/history.js:
--------------------------------------------------------------------------------
1 | import createHistory from 'history/createBrowserHistory';
2 | const history = createHistory();
3 | export default history;
4 |
--------------------------------------------------------------------------------
/app/utils/injectReducer.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import hoistNonReactStatics from 'hoist-non-react-statics';
4 |
5 | import getInjectors from './reducerInjectors';
6 |
7 | /**
8 | * Dynamically injects a reducer
9 | *
10 | * @param {string} key A key of the reducer
11 | * @param {function} reducer A reducer that will be injected
12 | *
13 | */
14 | export default ({ key, reducer }) => WrappedComponent => {
15 | class ReducerInjector extends React.Component {
16 | static WrappedComponent = WrappedComponent;
17 | static contextTypes = {
18 | store: PropTypes.object.isRequired,
19 | };
20 | static displayName = `withReducer(${WrappedComponent.displayName ||
21 | WrappedComponent.name ||
22 | 'Component'})`;
23 |
24 | componentWillMount() {
25 | const { injectReducer } = this.injectors;
26 |
27 | injectReducer(key, reducer);
28 | }
29 |
30 | injectors = getInjectors(this.context.store);
31 |
32 | render() {
33 | return
;
34 | }
35 | }
36 |
37 | return hoistNonReactStatics(ReducerInjector, WrappedComponent);
38 | };
39 |
--------------------------------------------------------------------------------
/app/utils/tests/checkStore.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test injectors
3 | */
4 |
5 | import checkStore from '../checkStore';
6 |
7 | describe('checkStore', () => {
8 | let store;
9 |
10 | beforeEach(() => {
11 | store = {
12 | dispatch: () => {},
13 | subscribe: () => {},
14 | getState: () => {},
15 | replaceReducer: () => {},
16 | runSaga: () => {},
17 | injectedReducers: {},
18 | injectedSagas: {},
19 | };
20 | });
21 |
22 | it('should not throw if passed valid store shape', () => {
23 | expect(() => checkStore(store)).not.toThrow();
24 | });
25 |
26 | it('should throw if passed invalid store shape', () => {
27 | expect(() => checkStore({})).toThrow();
28 | expect(() => checkStore({ ...store, injectedSagas: null })).toThrow();
29 | expect(() => checkStore({ ...store, injectedReducers: null })).toThrow();
30 | expect(() => checkStore({ ...store, runSaga: null })).toThrow();
31 | expect(() => checkStore({ ...store, replaceReducer: null })).toThrow();
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/app/utils/validators.js:
--------------------------------------------------------------------------------
1 | import * as Yup from 'yup';
2 |
3 | export const wrapperValidator = Yup.object().shape({
4 | name: Yup.string()
5 | .min(2, 'Please enter a longer agent name')
6 | .required('Name is required.'),
7 | avatar: Yup.string().url('Please enter a valid URL'),
8 | });
9 |
10 | export const agentValidator = Yup.object().shape({
11 | agent: Yup.string()
12 | .min(2, 'Please enter a longer agent name')
13 | .required('Name is required.'),
14 | avatar: Yup.string().url('Please enter a valid URL'),
15 | });
16 |
--------------------------------------------------------------------------------
/example.env:
--------------------------------------------------------------------------------
1 | ENABLE_TUNNEL=false
2 | NODE_ENV=development
3 | PORT=5001
4 | RASASERVER=http://yourrasaNLU:5000
5 | JWTSECRET=62make_sure_to_change_this1
6 | MONGOCONNECTIONSTRING=mongodb://yourmongodb:27017/admin
7 | MONGOUSER=
8 | MONGOPASS=
9 | MONGODB=
--------------------------------------------------------------------------------
/internals/docker/.dockerignore:
--------------------------------------------------------------------------------
1 | coverage
2 | build
3 | node_modules
4 | stats.json
5 | .DS_Store
6 | npm-debug.log
7 | .idea
8 | Dockerfile
9 |
--------------------------------------------------------------------------------
/internals/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:10-jessie-slim
2 |
3 | RUN apt-get update && apt-get install libpng12-0 bzip2 -y
4 |
5 | # Create app directory
6 | WORKDIR /usr/src/app
7 |
8 | COPY . .
9 |
10 | RUN yarn install
11 |
12 | RUN yarn build
13 |
14 | CMD ["yarn", "start:prod"]
15 |
--------------------------------------------------------------------------------
/internals/generators/component/class.js.hbs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * {{ properCase name }}
4 | *
5 | */
6 |
7 | import React from 'react';
8 | // import PropTypes from 'prop-types';
9 | // import styled from 'styled-components';
10 |
11 | {{#if wantMessages}}
12 | import { FormattedMessage } from 'react-intl';
13 | import messages from './messages';
14 | {{/if}}
15 |
16 | /* eslint-disable react/prefer-stateless-function */
17 | class {{ properCase name }} extends {{{ type }}} {
18 | render() {
19 | return (
20 |
21 | {{#if wantMessages}}
22 |
23 | {{/if}}
24 |
25 | );
26 | }
27 | }
28 |
29 | {{ properCase name }}.propTypes = {};
30 |
31 | export default {{ properCase name }};
32 |
--------------------------------------------------------------------------------
/internals/generators/component/loadable.js.hbs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Asynchronously loads the component for {{ properCase name }}
4 | *
5 | */
6 |
7 | import Loadable from 'react-loadable';
8 |
9 | export default Loadable({
10 | loader: () => import('./index'),
11 | loading: () => null,
12 | });
13 |
--------------------------------------------------------------------------------
/internals/generators/component/messages.js.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | * {{ properCase name }} Messages
3 | *
4 | * This contains all the text for the {{ properCase name }} component.
5 | */
6 |
7 | import { defineMessages } from 'react-intl';
8 |
9 | export default defineMessages({
10 | header: {
11 | id: 'app.components.{{ properCase name }}.header',
12 | defaultMessage: 'This is the {{ properCase name}} component !',
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/internals/generators/component/stateless.js.hbs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * {{ properCase name }}
4 | *
5 | */
6 |
7 | import React from 'react';
8 | // import PropTypes from 'prop-types';
9 | // import styled from 'styled-components';
10 |
11 | {{#if wantMessages}}
12 | import { FormattedMessage } from 'react-intl';
13 | import messages from './messages';
14 | {{/if}}
15 |
16 | function {{ properCase name }}() {
17 | return (
18 |
19 | {{#if wantMessages}}
20 |
21 | {{/if}}
22 |
23 | );
24 | }
25 |
26 | {{ properCase name }}.propTypes = {};
27 |
28 | export default {{ properCase name }};
29 |
--------------------------------------------------------------------------------
/internals/generators/component/test.js.hbs:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import {{ properCase name }} from '../index';
5 |
6 | describe('<{{ properCase name }} />', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/internals/generators/container/actions.js.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * {{ properCase name }} actions
4 | *
5 | */
6 |
7 | import { DEFAULT_ACTION } from './constants';
8 |
9 | export function defaultAction() {
10 | return {
11 | type: DEFAULT_ACTION,
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/internals/generators/container/actions.test.js.hbs:
--------------------------------------------------------------------------------
1 | import { defaultAction } from '../actions';
2 | import { DEFAULT_ACTION } from '../constants';
3 |
4 | describe('{{ properCase name }} actions', () => {
5 | describe('Default Action', () => {
6 | it('has a type of DEFAULT_ACTION', () => {
7 | const expected = {
8 | type: DEFAULT_ACTION,
9 | };
10 | expect(defaultAction()).toEqual(expected);
11 | });
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/internals/generators/container/constants.js.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * {{ properCase name }} constants
4 | *
5 | */
6 |
7 | export const DEFAULT_ACTION = 'app/{{ properCase name }}/DEFAULT_ACTION';
8 |
--------------------------------------------------------------------------------
/internals/generators/container/messages.js.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | * {{properCase name }} Messages
3 | *
4 | * This contains all the text for the {{properCase name }} component.
5 | */
6 |
7 | import { defineMessages } from 'react-intl';
8 |
9 | export default defineMessages({
10 | header: {
11 | id: 'app.containers.{{properCase name }}.header',
12 | defaultMessage: 'This is {{properCase name}} container !',
13 | },
14 | });
15 |
--------------------------------------------------------------------------------
/internals/generators/container/reducer.js.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * {{ properCase name }} reducer
4 | *
5 | */
6 |
7 | import { fromJS } from 'immutable';
8 | import { DEFAULT_ACTION } from './constants';
9 |
10 | export const initialState = fromJS({});
11 |
12 | function {{ camelCase name }}Reducer(state = initialState, action) {
13 | switch (action.type) {
14 | case DEFAULT_ACTION:
15 | return state;
16 | default:
17 | return state;
18 | }
19 | }
20 |
21 | export default {{ camelCase name }}Reducer;
22 |
--------------------------------------------------------------------------------
/internals/generators/container/reducer.test.js.hbs:
--------------------------------------------------------------------------------
1 | import { fromJS } from 'immutable';
2 | import {{ camelCase name }}Reducer from '../reducer';
3 |
4 | describe('{{ camelCase name }}Reducer', () => {
5 | it('returns the initial state', () => {
6 | expect({{ camelCase name }}Reducer(undefined, {})).toEqual(fromJS({}));
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/internals/generators/container/saga.js.hbs:
--------------------------------------------------------------------------------
1 | // import { take, call, put, select } from 'redux-saga/effects';
2 |
3 | // Individual exports for testing
4 | export default function* defaultSaga() {
5 | // See example in containers/HomePage/saga.js
6 | }
7 |
--------------------------------------------------------------------------------
/internals/generators/container/saga.test.js.hbs:
--------------------------------------------------------------------------------
1 | /**
2 | * Test sagas
3 | */
4 |
5 | /* eslint-disable redux-saga/yield-effects */
6 | // import { take, call, put, select } from 'redux-saga/effects';
7 | // import { defaultSaga } from '../saga';
8 |
9 | // const generator = defaultSaga();
10 |
11 | describe('defaultSaga Saga', () => {
12 | it('Expect to have unit tests specified', () => {
13 | expect(true).toEqual(true);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/internals/generators/container/selectors.js.hbs:
--------------------------------------------------------------------------------
1 | import { createSelector } from 'reselect';
2 | import { initialState } from './reducer';
3 |
4 | /**
5 | * Direct selector to the {{ camelCase name }} state domain
6 | */
7 |
8 | const select{{ properCase name }}Domain = state =>
9 | state.get('{{ camelCase name }}', initialState);
10 |
11 | /**
12 | * Other specific selectors
13 | */
14 |
15 | /**
16 | * Default selector used by {{ properCase name }}
17 | */
18 |
19 | const makeSelect{{ properCase name }} = () =>
20 | createSelector(select{{ properCase name }}Domain, substate => substate.toJS());
21 |
22 | export default makeSelect{{ properCase name }};
23 | export { select{{ properCase name }}Domain };
24 |
--------------------------------------------------------------------------------
/internals/generators/container/selectors.test.js.hbs:
--------------------------------------------------------------------------------
1 | // import { fromJS } from 'immutable';
2 | // import { select{{ properCase name }}Domain } from '../selectors';
3 |
4 | describe('select{{ properCase name }}Domain', () => {
5 | it('Expect to have unit tests specified', () => {
6 | expect(true).toEqual(true);
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/internals/generators/container/test.js.hbs:
--------------------------------------------------------------------------------
1 | // import React from 'react';
2 | // import { shallow } from 'enzyme';
3 |
4 | // import { {{ properCase name }} } from '../index';
5 |
6 | describe('<{{ properCase name }} />', () => {
7 | it('Expect to have unit tests specified', () => {
8 | expect(true).toEqual(true);
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/internals/generators/language/add-locale-data.hbs:
--------------------------------------------------------------------------------
1 | $1addLocaleData({{language}}LocaleData);
2 |
--------------------------------------------------------------------------------
/internals/generators/language/app-locale.hbs:
--------------------------------------------------------------------------------
1 | $1 '{{language}}',
2 |
--------------------------------------------------------------------------------
/internals/generators/language/format-translation-messages.hbs:
--------------------------------------------------------------------------------
1 | $1 {{language}}: formatTranslationMessages('{{language}}', {{language}}TranslationMessages),
2 |
--------------------------------------------------------------------------------
/internals/generators/language/intl-locale-data.hbs:
--------------------------------------------------------------------------------
1 | $&const {{language}}LocaleData = require('react-intl/locale-data/{{language}}');
2 |
--------------------------------------------------------------------------------
/internals/generators/language/polyfill-intl-locale.hbs:
--------------------------------------------------------------------------------
1 | $1 import('intl/locale-data/jsonp/{{language}}.js'),
2 |
--------------------------------------------------------------------------------
/internals/generators/language/translation-messages.hbs:
--------------------------------------------------------------------------------
1 | $1const {{language}}TranslationMessages = require('./translations/{{language}}.json');
2 |
--------------------------------------------------------------------------------
/internals/generators/language/translations-json.hbs:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/internals/generators/utils/componentExists.js:
--------------------------------------------------------------------------------
1 | /**
2 | * componentExists
3 | *
4 | * Check whether the given component exist in either the components or containers directory
5 | */
6 |
7 | const fs = require('fs');
8 | const path = require('path');
9 | const pageComponents = fs.readdirSync(
10 | path.join(__dirname, '../../../app/components'),
11 | );
12 | const pageContainers = fs.readdirSync(
13 | path.join(__dirname, '../../../app/containers'),
14 | );
15 | const components = pageComponents.concat(pageContainers);
16 |
17 | function componentExists(comp) {
18 | return components.indexOf(comp) >= 0;
19 | }
20 |
21 | module.exports = componentExists;
22 |
--------------------------------------------------------------------------------
/internals/mocks/cssModule.js:
--------------------------------------------------------------------------------
1 | module.exports = 'CSS_MODULE';
2 |
--------------------------------------------------------------------------------
/internals/mocks/image.js:
--------------------------------------------------------------------------------
1 | module.exports = 'IMAGE_MOCK';
2 |
--------------------------------------------------------------------------------
/internals/scripts/analyze.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | const shelljs = require('shelljs');
4 | const animateProgress = require('./helpers/progress');
5 | const chalk = require('chalk');
6 | const addCheckMark = require('./helpers/checkmark');
7 |
8 | const progress = animateProgress('Generating stats');
9 |
10 | // Generate stats.json file with webpack
11 | shelljs.exec(
12 | 'webpack --config internals/webpack/webpack.prod.babel.js --profile --json > stats.json',
13 | addCheckMark.bind(null, callback), // Output a checkmark on completion
14 | );
15 |
16 | // Called after webpack has finished generating the stats.json file
17 | function callback() {
18 | clearInterval(progress);
19 | process.stdout.write(
20 | '\n\nOpen ' +
21 | chalk.magenta('http://webpack.github.io/analyse/') +
22 | ' in your browser and upload the stats.json file!' +
23 | chalk.blue(
24 | '\n(Tip: ' + chalk.italic('CMD + double-click') + ' the link!)\n\n',
25 | ),
26 | );
27 | }
28 |
--------------------------------------------------------------------------------
/internals/scripts/helpers/checkmark.js:
--------------------------------------------------------------------------------
1 | const chalk = require('chalk');
2 |
3 | /**
4 | * Adds mark check symbol
5 | */
6 | function addCheckMark(callback) {
7 | process.stdout.write(chalk.green(' ✓'));
8 | if (callback) callback();
9 | }
10 |
11 | module.exports = addCheckMark;
12 |
--------------------------------------------------------------------------------
/internals/scripts/helpers/progress.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const readline = require('readline');
4 |
5 | /**
6 | * Adds an animated progress indicator
7 | *
8 | * @param {string} message The message to write next to the indicator
9 | * @param {number} amountOfDots The amount of dots you want to animate
10 | */
11 | function animateProgress(message, amountOfDots) {
12 | if (typeof amountOfDots !== 'number') {
13 | amountOfDots = 3;
14 | }
15 |
16 | let i = 0;
17 | return setInterval(function() {
18 | readline.cursorTo(process.stdout, 0);
19 | i = (i + 1) % (amountOfDots + 1);
20 | const dots = new Array(i + 1).join('.');
21 | process.stdout.write(message + dots);
22 | }, 500);
23 | }
24 |
25 | module.exports = animateProgress;
26 |
--------------------------------------------------------------------------------
/internals/scripts/helpers/xmark.js:
--------------------------------------------------------------------------------
1 | const chalk = require('chalk');
2 |
3 | /**
4 | * Adds mark cross symbol
5 | */
6 | function addXMark(callback) {
7 | process.stdout.write(chalk.red(' ✘'));
8 | if (callback) callback();
9 | }
10 |
11 | module.exports = addXMark;
12 |
--------------------------------------------------------------------------------
/internals/scripts/npmcheckversion.js:
--------------------------------------------------------------------------------
1 | const exec = require('child_process').exec;
2 | exec('npm -v', function(err, stdout, stderr) {
3 | if (err) throw err;
4 | if (parseFloat(stdout) < 3) {
5 | throw new Error('[ERROR: React Boilerplate] You need npm version @>=3');
6 | process.exit(1);
7 | }
8 | });
9 |
--------------------------------------------------------------------------------
/internals/testing/enzyme-setup.js:
--------------------------------------------------------------------------------
1 | import { configure } from 'enzyme';
2 | import Adapter from 'enzyme-adapter-react-16';
3 |
4 | configure({ adapter: new Adapter() });
5 |
--------------------------------------------------------------------------------
/internals/testing/test-bundler.js:
--------------------------------------------------------------------------------
1 | // needed for regenerator-runtime
2 | // (ES7 generator support is required by redux-saga)
3 | import 'babel-polyfill';
4 |
5 | const localStorageMock = (() => {
6 | let store = {};
7 | return {
8 | getItem(key) {
9 | return store[key];
10 | },
11 | setItem(key, value) {
12 | store[key] = value.toString();
13 | },
14 | clear() {
15 | store = {};
16 | },
17 | removeItem(key) {
18 | delete store[key];
19 | },
20 | };
21 | })();
22 | Object.defineProperty(window, 'localStorage', { value: localStorageMock });
23 |
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "app",
4 | "module": "commonjs",
5 | "target": "es2016",
6 | "jsx": "react"
7 | },
8 | "exclude": ["node_modules", "**/node_modules/*"]
9 | }
10 |
--------------------------------------------------------------------------------
/server/api_tests/auth.http:
--------------------------------------------------------------------------------
1 | # For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection).
2 | #
3 | # Following HTTP Request Live Templates are available:
4 | # * 'gtrp' and 'gtr' create a GET request with or without query parameters;
5 | # * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body;
6 | # * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data);
7 |
8 | ### Send POST request with json body
9 | POST http://localhost:3000/auth/login
10 | Content-Type: application/json
11 |
12 | {
13 | "email": "jackdh@hotmail.com",
14 | "password": "content"
15 | }
16 |
17 | ###
18 |
--------------------------------------------------------------------------------
/server/argv.js:
--------------------------------------------------------------------------------
1 | module.exports = require('minimist')(process.argv.slice(2));
2 |
--------------------------------------------------------------------------------
/server/authentication/auth-router.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const auth = require('./auth');
4 |
5 | /** Auth */
6 | router.post('/signup', auth.signup);
7 | router.post('/login', auth.login);
8 |
9 | module.exports = router;
10 |
--------------------------------------------------------------------------------
/server/authentication/authenitcation.http:
--------------------------------------------------------------------------------
1 | # For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection).
2 | #
3 | # Following HTTP Request Live Templates are available:
4 | # * 'gtrp' and 'gtr' create a GET request with or without query parameters;
5 | # * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body;
6 | # * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data);
7 |
8 | POST http://localhost:5001/auth/signup
9 | Content-Type: application/json
10 |
11 | {
12 | "password": "myPassword",
13 | "repeatPassword": "myPassword",
14 | "email": "Jack@jackdh.com"
15 | }
16 |
17 | ###
18 |
19 | POST http://localhost:5001/auth/login
20 | Content-Type: application/json
21 |
22 | {
23 | "email": "Jack@jackdh.com",
24 | "password": "myPassword"
25 | }
26 |
27 | ###
28 |
--------------------------------------------------------------------------------
/server/authentication/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "dbUri": "mongodb://mongodb://52.56.61.244:27017/sea-chatbot",
3 | "jwtSecret": "a secret phrase!!"
4 | }
--------------------------------------------------------------------------------
/server/authentication/local-signup.js:
--------------------------------------------------------------------------------
1 | const jwt = require('jsonwebtoken');
2 | const User = require('./models/user');
3 | const PassportLocalStrategy = require('passport-local').Strategy;
4 | /**
5 | * Return the Passport Local Strategy object.
6 | */
7 | module.exports = new PassportLocalStrategy(
8 | {
9 | usernameField: 'email',
10 | passwordField: 'password',
11 | session: false,
12 | passReqToCallback: true,
13 | },
14 | (req, email, password, done) => {
15 | User.count().then(count => {
16 | User.create({
17 | email: email.trim().toLowerCase(),
18 | password,
19 | role: count === 0 ? 'admin' : 'reader',
20 | groups: [],
21 | roles: [],
22 | name: req.body.name,
23 | })
24 | .then(user => {
25 | const token = jwt.sign(user.email, process.env.JWTSECRET);
26 | // eslint-disable-next-line no-param-reassign
27 | delete user.password;
28 | return done(null, token, user);
29 | })
30 | .catch(err => done(err));
31 | });
32 | },
33 | );
34 |
--------------------------------------------------------------------------------
/server/authentication/models/index.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('../../mongo/schemas/chatbot_db_connect');
2 | const debug = require('debug')('models/index');
3 |
4 | module.exports.connect = uri => {
5 | mongoose.connect(uri);
6 | // plug in the promise library:
7 | mongoose.Promise = global.Promise;
8 |
9 | mongoose.connection.on('error', err => {
10 | debug(`Mongoose connection error: ${err}`);
11 | process.exit(1);
12 | });
13 |
14 | // load models
15 | // eslint-disable-next-line global-require
16 | require('./user');
17 | };
18 |
--------------------------------------------------------------------------------
/server/middlewares/addProdMiddlewares.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const express = require('express');
3 | const compression = require('compression');
4 |
5 | module.exports = function addProdMiddlewares(app, options) {
6 | const publicPath = options.publicPath || '/';
7 | const outputPath = options.outputPath || path.resolve(process.cwd(), 'build');
8 |
9 | // compression middleware compresses your server responses which makes them
10 | // smaller (applies also to assets). You can read more about that technique
11 | // and other good practices on official Express.js docs http://mxs.is/googmy
12 | app.use(compression());
13 | app.use(publicPath, express.static(outputPath));
14 |
15 | app.get('*', (req, res) =>
16 | res.sendFile(path.resolve(outputPath, 'index.html')),
17 | );
18 | };
19 |
--------------------------------------------------------------------------------
/server/middlewares/frontendMiddleware.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable global-require */
2 |
3 | /**
4 | * Front-end middleware
5 | */
6 | module.exports = (app, options) => {
7 | const isProd = process.env.NODE_ENV === 'production';
8 |
9 | if (isProd) {
10 | const addProdMiddlewares = require('./addProdMiddlewares');
11 | addProdMiddlewares(app, options);
12 | } else {
13 | const webpackConfig = require('../../internals/webpack/webpack.dev.babel');
14 | const addDevMiddlewares = require('./addDevMiddlewares');
15 | addDevMiddlewares(app, webpackConfig);
16 | }
17 |
18 | return app;
19 | };
20 |
--------------------------------------------------------------------------------
/server/mongo/controllers/options.js:
--------------------------------------------------------------------------------
1 | const OptionsSchema = require('../schemas/optionsSchema');
2 |
3 | function save(req, res) {
4 | const { name, data } = req.params;
5 | OptionsSchema.update(
6 | { name },
7 | { $set: { 'options.text': data } },
8 | { upsert: true },
9 | err => {
10 | if (err) res.sendStatus(500);
11 |
12 | res.sendStatus(200);
13 | },
14 | );
15 | }
16 |
17 | function get(req, res) {
18 | if (req.params.name === 'all') {
19 | OptionsSchema.find({}, (err, model) => {
20 | if (err) res.sendStatus(500);
21 |
22 | res.send({ data: model });
23 | });
24 | } else {
25 | OptionsSchema.findOne({ name: req.params.name }, (err, model) => {
26 | if (err) res.sendStatus(500);
27 |
28 | res.send(model);
29 | });
30 | }
31 | }
32 |
33 | module.exports = {
34 | save,
35 | get,
36 | };
37 |
--------------------------------------------------------------------------------
/server/mongo/controllers/session.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-param-reassign */
2 | // const db = require('../mongo/mongodb');
3 | const SessionSchema = require('../schemas/sessionSchema');
4 | const debug = require('debug')('session');
5 | const co = require('co');
6 |
7 | /**
8 | * Gets the session or creates one.
9 | * @param userID
10 | * @returns {Promise}
11 | */
12 | const getSessionInternal = userID =>
13 | co(function* t() {
14 | const model = yield SessionSchema.findOne({ sessionID: userID });
15 |
16 | if (model) {
17 | if (!model.entities.saved) {
18 | model.entities.saved = {};
19 | }
20 | return model;
21 | }
22 | const newModel = yield SessionSchema.create({ sessionID: userID });
23 | newModel.entities = {
24 | context: {},
25 | saved: {},
26 | };
27 | return newModel;
28 | })
29 | .then(data => data)
30 | .catch(error => {
31 | debug(error);
32 | });
33 |
34 | module.exports = {
35 | getSessionInternal,
36 | };
37 |
--------------------------------------------------------------------------------
/server/mongo/schemas/agentsSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const agentSchema = new Schema(
6 | {
7 | _id: { type: String, required: true },
8 | agent: { type: String, required: true, unique: true },
9 | avatar: String,
10 | subtitle: String,
11 | description: String,
12 | intents: [
13 | {
14 | name: {
15 | type: String,
16 | required: true,
17 | sparse: true,
18 | },
19 | expressions: [{ type: Schema.Types.ObjectId, ref: 'expressions' }],
20 | regex: [String],
21 | },
22 | ],
23 | },
24 | { usePushEach: true },
25 | );
26 |
27 | const intent = mongoose.model('agents', agentSchema);
28 |
29 | module.exports = intent;
30 |
--------------------------------------------------------------------------------
/server/mongo/schemas/analyticsSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const analyticsSchema = new Schema({
6 | agent: String,
7 | talkWrapper: String,
8 | query: String,
9 | intent: String,
10 | responseTime: Number,
11 | session: String,
12 | cache: Boolean,
13 | });
14 |
15 | const intent = mongoose.model('analytics', analyticsSchema);
16 |
17 | module.exports = intent;
18 |
--------------------------------------------------------------------------------
/server/mongo/schemas/chatbot_db_connect.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | mongoose.Promise = require('bluebird');
3 | const logger = require('./../../logger');
4 | const options = {
5 | server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
6 | replset: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
7 | };
8 |
9 | if (process.env.MONGOUSER && process.env.MONGOPASS) {
10 | options.auth = {
11 | user: encodeURIComponent(process.env.MONGOUSER),
12 | password: encodeURIComponent(process.env.MONGOPASS),
13 | };
14 | }
15 | if (process.env.MONGODB) {
16 | options.dbName = process.env.MONGODB;
17 | }
18 | mongoose.connect(
19 | process.env.MONGOCONNECTIONSTRING,
20 | options,
21 | err => {
22 | logger.mongo(err);
23 | },
24 | );
25 | logger.log(`Mongo connection: ${mongoose.connection.readyState}`);
26 | module.exports = mongoose;
27 |
--------------------------------------------------------------------------------
/server/mongo/schemas/entitiesSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const entitiesSchema = new Schema(
6 | {
7 | name: {
8 | type: String,
9 | required: true,
10 | unique: true,
11 | },
12 | synonyms: [
13 | {
14 | synonym_reference: { type: String, required: true },
15 | list: [
16 | {
17 | type: String,
18 | },
19 | ],
20 | },
21 | ],
22 | date: { type: Date, default: Date.now },
23 | },
24 | { usePushEach: true },
25 | );
26 |
27 | // the schema is useless so far
28 | // we need to create a model using it
29 | const entities = mongoose.model('entities', entitiesSchema);
30 |
31 | // make this available to our Nodes in our Node applications
32 | module.exports = entities;
33 |
--------------------------------------------------------------------------------
/server/mongo/schemas/expressionsSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const expressionSchema = new Schema(
6 | {
7 | value: { type: String, required: true },
8 | intent: { type: Schema.Types.ObjectId, ref: 'intents' },
9 | entities: [
10 | {
11 | start: { type: Number, required: true },
12 | end: { type: Number, required: true },
13 | value: { type: String, required: true },
14 | entity: { type: String },
15 | },
16 | ],
17 | },
18 | { usePushEach: true },
19 | );
20 |
21 | // the schema is useless so far
22 | // we need to create a model using it
23 | const intent = mongoose.model('expressions', expressionSchema);
24 |
25 | // make this available to our Nodes in our Node applications
26 | module.exports = intent;
27 |
--------------------------------------------------------------------------------
/server/mongo/schemas/messageHistorySchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const messageHistorySchema = new Schema(
6 | {
7 | _id: { type: String, required: true },
8 | details: { type: Schema.Types.Mixed },
9 | history: [
10 | {
11 | text: { type: String, default: null },
12 | type: { type: String, default: null },
13 | time: { type: Date, default: Date.now },
14 | quick_replies: { type: Schema.Types.Mixed },
15 | },
16 | ],
17 | },
18 | { usePushEach: true },
19 | );
20 |
21 | const node = mongoose.model('messageHistories', messageHistorySchema);
22 |
23 | // make this available to our Nodes in our Node applications
24 | module.exports = node;
25 |
--------------------------------------------------------------------------------
/server/mongo/schemas/nodeWrapperSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const nodeWrappers = new Schema({
6 | name: { type: String, required: true },
7 | avatar: String,
8 | subtitle: String,
9 | description: String,
10 | _id: { type: String, required: true },
11 | });
12 |
13 | // the schema is useless so far
14 | // we need to create a model using it
15 | const entities = mongoose.model('nodeWrappers', nodeWrappers);
16 |
17 | // make this available to our Nodes in our Node applications
18 | module.exports = entities;
19 |
--------------------------------------------------------------------------------
/server/mongo/schemas/optionsSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const smallTalkSchema = new Schema(
6 | {
7 | name: { type: String, required: true },
8 | options: Schema.Types.Mixed,
9 | },
10 | { usePushEach: true },
11 | );
12 |
13 | // the schema is useless so far
14 | // we need to create a model using it
15 | const options = mongoose.model('options', smallTalkSchema);
16 |
17 | // make this available to our Nodes in our Node applications
18 | module.exports = options;
19 |
--------------------------------------------------------------------------------
/server/mongo/schemas/permissionsSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const permSchema = new Schema({
6 | _id: String,
7 | type: String,
8 | name: String,
9 | permissions: [String],
10 | });
11 |
12 | const session = mongoose.model('permissions', permSchema);
13 |
14 | // make this available to our Nodes in our Node applications
15 | module.exports = session;
16 |
--------------------------------------------------------------------------------
/server/mongo/schemas/sessionSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const sessionSchema = new Schema(
6 | {
7 | context: String,
8 | entities: {
9 | context: Schema.Types.Mixed,
10 | saved: Schema.Types.Mixed,
11 | },
12 | sessionID: { type: String, required: true },
13 | timestamp: { type: Date, default: Date.now },
14 | path: { type: [String], default: [] },
15 | updated_at: Date,
16 | created_at: Date,
17 | previousContext: [[String]],
18 | saveNext: String,
19 | failedGuesses: { type: Number, default: 0, min: 0 },
20 | previousQuestion: Schema.Types.Mixed,
21 | changingContext: String,
22 | inConversation: { type: Boolean, default: false },
23 | },
24 | { usePushEach: true, minimize: false },
25 | );
26 |
27 | // the schema is useless so far
28 | // we need to create a model using it
29 | const session = mongoose.model('sessions', sessionSchema);
30 |
31 | // make this available to our Nodes in our Node applications
32 | module.exports = session;
33 |
--------------------------------------------------------------------------------
/server/mongo/schemas/smallTalkSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const smallTalkSchema = new Schema(
6 | {
7 | name: { type: String, required: true },
8 | options: {
9 | enabled: { type: Boolean, default: false },
10 | prefix: { type: String, default: '#small-talk_' },
11 | },
12 | smallTalk: [
13 | {
14 | name: String,
15 | training: [String],
16 | responses: [String],
17 | },
18 | ],
19 | },
20 | { usePushEach: true },
21 | );
22 |
23 | // the schema is useless so far
24 | // we need to create a model using it
25 | const smallTalk = mongoose.model('small-talks', smallTalkSchema);
26 |
27 | // make this available to our Nodes in our Node applications
28 | module.exports = smallTalk;
29 |
--------------------------------------------------------------------------------
/server/mongo/schemas/synonymSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const synonymsSchema = new Schema(
6 | {
7 | entity: { type: String, ref: 'intents' },
8 | synonym_reference: { type: String, required: true },
9 | list: [
10 | {
11 | type: String,
12 | },
13 | ],
14 | },
15 | { usePushEach: true },
16 | );
17 |
18 | // the schema is useless so far
19 | // we need to create a model using it
20 | const intent = mongoose.model('synonyms', synonymsSchema);
21 |
22 | // make this available to our Nodes in our Node applications
23 | module.exports = intent;
24 |
--------------------------------------------------------------------------------
/server/mongo/schemas/thirdPartySchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const thirdPartySchema = new Schema({
6 | type: { type: String },
7 | enabled: { type: Boolean, default: false },
8 | debug: { type: Boolean, default: false },
9 |
10 | agent: { type: String, required: true },
11 | talkWrapper: { type: String, required: true },
12 | // Facebook
13 | access_token: { type: String },
14 | verify_token: { type: String },
15 | require_appsecret_proof: { type: Boolean, default: false },
16 | require_delivery: { type: Boolean, default: false },
17 | // Telegram
18 | telegram_token: { type: String },
19 | domain_name: { type: String },
20 | });
21 |
22 | // the schema is useless so far
23 | // we need to create a model using it
24 | const smallTalk = mongoose.model('third-parties', thirdPartySchema);
25 |
26 | // make this available to our Nodes in our Node applications
27 | module.exports = smallTalk;
28 |
--------------------------------------------------------------------------------
/server/mongo/schemas/trainingSchema.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('./chatbot_db_connect');
2 |
3 | const { Schema } = mongoose;
4 |
5 | const trainingSchema = new Schema(
6 | {
7 | date: { type: Date, default: Date.now },
8 | data: Object,
9 | model: { type: String, default: 'Not Trained' },
10 | agent: { type: String, required: true },
11 | training: { type: Boolean, default: false },
12 | trained: { type: Boolean, default: false },
13 | timeTaken: String,
14 | },
15 | { usePushEach: true },
16 | );
17 |
18 | // the schema is useless so far
19 | // we need to create a model using it
20 | const intent = mongoose.model('trainings', trainingSchema);
21 |
22 | // make this available to our Nodes in our Node applications
23 | module.exports = intent;
24 |
--------------------------------------------------------------------------------
/server/mongo/utils/cache.js:
--------------------------------------------------------------------------------
1 | const NodeCache = require('node-cache');
2 |
3 | class Cache {
4 | constructor(ttlSeconds = 60 * 60 * 24) {
5 | this.cache = new NodeCache({
6 | stdTTL: ttlSeconds,
7 | checkperiod: ttlSeconds * 0.2,
8 | useClones: false,
9 | });
10 | }
11 |
12 | set(key, data) {
13 | this.cache.set(key, data);
14 | }
15 | get(key) {
16 | return this.cache.get(key);
17 | }
18 |
19 | del(keys) {
20 | this.cache.del(keys);
21 | }
22 |
23 | flush() {
24 | this.cache.flushAll();
25 | }
26 | }
27 |
28 | module.exports = Cache;
29 |
--------------------------------------------------------------------------------
/server/mongo/utils/generateUID.js:
--------------------------------------------------------------------------------
1 | const shortid = require('shortid');
2 |
3 | // const generateUID = () => {
4 | // let firstPart = Math.random() * 46656 || 0;
5 | // let secondPart = Math.random() * 46656 || 0;
6 | // firstPart = `000${firstPart.toString(36)}`.slice(-3);
7 | // secondPart = `000${secondPart.toString(36)}`.slice(-3);
8 | // return firstPart + secondPart;
9 | // };
10 |
11 | const generateUID = () => shortid.generate();
12 |
13 | module.exports = generateUID;
14 |
--------------------------------------------------------------------------------
/server/mongo/utils/validators.js:
--------------------------------------------------------------------------------
1 | const yup = require('yup');
2 | const validateWrapper = yup.object().shape({
3 | avatar: yup.string().url(),
4 | name: yup
5 | .string()
6 | .min(2, 'Please enter a longer agent name')
7 | .max(50, 'Please enter a shorter name (50)')
8 | .required('Name is required.'),
9 | subtitle: yup.string().max(100, 'Please enter a shorter subtitle (100)'),
10 | description: yup.string().max(100, 'Please enter a shorter desc (100)'),
11 | });
12 |
13 | const validateAgent = yup.object().shape({
14 | avatar: yup.string().url(),
15 | agent: yup
16 | .string()
17 | .min(2, 'Please enter a longer agent name')
18 | .max(50, 'Please enter a shorter name (50)')
19 | .required('Agent name is required.'),
20 | subtitle: yup.string().max(100, 'Please enter a shorter subtitle (100)'),
21 | description: yup.string().max(100, 'Please enter a shorter desc (100)'),
22 | });
23 |
24 | module.exports = {
25 | validateWrapper,
26 | validateAgent,
27 | };
28 |
--------------------------------------------------------------------------------
/server/port.js:
--------------------------------------------------------------------------------
1 | const argv = require('./argv');
2 |
3 | module.exports = parseInt(argv.port || process.env.PORT || '3000', 10);
4 |
--------------------------------------------------------------------------------