@zohodesk/library-platform 1.1.9-exp.1 → 1.1.10

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 (145) hide show
  1. package/es/bc/field-validation/Constants.js +4 -0
  2. package/es/bc/field-validation/EventHandlers.js +1 -0
  3. package/es/bc/field-validation/Events.js +106 -0
  4. package/es/bc/field-validation/FieldTypes.js +20 -0
  5. package/es/bc/field-validation/Properties.js +11 -0
  6. package/es/bc/field-validation/index.js +5 -0
  7. package/es/cc/ephi-tag/Properties.js +1 -0
  8. package/es/cc/ephi-tag/index.js +1 -0
  9. package/es/cc/info-icon/Properties.js +10 -0
  10. package/es/cc/info-icon/index.js +1 -0
  11. package/es/{platform/app-context-behaviour → library/behaviours/field-validation}/adapters/controllers/AbstractController.js +4 -2
  12. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldController.js +32 -0
  13. package/es/library/behaviours/field-validation/adapters/controllers/ValidateFieldsController.js +31 -0
  14. package/es/library/behaviours/field-validation/adapters/gateway/Repository.js +23 -0
  15. package/es/library/behaviours/field-validation/adapters/gateway/Service.js +18 -0
  16. package/es/library/behaviours/field-validation/applications/interfaces/input/FieldData.js +17 -0
  17. package/es/library/behaviours/field-validation/applications/usecases/AbstractUseCase.js +15 -0
  18. package/es/library/behaviours/field-validation/applications/usecases/ValidateField.js +29 -0
  19. package/es/library/behaviours/field-validation/applications/usecases/ValidateFields.js +28 -0
  20. package/es/library/behaviours/field-validation/domain/FieldValidation.js +94 -0
  21. package/es/library/behaviours/field-validation/domain/field-vise-validations/BooleanValidation.js +28 -0
  22. package/es/library/behaviours/field-validation/domain/field-vise-validations/CurrencyValidation.js +49 -0
  23. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateTimeValidation.js +24 -0
  24. package/es/library/behaviours/field-validation/domain/field-vise-validations/DateValidation.js +24 -0
  25. package/es/library/behaviours/field-validation/domain/field-vise-validations/DecimalValidation.js +49 -0
  26. package/es/library/behaviours/field-validation/domain/field-vise-validations/EmailValidation.js +28 -0
  27. package/es/library/behaviours/field-validation/domain/field-vise-validations/IntegerValidation.js +39 -0
  28. package/es/library/behaviours/field-validation/domain/field-vise-validations/LookUpValidation.js +24 -0
  29. package/es/library/behaviours/field-validation/domain/field-vise-validations/MultiSelectValidation.js +26 -0
  30. package/es/library/behaviours/field-validation/domain/field-vise-validations/PercentValidation.js +28 -0
  31. package/es/library/behaviours/field-validation/domain/field-vise-validations/PhoneValidation.js +39 -0
  32. package/es/library/behaviours/field-validation/domain/field-vise-validations/PicklistValidation.js +24 -0
  33. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextAreaValidation.js +39 -0
  34. package/es/library/behaviours/field-validation/domain/field-vise-validations/TextBoxValidation.js +39 -0
  35. package/es/library/behaviours/field-validation/domain/field-vise-validations/URLValidation.js +28 -0
  36. package/es/library/behaviours/field-validation/domain/interfaces/FieldTypes.js +20 -0
  37. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsEnum.js +22 -0
  38. package/es/library/behaviours/field-validation/domain/interfaces/ValidationsMap.js +1 -0
  39. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateField.js +0 -0
  40. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDateTimeField.js +0 -0
  41. package/es/library/behaviours/field-validation/domain/interfaces/fields/IDecimalField.js +0 -0
  42. package/es/library/behaviours/field-validation/domain/interfaces/fields/IEmailField.js +0 -0
  43. package/es/library/behaviours/field-validation/domain/interfaces/fields/IIntegerField.js +0 -0
  44. package/es/library/behaviours/field-validation/domain/interfaces/fields/ILookUpField.js +0 -0
  45. package/es/library/behaviours/field-validation/domain/interfaces/fields/IMultiSelectField.js +0 -0
  46. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPercentField.js +0 -0
  47. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPhoneField.js +0 -0
  48. package/es/library/behaviours/field-validation/domain/interfaces/fields/IPicklistField.js +0 -0
  49. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextAreaField.js +0 -0
  50. package/es/library/behaviours/field-validation/domain/interfaces/fields/ITextBoxField.js +0 -0
  51. package/es/library/behaviours/field-validation/domain/interfaces/fields/IURLField.js +0 -0
  52. package/es/library/behaviours/field-validation/frameworks/ui/EventHandlerFactory.js +23 -0
  53. package/es/library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory.js +27 -0
  54. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/BooleanFieldValidation.test.js +137 -0
  55. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/CurrencyFieldValidation.test.js +228 -0
  56. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateFieldValidation.test.js +108 -0
  57. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DateTimeFieldValidation.test.js +108 -0
  58. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/DecimalFieldValidation.test.js +257 -0
  59. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/EmailFieldValidation.test.js +139 -0
  60. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/FieldValidationBehaviour.test.js +171 -0
  61. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/IntegerFieldValidation.test.js +168 -0
  62. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/LookUpFieldValidation.test.js +108 -0
  63. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/MultiSelectFieldValidation.test.js +79 -0
  64. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PercentFieldValidation.test.js +108 -0
  65. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PhoneFieldValidation.test.js +168 -0
  66. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/PicklistFieldValidation.test.js +79 -0
  67. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextAreaFieldValidation.test.js +170 -0
  68. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/TextBoxFieldValidation.test.js +170 -0
  69. package/es/library/behaviours/field-validation/frameworks/ui/__tests__/URLFieldValidation.test.js +108 -0
  70. package/es/library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor.js +228 -0
  71. package/es/library/behaviours/field-validation/frameworks/utils/__tests__/formValidate.test.js +284 -0
  72. package/es/library/behaviours/field-validation/frameworks/utils/formValidate.js +334 -0
  73. package/es/library/dot/components/form-fields/checkbox/adapters/presenter/TransformState.js +22 -0
  74. package/es/library/dot/components/form-fields/currency/adapters/presenter/TransformState.js +81 -0
  75. package/es/library/dot/components/form-fields/date/adapters/presenter/TransformState.js +22 -0
  76. package/es/library/dot/components/form-fields/datetime/adapters/presenter/TransformState.js +22 -0
  77. package/es/library/dot/components/form-fields/decimal/adapters/presenter/TransformState.js +31 -0
  78. package/es/library/dot/components/form-fields/email/adapters/presenter/TransformState.js +23 -0
  79. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITag.js +10 -0
  80. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/EPHITagView.js +21 -0
  81. package/es/library/dot/components/form-fields/ephi-tag/frameworks/ui/css/EPHITag.module.css +3 -0
  82. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIcon.js +10 -0
  83. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/InfoIconView.js +21 -0
  84. package/es/library/dot/components/form-fields/info-icon/frameworks/ui/css/InfoIcon.module.css +3 -0
  85. package/es/library/dot/components/form-fields/multi-select/adapters/presenter/TransformState.js +31 -0
  86. package/es/library/dot/components/form-fields/number/adapters/presenter/TransformState.js +31 -0
  87. package/es/library/dot/components/form-fields/percentage/adapters/presenter/TransformState.js +31 -0
  88. package/es/library/dot/components/form-fields/phone/adapters/presenter/TransformState.js +31 -0
  89. package/es/library/dot/components/form-fields/pick-list/adapters/presenter/TransformState.js +23 -0
  90. package/es/library/dot/components/form-fields/textarea/adapters/presenter/TransformState.js +23 -0
  91. package/es/library/dot/components/form-fields/textbox/adapters/presenter/TransformState.js +32 -0
  92. package/es/library/dot/components/form-fields/url/adapters/presenter/TransformState.js +31 -0
  93. package/es/library/dot/components/section/adapters/presenter/TransFormState.js +26 -0
  94. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelAction.js +9 -0
  95. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/LabelActionView.js +38 -0
  96. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/sub-components/ui/css/LabelAction.module.css +4 -0
  97. package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +18 -0
  98. package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +4 -2
  99. package/es/platform/zdata-source/domain/entities/APITemplate.js +2 -1
  100. package/es/platform/zform/adapters/controllers/ValidateErrorMessageController.js +22 -0
  101. package/es/platform/zform/applications/interfaces/input/GetIsFieldValueChangedUseCaseInput.js +1 -0
  102. package/es/platform/zform/applications/interfaces/input/ValidateErrorMessageInputModel.js +1 -0
  103. package/es/platform/zform/applications/usecases/GetIsFieldValueChanged.js +35 -0
  104. package/es/platform/zform/applications/usecases/ValidateErrorMessageUseCase.js +33 -0
  105. package/es/platform/zform/applications/usecases/ValidateFieldRequestUseCase.js +56 -0
  106. package/es/platform/zform/domain/ZField.js +4 -0
  107. package/package.json +1 -1
  108. package/es/bc/app-context/Event.js +0 -1
  109. package/es/bc/app-context/Properties.js +0 -58
  110. package/es/cc/component/ErrorStructure.js +0 -9
  111. package/es/cc/error-state/ErrorTypes.js +0 -11
  112. package/es/cc/error-state/Properties.js +0 -31
  113. package/es/cc/error-state/index.js +0 -2
  114. package/es/library/custom-component/domain/entities/ComponentProperties.js +0 -121
  115. package/es/library/custom-component/domain/entities/Logger.js +0 -63
  116. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState.js +0 -10
  117. package/es/library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorStateView.js +0 -68
  118. package/es/platform/app-context-behaviour/adapters/controllers/InitializeController.js +0 -19
  119. package/es/platform/app-context-behaviour/adapters/gateways/Service.js +0 -7
  120. package/es/platform/app-context-behaviour/adapters/presenters/Presenter.js +0 -18
  121. package/es/platform/app-context-behaviour/adapters/resources/AppResource.js +0 -25
  122. package/es/platform/app-context-behaviour/applications/AbstractUseCase.js +0 -6
  123. package/es/platform/app-context-behaviour/applications/usecases/InitializeUseCase.js +0 -15
  124. package/es/platform/app-context-behaviour/frameworks/AppContextBehaviourFactory.js +0 -31
  125. package/es/platform/app-context-behaviour/frameworks/EventHandlerFactory.js +0 -25
  126. package/es/platform/components/form-connected/frameworks/FallbackView.js +0 -23
  127. package/es/platform/data-source/http-template/getDependencyMappings.js +0 -18
  128. package/es/platform/data-source/http-template/getLayoutRules.js +0 -29
  129. package/es/platform/data-source/http-template/getMyForm.js +0 -19
  130. package/es/platform/data-source/http-template/getMyLayout.js +0 -43
  131. package/es/platform/data-source/http-template/getValidationRules.js +0 -30
  132. package/es/platform/zform/adapters/controllers/ApiFailureController.js +0 -31
  133. package/es/platform/zform/applications/usecases/ApiFailureUseCase.js +0 -30
  134. /package/es/{platform/app-context-behaviour/applications/interfaces/UsecaseDependencies.js → library/behaviours/field-validation/applications/interfaces/UseCaseDependencies.js} +0 -0
  135. /package/es/{platform/app-context-behaviour/applications/interfaces/gateways/IService.js → library/behaviours/field-validation/applications/interfaces/gateways/IRepository.js} +0 -0
  136. /package/es/{platform/app-context-behaviour/applications/interfaces/input/InitializeUseCaseInputModel.js → library/behaviours/field-validation/applications/interfaces/gateways/IService.js} +0 -0
  137. /package/es/{platform/app-context-behaviour/applications/interfaces/output/BehaviourState.js → library/behaviours/field-validation/applications/interfaces/input/FieldValidationInputModel.js} +0 -0
  138. /package/es/{platform/app-context-behaviour/applications/interfaces/output/IPresenter.js → library/behaviours/field-validation/applications/interfaces/input/ValidateFieldsInputModel.js} +0 -0
  139. /package/es/{bc/app-context/Constants.js → library/behaviours/field-validation/domain/interfaces/IField.js} +0 -0
  140. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ApiHeaderContract.js → library/behaviours/field-validation/domain/interfaces/IFieldValidation.js} +0 -0
  141. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/ContextContract.js → library/behaviours/field-validation/domain/interfaces/IFieldViseValidation.js} +0 -0
  142. /package/es/{platform/app-context-behaviour/applications/interfaces/resources/IAppResource.js → library/behaviours/field-validation/domain/interfaces/ValidationResult.js} +0 -0
  143. /package/es/{platform/zform/applications/interfaces/input/ApiFailureInputModel.js → library/behaviours/field-validation/domain/interfaces/ValidationsArray.js} +0 -0
  144. /package/es/{bc/app-context/EventHandlers.js → library/behaviours/field-validation/domain/interfaces/fields/IBooleanField.js} +0 -0
  145. /package/es/library/{custom-component/domain/entities/interfaces/IComponentProperties.js → behaviours/field-validation/domain/interfaces/fields/ICurrencyField.js} +0 -0
