@zohodesk/library-platform 1.1.0-exp.1 → 1.1.0-exp.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/es/bc/zclient-actions/Constants.js +11 -0
  2. package/es/bc/zclient-actions/EventHandlers.js +1 -0
  3. package/es/bc/zlist/Properties.js +3 -0
  4. package/es/bc/zrecord/Constants.js +3 -1
  5. package/es/cc/table-connected/Properties.js +3 -0
  6. package/es/cc/table-list/Properties.js +32 -8
  7. package/es/cc/table-list/data-types/Header.js +8 -7
  8. package/es/cc/table-list/data-types/RowActionsConfig.js +1 -0
  9. package/es/cc/table-list/data-types/RowCursor.js +8 -0
  10. package/es/cc/table-list/row/Properties.js +16 -3
  11. package/es/desk-frameworks/table-connected/frameworks/TableConnectedFactory.js +4 -1
  12. package/es/desk-frameworks/table-connected/frameworks/TableConnectedView.js +4 -2
  13. package/es/desk-frameworks/table-connected/frameworks/__tests__/TableConnectedFactory.spec.js +453 -0
  14. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getAvailableFields.js +86 -0
  15. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getRecords.js +81 -0
  16. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/http-template/getSelectedFields.js +32 -0
  17. package/es/desk-frameworks/table-connected/frameworks/__tests__/mock/data-broker/index.js +11 -0
  18. package/es/library/behaviours/list-selection/domain/entities/ListItemSelection.js +29 -9
  19. package/es/library/custom-component/domain/entities/Component.js +8 -4
  20. package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +16 -6
  21. package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +10 -0
  22. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +7 -6
  23. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +9 -7
  24. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/ActionColumn.js +3 -2
  25. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +2 -4
  26. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/Headers.js +0 -4
  27. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/SelectAll.js +4 -4
  28. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Columns.js +2 -6
  29. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +13 -7
  30. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowActions.js +2 -1
  31. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowData.js +2 -4
  32. package/es/platform/data-broker/http-template/deleteRecord.js +1 -1
  33. package/es/platform/data-broker/http-template/deleteRecords.js +1 -1
  34. package/es/platform/data-broker/http-template/getAvailableFields.js +1 -1
  35. package/es/platform/data-broker/http-template/getClientActions.js +23 -0
  36. package/es/platform/data-broker/http-template/getRecords.js +1 -1
  37. package/es/platform/data-broker/http-template/getSelectedFields.js +1 -1
  38. package/es/platform/data-broker/http-template/updateRecord.js +1 -1
  39. package/es/platform/data-broker/index.js +3 -3
  40. package/es/platform/zclient-actions/Readme.md +38 -0
  41. package/es/platform/zclient-actions/adapters/controllers/AbstractController.js +8 -0
  42. package/es/platform/zclient-actions/adapters/controllers/ClientActionBehaviourExecutorController.js +27 -0
  43. package/es/platform/zclient-actions/adapters/controllers/FailureController.js +28 -0
  44. package/es/platform/zclient-actions/adapters/controllers/FetchStateStopController.js +21 -0
  45. package/es/platform/zclient-actions/adapters/controllers/MountController.js +25 -0
  46. package/es/platform/zclient-actions/adapters/controllers/NoContentController.js +23 -0
  47. package/es/platform/zclient-actions/adapters/controllers/SetClientActionsController.js +24 -0
  48. package/es/platform/zclient-actions/adapters/controllers/SuccessController.js +28 -0
  49. package/es/platform/zclient-actions/adapters/gateways/Repository.js +28 -0
  50. package/es/platform/zclient-actions/adapters/gateways/Service.js +35 -0
  51. package/es/platform/zclient-actions/adapters/presenters/Presenter.js +24 -0
  52. package/es/platform/zclient-actions/applications/entities-factory/ClientActionFactory.js +12 -0
  53. package/es/platform/zclient-actions/applications/entities-factory/ClientActionManagerFactory.js +10 -0
  54. package/es/platform/zclient-actions/applications/interfaces/InputDependencies.js +1 -0
  55. package/es/platform/zclient-actions/applications/interfaces/gateways/IRepository.js +1 -0
  56. package/es/platform/zclient-actions/applications/interfaces/gateways/IService.js +0 -0
  57. package/es/platform/zclient-actions/applications/interfaces/gateways/State.js +1 -0
  58. package/es/platform/zclient-actions/applications/interfaces/input/ExecuteActionBehaviourInputModel.js +1 -0
  59. package/es/platform/zclient-actions/applications/interfaces/input/FailureInputModel.js +1 -0
  60. package/es/platform/zclient-actions/applications/interfaces/input/FetchStateStopInputModel.js +1 -0
  61. package/es/platform/zclient-actions/applications/interfaces/input/InitializeInputModel.js +1 -0
  62. package/es/platform/zclient-actions/applications/interfaces/input/NoContentInputModel.js +1 -0
  63. package/es/platform/zclient-actions/applications/interfaces/input/SetClientActionsInputModel.js +1 -0
  64. package/es/platform/zclient-actions/applications/interfaces/input/SuccessInputModel.js +1 -0
  65. package/es/platform/zclient-actions/applications/interfaces/output/IPresenter.js +1 -0
  66. package/es/platform/zclient-actions/applications/usecases/AbstractUseCase.js +17 -0
  67. package/es/platform/zclient-actions/applications/usecases/ExecuteActionBehaviourUseCase.js +33 -0
  68. package/es/platform/zclient-actions/applications/usecases/FailureUseCase.js +22 -0
  69. package/es/platform/zclient-actions/applications/usecases/FetchStateStopUseCase.js +25 -0
  70. package/es/platform/zclient-actions/applications/usecases/InitializeUseCase.js +17 -0
  71. package/es/platform/zclient-actions/applications/usecases/NoContentUseCase.js +27 -0
  72. package/es/platform/zclient-actions/applications/usecases/SetClientActionsUseCase.js +21 -0
  73. package/es/platform/zclient-actions/applications/usecases/SuccessUseCase.js +22 -0
  74. package/es/platform/zclient-actions/domain/entities/ClientAction.js +57 -0
  75. package/es/platform/zclient-actions/domain/entities/ClientActionManager.js +141 -0
  76. package/es/platform/zclient-actions/domain/entities/ClientActions.js +54 -0
  77. package/es/platform/zclient-actions/domain/entities/EventMapping.js +32 -0
  78. package/es/platform/zclient-actions/domain/entities/EventMappings.js +15 -0
  79. package/es/platform/zclient-actions/domain/entities/GetClientActionsStrategy.js +44 -0
  80. package/es/platform/zclient-actions/domain/entities/UIComponentMapping.js +37 -0
  81. package/es/platform/zclient-actions/domain/entities/interfaces/BehaviourState.js +1 -0
  82. package/es/platform/zclient-actions/domain/entities/interfaces/ClientActionModel.js +1 -0
  83. package/es/platform/zclient-actions/domain/entities/interfaces/ClientActionsModel.js +1 -0
  84. package/es/platform/zclient-actions/domain/entities/interfaces/ComponentPropertiesModel.js +1 -0
  85. package/es/platform/zclient-actions/domain/entities/interfaces/EventMappingModel.js +1 -0
  86. package/es/platform/zclient-actions/domain/entities/interfaces/EventModel.js +1 -0
  87. package/es/platform/zclient-actions/domain/entities/interfaces/IAction.js +1 -0
  88. package/es/platform/zclient-actions/domain/entities/interfaces/IClientAction.js +0 -0
  89. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActionExecuteStrategy.js +0 -0
  90. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActionManager.js +0 -0
  91. package/es/platform/zclient-actions/domain/entities/interfaces/IClientActions.js +0 -0
  92. package/es/platform/zclient-actions/domain/entities/interfaces/IError.js +1 -0
  93. package/es/platform/zclient-actions/domain/entities/interfaces/IEvent.js +1 -0
  94. package/es/platform/zclient-actions/domain/entities/interfaces/IEventMapping.js +0 -0
  95. package/es/platform/zclient-actions/domain/entities/interfaces/IEventMappings.js +0 -0
  96. package/es/platform/zclient-actions/domain/entities/interfaces/IPayload.js +0 -0
  97. package/es/platform/zclient-actions/domain/entities/interfaces/IUIComponentMapping.js +0 -0
  98. package/es/platform/zclient-actions/domain/entities/interfaces/PayloadValueMappingModel.js +1 -0
  99. package/es/platform/zclient-actions/domain/entities/interfaces/PropsMeta.js +1 -0
  100. package/es/platform/zclient-actions/domain/entities/interfaces/StrategyMeta.js +1 -0
  101. package/es/platform/zclient-actions/domain/entities/interfaces/SubMeta.js +1 -0
  102. package/es/platform/zclient-actions/domain/entities/interfaces/UIComponentMappingModel.js +1 -0
  103. package/es/platform/zclient-actions/domain/entities/interfaces/UserDetailsModel.js +1 -0
  104. package/es/platform/zclient-actions/frameworks/ActionsHandlersFactory.js +47 -0
  105. package/es/platform/zclient-actions/frameworks/ClientActionBehaviourFactory.js +12 -0
  106. package/es/platform/zdata-broker/adapters/controllers/{ActionExecutorController.js → DataBrokerExecutorController.js} +1 -1
  107. package/es/platform/zdata-broker/frameworks/EventHandlersFactory.js +3 -3
  108. package/es/platform/zlist/adapters/gateways/Repository.js +3 -1
  109. package/es/platform/zlist/adapters/presenters/TableTranslator.js +31 -2
  110. package/es/platform/zlist/adapters/presenters/translators/ColumnAlignmentTranslator.js +11 -0
  111. package/es/platform/zlist/adapters/presenters/translators/ColumnSizeTranslator.js +23 -0
  112. package/es/platform/zlist/adapters/presenters/translators/Header.js +4 -3
  113. package/es/platform/zlist/applications/entities-factory/ListFactory.js +3 -2
  114. package/es/platform/zlist/domain/entities/List.js +12 -21
  115. package/package.json +21 -20
  116. package/es/platform/data-broker/http-template/getUIActions.js +0 -22
