x-essential-lib 0.11.1 → 0.11.3

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