@giteeteam/apps-manifest 0.6.5 → 0.7.0

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 CHANGED
@@ -55,7 +55,7 @@ export declare class Manifest {
55
55
  pass: boolean;
56
56
  errors: any[];
57
57
  } | {
58
- pass: false | undefined;
58
+ pass: boolean | Promise<unknown> | undefined;
59
59
  errors: {
60
60
  path: string;
61
61
  message: string | undefined;
package/lib/types.d.ts CHANGED
@@ -25,7 +25,9 @@ export interface IManifestModule {
25
25
  displayConditions?: Record<string, any>;
26
26
  resolver?: {
27
27
  function: string;
28
+ method?: string;
28
29
  };
30
+ parent?: string;
29
31
  }
30
32
  export interface IManifestFunction {
31
33
  key: string;
package/lib/validate.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const validateAll: (json: IManifest) => {
3
3
  pass: boolean;
4
4
  errors: any[];
5
5
  } | {
6
- pass: false | undefined;
6
+ pass: boolean | Promise<unknown> | undefined;
7
7
  errors: {
8
8
  path: string;
9
9
  message: string | undefined;
package/lib/validate.js CHANGED
@@ -117,13 +117,45 @@ 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
+ continue;
128
+ }
129
+ if (module.parent && !groupKey.includes(module.parent)) {
130
+ errors.push({
131
+ path: `/modules/workspacePage/${module.key}`,
132
+ message: `Parent '${module.parent}' not found! `,
133
+ });
134
+ }
135
+ }
136
+ }
137
+ return {
138
+ pass: errors.length === 0,
139
+ errors,
140
+ };
141
+ };
120
142
  const validateAll = (json) => {
121
- const { pass: schemaPass, errors } = validateFactory('http://proxima.com/schemas/all.json')(json);
122
- if (!schemaPass) {
123
- return { pass: schemaPass, errors };
143
+ const validateFunctions = [
144
+ validateFactory('http://proxima.com/schemas/all.json'),
145
+ // 校验一下需要的引用是否存在
146
+ validateResource,
147
+ validateWorkspacePage,
148
+ ];
149
+ for (const validateFunction of validateFunctions) {
150
+ const validateRes = validateFunction(json);
151
+ if (!validateRes.pass) {
152
+ return validateRes;
153
+ }
124
154
  }
125
- // 校验一下需要的引用是否存在
126
- return validateResource(json);
155
+ return {
156
+ pass: true,
157
+ errors: [],
158
+ };
127
159
  };
128
160
  exports.validateAll = validateAll;
129
161
  exports.validateApp = validateFactory('http://proxima.com/schemas/app.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-manifest",
3
- "version": "0.6.5",
3
+ "version": "0.7.0",
4
4
  "description": "Giteeteam Apps Manifest",
5
5
  "keywords": [
6
6
  "typescript",