x-essential-lib 0.11.2 → 0.11.4
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/dist/index.d.ts +47 -0
- package/dist/index.js +312 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -178,11 +178,58 @@ export interface PermissionMeta {
|
|
|
178
178
|
layers: Layer[];
|
|
179
179
|
}
|
|
180
180
|
//#endregion
|
|
181
|
+
//#region src/utils/permission/category.d.ts
|
|
182
|
+
export declare const funcPlaneCategories: Category[];
|
|
183
|
+
export declare const dataPlaneCategories: Category[];
|
|
184
|
+
export declare const permissionCategories: Category[];
|
|
185
|
+
export declare function getCategoryPlane(category: Category): Plane | undefined;
|
|
186
|
+
//#endregion
|
|
181
187
|
//#region src/utils/permission/meta.d.ts
|
|
182
188
|
export declare const allPermissionMetas: PermissionMeta[];
|
|
183
189
|
export declare function getCategoryPermissionMetas(category: Category): PermissionMeta[];
|
|
184
190
|
export declare function getPermissionMeta(permission: Permission): PermissionMeta | undefined;
|
|
185
191
|
//#endregion
|
|
192
|
+
//#region src/utils/permission/object.d.ts
|
|
193
|
+
type ComputeSpace = {
|
|
194
|
+
id: string;
|
|
195
|
+
funcGroups: string[];
|
|
196
|
+
funcs: string[];
|
|
197
|
+
flowGroups: string[];
|
|
198
|
+
flows: string[];
|
|
199
|
+
};
|
|
200
|
+
type DataSpace = {
|
|
201
|
+
id: string;
|
|
202
|
+
tableGroups: string[];
|
|
203
|
+
tables: string[];
|
|
204
|
+
};
|
|
205
|
+
type ResourceSpace = {
|
|
206
|
+
id: string;
|
|
207
|
+
};
|
|
208
|
+
export type Objects = {
|
|
209
|
+
app: {
|
|
210
|
+
apps: string[];
|
|
211
|
+
};
|
|
212
|
+
compute: {
|
|
213
|
+
spaces: ComputeSpace[];
|
|
214
|
+
};
|
|
215
|
+
data: {
|
|
216
|
+
devSpaces: DataSpace[];
|
|
217
|
+
prodSpaces: DataSpace[];
|
|
218
|
+
};
|
|
219
|
+
resource: {
|
|
220
|
+
spaces: ResourceSpace[];
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
export type Names = {
|
|
224
|
+
[key: string]: string;
|
|
225
|
+
};
|
|
226
|
+
export declare function initObjects(): Objects;
|
|
227
|
+
export declare function fetchObjectNames(orgId: string): Promise<{
|
|
228
|
+
objects: Objects;
|
|
229
|
+
names: Names;
|
|
230
|
+
}>;
|
|
231
|
+
export declare function getLayerObjects(objects: Objects, permission: Permission, category: Category, layer: Layer, keys: string[]): string[];
|
|
232
|
+
//#endregion
|
|
186
233
|
//#region src/utils/permission/permission.d.ts
|
|
187
234
|
type InstanceTree = {
|
|
188
235
|
[key: string]: InstanceTree;
|
package/dist/index.js
CHANGED
|
@@ -173,6 +173,22 @@ function onUnauthorized() {
|
|
|
173
173
|
router.replace({ path: `/passport/login` });
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/utils/permission/category.ts
|
|
178
|
+
const funcPlaneCategories = [
|
|
179
|
+
"app",
|
|
180
|
+
"compute",
|
|
181
|
+
"data",
|
|
182
|
+
"resource",
|
|
183
|
+
"org"
|
|
184
|
+
];
|
|
185
|
+
const dataPlaneCategories = ["filter"];
|
|
186
|
+
const permissionCategories = [...funcPlaneCategories, ...dataPlaneCategories];
|
|
187
|
+
function getCategoryPlane(category) {
|
|
188
|
+
if (funcPlaneCategories.find((entry) => entry === category) !== void 0) return "func";
|
|
189
|
+
if (dataPlaneCategories.find((entry) => entry === category) !== void 0) return "data";
|
|
190
|
+
}
|
|
191
|
+
|
|
176
192
|
//#endregion
|
|
177
193
|
//#region src/pb/orgbase/v1/permission.ts
|
|
178
194
|
let Permission = /* @__PURE__ */ function(Permission) {
|
|
@@ -1076,6 +1092,301 @@ function getPermissionMeta(permission) {
|
|
|
1076
1092
|
return allPermissionMetas.find((entry) => entry.permission === permission);
|
|
1077
1093
|
}
|
|
1078
1094
|
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/api/appbase/instance.ts
|
|
1097
|
+
const instance$4 = createAxios({
|
|
1098
|
+
baseUrl: "http://localhost/appbase/",
|
|
1099
|
+
onError: (error) => {
|
|
1100
|
+
messageError(getErrorMessage(error));
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
if (window.API_URL) instance$4.defaults.baseURL = window.API_URL + "/appbase/";
|
|
1104
|
+
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region src/api/appbase/index.ts
|
|
1107
|
+
function GetAppList(request) {
|
|
1108
|
+
return instance$4.post("getAppList", request);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
//#endregion
|
|
1112
|
+
//#region src/api/computebase/instance.ts
|
|
1113
|
+
const instance$3 = createAxios({
|
|
1114
|
+
baseUrl: "http://localhost/computebase/",
|
|
1115
|
+
onError: (error) => {
|
|
1116
|
+
messageError(getErrorMessage(error));
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
if (window.API_URL) instance$3.defaults.baseURL = window.API_URL + "/computebase/";
|
|
1120
|
+
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region src/api/computebase/index.ts
|
|
1123
|
+
function GetComputeSpaceList(request) {
|
|
1124
|
+
return instance$3.post("getSpaceList", request);
|
|
1125
|
+
}
|
|
1126
|
+
function GetFuncGroupList(request) {
|
|
1127
|
+
return instance$3.post("getFuncGroupList", request);
|
|
1128
|
+
}
|
|
1129
|
+
function GetFuncList(request) {
|
|
1130
|
+
return instance$3.post("getFuncList", request);
|
|
1131
|
+
}
|
|
1132
|
+
function GetFlowGroupList(request) {
|
|
1133
|
+
return instance$3.post("getFlowGroupList", request);
|
|
1134
|
+
}
|
|
1135
|
+
function GetFlowList(request) {
|
|
1136
|
+
return instance$3.post("getFlowList", request);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/api/data/instance.ts
|
|
1141
|
+
const instance$2 = createAxios({
|
|
1142
|
+
baseUrl: "http://localhost/data/",
|
|
1143
|
+
onError: (error) => {
|
|
1144
|
+
messageError(getErrorMessage(error));
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
if (window.API_URL) instance$2.defaults.baseURL = window.API_URL + "/data/";
|
|
1148
|
+
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region src/api/data/index.ts
|
|
1151
|
+
function GetDataSpaceList(request) {
|
|
1152
|
+
return instance$2.post("getSpaceList", request);
|
|
1153
|
+
}
|
|
1154
|
+
function GetTableGroupList(request) {
|
|
1155
|
+
return instance$2.post("getTableGroupList", request);
|
|
1156
|
+
}
|
|
1157
|
+
function GetTableList(request) {
|
|
1158
|
+
return instance$2.post("getTableList", request);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/api/resource/instance.ts
|
|
1163
|
+
const instance$1 = createAxios({
|
|
1164
|
+
baseUrl: "http://localhost/resource/",
|
|
1165
|
+
onError: (error) => {
|
|
1166
|
+
messageError(getErrorMessage(error));
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
if (window.API_URL) instance$1.defaults.baseURL = window.API_URL + "/resource/";
|
|
1170
|
+
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region src/api/resource/index.ts
|
|
1173
|
+
function GetResourceSpaceList(request) {
|
|
1174
|
+
return instance$1.post("getSpaceList", request);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/utils/permission/object.ts
|
|
1179
|
+
function initObjects() {
|
|
1180
|
+
return {
|
|
1181
|
+
app: { apps: [] },
|
|
1182
|
+
compute: { spaces: [] },
|
|
1183
|
+
data: {
|
|
1184
|
+
devSpaces: [],
|
|
1185
|
+
prodSpaces: []
|
|
1186
|
+
},
|
|
1187
|
+
resource: { spaces: [] }
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
async function fetchObjectNames(orgId) {
|
|
1191
|
+
const objects = initObjects();
|
|
1192
|
+
const names = {};
|
|
1193
|
+
await fetchApp(orgId, objects, names);
|
|
1194
|
+
await fetchCompute(orgId, objects, names);
|
|
1195
|
+
await fetchData(orgId, objects, names);
|
|
1196
|
+
await fetchResource(orgId, objects, names);
|
|
1197
|
+
return {
|
|
1198
|
+
objects,
|
|
1199
|
+
names
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
async function fetchApp(orgId, objects, names) {
|
|
1203
|
+
const { appInfos } = await GetAppList({
|
|
1204
|
+
orgId,
|
|
1205
|
+
ids: []
|
|
1206
|
+
});
|
|
1207
|
+
for (const { id, name } of appInfos) {
|
|
1208
|
+
objects.app.apps.push(id);
|
|
1209
|
+
names[id] = name;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
async function fetchCompute(orgId, objects, names) {
|
|
1213
|
+
const { spaceInfos } = await GetComputeSpaceList({ orgId });
|
|
1214
|
+
spaceInfos.sort((a, b) => a.position - b.position);
|
|
1215
|
+
for (const { id, name } of spaceInfos) {
|
|
1216
|
+
const space = {
|
|
1217
|
+
id,
|
|
1218
|
+
funcGroups: [],
|
|
1219
|
+
funcs: [],
|
|
1220
|
+
flowGroups: [],
|
|
1221
|
+
flows: []
|
|
1222
|
+
};
|
|
1223
|
+
objects.compute.spaces.push(space);
|
|
1224
|
+
names[id] = name;
|
|
1225
|
+
const { funcGroupInfos } = await GetFuncGroupList({
|
|
1226
|
+
orgId,
|
|
1227
|
+
spaceId: id
|
|
1228
|
+
});
|
|
1229
|
+
funcGroupInfos.sort((a, b) => a.position - b.position);
|
|
1230
|
+
for (const { id } of funcGroupInfos) space.funcGroups.push(id);
|
|
1231
|
+
const { funcInfos } = await GetFuncList({
|
|
1232
|
+
orgId,
|
|
1233
|
+
spaceId: id,
|
|
1234
|
+
ids: []
|
|
1235
|
+
});
|
|
1236
|
+
funcInfos.sort((a, b) => {
|
|
1237
|
+
const agp = getGroupPos(funcGroupInfos, a.groupId);
|
|
1238
|
+
const bgp = getGroupPos(funcGroupInfos, b.groupId);
|
|
1239
|
+
if (agp !== bgp) return agp - bgp;
|
|
1240
|
+
return a.position - b.position;
|
|
1241
|
+
});
|
|
1242
|
+
for (const { id, name } of funcInfos) {
|
|
1243
|
+
space.funcs.push(id);
|
|
1244
|
+
names[id] = name;
|
|
1245
|
+
}
|
|
1246
|
+
const { flowGroupInfos } = await GetFlowGroupList({
|
|
1247
|
+
orgId,
|
|
1248
|
+
spaceId: id
|
|
1249
|
+
});
|
|
1250
|
+
flowGroupInfos.sort((a, b) => a.position - b.position);
|
|
1251
|
+
for (const { id } of flowGroupInfos) space.flowGroups.push(id);
|
|
1252
|
+
const { flowInfos } = await GetFlowList({
|
|
1253
|
+
orgId,
|
|
1254
|
+
spaceId: id,
|
|
1255
|
+
ids: []
|
|
1256
|
+
});
|
|
1257
|
+
flowInfos.sort((a, b) => {
|
|
1258
|
+
const agp = getGroupPos(funcGroupInfos, a.groupId);
|
|
1259
|
+
const bgp = getGroupPos(funcGroupInfos, b.groupId);
|
|
1260
|
+
if (agp !== bgp) return agp - bgp;
|
|
1261
|
+
return a.position - b.position;
|
|
1262
|
+
});
|
|
1263
|
+
for (const { id, name } of flowInfos) {
|
|
1264
|
+
space.flows.push(id);
|
|
1265
|
+
names[id] = name;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
async function fetchData(orgId, objects, names) {
|
|
1270
|
+
const { spaceInfos: devSpaceInfos } = await GetDataSpaceList({
|
|
1271
|
+
orgId,
|
|
1272
|
+
env: "dev"
|
|
1273
|
+
});
|
|
1274
|
+
devSpaceInfos.sort((a, b) => a.position - b.position);
|
|
1275
|
+
for (const { id, name } of devSpaceInfos) {
|
|
1276
|
+
const space = {
|
|
1277
|
+
id,
|
|
1278
|
+
tableGroups: [],
|
|
1279
|
+
tables: []
|
|
1280
|
+
};
|
|
1281
|
+
objects.data.devSpaces.push(space);
|
|
1282
|
+
names[id + "dev"] = name;
|
|
1283
|
+
const { tableGroupInfos } = await GetTableGroupList({
|
|
1284
|
+
orgId,
|
|
1285
|
+
env: "dev",
|
|
1286
|
+
spaceId: id,
|
|
1287
|
+
ids: []
|
|
1288
|
+
});
|
|
1289
|
+
tableGroupInfos.sort((a, b) => a.position - b.position);
|
|
1290
|
+
for (const { id } of tableGroupInfos) space.tableGroups.push(id);
|
|
1291
|
+
const { tableInfos } = await GetTableList({
|
|
1292
|
+
orgId,
|
|
1293
|
+
env: "dev",
|
|
1294
|
+
spaceId: id
|
|
1295
|
+
});
|
|
1296
|
+
tableInfos.sort((a, b) => {
|
|
1297
|
+
const agp = getGroupPos(tableGroupInfos, a.groupId);
|
|
1298
|
+
const bgp = getGroupPos(tableGroupInfos, b.groupId);
|
|
1299
|
+
if (agp !== bgp) return agp - bgp;
|
|
1300
|
+
return a.position - b.position;
|
|
1301
|
+
});
|
|
1302
|
+
for (const { id, name } of tableInfos) {
|
|
1303
|
+
space.tables.push(id);
|
|
1304
|
+
names[id + "dev"] = name;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const { spaceInfos: prodSpaceInfos } = await GetDataSpaceList({
|
|
1308
|
+
orgId,
|
|
1309
|
+
env: "prod"
|
|
1310
|
+
});
|
|
1311
|
+
prodSpaceInfos.sort((a, b) => a.position - b.position);
|
|
1312
|
+
for (const { id, name } of prodSpaceInfos) {
|
|
1313
|
+
const space = {
|
|
1314
|
+
id,
|
|
1315
|
+
tableGroups: [],
|
|
1316
|
+
tables: []
|
|
1317
|
+
};
|
|
1318
|
+
objects.data.prodSpaces.push(space);
|
|
1319
|
+
names[id + "prod"] = name;
|
|
1320
|
+
const { tableGroupInfos } = await GetTableGroupList({
|
|
1321
|
+
orgId,
|
|
1322
|
+
env: "prod",
|
|
1323
|
+
spaceId: id,
|
|
1324
|
+
ids: []
|
|
1325
|
+
});
|
|
1326
|
+
tableGroupInfos.sort((a, b) => a.position - b.position);
|
|
1327
|
+
for (const { id } of tableGroupInfos) space.tableGroups.push(id);
|
|
1328
|
+
const { tableInfos } = await GetTableList({
|
|
1329
|
+
orgId,
|
|
1330
|
+
env: "prod",
|
|
1331
|
+
spaceId: id
|
|
1332
|
+
});
|
|
1333
|
+
tableInfos.sort((a, b) => {
|
|
1334
|
+
const agp = getGroupPos(tableGroupInfos, a.groupId);
|
|
1335
|
+
const bgp = getGroupPos(tableGroupInfos, b.groupId);
|
|
1336
|
+
if (agp !== bgp) return agp - bgp;
|
|
1337
|
+
return a.position - b.position;
|
|
1338
|
+
});
|
|
1339
|
+
for (const { id, name } of tableInfos) {
|
|
1340
|
+
space.tables.push(id);
|
|
1341
|
+
names[id + "prod"] = name;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
async function fetchResource(orgId, objects, names) {
|
|
1346
|
+
const { spaceInfos } = await GetResourceSpaceList({ orgId });
|
|
1347
|
+
spaceInfos.sort((a, b) => a.position - b.position);
|
|
1348
|
+
for (const { id, name } of spaceInfos) {
|
|
1349
|
+
const space = { id };
|
|
1350
|
+
objects.resource.spaces.push(space);
|
|
1351
|
+
names[id] = name;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
function getGroupPos(groups, id) {
|
|
1355
|
+
return groups.find((group) => group.id === id)?.position ?? -1;
|
|
1356
|
+
}
|
|
1357
|
+
function getLayerObjects(objects, permission, category, layer, keys) {
|
|
1358
|
+
const ids = [];
|
|
1359
|
+
if (!getPermissionMeta(permission)) return ids;
|
|
1360
|
+
if (layer === "env") return ["dev", "prod"];
|
|
1361
|
+
if (category === "app") {
|
|
1362
|
+
if (layer === "app") for (const id of objects.app.apps) ids.push(id);
|
|
1363
|
+
} else if (category === "compute") {
|
|
1364
|
+
if (layer === "space") for (const { id } of objects.compute.spaces) ids.push(id);
|
|
1365
|
+
else if (layer === "flow") {
|
|
1366
|
+
for (const { id, flows } of objects.compute.spaces) if (id === keys[1]) for (const id of flows) ids.push(id);
|
|
1367
|
+
} else if (layer === "func") {
|
|
1368
|
+
for (const { id, funcs } of objects.compute.spaces) if (id === keys[1]) for (const id of funcs) ids.push(id);
|
|
1369
|
+
}
|
|
1370
|
+
} else if (category === "data") {
|
|
1371
|
+
if (layer === "space") {
|
|
1372
|
+
if (keys[0] === "dev") for (const { id } of objects.data.devSpaces) ids.push(id);
|
|
1373
|
+
else if (keys[0] === "prod") for (const { id } of objects.data.prodSpaces) ids.push(id);
|
|
1374
|
+
} else if (layer === "table") {
|
|
1375
|
+
if (keys[0] === "dev") {
|
|
1376
|
+
for (const { id, tables } of objects.data.devSpaces) if (id === keys[1]) for (const id of tables) ids.push(id);
|
|
1377
|
+
} else if (keys[0] === "prod") {
|
|
1378
|
+
for (const { id, tables } of objects.data.prodSpaces) if (id === keys[1]) for (const id of tables) ids.push(id);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
} else if (category === "org") console.assert(false);
|
|
1382
|
+
else if (category === "resource") {
|
|
1383
|
+
if (layer === "space") for (const { id } of objects.resource.spaces) ids.push(id);
|
|
1384
|
+
else if (layer === "resource") console.assert(false);
|
|
1385
|
+
} else if (category === "filter") console.assert(false);
|
|
1386
|
+
else console.assert(false);
|
|
1387
|
+
return ids;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1079
1390
|
//#endregion
|
|
1080
1391
|
//#region src/utils/permission/permission.ts
|
|
1081
1392
|
function toPermissionObjects(permissions) {
|
|
@@ -2452,4 +2763,4 @@ async function loadLocaleMessageEssential(locale) {
|
|
|
2452
2763
|
var src_default = { install };
|
|
2453
2764
|
|
|
2454
2765
|
//#endregion
|
|
2455
|
-
export { Permission, addView, allPermissionMetas, appAppear, categories, clearViews, closeWaitDlg, createAxios, src_default as default, delView, email, eventBus, getCategoryPermissionMetas, getErrorMessage, getPermissionMeta, getTypeColor, getTypeDefault, globalObjects, groups, hasView, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, layers, length, loadLocaleMessageEssential, matchRouteMeta, maxLength, messageError, messageInfo, messageSuccess, messageWarning, minLength, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, planes, popView, provideDark, provideLocale, providePermissionObjects, provideViews, required, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePageRoute, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
|
|
2766
|
+
export { Permission, addView, allPermissionMetas, appAppear, categories, clearViews, closeWaitDlg, createAxios, dataPlaneCategories, src_default as default, delView, email, eventBus, fetchObjectNames, funcPlaneCategories, getCategoryPermissionMetas, getCategoryPlane, getErrorMessage, getLayerObjects, getPermissionMeta, getTypeColor, getTypeDefault, globalObjects, groups, hasView, initObjects, injectDark, injectLocale, injectPermissionObjects, injectViews, isEmpty, isExist, lastView, layers, length, loadLocaleMessageEssential, matchRouteMeta, maxLength, messageError, messageInfo, messageSuccess, messageWarning, minLength, onBeforeEnter, openConfirmDlg, openNumberDlg, openPromptDlg, openWaitDlg, permissionCategories, planes, popView, provideDark, provideLocale, providePermissionObjects, provideViews, required, routeTransName, toPermissionObjects, types, useColor, useGlobalStates, useMicroApp, usePageRoute, usePermission, useSystem, useViewStack, verifyPermission, waitMs, waitUtil };
|