@tachybase/plugin-action-share 1.3.25 → 1.5.0

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.
@@ -0,0 +1,24 @@
1
+ export interface ShareValue {
2
+ linkStatus: boolean;
3
+ password: any;
4
+ permanent: boolean;
5
+ shareTime: Date;
6
+ permission: string;
7
+ generateLink: string;
8
+ createdBy: any;
9
+ updatedBy: any;
10
+ tabs: tabsValue[];
11
+ }
12
+ export interface tabsValue {
13
+ xUid: string;
14
+ schemaName: string;
15
+ title?: string;
16
+ }
17
+ export declare const ShareModalContext: import("react").Context<{
18
+ shareValue: ShareValue;
19
+ setShareValue: any;
20
+ }>;
21
+ export declare const useShareModal: () => {
22
+ shareValue: ShareValue;
23
+ setShareValue: any;
24
+ };
@@ -0,0 +1,7 @@
1
+ export declare const SharePageContext: import("react").Context<{
2
+ aclRoleShareMenuUiSchemas: any[];
3
+ }>;
4
+ export declare const SharePageProvider: (props: any) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const useSharePage: () => {
6
+ aclRoleShareMenuUiSchemas: any[];
7
+ };
@@ -1,11 +1,12 @@
1
1
  module.exports = {
2
- "@tachybase/client": "1.3.25",
2
+ "@tachybase/client": "1.5.0",
3
3
  "react-router": "6.28.1",
4
4
  "@tego/server": "1.3.52",
5
5
  "react": "18.3.1",
6
6
  "@tachybase/schema": "1.3.52",
7
7
  "@ant-design/icons": "5.6.1",
8
8
  "antd": "5.22.5",
9
+ "dayjs": "1.11.13",
9
10
  "@emotion/css": "11.13.5",
10
11
  "react-router-dom": "6.28.1",
11
12
  "antd-style": "3.7.1"
@@ -1,14 +1,30 @@
1
1
  {
2
2
  "Copy QR code": "复制二维码",
3
+ "Editable": "可编辑",
3
4
  "Enable Share page": "启用分享功能",
5
+ "Expand Settings": "展开设置",
6
+ "Form": "来自",
4
7
  "Guest": "访客",
5
8
  "Guest user not found.": "访客用户未找到。",
9
+ "Link timeliness": "链接时效",
6
10
  "Not allowed to modify login information of guest user.": "不允许修改访客用户的登录信息。",
11
+ "Password error, please re-enter": "密码错误,请重新输入",
12
+ "Permanently valid": "永久有效",
13
+ "Please enter the sharing password": "请输入分享密码",
14
+ "Please reset the link time limit": "请重新设置链接时效",
7
15
  "QR code": "二维码",
8
16
  "Replicated": "已复制",
9
17
  "Save Picture": "保存图片",
10
18
  "Saved": "已保存",
11
19
  "Scan the code to view the sharing": "扫码查看分享",
20
+ "Set access password": "设置访问密码",
21
+ "Sharing": "分享",
22
+ "Sharing permission": "分享权限",
23
+ "Tab": "标签页",
24
+ "The link does not exist. Please confirm if the link is correct or contact the relevant personnel": "链接不存在,请确认链接是否正确或联系相关人员",
25
+ "The link has expired. If you need to retrieve it again, please contact the relevant personnel": "链接已过期,如需重新获取,请联系相关人员",
26
+ "This link is currently not open. If you have any questions, please contact the relevant personnel": "该链接当前暂未开放,如有问题请联系相关人员",
12
27
  "Unauthorized": "未授权",
28
+ "View only": "仅查看",
13
29
  "page link": "页面链接"
14
30
  }
@@ -0,0 +1,2 @@
1
+ import { Context, Next } from '@tego/server';
2
+ export declare function verifyInAction(ctx: Context, next: Next): Promise<void>;
@@ -0,0 +1,39 @@
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
+ var share_exports = {};
19
+ __export(share_exports, {
20
+ verifyInAction: () => verifyInAction
21
+ });
22
+ module.exports = __toCommonJS(share_exports);
23
+ async function verifyInAction(ctx, next) {
24
+ const { id, password } = ctx.action.params.values;
25
+ const userRepository = ctx.db.getRepository("sharePageConfig");
26
+ const shareConfig = await userRepository.findOne({ filter: { id } });
27
+ if (shareConfig) {
28
+ const field = userRepository.collection.getField("password");
29
+ const valid = await field.verify(password, shareConfig.password);
30
+ ctx.body = {
31
+ valid
32
+ };
33
+ }
34
+ await next();
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ verifyInAction
39
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tego/server").CollectionOptions;
2
+ export default _default;
@@ -0,0 +1,27 @@
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
+ var rolesShareUiSchemas_exports = {};
19
+ __export(rolesShareUiSchemas_exports, {
20
+ default: () => rolesShareUiSchemas_default
21
+ });
22
+ module.exports = __toCommonJS(rolesShareUiSchemas_exports);
23
+ var import_server = require("@tego/server");
24
+ var rolesShareUiSchemas_default = (0, import_server.defineCollection)({
25
+ name: "rolesShareUischemas",
26
+ dumpRules: "required"
27
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tego/server").CollectionDef;
2
+ export default _default;
@@ -0,0 +1,44 @@
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
+ var sharePage_exports = {};
19
+ __export(sharePage_exports, {
20
+ default: () => sharePage_default
21
+ });
22
+ module.exports = __toCommonJS(sharePage_exports);
23
+ var import_server = require("@tego/server");
24
+ var sharePage_default = (0, import_server.extendCollection)({
25
+ name: "roles",
26
+ fields: [
27
+ {
28
+ name: "menuShareUiSchemas",
29
+ type: "belongsToMany",
30
+ interface: null,
31
+ collectionName: "roles",
32
+ parentKey: null,
33
+ reverseKey: null,
34
+ uiSchemaUid: null,
35
+ uiSchema: {},
36
+ target: "uiSchemas",
37
+ targetKey: "x-uid",
38
+ foreignKey: "roleName",
39
+ sourceKey: "name",
40
+ otherKey: "uiSchemaXUid",
41
+ through: "rolesShareUischemas"
42
+ }
43
+ ]
44
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tego/server").CollectionOptions;
2
+ export default _default;
@@ -0,0 +1,68 @@
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
+ var sharePageConfig_exports = {};
19
+ __export(sharePageConfig_exports, {
20
+ default: () => sharePageConfig_default
21
+ });
22
+ module.exports = __toCommonJS(sharePageConfig_exports);
23
+ var import_server = require("@tego/server");
24
+ var sharePageConfig_default = (0, import_server.defineCollection)({
25
+ name: "sharePageConfig",
26
+ dumpRules: "required",
27
+ createdAt: true,
28
+ updatedAt: true,
29
+ createdBy: true,
30
+ updatedBy: true,
31
+ fields: [
32
+ {
33
+ name: "id",
34
+ type: "bigInt",
35
+ autoIncrement: true,
36
+ allowNull: false,
37
+ primaryKey: true
38
+ },
39
+ {
40
+ type: "boolean",
41
+ name: "linkStatus"
42
+ },
43
+ {
44
+ type: "password",
45
+ name: "password"
46
+ },
47
+ {
48
+ type: "boolean",
49
+ name: "permanent"
50
+ },
51
+ {
52
+ type: "date",
53
+ name: "shareTime"
54
+ },
55
+ {
56
+ type: "string",
57
+ name: "permission"
58
+ },
59
+ {
60
+ type: "string",
61
+ name: "generateLink"
62
+ },
63
+ {
64
+ type: "jsonb",
65
+ name: "tabs"
66
+ }
67
+ ]
68
+ });
@@ -0,0 +1 @@
1
+ export declare const shareAclAction: (ctx: any, next: any) => Promise<any>;
@@ -0,0 +1,67 @@
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
+ var share_acl_action_exports = {};
19
+ __export(share_acl_action_exports, {
20
+ shareAclAction: () => shareAclAction
21
+ });
22
+ module.exports = __toCommonJS(share_acl_action_exports);
23
+ const shareAclAction = async (ctx, next) => {
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
25
+ if (((_a = ctx.action) == null ? void 0 : _a.resourceName) === "roles" && ((_b = ctx.action) == null ? void 0 : _b.actionName) === "check" && ctx.headers["x-role"] === "guest") {
26
+ const url = new URL(ctx.headers.referer);
27
+ if (((_c = url.pathname.split("/").filter(Boolean)) == null ? void 0 : _c[0]) === "share") {
28
+ const lastSegment = url.pathname.split("/").pop();
29
+ const shareConfig = await ctx.db.getRepository("sharePageConfig").findOne({ filter: { id: lastSegment } });
30
+ if (shareConfig.permission === "edit") {
31
+ ctx.body.strategy.actions = ["create", "view", "update", "destroy"];
32
+ } else if (shareConfig.permission === "view") {
33
+ ctx.body.strategy.actions = ["view"];
34
+ }
35
+ }
36
+ }
37
+ if (((_d = ctx.action) == null ? void 0 : _d.resourceName) === "uiSchemas" && ((_e = ctx.action) == null ? void 0 : _e.actionName) === "getJsonSchema" && ctx.headers["x-role"] === "guest") {
38
+ const url = new URL(ctx.headers.referer);
39
+ const xUid = url.pathname.split("/").slice(-2, -1)[0];
40
+ const lastSegment = url.pathname.split("/").pop();
41
+ if (((_f = url.pathname.split("/").filter(Boolean)) == null ? void 0 : _f[0]) === "share" && xUid === ((_h = (_g = ctx.action) == null ? void 0 : _g.params) == null ? void 0 : _h.filterByTk)) {
42
+ const shareConfig = await ctx.db.getRepository("sharePageConfig").findOne({ filter: { id: lastSegment } });
43
+ const shareTabs = shareConfig.tabs.map((item) => {
44
+ return item.schemaName;
45
+ }).filter(Boolean);
46
+ const bodyProperties = ctx.body.bodyProperties || ((_i = ctx.body) == null ? void 0 : _i.properties) || {};
47
+ const tabsProperties = ((_j = bodyProperties == null ? void 0 : bodyProperties.tabs) == null ? void 0 : _j.properties) || bodyProperties;
48
+ const properties = {};
49
+ for (let key in tabsProperties) {
50
+ if (shareTabs.includes(key)) {
51
+ properties[key] = tabsProperties[key];
52
+ }
53
+ }
54
+ if ((_k = bodyProperties == null ? void 0 : bodyProperties.tabs) == null ? void 0 : _k.properties) {
55
+ ctx.body.properties.tabs.properties = properties;
56
+ } else {
57
+ ctx.body.properties = properties;
58
+ }
59
+ ctx.body.bodyProperties = bodyProperties;
60
+ }
61
+ }
62
+ return next();
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ shareAclAction
67
+ });
@@ -32,8 +32,10 @@ __export(plugin_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(plugin_exports);
34
34
  var import_server = require("@tego/server");
35
+ var import_share = require("./actions/share");
35
36
  var actions = __toESM(require("./actions/users"));
36
37
  var import_ban_guest_action = require("./middlewares/ban-guest-action");
38
+ var import_share_acl_action = require("./middlewares/share-acl-action");
37
39
  class PluginShareServer extends import_server.Plugin {
38
40
  async beforeLoad() {
39
41
  for (const [key, action] of Object.entries(actions)) {
@@ -57,6 +59,11 @@ class PluginShareServer extends import_server.Plugin {
57
59
  }
58
60
  };
59
61
  });
62
+ const aclRoles = this.app.acl.snippetManager.snippets.get("pm.acl.roles");
63
+ this.app.acl.registerSnippet({
64
+ name: "pm.acl.roles",
65
+ actions: [...aclRoles.actions, "roles.menuShareUiSchemas:*"]
66
+ });
60
67
  }
61
68
  async load() {
62
69
  import_server.BaseAuth.prototype.check = async function() {
@@ -96,6 +103,15 @@ class PluginShareServer extends import_server.Plugin {
96
103
  return null;
97
104
  }
98
105
  };
106
+ this.app.acl.allow("sharePageConfig", "*", "public");
107
+ this.app.resourcer.registerActionHandler("sharePageConfig:verifyIn", import_share.verifyInAction);
108
+ this.app.use(async (ctx, next) => {
109
+ try {
110
+ await (0, import_share_acl_action.shareAclAction)(ctx, next);
111
+ } catch (error) {
112
+ ctx.logger.error(error);
113
+ }
114
+ });
99
115
  }
100
116
  getInstallingData(options = {}) {
101
117
  var _a;
@@ -130,7 +146,8 @@ class PluginShareServer extends import_server.Plugin {
130
146
  title: '{{t("Guest")}}',
131
147
  allowConfigure: false,
132
148
  allowNewMenu: false,
133
- snippets: ["!ui.*", "!pm", "!pm.*"]
149
+ snippets: ["!ui.*", "!pm", "!pm.*"],
150
+ strategy: { actions: ["view"] }
134
151
  }
135
152
  ]
136
153
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-action-share",
3
3
  "displayName": "Action: Share Externally",
4
- "version": "1.3.25",
4
+ "version": "1.5.0",
5
5
  "description": "Share pages with external users.",
6
6
  "keywords": [
7
7
  "Users & permissions"
@@ -17,11 +17,12 @@
17
17
  "@tego/server": "*",
18
18
  "antd": "5.22.5",
19
19
  "antd-style": "3.7.1",
20
+ "dayjs": "1.11.13",
20
21
  "qrcode": "^1.5.4",
21
- "react-i18next": "15.2.0",
22
+ "react-i18next": "16.2.1",
22
23
  "react-router": "6.28.1",
23
24
  "react-router-dom": "6.28.1",
24
- "@tachybase/client": "1.3.25"
25
+ "@tachybase/client": "1.5.0"
25
26
  },
26
27
  "description.zh-CN": "与外部用户分享页面。",
27
28
  "displayName.zh-CN": "动作:对外分享",