@giteeteam/apps-manifest 0.1.0 → 0.1.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.
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { Manifest } from './manifest';
2
+ export * from './types';
package/lib/index.js CHANGED
@@ -1,5 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.Manifest = void 0;
4
18
  var manifest_1 = require("./manifest");
5
19
  Object.defineProperty(exports, "Manifest", { enumerable: true, get: function () { return manifest_1.Manifest; } });
20
+ __exportStar(require("./types"), exports);
package/lib/manifest.d.ts CHANGED
@@ -1,14 +1,43 @@
1
+ import type { IManifest } from './types';
1
2
  export declare class Manifest {
2
- private manifest;
3
- constructor(manifestStr: string);
3
+ private readonly manifest;
4
+ private readonly manifestString;
5
+ constructor(manifestString: string);
4
6
  get resources(): import("./types").IManifestResource[] | undefined;
5
7
  get app(): import("./types").IManifestApp;
8
+ get tables(): any;
9
+ getManifest(): IManifest;
10
+ getManifestString(): string;
6
11
  /**
7
- * 根据key获取执行的function名称
12
+ * 获取所有自定义事项类型
13
+ */
14
+ getCustomItemType(): any[];
15
+ /**
16
+ * 获取所有自定义字段类型
17
+ */
18
+ getCustomFieldType(): import("./types").IManifestCustomFieldType[];
19
+ /**
20
+ * 获取所有自定义字段
21
+ */
22
+ getCustomField(): import("./types").IManifestCustomField[];
23
+ /**
24
+ * 根据key获取执行的function
8
25
  * @param key
9
26
  * @returns
10
27
  */
11
28
  getFunctionByKey(key: string): import("./types").IManifestFunction | undefined;
29
+ /**
30
+ * 根据functionKey获取执行的function
31
+ * @param functionKey
32
+ * @returns
33
+ */
34
+ getFunctionByFunctionKey(functionKey: string): import("./types").IManifestFunction | undefined;
35
+ /**
36
+ * 根据key获取执行的functionKey
37
+ * @param key
38
+ * @returns
39
+ */
40
+ getFunctionKeyByKey(key: string): string | undefined;
12
41
  /**
13
42
  * 获取function下的文件列表
14
43
  * @returns
package/lib/manifest.js CHANGED
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Manifest = void 0;
4
4
  const yaml_1 = require("yaml");
5
5
  class Manifest {
6
- constructor(manifestStr) {
7
- this.manifest = (0, yaml_1.parse)(manifestStr);
6
+ constructor(manifestString) {
7
+ this.manifest = (0, yaml_1.parse)(manifestString);
8
+ this.manifestString = manifestString;
8
9
  }
9
10
  get resources() {
10
11
  return this.manifest.resources;
@@ -12,13 +13,63 @@ class Manifest {
12
13
  get app() {
13
14
  return this.manifest.app;
14
15
  }
16
+ get tables() {
17
+ return this.manifest.tables;
18
+ }
19
+ getManifest() {
20
+ return this.manifest;
21
+ }
22
+ getManifestString() {
23
+ return this.manifestString;
24
+ }
25
+ /**
26
+ * 获取所有自定义事项类型
27
+ */
28
+ getCustomItemType() {
29
+ const { modules } = this.manifest;
30
+ return modules.customItemType || [];
31
+ }
32
+ /**
33
+ * 获取所有自定义字段类型
34
+ */
35
+ getCustomFieldType() {
36
+ const { modules } = this.manifest;
37
+ return modules.customFieldType || [];
38
+ }
39
+ /**
40
+ * 获取所有自定义字段
41
+ */
42
+ getCustomField() {
43
+ const { modules } = this.manifest;
44
+ return modules.customField || [];
45
+ }
15
46
  /**
16
- * 根据key获取执行的function名称
47
+ * 根据key获取执行的function
17
48
  * @param key
18
49
  * @returns
19
50
  */
20
51
  getFunctionByKey(key) {
21
- var _a, _b, _c, _d, _e;
52
+ const functionKey = this.getFunctionKeyByKey(key);
53
+ if (functionKey) {
54
+ return this.getFunctionByFunctionKey(functionKey);
55
+ }
56
+ }
57
+ /**
58
+ * 根据functionKey获取执行的function
59
+ * @param functionKey
60
+ * @returns
61
+ */
62
+ getFunctionByFunctionKey(functionKey) {
63
+ var _a, _b;
64
+ return (_b = (_a = this.manifest.modules) === null || _a === void 0 ? void 0 : _a.function) === null || _b === void 0 ? void 0 : _b.find(f => f.key === functionKey);
65
+ }
66
+ /**
67
+ * 根据key获取执行的functionKey
68
+ * @param key
69
+ * @returns
70
+ */
71
+ getFunctionKeyByKey(key) {
72
+ var _a, _b, _c;
22
73
  const { modules } = this.manifest;
23
74
  for (const k in modules) {
24
75
  if (k === 'function') {
@@ -27,13 +78,13 @@ class Manifest {
27
78
  else if (k === 'importer') {
28
79
  // importer扩展点需要判断function和validate
29
80
  if (key === ((_a = modules[k]) === null || _a === void 0 ? void 0 : _a.function) || key === ((_b = modules[k]) === null || _b === void 0 ? void 0 : _b.validate)) {
30
- return (_c = modules === null || modules === void 0 ? void 0 : modules.function) === null || _c === void 0 ? void 0 : _c.find(v => v.key === key);
81
+ return key;
31
82
  }
32
83
  }
33
84
  else if (Array.isArray(modules[k])) {
34
- const targetModule = (_d = modules[k]) === null || _d === void 0 ? void 0 : _d.find(v => v.key === key);
85
+ const targetModule = (_c = modules[k]) === null || _c === void 0 ? void 0 : _c.find(v => v.key === key);
35
86
  if (targetModule) {
36
- return (_e = modules === null || modules === void 0 ? void 0 : modules.function) === null || _e === void 0 ? void 0 : _e.find(v => v.key === targetModule.function);
87
+ return targetModule.function;
37
88
  }
38
89
  }
39
90
  }
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare type TriggerEvent = string;
1
2
  export interface IManifestResource {
2
3
  key: string;
3
4
  path: string;
@@ -32,14 +33,42 @@ export interface IManifestImporter {
32
33
  validate: string;
33
34
  itemFields: IManifestImporterItemField[];
34
35
  }
36
+ export interface IManifestTrigger {
37
+ key: string;
38
+ function: string;
39
+ events: TriggerEvent[];
40
+ }
41
+ export interface IManifestCustomField {
42
+ key: string;
43
+ name: string;
44
+ type: string;
45
+ description?: string;
46
+ }
47
+ export interface IManifestCustomFieldType {
48
+ key: string;
49
+ name: string;
50
+ dataType: string;
51
+ resource: string;
52
+ description?: string;
53
+ }
35
54
  export declare type TManifestModules = {
36
55
  [k in string]?: IManifestModule[];
37
56
  } & {
38
57
  function?: IManifestFunction[];
58
+ trigger?: IManifestTrigger[];
39
59
  importer?: IManifestImporter;
60
+ customField?: IManifestCustomField[];
61
+ customFieldType?: IManifestCustomFieldType[];
62
+ customItemType?: any[];
40
63
  };
64
+ export declare type TManifestLanguage = 'en-US' | 'zh-CN';
65
+ export declare type TManifestLocalesItem = Record<string, string>;
66
+ export declare type TManifestLocalesItems = Record<string, TManifestLocalesItem>;
67
+ export declare type TManifestLocales = Record<TManifestLanguage, TManifestLocalesItems>;
41
68
  export interface IManifest {
42
69
  app: IManifestApp;
43
70
  modules: TManifestModules;
71
+ tables?: any;
44
72
  resources?: IManifestResource[];
73
+ locales?: TManifestLocales;
45
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-manifest",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Giteeteam Apps Manifest",
5
5
  "keywords": [
6
6
  "typescript",
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "yaml": "^2.1.1"
36
36
  },
37
- "gitHead": "d8d5a8bac2ee65541cd015e3f2bb574caecf39fb"
37
+ "gitHead": "6c5232720259d831d50a34cae6ba276c348e9f77"
38
38
  }