@giteeteam/apps-manifest 0.1.0-alpha.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/README.md ADDED
@@ -0,0 +1 @@
1
+ # Apps Manifest
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { Manifest } from './manifest';
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Manifest = void 0;
4
+ var manifest_1 = require("./manifest");
5
+ Object.defineProperty(exports, "Manifest", { enumerable: true, get: function () { return manifest_1.Manifest; } });
@@ -0,0 +1,17 @@
1
+ export declare class Manifest {
2
+ private manifest;
3
+ constructor(manifestStr: string);
4
+ get resources(): import("./types").IManifestResource[] | undefined;
5
+ get app(): import("./types").IManifestApp;
6
+ /**
7
+ * 根据key获取执行的function名称
8
+ * @param key
9
+ * @returns
10
+ */
11
+ getFunctionByKey(key: string): import("./types").IManifestFunction | undefined;
12
+ /**
13
+ * 获取function下的文件列表
14
+ * @returns
15
+ */
16
+ getFunctionFiles(): string[];
17
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Manifest = void 0;
4
+ const yaml_1 = require("yaml");
5
+ class Manifest {
6
+ constructor(manifestStr) {
7
+ this.manifest = (0, yaml_1.parse)(manifestStr);
8
+ }
9
+ get resources() {
10
+ return this.manifest.resources;
11
+ }
12
+ get app() {
13
+ return this.manifest.app;
14
+ }
15
+ /**
16
+ * 根据key获取执行的function名称
17
+ * @param key
18
+ * @returns
19
+ */
20
+ getFunctionByKey(key) {
21
+ var _a, _b, _c, _d, _e;
22
+ const { modules } = this.manifest;
23
+ for (const k in modules) {
24
+ if (k === 'function') {
25
+ continue;
26
+ }
27
+ else if (k === 'importer') {
28
+ // importer扩展点需要判断function和validate
29
+ 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);
31
+ }
32
+ }
33
+ else if (Array.isArray(modules[k])) {
34
+ const targetModule = (_d = modules[k]) === null || _d === void 0 ? void 0 : _d.find(v => v.key === key);
35
+ 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);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ /**
42
+ * 获取function下的文件列表
43
+ * @returns
44
+ */
45
+ getFunctionFiles() {
46
+ var _a, _b;
47
+ const fileNames = new Set();
48
+ (_b = (_a = this.manifest.modules) === null || _a === void 0 ? void 0 : _a.function) === null || _b === void 0 ? void 0 : _b.forEach(({ handler }) => {
49
+ const filename = handler.split('.')[0];
50
+ fileNames.add(filename);
51
+ });
52
+ return [...fileNames];
53
+ }
54
+ }
55
+ exports.Manifest = Manifest;
package/lib/types.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ export interface IManifestResource {
2
+ key: string;
3
+ path: string;
4
+ }
5
+ export interface IManifestApp {
6
+ id: string;
7
+ name?: string;
8
+ key: string;
9
+ }
10
+ export declare type LoadType = 'micro' | 'iframe' | 'remoteJs' | 'redirect' | 'uikit';
11
+ export interface IManifestModule {
12
+ key: string;
13
+ loadType?: LoadType;
14
+ title?: string;
15
+ viewType?: string;
16
+ function?: string;
17
+ resource?: string;
18
+ route?: string;
19
+ }
20
+ export interface IManifestFunction {
21
+ key: string;
22
+ handler: string;
23
+ timeout?: number;
24
+ }
25
+ export interface IManifestImporterItemField {
26
+ key: string;
27
+ title: string;
28
+ }
29
+ export interface IManifestImporter {
30
+ function: string;
31
+ validate: string;
32
+ itemFields: IManifestImporterItemField[];
33
+ }
34
+ export declare type TManifestModules = {
35
+ [k in string]?: IManifestModule[];
36
+ } & {
37
+ function?: IManifestFunction[];
38
+ importer?: IManifestImporter;
39
+ };
40
+ export interface IManifest {
41
+ app: IManifestApp;
42
+ modules: TManifestModules;
43
+ resources?: IManifestResource[];
44
+ }
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@giteeteam/apps-manifest",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Giteeteam Apps Manifest",
5
+ "keywords": [
6
+ "typescript",
7
+ "giteeteam",
8
+ "manifest"
9
+ ],
10
+ "license": "ISC",
11
+ "main": "./lib/index.js",
12
+ "files": [
13
+ "lib"
14
+ ],
15
+ "bugs": {
16
+ "url": "https://github.com/moriahq/giteeteam-apps/issues"
17
+ },
18
+ "homepage": "https://github.com/moriahq/giteeteam-apps/tree/master/packages/manifest",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/moriahq/giteeteam-apps.git"
22
+ },
23
+ "scripts": {
24
+ "dev": "tsc -w",
25
+ "build": "rimraf lib && tsc",
26
+ "prepare": "npm run build"
27
+ },
28
+ "publishConfig": {
29
+ "allowBranch": "master",
30
+ "conventionalCommits": true,
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "dependencies": {
35
+ "yaml": "^2.1.1"
36
+ }
37
+ }