@@ -4,6 +4,7 @@ import ActionLocation from "../../../../../action-location/frameworks/ui/ActionL
4
4
  export default function RowActions(_ref) {
5
5
  let {
6
6
  hasActions,
7
+ columnWidth,
7
8
  type = '',
8
9
  actions
9
10
  } = _ref;
@@ -11,7 +12,7 @@ export default function RowActions(_ref) {
11
12
  // TODO: Need to fix the defaultValue from properties => CC
12
13
  if (hasActions) {
13
14
  return /*#__PURE__*/React.createElement(TableAction, {
14
- $ui_size: "medium"
15
+ $data_width: columnWidth
15
16
  }, /*#__PURE__*/React.createElement(ActionLocation, {
16
17
  type: type,
17
18
  actions: actions
@@ -4,9 +4,8 @@ import FieldComponent from "../field/FieldComponent";
4
4
  export default function RowData(_ref) {
5
5
  let {
6
6
  field,
7
- size,
7
+ width,
8
8
  alignment,
9
- resizedWidth,
10
9
  isFlexibleColumns
11
10
  } = _ref;
12
11
  let {
@@ -14,9 +13,8 @@ export default function RowData(_ref) {
14
13
  ...props
15
14
  } = field;
16
15
  return /*#__PURE__*/React.createElement(TableData, {
17
- $ui_size: size,
18
16
  $ui_align: alignment,
19
- $data_width: resizedWidth,
17
+ $data_width: width,
20
18
  $flag_flexible: isFlexibleColumns
21
19
  }, /*#__PURE__*/React.createElement(FieldComponent, {
22
20
  type: type,
@@ -1,6 +1,6 @@
1
1
  const deleteRecord = {
2
2
  name: 'records',
3
- api: '/api/v1/{{moduleName}}/moveToTrash',
3
+ api: '/{{servicePrefix}}/{{orgName}}/api/v1/{{moduleName}}/moveToTrash',
4
4
  parameters: `{}`,
5
5
  type: 'POST',
6
6
  transformer: data => data,
@@ -1,6 +1,6 @@
1
1
  const deleteRecords = {
2
2
  name: 'records',
3
- api: '/api/v1/{{moduleName}}/moveToTrash',
3
+ api: '/{{servicePrefix}}/{{orgName}}/api/v1/{{moduleName}}/moveToTrash',
4
4
  parameters: `{}`,
5
5
  type: 'POST',
6
6
  transformer: data => data,
@@ -1,6 +1,6 @@
1
1
  let getAvailableFields = {
2
2
  name: "availableFields",
3
- api: "/api/v1/views/availableFields",
3
+ api: "/{{servicePrefix}}/{{orgName}}/api/v1/views/availableFields",
4
4
  parameters: `{
5
5
  "departmentId":"{{departmentId}}",
6
6
  "module":"{{moduleName}}"
@@ -0,0 +1,23 @@
1
+ let getClientActions = {
2
+ name: "uiActions",
3
+ api: "/{{servicePrefix}}/{{orgName}}/api/v1/clientActions",
4
+ parameters: `{
5
+ "from":{{from}},
6
+ "limit":{{limit}},
7
+ "library": "{{library}}",
8
+ "module": "{{moduleName}}"
9
+ }`,
10
+ type: "GET",
11
+ transformer: data => data,
12
+ properties: {
13
+ modelName: {
14
+ required: true,
15
+ typeMetadata: {
16
+ schema: {
17
+ type: "string"
18
+ }
19
+ }
20
+ }
21
+ }
22
+ };
23
+ export default getClientActions;
@@ -1,6 +1,6 @@
1
1
  let getRecords = {
2
2
  name: 'records',
3
- api: '/api/v1/{{moduleName}}',
3
+ api: '/{{servicePrefix}}/{{orgName}}/api/v1/{{moduleName}}',
4
4
  parameters: `{
5
5
  "viewId":"{{viewId}}",
6
6
  "from":{{from}},
@@ -1,6 +1,6 @@
1
1
  let getSelectedFields = {
2
2
  name: "selectedFields",
3
- api: "/api/v1/views/{{viewId}}/selectedFields",
3
+ api: "/{{servicePrefix}}/{{orgName}}/api/v1/views/{{viewId}}/selectedFields",
4
4
  parameters: `{
5
5
  "departmentId":"{{departmentId}}"
6
6
  }`,
@@ -1,6 +1,6 @@
1
1
  const updateRecord = {
2
2
  name: 'records',
3
- api: '/api/v1/{{moduleName}}/{{recordId}}',
3
+ api: '/{{servicePrefix}}/{{orgName}}/api/v1/{{moduleName}}/{{recordId}}',
4
4
  parameters: `{}`,
5
5
  type: 'PATCH',
6
6
  transformer: data => data,
@@ -4,7 +4,7 @@ import updateRecord from "./http-template/updateRecord";
4
4
  import deleteRecords from "./http-template/deleteRecords";
5
5
  import getAvailableFields from "./http-template/getAvailableFields";
6
6
  import getSelectedFields from "./http-template/getSelectedFields";
7
- import getUIActions from "./http-template/getUIActions";
7
+ import getClientActions from "./http-template/getClientActions";
8
8
  import { RecordApiActionName } from "../../bc/zrecord/Constants";
9
9
  import deleteRecord from "./http-template/deleteRecord";
10
10
  let record = {
@@ -13,9 +13,9 @@ let record = {
13
13
  [RecordApiActionName.UPDATE_RECORD]: updateRecord,
14
14
  [RecordApiActionName.DELETE_RECORDS]: deleteRecords,
15
15
  [RecordApiActionName.DELETE_RECORD]: deleteRecord,
16
+ [RecordApiActionName.GET_CLIENTACTIONS]: getClientActions,
16
17
  getAvailableFields,
17
- getSelectedFields,
18
- getUIActions
18
+ getSelectedFields
19
19
  }
20
20
  };
21
21
  export default record; // let ticketsRecordSerice = createRecord(tickets, () => {});
@@ -0,0 +1,38 @@
1
+ Client Actions Behaviour
2
+
3
+
4
+ This behaviour will allows your library components to fetch client actions for your users.
5
+
6
+ # Implementation
7
+
8
+ ClientActionBehaviourFactory.create({ getClientActions: dataBroker.httpTemplates.getClientActions })
9
+
10
+ This above class should be implemeted in the behaviour props of your library components
11
+
12
+ The user needs to passdown the databroker into the behaviour in the format,
13
+
14
+ 1. getClientActions => Client Actions GET data broker template
15
+
16
+
17
+
18
+ # Integration inside component
19
+
20
+ We need to initialize or mount our behaviour with the component. Refer the eg used in List component below
21
+
22
+ private createClientActionsFetchAction(): ActionModel {
23
+ const props = this.createApiProps();
24
+ return {
25
+ type: CLIENTACTION_BEHAVIOUR_EXECUTE,
26
+ payload: {
27
+ actionName: 'getClientActions',
28
+ props,
29
+ apiName: 'clientActions'
30
+ }
31
+ };
32
+ }
33
+
34
+ The function createClientActionsFetchAction is called at Library component mount, which will mount client action behaviour and do the necessary processing.
35
+
36
+
37
+
38
+
@@ -0,0 +1,8 @@
1
+ export default class AbstractController {
2
+ constructor(service) {
3
+ this.service = service;
4
+ this.service = service;
5
+ this.handle = this.handle.bind(this);
6
+ }
7
+
8
+ }
@@ -0,0 +1,27 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class ClientActionBehaviourExecutorController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action,
8
+ dispatch
9
+ } = event;
10
+ const {
11
+ actionName,
12
+ props,
13
+ apiName
14
+ } = action.payload;
15
+ const {
16
+ executeActionBehaviourUseCase
17
+ } = this.service;
18
+ executeActionBehaviourUseCase.updateDependency(state, updateState);
19
+ executeActionBehaviourUseCase.execute({
20
+ dispatch,
21
+ apiName,
22
+ actionName,
23
+ props
24
+ });
25
+ }
26
+
27
+ }
@@ -0,0 +1,28 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class FailureController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action,
8
+ dispatch
9
+ } = event;
10
+ const {
11
+ metaData,
12
+ payload
13
+ } = action;
14
+ const {
15
+ error
16
+ } = payload;
17
+ const {
18
+ failureUseCase
19
+ } = this.service;
20
+ failureUseCase.updateDependency(state, updateState);
21
+ failureUseCase.execute({
22
+ dispatch,
23
+ error,
24
+ metaData
25
+ });
26
+ }
27
+
28
+ }
@@ -0,0 +1,21 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class FetchStateStopController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action
8
+ } = event;
9
+ const {
10
+ metaData
11
+ } = action;
12
+ const {
13
+ fetchStateStopUseCase
14
+ } = this.service;
15
+ fetchStateStopUseCase.updateDependency(state, updateState);
16
+ fetchStateStopUseCase.execute({
17
+ metaData
18
+ });
19
+ }
20
+
21
+ }
@@ -0,0 +1,25 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export default class MountController {
4
+ constructor(recordApis, service) {
5
+ this.recordApis = recordApis;
6
+ this.service = service;
7
+
8
+ _defineProperty(this, "handle", event => {
9
+ const {
10
+ state,
11
+ updateState,
12
+ dispatch
13
+ } = event;
14
+ const {
15
+ initializeUseCase
16
+ } = this.service;
17
+ initializeUseCase.updateDependency(state, updateState);
18
+ initializeUseCase.execute({
19
+ dispatch,
20
+ apiTemplates: this.recordApis
21
+ });
22
+ });
23
+ }
24
+
25
+ }
@@ -0,0 +1,23 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class NoContentController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action,
8
+ dispatch
9
+ } = event;
10
+ const {
11
+ metaData
12
+ } = action;
13
+ const {
14
+ noContentUseCase
15
+ } = this.service;
16
+ noContentUseCase.updateDependency(state, updateState);
17
+ noContentUseCase.execute({
18
+ dispatch,
19
+ metaData
20
+ });
21
+ }
22
+
23
+ }
@@ -0,0 +1,24 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class SetClientActionsController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action
8
+ } = event;
9
+ const {
10
+ payload
11
+ } = action;
12
+ const {
13
+ clientActions
14
+ } = payload;
15
+ const {
16
+ setClientActionsUseCase
17
+ } = this.service;
18
+ setClientActionsUseCase.updateDependency(state, updateState);
19
+ setClientActionsUseCase.execute({
20
+ clientActions
21
+ });
22
+ }
23
+
24
+ }
@@ -0,0 +1,28 @@
1
+ import AbstractController from "./AbstractController";
2
+ export default class SuccessController extends AbstractController {
3
+ handle(event) {
4
+ const {
5
+ state,
6
+ updateState,
7
+ action,
8
+ dispatch
9
+ } = event;
10
+ const {
11
+ metaData,
12
+ payload
13
+ } = action;
14
+ const {
15
+ response
16
+ } = payload;
17
+ const {
18
+ successUseCase
19
+ } = this.service;
20
+ successUseCase.updateDependency(state, updateState);
21
+ successUseCase.execute({
22
+ dispatch,
23
+ response,
24
+ metaData
25
+ });
26
+ }
27
+
28
+ }
@@ -0,0 +1,28 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import ClientActionManagerFactory from "../../applications/entities-factory/ClientActionManagerFactory";
4
+ export default class Repository {
5
+ constructor() {
6
+ _defineProperty(this, "state", void 0);
7
+ }
8
+
9
+ init(state) {
10
+ this.state = state;
11
+ }
12
+
13
+ getClientActionsManagerEntity() {
14
+ const {
15
+ zclientAction
16
+ } = this.state.behaviours;
17
+ const {
18
+ clientActions = [],
19
+ isFetching
20
+ } = zclientAction;
21
+ const clientActionManager = ClientActionManagerFactory.create({
22
+ data: clientActions,
23
+ isFetching
24
+ });
25
+ return clientActionManager;
26
+ }
27
+
28
+ }
@@ -0,0 +1,35 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import InitializeUseCase from "../../applications/usecases/InitializeUseCase";
4
+ import ExecuteActionBehaviourUseCase from "../../applications/usecases/ExecuteActionBehaviourUseCase";
5
+ import FailureUseCase from "../../applications/usecases/FailureUseCase";
6
+ import SuccessUseCase from "../../applications/usecases/SuccessUseCase";
7
+ import NoContentUseCase from "../../applications/usecases/NoContentUseCase";
8
+ import SetClientActionsUseCase from "../../applications/usecases/SetClientActionsUseCase";
9
+ import FetchStateStopUseCase from "../../applications/usecases/FetchStateStopUseCase";
10
+ export default class Service {
11
+ constructor(dependencies) {
12
+ _defineProperty(this, "initializeUseCase", void 0);
13
+
14
+ _defineProperty(this, "executeActionBehaviourUseCase", void 0);
15
+
16
+ _defineProperty(this, "failureUseCase", void 0);
17
+
18
+ _defineProperty(this, "successUseCase", void 0);
19
+
20
+ _defineProperty(this, "fetchStateStopUseCase", void 0);
21
+
22
+ _defineProperty(this, "noContentUseCase", void 0);
23
+
24
+ _defineProperty(this, "setClientActionsUseCase", void 0);
25
+
26
+ this.initializeUseCase = new InitializeUseCase(dependencies);
27
+ this.executeActionBehaviourUseCase = new ExecuteActionBehaviourUseCase(dependencies);
28
+ this.failureUseCase = new FailureUseCase(dependencies);
29
+ this.successUseCase = new SuccessUseCase(dependencies);
30
+ this.fetchStateStopUseCase = new FetchStateStopUseCase(dependencies);
31
+ this.noContentUseCase = new NoContentUseCase(dependencies);
32
+ this.setClientActionsUseCase = new SetClientActionsUseCase(dependencies);
33
+ }
34
+
35
+ }
@@ -0,0 +1,24 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export default class Presenter {
4
+ constructor() {
5
+ _defineProperty(this, "updateState", void 0);
6
+
7
+ _defineProperty(this, "state", void 0);
8
+ }
9
+
10
+ updateDependencies(state, updateState) {
11
+ this.updateState = updateState;
12
+ this.state = state;
13
+ }
14
+
15
+ updateClientAction(zclientAction) {
16
+ this.state = { ...this.state,
17
+ behaviours: { ...this.state.behaviours,
18
+ zclientAction
19
+ }
20
+ };
21
+ this.updateState(this.state);
22
+ }
23
+
24
+ }
@@ -0,0 +1,12 @@
1
+ import ClientAction from "../../domain/entities/ClientAction";
2
+ export default class ClientActionFactory {
3
+ static createSingleClientAction(clientActionModel) {
4
+ const clientAction = new ClientAction(clientActionModel);
5
+ return clientAction;
6
+ }
7
+
8
+ static createMultipleClientActions(data) {
9
+ return data.map(clientActionModel => new ClientAction(clientActionModel));
10
+ }
11
+
12
+ }
@@ -0,0 +1,10 @@
1
+ import ClientActionManager from "../../domain/entities/ClientActionManager";
2
+ import ClientActions from "../../domain/entities/ClientActions";
3
+ export default class ClientActionManagerFactory {
4
+ static create(clientActionsModel) {
5
+ const clientActions = new ClientActions(clientActionsModel);
6
+ const clientActionManager = new ClientActionManager(clientActions);
7
+ return clientActionManager;
8
+ }
9
+
10
+ }
@@ -0,0 +1,17 @@
1
+ class AbstractUseCase {
2
+ constructor(dependencies) {
3
+ this.dependencies = dependencies;
4
+ }
5
+
6
+ updateDependency(state, updateState) {
7
+ const {
8
+ repository,
9
+ presenter
10
+ } = this.dependencies;
11
+ repository.init(state);
12
+ presenter.updateDependencies(state, updateState);
13
+ }
14
+
15
+ }
16
+
17
+ export default AbstractUseCase;
@@ -0,0 +1,33 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class ExecuteActionBehaviourUseCase extends AbstractUseCase {
4
+ execute(input) {
5
+ const {
6
+ repository,
7
+ presenter
8
+ } = this.dependencies;
9
+ const {
10
+ props,
11
+ dispatch,
12
+ apiName,
13
+ actionName
14
+ } = input;
15
+ const recordManager = repository.getClientActionsManagerEntity();
16
+
17
+ if (!recordManager.isClientActionApiName(apiName)) {
18
+ return;
19
+ }
20
+
21
+ const metaData = recordManager.createFetchClientActionMeta(actionName, apiName, props);
22
+
23
+ if (recordManager.isGetClientActionsApi(actionName)) {
24
+ recordManager.fetchingStarted();
25
+ presenter.updateClientAction(recordManager.toObject());
26
+ }
27
+
28
+ dispatch(recordManager.createDataBrokerExecuteEvent(props, actionName, metaData));
29
+ }
30
+
31
+ }
32
+
33
+ export default ExecuteActionBehaviourUseCase;
@@ -0,0 +1,22 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class FailureUseCase extends AbstractUseCase {
4
+ execute(input) {
5
+ const {
6
+ repository
7
+ } = this.dependencies;
8
+ const {
9
+ dispatch,
10
+ metaData,
11
+ error
12
+ } = input;
13
+ const recordManager = repository.getClientActionsManagerEntity();
14
+ const events = recordManager.createFailureEvents(error, metaData);
15
+ events.forEach(event => {
16
+ dispatch(event);
17
+ });
18
+ }
19
+
20
+ }
21
+
22
+ export default FailureUseCase;
@@ -0,0 +1,25 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+
3
+ class FetchStateStopUseCase extends AbstractUseCase {
4
+ execute(input) {
5
+ const {
6
+ repository,
7
+ presenter
8
+ } = this.dependencies;
9
+ const {
10
+ metaData
11
+ } = input;
12
+ const {
13
+ actionName
14
+ } = metaData;
15
+ const recordManager = repository.getClientActionsManagerEntity();
16
+
17
+ if (recordManager.isGetClientActionsApi(actionName)) {
18
+ recordManager.fetchingFinished();
19
+ presenter.updateClientAction(recordManager.toObject());
20
+ }
21
+ }
22
+
23
+ }
24
+
25
+ export default FetchStateStopUseCase;
@@ -0,0 +1,17 @@
1
+ import AbstractUseCase from "./AbstractUseCase";
2
+ import { DATA_BROKER_REGISTER } from "../../../../bc/zdata-broker/Constants";
3
+ export default class InitializeUseCase extends AbstractUseCase {
4
+ execute(input) {
5
+ const {
6
+ apiTemplates,
7
+ dispatch
8
+ } = input;
9
+ dispatch({
10
+ type: DATA_BROKER_REGISTER,
11
+ payload: {
12
+ apiTemplates
13
+ }
14
+ });
15
+ }
16
+
17
+ }