@yuntijs/arcadia-bff-sdk 1.2.17 → 1.2.19
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/cjs/errors/handler.d.ts +3 -0
- package/dist/cjs/errors/handler.js +55 -0
- package/dist/cjs/errors/index.d.ts +1 -0
- package/dist/cjs/errors/index.js +23 -0
- package/dist/cjs/errors/modal.d.ts +3 -0
- package/dist/cjs/errors/modal.js +60 -0
- package/dist/cjs/errors/notification.d.ts +3 -0
- package/dist/cjs/errors/notification.js +73 -0
- package/dist/cjs/errors-taro/handler.d.ts +3 -0
- package/dist/cjs/errors-taro/handler.js +80 -0
- package/dist/cjs/errors-taro/index.d.ts +1 -0
- package/dist/cjs/errors-taro/index.js +23 -0
- package/dist/cjs/index.d.ts +1400 -0
- package/dist/cjs/index.js +151 -0
- package/dist/cjs/sdk.d.ts +6177 -0
- package/dist/cjs/sdk.js +2608 -0
- package/dist/cjs/taro.d.ts +1026 -0
- package/dist/cjs/taro.js +163 -0
- package/dist/cjs/useSWR.d.ts +8 -0
- package/dist/cjs/useSWR.js +70 -0
- package/dist/cjs/utils.d.ts +4 -0
- package/dist/cjs/utils.js +29 -0
- package/dist/esm/index.d.ts +22 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/sdk.d.ts +67 -0
- package/dist/esm/sdk.js +74 -68
- package/dist/esm/taro.d.ts +15 -0
- package/dist/esm/taro.js +0 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/errors/handler.ts
|
|
20
|
+
var handler_exports = {};
|
|
21
|
+
__export(handler_exports, {
|
|
22
|
+
default: () => handler_default,
|
|
23
|
+
errorsHandler: () => errorsHandler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(handler_exports);
|
|
26
|
+
var import_modal = require("./modal");
|
|
27
|
+
var import_notification = require("./notification");
|
|
28
|
+
var import_utils = require("../utils");
|
|
29
|
+
var errorsHandler = (errors) => {
|
|
30
|
+
const gqlErrors = errors.filter((e) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return typeof ((_a = e.extensions) == null ? void 0 : _a.code) !== "undefined";
|
|
33
|
+
});
|
|
34
|
+
console.warn("gql errors =>", errors);
|
|
35
|
+
if (gqlErrors.length === 0 || !(0, import_utils.isBrowser)()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
gqlErrors.forEach((e) => {
|
|
39
|
+
switch (e.extensions.code) {
|
|
40
|
+
case "InvalidToken":
|
|
41
|
+
(0, import_modal.showInvalidTokenModal)(e);
|
|
42
|
+
break;
|
|
43
|
+
case "Forbidden":
|
|
44
|
+
(0, import_notification.showForbiddenNotification)(e);
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var handler_default = errorsHandler;
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
errorsHandler
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './handler';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/errors/index.ts
|
|
17
|
+
var errors_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(errors_exports);
|
|
19
|
+
__reExport(errors_exports, require("./handler"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./handler")
|
|
23
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/errors/modal.ts
|
|
30
|
+
var modal_exports = {};
|
|
31
|
+
__export(modal_exports, {
|
|
32
|
+
logout: () => logout,
|
|
33
|
+
showInvalidTokenModal: () => showInvalidTokenModal
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(modal_exports);
|
|
36
|
+
var import_modal = __toESM(require("antd/es/modal"));
|
|
37
|
+
var logout = () => {
|
|
38
|
+
window.location.href = "/logout";
|
|
39
|
+
};
|
|
40
|
+
var InvalidTokenModal;
|
|
41
|
+
var onInvalidTokenModalCancel = () => {
|
|
42
|
+
InvalidTokenModal == null ? void 0 : InvalidTokenModal.destroy();
|
|
43
|
+
InvalidTokenModal = void 0;
|
|
44
|
+
};
|
|
45
|
+
var showInvalidTokenModal = (error) => {
|
|
46
|
+
if (InvalidTokenModal) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
InvalidTokenModal = import_modal.default.warn({
|
|
50
|
+
okText: "确定",
|
|
51
|
+
content: "用户凭证可能已失效,点击确定重新登录",
|
|
52
|
+
onOk: logout,
|
|
53
|
+
onCancel: onInvalidTokenModalCancel
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
logout,
|
|
59
|
+
showInvalidTokenModal
|
|
60
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/errors/notification.ts
|
|
30
|
+
var notification_exports = {};
|
|
31
|
+
__export(notification_exports, {
|
|
32
|
+
showForbiddenNotification: () => showForbiddenNotification,
|
|
33
|
+
showGlobalErrorNotification: () => showGlobalErrorNotification
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(notification_exports);
|
|
36
|
+
var import_notification = __toESM(require("antd/es/notification"));
|
|
37
|
+
var VERBS_MAP = {
|
|
38
|
+
create: "创建",
|
|
39
|
+
delete: "删除",
|
|
40
|
+
update: "更新",
|
|
41
|
+
patch: "更新",
|
|
42
|
+
get: "获取",
|
|
43
|
+
list: "列取",
|
|
44
|
+
watch: "监听"
|
|
45
|
+
};
|
|
46
|
+
var showForbiddenNotification = (error) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const { name, kind, verb = "" } = ((_b = (_a = error.extensions) == null ? void 0 : _a.exception) == null ? void 0 : _b.details) || {};
|
|
49
|
+
let description = "当前用户没有权限";
|
|
50
|
+
description += `${VERBS_MAP[verb] || "操作"}`;
|
|
51
|
+
if (kind) {
|
|
52
|
+
description += ` ${kind}`;
|
|
53
|
+
}
|
|
54
|
+
if (name) {
|
|
55
|
+
description += ` ${name}`;
|
|
56
|
+
}
|
|
57
|
+
import_notification.default.warning({
|
|
58
|
+
message: "当前操作未被授权",
|
|
59
|
+
description
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var showGlobalErrorNotification = (error) => {
|
|
63
|
+
const { message } = error || {};
|
|
64
|
+
import_notification.default.warning({
|
|
65
|
+
message: "请求错误",
|
|
66
|
+
description: message
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
showForbiddenNotification,
|
|
72
|
+
showGlobalErrorNotification
|
|
73
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/errors-taro/handler.ts
|
|
30
|
+
var handler_exports = {};
|
|
31
|
+
__export(handler_exports, {
|
|
32
|
+
default: () => handler_default,
|
|
33
|
+
errorsHandler: () => errorsHandler
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(handler_exports);
|
|
36
|
+
var Taro = __toESM(require("@tarojs/taro"));
|
|
37
|
+
var InvalidTokenModal;
|
|
38
|
+
var errorsHandler = (errors) => {
|
|
39
|
+
const gqlErrors = errors.filter((e) => {
|
|
40
|
+
var _a;
|
|
41
|
+
return typeof ((_a = e.extensions) == null ? void 0 : _a.code) !== "undefined";
|
|
42
|
+
});
|
|
43
|
+
console.warn("gql errors =>", errors);
|
|
44
|
+
if (gqlErrors.length === 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
gqlErrors.forEach(async (e) => {
|
|
48
|
+
switch (e.extensions.code) {
|
|
49
|
+
case "InvalidToken":
|
|
50
|
+
if (InvalidTokenModal) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
InvalidTokenModal = await Taro.showModal({
|
|
54
|
+
title: "登录过期啦",
|
|
55
|
+
content: "用户凭证可能已失效,点击确定重新登录",
|
|
56
|
+
success() {
|
|
57
|
+
Taro.navigateTo({
|
|
58
|
+
url: "/pages/login/index"
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
complete() {
|
|
62
|
+
InvalidTokenModal = void 0;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
case "Forbidden":
|
|
67
|
+
Taro.showToast({
|
|
68
|
+
title: "当前操作未被授权"
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var handler_default = errorsHandler;
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
errorsHandler
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './handler';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/errors-taro/index.ts
|
|
17
|
+
var errors_taro_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(errors_taro_exports);
|
|
19
|
+
__reExport(errors_taro_exports, require("./handler"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./handler")
|
|
23
|
+
});
|