From 8ba367f774b6d5931c82b8a4bdacbb594d77cffc Mon Sep 17 00:00:00 2001 From: B3zo0 Date: Sat, 31 Dec 2016 19:24:40 +0100 Subject: [PATCH 01/26] fix: Removed dev dependencies from dependecies --- package.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package.json b/package.json index 7850968..90a999e 100644 --- a/package.json +++ b/package.json @@ -28,11 +28,6 @@ }, "homepage": "https://sensenet.com", "dependencies": { - "@reactivex/rxjs": "5.0.0-rc.4", - "@types/isomorphic-fetch": "0.0.31", - "@types/normalizr": "2.0.17", - "@types/redux": "3.6.31", - "@types/redux-logger": "2.6.32", "isomorphic-fetch": "2.2.1", "rxjs": "5.0.0-rc.4", "normalizr": "2.2.1", From da9575a5d65351159558c413de169f63a24014cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Thu, 5 Jan 2017 13:21:34 +0100 Subject: [PATCH 02/26] fix: changed ADD_CONTENT_SUCCESS to CREATE_CONTENT_SUCCESS because there is no ADD_CONTENT action --- src/Reducers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Reducers.ts b/src/Reducers.ts index 6dc8aef..3ca7748 100644 --- a/src/Reducers.ts +++ b/src/Reducers.ts @@ -44,7 +44,7 @@ export module Reducers { switch (action.type) { case 'FETCH_CONTENT_SUCCESS': return action.response.result; - case 'ADD_CONTENT_SUCCESS': + case 'CREATE_CONTENT_SUCCESS': return [...state, action.response.result]; case 'DELETE_CONTENT_SUCCESS': return [...state.slice(0, action.index), ...state.slice(action.index + 1)] From d5b4ac5ec870d8c81dba417548f0fd67f546a5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Tue, 10 Jan 2017 12:19:58 +0100 Subject: [PATCH 03/26] fix: Use new ts-json-properties --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 466daaf..ccb3d6c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "redux-logger": "2.7.4", "redux-observable": "0.12.2", "sn-client-js": "1.0.2-beta.5", - "ts-json-properties": "1.1.1" + "ts-json-properties": "1.1.2" }, "devDependencies": { "@reactivex/rxjs": "5.0.0-rc.4", From 89bc46d63ad76fa80365cf82eba9d02fb7a23c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Mon, 1 May 2017 19:33:02 +0200 Subject: [PATCH 04/26] chore(deps): update sn-client.js to latest --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 476de3c..cdb99ac 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "redux": "3.6.0", "redux-logger": "2.8.2", "redux-observable": "0.14.1", - "sn-client-js": "1.1.0-beta.5", "ts-json-properties": "1.1.4" }, "devDependencies": { @@ -68,7 +67,7 @@ "rxjs": "5.2.0", "semantic-release": "^6.3.2", "sinon": "1.17.7", - "sn-client-js": "1.1.0-beta.5", + "sn-client-js": "1.1.1-beta.1", "tslint": "4.5.1", "typedoc": "0.5.7", "typescript": "2.2.1" From a900eabfc801b43376844879d6b94c66d5833ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Mon, 1 May 2017 20:05:43 +0200 Subject: [PATCH 05/26] fix(deps): sn-cleint should be in dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cdb99ac..add9d79 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "redux": "3.6.0", "redux-logger": "2.8.2", "redux-observable": "0.14.1", + "sn-client-js": "1.1.1-beta.1", "ts-json-properties": "1.1.4" }, "devDependencies": { @@ -67,7 +68,6 @@ "rxjs": "5.2.0", "semantic-release": "^6.3.2", "sinon": "1.17.7", - "sn-client-js": "1.1.1-beta.1", "tslint": "4.5.1", "typedoc": "0.5.7", "typescript": "2.2.1" From f56da66645b29e3dc168cea3bc09086cc945bbd0 Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 5 May 2017 09:25:00 +0200 Subject: [PATCH 06/26] chore(npm package, tsconfig, tsc build): Added index.ts to the unit tests, updated package dependenc --- package.json | 30 ++++++++++++------------------ test/index.ts | 4 ++++ tsconfig.json | 9 +++++---- 3 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 test/index.ts diff --git a/package.json b/package.json index 476de3c..5ebae73 100644 --- a/package.json +++ b/package.json @@ -28,23 +28,21 @@ }, "homepage": "https://sensenet.com", "dependencies": { - "isomorphic-fetch": "2.2.1", - "rxjs": "5.2.0", - "normalizr": "3.2.2", + "@reactivex/rxjs": "^5.3.1", + + "normalizr": "^3.2.2", "redux": "3.6.0", + "redux-thunk": "^2.2.0", "redux-logger": "2.8.2", - "redux-observable": "0.14.1", - "sn-client-js": "1.1.0-beta.5", - "ts-json-properties": "1.1.4" + "redux-observable": "^0.14.1", + "sn-client-js": "1.1.1-beta.1" }, "devDependencies": { - "@reactivex/rxjs": "5.2.0", "@types/chai": "3.4.35", "@types/mocha": "2.2.39", "@types/nock": "8.2.1", "@types/orchestrator": "0.0.30", "@types/redux-mock-store": "0.0.7", - "@types/sinon": "1.16.35", "chai": "3.5.0", "codecov.io": "0.1.6", "commitizen": "2.9.6", @@ -57,21 +55,17 @@ "gulp-tslint": "7.1.0", "gulp-typedoc": "2.0.2", "gulp-typescript": "3.1.5", - "isomorphic-fetch": "2.2.1", - "mocha": "3.2.0", + "mocha": "3.3.0", "nock": "9.0.9", "normalizr": "3.2.2", - "redux": "3.6.0", - "redux-mock-store": "1.2.2", + "redux": "^3.6.0", + "redux-mock-store": "1.2.3", "redux-observable": "0.14.1", "remap-istanbul": "0.9.1", - "rxjs": "5.2.0", "semantic-release": "^6.3.2", - "sinon": "1.17.7", - "sn-client-js": "1.1.0-beta.5", - "tslint": "4.5.1", - "typedoc": "0.5.7", - "typescript": "2.2.1" + "tslint": "5.2.0", + "typedoc": "0.6.0", + "typescript": "2.3.2" }, "czConfig": { "path": "node_modules/cz-conventional-changelog" diff --git a/test/index.ts b/test/index.ts new file mode 100644 index 0000000..2026583 --- /dev/null +++ b/test/index.ts @@ -0,0 +1,4 @@ +export * from './ActionsTests'; +export * from './EpicsTests'; +export * from './ReducersTests'; + diff --git a/tsconfig.json b/tsconfig.json index 2634938..a96d278 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,13 +4,13 @@ "noImplicitAny": false, "target": "es2015", "module": "commonjs", + "moduleResolution": "node", "sourceMap": true, "declaration": false, "preserveConstEnums": true, "experimentalDecorators": true, - "typeRoots": [ - "./node_modules/@types" - ] + "emitDecoratorMetadata": true, + "outDir": "./dist" }, "exclude": [ "node_modules", @@ -18,6 +18,7 @@ ], "compileOnSave": false, "files": [ - "src/sn-redux.ts" + "src/sn-redux.ts", + "test/index.ts" ] } \ No newline at end of file From f9f2c260a12a63959ebf499ca09e6ccb9f95a581 Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 5 May 2017 09:27:15 +0200 Subject: [PATCH 07/26] chore(tslint): removed trailing spaces --- src/Reducers.ts | 4 ++-- src/Schema.ts | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Reducers.ts b/src/Reducers.ts index 1e3de85..4726c27 100644 --- a/src/Reducers.ts +++ b/src/Reducers.ts @@ -3,9 +3,9 @@ import { combineReducers } from 'redux'; /** * Module for defining Redux reducers. - * + * * _Actions describe the fact that something happened, but don't specify how the application's state changes in response. This is the job of a reducer._ - * + * * Following module contains the reducers of sn-redux, some 'reducer groups' and the root reducer which could be passed to the store creator function. Using a root reduces means * that you define which combination of reducers will be used and eventually defines which type of actions can be called on the store. */ diff --git a/src/Schema.ts b/src/Schema.ts index 1ade185..8ae123f 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -1,8 +1,8 @@ import { schema } from 'normalizr'; -/** +/** * This module is for defining Content and Collection schemas to normalize nested JSON response data in redux state store. - * + * * Normalizr takes JSON and a schema and replaces nested entities with their IDs, gathering all entities in dictionaries. ** Entities can be nested inside other entities, objects and arrays; ** Combine entity schemas to express any kind of API response; @@ -10,11 +10,11 @@ import { schema } from 'normalizr'; ** Allows using a custom ID attribute (e.g. slug). * * Read more about normalizr [here](https://github.com/paularmstrong/normalizr) - * + * * Since everything is a Content in SenseNet we're working with Content and collection of Content in most of the cases. So the sn-redux Schemas module defines the two - * neccessarry main schema, content and arrayofContent to work with. This two schemas help you to normalize your JSON responses so that you can create a pure and flexible + * neccessarry main schema, content and arrayofContent to work with. This two schemas help you to normalize your JSON responses so that you can create a pure and flexible * client-side datasource. - * + * * Example of normalizing the JSON response of a SenseNet OData Action for fetching Content as arrayOfContent schema which will create a collection object. * ```ts * export const receiveContent = (response: any, filter: string) => @@ -24,9 +24,9 @@ import { schema } from 'normalizr'; * filter * }) * ``` - * + * * ![Normalized collection](http://download.sensenet.com/aniko/sn7/jsapidocs/img/normalized-collection.png) - * + * * Example of normalizing the JSON response of a SenseNet OData Action for creating Content as content schema. * ```ts * export const createContentSuccess = (response: any) => @@ -35,19 +35,19 @@ import { schema } from 'normalizr'; * response: normalize(response.response.d, Schemas.content) * }); * ``` - * + * * ![Normalized content](http://download.sensenet.com/aniko/sn7/jsapidocs/img/normalized-content.png) */ export module Schemas{ /** - * Schema of a Content. - * + * Schema of a Content. + * * It represents an item in the collection Object of the sn-redux store. The items are identified by the attribute 'Id'. */ export const content = new schema.Entity('collection', {}, { idAttribute: 'Id' }); /** * Schema of a Collection. - * + * * It represents the top object of the sn-redux store. It's a parent element of the Content items so it is defined as array of items with the schema content. */ export const arrayOfContent = new schema.Array(content); From 265dd11618e37a161b53dc08297a06a11d6dfed5 Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 5 May 2017 09:52:11 +0200 Subject: [PATCH 08/26] build(Git, Dist, package.json): Removed ./dist folder from source control, added to package.json 'fi --- .gitignore | 2 +- dist/src/Actions.js | 189 ------------- dist/src/Actions.js.map | 1 - dist/src/Epics.js | 162 ----------- dist/src/Epics.js.map | 1 - dist/src/Reducers.js | 142 ---------- dist/src/Reducers.js.map | 1 - dist/src/Schema.js | 10 - dist/src/Schema.js.map | 1 - dist/src/Store.js | 36 --- dist/src/Store.js.map | 1 - dist/src/sn-redux.js | 19 -- dist/src/sn-redux.js.map | 1 - dist/test/ActionsTests.js | 478 --------------------------------- dist/test/ActionsTests.js.map | 1 - dist/test/EpicsTests.js | 391 --------------------------- dist/test/EpicsTests.js.map | 1 - dist/test/ReducersTests.js | 341 ----------------------- dist/test/ReducersTests.js.map | 1 - package.json | 7 +- 20 files changed, 7 insertions(+), 1779 deletions(-) delete mode 100644 dist/src/Actions.js delete mode 100644 dist/src/Actions.js.map delete mode 100644 dist/src/Epics.js delete mode 100644 dist/src/Epics.js.map delete mode 100644 dist/src/Reducers.js delete mode 100644 dist/src/Reducers.js.map delete mode 100644 dist/src/Schema.js delete mode 100644 dist/src/Schema.js.map delete mode 100644 dist/src/Store.js delete mode 100644 dist/src/Store.js.map delete mode 100644 dist/src/sn-redux.js delete mode 100644 dist/src/sn-redux.js.map delete mode 100644 dist/test/ActionsTests.js delete mode 100644 dist/test/ActionsTests.js.map delete mode 100644 dist/test/EpicsTests.js delete mode 100644 dist/test/EpicsTests.js.map delete mode 100644 dist/test/ReducersTests.js delete mode 100644 dist/test/ReducersTests.js.map diff --git a/.gitignore b/.gitignore index fd24998..55b21d6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ coverage documentation npm-debug.log debug.log -.vscode \ No newline at end of file +dist \ No newline at end of file diff --git a/dist/src/Actions.js b/dist/src/Actions.js deleted file mode 100644 index cf451b8..0000000 --- a/dist/src/Actions.js +++ /dev/null @@ -1,189 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const normalizr_1 = require("normalizr"); -const Schema_1 = require("./Schema"); -const SN = require("sn-client-js"); -var Actions; -(function (Actions) { - Actions.RequestContent = (path, options = {}) => ({ - type: 'FETCH_CONTENT_REQUEST', - path, - filter: SN.ODataHelper.buildUrlParamString(options) - }); - Actions.ReceiveContent = (response, filter) => ({ - type: 'FETCH_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.d.results, Schema_1.Schemas.arrayOfContent), - filter - }); - Actions.ReceiveContentFailure = (filter, error) => ({ - type: 'FETCH_CONTENT_FAILURE', - filter, - message: error.message - }); - Actions.CreateContent = (path, content) => ({ type: 'CREATE_CONTENT_REQUEST', content, path }); - Actions.CreateContentSuccess = (response) => ({ - type: 'CREATE_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.CreateContentFailure = (error) => ({ - type: 'CREATE_CONTENT_FAILURE', - message: error.message - }); - Actions.UpdateContent = (id, fields) => ({ type: 'UPDATE_CONTENT_REQUEST', id, fields }); - Actions.UpdateContentSuccess = (response) => ({ - type: 'UPDATE_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.UpdateContentFailure = (error) => ({ - type: 'UPDATE_CONTENT_FAILURE', - message: error.message - }); - Actions.Delete = (id, permanently = false) => ({ type: 'DELETE_CONTENT_REQUEST', id, permanently }); - Actions.DeleteSuccess = (index, id) => ({ - type: 'DELETE_CONTENT_SUCCESS', - index, - id - }); - Actions.DeleteFailure = (error) => ({ - type: 'DELETE_CONTENT_FAILURE', - message: error.message - }); - Actions.DeleteBatch = (path, ids, permanently = false) => ({ - type: 'DELETE_BATCH_REQUEST', - path, - ids, - permanently - }); - Actions.DeleteBatchSuccess = (indexes) => ({ - type: 'DELETE_BATCH_SUCCESS', - indexes - }); - Actions.DeleteBatchFailure = (error) => ({ - type: 'DELETE_BATCH_FAILURE', - message: error.message - }); - Actions.CheckOut = (id) => ({ - type: 'CHECKOUT_CONTENT_REQUEST', - id - }); - Actions.CheckOutSuccess = (response) => ({ - type: 'CHECKOUT_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.CheckOutFailure = (error) => ({ - type: 'CHECKOUT_CONTENT_FAILURE', - message: error.message - }); - Actions.CheckIn = (id, checkInComment = '') => ({ - type: 'CHECKIN_CONTENT_REQUEST', - id, - checkInComment - }); - Actions.CheckInSuccess = (response) => ({ - type: 'CHECKIN_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.CheckInFailure = (error) => ({ - type: 'CHECKIN_CONTENT_FAILURE', - message: error.message - }); - Actions.Publish = (id) => ({ - type: 'PUBLISH_CONTENT_REQUEST', - id - }); - Actions.PublishSuccess = (response) => ({ - type: 'PUBLISH_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.PublishFailure = (error) => ({ - type: 'PUBLISH_CONTENT_FAILURE', - message: error.message - }); - Actions.Approve = (id) => ({ - type: 'APPROVE_CONTENT_REQUEST', - id - }); - Actions.ApproveSuccess = (response) => ({ - type: 'APPROVE_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.ApproveFailure = (error) => ({ - type: 'APPROVE_CONTENT_FAILURE', - message: error.message - }); - Actions.Reject = (id, rejectReason = '') => ({ - type: 'REJECT_CONTENT_REQUEST', - id, - rejectReason - }); - Actions.RejectSuccess = (response) => ({ - type: 'REJECT_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.RejectFailure = (error) => ({ - type: 'REJECT_CONTENT_FAILURE', - message: error.message - }); - Actions.UndoCheckout = (id) => ({ - type: 'UNDOCHECKOUT_CONTENT_REQUEST', - id - }); - Actions.UndoCheckoutSuccess = (response) => ({ - type: 'UNDOCHECKOUT_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.UndoCheckoutFailure = (error) => ({ - type: 'UNDOCHECKOUT_CONTENT_FAILURE', - message: error.message - }); - Actions.ForceUndoCheckout = (id) => ({ - type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', - id - }); - Actions.ForceUndoCheckoutSuccess = (response) => ({ - type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.ForceUndoCheckoutFailure = (error) => ({ - type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', - message: error.message - }); - Actions.RestoreVersion = (id, version) => ({ - type: 'RESTOREVERSION_CONTENT_REQUEST', - id, - version - }); - Actions.RestoreVersionSuccess = (response) => ({ - type: 'RESTOREVERSION_CONTENT_SUCCESS', - response: normalizr_1.normalize(response.response.d, Schema_1.Schemas.content) - }); - Actions.RestoreVersionFailure = (error) => ({ - type: 'RESTOREVERSION_CONTENT_FAILURE', - message: error.message - }); - Actions.UserLogin = (userName, password) => ({ - type: 'USER_LOGIN_REQUEST', - userName, - password - }); - Actions.UserLoginSuccess = (response) => ({ - type: 'USER_LOGIN_SUCCESS', - response: response.response.d - }); - Actions.UserLoginFailure = (error) => ({ - type: 'USER_LOGIN_FAILURE', - message: (error.status === 403) ? 'The username or the password is not valid!' : error.message - }); - Actions.UserLogout = () => ({ - type: 'USER_LOGOUT_REQUEST' - }); - Actions.UserLogoutSuccess = (response) => ({ - type: 'USER_LOGOUT_SUCCESS' - }); - Actions.UserLogoutFailure = (error) => ({ - type: 'USER_LOGOUT_FAILURE', - message: error.message - }); -})(Actions = exports.Actions || (exports.Actions = {})); - -//# sourceMappingURL=Actions.js.map diff --git a/dist/src/Actions.js.map b/dist/src/Actions.js.map deleted file mode 100644 index 9e68112..0000000 --- a/dist/src/Actions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["src/Actions.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AACtC,qCAAmC;AACnC,mCAAmC;AA+GnC,IAAc,OAAO,CAoapB;AApaD,WAAc,OAAO;IAOJ,sBAAc,GAAG,CAAC,IAAY,EAAE,UAAoC,EAAE,KAAK,C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AG,CAAC,KAAU,KAAK,CAAC;QAC9C,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,KAAK,CAAC,OAAO;KACzB,CAAC,CAAA;AACN,CAAC,EApaa,OAAO,GAAP,eAAO,KAAP,eAAO,QAoapB","file":"Actions.js","sourcesContent":["import { normalize } from 'normalizr';\r\nimport { Schemas } from './Schema';\r\nimport * as SN from 'sn-client-js';\r\n\r\n/**\r\n * Module that contains the action creators. \r\n * \r\n * _Redux actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using \r\n * ```store.dispatch()```. Actions are plain JavaScript objects. Actions must have a type property that indicates the type of action being performed._\r\n * \r\n * Learn more about Redux actions [here](http://redux.js.org/docs/basics/Actions.html)\r\n * \r\n * Following are Redux actions but they're all related with a Sense/Net built-in action. Since this Sense/Net built-in actions are OData actions and functions and they get and set \r\n * data throught ajax request we have to handle the main steps of their process separately. So there're three separate redux action for every Sense/Net action:\r\n * one for the request itself and two for the two possible end of an ajax request, success and fail.\r\n * \r\n * All of the JSON responses with content or collection are normalized so you shouldn't care about how to handle nested data structure, normalizr takes JSON and a schema and replaces \r\n * nested entities with their IDs, gathering all entities in dictionaries.\r\n * For further information about normalizr check this [link](https://github.com/paularmstrong/normalizr).\r\n * \r\n * ```\r\n * [{\r\n * Id: 5145,\r\n * DisplayName: 'Some Article',\r\n * Status: ['Active']\r\n * }, {\r\n * Id: 5146,\r\n * Displayname: 'Other Article',\r\n * Status: ['Completed']\r\n * }]\r\n * \r\n * ```\r\n * \r\n * is normalized to\r\n * \r\n * ```\r\n * result: [5145, 5146],\r\n * entities: {\r\n * collection: {\r\n * 5145: {\r\n * Id: 5145,\r\n * DisplayName: 'Some Article',\r\n * Status: ['Active']\r\n * },\r\n * 5146: {\r\n * Id: 5146,\r\n * Displayname: 'Other Article',\r\n * Status: ['Completed']\r\n * }\r\n * }\r\n * }\r\n * ```\r\n * \r\n * Following module now cover the CRUD operations, so it contains Actions which are related to fetching, creating, deleting and updating Content. Other built-in SenseNet OData\r\n * Actions and Functions will be the parts of this module too and you are be able to add your custom Actions too by combining your reducers with the built-in ones.\r\n * \r\n * ### Using built-in redux actions in your views\r\n * \r\n * ```\r\n * import * as React from 'react'\r\n * import { connect } from 'react-redux'\r\n * import { TextField } from 'material-ui/TextField';\r\n * import RaisedButton from 'material-ui/RaisedButton';\r\n * import { Actions } from 'sn-redux';\r\n * import { Content } from './SenseNet/Content';\r\n * \r\n * let AddTodo = ({ dispatch }) => {\r\n * let input\r\n * \r\n * return (\r\n *
\r\n *
{\r\n * e.preventDefault()\r\n * if (!input.value.trim()) {\r\n * return\r\n * }\r\n * const content = new Content({\r\n * Type: 'Task',\r\n * DisplayName: input.value\r\n * });\r\n * content[\"Status\"] = \"active\";\r\n * const ROOT_URL = 'https://mySite.com/OData.svc/workspaces/Project/budapestprojectworkspace/Tasks';\r\n * dispatch(Actions.createContent(ROOT_URL, content))\r\n * input.value = ''\r\n * } }>\r\n * {\r\n * input = node\r\n * } } />\r\n * \r\n * \r\n *
\r\n * )\r\n * }\r\n * AddTodo = connect()(AddTodo)\r\n * ```\r\n * \r\n * ### Combining your custom redux reducers with sn-redux's root reducer.\r\n * \r\n * ```\r\n * import { combineReducers } from 'redux';\r\n * import { Store, Reducers } from 'sn-redux';\r\n * import { Root } from './components/Root'\r\n * import { listByFilter } from './reducers/filtering'\r\n * \r\n * const collection = Reducers.collection;\r\n * const myReducer = combineReducers({\r\n * collection,\r\n * listByFilter\r\n * });\r\n * \r\n * const store = Store.configureStore(myReducer);\r\n * ```\r\n */\r\nexport module Actions {\r\n /**\r\n * Action creator for requesting a content from Sense/Net Content Repository to get its children content.\r\n * @param path {string} Path of the requested parent item.\r\n * @param options {OData.IODataParams} Represents an ODataOptions object based on the IODataOptions interface. Holds the possible url parameters as properties.\r\n * @returns {Object} Returns a redux action with the properties type, path and filter. \r\n */\r\n export const RequestContent = (path: string, options: SN.ODataApi.IODataParams = {}) => ({\r\n type: 'FETCH_CONTENT_REQUEST',\r\n path,\r\n filter: SN.ODataHelper.buildUrlParamString(options)\r\n });\r\n /**\r\n * Action creator for the step when a fetching request ends successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @param filter {string} String with the url params.\r\n * @returns {Object} Returns a redux action with the properties type, normalized response and filter. \r\n */\r\n export const ReceiveContent = (response: any, filter: string) =>\r\n ({\r\n type: 'FETCH_CONTENT_SUCCESS',\r\n response: normalize(response.d.results, Schemas.arrayOfContent),\r\n filter\r\n })\r\n /**\r\n * Action creator for the step when a fetching request failed.\r\n * @param filter {string} String with the url params.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type, filter and errormessage. \r\n */\r\n export const ReceiveContentFailure = (filter: string, error: any) => ({\r\n type: 'FETCH_CONTENT_FAILURE',\r\n filter,\r\n message: error.message\r\n });\r\n /**\r\n * Action creator for creating a Content in the Content Repository.\r\n * @param path {string} Path of the parent item.\r\n * @param content {Content} Content that have to be created in the Content Respository.\r\n * @returns {Object} Returns a redux action with the properties type, path of the parent and content. \r\n */\r\n export const CreateContent = (path: string, content: SN.Content) => ({ type: 'CREATE_CONTENT_REQUEST', content, path });\r\n /**\r\n * Action creator for the step when Content creation on the server ends successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized response. \r\n */\r\n export const CreateContentSuccess = (response: any) =>\r\n ({\r\n type: 'CREATE_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n });\r\n /**\r\n * Action creator for the step when Content creation failed on the server.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const CreateContentFailure = (error: any) => ({\r\n type: 'CREATE_CONTENT_FAILURE',\r\n message: error.message\r\n });\r\n /**\r\n * Action creator for updating a Content in the Content Repository.\r\n * @param id {number} Id of the Content that has to be updated.\r\n * @param fields {Object} Object with the field value pairs that have to be modified.\r\n * @returns {Object} Returns a redux action with the properties type, id and fields. \r\n */\r\n export const UpdateContent = (id: number, fields: Object) => ({ type: 'UPDATE_CONTENT_REQUEST', id, fields });\r\n /**\r\n * Action creator for the step when Content modification on the server ends successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the response. \r\n */\r\n export const UpdateContentSuccess = (response: any) =>\r\n ({\r\n type: 'UPDATE_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n });\r\n /**\r\n * Action creator for the step when Content modification failed on the server.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const UpdateContentFailure = (error: any) => ({\r\n type: 'UPDATE_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for deleting a Content from the Content Repository.\r\n * @param id {number} Id of the Content that has to be deleted.\r\n * @param permanently {boolean} Defines whether the a Content must be moved to the Trash or deleted permanently.\r\n * @returns {Object} Returns a redux action with the properties type, id and permanently. \r\n */\r\n export const Delete = (id: number, permanently: boolean = false) => ({ type: 'DELETE_CONTENT_REQUEST', id, permanently });\r\n /**\r\n * Action creator for the step when Content deleted successfully.\r\n * @param index {number} Index of the item in the state collection.\r\n * @returns {Object} Returns a redux action with the properties type and index. \r\n */\r\n export const DeleteSuccess = (index: number, id: number) => ({\r\n type: 'DELETE_CONTENT_SUCCESS',\r\n index,\r\n id\r\n })\r\n /**\r\n * Action creator for the step when deleting a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const DeleteFailure = (error: any) => ({\r\n type: 'DELETE_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for deleting multiple Content from the Content Repository.\r\n * @param path {string} Path of the parent Content.\r\n * @param ids {string[]} Array of ids of the Content that should be deleted.\r\n * @param permanently {boolean} Defines whether Content must be moved to the Trash or deleted permanently.\r\n * @returns {Object} Returns a redux action with the properties type, id and permanently. \r\n */\r\n export const DeleteBatch = (path: string, ids: string[], permanently: boolean = false) => ({\r\n type: 'DELETE_BATCH_REQUEST',\r\n path,\r\n ids,\r\n permanently\r\n })\r\n /**\r\n * Action creator for the step when multiple Content deleted successfully.\r\n * @param indexes {number[]} Array of indexes of the items in the state collection that should be removed.\r\n * @returns {Object} Returns a redux action with the properties type and index. \r\n */\r\n export const DeleteBatchSuccess = (indexes: number[]) => ({\r\n type: 'DELETE_BATCH_SUCCESS',\r\n indexes\r\n })\r\n /**\r\n * Action creator for the step when deleting multiple Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const DeleteBatchFailure = (error: any) => ({\r\n type: 'DELETE_BATCH_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for checking out a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be checked out.\r\n * @returns {Object} Returns a redux action with the properties type and id . \r\n */\r\n export const CheckOut = (id: number) => ({\r\n type: 'CHECKOUT_CONTENT_REQUEST',\r\n id\r\n })\r\n /**\r\n * Action creator for the step when a Content is checked out successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const CheckOutSuccess = (response: any) => ({\r\n type: 'CHECKOUT_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when checking out a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const CheckOutFailure = (error: any) => ({\r\n type: 'CHECKOUT_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for checking in a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be checked in.\r\n * @returns {Object} Returns a redux action with the properties type, id and checkinComment. \r\n */\r\n export const CheckIn = (id: number, checkInComment: string = '') => ({\r\n type: 'CHECKIN_CONTENT_REQUEST',\r\n id,\r\n checkInComment\r\n })\r\n /**\r\n * Action creator for the step when a Content is checked in successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const CheckInSuccess = (response: any) => ({\r\n type: 'CHECKIN_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when checking out a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const CheckInFailure = (error: any) => ({\r\n type: 'CHECKIN_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for publishing a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be published.\r\n * @returns {Object} Returns a redux action with the properties type and id. \r\n */\r\n export const Publish = (id: number) => ({\r\n type: 'PUBLISH_CONTENT_REQUEST',\r\n id\r\n })\r\n /**\r\n * Action creator for the step when a Content is published successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const PublishSuccess = (response: any) => ({\r\n type: 'PUBLISH_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when publishing a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const PublishFailure = (error: any) => ({\r\n type: 'PUBLISH_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for approving a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be approved.\r\n * @returns {Object} Returns a redux action with the properties type and id. \r\n */\r\n export const Approve = (id: number) => ({\r\n type: 'APPROVE_CONTENT_REQUEST',\r\n id\r\n })\r\n /**\r\n * Action creator for the step when a Content is approved successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const ApproveSuccess = (response: any) => ({\r\n type: 'APPROVE_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when approving a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const ApproveFailure = (error: any) => ({\r\n type: 'APPROVE_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for rejecting a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be rejected.\r\n * @param rejectReason {string} Reason of rejecting.\r\n * @returns {Object} Returns a redux action with the properties type, rejectReason and id. \r\n */\r\n export const Reject = (id: number, rejectReason: string = '') => ({\r\n type: 'REJECT_CONTENT_REQUEST',\r\n id,\r\n rejectReason\r\n })\r\n /**\r\n * Action creator for the step when a Content is rejected successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const RejectSuccess = (response: any) => ({\r\n type: 'REJECT_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when rejecting a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const RejectFailure = (error: any) => ({\r\n type: 'REJECT_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for undoing checkout on a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be checked in.\r\n * @returns {Object} Returns a redux action with the properties type and id. \r\n */\r\n export const UndoCheckout = (id: number) => ({\r\n type: 'UNDOCHECKOUT_CONTENT_REQUEST',\r\n id\r\n })\r\n /**\r\n * Action creator for the step when a Content is checked-in successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const UndoCheckoutSuccess = (response: any) => ({\r\n type: 'UNDOCHECKOUT_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when undoing checkout on a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const UndoCheckoutFailure = (error: any) => ({\r\n type: 'UNDOCHECKOUT_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for undoing checkout on a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be checked in.\r\n * @returns {Object} Returns a redux action with the properties type and id. \r\n */\r\n export const ForceUndoCheckout = (id: number) => ({\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST',\r\n id\r\n })\r\n /**\r\n * Action creator for the step when a Content is checked-in successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const ForceUndoCheckoutSuccess = (response: any) => ({\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when undoing checkout on a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const ForceUndoCheckoutFailure = (error: any) => ({\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n /**\r\n * Action creator for restoring the version of a Content in the Content Repository.\r\n * @param id {number} Id of the content that should be checked in.\r\n * @param version {string} Specify which old version to restore\r\n * @returns {Object} Returns a redux action with the properties type and id. \r\n */\r\n export const RestoreVersion = (id: number, version: string) => ({\r\n type: 'RESTOREVERSION_CONTENT_REQUEST',\r\n id,\r\n version\r\n })\r\n /**\r\n * Action creator for the step when a Content is restored to a previous version successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. \r\n */\r\n export const RestoreVersionSuccess = (response: any) => ({\r\n type: 'RESTOREVERSION_CONTENT_SUCCESS',\r\n response: normalize(response.response.d, Schemas.content)\r\n })\r\n /**\r\n * Action creator for the step when restoring a previous version of a Content is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const RestoreVersionFailure = (error: any) => ({\r\n type: 'RESTOREVERSION_CONTENT_FAILURE',\r\n message: error.message\r\n })\r\n\r\n /**\r\n * Action creator for login a user to a Sense/Net portal.\r\n * @param userName {string} Login name of the user.\r\n * @param password {string} Password of the user.\r\n * @returns {Object} Returns a redux action with the properties userName and password.\r\n */\r\n export const UserLogin = (userName: string, password: string) => ({\r\n type: 'USER_LOGIN_REQUEST',\r\n userName,\r\n password\r\n })\r\n /**\r\n * Action creator for the step when a User is logged in successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with the user as a response.\r\n */\r\n export const UserLoginSuccess = (response: any) => ({\r\n type: 'USER_LOGIN_SUCCESS',\r\n response: response.response.d\r\n })\r\n /**\r\n * Action creator for the step when login of a user is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const UserLoginFailure = (error: any) => ({\r\n type: 'USER_LOGIN_FAILURE',\r\n message: (error.status === 403) ? 'The username or the password is not valid!' : error.message\r\n })\r\n\r\n /**\r\n * Action creator for logout a user from a Sense/Net portal.\r\n * @returns {Object} Returns a redux action.\r\n */\r\n export const UserLogout = () => ({\r\n type: 'USER_LOGOUT_REQUEST'\r\n })\r\n /**\r\n * Action creator for the step when a user is logged out successfully.\r\n * @param response {any} JSON response of the ajax request.\r\n * @returns {Object} Returns a redux action with a response.\r\n */\r\n export const UserLogoutSuccess = (response: any) => ({\r\n type: 'USER_LOGOUT_SUCCESS'\r\n })\r\n /**\r\n * Action creator for the step when logging out of a user is failed.\r\n * @param error {any} The catched error object.\r\n * @returns {Object} Returns a redux action with the properties type and the error message. \r\n */\r\n export const UserLogoutFailure = (error: any) => ({\r\n type: 'USER_LOGOUT_FAILURE',\r\n message: error.message\r\n })\r\n}"]} \ No newline at end of file diff --git a/dist/src/Epics.js b/dist/src/Epics.js deleted file mode 100644 index c6156c0..0000000 --- a/dist/src/Epics.js +++ /dev/null @@ -1,162 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const redux_observable_1 = require("redux-observable"); -const Rx = require("@reactivex/rxjs"); -const SN = require("sn-client-js"); -const Actions_1 = require("./Actions"); -const Reducers_1 = require("./Reducers"); -const { ajax } = Rx.Observable; -var Epics; -(function (Epics) { - Epics.fetchContentEpic = action$ => { - return action$.ofType('FETCH_CONTENT_REQUEST') - .mergeMap(action => { - let params = `${action.filter}`; - return SN.ODataApiActionObservables.FetchContent(action.path, params) - .map((response) => Actions_1.Actions.ReceiveContent(response.response, params)) - .catch(error => Rx.Observable.of(Actions_1.Actions.ReceiveContentFailure(params, error))); - }); - }; - Epics.createContentEpic = action$ => { - return action$.ofType('CREATE_CONTENT_REQUEST') - .mergeMap(action => { - let content = action.content; - content['__ContentType'] = content.Type; - return SN.ODataApiActionObservables.CreateContent(action.path, content) - .map(Actions_1.Actions.CreateContentSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.CreateContentFailure(error))); - }); - }; - Epics.updateContentEpic = (action$, store) => { - return action$.ofType('UPDATE_CONTENT_REQUEST') - .mergeMap(action => { - return SN.ODataApiActionObservables.PatchContent(action.id, action.fields) - .map(Actions_1.Actions.UpdateContentSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.UpdateContentFailure(error))); - }); - }; - Epics.deleteContentEpic = (action$, store) => { - return action$.ofType('DELETE_CONTENT_REQUEST') - .mergeMap(action => { - return SN.ODataApiActionObservables.DeleteContent(action.id, action.permanently) - .map((response) => { - const state = store.getState(); - const ids = Reducers_1.Reducers.getIds(state.collection); - return Actions_1.Actions.DeleteSuccess(ids.indexOf(action.id), action.id); - }) - .catch(error => Rx.Observable.of(Actions_1.Actions.DeleteFailure(error))); - }); - }; - Epics.deleteBatchEpic = (action$, store) => { - return action$.ofType('DELETE_BATCH_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'DeleteBatch', path: action.path, isAction: true, requiredParams: ['paths'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'paths': action.ids, 'permanently': action.permanently } }) - .map((response) => { - const state = store.getState(); - const ids = Reducers_1.Reducers.getIds(state.collection); - let indexes = []; - for (let i = 0; i < ids.length; i++) { - if (action.ids.indexOf(ids[i]) > -1) { - indexes.push(i); - } - } - return Actions_1.Actions.DeleteBatchSuccess(indexes); - }) - .catch(error => Rx.Observable.of(Actions_1.Actions.DeleteBatchFailure(error))); - }); - }; - Epics.checkoutContentEpic = (action$, store) => { - return action$.ofType('CHECKOUT_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'CheckOut', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) - .map(Actions_1.Actions.CheckOutSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.CheckOutFailure(error))); - }); - }; - Epics.checkinContentEpic = (action$, store) => { - return action$.ofType('CHECKIN_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'CheckIn', id: action.id, isAction: true, params: ['checkInComment'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'checkInComments': action.checkInComment } }) - .map(Actions_1.Actions.CheckInSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.CheckInFailure(error))); - }); - }; - Epics.publishContentEpic = (action$, store) => { - return action$.ofType('PUBLISH_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Publish', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) - .map(Actions_1.Actions.PublishSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.PublishFailure(error))); - }); - }; - Epics.approveContentEpic = (action$, store) => { - return action$.ofType('APPROVE_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Approve', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) - .map(Actions_1.Actions.ApproveSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.ApproveFailure(error))); - }); - }; - Epics.rejectContentEpic = (action$, store) => { - return action$.ofType('REJECT_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Reject', id: action.id, isAction: true, params: ['rejectReason'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'rejectReason': action.rejectReason ? action.rejectReason : '' } }) - .map(Actions_1.Actions.RejectSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.RejectFailure(error))); - }); - }; - Epics.undocheckoutContentEpic = (action$, store) => { - return action$.ofType('UNDOCHECKOUT_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'UndoCheckout', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) - .map(Actions_1.Actions.UndoCheckoutSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.UndoCheckoutFailure(error))); - }); - }; - Epics.forceundocheckoutContentEpic = (action$, store) => { - return action$.ofType('FORCEUNDOCHECKOUT_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'ForceUndoCheckout', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) - .map(Actions_1.Actions.ForceUndoCheckoutSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.ForceUndoCheckoutFailure(error))); - }); - }; - Epics.restoreversionContentEpic = (action$, store) => { - return action$.ofType('RESTOREVERSION_CONTENT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'RestoreVersion', id: action.id, isAction: true, params: ['version'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'version': action.version } }) - .map(Actions_1.Actions.RestoreVersionSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.RestoreVersionFailure(error))); - }); - }; - Epics.userLoginEpic = (action$, store) => { - return action$.ofType('USER_LOGIN_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Login', path: '/Root', isAction: true, requiredParams: ['username', 'password'], noCache: true }); - return SN.ODataApiActionObservables.Login(Action, { data: { 'username': action.userName, 'password': action.password } }) - .map(Actions_1.Actions.UserLoginSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.UserLoginFailure(error))); - }); - }; - Epics.userLogoutEpic = (action$, store) => { - return action$.ofType('USER_LOGOUT_REQUEST') - .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Logout', path: '/Root', isAction: true, noCache: true }); - return SN.ODataApiActionObservables.Logout(Action, {}) - .map(Actions_1.Actions.UserLogoutSuccess) - .catch(error => Rx.Observable.of(Actions_1.Actions.UserLogoutFailure(error))); - }); - }; - Epics.rootEpic = redux_observable_1.combineEpics(Epics.fetchContentEpic, Epics.createContentEpic, Epics.updateContentEpic, Epics.deleteContentEpic, Epics.deleteBatchEpic, Epics.checkoutContentEpic, Epics.checkinContentEpic, Epics.publishContentEpic, Epics.approveContentEpic, Epics.rejectContentEpic, Epics.undocheckoutContentEpic, Epics.forceundocheckoutContentEpic, Epics.restoreversionContentEpic, Epics.userLoginEpic, Epics.userLogoutEpic); -})(Epics = exports.Epics || (exports.Epics = {})); - -//# sourceMappingURL=Epics.js.map diff --git a/dist/src/Epics.js.map b/dist/src/Epics.js.map deleted file mode 100644 index 25326ca..0000000 --- a/dist/src/Epics.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["src/Epics.ts"],"names":[],"mappings":";;AAAA,uDAAmE;AACnE,sCAAsC;AACtC,mCAAmC;AACnC,uCAAoC;AACpC,yCAAsC;AAEtC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC;AA+B/B,IAAc,KAAK,CAwOlB;AAxOD,WAAc,KAAK;IAKF,sBAAgB,GAAG,OAAO;QACnC,MAAM,CAAC,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AA;IAKY,cAAQ,GAAG,+BAAY,CAChC,MAAA,gBAAgB,EAChB,MAAA,iBAAiB,EACjB,MAAA,iBAAiB,EACjB,MAAA,iBAAiB,EACjB,MAAA,eAAe,EACf,MAAA,mBAAmB,EACnB,MAAA,kBAAkB,EAClB,MAAA,kBAAkB,EAClB,MAAA,kBAAkB,EAClB,MAAA,iBAAiB,EACjB,MAAA,uBAAuB,EACvB,MAAA,4BAA4B,EAC5B,MAAA,yBAAyB,EACzB,MAAA,aAAa,EACb,MAAA,cAAc,CACjB,CAAC;AACN,CAAC,EAxOa,KAAK,GAAL,aAAK,KAAL,aAAK,QAwOlB","file":"Epics.js","sourcesContent":["import { ActionsObservable, combineEpics } from 'redux-observable';\r\nimport * as Rx from '@reactivex/rxjs';\r\nimport * as SN from 'sn-client-js';\r\nimport { Actions } from './Actions';\r\nimport { Reducers } from './Reducers';\r\n\r\nconst { ajax } = Rx.Observable;\r\n\r\n/**\r\n * Module for redux-observable Epics of the Sense/Net built-in OData actions.\r\n * \r\n * _An Epic is the core primitive of [redux-observable](https://redux-observable.js.org). It is a function which takes a stream of actions and returns a stream of actions._\r\n * \r\n * Learn more about redux-observable Epics [here](https://redux-observable.js.org/docs/basics/Epics.html);\r\n * \r\n * In Sense/Net's case it means that the action steps (for exmaple request, success, fail) or multiple actions can be combined into Epics. It's extremely useful if you have\r\n * to work with async action or you have a complex process with multiple steps that have to wait for each other like validation, multiple step saving, etc.\r\n * \r\n * Following epics cover the CRUD operations and all the other built-in Sense/Net OData Actions. All of these Epics are combined into one root Epic. If you want to use them in\r\n * your application without any customization you don't have to do anything special, because it is set as default at the store creation, but if you want add you custom Epics to it\r\n * use combineEpics on Sense/Nets root Epic and yours.\r\n * \r\n * ```\r\n * import { combineEpics } from 'redux-observable';\r\n * import { myCombinedEpics } from '../myApp/Epics';\r\n * import { myRootReducer } from '../myApp/Reducers';\r\n * import { rootEpic } from '../sn-redux/Epics';\r\n * \r\n * const myRootEpic = combinedEpics(\r\n * rootEpic,\r\n * myCombinedEpics\r\n * );\r\n * \r\n * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]);\r\n * ``` \r\n */\r\n\r\nexport module Epics {\r\n /**\r\n * Epic for fetching content from the Content Repository. It is related to three redux actions, returns the ```RequestContent``` action and sends the JSON response to the\r\n * ```ReceiveContent``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ReceiveContentFailure``` action.\r\n */\r\n export const fetchContentEpic = action$ => {\r\n return action$.ofType('FETCH_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n let params = `${action.filter}`;\r\n return SN.ODataApiActionObservables.FetchContent(action.path, params)\r\n .map((response) => Actions.ReceiveContent(response.response, params))\r\n .catch(error => Rx.Observable.of(Actions.ReceiveContentFailure(params, error)))\r\n }\r\n );\r\n }\r\n /**\r\n * Epic for creating a Content in the Content Repository. It is related to three redux actions, returns ```CreateContent``` action and sends the JSON response to the\r\n * ```CreateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CreateContentFailure``` action.\r\n */\r\n export const createContentEpic = action$ => {\r\n return action$.ofType('CREATE_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n let content = action.content;\r\n content['__ContentType'] = content.Type;\r\n return SN.ODataApiActionObservables.CreateContent(action.path, content)\r\n .map(Actions.CreateContentSuccess)\r\n .catch(error => Rx.Observable.of(Actions.CreateContentFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic for updating metadata of a Content in the Content Repository. It is related to three redux actions, returns ```UpdateContent``` action and sends the JSON response to the\r\n * ```UpdateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UpdateContentFailure``` action.\r\n */\r\n export const updateContentEpic = (action$, store) => {\r\n return action$.ofType('UPDATE_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n return SN.ODataApiActionObservables.PatchContent(action.id, action.fields)\r\n .map(Actions.UpdateContentSuccess)\r\n .catch(error => Rx.Observable.of(Actions.UpdateContentFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to delete a Content from the Content Repository. It is related to three redux actions, returns ```Delete``` action and sends the response to the\r\n * ```DeleteSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```DeleteFailure``` action.\r\n */\r\n export const deleteContentEpic = (action$, store) => {\r\n return action$.ofType('DELETE_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n return SN.ODataApiActionObservables.DeleteContent(action.id, action.permanently)\r\n .map((response) => {\r\n const state = store.getState();\r\n const ids = Reducers.getIds(state.collection);\r\n return Actions.DeleteSuccess(ids.indexOf(action.id), action.id);\r\n })\r\n .catch(error => Rx.Observable.of(Actions.DeleteFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to delete multiple Content from the Content Repository. It is related to three redux actions, returns ```DeleteBatch``` action and sends the response to the\r\n * ```DeleteBatchSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```DeleteBatchFailure``` action.\r\n */\r\n export const deleteBatchEpic = (action$, store) => {\r\n return action$.ofType('DELETE_BATCH_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'DeleteBatch', path: action.path, isAction: true, requiredParams: ['paths'] });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'paths': action.ids, 'permanently': action.permanently } })\r\n .map((response) => {\r\n const state = store.getState();\r\n const ids = Reducers.getIds(state.collection);\r\n let indexes = [];\r\n for (let i = 0; i < ids.length; i++) {\r\n if (action.ids.indexOf(ids[i]) > -1) {\r\n indexes.push(i);\r\n }\r\n }\r\n return Actions.DeleteBatchSuccess(indexes);\r\n })\r\n .catch(error => Rx.Observable.of(Actions.DeleteBatchFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to checkout a Content in the Content Repository. It is related to three redux actions, returns ```CheckOut``` action and sends the response to the\r\n * ```CheckOutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckOutFailure``` action.\r\n */\r\n export const checkoutContentEpic = (action$, store) => {\r\n return action$.ofType('CHECKOUT_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'CheckOut', id: action.id, isAction: true });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action)\r\n .map(Actions.CheckOutSuccess)\r\n .catch(error => Rx.Observable.of(Actions.CheckOutFailure(error)))\r\n })\r\n }\r\n\r\n /**\r\n * Epic to checkin a Content in the Content Repository. It is related to three redux actions, returns ```CheckIn``` action and sends the response to the\r\n * ```CheckInSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckInFailure``` action.\r\n */\r\n export const checkinContentEpic = (action$, store) => {\r\n return action$.ofType('CHECKIN_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'CheckIn', id: action.id, isAction: true, params: ['checkInComment'] });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'checkInComments': action.checkInComment } })\r\n .map(Actions.CheckInSuccess)\r\n .catch(error => Rx.Observable.of(Actions.CheckInFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to publish a Content in the Content Repository. It is related to three redux actions, returns ```Publish``` action and sends the response to the\r\n * ```PublishSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```PublishFailure``` action.\r\n */\r\n export const publishContentEpic = (action$, store) => {\r\n return action$.ofType('PUBLISH_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'Publish', id: action.id, isAction: true });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action)\r\n .map(Actions.PublishSuccess)\r\n .catch(error => Rx.Observable.of(Actions.PublishFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to approve a Content in the Content Repository. It is related to three redux actions, returns ```Approve``` action and sends the response to the\r\n * ```ApproveSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ApproveFailure``` action.\r\n */\r\n export const approveContentEpic = (action$, store) => {\r\n return action$.ofType('APPROVE_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'Approve', id: action.id, isAction: true });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action)\r\n .map(Actions.ApproveSuccess)\r\n .catch(error => Rx.Observable.of(Actions.ApproveFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to reject a Content in the Content Repository. It is related to three redux actions, returns ```Reject``` action and sends the response to the\r\n * ```RejectSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RejectFailure``` action.\r\n */\r\n export const rejectContentEpic = (action$, store) => {\r\n return action$.ofType('REJECT_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'Reject', id: action.id, isAction: true, params: ['rejectReason'] });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'rejectReason': action.rejectReason ? action.rejectReason : '' } })\r\n .map(Actions.RejectSuccess)\r\n .catch(error => Rx.Observable.of(Actions.RejectFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```UndoCheckout``` action and sends the response to the\r\n * ```UndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UndoCheckoutFailure``` action.\r\n */\r\n export const undocheckoutContentEpic = (action$, store) => {\r\n return action$.ofType('UNDOCHECKOUT_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'UndoCheckout', id: action.id, isAction: true });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action)\r\n .map(Actions.UndoCheckoutSuccess)\r\n .catch(error => Rx.Observable.of(Actions.UndoCheckoutFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to force undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```ForceUndoCheckout``` action and sends the response to the\r\n * ```ForceUndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ForceUndoCheckoutFailure``` action.\r\n */\r\n export const forceundocheckoutContentEpic = (action$, store) => {\r\n return action$.ofType('FORCEUNDOCHECKOUT_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'ForceUndoCheckout', id: action.id, isAction: true });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action)\r\n .map(Actions.ForceUndoCheckoutSuccess)\r\n .catch(error => Rx.Observable.of(Actions.ForceUndoCheckoutFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to restore a version of a Content in the Content Repository. It is related to three redux actions, returns ```RestoreVersion``` action and sends the response to the\r\n * ```RestoreVersionSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RestoreVersionFailure``` action.\r\n */\r\n export const restoreversionContentEpic = (action$, store) => {\r\n return action$.ofType('RESTOREVERSION_CONTENT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'RestoreVersion', id: action.id, isAction: true, params: ['version'] });\r\n return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'version': action.version } })\r\n .map(Actions.RestoreVersionSuccess)\r\n .catch(error => Rx.Observable.of(Actions.RestoreVersionFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to login a user to a Sense/Net portal. It is related to three redux actions, returns ```LoginUser``` action and sends the response to the\r\n * ```LoginUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LoginUserFailure``` action.\r\n */\r\n export const userLoginEpic = (action$, store) => {\r\n return action$.ofType('USER_LOGIN_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'Login', path: '/Root', isAction: true, requiredParams: ['username', 'password'], noCache: true });\r\n return SN.ODataApiActionObservables.Login(Action, { data: { 'username': action.userName, 'password': action.password } })\r\n .map(Actions.UserLoginSuccess)\r\n .catch(error => Rx.Observable.of(Actions.UserLoginFailure(error)))\r\n })\r\n }\r\n /**\r\n * Epic to logout a user from a Sense/Net portal. It is related to three redux actions, returns ```LogoutUser``` action and sends the response to the\r\n * ```LogoutUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LogoutUserFailure``` action.\r\n */\r\n export const userLogoutEpic = (action$, store) => {\r\n return action$.ofType('USER_LOGOUT_REQUEST')\r\n .mergeMap(action => {\r\n const Action = new SN.ODataApi.CustomAction({ name: 'Logout', path: '/Root', isAction: true, noCache: true });\r\n return SN.ODataApiActionObservables.Logout(Action, {})\r\n .map(Actions.UserLogoutSuccess)\r\n .catch(error => Rx.Observable.of(Actions.UserLogoutFailure(error)))\r\n })\r\n }\r\n /**\r\n * sn-redux root Epic, the main Epic combination that is used on a default Sense/Net application. Contains Epics related to CRUD operations and thr other built-in Sense/Net\r\n * [OData Actions and Function](http://wiki.sensenet.com/Built-in_OData_actions_and_functions).\r\n */\r\n export const rootEpic = combineEpics(\r\n fetchContentEpic,\r\n createContentEpic,\r\n updateContentEpic,\r\n deleteContentEpic,\r\n deleteBatchEpic,\r\n checkoutContentEpic,\r\n checkinContentEpic,\r\n publishContentEpic,\r\n approveContentEpic,\r\n rejectContentEpic,\r\n undocheckoutContentEpic,\r\n forceundocheckoutContentEpic,\r\n restoreversionContentEpic,\r\n userLoginEpic,\r\n userLogoutEpic\r\n );\r\n}"]} \ No newline at end of file diff --git a/dist/src/Reducers.js b/dist/src/Reducers.js deleted file mode 100644 index 7eba8bc..0000000 --- a/dist/src/Reducers.js +++ /dev/null @@ -1,142 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const redux_1 = require("redux"); -var Reducers; -(function (Reducers) { - Reducers.byId = (state = {}, action) => { - if (action.response && action.type !== 'USER_LOGIN_SUCCESS') { - return Object.assign({}, state, action.response.entities.collection); - } - switch (action.type) { - case 'DELETE_CONTENT_SUCCESS': - let res = Object.assign({}, state); - delete res[action.id]; - return res; - default: - return state; - } - }; - Reducers.ids = (state = [], action) => { - switch (action.type) { - case 'FETCH_CONTENT_SUCCESS': - return action.response.result; - case 'CREATE_CONTENT_SUCCESS': - return [...state, action.response.result]; - case 'DELETE_CONTENT_SUCCESS': - return [...state.slice(0, action.index), ...state.slice(action.index + 1)]; - default: - return state; - } - }; - Reducers.isFetching = (state = false, action) => { - switch (action.type) { - case 'FETCH_CONTENT_REQUEST': - return true; - case 'FETCH_CONTENT_SUCCESS': - case 'FETCH_CONTENT_FAILURE': - return false; - default: - return state; - } - }; - Reducers.errorMessage = (state = null, action) => { - switch (action.type) { - case 'FETCH_CONTENT_FAILURE': - case 'CREATE_CONTENT_FAILURE': - case 'UPDATE_CONTENT_FAILURE': - case 'DELETE_CONTENT_FAILURE': - case 'CHECKIN_CONTENT_FAILURE': - case 'CHECKOUT_CONTENT_FAILURE': - case 'PUBLISH_CONTENT_FAILURE': - case 'APPROVE_CONTENT_FAILURE': - case 'REJECT_CONTENT_FAILURE': - case 'UNDOCHECKOUT_CONTENT_FAILURE': - case 'FORCEUNDOCHECKOUT_CONTENT_FAILURE': - case 'RESTOREVERSION_CONTENT_FAILURE': - return action.message; - case 'FETCH_CONTENT_REQUEST': - case 'FETCH_CONTENT_SUCCESS': - case 'CREATE_CONTENT_REQUEST': - case 'CREATE_CONTENT_SUCCESS': - case 'UPDATE_CONTENT_REQUEST': - case 'UPDATE_CONTENT_SUCCESS': - case 'DELETE_CONTENT_REQUEST': - case 'DELETE_CONTENT_SUCCESS': - case 'CHECKIN_CONTENT_REQUEST': - case 'CHECKIN_CONTENT_SUCCESS': - case 'CHECKOUT_CONTENT_REQUEST': - case 'CHECKOUT_CONTENT_SUCCESS': - case 'APPROVE_CONTENT_REQUEST': - case 'APPROVE_CONTENT_SUCCESS': - case 'PUBLISH_CONTENT_REQUEST': - case 'PUBLISH_CONTENT_SUCCESS': - case 'REJECT_CONTENT_REQUEST': - case 'REJECT_CONTENT_SUCCESS': - case 'UNDOCHECKOUT_CONTENT_REQUEST': - case 'UNDOCHECKOUT_CONTENT_SUCCESS': - case 'FORCEUNDOCHECKOUT_CONTENT_REQUEST': - case 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS': - case 'RESTOREVERSION_CONTENT_REQUEST': - case 'RESTOREVERSION_CONTENT_SUCCESS': - return null; - default: - return state; - } - }; - const userInitialState = { - data: null, - isLoading: false, - isAuthenticated: false, - errorMessage: '' - }; - Reducers.user = (state = userInitialState, action) => { - switch (action.type) { - case 'USER_LOGIN_REQUEST': - case 'USER_LOGOUT_REQUEST': - return Object.assign({}, userInitialState, { isLoading: true, isAuthenticated: false }); - case 'USER_LOGIN_SUCCESS': - return { - data: { - userName: action.response.LoginName, - fullName: action.response.FullName - }, - isLoading: false, - isAuthenticated: true - }; - case 'USER_LOGOUT_SUCCESS': - return userInitialState; - case 'USER_LOGIN_FAILURE': - return Object.assign({}, userInitialState, { isLoading: false, errorMessage: action.message, isAuthenticated: false }); - case 'USER_LOGOUT_FAILURE': - return Object.assign({}, userInitialState, { isLoading: false, errorMessage: action.message, isAuthenticated: true }); - default: - return state; - } - }; - Reducers.collection = redux_1.combineReducers({ - byId: Reducers.byId, - ids: Reducers.ids, - isFetching: Reducers.isFetching, - errorMessage: Reducers.errorMessage, - user: Reducers.user - }); - Reducers.snApp = redux_1.combineReducers({ - collection: Reducers.collection - }); - Reducers.getContent = (state, Id) => state[Id]; - Reducers.getIds = (state) => state.ids; - Reducers.getFetching = (state) => state.isFetching; - Reducers.getError = (state) => { - return state.errorMessage; - }; - Reducers.getAuthenticationStatus = (state) => { - const user = state.user; - return user.isAuthenticated; - }; - Reducers.getAuthenticationError = (state) => { - const user = state.user; - return user.errorMessage; - }; -})(Reducers = exports.Reducers || (exports.Reducers = {})); - -//# sourceMappingURL=Reducers.js.map diff --git a/dist/src/Reducers.js.map b/dist/src/Reducers.js.map deleted file mode 100644 index 47675f7..0000000 --- a/dist/src/Reducers.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["src/Reducers.ts"],"names":[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IAAI,IAC3F;YACH;gBACE,MAAM,CAAC,KAAK,CAAA;QAChB,CAAC;IACH,CAAC,CAAA;IAKY,mBAAU,GAAG,uBAAe,CAAC;QACxC,IAAI,EAAJ,SAAA,IAAI;QACJ,GAAG,EAAH,SAAA,GAAG;QACH,UAAU,EAAV,SAAA,UAAU;QACV,YAAY,EAAZ,SAAA,YAAY;QACZ,IAAI,EAAJ,SAAA,IAAI;KACL,CAAC,CAAA;IAKW,cAAK,GAAG,uBAAe,CAAC;QACnC,UAAU,EAAV,SAAA,UAAU;KACX,CAAC,CAAA;IAOW,mBAAU,GAAG,CAAC,KAAa,EAAE,EAAU,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;IAMtD,eAAM,GAAG,CAAC,KAAU,KAAK,KAAK,CAAC,GAAG,CAAC;IAMnC,oBAAW,GAAG,CAAC,KAAU,KAAK,KAAK,CAAC,UAAU,CAAC;IAM/C,iBAAQ,GAAG,CAAC,KAAU;QAEjC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAA;IAC3B,CAAC,CAAC;IAEW,gCAAuB,GAAG,CAAC,KAAK;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC,CAAA;IAEY,+BAAsB,GAAG,CAAC,KAAK;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC,CAAA;AAEH,CAAC,EAlNa,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAkNrB","file":"Reducers.js","sourcesContent":["import { normalize } from 'normalizr';\r\nimport { combineReducers } from 'redux';\r\n\r\n/**\r\n * Module for defining Redux reducers.\r\n * \r\n * _Actions describe the fact that something happened, but don't specify how the application's state changes in response. This is the job of a reducer._\r\n * \r\n * Following module contains the reducers of sn-redux, some 'reducer groups' and the root reducer which could be passed to the store creator function. Using a root reduces means\r\n * that you define which combination of reducers will be used and eventually defines which type of actions can be called on the store.\r\n */\r\nexport module Reducers {\r\n\r\n /**\r\n * Reducer to handle Actions on the byId Object in the state, which is a dictionary with normalized nested JSON response. It becomes the current state and an action as arguments,\r\n * creates a new state based on the previous state and the action and returns it as the next state. If the Action doesn't affect the state the returned state will\r\n * be the current state itself.\r\n * @param {Object} [state={}] Represents the current state.\r\n * @param {Object} action Represents an action that is called.\r\n * @returns {Object} state. Returns the next state based on the action.\r\n */\r\n export const byId = (state = {}, action) => {\r\n if (action.response && action.type !== 'USER_LOGIN_SUCCESS') {\r\n return (Object).assign({}, state, action.response.entities.collection);\r\n }\r\n switch (action.type) {\r\n case 'DELETE_CONTENT_SUCCESS':\r\n let res = Object.assign({}, state);\r\n delete res[action.id];\r\n return res;\r\n default:\r\n return state;\r\n }\r\n }\r\n /**\r\n * Reducers to handle Actions on the ids Array in the state, which is the list Ids of the Content in the byId Object. It becomes the current state of the ids array and an action\r\n * creates a new array based on the current one and the action and returns it as the next state of the ids array. If the Action doesn't affect the state the returned state will\r\n * be the current state itself.\r\n * @param {number[]} state Represents the current state.\r\n * @param {Object} action Represents the action that is called.\r\n * @returns {number[]} state. Returns the next state based on the action.\r\n */\r\n export const ids = (state = [], action) => {\r\n switch (action.type) {\r\n case 'FETCH_CONTENT_SUCCESS':\r\n return action.response.result;\r\n case 'CREATE_CONTENT_SUCCESS':\r\n return [...state, action.response.result];\r\n case 'DELETE_CONTENT_SUCCESS':\r\n return [...state.slice(0, action.index), ...state.slice(action.index + 1)]\r\n default:\r\n return state;\r\n }\r\n }\r\n /**\r\n * Reducers to set in the state if the data is fetching or not. If the Action doesn't affect the state the returned state will be the current state itself.\r\n * @param {boolean} [state=false] Represents the current state.\r\n * @param {Object} action Represents the action that is called.\r\n * @returns {boolean} state. Returns the next state based on the action.\r\n */\r\n export const isFetching = (state = false, action) => {\r\n switch (action.type) {\r\n case 'FETCH_CONTENT_REQUEST':\r\n return true;\r\n case 'FETCH_CONTENT_SUCCESS':\r\n case 'FETCH_CONTENT_FAILURE':\r\n return false;\r\n default:\r\n return state;\r\n }\r\n }\r\n /**\r\n * Reducers to set the errormessage in the state if a process is failed. If the Action doesn't affect the state the returned state will be the current state itself.\r\n * @param {any} [state=null] Represents the current state.\r\n * @param {any} action Represents the action that is called.\r\n * @returns {string} state. Returns the next state based on the action.\r\n */\r\n export const errorMessage = (state: any = null, action: any) => {\r\n switch (action.type) {\r\n case 'FETCH_CONTENT_FAILURE':\r\n case 'CREATE_CONTENT_FAILURE':\r\n case 'UPDATE_CONTENT_FAILURE':\r\n case 'DELETE_CONTENT_FAILURE':\r\n case 'CHECKIN_CONTENT_FAILURE':\r\n case 'CHECKOUT_CONTENT_FAILURE':\r\n case 'PUBLISH_CONTENT_FAILURE':\r\n case 'APPROVE_CONTENT_FAILURE':\r\n case 'REJECT_CONTENT_FAILURE':\r\n case 'UNDOCHECKOUT_CONTENT_FAILURE':\r\n case 'FORCEUNDOCHECKOUT_CONTENT_FAILURE':\r\n case 'RESTOREVERSION_CONTENT_FAILURE':\r\n return action.message;\r\n case 'FETCH_CONTENT_REQUEST':\r\n case 'FETCH_CONTENT_SUCCESS':\r\n case 'CREATE_CONTENT_REQUEST':\r\n case 'CREATE_CONTENT_SUCCESS':\r\n case 'UPDATE_CONTENT_REQUEST':\r\n case 'UPDATE_CONTENT_SUCCESS':\r\n case 'DELETE_CONTENT_REQUEST':\r\n case 'DELETE_CONTENT_SUCCESS':\r\n case 'CHECKIN_CONTENT_REQUEST':\r\n case 'CHECKIN_CONTENT_SUCCESS':\r\n case 'CHECKOUT_CONTENT_REQUEST':\r\n case 'CHECKOUT_CONTENT_SUCCESS':\r\n case 'APPROVE_CONTENT_REQUEST':\r\n case 'APPROVE_CONTENT_SUCCESS':\r\n case 'PUBLISH_CONTENT_REQUEST':\r\n case 'PUBLISH_CONTENT_SUCCESS':\r\n case 'REJECT_CONTENT_REQUEST':\r\n case 'REJECT_CONTENT_SUCCESS':\r\n case 'UNDOCHECKOUT_CONTENT_REQUEST':\r\n case 'UNDOCHECKOUT_CONTENT_SUCCESS':\r\n case 'FORCEUNDOCHECKOUT_CONTENT_REQUEST':\r\n case 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS':\r\n case 'RESTOREVERSION_CONTENT_REQUEST':\r\n case 'RESTOREVERSION_CONTENT_SUCCESS':\r\n return null;\r\n default:\r\n return state;\r\n }\r\n }\r\n\r\n const userInitialState = {\r\n data: null,\r\n isLoading: false,\r\n isAuthenticated: false,\r\n errorMessage: ''\r\n }\r\n /**\r\n * Reducer to handle Actions on the user Object in the state. It becomes the current state and an action as arguments,\r\n * creates a new state based on the previous state and the action and returns it as the next state. If the Action doesn't affect the state the returned state will\r\n * be the current state itself.\r\n * @param {Object} [state={}] Represents the current state.\r\n * @param {Object} action Represents an action that is called.\r\n * @returns {Object} state. Returns the next state based on the action.\r\n */\r\n export const user = (state = userInitialState, action) => {\r\n switch (action.type) {\r\n case 'USER_LOGIN_REQUEST':\r\n case 'USER_LOGOUT_REQUEST':\r\n return { ...userInitialState, isLoading: true, isAuthenticated: false }\r\n case 'USER_LOGIN_SUCCESS':\r\n return {\r\n data: {\r\n userName: action.response.LoginName,\r\n fullName: action.response.FullName\r\n },\r\n isLoading: false,\r\n isAuthenticated: true\r\n }\r\n case 'USER_LOGOUT_SUCCESS':\r\n return userInitialState\r\n case 'USER_LOGIN_FAILURE':\r\n return {\r\n ...userInitialState, isLoading: false, errorMessage: action.message, isAuthenticated: false\r\n }\r\n case 'USER_LOGOUT_FAILURE':\r\n return {\r\n ...userInitialState, isLoading: false, errorMessage: action.message, isAuthenticated: true\r\n }\r\n default:\r\n return state\r\n }\r\n }\r\n\r\n /**\r\n * Reducer combining ```byId``` object, ```ids``` array, isFetching and errorMessage into a single object which means ```collection``` will be a top object in the state.\r\n */\r\n export const collection = combineReducers({\r\n byId,\r\n ids,\r\n isFetching,\r\n errorMessage,\r\n user\r\n })\r\n /**\r\n * Reducer to hold the collection object and represent a root reducer of a SenseNet Redux application store. If you want to add your custom Reducers to the store, create your own\r\n * root Reducer combining ```collection``` and your top Reducer.\r\n */\r\n export const snApp = combineReducers({\r\n collection\r\n })\r\n /**\r\n * Method to get a Content item from a state object by its Id.\r\n * @param {Object} state Current state object.\r\n * @param {number} Id Id of the Content.\r\n * @returns {Object} content. Returns the Content from a state object with the given Id.\r\n */\r\n export const getContent = (state: Object, Id: number) => state[Id];\r\n /**\r\n * Method to get the ```ids``` array from a state object.\r\n * @param {Object} state Current state object.\r\n * @returns {number[]} content. Returns the ```ids``` array from the given state.\r\n */\r\n export const getIds = (state: any) => state.ids;\r\n /**\r\n * Method to get if the fetching of data is in progress.\r\n * @param {Object} state Current state object.\r\n * @returns {boolean} Returns true or false whether data fetching is in progress or not.\r\n */\r\n export const getFetching = (state: any) => state.isFetching;\r\n /**\r\n * Method to get the error message.\r\n * @param {Object} state Current state object.\r\n * @returns {string} Returns the error message.\r\n */\r\n export const getError = (state: any) => {\r\n\r\n return state.errorMessage\r\n };\r\n\r\n export const getAuthenticationStatus = (state) => {\r\n const user = state.user;\r\n return user.isAuthenticated;\r\n }\r\n\r\n export const getAuthenticationError = (state) => {\r\n const user = state.user;\r\n return user.errorMessage;\r\n }\r\n\r\n}"]} \ No newline at end of file diff --git a/dist/src/Schema.js b/dist/src/Schema.js deleted file mode 100644 index dc7ef27..0000000 --- a/dist/src/Schema.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const normalizr_1 = require("normalizr"); -var Schemas; -(function (Schemas) { - Schemas.content = new normalizr_1.schema.Entity('collection', {}, { idAttribute: 'Id' }); - Schemas.arrayOfContent = new normalizr_1.schema.Array(Schemas.content); -})(Schemas = exports.Schemas || (exports.Schemas = {})); - -//# sourceMappingURL=Schema.js.map diff --git a/dist/src/Schema.js.map b/dist/src/Schema.js.map deleted file mode 100644 index 08b9950..0000000 --- a/dist/src/Schema.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["src/Schema.ts"],"names":[],"mappings":";;AAAA,yCAAmC;AAwCnC,IAAc,OAAO,CAapB;AAbD,WAAc,OAAO;IAMJ,eAAO,GAAG,IAAI,kBAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAMrE,sBAAc,GAAG,IAAI,kBAAM,CAAC,KAAK,CAAC,QAAA,OAAO,CAAC,CAAC;AAC5D,CAAC,EAba,OAAO,GAAP,eAAO,KAAP,eAAO,QAapB","file":"Schema.js","sourcesContent":["import { schema } from 'normalizr';\r\n\r\n/** \r\n * This module is for defining Content and Collection schemas to normalize nested JSON response data in redux state store.\r\n * \r\n * Normalizr takes JSON and a schema and replaces nested entities with their IDs, gathering all entities in dictionaries.\r\n ** Entities can be nested inside other entities, objects and arrays;\r\n ** Combine entity schemas to express any kind of API response;\r\n ** Entities with same IDs are automatically merged (with a warning if they differ);\r\n ** Allows using a custom ID attribute (e.g. slug).\r\n *\r\n * Read more about normalizr [here](https://github.com/paularmstrong/normalizr)\r\n * \r\n * Since everything is a Content in SenseNet we're working with Content and collection of Content in most of the cases. So the sn-redux Schemas module defines the two\r\n * neccessarry main schema, content and arrayofContent to work with. This two schemas help you to normalize your JSON responses so that you can create a pure and flexible \r\n * client-side datasource.\r\n * \r\n * Example of normalizing the JSON response of a SenseNet OData Action for fetching Content as arrayOfContent schema which will create a collection object.\r\n * ```ts\r\n * export const receiveContent = (response: any, filter: string) =>\r\n * ({\r\n * type: 'FETCH_CONTENT_SUCCESS',\r\n * response: normalize(response.d.results, Schemas.arrayOfContent),\r\n * filter\r\n * })\r\n * ```\r\n * \r\n * ![Normalized collection](http://download.sensenet.com/aniko/sn7/jsapidocs/img/normalized-collection.png)\r\n * \r\n * Example of normalizing the JSON response of a SenseNet OData Action for creating Content as content schema.\r\n * ```ts\r\n * export const createContentSuccess = (response: any) =>\r\n * ({\r\n * type: 'CREATE_CONTENT_SUCCESS',\r\n * response: normalize(response.response.d, Schemas.content)\r\n * });\r\n * ```\r\n * \r\n * ![Normalized content](http://download.sensenet.com/aniko/sn7/jsapidocs/img/normalized-content.png)\r\n*/\r\nexport module Schemas{\r\n /**\r\n * Schema of a Content. \r\n * \r\n * It represents an item in the collection Object of the sn-redux store. The items are identified by the attribute 'Id'.\r\n */\r\n export const content = new schema.Entity('collection', {}, { idAttribute: 'Id' });\r\n /**\r\n * Schema of a Collection.\r\n * \r\n * It represents the top object of the sn-redux store. It's a parent element of the Content items so it is defined as array of items with the schema content.\r\n */\r\n export const arrayOfContent = new schema.Array(content);\r\n}"]} \ No newline at end of file diff --git a/dist/src/Store.js b/dist/src/Store.js deleted file mode 100644 index b706fe6..0000000 --- a/dist/src/Store.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const redux_1 = require("redux"); -const createLogger = require("redux-logger"); -const redux_observable_1 = require("redux-observable"); -const Epics_1 = require("./Epics"); -const Reducers_1 = require("./Reducers"); -var Store; -(function (Store) { - Store.configureStore = (rootReducer = Reducers_1.Reducers.snApp, rootEpic, middlewares, persistedState) => { - let epicMiddleware; - if (typeof rootEpic === 'undefined' || rootEpic === null) { - epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.rootEpic); - } - else { - epicMiddleware = redux_observable_1.createEpicMiddleware(rootEpic); - } - let middlewareArray = []; - if (typeof middlewares === 'undefined' || middlewares === null) { - middlewareArray.push(epicMiddleware); - } - else { - middlewareArray = [...middlewares, epicMiddleware]; - } - const loggerMiddleware = createLogger(); - middlewareArray.push(loggerMiddleware); - if (typeof persistedState !== 'undefined') { - return redux_1.createStore(rootReducer, persistedState, redux_1.applyMiddleware(...middlewareArray)); - } - else { - return redux_1.createStore(rootReducer, redux_1.applyMiddleware(...middlewareArray)); - } - }; -})(Store = exports.Store || (exports.Store = {})); - -//# sourceMappingURL=Store.js.map diff --git a/dist/src/Store.js.map b/dist/src/Store.js.map de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,eAAe,CAAC,CACtC,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC,EAtDa,KAAK,GAAL,aAAK,KAAL,aAAK,QAsDlB","file":"Store.js","sourcesContent":["import { createStore, applyMiddleware } from 'redux';\r\nimport * as createLogger from 'redux-logger'\r\nimport { createEpicMiddleware } from 'redux-observable';\r\nimport { Epics } from './Epics';\r\nimport { Reducers } from './Reducers';\r\n\r\n/**\r\n * Module for configuring a store.\r\n * \r\n * It is actually a redux based data store, that lets you keep your application data in on place, allows you to access (get and update) the application state or subscribe to its listeners.\r\n * \r\n * Two middlewares are built-in:\r\n * * [redux-observable](https://redux-observable.js.org/) is as RxJS 5-based middleware for Redux. It's needed to compose and cancel async actions to create side effects and more, \r\n * so that your app are able to get or post data to Sense/Net Content Repository through OData with ajax requests.\r\n * * [redux-logger](https://github.com/evgenyrodionov/redux-logger) creates a detailed log on the dev toolbar console on all state changes.\r\n * You can add other middlewares too through the configureStore functions second param as an array of middlewares. But the built-in middlewares will be the part of the applied middleware group\r\n * in every way.\r\n * \r\n * ```\r\n * import * as React from \"react\";\r\n * import * as ReactDOM from \"react-dom\";\r\n * import Authentication from 'redux-authentication'\r\n * import { myRootReducer } from '../myApp/Reducers'\r\n * import { myRootEpic } from '../myApp/Epics'\r\n * \r\n * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]);\r\n * \r\n * ReactDOM.render(\r\n * ,\r\n * document.getElementById(\"root\")\r\n * );\r\n * ```\r\n */\r\nexport module Store {\r\n /**\r\n * Method to create a Redux store that holds the application state.\r\n * @param {any} [rootReducer=Reducers.snApp] Root reducer of your application.\r\n * @param {any} [rootEpic=Epics.rootEpic] Root epic of your application.\r\n * @param {Array=} middlewares Array of middlewares.\r\n * @param {Object=} persistedState Persisted state.\r\n * @returns {Store} Returns a Redux store, an object that holds the application state.\r\n * ```\r\n * import * as React from \"react\";\r\n * import * as ReactDOM from \"react-dom\";\r\n * import Authentication from 'redux-authentication'\r\n * import { myRootReducer } from '../myApp/Reducers'\r\n * import { myRootEpic } from '../myApp/Epics'\r\n * \r\n * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]);\r\n * \r\n * ReactDOM.render(\r\n * ,\r\n * document.getElementById(\"root\")\r\n * );\r\n * ```\r\n */\r\n export const configureStore = (rootReducer: any = Reducers.snApp, rootEpic?: any, middlewares?: Array, persistedState?: Object) => {\r\n let epicMiddleware;\r\n if (typeof rootEpic === 'undefined' || rootEpic === null) {\r\n epicMiddleware = createEpicMiddleware(Epics.rootEpic);\r\n }\r\n else {\r\n epicMiddleware = createEpicMiddleware(rootEpic);\r\n }\r\n let middlewareArray = [];\r\n if (typeof middlewares === 'undefined' || middlewares === null) {\r\n middlewareArray.push(epicMiddleware);\r\n }\r\n else {\r\n middlewareArray = [...middlewares, epicMiddleware];\r\n }\r\n const loggerMiddleware = (createLogger as any)();\r\n middlewareArray.push(loggerMiddleware);\r\n if (typeof persistedState !== 'undefined') {\r\n return createStore(\r\n rootReducer,\r\n persistedState,\r\n applyMiddleware(...middlewareArray)\r\n );\r\n }\r\n else {\r\n return createStore(\r\n rootReducer,\r\n applyMiddleware(...middlewareArray)\r\n );\r\n }\r\n };\r\n}"]} \ No newline at end of file diff --git a/dist/src/sn-redux.js b/dist/src/sn-redux.js deleted file mode 100644 index c0f5a12..0000000 --- a/dist/src/sn-redux.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("./Actions"); -require("./Epics"); -require("./Reducers"); -require("./Schema"); -require("./Store"); -var Actions_1 = require("./Actions"); -exports.Actions = Actions_1.Actions; -var Epics_1 = require("./Epics"); -exports.Epics = Epics_1.Epics; -var Reducers_1 = require("./Reducers"); -exports.Reducers = Reducers_1.Reducers; -var Schema_1 = require("./Schema"); -exports.Schemas = Schema_1.Schemas; -var Store_1 = require("./Store"); -exports.Store = Store_1.Store; - -//# sourceMappingURL=sn-redux.js.map diff --git a/dist/src/sn-redux.js.map b/dist/src/sn-redux.js.map deleted file mode 100644 index b1aca5d..0000000 --- a/dist/src/sn-redux.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["src/sn-redux.ts"],"names":[],"mappings":";;AAAA,qBAAmB;AACnB,mBAAiB;AACjB,sBAAoB;AACpB,oBAAkB;AAClB,mBAAiB;AAEjB,qCAAoC;AAA3B,4BAAA,OAAO,CAAA;AAChB,iCAAgC;AAAvB,wBAAA,KAAK,CAAA;AACd,uCAAsC;AAA7B,8BAAA,QAAQ,CAAA;AACjB,mCAAmC;AAA1B,2BAAA,OAAO,CAAA;AAChB,iCAAgC;AAAvB,wBAAA,KAAK,CAAA","file":"sn-redux.js","sourcesContent":["import './Actions';\r\nimport './Epics';\r\nimport './Reducers';\r\nimport './Schema';\r\nimport './Store';\r\n\r\nexport { Actions } from './Actions';\r\nexport { Epics } from './Epics';\r\nexport { Reducers } from './Reducers';\r\nexport { Schemas } from './Schema';\r\nexport { Store } from './Store';"]} \ No newline at end of file diff --git a/dist/test/ActionsTests.js b/dist/test/ActionsTests.js deleted file mode 100644 index 220031a..0000000 --- a/dist/test/ActionsTests.js +++ /dev/null @@ -1,478 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const SN = require("sn-client-js"); -const Actions_1 = require("../src/Actions"); -const Chai = require("chai"); -const expect = Chai.expect; -describe('Actions', () => { - const path = '/workspaces/project'; - describe('FetchContent', () => { - it('should create an action to a fetch content request', () => { - const expectedAction = { - type: 'FETCH_CONTENT_REQUEST', - path: '/workspaces/project', - filter: "?$select=Id,Type&metadata=no" - }; - expect(Actions_1.Actions.RequestContent(path, {})).to.deep.equal(expectedAction); - }); - it('should create an action to receive content', () => { - const expectedAction = { - type: 'FETCH_CONTENT_SUCCESS', - response: { entities: {}, result: [] }, - filter: "?$select=Id,Type&metadata=no" - }; - expect(Actions_1.Actions.ReceiveContent({ d: { results: [] } }, '?$select=Id,Type&metadata=no')).to.deep.equal(expectedAction); - }); - it('should create an action to content fetch request failure', () => { - const expectedAction = { - type: 'FETCH_CONTENT_FAILURE', - message: 'error', - filter: "?$select=Id,Type&metadata=no" - }; - expect(Actions_1.Actions.ReceiveContentFailure('?$select=Id,Type&metadata=no', { message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('CreateContent', () => { - const content = SN.Content.Create('Article', { DisplayName: 'My content', Id: 123 }); - it('should create an action to a create content request', () => { - const expectedAction = { - type: 'CREATE_CONTENT_REQUEST', - path: '/workspaces/project', - content: content - }; - expect(Actions_1.Actions.CreateContent(path, content)).to.deep.equal(expectedAction); - }); - it('should create an action to create content success', () => { - const expectedAction = { - type: 'CREATE_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: 'My content', - Id: 123 - } - } - }, - result: 123 - } - }; - expect(Actions_1.Actions.CreateContentSuccess({ response: { d: { DisplayName: 'My content', Id: 123 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to content creation failure', () => { - const expectedAction = { - type: 'CREATE_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.CreateContentFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('UpdateContent', () => { - it('should create an action to an update content request', () => { - const expectedAction = { - type: 'UPDATE_CONTENT_REQUEST', - id: 123, - fields: { Index: 2 } - }; - expect(Actions_1.Actions.UpdateContent(123, { Index: 2 })).to.deep.equal(expectedAction); - }); - it('should create an action to update content success', () => { - const expectedAction = { - type: 'UPDATE_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.UpdateContentSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to content update request failure', () => { - const expectedAction = { - type: 'UPDATE_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.UpdateContentFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('DeleteContent', () => { - it('should create an action to a delete content request', () => { - const expectedAction = { - type: 'DELETE_CONTENT_REQUEST', - id: 123, - permanently: false - }; - expect(Actions_1.Actions.Delete(123, false)).to.deep.equal(expectedAction); - }); - it('should create an action to delete content success', () => { - const expectedAction = { - type: 'DELETE_CONTENT_SUCCESS', - id: 123, - index: 0 - }; - expect(Actions_1.Actions.DeleteSuccess(0, 123)).to.deep.equal(expectedAction); - }); - it('should create an action to delete content failure', () => { - const expectedAction = { - type: 'DELETE_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.DeleteFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('DeleteBatchContent', () => { - it('should create an action to a delete content request', () => { - const expectedAction = { - type: 'DELETE_BATCH_REQUEST', - path: path, - ids: ['1', '2', '3'], - permanently: false - }; - expect(Actions_1.Actions.DeleteBatch(path, ['1', '2', '3'], false)).to.deep.equal(expectedAction); - }); - it('should create an action to delete content success', () => { - const expectedAction = { - type: 'DELETE_BATCH_SUCCESS', - indexes: [0, 1, 2] - }; - expect(Actions_1.Actions.DeleteBatchSuccess([0, 1, 2])).to.deep.equal(expectedAction); - }); - it('should create an action to delete content failure', () => { - const expectedAction = { - type: 'DELETE_BATCH_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.DeleteBatchFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('CheckoutContent', () => { - it('should create an action to a checkout content request', () => { - const expectedAction = { - type: 'CHECKOUT_CONTENT_REQUEST', - id: 123 - }; - expect(Actions_1.Actions.CheckOut(123)).to.deep.equal(expectedAction); - }); - it('should create an action to checkout content success', () => { - const expectedAction = { - type: 'CHECKOUT_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.CheckOutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to checkout content failure', () => { - const expectedAction = { - type: 'CHECKOUT_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.CheckOutFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('CheckinContent', () => { - it('should create an action to a checkin content request', () => { - const expectedAction = { - type: 'CHECKIN_CONTENT_REQUEST', - id: 123, - checkInComment: 'comment' - }; - expect(Actions_1.Actions.CheckIn(123, 'comment')).to.deep.equal(expectedAction); - }); - it('should create an action to checkin content success', () => { - const expectedAction = { - type: 'CHECKIN_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.CheckInSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to checkin content failure', () => { - const expectedAction = { - type: 'CHECKIN_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.CheckInFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('PublishContent', () => { - it('should create an action to a publish content request', () => { - const expectedAction = { - type: 'PUBLISH_CONTENT_REQUEST', - id: 123 - }; - expect(Actions_1.Actions.Publish(123)).to.deep.equal(expectedAction); - }); - it('should create an action to publish content success', () => { - const expectedAction = { - type: 'PUBLISH_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.PublishSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to publish content failure', () => { - const expectedAction = { - type: 'PUBLISH_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.PublishFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('ApproveContent', () => { - it('should create an action to an approve content request', () => { - const expectedAction = { - type: 'APPROVE_CONTENT_REQUEST', - id: 123 - }; - expect(Actions_1.Actions.Approve(123)).to.deep.equal(expectedAction); - }); - it('should create an action to approve content success', () => { - const expectedAction = { - type: 'APPROVE_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.ApproveSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to approve content failure', () => { - const expectedAction = { - type: 'APPROVE_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.ApproveFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('RejectContent', () => { - it('should create an action to an reject content request', () => { - const expectedAction = { - type: 'REJECT_CONTENT_REQUEST', - id: 123, - rejectReason: 'reason' - }; - expect(Actions_1.Actions.Reject(123, 'reason')).to.deep.equal(expectedAction); - }); - it('should create an action to reject content success', () => { - const expectedAction = { - type: 'REJECT_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.RejectSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to reject content failure', () => { - const expectedAction = { - type: 'REJECT_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.RejectFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('UndoCheckoutContent', () => { - it('should create an action to an undo-checkout content request', () => { - const expectedAction = { - type: 'UNDOCHECKOUT_CONTENT_REQUEST', - id: 123 - }; - expect(Actions_1.Actions.UndoCheckout(123)).to.deep.equal(expectedAction); - }); - it('should create an action to undo-checkout content success', () => { - const expectedAction = { - type: 'UNDOCHECKOUT_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.UndoCheckoutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to undo-checkout content failure', () => { - const expectedAction = { - type: 'UNDOCHECKOUT_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.UndoCheckoutFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('ForceUndoCheckoutContent', () => { - it('should create an action to a force undo-checkout content request', () => { - const expectedAction = { - type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', - id: 123 - }; - expect(Actions_1.Actions.ForceUndoCheckout(123)).to.deep.equal(expectedAction); - }); - it('should create an action to force undo-checkout content success', () => { - const expectedAction = { - type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.ForceUndoCheckoutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to force undo-checkout content failure', () => { - const expectedAction = { - type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.ForceUndoCheckoutFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('RestoreVersion', () => { - it('should create an action to a version restore request', () => { - const expectedAction = { - type: 'RESTOREVERSION_CONTENT_REQUEST', - id: 123, - version: 'A.1.0' - }; - expect(Actions_1.Actions.RestoreVersion(123, 'A.1.0')).to.deep.equal(expectedAction); - }); - it('should create an action to a version restore success', () => { - const expectedAction = { - type: 'RESTOREVERSION_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: "My content", - Id: 123, - Index: 2 - } - } - }, result: 123 - } - }; - expect(Actions_1.Actions.RestoreVersionSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction); - }); - it('should create an action to a version restore failure', () => { - const expectedAction = { - type: 'RESTOREVERSION_CONTENT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.RestoreVersionFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); - describe('UserLogin', () => { - it('should create an action to a user login request', () => { - const expectedAction = { - type: 'USER_LOGIN_REQUEST', - userName: 'alba', - password: 'alba' - }; - expect(Actions_1.Actions.UserLogin('alba', 'alba')).to.deep.equal(expectedAction); - }); - it('should create an action to a user login success', () => { - const expectedAction = { - type: 'USER_LOGIN_SUCCESS', - response: { - Name: 'alba', - DisplayName: 'Alba Monday' - } - }; - expect(Actions_1.Actions.UserLoginSuccess({ response: { d: { Name: 'alba', DisplayName: 'Alba Monday' } } })).to.deep.equal(expectedAction); - }); - it('should create an action to a user login failure', () => { - const expectedAction = { - type: 'USER_LOGIN_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.UserLoginFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - it('should create an action to a user login failure with the proper message when 403', () => { - const expectedAction = { - type: 'USER_LOGIN_FAILURE', - message: 'The username or the password is not valid!' - }; - expect(Actions_1.Actions.UserLoginFailure({ message: 'The username or the password is not valid!', status: 403 })).to.deep.equal(expectedAction); - }); - }); - describe('UserLogout', () => { - it('should create an action to a user logout request', () => { - const expectedAction = { - type: 'USER_LOGOUT_REQUEST' - }; - expect(Actions_1.Actions.UserLogout()).to.deep.equal(expectedAction); - }); - it('should create an action to a user logout success', () => { - const expectedAction = { - type: 'USER_LOGOUT_SUCCESS' - }; - expect(Actions_1.Actions.UserLogoutSuccess({})).to.deep.equal(expectedAction); - }); - it('should create an action to a user logout failure', () => { - const expectedAction = { - type: 'USER_LOGOUT_FAILURE', - message: 'error' - }; - expect(Actions_1.Actions.UserLogoutFailure({ message: 'error' })).to.deep.equal(expectedAction); - }); - }); -}); - -//# sourceMappingURL=ActionsTests.js.map diff --git a/dist/test/ActionsTests.js.map b/dist/test/ActionsTests.js.map deleted file mode 100644 index 643891f..0000000 --- a/dist/test/ActionsTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["test/ActionsTests.ts"],"names":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AAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACvE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,kDAAkD,EAAE;YACnD,MAAM,cAAc,GAAG;gBACnB,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EAAE,OAAO;aACnB,CAAA;YACD,MAAM,CAAC,iBAAO,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACzF,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","file":"ActionsTests.js","sourcesContent":["///\r\nimport * as SN from 'sn-client-js';\r\nimport { Actions } from '../src/Actions'\r\nimport * as Chai from 'chai';\r\nconst expect = Chai.expect;\r\n\r\ndescribe('Actions', () => {\r\n const path = '/workspaces/project';\r\n describe('FetchContent', () => {\r\n it('should create an action to a fetch content request', () => {\r\n const expectedAction = {\r\n type: 'FETCH_CONTENT_REQUEST',\r\n path: '/workspaces/project',\r\n filter: \"?$select=Id,Type&metadata=no\"\r\n }\r\n expect(Actions.RequestContent(path, {})).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to receive content', () => {\r\n const expectedAction = {\r\n type: 'FETCH_CONTENT_SUCCESS',\r\n response: { entities: {}, result: [] },\r\n filter: \"?$select=Id,Type&metadata=no\"\r\n }\r\n expect(Actions.ReceiveContent({ d: { results: [] } }, '?$select=Id,Type&metadata=no')).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to content fetch request failure', () => {\r\n const expectedAction = {\r\n type: 'FETCH_CONTENT_FAILURE',\r\n message: 'error',\r\n filter: \"?$select=Id,Type&metadata=no\"\r\n }\r\n expect(Actions.ReceiveContentFailure('?$select=Id,Type&metadata=no', { message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('CreateContent', () => {\r\n const content = SN.Content.Create('Article', { DisplayName: 'My content', Id: 123 })\r\n it('should create an action to a create content request', () => {\r\n const expectedAction = {\r\n type: 'CREATE_CONTENT_REQUEST',\r\n path: '/workspaces/project',\r\n content: content\r\n }\r\n expect(Actions.CreateContent(path, content)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to create content success', () => {\r\n const expectedAction = {\r\n type: 'CREATE_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: 'My content',\r\n Id: 123\r\n }\r\n }\r\n },\r\n result: 123\r\n }\r\n }\r\n expect(Actions.CreateContentSuccess({ response: { d: { DisplayName: 'My content', Id: 123 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to content creation failure', () => {\r\n const expectedAction = {\r\n type: 'CREATE_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.CreateContentFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('UpdateContent', () => {\r\n it('should create an action to an update content request', () => {\r\n const expectedAction = {\r\n type: 'UPDATE_CONTENT_REQUEST',\r\n id: 123,\r\n fields: { Index: 2 }\r\n }\r\n expect(Actions.UpdateContent(123, { Index: 2 })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to update content success', () => {\r\n const expectedAction = {\r\n type: 'UPDATE_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.UpdateContentSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to content update request failure', () => {\r\n const expectedAction = {\r\n type: 'UPDATE_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.UpdateContentFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('DeleteContent', () => {\r\n it('should create an action to a delete content request', () => {\r\n const expectedAction = {\r\n type: 'DELETE_CONTENT_REQUEST',\r\n id: 123,\r\n permanently: false\r\n }\r\n expect(Actions.Delete(123, false)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to delete content success', () => {\r\n const expectedAction = {\r\n type: 'DELETE_CONTENT_SUCCESS',\r\n id: 123,\r\n index: 0\r\n }\r\n expect(Actions.DeleteSuccess(0, 123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to delete content failure', () => {\r\n const expectedAction = {\r\n type: 'DELETE_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.DeleteFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('DeleteBatchContent', () => {\r\n it('should create an action to a delete content request', () => {\r\n const expectedAction = {\r\n type: 'DELETE_BATCH_REQUEST',\r\n path: path,\r\n ids: ['1', '2', '3'],\r\n permanently: false\r\n }\r\n expect(Actions.DeleteBatch(path, ['1', '2', '3'], false)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to delete content success', () => {\r\n const expectedAction = {\r\n type: 'DELETE_BATCH_SUCCESS',\r\n indexes: [0, 1, 2]\r\n }\r\n expect(Actions.DeleteBatchSuccess([0, 1, 2])).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to delete content failure', () => {\r\n const expectedAction = {\r\n type: 'DELETE_BATCH_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.DeleteBatchFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('CheckoutContent', () => {\r\n it('should create an action to a checkout content request', () => {\r\n const expectedAction = {\r\n type: 'CHECKOUT_CONTENT_REQUEST',\r\n id: 123\r\n }\r\n expect(Actions.CheckOut(123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to checkout content success', () => {\r\n const expectedAction = {\r\n type: 'CHECKOUT_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.CheckOutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to checkout content failure', () => {\r\n const expectedAction = {\r\n type: 'CHECKOUT_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.CheckOutFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('CheckinContent', () => {\r\n it('should create an action to a checkin content request', () => {\r\n const expectedAction = {\r\n type: 'CHECKIN_CONTENT_REQUEST',\r\n id: 123,\r\n checkInComment: 'comment'\r\n }\r\n expect(Actions.CheckIn(123, 'comment')).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to checkin content success', () => {\r\n const expectedAction = {\r\n type: 'CHECKIN_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.CheckInSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to checkin content failure', () => {\r\n const expectedAction = {\r\n type: 'CHECKIN_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.CheckInFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('PublishContent', () => {\r\n it('should create an action to a publish content request', () => {\r\n const expectedAction = {\r\n type: 'PUBLISH_CONTENT_REQUEST',\r\n id: 123\r\n }\r\n expect(Actions.Publish(123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to publish content success', () => {\r\n const expectedAction = {\r\n type: 'PUBLISH_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.PublishSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to publish content failure', () => {\r\n const expectedAction = {\r\n type: 'PUBLISH_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.PublishFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('ApproveContent', () => {\r\n it('should create an action to an approve content request', () => {\r\n const expectedAction = {\r\n type: 'APPROVE_CONTENT_REQUEST',\r\n id: 123\r\n }\r\n expect(Actions.Approve(123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to approve content success', () => {\r\n const expectedAction = {\r\n type: 'APPROVE_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.ApproveSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to approve content failure', () => {\r\n const expectedAction = {\r\n type: 'APPROVE_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.ApproveFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('RejectContent', () => {\r\n it('should create an action to an reject content request', () => {\r\n const expectedAction = {\r\n type: 'REJECT_CONTENT_REQUEST',\r\n id: 123,\r\n rejectReason: 'reason'\r\n }\r\n expect(Actions.Reject(123, 'reason')).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to reject content success', () => {\r\n const expectedAction = {\r\n type: 'REJECT_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.RejectSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to reject content failure', () => {\r\n const expectedAction = {\r\n type: 'REJECT_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.RejectFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('UndoCheckoutContent', () => {\r\n it('should create an action to an undo-checkout content request', () => {\r\n const expectedAction = {\r\n type: 'UNDOCHECKOUT_CONTENT_REQUEST',\r\n id: 123\r\n }\r\n expect(Actions.UndoCheckout(123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to undo-checkout content success', () => {\r\n const expectedAction = {\r\n type: 'UNDOCHECKOUT_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.UndoCheckoutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to undo-checkout content failure', () => {\r\n const expectedAction = {\r\n type: 'UNDOCHECKOUT_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.UndoCheckoutFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('ForceUndoCheckoutContent', () => {\r\n it('should create an action to a force undo-checkout content request', () => {\r\n const expectedAction = {\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST',\r\n id: 123\r\n }\r\n expect(Actions.ForceUndoCheckout(123)).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to force undo-checkout content success', () => {\r\n const expectedAction = {\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.ForceUndoCheckoutSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to force undo-checkout content failure', () => {\r\n const expectedAction = {\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.ForceUndoCheckoutFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('RestoreVersion', () => {\r\n it('should create an action to a version restore request', () => {\r\n const expectedAction = {\r\n type: 'RESTOREVERSION_CONTENT_REQUEST',\r\n id: 123,\r\n version: 'A.1.0'\r\n }\r\n expect(Actions.RestoreVersion(123, 'A.1.0')).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a version restore success', () => {\r\n const expectedAction = {\r\n type: 'RESTOREVERSION_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: \"My content\",\r\n Id: 123,\r\n Index: 2\r\n }\r\n }\r\n }, result: 123\r\n }\r\n }\r\n expect(Actions.RestoreVersionSuccess({ response: { d: { DisplayName: 'My content', Id: 123, Index: 2 } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a version restore failure', () => {\r\n const expectedAction = {\r\n type: 'RESTOREVERSION_CONTENT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.RestoreVersionFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('UserLogin', () => {\r\n it('should create an action to a user login request', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGIN_REQUEST',\r\n userName: 'alba',\r\n password: 'alba'\r\n }\r\n expect(Actions.UserLogin('alba', 'alba')).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a user login success', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGIN_SUCCESS',\r\n response: {\r\n Name: 'alba',\r\n DisplayName: 'Alba Monday'\r\n }\r\n }\r\n expect(Actions.UserLoginSuccess({ response: { d: { Name: 'alba', DisplayName: 'Alba Monday' } } })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a user login failure', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGIN_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.UserLoginFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a user login failure with the proper message when 403', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGIN_FAILURE',\r\n message: 'The username or the password is not valid!'\r\n }\r\n expect(Actions.UserLoginFailure({ message: 'The username or the password is not valid!', status: 403 })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n describe('UserLogout', () => {\r\n it('should create an action to a user logout request', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGOUT_REQUEST'\r\n }\r\n expect(Actions.UserLogout()).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a user logout success', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGOUT_SUCCESS'\r\n }\r\n expect(Actions.UserLogoutSuccess({})).to.deep.equal(expectedAction)\r\n });\r\n it('should create an action to a user logout failure', () => {\r\n const expectedAction = {\r\n type: 'USER_LOGOUT_FAILURE',\r\n message: 'error'\r\n }\r\n expect(Actions.UserLogoutFailure({ message: 'error' })).to.deep.equal(expectedAction)\r\n });\r\n });\r\n});"]} \ No newline at end of file diff --git a/dist/test/EpicsTests.js b/dist/test/EpicsTests.js deleted file mode 100644 index 8bf8f62..0000000 --- a/dist/test/EpicsTests.js +++ /dev/null @@ -1,391 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("rxjs"); -const nock = require("nock"); -const Chai = require("chai"); -const redux_mock_store_1 = require("redux-mock-store"); -const redux_observable_1 = require("redux-observable"); -const SN = require("sn-client-js"); -const Epics_1 = require("../src/Epics"); -const expect = Chai.expect; -describe('Epics', () => { - let window = { - 'siteUrl': 'https://daily.demo.sensenet.com' - }; - beforeEach(() => { - window['siteUrl'] = "https://daily.demo.sensenet.com"; - }); - describe('fetchContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.fetchContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.fetchContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'FETCH_CONTENT_REQUEST', - path: '/workspaces/Project' - }, - { - type: 'FETCH_CONTENT_FAILURE', - filter: 'undefined', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('createContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.createContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.createContentEpic); - }); - it('handles the error', () => { - const content = SN.Content.Create('Article', { DisplayName: 'My article' }); - store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'CREATE_CONTENT_REQUEST', - path: '/workspaces/Project', - content - }, - { - type: 'CREATE_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('updateContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.updateContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.updateContentEpic); - }); - it('handles the error', () => { - const fields = { DisplayName: 'My article', Index: 2 }; - store.dispatch({ type: 'UPDATE_CONTENT_REQUEST', id: 111, fields }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'UPDATE_CONTENT_REQUEST', - id: 111, - fields - }, - { - type: 'UPDATE_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('deleteContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.deleteContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.deleteContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'DELETE_CONTENT_REQUEST', id: 111, permanently: false }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'DELETE_CONTENT_REQUEST', - id: 111, - permanently: false - }, - { - type: 'DELETE_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('deleteBatch Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.deleteBatchEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.deleteBatchEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'DELETE_BATCH_REQUEST', path: '/workspaces/Project', paths: ['1', '2'], permanently: false }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'DELETE_BATCH_REQUEST', - path: '/workspaces/Project', - paths: ['1', '2'], - permanently: false - }, - { - type: 'DELETE_BATCH_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('checkoutContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.checkoutContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.checkoutContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'CHECKOUT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'CHECKOUT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'CHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('checkinContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.checkinContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.checkinContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'CHECKIN_CONTENT_REQUEST', id: 111, checkinComment: 'comment' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'CHECKIN_CONTENT_REQUEST', - id: 111, - checkinComment: 'comment' - }, - { - type: 'CHECKIN_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('publishContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.publishContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.publishContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'PUBLISH_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'PUBLISH_CONTENT_REQUEST', - id: 111 - }, - { - type: 'PUBLISH_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('approveContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.approveContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.approveContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'APPROVE_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'APPROVE_CONTENT_REQUEST', - id: 111 - }, - { - type: 'APPROVE_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('rejectContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.rejectContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - beforeEach(() => { - store = mockStore(); - }); - afterEach(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.rejectContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111, rejectReason: 'reason' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'REJECT_CONTENT_REQUEST', - id: 111, - rejectReason: 'reason' - }, - { - type: 'REJECT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - it('handles the error', () => { - store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'REJECT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'REJECT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('undocheckoutContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.undocheckoutContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.undocheckoutContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'UNDOCHECKOUT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'UNDOCHECKOUT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'UNDOCHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('forceundocheckoutContent Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.forceundocheckoutContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.forceundocheckoutContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('restoreVersion Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.restoreversionContentEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.restoreversionContentEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'RESTOREVERSION_CONTENT_REQUEST', id: 111, version: 'A.1.0' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'RESTOREVERSION_CONTENT_REQUEST', - id: 111, - version: 'A.1.0' - }, - { - type: 'RESTOREVERSION_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('login Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.userLoginEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.userLoginEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'USER_LOGIN_REQUEST', id: 111, username: 'alba', password: 'alba' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'USER_LOGIN_REQUEST', - id: 111, - username: 'alba', - password: 'alba' - }, - { - type: 'USER_LOGIN_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); - describe('logout Epic', () => { - let store; - const epicMiddleware = redux_observable_1.createEpicMiddleware(Epics_1.Epics.userLogoutEpic); - const mockStore = redux_mock_store_1.default([epicMiddleware]); - before(() => { - store = mockStore(); - }); - after(() => { - nock.cleanAll(); - epicMiddleware.replaceEpic(Epics_1.Epics.userLogoutEpic); - }); - it('handles the error', () => { - store.dispatch({ type: 'USER_LOGOUT_REQUEST', id: 111, username: 'alba', password: 'alba' }); - expect(store.getActions()).to.be.deep.eq([{ - type: 'USER_LOGOUT_REQUEST', - id: 111, - username: 'alba', - password: 'alba' - }, - { - type: 'USER_LOGOUT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }); - }); -}); - -//# sourceMappingURL=EpicsTests.js.map diff --git a/dist/test/EpicsTests.js.map b/dist/test/EpicsTests.js.map deleted file mode 100644 index 03ff8d2..0000000 --- a/dist/test/EpicsTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["test/EpicsTests.ts"],"names":[],"mappings":";;AACA,gBAAc;AACd,6BAA6B;AAC7B,6BAA6B;AAC7B,uDAAkD;AAClD,uDAAwD;AACxD,mCAAmC;AACnC,wCAAoC;AACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AAE3B,QAAQ,CAAC,OAAO,EAAE;IACd,IAAI,MAAM,GAAG;QACT,SAAS,EAAE,iCAAiC;KAC/C,CAAA;IACD,UAAU,CAAC;QACP,MAAM,CAAC,SAAS,CAAC,GAAG,iCAAiC,CAAC;IAC1D,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,mBAAmB,EAAE;QAC1B,IAAI,KAAK,CAAC;QACV,MAAM,cAAc,GAAG,uCAAoB,CAAC,aAAK,CAAC,gBAAgB,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,0BAAkB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;QAEvD,MAAM,CAAC;YACH,KAAK,GAAG,SAAS,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC;YACF,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,cAAc,CAAC,WAAW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AAC,CAAC;QACZ,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","file":"EpicsTests.js","sourcesContent":["///\r\nimport 'rxjs';\r\nimport * as nock from 'nock';\r\nimport * as Chai from 'chai';\r\nimport configureMockStore from 'redux-mock-store';\r\nimport { createEpicMiddleware } from 'redux-observable';\r\nimport * as SN from 'sn-client-js';\r\nimport { Epics } from '../src/Epics'\r\nconst expect = Chai.expect;\r\n\r\ndescribe('Epics', () => {\r\n let window = {\r\n 'siteUrl': 'https://daily.demo.sensenet.com'\r\n }\r\n beforeEach(() => {\r\n window['siteUrl'] = \"https://daily.demo.sensenet.com\";\r\n })\r\n describe('fetchContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.fetchContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.fetchContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'FETCH_CONTENT_REQUEST',\r\n path: '/workspaces/Project'\r\n },\r\n {\r\n type: 'FETCH_CONTENT_FAILURE',\r\n filter: 'undefined',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('createContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.createContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.createContentEpic);\r\n });\r\n it('handles the error', () => {\r\n const content = SN.Content.Create('Article', { DisplayName: 'My article' })\r\n store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'CREATE_CONTENT_REQUEST',\r\n path: '/workspaces/Project',\r\n content\r\n },\r\n {\r\n type: 'CREATE_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('updateContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.updateContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.updateContentEpic);\r\n });\r\n it('handles the error', () => {\r\n const fields = { DisplayName: 'My article', Index: 2 };\r\n store.dispatch({ type: 'UPDATE_CONTENT_REQUEST', id: 111, fields });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'UPDATE_CONTENT_REQUEST',\r\n id: 111,\r\n fields\r\n },\r\n {\r\n type: 'UPDATE_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('deleteContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.deleteContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.deleteContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'DELETE_CONTENT_REQUEST', id: 111, permanently: false });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'DELETE_CONTENT_REQUEST',\r\n id: 111,\r\n permanently: false\r\n },\r\n {\r\n type: 'DELETE_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('deleteBatch Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.deleteBatchEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.deleteBatchEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'DELETE_BATCH_REQUEST', path: '/workspaces/Project', paths: ['1', '2'], permanently: false });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'DELETE_BATCH_REQUEST',\r\n path: '/workspaces/Project',\r\n paths: ['1', '2'],\r\n permanently: false\r\n },\r\n {\r\n type: 'DELETE_BATCH_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('checkoutContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.checkoutContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.checkoutContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'CHECKOUT_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'CHECKOUT_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'CHECKOUT_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('checkinContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.checkinContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.checkinContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'CHECKIN_CONTENT_REQUEST', id: 111, checkinComment: 'comment' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'CHECKIN_CONTENT_REQUEST',\r\n id: 111,\r\n checkinComment: 'comment'\r\n },\r\n {\r\n type: 'CHECKIN_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('publishContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.publishContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.publishContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'PUBLISH_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'PUBLISH_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'PUBLISH_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('approveContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.approveContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.approveContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'APPROVE_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'APPROVE_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'APPROVE_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('rejectContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.rejectContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n beforeEach(() => {\r\n store = mockStore();\r\n });\r\n\r\n afterEach(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.rejectContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111, rejectReason: 'reason' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'REJECT_CONTENT_REQUEST',\r\n id: 111,\r\n rejectReason: 'reason'\r\n },\r\n {\r\n type: 'REJECT_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'REJECT_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'REJECT_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('undocheckoutContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.undocheckoutContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.undocheckoutContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'UNDOCHECKOUT_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'UNDOCHECKOUT_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'UNDOCHECKOUT_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('forceundocheckoutContent Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.forceundocheckoutContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.forceundocheckoutContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', id: 111 });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST',\r\n id: 111\r\n },\r\n {\r\n type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('restoreVersion Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.restoreversionContentEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.restoreversionContentEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'RESTOREVERSION_CONTENT_REQUEST', id: 111, version: 'A.1.0' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'RESTOREVERSION_CONTENT_REQUEST',\r\n id: 111,\r\n version: 'A.1.0'\r\n },\r\n {\r\n type: 'RESTOREVERSION_CONTENT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('login Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.userLoginEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.userLoginEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'USER_LOGIN_REQUEST', id: 111, username: 'alba', password: 'alba' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'USER_LOGIN_REQUEST',\r\n id: 111,\r\n username: 'alba',\r\n password: 'alba'\r\n },\r\n {\r\n type: 'USER_LOGIN_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n describe('logout Epic', () => {\r\n let store;\r\n const epicMiddleware = createEpicMiddleware(Epics.userLogoutEpic);\r\n const mockStore = configureMockStore([epicMiddleware]);\r\n\r\n before(() => {\r\n store = mockStore();\r\n });\r\n\r\n after(() => {\r\n nock.cleanAll();\r\n epicMiddleware.replaceEpic(Epics.userLogoutEpic);\r\n });\r\n it('handles the error', () => {\r\n store.dispatch({ type: 'USER_LOGOUT_REQUEST', id: 111, username: 'alba', password: 'alba' });\r\n expect(store.getActions()).to.be.deep.eq(\r\n [{\r\n type: 'USER_LOGOUT_REQUEST',\r\n id: 111,\r\n username: 'alba',\r\n password: 'alba'\r\n },\r\n {\r\n type: 'USER_LOGOUT_FAILURE',\r\n message: 'XMLHttpRequest is not supported by your browser'\r\n }]);\r\n })\r\n });\r\n});"]} \ No newline at end of file diff --git a/dist/test/ReducersTests.js b/dist/test/ReducersTests.js deleted file mode 100644 index edab658..0000000 --- a/dist/test/ReducersTests.js +++ /dev/null @@ -1,341 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const Reducers_1 = require("../src/Reducers"); -const Chai = require("chai"); -const expect = Chai.expect; -describe('byId reducer', () => { - it('should return the initial state', () => { - expect(Reducers_1.Reducers.byId(undefined, {})).to.be.deep.equal({}); - }); - it('should handle DELETE_CONTENT_SUCCESS', () => { - const ids = [1, 2, 3]; - expect(Reducers_1.Reducers.byId(ids, { type: 'DELETE_CONTENT_SUCCESS', id: 1 })).to.be.deep.equal({ 0: 1, 2: 3 }); - }); - it('should return a new state with the given response', () => { - expect(Reducers_1.Reducers.byId({}, { response: { entities: { collection: { a: 0, b: 2 } } } })) - .to.be.deep.eq({ a: 0, b: 2 }); - }); -}); -describe('ids reducer', () => { - it('should return the initial state', () => { - expect(Reducers_1.Reducers.ids(undefined, {})).to.be.deep.equal([]); - }); - it('should handle FETCH_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.ids([], { - type: 'FETCH_CONTENT_SUCCESS', - response: { - result: [5145, 5146], - entities: { - collection: { - 5145: { - Id: 5145, - DisplayName: 'Some Article', - Status: ['Active'] - }, - 5146: { - Id: 5146, - Displayname: 'Other Article', - Status: ['Completed'] - } - } - } - }, - filter: "?$select=Id,Type&metadata=no" - })) - .to.be.deep.equal([5145, 5146]); - }); - it('should handle CREATE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.ids([], { - type: 'CREATE_CONTENT_SUCCESS', - response: { - entities: { - collection: { - 123: { - DisplayName: 'My content', - Id: 123 - } - } - }, - result: 123 - }, - filter: "?$select=Id,Type&metadata=no" - })) - .to.be.deep.equal([123]); - }); - it('should handle DELETE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.ids([1, 2, 3], { - type: 'DELETE_CONTENT_SUCCESS', - index: 0, - id: 1 - })) - .to.be.deep.equal([2, 3]); - }); -}); -describe('isFetching reducer', () => { - it('should return the initial state', () => { - expect(Reducers_1.Reducers.isFetching(undefined, {})).to.be.eq(false); - }); - it('should handle FETCH_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.isFetching(false, { type: 'FETCH_CONTENT_REQUEST' })).to.be.eq(true); - }); - it('should handle FETCH_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.isFetching(true, { type: 'FETCH_CONTENT_SUCCESS' })).to.be.eq(false); - }); - it('should handle FETCH_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.isFetching(true, { type: 'FETCH_CONTENT_FAILURE' })).to.be.eq(false); - }); -}); -describe('user reducer', () => { - const userInitialState = { - data: null, - isLoading: false, - isAuthenticated: false, - errorMessage: '' - }; - const user = { - data: { - userName: 'alba', - fullName: 'Alba Monday' - } - }; - it('should return the initial state', () => { - expect(Reducers_1.Reducers.user(undefined, {})).to.be.deep.equal(userInitialState); - }); - it('should handle USER_LOGIN_REQUEST', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGIN_REQUEST' })).to.be.deep.equal({ - data: null, - isLoading: true, - errorMessage: '', - isAuthenticated: false - }); - }); - it('should handle USER_LOGIN_SUCCESS', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGIN_SUCCESS', response: { LoginName: 'alba', FullName: 'Alba Monday' } })).to.be.deep.equal({ - data: { - userName: 'alba', - fullName: 'Alba Monday' - }, - isLoading: false, - isAuthenticated: true - }); - }); - it('should handle USER_LOGIN_FAILURE', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGIN_FAILURE', message: 'aaa' })).to.be.deep.equal({ - data: null, - isLoading: false, - errorMessage: 'aaa', - isAuthenticated: false - }); - }); - it('should handle USER_LOGOUT_REQUEST', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGOUT_REQUEST' })).to.be.deep.equal({ - data: null, - isLoading: true, - errorMessage: '', - isAuthenticated: false - }); - }); - it('should handle USER_LOGOUT_SUCCESS', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGOUT_SUCCESS' })).to.be.deep.equal({ - data: null, - isLoading: false, - errorMessage: '', - isAuthenticated: false - }); - }); - it('should handle USER_LOGOUT_FAILURE', () => { - expect(Reducers_1.Reducers.user(userInitialState, { type: 'USER_LOGOUT_FAILURE', message: 'aaa' })).to.be.deep.equal({ - data: null, - isLoading: false, - errorMessage: 'aaa', - isAuthenticated: true - }); - }); -}); -describe('errorMessage reducer', () => { - it('should return the initial state', () => { - expect(Reducers_1.Reducers.errorMessage(undefined, {})).to.be.eq(null); - }); - it('should handle FETCH_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FETCH_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle CREATE_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CREATE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle UPDATE_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle DELETE_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'DELETE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle CHECKIN_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle CHECKOUT_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle PUBLISH_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle APPROVE_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle REJECT_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'REJECT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle UNDOCHECKOUT_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle FORCEUNDOCHECKOUT_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle RESTOREVERSION_CONTENT_FAILURE', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_FAILURE', message: 'error' })).to.be.eq('error'); - }); - it('should handle FETCH_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FETCH_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle FETCH_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FETCH_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle CREATE_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CREATE_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle CREATE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CREATE_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle UPDATE_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle UPDATE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle DELETE_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'DELETE_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle DELETE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'DELETE_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle CHECKIN_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle CHECKIN_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle CHECKOUT_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle CHECKOUT_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle APPROVE_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle APPROVE_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle PUBLISH_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle PUBLISH_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle REJECT_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'REJECT_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle REJECT_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'REJECT_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle UNDOCHECKOUT_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle UNDOCHECKOUT_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle FORCEUNDOCHECKOUT_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle FORCEUNDOCHECKOUT_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null); - }); - it('should handle RESTOREVERSION_CONTENT_REQUEST', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_REQUEST' })).to.be.eq(null); - }); - it('should handle RESTOREVERSION_CONTENT_SUCCESS', () => { - expect(Reducers_1.Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_SUCCESS' })).to.be.eq(null); - }); -}); -describe('getContent', () => { - const state = { - entities: { - collection: { - 5145: { - Id: 5145, - DisplayName: 'Some Article', - Status: ['Active'] - }, - 5146: { - Id: 5146, - Displayname: 'Other Article', - Status: ['Completed'] - } - } - } - }; - it('should return the content from the state by the given id', () => { - expect(Reducers_1.Reducers.getContent(state.entities.collection, 5145)).to.be.deep.eq({ - Id: 5145, - DisplayName: 'Some Article', - Status: ['Active'] - }); - }); -}); -describe('getIds', () => { - const state = { - ids: [5145, 5146] - }; - it('should return the id array from the current state', () => { - expect(Reducers_1.Reducers.getIds(state)).to.be.deep.eq([5145, 5146]); - }); -}); -describe('getFetching', () => { - const state = { - ids: [5145, 5146], - isFetching: false - }; - it('should return the value of isFetching from the current state', () => { - expect(Reducers_1.Reducers.getFetching(state)).to.be.eq(false); - }); -}); -describe('getError', () => { - const state = { - ids: [5145, 5146], - isFetching: false, - errorMessage: 'error' - }; - it('should return the value of errorMessage from the current state', () => { - expect(Reducers_1.Reducers.getError(state)).to.be.eq('error'); - }); -}); -describe('getAuthenticationStatus', () => { - const state = { - user: { - isAuthenticated: true - } - }; - it('should return true if the user is authenticated state', () => { - expect(Reducers_1.Reducers.getAuthenticationStatus(state)).to.be.eq(true); - }); -}); -describe('getAuthenticationError', () => { - const state = { - user: { - errorMessage: 'error' - } - }; - it('should return the value of errorMessage from the current state', () => { - expect(Reducers_1.Reducers.getAuthenticationError(state)).to.be.eq('error'); - }); -}); - -//# sourceMappingURL=ReducersTests.js.map diff --git a/dist/test/ReducersTests.js.map b/dist/test/ReducersTests.js.map deleted file mode 100644 index 2da6024..0000000 --- a/dist/test/ReducersTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["test/ReducersTests.ts"],"names":[],"mappings":";;AACA,8CAA2C;AAE3C,6BAA6B;AAC7B,MAAM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IAAI,CAAC;QACjB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,OAAO;KACxB,CAAA;IACD,EAAE,CAAC,gEAAgE,EAAE;QACjE,MAAM,CAAC,mBAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE;IAChC,MAAM,KAAK,GAAG;QACV,IAAI,EAAE;YACF,eAAe,EAAE,IAAI;SACxB;KACJ,CAAA;IACD,EAAE,CAAC,uDAAuD,EAAE;QACxD,MAAM,CAAC,mBAAQ,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,wBAAwB,EAAE;IAC/B,MAAM,KAAK,GAAG;QACV,IAAI,EAAE;YACF,YAAY,EAAE,OAAO;SACxB;KACJ,CAAA;IACD,EAAE,CAAC,gEAAgE,EAAE;QACjE,MAAM,CAAC,mBAAQ,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","file":"ReducersTests.js","sourcesContent":["///\r\nimport { Reducers } from '../src/Reducers';\r\nimport { Actions } from '../src/Actions';\r\nimport * as Chai from 'chai';\r\nconst expect = Chai.expect;\r\n\r\ndescribe('byId reducer', () => {\r\n it('should return the initial state', () => {\r\n expect(Reducers.byId(undefined, {})).to.be.deep.equal({});\r\n });\r\n it('should handle DELETE_CONTENT_SUCCESS', () => {\r\n const ids = [1, 2, 3];\r\n expect(Reducers.byId(ids, { type: 'DELETE_CONTENT_SUCCESS', id: 1 })).to.be.deep.equal({ 0: 1, 2: 3 });\r\n });\r\n it('should return a new state with the given response', () => {\r\n expect(Reducers.byId({}, { response: { entities: { collection: { a: 0, b: 2 } } } }))\r\n .to.be.deep.eq({ a: 0, b: 2 });\r\n });\r\n});\r\n\r\ndescribe('ids reducer', () => {\r\n it('should return the initial state', () => {\r\n expect(Reducers.ids(undefined, {})).to.be.deep.equal([]);\r\n });\r\n it('should handle FETCH_CONTENT_SUCCESS', () => {\r\n expect(Reducers.ids([],\r\n {\r\n type: 'FETCH_CONTENT_SUCCESS',\r\n response: {\r\n result: [5145, 5146],\r\n entities: {\r\n collection: {\r\n 5145: {\r\n Id: 5145,\r\n DisplayName: 'Some Article',\r\n Status: ['Active']\r\n },\r\n 5146: {\r\n Id: 5146,\r\n Displayname: 'Other Article',\r\n Status: ['Completed']\r\n }\r\n }\r\n }\r\n },\r\n filter: \"?$select=Id,Type&metadata=no\"\r\n }))\r\n .to.be.deep.equal([5145, 5146]);\r\n });\r\n it('should handle CREATE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.ids([],\r\n {\r\n type: 'CREATE_CONTENT_SUCCESS',\r\n response: {\r\n entities: {\r\n collection: {\r\n 123: {\r\n DisplayName: 'My content',\r\n Id: 123\r\n }\r\n }\r\n },\r\n result: 123\r\n },\r\n filter: \"?$select=Id,Type&metadata=no\"\r\n }))\r\n .to.be.deep.equal([123]);\r\n });\r\n it('should handle DELETE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.ids(\r\n [1, 2, 3],\r\n {\r\n type: 'DELETE_CONTENT_SUCCESS',\r\n index: 0,\r\n id: 1\r\n }))\r\n .to.be.deep.equal([2, 3]);\r\n });\r\n});\r\n\r\ndescribe('isFetching reducer', () => {\r\n it('should return the initial state', () => {\r\n expect(Reducers.isFetching(undefined, {})).to.be.eq(false);\r\n });\r\n it('should handle FETCH_CONTENT_SUCCESS', () => {\r\n expect(Reducers.isFetching(false, { type: 'FETCH_CONTENT_REQUEST' })).to.be.eq(true);\r\n });\r\n it('should handle FETCH_CONTENT_SUCCESS', () => {\r\n expect(Reducers.isFetching(true, { type: 'FETCH_CONTENT_SUCCESS' })).to.be.eq(false);\r\n });\r\n it('should handle FETCH_CONTENT_FAILURE', () => {\r\n expect(Reducers.isFetching(true, { type: 'FETCH_CONTENT_FAILURE' })).to.be.eq(false);\r\n });\r\n});\r\n\r\ndescribe('user reducer', () => {\r\n const userInitialState = {\r\n data: null,\r\n isLoading: false,\r\n isAuthenticated: false,\r\n errorMessage: ''\r\n };\r\n const user = {\r\n data: {\r\n userName: 'alba',\r\n fullName: 'Alba Monday'\r\n }\r\n }\r\n it('should return the initial state', () => {\r\n expect(Reducers.user(undefined, {})).to.be.deep.equal(userInitialState);\r\n });\r\n it('should handle USER_LOGIN_REQUEST', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_REQUEST' })).to.be.deep.equal(\r\n {\r\n data: null,\r\n isLoading: true,\r\n errorMessage: '',\r\n isAuthenticated: false\r\n }\r\n );\r\n });\r\n it('should handle USER_LOGIN_SUCCESS', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_SUCCESS', response: { LoginName: 'alba', FullName: 'Alba Monday' } })).to.be.deep.equal(\r\n {\r\n data: {\r\n userName: 'alba',\r\n fullName: 'Alba Monday'\r\n },\r\n isLoading: false,\r\n isAuthenticated: true\r\n }\r\n );\r\n });\r\n it('should handle USER_LOGIN_FAILURE', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_FAILURE', message: 'aaa' })).to.be.deep.equal(\r\n {\r\n data: null,\r\n isLoading: false,\r\n errorMessage: 'aaa',\r\n isAuthenticated: false\r\n }\r\n );\r\n });\r\n it('should handle USER_LOGOUT_REQUEST', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_REQUEST' })).to.be.deep.equal(\r\n {\r\n data: null,\r\n isLoading: true,\r\n errorMessage: '',\r\n isAuthenticated: false\r\n }\r\n );\r\n });\r\n it('should handle USER_LOGOUT_SUCCESS', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_SUCCESS' })).to.be.deep.equal(\r\n {\r\n data: null,\r\n isLoading: false,\r\n errorMessage: '',\r\n isAuthenticated: false\r\n }\r\n );\r\n });\r\n it('should handle USER_LOGOUT_FAILURE', () => {\r\n expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_FAILURE', message: 'aaa' })).to.be.deep.equal(\r\n {\r\n data: null,\r\n isLoading: false,\r\n errorMessage: 'aaa',\r\n isAuthenticated: true\r\n }\r\n );\r\n });\r\n});\r\n\r\ndescribe('errorMessage reducer', () => {\r\n it('should return the initial state', () => {\r\n expect(Reducers.errorMessage(undefined, {})).to.be.eq(null);\r\n });\r\n it('should handle FETCH_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FETCH_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle CREATE_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CREATE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle UPDATE_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle DELETE_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'DELETE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle CHECKIN_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle CHECKOUT_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle PUBLISH_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle APPROVE_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle REJECT_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'REJECT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle UNDOCHECKOUT_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle FORCEUNDOCHECKOUT_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle RESTOREVERSION_CONTENT_FAILURE', () => {\r\n expect(Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_FAILURE', message: 'error' })).to.be.eq('error');\r\n });\r\n it('should handle FETCH_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FETCH_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle FETCH_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FETCH_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle CREATE_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CREATE_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle CREATE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CREATE_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle UPDATE_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle UPDATE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UPDATE_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle DELETE_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'DELETE_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle DELETE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'DELETE_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle CHECKIN_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle CHECKIN_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKIN_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle CHECKOUT_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle CHECKOUT_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'CHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle APPROVE_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle APPROVE_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'APPROVE_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle PUBLISH_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle PUBLISH_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'PUBLISH_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle REJECT_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'REJECT_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle REJECT_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'REJECT_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle UNDOCHECKOUT_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle UNDOCHECKOUT_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'UNDOCHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle FORCEUNDOCHECKOUT_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle FORCEUNDOCHECKOUT_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n it('should handle RESTOREVERSION_CONTENT_REQUEST', () => {\r\n expect(Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_REQUEST' })).to.be.eq(null);\r\n });\r\n it('should handle RESTOREVERSION_CONTENT_SUCCESS', () => {\r\n expect(Reducers.errorMessage(null, { type: 'RESTOREVERSION_CONTENT_SUCCESS' })).to.be.eq(null);\r\n });\r\n});\r\n\r\ndescribe('getContent', () => {\r\n const state = {\r\n entities: {\r\n collection: {\r\n 5145: {\r\n Id: 5145,\r\n DisplayName: 'Some Article',\r\n Status: ['Active']\r\n },\r\n 5146: {\r\n Id: 5146,\r\n Displayname: 'Other Article',\r\n Status: ['Completed']\r\n }\r\n }\r\n }\r\n }\r\n it('should return the content from the state by the given id', () => {\r\n expect(Reducers.getContent(state.entities.collection, 5145)).to.be.deep.eq(\r\n {\r\n Id: 5145,\r\n DisplayName: 'Some Article',\r\n Status: ['Active']\r\n }\r\n );\r\n });\r\n});\r\n\r\ndescribe('getIds', () => {\r\n const state = {\r\n ids: [5145, 5146]\r\n }\r\n it('should return the id array from the current state', () => {\r\n expect(Reducers.getIds(state)).to.be.deep.eq([5145, 5146]);\r\n });\r\n});\r\n\r\ndescribe('getFetching', () => {\r\n const state = {\r\n ids: [5145, 5146],\r\n isFetching: false\r\n }\r\n it('should return the value of isFetching from the current state', () => {\r\n expect(Reducers.getFetching(state)).to.be.eq(false);\r\n });\r\n});\r\n\r\ndescribe('getError', () => {\r\n const state = {\r\n ids: [5145, 5146],\r\n isFetching: false,\r\n errorMessage: 'error'\r\n }\r\n it('should return the value of errorMessage from the current state', () => {\r\n expect(Reducers.getError(state)).to.be.eq('error');\r\n });\r\n});\r\n\r\ndescribe('getAuthenticationStatus', () => {\r\n const state = {\r\n user: {\r\n isAuthenticated: true\r\n }\r\n }\r\n it('should return true if the user is authenticated state', () => {\r\n expect(Reducers.getAuthenticationStatus(state)).to.be.eq(true);\r\n });\r\n});\r\n\r\ndescribe('getAuthenticationError', () => {\r\n const state = {\r\n user: {\r\n errorMessage: 'error'\r\n }\r\n }\r\n it('should return the value of errorMessage from the current state', () => {\r\n expect(Reducers.getAuthenticationError(state)).to.be.eq('error');\r\n });\r\n});"]} \ No newline at end of file diff --git a/package.json b/package.json index 5ebae73..9efc391 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "sn-redux", "version": "1.1.0-beta.2", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", - "main": "dist/sn-redux.js", + "main": "dist/src/sn-redux.js", "scripts": { "commit": "git-cz", "gulp": "gulp", @@ -11,6 +11,11 @@ "report-coverage": "cat ./coverage/lcov.info | codecov", "semantic-release": "semantic-release pre && semantic-release post" }, + "files": [ + "dist", + "src", + "test" + ], "repository": { "type": "git", "url": "https://github.com/SenseNet/sn-redux.git" From 894cde4564f4b08bddf2b0c3d7d0811f1ce9896a Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 5 May 2017 09:57:20 +0200 Subject: [PATCH 09/26] fix(sn-client-js dependency and namespaces): Fixed import namespaces in Actions.ts, updated dependen --- package.json | 2 +- src/Actions.ts | 132 ++++++++++++++++++++++++------------------------- src/Schema.ts | 2 +- 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/package.json b/package.json index 9efc391..89837f4 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "redux-thunk": "^2.2.0", "redux-logger": "2.8.2", "redux-observable": "^0.14.1", - "sn-client-js": "1.1.1-beta.1" + "sn-client-js": "1.1.1-development.4" }, "devDependencies": { "@types/chai": "3.4.35", diff --git a/src/Actions.ts b/src/Actions.ts index c46a57a..0ee1465 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -1,23 +1,23 @@ import { normalize } from 'normalizr'; import { Schemas } from './Schema'; -import * as SN from 'sn-client-js'; +import { Content, ODataApi, ODataHelper } from 'sn-client-js'; /** - * Module that contains the action creators. - * - * _Redux actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using + * Module that contains the action creators. + * + * _Redux actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using * ```store.dispatch()```. Actions are plain JavaScript objects. Actions must have a type property that indicates the type of action being performed._ - * + * * Learn more about Redux actions [here](http://redux.js.org/docs/basics/Actions.html) - * - * Following are Redux actions but they're all related with a Sense/Net built-in action. Since this Sense/Net built-in actions are OData actions and functions and they get and set + * + * Following are Redux actions but they're all related with a Sense/Net built-in action. Since this Sense/Net built-in actions are OData actions and functions and they get and set * data throught ajax request we have to handle the main steps of their process separately. So there're three separate redux action for every Sense/Net action: * one for the request itself and two for the two possible end of an ajax request, success and fail. - * - * All of the JSON responses with content or collection are normalized so you shouldn't care about how to handle nested data structure, normalizr takes JSON and a schema and replaces + * + * All of the JSON responses with content or collection are normalized so you shouldn't care about how to handle nested data structure, normalizr takes JSON and a schema and replaces * nested entities with their IDs, gathering all entities in dictionaries. * For further information about normalizr check this [link](https://github.com/paularmstrong/normalizr). - * + * * ``` * [{ * Id: 5145, @@ -28,11 +28,11 @@ import * as SN from 'sn-client-js'; * Displayname: 'Other Article', * Status: ['Completed'] * }] - * + * * ``` - * + * * is normalized to - * + * * ``` * result: [5145, 5146], * entities: { @@ -50,12 +50,12 @@ import * as SN from 'sn-client-js'; * } * } * ``` - * + * * Following module now cover the CRUD operations, so it contains Actions which are related to fetching, creating, deleting and updating Content. Other built-in SenseNet OData * Actions and Functions will be the parts of this module too and you are be able to add your custom Actions too by combining your reducers with the built-in ones. - * + * * ### Using built-in redux actions in your views - * + * * ``` * import * as React from 'react' * import { connect } from 'react-redux' @@ -63,10 +63,10 @@ import * as SN from 'sn-client-js'; * import RaisedButton from 'material-ui/RaisedButton'; * import { Actions } from 'sn-redux'; * import { Content } from './SenseNet/Content'; - * + * * let AddTodo = ({ dispatch }) => { * let input - * + * * return ( *
*
{ @@ -93,21 +93,21 @@ import * as SN from 'sn-client-js'; * } * AddTodo = connect()(AddTodo) * ``` - * + * * ### Combining your custom redux reducers with sn-redux's root reducer. - * + * * ``` * import { combineReducers } from 'redux'; * import { Store, Reducers } from 'sn-redux'; * import { Root } from './components/Root' * import { listByFilter } from './reducers/filtering' - * + * * const collection = Reducers.collection; * const myReducer = combineReducers({ * collection, * listByFilter * }); - * + * * const store = Store.configureStore(myReducer); * ``` */ @@ -116,18 +116,18 @@ export module Actions { * Action creator for requesting a content from Sense/Net Content Repository to get its children content. * @param path {string} Path of the requested parent item. * @param options {OData.IODataParams} Represents an ODataOptions object based on the IODataOptions interface. Holds the possible url parameters as properties. - * @returns {Object} Returns a redux action with the properties type, path and filter. + * @returns {Object} Returns a redux action with the properties type, path and filter. */ - export const RequestContent = (path: string, options: SN.ODataApi.IODataParams = {}) => ({ + export const RequestContent = (path: string, options: ODataApi.IODataParams = {}) => ({ type: 'FETCH_CONTENT_REQUEST', path, - filter: SN.ODataHelper.buildUrlParamString(options) + filter: ODataHelper.buildUrlParamString(options) }); /** * Action creator for the step when a fetching request ends successfully. * @param response {any} JSON response of the ajax request. * @param filter {string} String with the url params. - * @returns {Object} Returns a redux action with the properties type, normalized response and filter. + * @returns {Object} Returns a redux action with the properties type, normalized response and filter. */ export const ReceiveContent = (response: any, filter: string) => ({ @@ -139,7 +139,7 @@ export module Actions { * Action creator for the step when a fetching request failed. * @param filter {string} String with the url params. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type, filter and errormessage. + * @returns {Object} Returns a redux action with the properties type, filter and errormessage. */ export const ReceiveContentFailure = (filter: string, error: any) => ({ type: 'FETCH_CONTENT_FAILURE', @@ -150,13 +150,13 @@ export module Actions { * Action creator for creating a Content in the Content Repository. * @param path {string} Path of the parent item. * @param content {Content} Content that have to be created in the Content Respository. - * @returns {Object} Returns a redux action with the properties type, path of the parent and content. + * @returns {Object} Returns a redux action with the properties type, path of the parent and content. */ - export const CreateContent = (path: string, content: SN.Content) => ({ type: 'CREATE_CONTENT_REQUEST', content, path }); + export const CreateContent = (path: string, content: Content) => ({ type: 'CREATE_CONTENT_REQUEST', content, path }); /** * Action creator for the step when Content creation on the server ends successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized response. + * @returns {Object} Returns a redux action with the properties type and the normalized response. */ export const CreateContentSuccess = (response: any) => ({ @@ -166,7 +166,7 @@ export module Actions { /** * Action creator for the step when Content creation failed on the server. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const CreateContentFailure = (error: any) => ({ type: 'CREATE_CONTENT_FAILURE', @@ -176,13 +176,13 @@ export module Actions { * Action creator for updating a Content in the Content Repository. * @param id {number} Id of the Content that has to be updated. * @param fields {Object} Object with the field value pairs that have to be modified. - * @returns {Object} Returns a redux action with the properties type, id and fields. + * @returns {Object} Returns a redux action with the properties type, id and fields. */ export const UpdateContent = (id: number, fields: Object) => ({ type: 'UPDATE_CONTENT_REQUEST', id, fields }); /** * Action creator for the step when Content modification on the server ends successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the response. + * @returns {Object} Returns a redux action with the properties type and the response. */ export const UpdateContentSuccess = (response: any) => ({ @@ -192,7 +192,7 @@ export module Actions { /** * Action creator for the step when Content modification failed on the server. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const UpdateContentFailure = (error: any) => ({ type: 'UPDATE_CONTENT_FAILURE', @@ -202,13 +202,13 @@ export module Actions { * Action creator for deleting a Content from the Content Repository. * @param id {number} Id of the Content that has to be deleted. * @param permanently {boolean} Defines whether the a Content must be moved to the Trash or deleted permanently. - * @returns {Object} Returns a redux action with the properties type, id and permanently. + * @returns {Object} Returns a redux action with the properties type, id and permanently. */ export const Delete = (id: number, permanently: boolean = false) => ({ type: 'DELETE_CONTENT_REQUEST', id, permanently }); /** * Action creator for the step when Content deleted successfully. * @param index {number} Index of the item in the state collection. - * @returns {Object} Returns a redux action with the properties type and index. + * @returns {Object} Returns a redux action with the properties type and index. */ export const DeleteSuccess = (index: number, id: number) => ({ type: 'DELETE_CONTENT_SUCCESS', @@ -218,7 +218,7 @@ export module Actions { /** * Action creator for the step when deleting a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const DeleteFailure = (error: any) => ({ type: 'DELETE_CONTENT_FAILURE', @@ -229,7 +229,7 @@ export module Actions { * @param path {string} Path of the parent Content. * @param ids {string[]} Array of ids of the Content that should be deleted. * @param permanently {boolean} Defines whether Content must be moved to the Trash or deleted permanently. - * @returns {Object} Returns a redux action with the properties type, id and permanently. + * @returns {Object} Returns a redux action with the properties type, id and permanently. */ export const DeleteBatch = (path: string, ids: string[], permanently: boolean = false) => ({ type: 'DELETE_BATCH_REQUEST', @@ -240,7 +240,7 @@ export module Actions { /** * Action creator for the step when multiple Content deleted successfully. * @param indexes {number[]} Array of indexes of the items in the state collection that should be removed. - * @returns {Object} Returns a redux action with the properties type and index. + * @returns {Object} Returns a redux action with the properties type and index. */ export const DeleteBatchSuccess = (indexes: number[]) => ({ type: 'DELETE_BATCH_SUCCESS', @@ -249,7 +249,7 @@ export module Actions { /** * Action creator for the step when deleting multiple Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const DeleteBatchFailure = (error: any) => ({ type: 'DELETE_BATCH_FAILURE', @@ -258,7 +258,7 @@ export module Actions { /** * Action creator for checking out a Content in the Content Repository. * @param id {number} Id of the content that should be checked out. - * @returns {Object} Returns a redux action with the properties type and id . + * @returns {Object} Returns a redux action with the properties type and id . */ export const CheckOut = (id: number) => ({ type: 'CHECKOUT_CONTENT_REQUEST', @@ -267,7 +267,7 @@ export module Actions { /** * Action creator for the step when a Content is checked out successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const CheckOutSuccess = (response: any) => ({ type: 'CHECKOUT_CONTENT_SUCCESS', @@ -276,7 +276,7 @@ export module Actions { /** * Action creator for the step when checking out a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const CheckOutFailure = (error: any) => ({ type: 'CHECKOUT_CONTENT_FAILURE', @@ -285,7 +285,7 @@ export module Actions { /** * Action creator for checking in a Content in the Content Repository. * @param id {number} Id of the content that should be checked in. - * @returns {Object} Returns a redux action with the properties type, id and checkinComment. + * @returns {Object} Returns a redux action with the properties type, id and checkinComment. */ export const CheckIn = (id: number, checkInComment: string = '') => ({ type: 'CHECKIN_CONTENT_REQUEST', @@ -295,7 +295,7 @@ export module Actions { /** * Action creator for the step when a Content is checked in successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const CheckInSuccess = (response: any) => ({ type: 'CHECKIN_CONTENT_SUCCESS', @@ -304,7 +304,7 @@ export module Actions { /** * Action creator for the step when checking out a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const CheckInFailure = (error: any) => ({ type: 'CHECKIN_CONTENT_FAILURE', @@ -313,7 +313,7 @@ export module Actions { /** * Action creator for publishing a Content in the Content Repository. * @param id {number} Id of the content that should be published. - * @returns {Object} Returns a redux action with the properties type and id. + * @returns {Object} Returns a redux action with the properties type and id. */ export const Publish = (id: number) => ({ type: 'PUBLISH_CONTENT_REQUEST', @@ -322,7 +322,7 @@ export module Actions { /** * Action creator for the step when a Content is published successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const PublishSuccess = (response: any) => ({ type: 'PUBLISH_CONTENT_SUCCESS', @@ -331,7 +331,7 @@ export module Actions { /** * Action creator for the step when publishing a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const PublishFailure = (error: any) => ({ type: 'PUBLISH_CONTENT_FAILURE', @@ -340,7 +340,7 @@ export module Actions { /** * Action creator for approving a Content in the Content Repository. * @param id {number} Id of the content that should be approved. - * @returns {Object} Returns a redux action with the properties type and id. + * @returns {Object} Returns a redux action with the properties type and id. */ export const Approve = (id: number) => ({ type: 'APPROVE_CONTENT_REQUEST', @@ -349,7 +349,7 @@ export module Actions { /** * Action creator for the step when a Content is approved successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const ApproveSuccess = (response: any) => ({ type: 'APPROVE_CONTENT_SUCCESS', @@ -358,7 +358,7 @@ export module Actions { /** * Action creator for the step when approving a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const ApproveFailure = (error: any) => ({ type: 'APPROVE_CONTENT_FAILURE', @@ -368,7 +368,7 @@ export module Actions { * Action creator for rejecting a Content in the Content Repository. * @param id {number} Id of the content that should be rejected. * @param rejectReason {string} Reason of rejecting. - * @returns {Object} Returns a redux action with the properties type, rejectReason and id. + * @returns {Object} Returns a redux action with the properties type, rejectReason and id. */ export const Reject = (id: number, rejectReason: string = '') => ({ type: 'REJECT_CONTENT_REQUEST', @@ -378,7 +378,7 @@ export module Actions { /** * Action creator for the step when a Content is rejected successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const RejectSuccess = (response: any) => ({ type: 'REJECT_CONTENT_SUCCESS', @@ -387,7 +387,7 @@ export module Actions { /** * Action creator for the step when rejecting a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const RejectFailure = (error: any) => ({ type: 'REJECT_CONTENT_FAILURE', @@ -396,7 +396,7 @@ export module Actions { /** * Action creator for undoing checkout on a Content in the Content Repository. * @param id {number} Id of the content that should be checked in. - * @returns {Object} Returns a redux action with the properties type and id. + * @returns {Object} Returns a redux action with the properties type and id. */ export const UndoCheckout = (id: number) => ({ type: 'UNDOCHECKOUT_CONTENT_REQUEST', @@ -405,7 +405,7 @@ export module Actions { /** * Action creator for the step when a Content is checked-in successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const UndoCheckoutSuccess = (response: any) => ({ type: 'UNDOCHECKOUT_CONTENT_SUCCESS', @@ -414,7 +414,7 @@ export module Actions { /** * Action creator for the step when undoing checkout on a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const UndoCheckoutFailure = (error: any) => ({ type: 'UNDOCHECKOUT_CONTENT_FAILURE', @@ -423,7 +423,7 @@ export module Actions { /** * Action creator for undoing checkout on a Content in the Content Repository. * @param id {number} Id of the content that should be checked in. - * @returns {Object} Returns a redux action with the properties type and id. + * @returns {Object} Returns a redux action with the properties type and id. */ export const ForceUndoCheckout = (id: number) => ({ type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', @@ -432,7 +432,7 @@ export module Actions { /** * Action creator for the step when a Content is checked-in successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const ForceUndoCheckoutSuccess = (response: any) => ({ type: 'FORCEUNDOCHECKOUT_CONTENT_SUCCESS', @@ -441,7 +441,7 @@ export module Actions { /** * Action creator for the step when undoing checkout on a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const ForceUndoCheckoutFailure = (error: any) => ({ type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', @@ -451,7 +451,7 @@ export module Actions { * Action creator for restoring the version of a Content in the Content Repository. * @param id {number} Id of the content that should be checked in. * @param version {string} Specify which old version to restore - * @returns {Object} Returns a redux action with the properties type and id. + * @returns {Object} Returns a redux action with the properties type and id. */ export const RestoreVersion = (id: number, version: string) => ({ type: 'RESTOREVERSION_CONTENT_REQUEST', @@ -461,7 +461,7 @@ export module Actions { /** * Action creator for the step when a Content is restored to a previous version successfully. * @param response {any} JSON response of the ajax request. - * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. + * @returns {Object} Returns a redux action with the properties type and the normalized JSON response. */ export const RestoreVersionSuccess = (response: any) => ({ type: 'RESTOREVERSION_CONTENT_SUCCESS', @@ -470,7 +470,7 @@ export module Actions { /** * Action creator for the step when restoring a previous version of a Content is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const RestoreVersionFailure = (error: any) => ({ type: 'RESTOREVERSION_CONTENT_FAILURE', @@ -500,7 +500,7 @@ export module Actions { /** * Action creator for the step when login of a user is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const UserLoginFailure = (error: any) => ({ type: 'USER_LOGIN_FAILURE', @@ -525,7 +525,7 @@ export module Actions { /** * Action creator for the step when logging out of a user is failed. * @param error {any} The catched error object. - * @returns {Object} Returns a redux action with the properties type and the error message. + * @returns {Object} Returns a redux action with the properties type and the error message. */ export const UserLogoutFailure = (error: any) => ({ type: 'USER_LOGOUT_FAILURE', diff --git a/src/Schema.ts b/src/Schema.ts index 8ae123f..af1a9de 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -38,7 +38,7 @@ import { schema } from 'normalizr'; * * ![Normalized content](http://download.sensenet.com/aniko/sn7/jsapidocs/img/normalized-content.png) */ -export module Schemas{ +export module Schemas { /** * Schema of a Content. * From 3579c151fbbe3526236a1adbe597da9255dba8f2 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 12:33:06 +0200 Subject: [PATCH 10/26] chore(VS Code): Added build task and debug profile Added VS Code Build task and Test Debug profile --- .vscode/launch.json | 27 +++++++++++++++++++++++++++ .vscode/tasks.json | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d6a3d68 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug tests", + "runtimeExecutable": "mocha", + "windows": { + "runtimeExecutable": "mocha.cmd" + }, + "preLaunchTask": "build", + "runtimeArgs": [ + "--debug-brk", + "./dist/test/index.js" + ], + "program": "${workspaceRoot}\\test\\index.ts", + "outFiles": [ + "${workspaceRoot}\\dist\\**\\*.js" + ], + "port": 5858 + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..31effad --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "tasks": [ + { + "taskName": "build", + "args": [ + "run", + "build" + ] + } + ] +} \ No newline at end of file From c4d170686a600415e512af5ada9174da9d033a48 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 12:34:49 +0200 Subject: [PATCH 11/26] build(package.json): Updated dependencies, modified test & build npm scripts --- package.json | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 89837f4..55c95f6 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,19 @@ "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { + "lint": "node tslint --project ./tsconfig.json", + "clean": "rimraf dist", + "precommit": "npm run lint", "commit": "git-cz", "gulp": "gulp", - "test": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec dist/test/*Tests.js", + "pretest": "npm run build", + "test": "nyc mocha -p tsconfig.json dist/test/index.js", "check-coverage": "istanbul check-coverage ", "report-coverage": "cat ./coverage/lcov.info | codecov", + "prebuild": "npm run lint && npm run clean", + "build": "tsc", + "typedoc:md": "gulp typedoc:md", + "typedoc:html": "gulp typedoc", "semantic-release": "semantic-release pre && semantic-release post" }, "files": [ @@ -31,15 +39,29 @@ "bugs": { "url": "https://github.com/SenseNet/sn-redux/issues" }, + "nyc": { + "exclude": "dist/test/**/*.*", + "include": "dist/src/**/*.js", + "check-coverage": true, + "cache": true, + "all": true, + "reporter": [ + "lcov", + "text-summary", + "json" + ] + }, "homepage": "https://sensenet.com", "dependencies": { "@reactivex/rxjs": "^5.3.1", - "normalizr": "^3.2.2", + "nyc": "^10.3.0", "redux": "3.6.0", - "redux-thunk": "^2.2.0", "redux-logger": "2.8.2", "redux-observable": "^0.14.1", + "redux-thunk": "^2.2.0", + "rimraf": "^2.6.1", + "rxjs": "^5.3.1", "sn-client-js": "1.1.1-development.4" }, "devDependencies": { @@ -54,19 +76,13 @@ "cz-conventional-changelog": "2.0.0", "del": "2.2.2", "gulp": "3.9.1", - "gulp-istanbul": "1.1.1", - "gulp-mocha": "3.0.1", - "gulp-sourcemaps": "2.4.1", - "gulp-tslint": "7.1.0", "gulp-typedoc": "2.0.2", - "gulp-typescript": "3.1.5", "mocha": "3.3.0", "nock": "9.0.9", "normalizr": "3.2.2", "redux": "^3.6.0", "redux-mock-store": "1.2.3", "redux-observable": "0.14.1", - "remap-istanbul": "0.9.1", "semantic-release": "^6.3.2", "tslint": "5.2.0", "typedoc": "0.6.0", From b8123e7a3df8c689e43fb79968a7ba640d6fa179 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 12:35:15 +0200 Subject: [PATCH 12/26] chore(gitignore): added .nyc_output to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 55b21d6..dba7f54 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ coverage documentation npm-debug.log debug.log -dist \ No newline at end of file +dist +.nyc_output \ No newline at end of file From f0aeeab35f6eba3e8bc281a012c8edb73c486959 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 12:36:26 +0200 Subject: [PATCH 13/26] refactor(Modified imports, namespaces, injected the Repository reference into epics): --- src/Epics.ts | 141 ++++++++++++++++++++++--------------------- src/Store.ts | 30 +++++---- test/ActionsTests.ts | 9 ++- test/EpicsTests.ts | 41 +++++++------ test/index.ts | 7 ++- 5 files changed, 126 insertions(+), 102 deletions(-) diff --git a/src/Epics.ts b/src/Epics.ts index 70784f9..5c8d9da 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -1,52 +1,54 @@ -import { ActionsObservable, combineEpics } from 'redux-observable'; -import * as Rx from '@reactivex/rxjs'; -import * as SN from 'sn-client-js'; import { Actions } from './Actions'; import { Reducers } from './Reducers'; -const { ajax } = Rx.Observable; +import { ActionsObservable, combineEpics } from 'redux-observable'; +import { Observable } from '@reactivex/rxjs'; +import { Repository, Content } from 'sn-client-js'; /** * Module for redux-observable Epics of the Sense/Net built-in OData actions. - * + * * _An Epic is the core primitive of [redux-observable](https://redux-observable.js.org). It is a function which takes a stream of actions and returns a stream of actions._ - * + * * Learn more about redux-observable Epics [here](https://redux-observable.js.org/docs/basics/Epics.html); - * + * * In Sense/Net's case it means that the action steps (for exmaple request, success, fail) or multiple actions can be combined into Epics. It's extremely useful if you have * to work with async action or you have a complex process with multiple steps that have to wait for each other like validation, multiple step saving, etc. - * + * * Following epics cover the CRUD operations and all the other built-in Sense/Net OData Actions. All of these Epics are combined into one root Epic. If you want to use them in * your application without any customization you don't have to do anything special, because it is set as default at the store creation, but if you want add you custom Epics to it * use combineEpics on Sense/Nets root Epic and yours. - * + * * ``` * import { combineEpics } from 'redux-observable'; * import { myCombinedEpics } from '../myApp/Epics'; * import { myRootReducer } from '../myApp/Reducers'; * import { rootEpic } from '../sn-redux/Epics'; - * + * * const myRootEpic = combinedEpics( * rootEpic, * myCombinedEpics * ); - * + * * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]); - * ``` + * ``` */ +type Repository = Repository.BaseRepository; + export module Epics { /** * Epic for fetching content from the Content Repository. It is related to three redux actions, returns the ```RequestContent``` action and sends the JSON response to the * ```ReceiveContent``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ReceiveContentFailure``` action. */ - export const fetchContentEpic = action$ => { + export const fetchContentEpic = (action$, store, dependencies?: { repository: Repository } ) => { return action$.ofType('FETCH_CONTENT_REQUEST') .mergeMap(action => { let params = `${action.filter}`; - return SN.ODataApiActionObservables.FetchContent(action.path, params) - .map((response) => Actions.ReceiveContent(response.response, params)) - .catch(error => Rx.Observable.of(Actions.ReceiveContentFailure(params, error))) + + return dependencies.repository.Contents.Fetch(action.path) + .map((response) => Actions.ReceiveContent(response, params)) + .catch(error => Observable.of(Actions.ReceiveContentFailure(params, error))) } ); } @@ -54,53 +56,54 @@ export module Epics { * Epic for creating a Content in the Content Repository. It is related to three redux actions, returns ```CreateContent``` action and sends the JSON response to the * ```CreateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CreateContentFailure``` action. */ - export const createContentEpic = action$ => { + export function createContentEpic(action$, store, dependencies?: { repository: Repository }) { return action$.ofType('CREATE_CONTENT_REQUEST') .mergeMap(action => { let content = action.content; content['__ContentType'] = content.Type; - return SN.ODataApiActionObservables.CreateContent(action.path, content) + return dependencies.repository.Contents.Create(action.path, content, action.contentType) .map(Actions.CreateContentSuccess) - .catch(error => Rx.Observable.of(Actions.CreateContentFailure(error))) + .catch(error => Observable.of(Actions.CreateContentFailure(error))) }) } /** * Epic for updating metadata of a Content in the Content Repository. It is related to three redux actions, returns ```UpdateContent``` action and sends the JSON response to the * ```UpdateContentSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UpdateContentFailure``` action. */ - export const updateContentEpic = (action$, store) => { + export const updateContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('UPDATE_CONTENT_REQUEST') .mergeMap(action => { - return SN.ODataApiActionObservables.PatchContent(action.id, action.fields) + return dependencies.repository.Contents.Patch(action.id, action.fields) .map(Actions.UpdateContentSuccess) - .catch(error => Rx.Observable.of(Actions.UpdateContentFailure(error))) + .catch(error => Observable.of(Actions.UpdateContentFailure(error))) }) } /** * Epic to delete a Content from the Content Repository. It is related to three redux actions, returns ```Delete``` action and sends the response to the * ```DeleteSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```DeleteFailure``` action. */ - export const deleteContentEpic = (action$, store) => { + export const deleteContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('DELETE_CONTENT_REQUEST') .mergeMap(action => { - return SN.ODataApiActionObservables.DeleteContent(action.id, action.permanently) + return dependencies.repository.Contents.Delete(action.id, action.permanently) .map((response) => { const state = store.getState(); const ids = Reducers.getIds(state.collection); return Actions.DeleteSuccess(ids.indexOf(action.id), action.id); }) - .catch(error => Rx.Observable.of(Actions.DeleteFailure(error))) + .catch(error => Observable.of(Actions.DeleteFailure(error))) }) } /** * Epic to delete multiple Content from the Content Repository. It is related to three redux actions, returns ```DeleteBatch``` action and sends the response to the * ```DeleteBatchSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```DeleteBatchFailure``` action. */ - export const deleteBatchEpic = (action$, store) => { + export const deleteBatchEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('DELETE_BATCH_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'DeleteBatch', path: action.path, isAction: true, requiredParams: ['paths'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'paths': action.ids, 'permanently': action.permanently } }) + return dependencies.repository.Contents.CreateCustomAction( + { name: 'DeleteBatch', path: action.path, isAction: true, requiredParams: ['paths'] }, + { data: { 'paths': action.ids, 'permanently': action.permanently } }) .map((response) => { const state = store.getState(); const ids = Reducers.getIds(state.collection); @@ -112,20 +115,19 @@ export module Epics { } return Actions.DeleteBatchSuccess(indexes); }) - .catch(error => Rx.Observable.of(Actions.DeleteBatchFailure(error))) + .catch(error => Observable.of(Actions.DeleteBatchFailure(error))) }) } /** * Epic to checkout a Content in the Content Repository. It is related to three redux actions, returns ```CheckOut``` action and sends the response to the * ```CheckOutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckOutFailure``` action. */ - export const checkoutContentEpic = (action$, store) => { + export const checkoutContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('CHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'CheckOut', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) + return dependencies.repository.Contents.CreateCustomAction({ name: 'CheckOut', id: action.id, isAction: true }) .map(Actions.CheckOutSuccess) - .catch(error => Rx.Observable.of(Actions.CheckOutFailure(error))) + .catch(error => Observable.of(Actions.CheckOutFailure(error))) }) } @@ -133,117 +135,118 @@ export module Epics { * Epic to checkin a Content in the Content Repository. It is related to three redux actions, returns ```CheckIn``` action and sends the response to the * ```CheckInSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```CheckInFailure``` action. */ - export const checkinContentEpic = (action$, store) => { + export const checkinContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('CHECKIN_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'CheckIn', id: action.id, isAction: true, params: ['checkInComment'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'checkInComments': action.checkInComment } }) + return dependencies.repository.Contents.CreateCustomAction( + { name: 'CheckIn', id: action.id, isAction: true, params: ['checkInComment'] }, + { data: { 'checkInComments': action.checkInComment } } + ) .map(Actions.CheckInSuccess) - .catch(error => Rx.Observable.of(Actions.CheckInFailure(error))) + .catch(error => Observable.of(Actions.CheckInFailure(error))) }) } /** * Epic to publish a Content in the Content Repository. It is related to three redux actions, returns ```Publish``` action and sends the response to the * ```PublishSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```PublishFailure``` action. */ - export const publishContentEpic = (action$, store) => { + export const publishContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('PUBLISH_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Publish', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) + return dependencies.repository.Contents.CreateCustomAction({ name: 'Publish', id: action.id, isAction: true }) .map(Actions.PublishSuccess) - .catch(error => Rx.Observable.of(Actions.PublishFailure(error))) + .catch(error => Observable.of(Actions.PublishFailure(error))) }) } /** * Epic to approve a Content in the Content Repository. It is related to three redux actions, returns ```Approve``` action and sends the response to the * ```ApproveSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ApproveFailure``` action. */ - export const approveContentEpic = (action$, store) => { + export const approveContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('APPROVE_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Approve', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) + return dependencies.repository.Contents.CreateCustomAction({ name: 'Approve', id: action.id, isAction: true }) .map(Actions.ApproveSuccess) - .catch(error => Rx.Observable.of(Actions.ApproveFailure(error))) + .catch(error => Observable.of(Actions.ApproveFailure(error))) }) } /** * Epic to reject a Content in the Content Repository. It is related to three redux actions, returns ```Reject``` action and sends the response to the * ```RejectSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RejectFailure``` action. */ - export const rejectContentEpic = (action$, store) => { + export const rejectContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('REJECT_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Reject', id: action.id, isAction: true, params: ['rejectReason'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'rejectReason': action.rejectReason ? action.rejectReason : '' } }) + return dependencies.repository.Contents.CreateCustomAction( + { name: 'Reject', id: action.id, isAction: true, params: ['rejectReason'] }, + { data: { 'rejectReason': action.rejectReason ? action.rejectReason : '' } } + ) .map(Actions.RejectSuccess) - .catch(error => Rx.Observable.of(Actions.RejectFailure(error))) + .catch(error => Observable.of(Actions.RejectFailure(error))) }) } /** * Epic to undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```UndoCheckout``` action and sends the response to the * ```UndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```UndoCheckoutFailure``` action. */ - export const undocheckoutContentEpic = (action$, store) => { + export const undocheckoutContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('UNDOCHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'UndoCheckout', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) + return dependencies.repository.Contents.CreateCustomAction({ name: 'UndoCheckout', id: action.id, isAction: true }) .map(Actions.UndoCheckoutSuccess) - .catch(error => Rx.Observable.of(Actions.UndoCheckoutFailure(error))) + .catch(error => Observable.of(Actions.UndoCheckoutFailure(error))) }) } /** * Epic to force undo checkout a Content in the Content Repository. It is related to three redux actions, returns ```ForceUndoCheckout``` action and sends the response to the * ```ForceUndoCheckoutSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```ForceUndoCheckoutFailure``` action. */ - export const forceundocheckoutContentEpic = (action$, store) => { + export const forceundocheckoutContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('FORCEUNDOCHECKOUT_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'ForceUndoCheckout', id: action.id, isAction: true }); - return SN.ODataApiActionObservables.CreateCustomAction(Action) + return dependencies.repository.Contents.CreateCustomAction({ name: 'ForceUndoCheckout', id: action.id, isAction: true }) .map(Actions.ForceUndoCheckoutSuccess) - .catch(error => Rx.Observable.of(Actions.ForceUndoCheckoutFailure(error))) + .catch(error => Observable.of(Actions.ForceUndoCheckoutFailure(error))) }) } /** * Epic to restore a version of a Content in the Content Repository. It is related to three redux actions, returns ```RestoreVersion``` action and sends the response to the * ```RestoreVersionSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```RestoreVersionFailure``` action. */ - export const restoreversionContentEpic = (action$, store) => { + export const restoreversionContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('RESTOREVERSION_CONTENT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'RestoreVersion', id: action.id, isAction: true, params: ['version'] }); - return SN.ODataApiActionObservables.CreateCustomAction(Action, { data: { 'version': action.version } }) + return dependencies.repository.Contents.CreateCustomAction( + { name: 'RestoreVersion', id: action.id, isAction: true, params: ['version'] }, + { data: { 'version': action.version } }) .map(Actions.RestoreVersionSuccess) - .catch(error => Rx.Observable.of(Actions.RestoreVersionFailure(error))) + .catch(error => Observable.of(Actions.RestoreVersionFailure(error))) }) } /** * Epic to login a user to a Sense/Net portal. It is related to three redux actions, returns ```LoginUser``` action and sends the response to the * ```LoginUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LoginUserFailure``` action. */ - export const userLoginEpic = (action$, store) => { + export const userLoginEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('USER_LOGIN_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Login', path: '/Root', isAction: true, requiredParams: ['username', 'password'], noCache: true }); - return SN.ODataApiActionObservables.Login(Action, { data: { 'username': action.userName, 'password': action.password } }) + return dependencies.repository.Authentication.Login(action.userName, action.password) + // const Action = new SN.ODataApi.CustomAction({ name: 'Login', path: '/Root', isAction: true, requiredParams: ['username', 'password'], noCache: true }); + // return SN.ODataApiActionObservables.Login(Action, { data: { 'username': action.userName, 'password': action.password } }) .map(Actions.UserLoginSuccess) - .catch(error => Rx.Observable.of(Actions.UserLoginFailure(error))) + .catch(error => Observable.of(Actions.UserLoginFailure(error))) }) } /** * Epic to logout a user from a Sense/Net portal. It is related to three redux actions, returns ```LogoutUser``` action and sends the response to the * ```LogoutUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LogoutUserFailure``` action. */ - export const userLogoutEpic = (action$, store) => { + export const userLogoutEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('USER_LOGOUT_REQUEST') .mergeMap(action => { - const Action = new SN.ODataApi.CustomAction({ name: 'Logout', path: '/Root', isAction: true, noCache: true }); - return SN.ODataApiActionObservables.Logout(Action, {}) + return dependencies.repository.Authentication.Logout() .map(Actions.UserLogoutSuccess) - .catch(error => Rx.Observable.of(Actions.UserLogoutFailure(error))) + .catch(error => Observable.of(Actions.UserLogoutFailure(error))) }) } /** diff --git a/src/Store.ts b/src/Store.ts index bb5a7d0..0175a58 100644 --- a/src/Store.ts +++ b/src/Store.ts @@ -3,28 +3,29 @@ import * as createLogger from 'redux-logger' import { createEpicMiddleware } from 'redux-observable'; import { Epics } from './Epics'; import { Reducers } from './Reducers'; +import { Repository } from 'sn-client-js'; /** * Module for configuring a store. - * + * * It is actually a redux based data store, that lets you keep your application data in on place, allows you to access (get and update) the application state or subscribe to its listeners. - * + * * Two middlewares are built-in: - * * [redux-observable](https://redux-observable.js.org/) is as RxJS 5-based middleware for Redux. It's needed to compose and cancel async actions to create side effects and more, + * * [redux-observable](https://redux-observable.js.org/) is as RxJS 5-based middleware for Redux. It's needed to compose and cancel async actions to create side effects and more, * so that your app are able to get or post data to Sense/Net Content Repository through OData with ajax requests. * * [redux-logger](https://github.com/evgenyrodionov/redux-logger) creates a detailed log on the dev toolbar console on all state changes. * You can add other middlewares too through the configureStore functions second param as an array of middlewares. But the built-in middlewares will be the part of the applied middleware group * in every way. - * + * * ``` * import * as React from "react"; * import * as ReactDOM from "react-dom"; * import Authentication from 'redux-authentication' * import { myRootReducer } from '../myApp/Reducers' * import { myRootEpic } from '../myApp/Epics' - * + * * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]); - * + * * ReactDOM.render( * , * document.getElementById("root") @@ -32,9 +33,11 @@ import { Reducers } from './Reducers'; * ``` */ export module Store { + /** * Method to create a Redux store that holds the application state. * @param {any} [rootReducer=Reducers.snApp] Root reducer of your application. + * @param {Repository.BaseRepository} The Sense/Net Repository * @param {any} [rootEpic=Epics.rootEpic] Root epic of your application. * @param {Array=} middlewares Array of middlewares. * @param {Object=} persistedState Persisted state. @@ -45,22 +48,27 @@ export module Store { * import Authentication from 'redux-authentication' * import { myRootReducer } from '../myApp/Reducers' * import { myRootEpic } from '../myApp/Epics' - * + * * const store = Store.configureStore(myRootReducer, myRootEpic, [Authentication]); - * + * * ReactDOM.render( * , * document.getElementById("root") * ); * ``` */ - export const configureStore = (rootReducer: any = Reducers.snApp, rootEpic?: any, middlewares?: Array, persistedState?: Object) => { + export const configureStore = (rootReducer: any = Reducers.snApp, rootEpic?: any, middlewares?: Array, persistedState?: Object, repository?: Repository.BaseRepository) => { let epicMiddleware; + + if (!repository) { + repository = new Repository.SnRepository(); + } + if (typeof rootEpic === 'undefined' || rootEpic === null) { - epicMiddleware = createEpicMiddleware(Epics.rootEpic); + epicMiddleware = createEpicMiddleware(Epics.fetchContentEpic, {dependencies: { repository } }); } else { - epicMiddleware = createEpicMiddleware(rootEpic); + epicMiddleware = createEpicMiddleware(rootEpic, {dependencies: {repository } }); } let middlewareArray = []; if (typeof middlewares === 'undefined' || middlewares === null) { diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index 181d677..b748656 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -1,7 +1,8 @@ /// -import * as SN from 'sn-client-js'; +import { ContentTypes } from 'sn-client-js'; import { Actions } from '../src/Actions' import * as Chai from 'chai'; +import { Content, Mocks } from "sn-client-js"; const expect = Chai.expect; describe('Actions', () => { @@ -33,7 +34,11 @@ describe('Actions', () => { }); }); describe('CreateContent', () => { - const content = SN.Content.Create('Article', { DisplayName: 'My content', Id: 123 }) + const content = new ContentTypes.Task({ + Id: 123, + Name: 'My Content', + DueDate: null + }, new Mocks.MockRepository()) it('should create an action to a create content request', () => { const expectedAction = { type: 'CREATE_CONTENT_REQUEST', diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index 4a954be..a2f3f95 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -4,11 +4,14 @@ import * as nock from 'nock'; import * as Chai from 'chai'; import configureMockStore from 'redux-mock-store'; import { createEpicMiddleware } from 'redux-observable'; -import * as SN from 'sn-client-js'; +import { Mocks, ContentTypes, HttpProviders } from 'sn-client-js'; import { Epics } from '../src/Epics' const expect = Chai.expect; describe('Epics', () => { + + let repo = new Mocks.MockRepository(); + let window = { 'siteUrl': 'https://daily.demo.sensenet.com' } @@ -17,11 +20,12 @@ describe('Epics', () => { }) describe('fetchContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.fetchContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.fetchContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { store = mockStore(); + (repo.httpProviderRef as Mocks.MockHttpProvider).setError('FETCH_CONTENT_FAILURE'); }); after(() => { @@ -44,7 +48,7 @@ describe('Epics', () => { }); describe('createContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.createContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.createContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -56,7 +60,10 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.createContentEpic); }); it('handles the error', () => { - const content = SN.Content.Create('Article', { DisplayName: 'My article' }) + const content = new ContentTypes.Task({ + Name: 'My Task', + DueDate: null + }, repo); store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content }); expect(store.getActions()).to.be.deep.eq( [{ @@ -72,7 +79,7 @@ describe('Epics', () => { }); describe('updateContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.updateContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.updateContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -100,7 +107,7 @@ describe('Epics', () => { }); describe('deleteContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.deleteContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.deleteContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -127,7 +134,7 @@ describe('Epics', () => { }); describe('deleteBatch Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.deleteBatchEpic); + const epicMiddleware = createEpicMiddleware(Epics.deleteBatchEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -155,7 +162,7 @@ describe('Epics', () => { }); describe('checkoutContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.checkoutContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.checkoutContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -181,7 +188,7 @@ describe('Epics', () => { }); describe('checkinContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.checkinContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.checkinContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -208,7 +215,7 @@ describe('Epics', () => { }); describe('publishContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.publishContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.publishContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -234,7 +241,7 @@ describe('Epics', () => { }); describe('approveContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.approveContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.approveContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -260,7 +267,7 @@ describe('Epics', () => { }); describe('rejectContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.rejectContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.rejectContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); beforeEach(() => { @@ -299,7 +306,7 @@ describe('Epics', () => { }); describe('undocheckoutContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.undocheckoutContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.undocheckoutContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -325,7 +332,7 @@ describe('Epics', () => { }); describe('forceundocheckoutContent Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.forceundocheckoutContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.forceundocheckoutContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -351,7 +358,7 @@ describe('Epics', () => { }); describe('restoreVersion Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.restoreversionContentEpic); + const epicMiddleware = createEpicMiddleware(Epics.restoreversionContentEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -378,7 +385,7 @@ describe('Epics', () => { }); describe('login Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.userLoginEpic); + const epicMiddleware = createEpicMiddleware(Epics.userLoginEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { @@ -406,7 +413,7 @@ describe('Epics', () => { }); describe('logout Epic', () => { let store; - const epicMiddleware = createEpicMiddleware(Epics.userLogoutEpic); + const epicMiddleware = createEpicMiddleware(Epics.userLogoutEpic, {dependencies: {repository: repo}}); const mockStore = configureMockStore([epicMiddleware]); before(() => { diff --git a/test/index.ts b/test/index.ts index 2026583..1735751 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1,4 +1,5 @@ -export * from './ActionsTests'; -export * from './EpicsTests'; -export * from './ReducersTests'; +import * as ActionsTests from './ActionsTests'; +import * as EpicsTests from './EpicsTests'; +import * as ReducersTests from './ReducersTests'; +export { ActionsTests, EpicsTests, ReducersTests }; From e7815e32dae55b9a81e1bc79715a651c64b8bfc3 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 14:23:40 +0200 Subject: [PATCH 14/26] test(EpicsTests): Fixed Logout and Login epics and tests --- src/Actions.ts | 4 ++-- src/Epics.ts | 12 ++++++++---- test/ActionsTests.ts | 2 +- test/EpicsTests.ts | 36 ++++++++---------------------------- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index 0ee1465..d028d16 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -129,7 +129,7 @@ export module Actions { * @param filter {string} String with the url params. * @returns {Object} Returns a redux action with the properties type, normalized response and filter. */ - export const ReceiveContent = (response: any, filter: string) => + export const ReceiveContent = (response: ODataApi.ODataCollectionResponse, filter: string) => ({ type: 'FETCH_CONTENT_SUCCESS', response: normalize(response.d.results, Schemas.arrayOfContent), @@ -495,7 +495,7 @@ export module Actions { */ export const UserLoginSuccess = (response: any) => ({ type: 'USER_LOGIN_SUCCESS', - response: response.response.d + response: response }) /** * Action creator for the step when login of a user is failed. diff --git a/src/Epics.ts b/src/Epics.ts index 5c8d9da..be46c65 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -48,7 +48,9 @@ export module Epics { return dependencies.repository.Contents.Fetch(action.path) .map((response) => Actions.ReceiveContent(response, params)) - .catch(error => Observable.of(Actions.ReceiveContentFailure(params, error))) + .catch(error => { + return Observable.of(Actions.ReceiveContentFailure(params, error)) + }) } ); } @@ -231,9 +233,11 @@ export module Epics { return action$.ofType('USER_LOGIN_REQUEST') .mergeMap(action => { return dependencies.repository.Authentication.Login(action.userName, action.password) - // const Action = new SN.ODataApi.CustomAction({ name: 'Login', path: '/Root', isAction: true, requiredParams: ['username', 'password'], noCache: true }); - // return SN.ODataApiActionObservables.Login(Action, { data: { 'username': action.userName, 'password': action.password } }) - .map(Actions.UserLoginSuccess) + .map(result => { return result ? + Actions.UserLoginSuccess(result) + : + Actions.UserLoginFailure({message: "Failed to log in."}); + }) .catch(error => Observable.of(Actions.UserLoginFailure(error))) }) } diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index b748656..e2e7684 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -22,7 +22,7 @@ describe('Actions', () => { response: { entities: {}, result: [] }, filter: "?$select=Id,Type&metadata=no" } - expect(Actions.ReceiveContent({ d: { results: [] } }, '?$select=Id,Type&metadata=no')).to.deep.equal(expectedAction) + expect(Actions.ReceiveContent({ d: { results: [], __count: 0 } }, '?$select=Id,Type&metadata=no')).to.deep.equal(expectedAction) }); it('should create an action to content fetch request failure', () => { const expectedAction = { diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index a2f3f95..4efbf59 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -1,22 +1,19 @@ -/// -import 'rxjs'; -import * as nock from 'nock'; import * as Chai from 'chai'; import configureMockStore from 'redux-mock-store'; import { createEpicMiddleware } from 'redux-observable'; -import { Mocks, ContentTypes, HttpProviders } from 'sn-client-js'; +import { Mocks, ContentTypes, HttpProviders, Authentication } from 'sn-client-js'; import { Epics } from '../src/Epics' const expect = Chai.expect; +import 'rxjs'; describe('Epics', () => { - let repo = new Mocks.MockRepository(); + let repo: Mocks.MockRepository = new Mocks.MockRepository(); + (repo.Authentication as Mocks.MockAuthService).stateSubject.next(Authentication.LoginState.Authenticated); - let window = { - 'siteUrl': 'https://daily.demo.sensenet.com' - } beforeEach(() => { - window['siteUrl'] = "https://daily.demo.sensenet.com"; + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'XMLHttpRequest is not supported by your browser'}); + }) describe('fetchContent Epic', () => { let store; @@ -25,11 +22,9 @@ describe('Epics', () => { before(() => { store = mockStore(); - (repo.httpProviderRef as Mocks.MockHttpProvider).setError('FETCH_CONTENT_FAILURE'); }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.fetchContentEpic); }); it('handles the error', () => { @@ -56,7 +51,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.createContentEpic); }); it('handles the error', () => { @@ -87,7 +81,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.updateContentEpic); }); it('handles the error', () => { @@ -115,7 +108,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.deleteContentEpic); }); it('handles the error', () => { @@ -142,7 +134,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.deleteBatchEpic); }); it('handles the error', () => { @@ -170,7 +161,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.checkoutContentEpic); }); it('handles the error', () => { @@ -196,7 +186,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.checkinContentEpic); }); it('handles the error', () => { @@ -223,7 +212,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.publishContentEpic); }); it('handles the error', () => { @@ -249,7 +237,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.approveContentEpic); }); it('handles the error', () => { @@ -275,7 +262,6 @@ describe('Epics', () => { }); afterEach(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.rejectContentEpic); }); it('handles the error', () => { @@ -314,7 +300,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.undocheckoutContentEpic); }); it('handles the error', () => { @@ -340,7 +325,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.forceundocheckoutContentEpic); }); it('handles the error', () => { @@ -366,7 +350,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.restoreversionContentEpic); }); it('handles the error', () => { @@ -393,7 +376,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.userLoginEpic); }); it('handles the error', () => { @@ -407,7 +389,7 @@ describe('Epics', () => { }, { type: 'USER_LOGIN_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' + message: 'Failed to log in.' }]); }) }); @@ -421,7 +403,6 @@ describe('Epics', () => { }); after(() => { - nock.cleanAll(); epicMiddleware.replaceEpic(Epics.userLogoutEpic); }); it('handles the error', () => { @@ -434,8 +415,7 @@ describe('Epics', () => { password: 'alba' }, { - type: 'USER_LOGOUT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' + type: 'USER_LOGOUT_SUCCESS' }]); }) }); From 84726662fe0f74acd3766279af6ca92766661892 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 15:29:24 +0200 Subject: [PATCH 15/26] test(ActionsTests, EpicsTests): Fixed test cases --- test/ActionsTests.ts | 7 +- test/EpicsTests.ts | 162 +++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 86 deletions(-) diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index e2e7684..ac12c0b 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -435,12 +435,9 @@ describe('Actions', () => { it('should create an action to a user login success', () => { const expectedAction = { type: 'USER_LOGIN_SUCCESS', - response: { - Name: 'alba', - DisplayName: 'Alba Monday' - } + response: true } - expect(Actions.UserLoginSuccess({ response: { d: { Name: 'alba', DisplayName: 'Alba Monday' } } })).to.deep.equal(expectedAction) + expect(Actions.UserLoginSuccess(true)).to.deep.equal(expectedAction) }); it('should create an action to a user login failure', () => { const expectedAction = { diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index 4efbf59..99592a6 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -10,6 +10,7 @@ describe('Epics', () => { let repo: Mocks.MockRepository = new Mocks.MockRepository(); (repo.Authentication as Mocks.MockAuthService).stateSubject.next(Authentication.LoginState.Authenticated); + (repo.httpProviderRef as Mocks.MockHttpProvider).UseTimeout = false; beforeEach(() => { (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'XMLHttpRequest is not supported by your browser'}); @@ -57,7 +58,7 @@ describe('Epics', () => { const content = new ContentTypes.Task({ Name: 'My Task', DueDate: null - }, repo); + }, repo)['options']; store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content }); expect(store.getActions()).to.be.deep.eq( [{ @@ -164,16 +165,17 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.checkoutContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Checkout Content failed'}); store.dispatch({ type: 'CHECKOUT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'CHECKOUT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'CHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'CHECKOUT_CONTENT_REQUEST', + id: 111 + }, + { + type: 'CHECKOUT_CONTENT_FAILURE', + message: 'Checkout Content failed' + }]); }) }); describe('checkinContent Epic', () => { @@ -189,17 +191,20 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.checkinContentEpic); }); it('handles the error', () => { + + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Checkin Content failed'}); + store.dispatch({ type: 'CHECKIN_CONTENT_REQUEST', id: 111, checkinComment: 'comment' }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'CHECKIN_CONTENT_REQUEST', - id: 111, - checkinComment: 'comment' - }, - { - type: 'CHECKIN_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'CHECKIN_CONTENT_REQUEST', + id: 111, + checkinComment: 'comment' + }, + { + type: 'CHECKIN_CONTENT_FAILURE', + message: 'Checkin Content failed' + }]); }) }); describe('publishContent Epic', () => { @@ -215,16 +220,18 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.publishContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Publish Content failed'}); store.dispatch({ type: 'PUBLISH_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'PUBLISH_CONTENT_REQUEST', - id: 111 - }, - { - type: 'PUBLISH_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'PUBLISH_CONTENT_REQUEST', + id: 111 + }, + { + type: 'PUBLISH_CONTENT_FAILURE', + message: 'Publish Content failed' + }]); }) }); describe('approveContent Epic', () => { @@ -240,16 +247,17 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.approveContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Approve Content failed'}); store.dispatch({ type: 'APPROVE_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'APPROVE_CONTENT_REQUEST', - id: 111 - }, - { - type: 'APPROVE_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'APPROVE_CONTENT_REQUEST', + id: 111 + }, + { + type: 'APPROVE_CONTENT_FAILURE', + message: 'Approve Content failed' + }]); }) }); describe('rejectContent Epic', () => { @@ -265,30 +273,19 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.rejectContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Reject Content failed'}); store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111, rejectReason: 'reason' }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'REJECT_CONTENT_REQUEST', - id: 111, - rejectReason: 'reason' - }, - { - type: 'REJECT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'REJECT_CONTENT_REQUEST', + id: 111, + rejectReason: 'reason' + }, + { + type: 'REJECT_CONTENT_FAILURE', + message: 'Reject Content failed' + }]); }); - it('handles the error', () => { - store.dispatch({ type: 'REJECT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'REJECT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'REJECT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }) }); describe('undocheckoutContent Epic', () => { let store; @@ -303,6 +300,7 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.undocheckoutContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Undo Checkout failed'}); store.dispatch({ type: 'UNDOCHECKOUT_CONTENT_REQUEST', id: 111 }); expect(store.getActions()).to.be.deep.eq( [{ @@ -311,7 +309,7 @@ describe('Epics', () => { }, { type: 'UNDOCHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' + message: 'Undo Checkout failed' }]); }) }); @@ -328,16 +326,17 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.forceundocheckoutContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'ForceUndoCheckout failed'}); store.dispatch({ type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', id: 111 }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', - id: 111 - }, - { - type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'FORCEUNDOCHECKOUT_CONTENT_REQUEST', + id: 111 + }, + { + type: 'FORCEUNDOCHECKOUT_CONTENT_FAILURE', + message: 'ForceUndoCheckout failed' + }]); }) }); describe('restoreVersion Epic', () => { @@ -353,18 +352,19 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.restoreversionContentEpic); }); it('handles the error', () => { + (repo.httpProviderRef as Mocks.MockHttpProvider).setError({message: 'Restore failed'}); store.dispatch({ type: 'RESTOREVERSION_CONTENT_REQUEST', id: 111, version: 'A.1.0' }); - expect(store.getActions()).to.be.deep.eq( - [{ - type: 'RESTOREVERSION_CONTENT_REQUEST', - id: 111, - version: 'A.1.0' - }, - { - type: 'RESTOREVERSION_CONTENT_FAILURE', - message: 'XMLHttpRequest is not supported by your browser' - }]); - }) + expect(store.getActions()).to.be.deep.eq( + [{ + type: 'RESTOREVERSION_CONTENT_REQUEST', + id: 111, + version: 'A.1.0' + }, + { + type: 'RESTOREVERSION_CONTENT_FAILURE', + message: 'Restore failed' + }]); + }); }); describe('login Epic', () => { let store; From 99670a181298d6a0a75ae6ab31b6dea920ea586c Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 8 May 2017 15:39:37 +0200 Subject: [PATCH 16/26] build(Removed nyc coverage check, added publish:development script, updated sn-client-js dependency) --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 55c95f6..e00c47c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "1.1.0-beta.2", + "version": "1.1.0-development.1", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { @@ -17,7 +17,8 @@ "build": "tsc", "typedoc:md": "gulp typedoc:md", "typedoc:html": "gulp typedoc", - "semantic-release": "semantic-release pre && semantic-release post" + "semantic-release": "semantic-release pre && semantic-release post", + "publish:development": "npm publish --tag development" }, "files": [ "dist", @@ -42,7 +43,6 @@ "nyc": { "exclude": "dist/test/**/*.*", "include": "dist/src/**/*.js", - "check-coverage": true, "cache": true, "all": true, "reporter": [ @@ -62,7 +62,7 @@ "redux-thunk": "^2.2.0", "rimraf": "^2.6.1", "rxjs": "^5.3.1", - "sn-client-js": "1.1.1-development.4" + "sn-client-js": "1.1.1-development.6" }, "devDependencies": { "@types/chai": "3.4.35", From ef390de1ac2e4608f4cb9e963767d556fc017f80 Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 9 May 2017 17:35:03 +0200 Subject: [PATCH 17/26] fix(fetchContent epic API): --- src/Actions.ts | 8 ++++---- src/Epics.ts | 14 +++++++------- test/ActionsTests.ts | 15 ++++++++------- test/EpicsTests.ts | 9 +++++---- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index d028d16..8dd38ae 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -1,6 +1,6 @@ import { normalize } from 'normalizr'; import { Schemas } from './Schema'; -import { Content, ODataApi, ODataHelper } from 'sn-client-js'; +import { Content, ODataApi, ODataHelper, Repository } from 'sn-client-js'; /** * Module that contains the action creators. @@ -129,7 +129,7 @@ export module Actions { * @param filter {string} String with the url params. * @returns {Object} Returns a redux action with the properties type, normalized response and filter. */ - export const ReceiveContent = (response: ODataApi.ODataCollectionResponse, filter: string) => + export const ReceiveContent = (response: ODataApi.ODataCollectionResponse, filter: any) => ({ type: 'FETCH_CONTENT_SUCCESS', response: normalize(response.d.results, Schemas.arrayOfContent), @@ -141,7 +141,7 @@ export module Actions { * @param error {any} The catched error object. * @returns {Object} Returns a redux action with the properties type, filter and errormessage. */ - export const ReceiveContentFailure = (filter: string, error: any) => ({ + export const ReceiveContentFailure = (filter: any, error: any) => ({ type: 'FETCH_CONTENT_FAILURE', filter, message: error.message @@ -152,7 +152,7 @@ export module Actions { * @param content {Content} Content that have to be created in the Content Respository. * @returns {Object} Returns a redux action with the properties type, path of the parent and content. */ - export const CreateContent = (path: string, content: Content) => ({ type: 'CREATE_CONTENT_REQUEST', content, path }); + export const CreateContent = (path: string, contentType: { new(arg: K, arg2: Repository.IRepository): T}, contentOptions: K) => ({ type: 'CREATE_CONTENT_REQUEST', contentOptions, path, contentType }); /** * Action creator for the step when Content creation on the server ends successfully. * @param response {any} JSON response of the ajax request. diff --git a/src/Epics.ts b/src/Epics.ts index be46c65..615c7f7 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -3,7 +3,7 @@ import { Reducers } from './Reducers'; import { ActionsObservable, combineEpics } from 'redux-observable'; import { Observable } from '@reactivex/rxjs'; -import { Repository, Content } from 'sn-client-js'; +import { Repository, Content, ODataApi } from 'sn-client-js'; /** * Module for redux-observable Epics of the Sense/Net built-in OData actions. @@ -44,9 +44,11 @@ export module Epics { export const fetchContentEpic = (action$, store, dependencies?: { repository: Repository } ) => { return action$.ofType('FETCH_CONTENT_REQUEST') .mergeMap(action => { - let params = `${action.filter}`; - - return dependencies.repository.Contents.Fetch(action.path) + let params = new ODataApi.ODataParams({filter: `${action.filter}`}); + return dependencies.repository.Contents.Fetch(new ODataApi.ODataRequestOptions({ + path: action.path, + params + })) .map((response) => Actions.ReceiveContent(response, params)) .catch(error => { return Observable.of(Actions.ReceiveContentFailure(params, error)) @@ -61,9 +63,7 @@ export module Epics { export function createContentEpic(action$, store, dependencies?: { repository: Repository }) { return action$.ofType('CREATE_CONTENT_REQUEST') .mergeMap(action => { - let content = action.content; - content['__ContentType'] = content.Type; - return dependencies.repository.Contents.Create(action.path, content, action.contentType) + return dependencies.repository.Contents.Create(action.path, action.contentOptions, action.contentType) .map(Actions.CreateContentSuccess) .catch(error => Observable.of(Actions.CreateContentFailure(error))) }) diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index ac12c0b..02687aa 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -2,7 +2,7 @@ import { ContentTypes } from 'sn-client-js'; import { Actions } from '../src/Actions' import * as Chai from 'chai'; -import { Content, Mocks } from "sn-client-js"; +import { Content, Mocks, IContentOptions } from "sn-client-js"; const expect = Chai.expect; describe('Actions', () => { @@ -34,18 +34,19 @@ describe('Actions', () => { }); }); describe('CreateContent', () => { - const content = new ContentTypes.Task({ + const content = { Id: 123, Name: 'My Content', - DueDate: null - }, new Mocks.MockRepository()) + DueDate: null, + }; it('should create an action to a create content request', () => { const expectedAction = { type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/project', - content: content - } - expect(Actions.CreateContent(path, content)).to.deep.equal(expectedAction) + contentOptions: content, + contentType: ContentTypes.Task, + }; + expect(Actions.CreateContent(path, ContentTypes.Task, content as IContentOptions)).to.deep.equal(expectedAction) }); it('should create an action to create content success', () => { const expectedAction = { diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index 99592a6..1ac12a5 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -1,7 +1,7 @@ import * as Chai from 'chai'; import configureMockStore from 'redux-mock-store'; import { createEpicMiddleware } from 'redux-observable'; -import { Mocks, ContentTypes, HttpProviders, Authentication } from 'sn-client-js'; +import { Mocks, ContentTypes, HttpProviders, Authentication, ODataApi } from 'sn-client-js'; import { Epics } from '../src/Epics' const expect = Chai.expect; import 'rxjs'; @@ -29,15 +29,16 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.fetchContentEpic); }); it('handles the error', () => { - store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project' }); + store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project', filter: `isOf('Task') and Status eq %27Completed%27` }); expect(store.getActions()).to.be.deep.eq( [{ type: 'FETCH_CONTENT_REQUEST', - path: '/workspaces/Project' + path: '/workspaces/Project', + filter: `isOf('Task') and Status eq %27Completed%27` }, { type: 'FETCH_CONTENT_FAILURE', - filter: 'undefined', + filter: new ODataApi.ODataParams({filter: `isOf('Task') and Status eq %27Completed%27`, select: ["Id", "Type"]}), message: 'XMLHttpRequest is not supported by your browser' }]); }) From f1aac378e96ea5a33363c1cfe4b5006343daceec Mon Sep 17 00:00:00 2001 From: Gallay Lajos Date: Tue, 9 May 2017 18:58:44 +0200 Subject: [PATCH 18/26] fix(fetchContent epic): Fixed duplicated OData parameter parsing logic --- src/Actions.ts | 10 +++++----- src/Epics.ts | 2 +- test/ActionsTests.ts | 6 +++--- test/EpicsTests.ts | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index 8dd38ae..3554b07 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -121,7 +121,7 @@ export module Actions { export const RequestContent = (path: string, options: ODataApi.IODataParams = {}) => ({ type: 'FETCH_CONTENT_REQUEST', path, - filter: ODataHelper.buildUrlParamString(options) + options: options }); /** * Action creator for the step when a fetching request ends successfully. @@ -129,11 +129,11 @@ export module Actions { * @param filter {string} String with the url params. * @returns {Object} Returns a redux action with the properties type, normalized response and filter. */ - export const ReceiveContent = (response: ODataApi.ODataCollectionResponse, filter: any) => + export const ReceiveContent = (response: ODataApi.ODataCollectionResponse, params: any) => ({ type: 'FETCH_CONTENT_SUCCESS', response: normalize(response.d.results, Schemas.arrayOfContent), - filter + params }) /** * Action creator for the step when a fetching request failed. @@ -141,9 +141,9 @@ export module Actions { * @param error {any} The catched error object. * @returns {Object} Returns a redux action with the properties type, filter and errormessage. */ - export const ReceiveContentFailure = (filter: any, error: any) => ({ + export const ReceiveContentFailure = (params: any, error: any) => ({ type: 'FETCH_CONTENT_FAILURE', - filter, + params, message: error.message }); /** diff --git a/src/Epics.ts b/src/Epics.ts index 615c7f7..46f9992 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -44,7 +44,7 @@ export module Epics { export const fetchContentEpic = (action$, store, dependencies?: { repository: Repository } ) => { return action$.ofType('FETCH_CONTENT_REQUEST') .mergeMap(action => { - let params = new ODataApi.ODataParams({filter: `${action.filter}`}); + let params = new ODataApi.ODataParams(action.options || {}); return dependencies.repository.Contents.Fetch(new ODataApi.ODataRequestOptions({ path: action.path, params diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index 02687aa..fdf1c42 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -12,7 +12,7 @@ describe('Actions', () => { const expectedAction = { type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/project', - filter: "?$select=Id,Type&metadata=no" + options: {} } expect(Actions.RequestContent(path, {})).to.deep.equal(expectedAction) }); @@ -20,7 +20,7 @@ describe('Actions', () => { const expectedAction = { type: 'FETCH_CONTENT_SUCCESS', response: { entities: {}, result: [] }, - filter: "?$select=Id,Type&metadata=no" + params: "?$select=Id,Type&metadata=no" } expect(Actions.ReceiveContent({ d: { results: [], __count: 0 } }, '?$select=Id,Type&metadata=no')).to.deep.equal(expectedAction) }); @@ -28,7 +28,7 @@ describe('Actions', () => { const expectedAction = { type: 'FETCH_CONTENT_FAILURE', message: 'error', - filter: "?$select=Id,Type&metadata=no" + params: "?$select=Id,Type&metadata=no" } expect(Actions.ReceiveContentFailure('?$select=Id,Type&metadata=no', { message: 'error' })).to.deep.equal(expectedAction) }); diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index 1ac12a5..bad8ff8 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -29,16 +29,16 @@ describe('Epics', () => { epicMiddleware.replaceEpic(Epics.fetchContentEpic); }); it('handles the error', () => { - store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project', filter: `isOf('Task') and Status eq %27Completed%27` }); + store.dispatch({ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project', options: {} }); expect(store.getActions()).to.be.deep.eq( [{ type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/Project', - filter: `isOf('Task') and Status eq %27Completed%27` + options: {} }, { type: 'FETCH_CONTENT_FAILURE', - filter: new ODataApi.ODataParams({filter: `isOf('Task') and Status eq %27Completed%27`, select: ["Id", "Type"]}), + params: new ODataApi.ODataParams({select: ["Id", "Type"]}), message: 'XMLHttpRequest is not supported by your browser' }]); }) From 2055942cfc0b31f44fd01820cfd1576167e00ac6 Mon Sep 17 00:00:00 2001 From: gallayl Date: Wed, 10 May 2017 15:56:47 +0200 Subject: [PATCH 19/26] fix(Store): fixed ConfigureStore (createEpicMiddleware default epic to rootEpic) --- src/Store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Store.ts b/src/Store.ts index 0175a58..1f903f9 100644 --- a/src/Store.ts +++ b/src/Store.ts @@ -65,7 +65,7 @@ export module Store { } if (typeof rootEpic === 'undefined' || rootEpic === null) { - epicMiddleware = createEpicMiddleware(Epics.fetchContentEpic, {dependencies: { repository } }); + epicMiddleware = createEpicMiddleware(Epics.rootEpic, {dependencies: { repository } }); } else { epicMiddleware = createEpicMiddleware(rootEpic, {dependencies: {repository } }); From d20e45c94c0972a0b456c028df263b6ad588b343 Mon Sep 17 00:00:00 2001 From: gallayl Date: Wed, 10 May 2017 15:57:25 +0200 Subject: [PATCH 20/26] fix(FetchContent epic): Added optional type parameter to FetchContent epic --- src/Actions.ts | 5 +++-- src/Epics.ts | 2 +- test/ActionsTests.ts | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index 3554b07..52385a8 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -118,10 +118,11 @@ export module Actions { * @param options {OData.IODataParams} Represents an ODataOptions object based on the IODataOptions interface. Holds the possible url parameters as properties. * @returns {Object} Returns a redux action with the properties type, path and filter. */ - export const RequestContent = (path: string, options: ODataApi.IODataParams = {}) => ({ + export const RequestContent = (path: string, options: ODataApi.IODataParams = {}, contentType?: {new(...args): T}) => ({ type: 'FETCH_CONTENT_REQUEST', path, - options: options + options: options, + contentType }); /** * Action creator for the step when a fetching request ends successfully. diff --git a/src/Epics.ts b/src/Epics.ts index 46f9992..4ff2c15 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -48,7 +48,7 @@ export module Epics { return dependencies.repository.Contents.Fetch(new ODataApi.ODataRequestOptions({ path: action.path, params - })) + }), action.contentType || Content) .map((response) => Actions.ReceiveContent(response, params)) .catch(error => { return Observable.of(Actions.ReceiveContentFailure(params, error)) diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index fdf1c42..bfcc441 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -12,9 +12,10 @@ describe('Actions', () => { const expectedAction = { type: 'FETCH_CONTENT_REQUEST', path: '/workspaces/project', - options: {} + options: {}, + contentType: Content } - expect(Actions.RequestContent(path, {})).to.deep.equal(expectedAction) + expect(Actions.RequestContent(path, {}, Content)).to.deep.equal(expectedAction) }); it('should create an action to receive content', () => { const expectedAction = { From 3daa7e2fd9ff34928259daf4da7d4f2236b02851 Mon Sep 17 00:00:00 2001 From: gallayl Date: Thu, 11 May 2017 16:33:36 +0200 Subject: [PATCH 21/26] refactor(Session management): Refactored session management actions, epics and reducers in order to --- src/Actions.ts | 10 ++++++++- src/Epics.ts | 27 ++++++++++++++++++---- src/Reducers.ts | 25 +++++++++------------ test/ActionsTests.ts | 2 +- test/ReducersTests.ts | 52 ++++++++++++------------------------------- 5 files changed, 57 insertions(+), 59 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index 52385a8..d4f2dad 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -162,7 +162,7 @@ export module Actions { export const CreateContentSuccess = (response: any) => ({ type: 'CREATE_CONTENT_SUCCESS', - response: normalize(response.response.d, Schemas.content) + response: normalize(response.d, Schemas.content) }); /** * Action creator for the step when Content creation failed on the server. @@ -478,6 +478,14 @@ export module Actions { message: error.message }) + /** + * Action creator for check user state in a sense NET portal. + * @returns {Object} Returns a redux action with the properties. + */ + export const CheckLoginState = () => ({ + type: 'CHECK_LOGIN_STATE_REQUEST' + }) + /** * Action creator for login a user to a Sense/Net portal. * @param userName {string} Login name of the user. diff --git a/src/Epics.ts b/src/Epics.ts index 4ff2c15..1ff9b1e 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -3,7 +3,7 @@ import { Reducers } from './Reducers'; import { ActionsObservable, combineEpics } from 'redux-observable'; import { Observable } from '@reactivex/rxjs'; -import { Repository, Content, ODataApi } from 'sn-client-js'; +import { Repository, Content, ODataApi, Authentication } from 'sn-client-js'; /** * Module for redux-observable Epics of the Sense/Net built-in OData actions. @@ -225,10 +225,28 @@ export module Epics { .catch(error => Observable.of(Actions.RestoreVersionFailure(error))) }) } + /** - * Epic to login a user to a Sense/Net portal. It is related to three redux actions, returns ```LoginUser``` action and sends the response to the - * ```LoginUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LoginUserFailure``` action. - */ + * Epic to wait for the current login state to be initialized + */ + export const checkLoginStateEpic = (action$, store, dependencies?: { repository: Repository }) => { + return action$.ofType('CHECK_LOGIN_STATE_REQUEST') + .mergeMap(action => { + return dependencies.repository.Authentication.State.skipWhile(state => state === Authentication.LoginState.Pending) + .first() + .map(result => { return result === Authentication.LoginState.Authenticated ? + Actions.UserLoginSuccess(result) + : + Actions.UserLoginFailure({message: "Failed to log in."}); + }) + .catch(error => Observable.of(Actions.UserLoginFailure(error))) + }) + } + + /** + * Epic to login a user to a Sense/Net portal. It is related to three redux actions, returns ```LoginUser``` action and sends the response to the + * ```LoginUserSuccess``` action if the ajax request ended successfully or catches the error if the request failed and sends the error message to the ```LoginUserFailure``` action. + */ export const userLoginEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('USER_LOGIN_REQUEST') .mergeMap(action => { @@ -271,6 +289,7 @@ export module Epics { undocheckoutContentEpic, forceundocheckoutContentEpic, restoreversionContentEpic, + checkLoginStateEpic, userLoginEpic, userLogoutEpic ); diff --git a/src/Reducers.ts b/src/Reducers.ts index 4726c27..45f832b 100644 --- a/src/Reducers.ts +++ b/src/Reducers.ts @@ -1,5 +1,6 @@ import { normalize } from 'normalizr'; import { combineReducers } from 'redux'; +import { Authentication } from "sn-client-js"; /** * Module for defining Redux reducers. @@ -121,9 +122,7 @@ export module Reducers { } const userInitialState = { - data: null, - isLoading: false, - isAuthenticated: false, + loginState: Authentication.LoginState.Pending, errorMessage: '' } /** @@ -138,25 +137,22 @@ export module Reducers { switch (action.type) { case 'USER_LOGIN_REQUEST': case 'USER_LOGOUT_REQUEST': - return { ...userInitialState, isLoading: true, isAuthenticated: false } + return { ...userInitialState, loginState: Authentication.LoginState.Pending } case 'USER_LOGIN_SUCCESS': return { - data: { - userName: action.response.LoginName, - fullName: action.response.FullName - }, - isLoading: false, - isAuthenticated: true + loginState: Authentication.LoginState.Authenticated } case 'USER_LOGOUT_SUCCESS': - return userInitialState + return { + loginState: Authentication.LoginState.Unauthenticated + } case 'USER_LOGIN_FAILURE': return { - ...userInitialState, isLoading: false, errorMessage: action.message, isAuthenticated: false + ...userInitialState, errorMessage: action.message, loginState: Authentication.LoginState.Unauthenticated } case 'USER_LOGOUT_FAILURE': return { - ...userInitialState, isLoading: false, errorMessage: action.message, isAuthenticated: true + ...userInitialState, errorMessage: action.message, loginState: Authentication.LoginState.Unauthenticated } default: return state @@ -210,8 +206,7 @@ export module Reducers { }; export const getAuthenticationStatus = (state) => { - const user = state.user; - return user.isAuthenticated; + return state.user.loginState as Authentication.LoginState; } export const getAuthenticationError = (state) => { diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index bfcc441..28b7a55 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -64,7 +64,7 @@ describe('Actions', () => { result: 123 } } - expect(Actions.CreateContentSuccess({ response: { d: { DisplayName: 'My content', Id: 123 } } })).to.deep.equal(expectedAction) + expect(Actions.CreateContentSuccess({ d: { DisplayName: 'My content', Id: 123 } })).to.deep.equal(expectedAction) }); it('should create an action to content creation failure', () => { const expectedAction = { diff --git a/test/ReducersTests.ts b/test/ReducersTests.ts index 2d79736..4881645 100644 --- a/test/ReducersTests.ts +++ b/test/ReducersTests.ts @@ -2,6 +2,7 @@ import { Reducers } from '../src/Reducers'; import { Actions } from '../src/Actions'; import * as Chai from 'chai'; +import { Authentication } from "sn-client-js"; const expect = Chai.expect; describe('byId reducer', () => { @@ -95,79 +96,54 @@ describe('isFetching reducer', () => { describe('user reducer', () => { const userInitialState = { - data: null, - isLoading: false, - isAuthenticated: false, + loginState: Authentication.LoginState.Pending, errorMessage: '' }; - const user = { - data: { - userName: 'alba', - fullName: 'Alba Monday' - } - } it('should return the initial state', () => { expect(Reducers.user(undefined, {})).to.be.deep.equal(userInitialState); }); it('should handle USER_LOGIN_REQUEST', () => { expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_REQUEST' })).to.be.deep.equal( - { - data: null, - isLoading: true, - errorMessage: '', - isAuthenticated: false - } - ); + { + loginState: Authentication.LoginState.Pending, + errorMessage: '' + }); }); it('should handle USER_LOGIN_SUCCESS', () => { - expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_SUCCESS', response: { LoginName: 'alba', FullName: 'Alba Monday' } })).to.be.deep.equal( + expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_SUCCESS', response: true })).to.be.deep.equal( { - data: { - userName: 'alba', - fullName: 'Alba Monday' - }, - isLoading: false, - isAuthenticated: true + loginState: Authentication.LoginState.Authenticated, } ); }); it('should handle USER_LOGIN_FAILURE', () => { expect(Reducers.user(userInitialState, { type: 'USER_LOGIN_FAILURE', message: 'aaa' })).to.be.deep.equal( { - data: null, - isLoading: false, + loginState: Authentication.LoginState.Unauthenticated, errorMessage: 'aaa', - isAuthenticated: false } ); }); it('should handle USER_LOGOUT_REQUEST', () => { expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_REQUEST' })).to.be.deep.equal( { - data: null, - isLoading: true, + loginState: Authentication.LoginState.Pending, errorMessage: '', - isAuthenticated: false } ); }); it('should handle USER_LOGOUT_SUCCESS', () => { expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_SUCCESS' })).to.be.deep.equal( { - data: null, - isLoading: false, - errorMessage: '', - isAuthenticated: false + loginState: Authentication.LoginState.Unauthenticated, } ); }); it('should handle USER_LOGOUT_FAILURE', () => { expect(Reducers.user(userInitialState, { type: 'USER_LOGOUT_FAILURE', message: 'aaa' })).to.be.deep.equal( { - data: null, - isLoading: false, + loginState: Authentication.LoginState.Unauthenticated, errorMessage: 'aaa', - isAuthenticated: true } ); }); @@ -348,11 +324,11 @@ describe('getError', () => { describe('getAuthenticationStatus', () => { const state = { user: { - isAuthenticated: true + loginState: Authentication.LoginState.Authenticated } } it('should return true if the user is authenticated state', () => { - expect(Reducers.getAuthenticationStatus(state)).to.be.eq(true); + expect(Reducers.getAuthenticationStatus(state)).to.be.eq(Authentication.LoginState.Authenticated); }); }); From 58a4f60da7b59f02d2c4894c7c5ba984d277d11f Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 12 May 2017 15:56:10 +0200 Subject: [PATCH 22/26] refactor(updated UPDATE_CONTENT_REQUEST actions and epics to improve type safety): --- src/Actions.ts | 4 ++-- src/Epics.ts | 4 ++-- test/ActionsTests.ts | 11 +++++++---- test/EpicsTests.ts | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index d4f2dad..775de5f 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -153,7 +153,7 @@ export module Actions { * @param content {Content} Content that have to be created in the Content Respository. * @returns {Object} Returns a redux action with the properties type, path of the parent and content. */ - export const CreateContent = (path: string, contentType: { new(arg: K, arg2: Repository.IRepository): T}, contentOptions: K) => ({ type: 'CREATE_CONTENT_REQUEST', contentOptions, path, contentType }); + export const CreateContent = (path: string, contentType: { new(arg: K, arg2: Repository.IRepository): T}, contentOptions: K) => ({ type: 'CREATE_CONTENT_REQUEST', content: contentOptions, path, contentType }); /** * Action creator for the step when Content creation on the server ends successfully. * @param response {any} JSON response of the ajax request. @@ -179,7 +179,7 @@ export module Actions { * @param fields {Object} Object with the field value pairs that have to be modified. * @returns {Object} Returns a redux action with the properties type, id and fields. */ - export const UpdateContent = (id: number, fields: Object) => ({ type: 'UPDATE_CONTENT_REQUEST', id, fields }); + export const UpdateContent = (id: number, contentType: {new(...args): T}, fields: Partial) => ({ type: 'UPDATE_CONTENT_REQUEST', id, contentType, fields }); /** * Action creator for the step when Content modification on the server ends successfully. * @param response {any} JSON response of the ajax request. diff --git a/src/Epics.ts b/src/Epics.ts index 1ff9b1e..120eb3a 100644 --- a/src/Epics.ts +++ b/src/Epics.ts @@ -63,7 +63,7 @@ export module Epics { export function createContentEpic(action$, store, dependencies?: { repository: Repository }) { return action$.ofType('CREATE_CONTENT_REQUEST') .mergeMap(action => { - return dependencies.repository.Contents.Create(action.path, action.contentOptions, action.contentType) + return dependencies.repository.Contents.Create(action.path, action.content, action.contentType) .map(Actions.CreateContentSuccess) .catch(error => Observable.of(Actions.CreateContentFailure(error))) }) @@ -75,7 +75,7 @@ export module Epics { export const updateContentEpic = (action$, store, dependencies?: { repository: Repository }) => { return action$.ofType('UPDATE_CONTENT_REQUEST') .mergeMap(action => { - return dependencies.repository.Contents.Patch(action.id, action.fields) + return dependencies.repository.Contents.Patch(action.id, action.contentType, action.fields) .map(Actions.UpdateContentSuccess) .catch(error => Observable.of(Actions.UpdateContentFailure(error))) }) diff --git a/test/ActionsTests.ts b/test/ActionsTests.ts index 28b7a55..e35888c 100644 --- a/test/ActionsTests.ts +++ b/test/ActionsTests.ts @@ -44,10 +44,10 @@ describe('Actions', () => { const expectedAction = { type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/project', - contentOptions: content, + content, contentType: ContentTypes.Task, }; - expect(Actions.CreateContent(path, ContentTypes.Task, content as IContentOptions)).to.deep.equal(expectedAction) + expect(Actions.CreateContent(path, ContentTypes.Task, content as any)).to.deep.equal(expectedAction) }); it('should create an action to create content success', () => { const expectedAction = { @@ -79,9 +79,12 @@ describe('Actions', () => { const expectedAction = { type: 'UPDATE_CONTENT_REQUEST', id: 123, - fields: { Index: 2 } + fields: { Index: 2 }, + contentType: ContentTypes.Task } - expect(Actions.UpdateContent(123, { Index: 2 })).to.deep.equal(expectedAction) + expect(Actions.UpdateContent(123, ContentTypes.Task, { + Index: 2 + })).to.deep.equal(expectedAction) }); it('should create an action to update content success', () => { const expectedAction = { diff --git a/test/EpicsTests.ts b/test/EpicsTests.ts index bad8ff8..1e93e5c 100644 --- a/test/EpicsTests.ts +++ b/test/EpicsTests.ts @@ -1,7 +1,7 @@ import * as Chai from 'chai'; import configureMockStore from 'redux-mock-store'; import { createEpicMiddleware } from 'redux-observable'; -import { Mocks, ContentTypes, HttpProviders, Authentication, ODataApi } from 'sn-client-js'; +import { Mocks, ContentTypes, HttpProviders, Authentication, ODataApi, Content } from 'sn-client-js'; import { Epics } from '../src/Epics' const expect = Chai.expect; import 'rxjs'; @@ -60,12 +60,13 @@ describe('Epics', () => { Name: 'My Task', DueDate: null }, repo)['options']; - store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content }); + store.dispatch({ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', content, contentType: Content }); expect(store.getActions()).to.be.deep.eq( [{ type: 'CREATE_CONTENT_REQUEST', path: '/workspaces/Project', - content + content, + contentType: Content }, { type: 'CREATE_CONTENT_FAILURE', From ba27141c454aaae589980d52d72845f63ca3e75a Mon Sep 17 00:00:00 2001 From: gallayl Date: Fri, 12 May 2017 16:29:45 +0200 Subject: [PATCH 23/26] fix(modified UpdateContent to be able to work with a general Object parameter): --- package.json | 4 ++-- src/Actions.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e00c47c..684fa6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "1.1.0-development.1", + "version": "1.1.0-development.2", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { @@ -62,7 +62,7 @@ "redux-thunk": "^2.2.0", "rimraf": "^2.6.1", "rxjs": "^5.3.1", - "sn-client-js": "1.1.1-development.6" + "sn-client-js": "1.1.1-development.7" }, "devDependencies": { "@types/chai": "3.4.35", diff --git a/src/Actions.ts b/src/Actions.ts index 775de5f..f397ca8 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -179,7 +179,7 @@ export module Actions { * @param fields {Object} Object with the field value pairs that have to be modified. * @returns {Object} Returns a redux action with the properties type, id and fields. */ - export const UpdateContent = (id: number, contentType: {new(...args): T}, fields: Partial) => ({ type: 'UPDATE_CONTENT_REQUEST', id, contentType, fields }); + export const UpdateContent = (id: number, contentType: {new(...args): T} | object, fields: Partial) => ({ type: 'UPDATE_CONTENT_REQUEST', id, contentType, fields }); /** * Action creator for the step when Content modification on the server ends successfully. * @param response {any} JSON response of the ajax request. From bc0713ea21e5e43945f44245e959103b77bdbcb6 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 15 May 2017 10:19:18 +0200 Subject: [PATCH 24/26] docs(readme.md): Updated readme.md with the new methods how to create and configure a store --- README.md | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 4f8c331..454ae32 100644 --- a/README.md +++ b/README.md @@ -51,24 +51,35 @@ To install the latest stable version npm install --save sn-redux ``` -Set your Sense/Net portal's url with SetSiteUrl method +Create your sense NET portal Repository to use. You can configure your Store to use this repository, when calling Store.ConfigureStore -``` -import { SetSiteUrl } from 'sn-client-js'; +```ts +import { Repository } from 'sn-client-js'; -SetSiteUrl('https://daily.demo.sensenet.com'); -``` +let repository = new Repository.SnRepository({ + RepositoryUrl: 'http://path-to-your-portal.com', +}); -So that you can set the url of your Sense/Net portal that you want to communicate with. To enable your external app to send request against your Sense/Net portal change -your ```Portal.settings```. For further information about cross-origin resource sharing in Sense/Net check [this](http://wiki.sensenet.com/Cross-origin_resource_sharing#Origin_check) -article. +const store = Store.configureStore( + myRootReducer, + myRootEpic, // If not set, the default will be 'Epics.rootEpic' + [middleware1, middleware2], // If not set, only the epicMiddleware will be used + persistedState, // Optional + repository // Optional. If not provided, a Repository with default values will be used + ); -Check your Sense/Net portal's web.config and if the ```ODataServiceToken``` is set, use the ```SetServiceToken()``` method to set the same service token on client side. ``` -import { SetServiceToken } from 'sn-client-js'; -SetServiceToken('myservicetoken'); +To enable your external app to send request against your Sense/Net portal change your ```Portal.settings```. For further information about cross-origin resource sharing in Sense/Net check [this](http://wiki.sensenet.com/Cross-origin_resource_sharing#Origin_check) article. + +Check your Sense/Net portal's web.config and if the ```ODataServiceToken``` is set, you can pass to your Repository as a config value on client side. + +```ts +let repository = new Repository.SnRepository({ + RepositoryUrl: 'http://path-to-your-portal.com', + ODataToken: 'MyODataServiceToken' +}); ``` ## Import @@ -94,22 +105,17 @@ store.dispatch(Actions.Delete(123, false)); Building the project, running all the unit tests and the ts linter and get the code coverage report, use: ``` -gulp +npm run build ``` ## Running tests -To execute all unit tests, use: +To execute all unit tests and generate coverage reports, use: ``` -gulp test +npm t ``` -## Generatings code coverage report - -``` -gulp test:coverage -``` ## Examples From 4f358ceb0bccbda549e158c5d64798440be4124f Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 15 May 2017 10:59:38 +0200 Subject: [PATCH 25/26] fix(nyc config): fixed nyc config scope (excluded sn-redux.js) --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 684fa6c..f74b667 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "commit": "git-cz", "gulp": "gulp", "pretest": "npm run build", - "test": "nyc mocha -p tsconfig.json dist/test/index.js", + "test": "nyc mocha dist/test/index.js", "check-coverage": "istanbul check-coverage ", "report-coverage": "cat ./coverage/lcov.info | codecov", "prebuild": "npm run lint && npm run clean", @@ -41,9 +41,9 @@ "url": "https://github.com/SenseNet/sn-redux/issues" }, "nyc": { - "exclude": "dist/test/**/*.*", - "include": "dist/src/**/*.js", "cache": true, + "include": "dist/src/**/*.*", + "exclude": "dist/src/**/sn-redux.js", "all": true, "reporter": [ "lcov", From e67909ac269fe48b2b9c513106f1f6baff1bd497 Mon Sep 17 00:00:00 2001 From: gallayl Date: Mon, 15 May 2017 14:52:05 +0200 Subject: [PATCH 26/26] chore(package.json): Bumped version --- gulpfile.js | 134 ++++++++++++++++++++------------------------------- package.json | 10 ++-- 2 files changed, 60 insertions(+), 84 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 0c8dbc6..252eb56 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,94 +1,66 @@ const gulp = require('gulp'); -const ts = require('gulp-typescript'); -const mocha = require('gulp-mocha'); -const sourcemaps = require('gulp-sourcemaps'); -const istanbul = require('gulp-istanbul'); -const remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul'); const typedoc = require("gulp-typedoc"); +var rename = require("gulp-rename"); const del = require('del'); const __coverageThreshold = 60; -const tsProject = ts.createProject('./tsconfig.json'); -const tslint = require("gulp-tslint"); - -gulp.task("build:lint", function () { - return gulp.src(["./**/*.ts", "!./node_modules/**/*", "!./test/**/*"]) - .pipe(tslint({ - configuration: { - rules: { - "variable-name": false, - "quotemark": [true, "single", "avoid-escape"], - "max-file-line-count": false - } - } - })) - .pipe(tslint.report()) -}); - -gulp.task('build:clean', function () { - return del([ - './dist', - './coverage', - './coverage-report' - ]); -}); - -gulp.task('build', ['build:clean'], function () { - return gulp.src([ - './src/**/*.ts', - './test/**/*.ts' - ], { base: '.' }) - .pipe(sourcemaps.init()) - .pipe(tsProject()) - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest('./dist')); -}) - -gulp.task('test:instrument', ['build'], function () { - return gulp.src('./dist/src/**/*.js') - .pipe(istanbul()) - .pipe(istanbul.hookRequire()); -}); - -gulp.task('test:cover', ['test:instrument'], function () { - return gulp.src('./dist/**/*Tests.js') - .pipe(mocha({ ui: 'bdd' })) - .pipe(istanbul.writeReports({ - reporters: ['json', 'html'] - })).on('end', remapCoverageFiles); +gulp.task("typedoc", function () { + return gulp + .src([ + "./src/**/*.ts", + "!./src/**/index.ts", + "!./src/SN.ts", + "!./src/SN.d.ts" + ]) + .pipe(typedoc({ + module: "commonjs", + target: "es2015", + includeDeclarations: false, + out: "./documentation/html", + name: "sn-client-js", + theme: "default", + ignoreCompilerErrors: true, + version: true, + mode: "modules", + readme: "sn-client-js/README.md", + excludeExternals: true, + excludePrivate: true, + includes: "docs", + experimentalDecorators: true + })); }); -function remapCoverageFiles() { - return gulp.src('./coverage/coverage-final.json') - .pipe(remapIstanbul({ - basePath: '.', - reports: { - 'html': './coverage', - 'text-summary': null, - 'lcovonly': './coverage/lcov.info' - } - })); -} -gulp.task("typedoc", function () { +gulp.task("typedoc:md:generate", function () { return gulp - .src(["src/*.ts", "!src/sn-redux.ts"]) + .src([ + "./src/**/*.ts", + "!./src/**/index.ts", + "!./src/SN.ts", + "!./src/SN.d.ts" + ]) .pipe(typedoc({ - module: "commonjs", - target: "es2015", - includeDeclarations: false, - out: "./documentation", - name: "sn-redux", - theme: "default", - ignoreCompilerErrors: true, - version: true, - readme: "sn-redux/README.md", - excludeExternals: true, - excludePrivate: true, - includes: "docs" - })); + module: "commonjs", + target: "es2015", + includeDeclarations: false, + out: "./documentation/markdown", + name: "sn-client-js", + theme: "node_modules/typedoc-md-theme/bin", + ignoreCompilerErrors: true, + version: true, + mode: "modules", + readme: "sn-client-js/README.md", + excludeExternals: true, + excludePrivate: true, + includes: "docs" + })); }); -gulp.task('test', ['test:cover']); -gulp.task('default', ['build:lint', 'build', 'test']); \ No newline at end of file +gulp.task('typedoc:md', ['typedoc:md:generate'], ()=>{ + gulp.src('./documentation/markdown/**/*.*') + .pipe(rename((path)=>{ + path.extname= path.extname == '.html' ? '.md' : path.extname + })) + .pipe(gulp.dest('documentation/markdown_renamed')) +}); \ No newline at end of file diff --git a/package.json b/package.json index f74b667..af903f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sn-redux", - "version": "1.1.0-development.2", + "version": "2.0.0-RC.1", "description": "A set of redux actions, reducers and redux-ovbservable epics for Sense/Net ECM", "main": "dist/src/sn-redux.js", "scripts": { @@ -23,7 +23,8 @@ "files": [ "dist", "src", - "test" + "test", + "documentation" ], "repository": { "type": "git", @@ -62,7 +63,7 @@ "redux-thunk": "^2.2.0", "rimraf": "^2.6.1", "rxjs": "^5.3.1", - "sn-client-js": "1.1.1-development.7" + "sn-client-js": "^2.0.0-RC.1" }, "devDependencies": { "@types/chai": "3.4.35", @@ -76,6 +77,7 @@ "cz-conventional-changelog": "2.0.0", "del": "2.2.2", "gulp": "3.9.1", + "gulp-rename": "^1.2.2", "gulp-typedoc": "2.0.2", "mocha": "3.3.0", "nock": "9.0.9", @@ -86,6 +88,8 @@ "semantic-release": "^6.3.2", "tslint": "5.2.0", "typedoc": "0.6.0", + "typedoc-md-theme": "^1.0.1", + "typedoc-plugin-external-module-name": "^1.0.9", "typescript": "2.3.2" }, "czConfig": {