@@ -1,121 +0,0 @@
1
- /* eslint-disable complexity */
2
- import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
3
- import Logger from "./Logger";
4
- export default class ComponentProperties {
5
- constructor(componentName, properties, behaviours) {
6
- this.componentName = componentName;
7
- this.properties = properties;
8
- this.behaviours = behaviours;
9
- this.logger = new Logger(componentName);
10
- this.behavioursProperties = {};
11
- /* store behaviour properties */
12
-
13
- this.behaviours.forEach(behaviour => {
14
- behaviour.getProperties().data && behaviour.getProperties().data.forEach(obj => {
15
- this.behavioursProperties[obj.getName()] = obj.clone();
16
- });
17
- });
18
- }
19
-
20
- getAllBehavioursPropertiesWithValue() {
21
- const output = {};
22
- Object.keys(this.behavioursProperties).forEach(propertyName => {
23
- output[propertyName] = this.behavioursProperties[propertyName].getValue();
24
- });
25
- return output;
26
- }
27
-
28
- getAllPropertiesValue() {
29
- return { ...this.properties.getAllPropertiesValue(),
30
- ...this.getAllBehavioursPropertiesWithValue()
31
- };
32
- }
33
-
34
- getAllPropertiesKeys() {
35
- const propKeys = this.properties.getAllPropertiesKeys();
36
- const bhvrKeys = Object.keys(this.behavioursProperties);
37
- return [...propKeys, ...bhvrKeys];
38
- }
39
-
40
- validateAndUpdateProperties(jsonValidator, newProps) {
41
- const {
42
- isValid,
43
- validationResults
44
- } = this.validateProperties(jsonValidator, newProps);
45
-
46
- if (!isValid) {
47
- this.logger.logPropertiesValidation(validationResults); // console.log({ isValid, componentName: this.componentName, validationResults });
48
-
49
- throw {
50
- code: ErrorCodes.PROPERTY_VALIDATION_FAILED,
51
- message: `Properties validation failed for component ${this.componentName}`,
52
- errorDetails: {
53
- isBreaking: true,
54
- validationResults: validationResults.filter(result => !result.isValid)
55
- }
56
- };
57
- }
58
-
59
- return this.updateProperties(newProps);
60
- }
61
-
62
- updateProperties(newProps) {
63
- const allProperties = this.getAllPropertiesKeys();
64
- let isChanged = false;
65
- allProperties.forEach(key => {
66
- const property = this.findProperty(key);
67
-
68
- if (property) {
69
- isChanged = property.updateValue(newProps[key]) || isChanged;
70
- }
71
- });
72
- return isChanged;
73
- }
74
-
75
- getExtraPropertiesError(propertyName) {
76
- return {
77
- key: propertyName,
78
- isValid: false,
79
- warnings: [{
80
- keyword: 'extra',
81
- message: 'Property is not allowed',
82
- params: {}
83
- }],
84
- errors: [],
85
- schema: {}
86
- };
87
- }
88
-
89
- validateProperties(validator, newProps) {
90
- const allProperties = this.getAllPropertiesKeys();
91
- const validationResults = [];
92
- allProperties.forEach(propertyName => {
93
- const property = this.findProperty(propertyName);
94
-
95
- if (property) {
96
- const result = property.validateProperty(validator, newProps[propertyName]);
97
- validationResults.push(result);
98
- } else {
99
- validationResults.push(this.getExtraPropertiesError(propertyName));
100
- }
101
- });
102
- const isValid = validationResults.every(result => result.isValid);
103
- return {
104
- isValid,
105
- validationResults
106
- };
107
- }
108
-
109
- findProperty(propertyName) {
110
- if (this.behavioursProperties[propertyName]) {
111
- return this.behavioursProperties[propertyName];
112
- }
113
-
114
- return this.properties.findProperty(propertyName);
115
- }
116
-
117
- getAppendToActionPayloadProperty() {
118
- return this.properties.getAppendToActionPayloadProperty();
119
- }
120
-
121
- }
@@ -1,63 +0,0 @@
1
- // Define types
2
- // const ERROR_TITLE: string = 'color: red; font-weight: bold;';
3
- const ERROR_PRIMARY = 'color: #FF6F61;font-weight: bold';
4
- const ERROR_SECONDARY = 'color: #FFA500;font-weight: initial'; // const LOG_TITLE: string = 'color: gray; font-weight: bold;';
5
-
6
- const LOG_PRIMARY = 'color: #55c355;font-weight: bold';
7
- const LOG_SECONDARY = 'color: #5a9de9;font-weight: bold';
8
- export default class Logger {
9
- constructor(componentName) {
10
- this.componentName = componentName;
11
- } // eslint-disable-next-line max-lines-per-function
12
-
13
-
14
- logPropertiesValidation(validationResults) {
15
- console.group(`%cProperties Validation: %c${this.componentName}`, ERROR_PRIMARY, ERROR_SECONDARY, validationResults.filter(result => result.errors?.length > 0 || result.warnings?.length > 0));
16
- validationResults.filter(result => result.errors?.length > 0 || result.warnings?.length > 0).forEach(result => {
17
- result.errors?.forEach(error => {
18
- this.printResult(result.key, error);
19
- });
20
- result.warnings?.forEach(warning => {
21
- this.printResult(result.key, warning);
22
- });
23
- });
24
- console.groupEnd();
25
- }
26
-
27
- printResult(key, errorOrWarning) {
28
- if (errorOrWarning.dataPath) {
29
- console.error(`Invalid Property %c${key}%c${errorOrWarning.dataPath} %c${errorOrWarning.message}`, ERROR_PRIMARY, ERROR_SECONDARY, 'color: white;');
30
- return;
31
- }
32
-
33
- console.error(`Invalid Property %c${key} : %c${errorOrWarning.message}`, ERROR_PRIMARY, 'color: white;');
34
- }
35
-
36
- eventNameConsoleStyle(type) {
37
- const index = type.indexOf('#');
38
- return {
39
- msg: '%c' + type.slice(0, index) + '%c' + type.slice(index),
40
- styles: [LOG_PRIMARY, LOG_SECONDARY]
41
- };
42
- }
43
-
44
- isLoggingEnabled() {
45
- // @ts-ignore
46
- return __DEVELOPMENT__ && globalThis.enableEventLogging;
47
- }
48
-
49
- isLoggingEnabledAndTypePresent(type) {
50
- return this.isLoggingEnabled() && type;
51
- }
52
-
53
- logEvent(type, data) {
54
- if (this.isLoggingEnabledAndTypePresent(type)) {
55
- const {
56
- msg,
57
- styles: nameStyles
58
- } = this.eventNameConsoleStyle(type);
59
- console.log(`%cEvent ${msg}`, 'font-weight: bold', ...nameStyles, data);
60
- }
61
- }
62
-
63
- }
@@ -1,10 +0,0 @@
1
- import { createCustomComponent } from "../../../../../custom-component";
2
- import ErrorStateProperties from "../../../../../../cc/error-state/Properties";
3
- import ErrorStateView from "./ErrorStateView";
4
- let ErrorState = createCustomComponent({
5
- name: "ErrorState",
6
- View: ErrorStateView,
7
- properties: ErrorStateProperties,
8
- eventHandlers: {}
9
- });
10
- export default ErrorState;
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import ErrorTypes from "../../../../../../cc/error-state/ErrorTypes";
3
- import { i18NProviderUtils } from '@zohodesk/i18n';
4
- import Inconvenience from '@zohodesk/dot/lib/version2/errorstate/Inconvenience/Inconvenience';
5
- import OopsSomethingMiss from '@zohodesk/dot/lib/version2/errorstate/OopsSomethingMiss/OopsSomethingMiss';
6
- import UnableToProcess from '@zohodesk/dot/lib/version2/errorstate/UnableToProcessRequest/UnableToProcessRequest';
7
- import PermissionDenied from '@zohodesk/dot/lib/version2/errorstate/UnauthorizedLogin/UnauthorizedLogin';
8
- import UrlNotFound from '@zohodesk/dot/lib/version2/errorstate/UrlNotFound/UrlNotFound';
9
- import WillBeRightBack from '@zohodesk/dot/lib/version2/errorstate/WillBeRightBack/WillBeRightBack';
10
- const errorStateComponents = {
11
- [ErrorTypes.Inconvenience]: Inconvenience,
12
- [ErrorTypes.OopsSomethingMiss]: OopsSomethingMiss,
13
- [ErrorTypes.UnableToProcess]: UnableToProcess,
14
- [ErrorTypes.PermissionDenied]: PermissionDenied,
15
- [ErrorTypes.UrlNotFound]: UrlNotFound,
16
- [ErrorTypes.WillBeRightBack]: WillBeRightBack
17
- };
18
-
19
- const getErrorStateContent = type => {
20
- const errorStateContent = {
21
- [ErrorTypes.Inconvenience]: {
22
- title: i18NProviderUtils.getI18NValue('support.error.inconvenience.v2.title'),
23
- description: i18NProviderUtils.getI18NValue('support.error.inconvenience.v2.message')
24
- },
25
- [ErrorTypes.OopsSomethingMiss]: {
26
- title: i18NProviderUtils.getI18NValue('support.error.oops.something.miss'),
27
- description: i18NProviderUtils.getI18NValue('support.error.oops.something.miss.desc')
28
- },
29
- [ErrorTypes.UnableToProcess]: {
30
- title: i18NProviderUtils.getI18NValue('support.something.went.wrong'),
31
- description: i18NProviderUtils.getI18NValue('support.unable.to.process.your.request.desc')
32
- },
33
- [ErrorTypes.PermissionDenied]: {
34
- title: i18NProviderUtils.getI18NValue('support.error.lable.insufficient'),
35
- description: i18NProviderUtils.getI18NValue('support.error.lable.insufficient.message')
36
- },
37
- [ErrorTypes.UrlNotFound]: {
38
- title: i18NProviderUtils.getI18NValue('support.label.requested.url.not.found'),
39
- description: i18NProviderUtils.getI18NValue('support.label.requested.url.not.found.desc')
40
- },
41
- [ErrorTypes.WillBeRightBack]: {
42
- title: i18NProviderUtils.getI18NValue('support.crmlabel.err.whoa'),
43
- description: i18NProviderUtils.getI18NValue('support.something.went.wrong')
44
- }
45
- };
46
- return errorStateContent[type] || errorStateContent[ErrorTypes.Inconvenience];
47
- };
48
-
49
- function ErrorStateView(_ref, ref) {
50
- let {
51
- state
52
- } = _ref;
53
- const {
54
- type,
55
- title,
56
- description
57
- } = state.properties;
58
- const ErrorComponent = errorStateComponents[type];
59
- const errorStateContent = getErrorStateContent(type);
60
- return /*#__PURE__*/React.createElement("div", {
61
- ref: ref
62
- }, /*#__PURE__*/React.createElement(ErrorComponent, {
63
- title: title || errorStateContent.title,
64
- description: description || errorStateContent.description
65
- }));
66
- }
67
-
68
- export default ErrorStateView;
@@ -1,19 +0,0 @@
1
- import { AbstractController } from "./AbstractController";
2
- export class InitializeController extends AbstractController {
3
- handle(_ref) {
4
- let {
5
- state
6
- } = _ref;
7
- const {
8
- service
9
- } = this;
10
- const context = state.properties.context;
11
- const {
12
- initializeUseCase
13
- } = service;
14
- initializeUseCase.execute({
15
- context
16
- });
17
- }
18
-
19
- }
@@ -1,7 +0,0 @@
1
- import { InitializeUseCase } from "../../applications/usecases/InitializeUseCase";
2
- export class Service {
3
- constructor(dependencies) {
4
- this.initializeUseCase = new InitializeUseCase(dependencies);
5
- }
6
-
7
- }
@@ -1,18 +0,0 @@
1
- // import { State } from '../gateways/State';
2
- class Presenter {
3
- updateDependencies(state, updateState) {
4
- this.state = state;
5
- this.updateState = updateState;
6
- }
7
-
8
- updateView(view) {
9
- this.updateState({ ...this.state,
10
- behaviours: { ...this.state.behaviours,
11
- appContext: view
12
- }
13
- });
14
- }
15
-
16
- }
17
-
18
- export default Presenter;
@@ -1,25 +0,0 @@
1
- import { AbstractResource } from "../../../sdk/application/interfaces/gateways/AbstractResource";
2
-
3
- /** Sample Implementation of AppResource */
4
- export class AppResource extends AbstractResource {
5
- initialize() {}
6
-
7
- destroy() {}
8
-
9
- initializeContext(context) {
10
- this.context = context;
11
- }
12
-
13
- initializeApiHeader(headers) {
14
- this.headers = headers;
15
- }
16
-
17
- getContext() {
18
- return this.context;
19
- }
20
-
21
- getApiHeader() {
22
- return this.headers;
23
- }
24
-
25
- }
@@ -1,6 +0,0 @@
1
- export default class AbstractUseCase {
2
- constructor(dependencies) {
3
- this.dependencies = dependencies;
4
- }
5
-
6
- }
@@ -1,15 +0,0 @@
1
- import AbstractUseCase from "../AbstractUseCase";
2
- export class InitializeUseCase extends AbstractUseCase {
3
- execute(_ref) {
4
- let {
5
- instanceName
6
- } = _ref;
7
- const {
8
- appResource,
9
- presenter
10
- } = this.dependencies;
11
- const context = appResource.getContext();
12
- presenter.updateView(context);
13
- }
14
-
15
- }
@@ -1,31 +0,0 @@
1
- import AppContextProperties from "../../../bc/app-context/Properties";
2
- import { platformSDK } from "../../sdk/frameworks/Sdk";
3
- import ResourceNamesEnum from "../../../bc/sdk/ResourceNamesEnum";
4
-
5
- class AppContextBehaviourFactory {
6
- static create() {
7
- return {
8
- name: 'appContext',
9
- setInitialState: _ref => {
10
- let {
11
- properties: {
12
- context
13
- }
14
- } = _ref;
15
- const appResource = platformSDK[ResourceNamesEnum.APP];
16
- return {
17
- headers: appResource.getApiHeader(),
18
- context: { ...appResource.getContext(),
19
- ...context
20
- }
21
- };
22
- },
23
- // eventHandlers: EventHandlerFactory.create(),
24
- eventHandlers: {},
25
- properties: AppContextProperties
26
- };
27
- }
28
-
29
- }
30
-
31
- export default AppContextBehaviourFactory;
@@ -1,25 +0,0 @@
1
- import LifeCycleEvents from "../../../cc/component/LifeCycleEventsEnum";
2
- import ResourceNamesEnum from "../../../bc/sdk/ResourceNamesEnum";
3
- import { Service } from "../adapters/gateways/Service";
4
- import { InitializeController } from "../adapters/controllers/InitializeController";
5
- import { platformSDK } from "../../sdk/frameworks/Sdk";
6
- import Presenter from "../adapters/presenters/Presenter";
7
-
8
- class EventHandlerFactory {
9
- static create() {
10
- const appResource = platformSDK[ResourceNamesEnum.APP]; // NOTE: here 'app' should match the resource name in the sdk registry
11
-
12
- const presenter = new Presenter();
13
- const dependencies = {
14
- appResource,
15
- presenter
16
- };
17
- const service = new Service(dependencies);
18
- return {
19
- [LifeCycleEvents.MOUNT]: new InitializeController(service).handle
20
- };
21
- }
22
-
23
- }
24
-
25
- export default EventHandlerFactory;
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import ErrorState from "../../../../library/dot/legacy-to-new-arch/error-state/frameworks/ui/ErrorState";
3
- import { ErrorCodes } from "../../../../cc/component/ErrorStructure";
4
- import ErrorTypes from "../../../../cc/error-state/ErrorTypes";
5
-
6
- function FallbackView(_ref, ref) {
7
- let {
8
- error
9
- } = _ref;
10
- const map = {
11
- [ErrorCodes.API_FAILED]: ErrorTypes.UrlNotFound,
12
- [ErrorCodes.PROPERTY_VALIDATION_FAILED]: ErrorTypes.OopsSomethingMiss,
13
- [ErrorCodes.EVENT_HANDLER_FAILED]: ErrorTypes.Inconvenience,
14
- [ErrorCodes.UNKNOWN_ERROR]: ErrorTypes.Inconvenience
15
- };
16
- const errorType = map[error.code] === undefined ? ErrorTypes.Inconvenience : map[error.code];
17
- return /*#__PURE__*/React.createElement(ErrorState, {
18
- type: errorType,
19
- getRef: ref
20
- });
21
- }
22
-
23
- export default /*#__PURE__*/React.forwardRef(FallbackView);
@@ -1,18 +0,0 @@
1
- const getDependencyMappings = {
2
- name: 'getDependencyMappings',
3
- api: '/{{servicePrefix}}/{{orgName}}/api/v1/dependencyMappings',
4
- parameters: `{"layoutId":"{{layoutId}}"}`,
5
- type: 'GET',
6
- transformer: data => data,
7
- properties: {
8
- layoutId: {
9
- required: true,
10
- typeMetadata: {
11
- schema: {
12
- type: 'string'
13
- }
14
- }
15
- }
16
- }
17
- };
18
- export default getDependencyMappings;
@@ -1,29 +0,0 @@
1
- // Assuming GetTemplate interface is defined
2
- const getLayoutRules = {
3
- name: 'getLayoutRules',
4
- api: '/{{servicePrefix}}/{{orgName}}/api/v1/layouts/{{layoutId}}/layoutRules',
5
- parameters: `{"activeRulesOnly":{{activeRulesOnly}}}`,
6
- type: 'GET',
7
- transformer: data => data,
8
- properties: {
9
- layoutId: {
10
- required: true,
11
- typeMetadata: {
12
- schema: {
13
- type: 'string'
14
- }
15
- }
16
- },
17
- activeRulesOnly: {
18
- required: true,
19
- typeMetadata: {
20
- schema: {
21
- type: 'boolean'
22
- }
23
- },
24
- defaultValue: true // Assuming true as a default if parameter is optional
25
-
26
- }
27
- }
28
- };
29
- export default getLayoutRules;
@@ -1,19 +0,0 @@
1
- // Assuming similar structure to PatchTemplate
2
- const getMyForm = {
3
- name: 'getMyForm',
4
- api: '/{{servicePrefix}}/{{orgName}}/api/v1/myForm',
5
- parameters: `{"layoutId":"{{layoutId}}"}`,
6
- type: 'GET',
7
- transformer: data => data,
8
- properties: {
9
- layoutId: {
10
- required: true,
11
- typeMetadata: {
12
- schema: {
13
- type: 'string'
14
- }
15
- }
16
- }
17
- }
18
- };
19
- export default getMyForm;
@@ -1,43 +0,0 @@
1
- // Assumed you have a GetTemplate interface similar to PatchTemplate
2
- const getMyLayouts = {
3
- name: 'getMyLayouts',
4
- api: '/{{servicePrefix}}/{{orgName}}/api/v1/myLayouts',
5
- parameters: `{"module":"{{module}}","departmentId":"{{departmentId}}","from":"{{from}}","limit":"{{limit}}"}`,
6
- type: 'GET',
7
- transformer: data => data,
8
- properties: {
9
- module: {
10
- required: true,
11
- typeMetadata: {
12
- schema: {
13
- type: 'string'
14
- }
15
- }
16
- },
17
- departmentId: {
18
- required: true,
19
- typeMetadata: {
20
- schema: {
21
- type: 'string'
22
- }
23
- }
24
- },
25
- from: {
26
- required: true,
27
- typeMetadata: {
28
- schema: {
29
- type: 'string'
30
- }
31
- }
32
- },
33
- limit: {
34
- required: true,
35
- typeMetadata: {
36
- schema: {
37
- type: 'string'
38
- }
39
- }
40
- }
41
- }
42
- };
43
- export default getMyLayouts;
@@ -1,30 +0,0 @@
1
- // Assuming GetTemplate interface is similar to PatchTemplate
2
- import { transFormValidationRules } from "../utils/validation-rules/TransFormValidationRules";
3
- const getValidationRules = {
4
- name: 'getValidationRules',
5
- api: '/{{servicePrefix}}/{{orgName}}/api/v1/layouts/{{layoutId}}/validationRules',
6
- parameters: `{"activeRulesOnly":{{activeRulesOnly}}}`,
7
- type: 'GET',
8
- transformer: transFormValidationRules,
9
- properties: {
10
- layoutId: {
11
- required: true,
12
- typeMetadata: {
13
- schema: {
14
- type: 'string'
15
- }
16
- }
17
- },
18
- activeRulesOnly: {
19
- required: true,
20
- typeMetadata: {
21
- schema: {
22
- type: 'boolean'
23
- }
24
- },
25
- defaultValue: true // Assuming default behavior if not provided
26
-
27
- }
28
- }
29
- };
30
- export default getValidationRules;
@@ -1,31 +0,0 @@
1
- import AbstractController from "./AbstractController";
2
-
3
- class ApiFailureController extends AbstractController {
4
- handle(event) {
5
- const {
6
- apiFailureUseCase
7
- } = this.service;
8
- const {
9
- state,
10
- updateState,
11
- action,
12
- dispatch
13
- } = event;
14
- const {
15
- payload,
16
- metaData
17
- } = action;
18
- const {
19
- error
20
- } = payload;
21
- apiFailureUseCase.updateDependency(state, updateState);
22
- apiFailureUseCase.execute({
23
- error,
24
- metaData,
25
- dispatch
26
- });
27
- }
28
-
29
- }
30
-
31
- export default ApiFailureController;
@@ -1,30 +0,0 @@
1
- import { ACA_ERROR_OCCURRED } from "../../../../cc/component/ErrorStructure";
2
- import AbstractUseCase from "./AbstractUseCase";
3
-
4
- class ApiFailureUseCase extends AbstractUseCase {
5
- execute(params) {
6
- const {
7
- error,
8
- metaData,
9
- dispatch
10
- } = params;
11
- const {
12
- actionName
13
- } = metaData;
14
- const {
15
- repository,
16
- presenter
17
- } = this.dependencies;
18
- const zFormEntity = repository.getFormEntity();
19
- const isBreaking = zFormEntity.stopLoadingAndDecideIsBreaking(actionName);
20
- const errorStructure = zFormEntity.constructApiErrorEvent(error, actionName, isBreaking);
21
- presenter.updateFormResponse(zFormEntity.toObject());
22
- dispatch({
23
- type: ACA_ERROR_OCCURRED,
24
- payload: errorStructure
25
- });
26
- }
27
-
28
- }
29
-
30
- export default ApiFailureUseCase;