@giteeteam/apps-manifest 0.6.6 → 0.7.1
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/lib/manifest.d.ts +1 -1
- package/lib/types.d.ts +1 -0
- package/lib/validate.d.ts +1 -1
- package/lib/validate.js +50 -5
- package/package.json +1 -1
package/lib/manifest.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
package/lib/validate.d.ts
CHANGED
package/lib/validate.js
CHANGED
|
@@ -117,13 +117,58 @@ const validateFactory = (schema) => {
|
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
|
+
const validateWorkspacePage = (json) => {
|
|
121
|
+
const modules = json.modules['workspacePage'] || json.modules['proxima:workspacePage'];
|
|
122
|
+
const errors = [];
|
|
123
|
+
if (modules === null || modules === void 0 ? void 0 : modules.length) {
|
|
124
|
+
const groupKey = modules.filter(item => item.type === 'group').map(item => item.key);
|
|
125
|
+
for (const module of modules) {
|
|
126
|
+
if (module.type === 'group') {
|
|
127
|
+
if (module.title && (module.title.length < 2 || module.title.length > 10)) {
|
|
128
|
+
errors.push({
|
|
129
|
+
path: `/modules/workspacePage/${module.key}`,
|
|
130
|
+
message: `Group title length must be between 2 and 10! `,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
if (module.parent && !groupKey.includes(module.parent)) {
|
|
136
|
+
errors.push({
|
|
137
|
+
path: `/modules/workspacePage/${module.key}`,
|
|
138
|
+
message: `Parent '${module.parent}' not found! `,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (module.title && (module.title.length < 2 || module.title.length > 30)) {
|
|
142
|
+
errors.push({
|
|
143
|
+
path: `/modules/workspacePage/${module.key}`,
|
|
144
|
+
message: `Title length must be between 2 and 30! `,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
pass: errors.length === 0,
|
|
152
|
+
errors,
|
|
153
|
+
};
|
|
154
|
+
};
|
|
120
155
|
const validateAll = (json) => {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
156
|
+
const validateFunctions = [
|
|
157
|
+
validateFactory('http://proxima.com/schemas/all.json'),
|
|
158
|
+
// 校验一下需要的引用是否存在
|
|
159
|
+
validateResource,
|
|
160
|
+
validateWorkspacePage,
|
|
161
|
+
];
|
|
162
|
+
for (const validateFunction of validateFunctions) {
|
|
163
|
+
const validateRes = validateFunction(json);
|
|
164
|
+
if (!validateRes.pass) {
|
|
165
|
+
return validateRes;
|
|
166
|
+
}
|
|
124
167
|
}
|
|
125
|
-
|
|
126
|
-
|
|
168
|
+
return {
|
|
169
|
+
pass: true,
|
|
170
|
+
errors: [],
|
|
171
|
+
};
|
|
127
172
|
};
|
|
128
173
|
exports.validateAll = validateAll;
|
|
129
174
|
exports.validateApp = validateFactory('http://proxima.com/schemas/app.json');
|