@steedos/metadata-registrar 2.5.3-beta.2 → 2.5.3-beta.20
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/config-register/actions.d.ts +4 -0
- package/lib/config-register/actions.js +165 -0
- package/lib/config-register/actions.js.map +1 -0
- package/lib/config-register/app.d.ts +1 -0
- package/lib/config-register/app.js +21 -0
- package/lib/config-register/app.js.map +1 -0
- package/lib/config-register/approval_process.d.ts +5 -0
- package/lib/config-register/approval_process.js +85 -0
- package/lib/config-register/approval_process.js.map +1 -0
- package/lib/config-register/button.d.ts +7 -0
- package/lib/config-register/button.js +89 -0
- package/lib/config-register/button.js.map +1 -0
- package/lib/config-register/chart.d.ts +1 -0
- package/lib/config-register/chart.js +26 -0
- package/lib/config-register/chart.js.map +1 -0
- package/lib/config-register/client_script.d.ts +3 -0
- package/lib/config-register/client_script.js +49 -0
- package/lib/config-register/client_script.js.map +1 -0
- package/lib/config-register/core.d.ts +32 -0
- package/lib/config-register/core.js +414 -0
- package/lib/config-register/core.js.map +1 -0
- package/lib/config-register/field.d.ts +5 -0
- package/lib/config-register/field.js +90 -0
- package/lib/config-register/field.js.map +1 -0
- package/lib/config-register/flow_role.d.ts +4 -0
- package/lib/config-register/flow_role.js +65 -0
- package/lib/config-register/flow_role.js.map +1 -0
- package/lib/config-register/index.d.ts +2 -0
- package/lib/config-register/index.js +55 -0
- package/lib/config-register/index.js.map +1 -0
- package/lib/config-register/layout.d.ts +5 -0
- package/lib/config-register/layout.js +68 -0
- package/lib/config-register/layout.js.map +1 -0
- package/lib/config-register/listview.d.ts +3 -0
- package/lib/config-register/listview.js +71 -0
- package/lib/config-register/listview.js.map +1 -0
- package/lib/config-register/method.d.ts +3 -0
- package/lib/config-register/method.js +83 -0
- package/lib/config-register/method.js.map +1 -0
- package/lib/config-register/object_translations.d.ts +2 -0
- package/lib/config-register/object_translations.js +41 -0
- package/lib/config-register/object_translations.js.map +1 -0
- package/lib/config-register/originalObject.d.ts +1 -0
- package/lib/config-register/originalObject.js +11 -0
- package/lib/config-register/originalObject.js.map +1 -0
- package/lib/config-register/package.d.ts +1 -0
- package/lib/config-register/package.js +357 -0
- package/lib/config-register/package.js.map +1 -0
- package/lib/config-register/page.d.ts +1 -0
- package/lib/config-register/page.js +26 -0
- package/lib/config-register/page.js.map +1 -0
- package/lib/config-register/permission.d.ts +4 -0
- package/lib/config-register/permission.js +102 -0
- package/lib/config-register/permission.js.map +1 -0
- package/lib/config-register/permissionset.d.ts +5 -0
- package/lib/config-register/permissionset.js +100 -0
- package/lib/config-register/permissionset.js.map +1 -0
- package/lib/config-register/preload_data.d.ts +8 -0
- package/lib/config-register/preload_data.js +172 -0
- package/lib/config-register/preload_data.js.map +1 -0
- package/lib/config-register/profile.d.ts +5 -0
- package/lib/config-register/profile.js +108 -0
- package/lib/config-register/profile.js.map +1 -0
- package/lib/config-register/query.d.ts +1 -0
- package/lib/config-register/query.js +26 -0
- package/lib/config-register/query.js.map +1 -0
- package/lib/config-register/restrictionRules.d.ts +1 -0
- package/lib/config-register/restrictionRules.js +26 -0
- package/lib/config-register/restrictionRules.js.map +1 -0
- package/lib/config-register/role.d.ts +4 -0
- package/lib/config-register/role.js +65 -0
- package/lib/config-register/role.js.map +1 -0
- package/lib/config-register/shareRules.d.ts +1 -0
- package/lib/config-register/shareRules.js +26 -0
- package/lib/config-register/shareRules.js.map +1 -0
- package/lib/config-register/tab.d.ts +1 -0
- package/lib/config-register/tab.js +20 -0
- package/lib/config-register/tab.js.map +1 -0
- package/lib/config-register/tabs.d.ts +2 -0
- package/lib/config-register/tabs.js +14 -0
- package/lib/config-register/tabs.js.map +1 -0
- package/lib/config-register/translations.d.ts +2 -0
- package/lib/config-register/translations.js +42 -0
- package/lib/config-register/translations.js.map +1 -0
- package/lib/config-register/trigger.d.ts +6 -0
- package/lib/config-register/trigger.js +231 -0
- package/lib/config-register/trigger.js.map +1 -0
- package/lib/config-register/validation_rule.d.ts +6 -0
- package/lib/config-register/validation_rule.js +88 -0
- package/lib/config-register/validation_rule.js.map +1 -0
- package/lib/config-register/workflow.d.ts +17 -0
- package/lib/config-register/workflow.js +158 -0
- package/lib/config-register/workflow.js.map +1 -0
- package/lib/config.d.ts +10 -0
- package/lib/config.js +124 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +35 -1
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -1
- package/lib/metadata-register/_base.d.ts +12 -0
- package/lib/metadata-register/_base.js +92 -0
- package/lib/metadata-register/_base.js.map +1 -0
- package/lib/metadata-register/app.d.ts +4 -0
- package/lib/metadata-register/app.js +44 -0
- package/lib/metadata-register/app.js.map +1 -0
- package/lib/metadata-register/chart.d.ts +6 -0
- package/lib/metadata-register/chart.js +12 -0
- package/lib/metadata-register/chart.js.map +1 -0
- package/lib/metadata-register/index.d.ts +33 -0
- package/lib/metadata-register/index.js +142 -0
- package/lib/metadata-register/index.js.map +1 -0
- package/lib/metadata-register/layout.d.ts +5 -0
- package/lib/metadata-register/layout.js +54 -0
- package/lib/metadata-register/layout.js.map +1 -0
- package/lib/metadata-register/object.d.ts +5 -0
- package/lib/metadata-register/object.js +76 -0
- package/lib/metadata-register/object.js.map +1 -0
- package/lib/metadata-register/page.d.ts +6 -0
- package/lib/metadata-register/page.js +12 -0
- package/lib/metadata-register/page.js.map +1 -0
- package/lib/metadata-register/permissionFields.d.ts +7 -0
- package/lib/metadata-register/permissionFields.js +15 -0
- package/lib/metadata-register/permissionFields.js.map +1 -0
- package/lib/metadata-register/permissionset.d.ts +3 -0
- package/lib/metadata-register/permissionset.js +37 -0
- package/lib/metadata-register/permissionset.js.map +1 -0
- package/lib/metadata-register/process.d.ts +6 -0
- package/lib/metadata-register/process.js +12 -0
- package/lib/metadata-register/process.js.map +1 -0
- package/lib/metadata-register/processTrigger.d.ts +7 -0
- package/lib/metadata-register/processTrigger.js +15 -0
- package/lib/metadata-register/processTrigger.js.map +1 -0
- package/lib/metadata-register/profile.d.ts +3 -0
- package/lib/metadata-register/profile.js +37 -0
- package/lib/metadata-register/profile.js.map +1 -0
- package/lib/metadata-register/query.d.ts +6 -0
- package/lib/metadata-register/query.js +12 -0
- package/lib/metadata-register/query.js.map +1 -0
- package/lib/metadata-register/restrictionRules.d.ts +7 -0
- package/lib/metadata-register/restrictionRules.js +15 -0
- package/lib/metadata-register/restrictionRules.js.map +1 -0
- package/lib/metadata-register/shareRules.d.ts +7 -0
- package/lib/metadata-register/shareRules.js +15 -0
- package/lib/metadata-register/shareRules.js.map +1 -0
- package/lib/metadata-register/tab.d.ts +6 -0
- package/lib/metadata-register/tab.js +12 -0
- package/lib/metadata-register/tab.js.map +1 -0
- package/lib/metadata-register/tabs.d.ts +5 -0
- package/lib/metadata-register/tabs.js +54 -0
- package/lib/metadata-register/tabs.js.map +1 -0
- package/lib/utils/convert.d.ts +2 -0
- package/lib/utils/convert.js +130 -0
- package/lib/utils/convert.js.map +1 -0
- package/lib/utils/index.d.ts +35 -0
- package/lib/utils/index.js +437 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/transform.d.ts +2 -0
- package/lib/utils/transform.js +209 -0
- package/lib/utils/transform.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterTabs = exports.getTabs = exports.getTab = exports.removeTab = exports.registerTab = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const clone = require('clone');
|
|
6
|
+
const SERVICE_NAME = 'tabs';
|
|
7
|
+
function registerTab(broker, serviceName, config) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const metadata = clone(config);
|
|
10
|
+
delete metadata.triggers;
|
|
11
|
+
const res = yield broker.call(`${SERVICE_NAME}.add`, { tabApiName: metadata.name, data: metadata }, { meta: {
|
|
12
|
+
metadataServiceName: serviceName,
|
|
13
|
+
caller: {
|
|
14
|
+
nodeID: broker.nodeID,
|
|
15
|
+
service: {
|
|
16
|
+
name: serviceName,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
} });
|
|
20
|
+
return res;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.registerTab = registerTab;
|
|
24
|
+
function removeTab(broker, tabApiName) {
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const res = yield broker.call(`${SERVICE_NAME}.delete`, { tabApiName: tabApiName });
|
|
27
|
+
return res;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.removeTab = removeTab;
|
|
31
|
+
function getTab(broker, tabApiName) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const res = yield broker.call(`${SERVICE_NAME}.get`, { tabApiName: tabApiName });
|
|
34
|
+
return res;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.getTab = getTab;
|
|
38
|
+
function getTabs(broker) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const res = yield broker.call(`${SERVICE_NAME}.getAll`);
|
|
41
|
+
return res;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.getTabs = getTabs;
|
|
45
|
+
function filterTabs(broker, tabApiName, spaceId, objectApiName) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const res = yield broker.call(`${SERVICE_NAME}.filter`, {
|
|
48
|
+
objectApiName, spaceId, tabApiName
|
|
49
|
+
});
|
|
50
|
+
return res;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.filterTabs = filterTabs;
|
|
54
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/metadata-register/tabs.ts"],"names":[],"mappings":";;;;AAAA,MAAM,KA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ED,SAAsB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAQ,EAAE,aAAc;;QACzE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,SAAS,EAAE;YACpD,aAAa,EAAE,OAAO,EAAE,UAAU;SACrC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACf,CAAC;CAAA;AALD,gCAKC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectToJson = exports.jsonToObject = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
function funEval(funStr) {
|
|
6
|
+
try {
|
|
7
|
+
return eval(funStr);
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
console.error(e, funStr);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
;
|
|
14
|
+
function jsonToObject(objectMetadata) {
|
|
15
|
+
_.forEach(objectMetadata.fields, (field, key) => {
|
|
16
|
+
const _reference_to = field._reference_to;
|
|
17
|
+
if (_reference_to && _.isString(_reference_to)) {
|
|
18
|
+
field.reference_to = funEval(`(${_reference_to})`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.jsonToObject = jsonToObject;
|
|
23
|
+
function objectToJson(objectConfig) {
|
|
24
|
+
_.forEach(objectConfig.actions, (action, key) => {
|
|
25
|
+
const _todo = action === null || action === void 0 ? void 0 : action.todo;
|
|
26
|
+
if (_todo && _.isFunction(_todo)) {
|
|
27
|
+
action.todo = _todo.toString();
|
|
28
|
+
action._todo = _todo.toString();
|
|
29
|
+
}
|
|
30
|
+
const _visible = action === null || action === void 0 ? void 0 : action.visible;
|
|
31
|
+
if (_visible && _.isFunction(_visible)) {
|
|
32
|
+
action._visible = _visible.toString();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
_.forEach(objectConfig.fields, (field, key) => {
|
|
36
|
+
const options = field.options;
|
|
37
|
+
if (options && _.isFunction(options)) {
|
|
38
|
+
field._options = field.options.toString();
|
|
39
|
+
}
|
|
40
|
+
if (field.regEx) {
|
|
41
|
+
field._regEx = field.regEx.toString();
|
|
42
|
+
}
|
|
43
|
+
if (_.isFunction(field.min)) {
|
|
44
|
+
field._min = field.min.toString();
|
|
45
|
+
}
|
|
46
|
+
if (_.isFunction(field.max)) {
|
|
47
|
+
field._max = field.max.toString();
|
|
48
|
+
}
|
|
49
|
+
if (field.autoform) {
|
|
50
|
+
const _type = field.autoform.type;
|
|
51
|
+
if (_type && _.isFunction(_type) && _type != Object && _type != String && _type != Number && _type != Boolean && !_.isArray(_type)) {
|
|
52
|
+
field.autoform._type = _type.toString();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const optionsFunction = field.optionsFunction;
|
|
56
|
+
const reference_to = field.reference_to;
|
|
57
|
+
const createFunction = field.createFunction;
|
|
58
|
+
const beforeOpenFunction = field.beforeOpenFunction;
|
|
59
|
+
const filtersFunction = field.filtersFunction;
|
|
60
|
+
if (optionsFunction && _.isFunction(optionsFunction)) {
|
|
61
|
+
field._optionsFunction = optionsFunction.toString();
|
|
62
|
+
}
|
|
63
|
+
if (reference_to && _.isFunction(reference_to)) {
|
|
64
|
+
field._reference_to = reference_to.toString();
|
|
65
|
+
}
|
|
66
|
+
if (createFunction && _.isFunction(createFunction)) {
|
|
67
|
+
field._createFunction = createFunction.toString();
|
|
68
|
+
}
|
|
69
|
+
if (beforeOpenFunction && _.isFunction(beforeOpenFunction)) {
|
|
70
|
+
field._beforeOpenFunction = beforeOpenFunction.toString();
|
|
71
|
+
}
|
|
72
|
+
if (filtersFunction && _.isFunction(filtersFunction)) {
|
|
73
|
+
field._filtersFunction = filtersFunction.toString();
|
|
74
|
+
}
|
|
75
|
+
const defaultValue = field.defaultValue;
|
|
76
|
+
if (defaultValue && _.isFunction(defaultValue)) {
|
|
77
|
+
field._defaultValue = field.defaultValue.toString();
|
|
78
|
+
}
|
|
79
|
+
const is_company_limited = field.is_company_limited;
|
|
80
|
+
if (is_company_limited && _.isFunction(is_company_limited)) {
|
|
81
|
+
field._is_company_limited = field.is_company_limited.toString();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
_.forEach(objectConfig.list_views, (list_view, key) => {
|
|
85
|
+
if (_.isFunction(list_view.filters)) {
|
|
86
|
+
list_view._filters = list_view.filters.toString();
|
|
87
|
+
}
|
|
88
|
+
else if (_.isArray(list_view.filters)) {
|
|
89
|
+
_.forEach(list_view.filters, (filter, _index) => {
|
|
90
|
+
if (_.isArray(filter)) {
|
|
91
|
+
if (filter.length == 3 && _.isFunction(filter[2])) {
|
|
92
|
+
filter[2] = filter[2].toString();
|
|
93
|
+
filter[3] = "FUNCTION";
|
|
94
|
+
}
|
|
95
|
+
else if (filter.length == 3 && _.isDate(filter[2])) {
|
|
96
|
+
filter[3] = "DATE";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (_.isObject(filter)) {
|
|
100
|
+
if (_.isFunction(filter === null || filter === void 0 ? void 0 : filter.value)) {
|
|
101
|
+
filter._value = filter.value.toString();
|
|
102
|
+
}
|
|
103
|
+
else if (_.isDate(filter === null || filter === void 0 ? void 0 : filter.value)) {
|
|
104
|
+
filter._is_date = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (objectConfig.form && !_.isString(objectConfig.form)) {
|
|
111
|
+
objectConfig.form = JSON.stringify(objectConfig.form, (key, val) => {
|
|
112
|
+
if (_.isFunction(val))
|
|
113
|
+
return val + '';
|
|
114
|
+
else
|
|
115
|
+
return val;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
_.forEach(objectConfig.relatedList, (relatedObjInfo) => {
|
|
119
|
+
if (_.isObject(relatedObjInfo)) {
|
|
120
|
+
_.forEach(relatedObjInfo, (val, key) => {
|
|
121
|
+
if (key == 'filters' && _.isFunction(val)) {
|
|
122
|
+
relatedObjInfo[key] = val.toString();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return objectConfig;
|
|
128
|
+
}
|
|
129
|
+
exports.objectToJson = objectToJson;
|
|
130
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/utils/convert.ts"],"names":[],"mappings":";;;AAAA,4BAA4B;AAE5B,SAAS,OAAO,CAAC,MAAM;IACnB,IAAI;QACA,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;KACtB;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;KAC5B;AACL,CAAC;AAAA,CAAC;AAEF,SAAgB,YAAY,CAAC,cAAc;IACvC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QAC1C,IAAI,aAAa,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YAC5C,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,aAAa,GAAG,CAAC,CAAC;SACtD;IACL,CAAC,CAAC,CAAA;AACN,CAAC;AAPD,oCAOC;AAED,SAAgB,YAAY,CAAC,YAAY;IACrC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAA;QAC1B,IAAI,KAAK,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;YAC9B,MAA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/ts-types';
|
|
2
|
+
export declare const loadFile: (filePath: string) => JsonMap;
|
|
3
|
+
export declare function wrapAsync(fn: any, context: any): any;
|
|
4
|
+
export declare function JSONStringify(data: any): string;
|
|
5
|
+
export declare function extend(destination: JsonMap, ...sources: JsonMap[]): JsonMap;
|
|
6
|
+
export declare const loadProcessTriggers: (filePath: string) => any[];
|
|
7
|
+
export declare const loadPermissions: (filePath: string) => any[];
|
|
8
|
+
export declare const loadObjects: (filePath: string) => any[];
|
|
9
|
+
export declare const loadFields: (filePath: string) => any[];
|
|
10
|
+
export declare const loadListViews: (filePath: string) => any[];
|
|
11
|
+
export declare const loadButtons: (filePath: string) => any[];
|
|
12
|
+
export declare const loadButtonScripts: (filePath: string) => any[];
|
|
13
|
+
export declare const loadActions: (filePath: string) => any[];
|
|
14
|
+
export declare const loadRouters: (filePath: string) => any[];
|
|
15
|
+
export declare const loadI18n: (filePath: string) => any[];
|
|
16
|
+
export declare function loadObjectDataFiles(filePath: string): any[];
|
|
17
|
+
export declare const loadLayouts: (filePath: string) => any[];
|
|
18
|
+
export declare const loadObjectTranslations: (filePath: string) => any[];
|
|
19
|
+
export declare const loadTranslations: (filePath: string) => any[];
|
|
20
|
+
export declare enum CanLoadedMetadataType {
|
|
21
|
+
Object = "Object",
|
|
22
|
+
App = "App",
|
|
23
|
+
Trigger = "Trigger",
|
|
24
|
+
ProcessTrigger = "ProcessTrigger",
|
|
25
|
+
TriggerYml = "TriggerYml",
|
|
26
|
+
ClientJS = "ClientJS",
|
|
27
|
+
ObjectJS = "ObjectJS",
|
|
28
|
+
Router = "Router",
|
|
29
|
+
Process = "Process",
|
|
30
|
+
Flow = "Flow",
|
|
31
|
+
Translation = "Translation",
|
|
32
|
+
ObjectTranslation = "ObjectTranslation",
|
|
33
|
+
PublicFolder = "PublicFolder"
|
|
34
|
+
}
|
|
35
|
+
export declare const canLoadMetadata: (metadataType: CanLoadedMetadataType) => any;
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canLoadMetadata = exports.CanLoadedMetadataType = exports.loadTranslations = exports.loadObjectTranslations = exports.loadLayouts = exports.loadObjectDataFiles = exports.loadI18n = exports.loadRouters = exports.loadActions = exports.loadButtonScripts = exports.loadButtons = exports.loadListViews = exports.loadFields = exports.loadObjects = exports.loadPermissions = exports.loadProcessTriggers = exports.extend = exports.JSONStringify = exports.wrapAsync = exports.loadFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
6
|
+
const metadata_core_1 = require("@steedos/metadata-core");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const _ = require('underscore');
|
|
10
|
+
const lodash = require('lodash');
|
|
11
|
+
var clone = require('clone');
|
|
12
|
+
const yaml = require('js-yaml');
|
|
13
|
+
const loadFile = (filePath) => {
|
|
14
|
+
let json = {};
|
|
15
|
+
try {
|
|
16
|
+
let extname = path.extname(filePath);
|
|
17
|
+
if (extname.toLocaleLowerCase() == '.json')
|
|
18
|
+
json = JSON.parse(fs.readFileSync(filePath, 'utf8').normalize('NFC'));
|
|
19
|
+
else if (extname.toLocaleLowerCase() == '.yml')
|
|
20
|
+
json = yaml.load(fs.readFileSync(filePath, 'utf8'));
|
|
21
|
+
else if (extname.toLocaleLowerCase() == '.js')
|
|
22
|
+
json = clone(require(filePath));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error('loadFile error', filePath, error);
|
|
26
|
+
}
|
|
27
|
+
return json;
|
|
28
|
+
};
|
|
29
|
+
exports.loadFile = loadFile;
|
|
30
|
+
function wrapAsync(fn, context) {
|
|
31
|
+
try {
|
|
32
|
+
const Future = require('fibers/future');
|
|
33
|
+
let proxyFn = function (_cb) {
|
|
34
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let value = null;
|
|
36
|
+
let error = null;
|
|
37
|
+
try {
|
|
38
|
+
value = yield fn.call(context);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
error = err;
|
|
42
|
+
}
|
|
43
|
+
_cb(error, value);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
let fut = new Future();
|
|
47
|
+
let callback = fut.resolver();
|
|
48
|
+
let result = proxyFn.apply(this, [callback]);
|
|
49
|
+
return fut ? fut.wait() : result;
|
|
50
|
+
}
|
|
51
|
+
catch (Exception) {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.wrapAsync = wrapAsync;
|
|
55
|
+
function JSONStringify(data) {
|
|
56
|
+
return JSON.stringify(data, function (key, val) {
|
|
57
|
+
if (typeof val === 'function') {
|
|
58
|
+
return val + '';
|
|
59
|
+
}
|
|
60
|
+
return val;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.JSONStringify = JSONStringify;
|
|
64
|
+
function extend(destination, ...sources) {
|
|
65
|
+
_.each(sources, (source) => {
|
|
66
|
+
_.each(source, (v, k) => {
|
|
67
|
+
if (!(0, ts_types_1.has)(destination, k)) {
|
|
68
|
+
destination[k] = v;
|
|
69
|
+
}
|
|
70
|
+
else if ((0, ts_types_1.isJsonMap)(v)) {
|
|
71
|
+
let _d = (0, ts_types_1.getJsonMap)(destination, k);
|
|
72
|
+
if ((0, ts_types_1.isJsonMap)(_d)) {
|
|
73
|
+
destination[k] = extend(clone(_d), v);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
destination[k] = v;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
destination[k] = v;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return destination;
|
|
85
|
+
}
|
|
86
|
+
exports.extend = extend;
|
|
87
|
+
const loadProcessTriggers = (filePath) => {
|
|
88
|
+
let results = [];
|
|
89
|
+
const filePatten = [
|
|
90
|
+
path.join(filePath, "*.processTrigger.js"),
|
|
91
|
+
"!" + path.join(filePath, "node_modules"),
|
|
92
|
+
];
|
|
93
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
94
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
95
|
+
delete require.cache[require.resolve(matchedPath)];
|
|
96
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
97
|
+
if (!_.has(json, "listenTo")) {
|
|
98
|
+
json.listenTo = path.basename(matchedPath).split(".")[0];
|
|
99
|
+
}
|
|
100
|
+
results.push(json);
|
|
101
|
+
});
|
|
102
|
+
return results;
|
|
103
|
+
};
|
|
104
|
+
exports.loadProcessTriggers = loadProcessTriggers;
|
|
105
|
+
const loadPermissions = (filePath) => {
|
|
106
|
+
let results = [];
|
|
107
|
+
const filePatten = [
|
|
108
|
+
path.join(filePath, "*.permission.yml"),
|
|
109
|
+
"!" + path.join(filePath, "node_modules"),
|
|
110
|
+
];
|
|
111
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
112
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
113
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
114
|
+
if (!_.has(json, 'object_name')) {
|
|
115
|
+
json.object_name = path.parse(path.dirname(path.dirname(matchedPath))).name;
|
|
116
|
+
}
|
|
117
|
+
json.name = path.basename(matchedPath).split('.')[0];
|
|
118
|
+
results.push(json);
|
|
119
|
+
});
|
|
120
|
+
return results;
|
|
121
|
+
};
|
|
122
|
+
exports.loadPermissions = loadPermissions;
|
|
123
|
+
const loadObjects = (filePath) => {
|
|
124
|
+
let results = [];
|
|
125
|
+
const filePatten = [
|
|
126
|
+
path.join(filePath, "*.object.yml"),
|
|
127
|
+
path.join(filePath, "*.object.json"),
|
|
128
|
+
"!" + path.join(filePath, "node_modules"),
|
|
129
|
+
];
|
|
130
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
131
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
132
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
133
|
+
try {
|
|
134
|
+
if (json) {
|
|
135
|
+
json.__filename = matchedPath;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.error("loadObjects error", matchedPath, error);
|
|
140
|
+
}
|
|
141
|
+
results.push(json);
|
|
142
|
+
});
|
|
143
|
+
return results;
|
|
144
|
+
};
|
|
145
|
+
exports.loadObjects = loadObjects;
|
|
146
|
+
const loadFields = (filePath) => {
|
|
147
|
+
let results = [];
|
|
148
|
+
const filePatten = [
|
|
149
|
+
path.join(filePath, "*.field.yml"),
|
|
150
|
+
"!" + path.join(filePath, "node_modules"),
|
|
151
|
+
];
|
|
152
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
153
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
154
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
155
|
+
if (!json.name) {
|
|
156
|
+
json.name = path.basename(matchedPath).split(".")[0];
|
|
157
|
+
}
|
|
158
|
+
if (!json.object_name) {
|
|
159
|
+
json.object_name = path.parse(path.dirname(path.dirname(matchedPath))).name;
|
|
160
|
+
}
|
|
161
|
+
results.push(json);
|
|
162
|
+
});
|
|
163
|
+
return results;
|
|
164
|
+
};
|
|
165
|
+
exports.loadFields = loadFields;
|
|
166
|
+
const loadListViews = (filePath) => {
|
|
167
|
+
let results = [];
|
|
168
|
+
const filePatten = [
|
|
169
|
+
path.join(filePath, "*.listview.yml"),
|
|
170
|
+
"!" + path.join(filePath, "node_modules"),
|
|
171
|
+
];
|
|
172
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
173
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
174
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
175
|
+
if (!json.name) {
|
|
176
|
+
json.name = path.basename(matchedPath).split('.')[0];
|
|
177
|
+
}
|
|
178
|
+
if (!json.object_name) {
|
|
179
|
+
json.object_name = path.parse(path.dirname(path.dirname(matchedPath))).name;
|
|
180
|
+
}
|
|
181
|
+
results.push(json);
|
|
182
|
+
});
|
|
183
|
+
return results;
|
|
184
|
+
};
|
|
185
|
+
exports.loadListViews = loadListViews;
|
|
186
|
+
const loadButtons = (filePath) => {
|
|
187
|
+
let results = [];
|
|
188
|
+
const filePatten = [
|
|
189
|
+
path.join(filePath, "*.button.yml"),
|
|
190
|
+
"!" + path.join(filePath, "node_modules"),
|
|
191
|
+
];
|
|
192
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
193
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
194
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
195
|
+
if (!json.name) {
|
|
196
|
+
json.name = path.basename(matchedPath).split('.')[0];
|
|
197
|
+
}
|
|
198
|
+
if (!json.object_name) {
|
|
199
|
+
json.object_name = path.parse(path.dirname(path.dirname(matchedPath))).name;
|
|
200
|
+
}
|
|
201
|
+
results.push(json);
|
|
202
|
+
});
|
|
203
|
+
return results;
|
|
204
|
+
};
|
|
205
|
+
exports.loadButtons = loadButtons;
|
|
206
|
+
const loadButtonScripts = (filePath) => {
|
|
207
|
+
let results = [];
|
|
208
|
+
const filePatten = [
|
|
209
|
+
path.join(filePath, "*.button.js"),
|
|
210
|
+
"!" + path.join(filePath, "node_modules"),
|
|
211
|
+
];
|
|
212
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
213
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
214
|
+
delete require.cache[require.resolve(matchedPath)];
|
|
215
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
216
|
+
if (!_.has(json, 'listenTo')) {
|
|
217
|
+
json.listenTo = path.parse(path.dirname(path.dirname(matchedPath))).name;
|
|
218
|
+
}
|
|
219
|
+
results.push(json);
|
|
220
|
+
});
|
|
221
|
+
return results;
|
|
222
|
+
};
|
|
223
|
+
exports.loadButtonScripts = loadButtonScripts;
|
|
224
|
+
const loadActions = (filePath) => {
|
|
225
|
+
let results = [];
|
|
226
|
+
const filePatten = [
|
|
227
|
+
path.join(filePath, "*.action.js"),
|
|
228
|
+
"!" + path.join(filePath, "node_modules"),
|
|
229
|
+
];
|
|
230
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
231
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
232
|
+
delete require.cache[require.resolve(matchedPath)];
|
|
233
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
234
|
+
if (!_.has(json, "listenTo")) {
|
|
235
|
+
json.listenTo = path.basename(matchedPath).split(".")[0];
|
|
236
|
+
}
|
|
237
|
+
results.push(json);
|
|
238
|
+
});
|
|
239
|
+
return results;
|
|
240
|
+
};
|
|
241
|
+
exports.loadActions = loadActions;
|
|
242
|
+
const getRouterInfoList = (router, md5) => {
|
|
243
|
+
const infoList = [];
|
|
244
|
+
if (router &&
|
|
245
|
+
router.default &&
|
|
246
|
+
router.default.stack &&
|
|
247
|
+
router.default.stack.length > 0) {
|
|
248
|
+
_.each(router.default.stack, (_route) => {
|
|
249
|
+
const info = {
|
|
250
|
+
path: "",
|
|
251
|
+
methods: "",
|
|
252
|
+
md5: md5,
|
|
253
|
+
};
|
|
254
|
+
if (_route.route) {
|
|
255
|
+
info.path = _route.route.path;
|
|
256
|
+
info.methods = _route.route.methods;
|
|
257
|
+
infoList.push(info);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return infoList;
|
|
262
|
+
};
|
|
263
|
+
const getFileMD5 = (filePath) => {
|
|
264
|
+
const buffer = fs.readFileSync(filePath);
|
|
265
|
+
return (0, metadata_core_1.getMD5)(buffer);
|
|
266
|
+
};
|
|
267
|
+
const loadRouters = (filePath) => {
|
|
268
|
+
let results = [];
|
|
269
|
+
const filePatten = [
|
|
270
|
+
path.join(filePath, "*.router.js"),
|
|
271
|
+
"!" + path.join(filePath, "node_modules"),
|
|
272
|
+
];
|
|
273
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
274
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
275
|
+
delete require.cache[require.resolve(matchedPath)];
|
|
276
|
+
let router = (0, exports.loadFile)(matchedPath);
|
|
277
|
+
let md5 = getFileMD5(matchedPath);
|
|
278
|
+
let infoList = getRouterInfoList(router, md5);
|
|
279
|
+
results.push({ router: router, infoList: infoList });
|
|
280
|
+
});
|
|
281
|
+
return results;
|
|
282
|
+
};
|
|
283
|
+
exports.loadRouters = loadRouters;
|
|
284
|
+
function getI18nLng(filePath) {
|
|
285
|
+
try {
|
|
286
|
+
let pathJson = path.parse(filePath);
|
|
287
|
+
let filename = pathJson.base;
|
|
288
|
+
if (filename) {
|
|
289
|
+
let f = filename.split(".");
|
|
290
|
+
if (f.length >= 3) {
|
|
291
|
+
return f[f.length - 3];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
console.log(`getI18nLng warn: Invalid file: ${filePath}`);
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
console.error(`getI18nLng error: ${filePath}`, error);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const loadI18n = (filePath) => {
|
|
301
|
+
let results = [];
|
|
302
|
+
const filePatten = [
|
|
303
|
+
path.join(filePath, "*.i18n.yml"),
|
|
304
|
+
path.join(filePath, "*.i18n.json"),
|
|
305
|
+
"!" + path.join(filePath, "node_modules"),
|
|
306
|
+
];
|
|
307
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
308
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
309
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
310
|
+
let lng = getI18nLng(matchedPath);
|
|
311
|
+
if (lng) {
|
|
312
|
+
results.push({ lng: lng, __filename: matchedPath, data: json });
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return results;
|
|
316
|
+
};
|
|
317
|
+
exports.loadI18n = loadI18n;
|
|
318
|
+
function loadObjectDataFiles(filePath) {
|
|
319
|
+
let results = [];
|
|
320
|
+
const filePatten = [
|
|
321
|
+
path.join(filePath, "*.data.json"),
|
|
322
|
+
"!" + path.join(filePath, "node_modules"),
|
|
323
|
+
];
|
|
324
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
325
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
326
|
+
let records = (0, exports.loadFile)(matchedPath);
|
|
327
|
+
let objectName = path.basename(matchedPath).split('.')[0];
|
|
328
|
+
results.push({ objectName: objectName, records: records });
|
|
329
|
+
});
|
|
330
|
+
return results;
|
|
331
|
+
}
|
|
332
|
+
exports.loadObjectDataFiles = loadObjectDataFiles;
|
|
333
|
+
const loadLayouts = (filePath) => {
|
|
334
|
+
let results = [];
|
|
335
|
+
const filePatten = [
|
|
336
|
+
path.join(filePath, "*.layout.yml"),
|
|
337
|
+
"!" + path.join(filePath, "node_modules"),
|
|
338
|
+
];
|
|
339
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
340
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
341
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
342
|
+
let names = path.basename(matchedPath).split(".");
|
|
343
|
+
if (!json.name) {
|
|
344
|
+
json.name = names[1];
|
|
345
|
+
}
|
|
346
|
+
if (!json.object_name) {
|
|
347
|
+
json.object_name = names[0];
|
|
348
|
+
}
|
|
349
|
+
results.push(json);
|
|
350
|
+
});
|
|
351
|
+
return results;
|
|
352
|
+
};
|
|
353
|
+
exports.loadLayouts = loadLayouts;
|
|
354
|
+
function getObjectApiName(filePath) {
|
|
355
|
+
try {
|
|
356
|
+
let pathJson = path.parse(filePath);
|
|
357
|
+
let filename = pathJson.base;
|
|
358
|
+
if (filename) {
|
|
359
|
+
let f = filename.split(".");
|
|
360
|
+
if (f.length >= 3) {
|
|
361
|
+
return f[0];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
console.log(`getObjectApiName warn: Invalid file: ${filePath}`);
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
console.error(`getObjectApiName error: ${filePath}`, error);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const loadObjectTranslations = (filePath) => {
|
|
371
|
+
let results = [];
|
|
372
|
+
const filePatten = [
|
|
373
|
+
path.join(filePath, "*.objectTranslation.yml"),
|
|
374
|
+
"!" + path.join(filePath, "node_modules"),
|
|
375
|
+
];
|
|
376
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
377
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
378
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
379
|
+
let lng = getI18nLng(matchedPath);
|
|
380
|
+
let objectApiName = getObjectApiName(matchedPath);
|
|
381
|
+
if (lng) {
|
|
382
|
+
results.push({
|
|
383
|
+
lng: lng,
|
|
384
|
+
objectApiName,
|
|
385
|
+
__filename: matchedPath,
|
|
386
|
+
data: json,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
return results;
|
|
391
|
+
};
|
|
392
|
+
exports.loadObjectTranslations = loadObjectTranslations;
|
|
393
|
+
const loadTranslations = (filePath) => {
|
|
394
|
+
let results = [];
|
|
395
|
+
const filePatten = [
|
|
396
|
+
path.join(filePath, "*.translation.yml"),
|
|
397
|
+
"!" + path.join(filePath, "node_modules"),
|
|
398
|
+
];
|
|
399
|
+
const matchedPaths = (0, metadata_core_1.syncMatchFiles)(filePatten);
|
|
400
|
+
_.each(matchedPaths, (matchedPath) => {
|
|
401
|
+
let json = (0, exports.loadFile)(matchedPath);
|
|
402
|
+
let lng = getI18nLng(matchedPath);
|
|
403
|
+
if (lng) {
|
|
404
|
+
results.push({ lng: lng, __filename: matchedPath, data: json });
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
return results;
|
|
408
|
+
};
|
|
409
|
+
exports.loadTranslations = loadTranslations;
|
|
410
|
+
var CanLoadedMetadataType;
|
|
411
|
+
(function (CanLoadedMetadataType) {
|
|
412
|
+
CanLoadedMetadataType["Object"] = "Object";
|
|
413
|
+
CanLoadedMetadataType["App"] = "App";
|
|
414
|
+
CanLoadedMetadataType["Trigger"] = "Trigger";
|
|
415
|
+
CanLoadedMetadataType["ProcessTrigger"] = "ProcessTrigger";
|
|
416
|
+
CanLoadedMetadataType["TriggerYml"] = "TriggerYml";
|
|
417
|
+
CanLoadedMetadataType["ClientJS"] = "ClientJS";
|
|
418
|
+
CanLoadedMetadataType["ObjectJS"] = "ObjectJS";
|
|
419
|
+
CanLoadedMetadataType["Router"] = "Router";
|
|
420
|
+
CanLoadedMetadataType["Process"] = "Process";
|
|
421
|
+
CanLoadedMetadataType["Flow"] = "Flow";
|
|
422
|
+
CanLoadedMetadataType["Translation"] = "Translation";
|
|
423
|
+
CanLoadedMetadataType["ObjectTranslation"] = "ObjectTranslation";
|
|
424
|
+
CanLoadedMetadataType["PublicFolder"] = "PublicFolder";
|
|
425
|
+
})(CanLoadedMetadataType = exports.CanLoadedMetadataType || (exports.CanLoadedMetadataType = {}));
|
|
426
|
+
const canLoadMetadata = (metadataType) => {
|
|
427
|
+
if (!process.env.STEEDOS_PACKAGE_METADATA_TYPES) {
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
const allowedMetadataTypes = process.env.STEEDOS_PACKAGE_METADATA_TYPES.split(',');
|
|
431
|
+
if (allowedMetadataTypes.length == 0) {
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
return lodash.includes(allowedMetadataTypes, metadataType);
|
|
435
|
+
};
|
|
436
|
+
exports.canLoadMetadata = canLoadMetadata;
|
|
437
|
+
//# sourceMappingURL=index.js.map
|