@zohodesk/library-platform 1.2.2 → 1.2.3
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.
- package/es/.DS_Store +0 -0
- package/es/cc/action-status/Constants.js +5 -0
- package/es/cc/action-status/Events.js +6 -0
- package/es/cc/action-status/Properties.js +29 -0
- package/es/cc/action-status/index.js +3 -0
- package/es/cc/button/Properties.js +28 -0
- package/es/cc/fields/field/Events.js +8 -0
- package/es/cc/highlighted-value/Properties.js +28 -0
- package/es/cc/index.js +1 -0
- package/es/cc/radio-dropdown/Events.js +16 -0
- package/es/cc/table-column-filter/Properties.js +9 -0
- package/es/cc/table-list/Events.js +8 -0
- package/es/library/custom-component/frameworks/ui/DependencyFactory.js +1 -1
- package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +3 -1
- package/es/library/dot/components/action-status/frameworks/ui/ActionStatus.js +12 -0
- package/es/library/dot/components/action-status/frameworks/ui/ActionStatusView.js +57 -0
- package/es/library/dot/components/action-status/frameworks/ui/css/ActionStatus.module.css +61 -0
- package/es/library/dot/components/form/frameworks/ui/sub-components/Footer.js +1 -1
- package/es/library/dot/components/table-list/adapters/controllers/FieldChangeController.js +4 -2
- package/es/library/dot/legacy-to-new-arch/button/frameworks/ui/ButtonView.js +17 -2
- package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/HighlightedValueView.js +13 -2
- package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/css/HighlightedValue.module.css +4 -0
- package/es/library/dot/legacy-to-new-arch/radio-dropdown/frameworks/ui/RadioDropdownView.js +3 -1
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/EventHandlersFactory.js +26 -0
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilter.js +19 -1
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilterView.js +3 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +2 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/highlighted-value-field/frameworks/ui/HighlightedValueFieldView.js +8 -2
- package/es/library/dot/legacy-to-new-arch/table-field-components/radio-dropdown-field/frameworks/ui/EventHandlersFactory.js +4 -2
- package/es/library/dot/legacy-to-new-arch/table-field-components/switch-field/frameworks/ui/EventHandlersFactory.js +2 -1
- package/es/library/json-schema-validator/Validator.js +338 -0
- package/es/library/json-schema-validator/__tests__/Validator.test.js +753 -0
- package/es/library/json-schema-validator/index.js +1 -0
- package/es/platform/.DS_Store +0 -0
- package/es/platform/client-actions/cc/client-actions-renderer/Properties.js +1 -1
- package/es/platform/client-actions/cc/client-actions-renderer/ViewMetaSchema.js +1 -1
- package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js +1 -8
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRendererView.js +2 -2
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/views/DefaultActionsRendererView.js +2 -2
- package/es/platform/data-source/http-template/getAvailableFields.js +4 -2
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +1 -1
- package/es/platform/zform/domain/interfaces/IZForm.js +2 -5
- package/es/platform/zform/domain/interfaces/ValidationEvents.js +4 -0
- package/package.json +18 -6
- package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +0 -164
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Validator } from "./Validator";
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Layout } from "../../components/
|
|
1
|
+
import { Layout } from "../../components/interfaces/ActionViewModel";
|
|
2
2
|
import { ActionViewGap } from "../../components/interfaces/ActionViewModel";
|
|
3
3
|
export default {
|
|
4
4
|
type: 'object',
|
package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
Layout["HORIZONTAL"] = "horizontal";
|
|
3
|
-
Layout["VERTICAL"] = "vertical";
|
|
4
|
-
Layout["HORIZONTAL_WITH_MORE_ACTIONS"] = "horizontal-with-more-actions";
|
|
5
|
-
Layout["VERTICAL_WITH_MORE_ACTIONS"] = "vertical-with-more-actions";
|
|
6
|
-
return Layout;
|
|
7
|
-
}({});
|
|
8
|
-
;
|
|
1
|
+
export {};
|
|
@@ -10,10 +10,10 @@ export default function ClientActionsRendererView(_ref, ref) {
|
|
|
10
10
|
clientScripts,
|
|
11
11
|
viewMeta,
|
|
12
12
|
testId,
|
|
13
|
-
|
|
13
|
+
location,
|
|
14
14
|
instanceName
|
|
15
15
|
} = state.properties;
|
|
16
|
-
const customView =
|
|
16
|
+
const customView = location !== '' && instanceName !== '' ? ComponentRegistry.get(`${instanceName}_${location}_renderer`) : null;
|
|
17
17
|
const View = customView ? customView : DefaultActionsRendererView;
|
|
18
18
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
19
19
|
clientActions: actions,
|
|
@@ -6,7 +6,7 @@ import style from "../ClientActionsRenderer.module.css";
|
|
|
6
6
|
import MoreActionsRenderer from "../../more-actions-renderer/MoreActionsRenderer";
|
|
7
7
|
import Flex from '@zohodesk/layout/es/Flex/Flex';
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import { Layout } from "
|
|
9
|
+
import { Layout } from "../../../../../interfaces/ActionViewModel";
|
|
10
10
|
const HORIZONTAL_LAYOUTS = [Layout.HORIZONTAL, Layout.HORIZONTAL_WITH_MORE_ACTIONS];
|
|
11
11
|
const MORE_ACTIONS_LAYOUTS = [Layout.VERTICAL_WITH_MORE_ACTIONS, Layout.HORIZONTAL_WITH_MORE_ACTIONS];
|
|
12
12
|
|
|
@@ -53,7 +53,7 @@ export default function DefaultActionsRendererView(_ref) {
|
|
|
53
53
|
ref: getRef,
|
|
54
54
|
testId: testId,
|
|
55
55
|
$ui_direction: getFlexDirection(layout),
|
|
56
|
-
$ui_className: getGapClassName(gap)
|
|
56
|
+
$ui_className: `${style.wrapper} ${getGapClassName(gap)}`,
|
|
57
57
|
$ui_displayMode: "inline",
|
|
58
58
|
$ui_alignItems: "center"
|
|
59
59
|
}, actionsList.map(action => renderAction(action, clientScripts)), showMore &&
|
|
@@ -39,13 +39,15 @@ let getAvailableFields = {
|
|
|
39
39
|
const res = await fetch(availableFieldsUrl, {
|
|
40
40
|
method: 'GET',
|
|
41
41
|
headers
|
|
42
|
-
});
|
|
42
|
+
}); // fetch-ignore
|
|
43
|
+
|
|
43
44
|
const availableFields = await getValidJsonResArray(res, 'fields');
|
|
44
45
|
const organizationFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/organizationFields?departmentId=${departmentId}&module=${module}`;
|
|
45
46
|
const ores = await fetch(organizationFieldsUrl, {
|
|
46
47
|
method: 'GET',
|
|
47
48
|
headers
|
|
48
|
-
});
|
|
49
|
+
}); // fetch-ignore
|
|
50
|
+
|
|
49
51
|
const organizationFields = await getValidJsonResArray(ores, 'data');
|
|
50
52
|
return {
|
|
51
53
|
fields: availableFields.map(field => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ErrorPrinter from "../../../../components/table-connected/adapters/resources/ErrorPrinter";
|
|
2
|
-
import Validator from "../../../../../library/
|
|
2
|
+
import { Validator } from "../../../../../library/json-schema-validator";
|
|
3
3
|
export class AbstractResource {
|
|
4
4
|
updateDependencies(dependencies) {
|
|
5
5
|
this.dependencies = dependencies;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/library-platform",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,18 +15,30 @@
|
|
|
15
15
|
"clean": "cdt clean ./es",
|
|
16
16
|
"build": "npm run clean && cbt build:es",
|
|
17
17
|
"build:watch": "npm run build -- -w",
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "npx ZDTestingFramework unit-test",
|
|
19
19
|
"prepare": "npm run build",
|
|
20
20
|
"publish:alpha": "npm publish --tag alpha",
|
|
21
21
|
"publish:beta": "npm publish --tag beta",
|
|
22
22
|
"publish:exp": "npm publish --tag experimental",
|
|
23
|
+
"postinstall": "node -e \"const path = require('path'); const cwd = process.cwd(); const initCwd = process.env.INIT_CWD ? path.resolve(process.env.INIT_CWD) : cwd; const isDirectInstall = initCwd === cwd; process.exit(!isDirectInstall ? 0 : 1);\" || (npm run lint:setup && sh scripts/setup-husky-precommit.sh)",
|
|
23
24
|
"postpublish": "node ./post_publish.js",
|
|
24
25
|
"lint:setup": "ZDPrecommit setupPlugins",
|
|
25
26
|
"lint": "eslint -c .eslintrc.js --ext .ts,.js,.tsx",
|
|
26
27
|
"lint:analytics": "ZDLintFramework lint",
|
|
27
28
|
"lint:exemption": "ZDLintFramework exemption-report",
|
|
28
29
|
"lint:ci": "ZDLintFramework lint-ci",
|
|
29
|
-
"prettify": "node prettify.js staged"
|
|
30
|
+
"prettify": "node prettify.js staged",
|
|
31
|
+
"arch:check": "depcruise --config .dependency-cruiser.js src",
|
|
32
|
+
"tdd:check": "bash scripts/check-tdd-compliance.sh",
|
|
33
|
+
"layer:check": "bash scripts/check-layer-completeness.sh",
|
|
34
|
+
"guardrails:fast": "bash scripts/guardrails-fast.sh",
|
|
35
|
+
"guardrails:arch": "npm run arch:check && npm run guardrails:fast",
|
|
36
|
+
"guardrails:full": "npm run arch:check && npm run lint && npm test && npm run build && npm run guardrails:fast",
|
|
37
|
+
"staged:test": "bash scripts/run-staged-tests.sh",
|
|
38
|
+
"mutation:test": "npx zdcodequality mutate --local --branch=v2 --mutationConfigPath=mutation.conf.js --jestConfigPath=ut.config.js",
|
|
39
|
+
"mutation:test:ci": "npx zdcodequality mutate --ci --branch=v2 --mutationConfigPath=mutation.conf.js --jestConfigPath=ut.config.js",
|
|
40
|
+
"mutation:staged": "bash scripts/check-mutation-staged.sh",
|
|
41
|
+
"uat:impact": "bash scripts/check-uat-impact.sh"
|
|
30
42
|
},
|
|
31
43
|
"author": "",
|
|
32
44
|
"license": "ISC",
|
|
@@ -46,7 +58,7 @@
|
|
|
46
58
|
"@zohodesk-private/dot-registry": "0.0.2",
|
|
47
59
|
"@zohodesk-private/node-plugins": "1.1.9",
|
|
48
60
|
"@zohodesk/a11y": "2.3.8",
|
|
49
|
-
"@zohodesk/codestandard-validator": "1.3.1",
|
|
61
|
+
"@zohodesk/codestandard-validator": "1.3.1-platform-14",
|
|
50
62
|
"@zohodesk/components": "1.5.8",
|
|
51
63
|
"@zohodesk/dot": "1.8.6",
|
|
52
64
|
"@zohodesk/dotkit": "1.0.7",
|
|
@@ -54,6 +66,7 @@
|
|
|
54
66
|
"@zohodesk/icons": "1.1.5",
|
|
55
67
|
"@zohodesk/layout": "3.1.0",
|
|
56
68
|
"@zohodesk/svg": "1.2.6",
|
|
69
|
+
"@zohodesk/testinglibrary": "0.0.51-n20-experimental",
|
|
57
70
|
"@zohodesk/utils": "1.3.16",
|
|
58
71
|
"@zohodesk/variables": "1.2.0",
|
|
59
72
|
"@zohodesk/virtualizer": "1.0.13",
|
|
@@ -91,8 +104,7 @@
|
|
|
91
104
|
"react-sortable-hoc": "1.11.0"
|
|
92
105
|
},
|
|
93
106
|
"dependencies": {
|
|
94
|
-
"ajv": "6.12.6",
|
|
95
107
|
"jsep": "0.3.5",
|
|
96
108
|
"object-path-immutable": "4.1.2"
|
|
97
109
|
}
|
|
98
|
-
}
|
|
110
|
+
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
let jsonValidator = new Ajv({
|
|
4
|
-
useDefaults: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
class Validator {
|
|
8
|
-
static validate(schema, value) {
|
|
9
|
-
if (schema.schema) {
|
|
10
|
-
return Validator.validatePropertySchema(schema, value);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let errors = [];
|
|
14
|
-
Validator.checkFunctionsRecursively(schema, value, '', '#', errors); // Use AJV for the rest of the validation, ignoring functions
|
|
15
|
-
|
|
16
|
-
const ajvSchema = JSON.parse(JSON.stringify(schema, (key, val) => val === 'function' ? undefined : val)); // validate is a type guard for MyData - type is inferred from schema type
|
|
17
|
-
// const validate = jsonValidator.compile(schema);
|
|
18
|
-
|
|
19
|
-
const validate = jsonValidator.compile(ajvSchema);
|
|
20
|
-
const isValid = validate(value);
|
|
21
|
-
|
|
22
|
-
if (!isValid) {
|
|
23
|
-
// errors = validate.errors;
|
|
24
|
-
validate.errors && errors.push(...validate.errors);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
isValid: isValid && errors.length === 0,
|
|
29
|
-
errors,
|
|
30
|
-
warnings: []
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static checkFunctionsRecursively(schema, value) {
|
|
35
|
-
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
36
|
-
let schemaPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#';
|
|
37
|
-
let errors = arguments.length > 4 ? arguments[4] : undefined;
|
|
38
|
-
|
|
39
|
-
if (schema.type === 'function') {
|
|
40
|
-
if (typeof value !== 'function') {
|
|
41
|
-
errors.push({
|
|
42
|
-
keyword: 'type',
|
|
43
|
-
dataPath: path ? `.${path}` : '',
|
|
44
|
-
schemaPath: `${schemaPath}/type`,
|
|
45
|
-
params: {
|
|
46
|
-
type: 'function'
|
|
47
|
-
},
|
|
48
|
-
message: 'should be function'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (schema.type === 'object' && schema.properties && typeof value === 'object' && value !== null) {
|
|
56
|
-
for (const key in schema.properties) {
|
|
57
|
-
Validator.checkFunctionsRecursively(schema.properties[key], value[key], path ? `${path}.${key}` : key, `${schemaPath}/properties/${key}`, errors);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (schema.type === 'array' && Array.isArray(value) && schema.items) {
|
|
62
|
-
value.forEach((item, index) => {
|
|
63
|
-
Validator.checkFunctionsRecursively(schema.items, item, `${path}[${index}]`, `${schemaPath}/items`, errors);
|
|
64
|
-
});
|
|
65
|
-
} // if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
66
|
-
// const subErrors = [];
|
|
67
|
-
// const valid = schema.anyOf.some((subSchema, idx) => {
|
|
68
|
-
// const tmpErrors = [];
|
|
69
|
-
// Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/anyOf/${idx}`, tmpErrors);
|
|
70
|
-
// return tmpErrors.length === 0;
|
|
71
|
-
// });
|
|
72
|
-
// if (!valid) {
|
|
73
|
-
// errors.push({ keyword: "anyOf", dataPath: path ? `.${path}` : "", schemaPath: `${schemaPath}/anyOf`, params: {}, message: "should match some schema in anyOf" });
|
|
74
|
-
// }
|
|
75
|
-
// return;
|
|
76
|
-
// }
|
|
77
|
-
// if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
78
|
-
// schema.allOf.forEach((subSchema, idx) => {
|
|
79
|
-
// Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/allOf/${idx}`, errors);
|
|
80
|
-
// });
|
|
81
|
-
// return;
|
|
82
|
-
// }
|
|
83
|
-
// if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
84
|
-
// let matchCount = 0;
|
|
85
|
-
// schema.oneOf.forEach((subSchema, idx) => {
|
|
86
|
-
// const tmpErrors = [];
|
|
87
|
-
// Validator.checkFunctionsRecursively(subSchema, value, path, `${schemaPath}/oneOf/${idx}`, tmpErrors);
|
|
88
|
-
// if (tmpErrors.length === 0) matchCount++;
|
|
89
|
-
// });
|
|
90
|
-
// if (matchCount !== 1) {
|
|
91
|
-
// errors.push({ keyword: "oneOf", dataPath: path ? `.${path}` : "", schemaPath: `${schemaPath}/oneOf`, params: {}, message: "should match exactly one schema in oneOf" });
|
|
92
|
-
// }
|
|
93
|
-
// return;
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static validatePropertySchema(propertySchema, value) {
|
|
99
|
-
const {
|
|
100
|
-
schema
|
|
101
|
-
} = propertySchema;
|
|
102
|
-
const result = Validator.validateRequired(propertySchema, value);
|
|
103
|
-
const isProvided = propertySchema.isValueProvided;
|
|
104
|
-
|
|
105
|
-
if (result.isValid === false) {
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!isProvided) {
|
|
110
|
-
return {
|
|
111
|
-
isValid: true,
|
|
112
|
-
errors: [],
|
|
113
|
-
warnings: result.warnings
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const {
|
|
118
|
-
isValid,
|
|
119
|
-
errors,
|
|
120
|
-
warnings
|
|
121
|
-
} = Validator.validate(schema, value);
|
|
122
|
-
return {
|
|
123
|
-
key: propertySchema.name,
|
|
124
|
-
isValid,
|
|
125
|
-
errors,
|
|
126
|
-
warnings: [...result.warnings, ...warnings]
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
static validateRequired(propertySchema, value) {
|
|
131
|
-
const errors = [];
|
|
132
|
-
const warnings = [];
|
|
133
|
-
const isRequired = propertySchema.required === true;
|
|
134
|
-
const hasDefault = Object.prototype.hasOwnProperty.call(propertySchema, 'defaultValue');
|
|
135
|
-
const isProvided = propertySchema.isValueProvided;
|
|
136
|
-
|
|
137
|
-
if (!isProvided && isRequired) {
|
|
138
|
-
if (hasDefault) {
|
|
139
|
-
if (propertySchema.defaultValue === undefined) {
|
|
140
|
-
errors.push({
|
|
141
|
-
message: `is required but missing. So, default value is undefined.`
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
warnings.push({
|
|
145
|
-
message: `is required but missing. So, Default value will be used.`
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
errors.push({
|
|
150
|
-
message: `is required but missing. And, neither a value nor a default value is present.`
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
isValid: errors.length === 0,
|
|
157
|
-
warnings,
|
|
158
|
-
errors
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default Validator;
|