@giteeteam/apps-manifest 0.1.0-alpha.0 → 0.1.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/constants.d.ts +6 -0
- package/lib/constants.js +10 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +16 -0
- package/lib/manifest.d.ts +32 -3
- package/lib/manifest.js +58 -7
- package/lib/types.d.ts +32 -2
- package/package.json +1 -1
package/lib/constants.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Triggers = void 0;
|
|
4
|
+
var Triggers;
|
|
5
|
+
(function (Triggers) {
|
|
6
|
+
Triggers["appInstall"] = "proxima:app:install";
|
|
7
|
+
Triggers["appUninstall"] = "proxima:app:uninstall";
|
|
8
|
+
Triggers["appUpdate"] = "proxima:app:update";
|
|
9
|
+
Triggers["itemChange"] = "proxima:item:change";
|
|
10
|
+
})(Triggers = exports.Triggers || (exports.Triggers = {}));
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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);
|
|
21
|
+
__exportStar(require("./constants"), 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
|
-
|
|
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
|
-
*
|
|
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(
|
|
7
|
-
this.manifest = (0, yaml_1.parse)(
|
|
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
|
-
|
|
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
|
|
81
|
+
return key;
|
|
31
82
|
}
|
|
32
83
|
}
|
|
33
84
|
else if (Array.isArray(modules[k])) {
|
|
34
|
-
const targetModule = (
|
|
85
|
+
const targetModule = (_c = modules[k]) === null || _c === void 0 ? void 0 : _c.find(v => v.key === key);
|
|
35
86
|
if (targetModule) {
|
|
36
|
-
return
|
|
87
|
+
return targetModule.function;
|
|
37
88
|
}
|
|
38
89
|
}
|
|
39
90
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { Triggers } from './constants';
|
|
1
2
|
export interface IManifestResource {
|
|
2
3
|
key: string;
|
|
3
4
|
path: string;
|
|
4
5
|
}
|
|
5
6
|
export interface IManifestApp {
|
|
6
|
-
id
|
|
7
|
+
id?: string;
|
|
7
8
|
name?: string;
|
|
8
|
-
key
|
|
9
|
+
key?: string;
|
|
10
|
+
version?: string;
|
|
9
11
|
}
|
|
10
12
|
export declare type LoadType = 'micro' | 'iframe' | 'remoteJs' | 'redirect' | 'uikit';
|
|
11
13
|
export interface IManifestModule {
|
|
@@ -31,14 +33,42 @@ export interface IManifestImporter {
|
|
|
31
33
|
validate: string;
|
|
32
34
|
itemFields: IManifestImporterItemField[];
|
|
33
35
|
}
|
|
36
|
+
export interface IManifestTrigger {
|
|
37
|
+
key: string;
|
|
38
|
+
function: string;
|
|
39
|
+
events: Triggers[];
|
|
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
|
+
}
|
|
34
54
|
export declare type TManifestModules = {
|
|
35
55
|
[k in string]?: IManifestModule[];
|
|
36
56
|
} & {
|
|
37
57
|
function?: IManifestFunction[];
|
|
58
|
+
trigger?: IManifestTrigger[];
|
|
38
59
|
importer?: IManifestImporter;
|
|
60
|
+
customField?: IManifestCustomField[];
|
|
61
|
+
customFieldType?: IManifestCustomFieldType[];
|
|
62
|
+
customItemType?: any[];
|
|
39
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>;
|
|
40
68
|
export interface IManifest {
|
|
41
69
|
app: IManifestApp;
|
|
42
70
|
modules: TManifestModules;
|
|
71
|
+
tables?: any;
|
|
43
72
|
resources?: IManifestResource[];
|
|
73
|
+
locales?: TManifestLocales;
|
|
44
74
|
}
|