@nocobase/plugin-public-forms 2.1.0-beta.36 → 2.1.0-beta.38
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/{595.3f415d402fcb4010.js → 595.b7c06702cf42a9f1.js} +1 -1
- package/dist/client/755.54e2c6a5fba42eb6.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/594.3ec7d41fb076d365.js +10 -0
- package/dist/client-v2/599.be4aea35e18fe34f.js +10 -0
- package/dist/client-v2/610.5a762348c1d0e93d.js +10 -0
- package/dist/client-v2/64.14dd13ceb37723c5.js +10 -0
- package/dist/client-v2/965.9ebc606a71f466a5.js +10 -0
- package/dist/client-v2/constants.d.ts +20 -0
- package/dist/client-v2/index.d.ts +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +12 -0
- package/dist/client-v2/modelTree.d.ts +125 -0
- package/dist/client-v2/models/PublicFormLayoutModel.d.ts +32 -0
- package/dist/client-v2/models/PublicFormPageModel.d.ts +19 -0
- package/dist/client-v2/models/PublicFormSubmitActionModel.d.ts +20 -0
- package/dist/client-v2/models/PublicFormsSettingsLayoutModel.d.ts +14 -0
- package/dist/client-v2/pages/PublicFormsSettingsPage.d.ts +12 -0
- package/dist/client-v2/plugin.d.ts +14 -0
- package/dist/client-v2/publicFormFlowModelRepository.d.ts +34 -0
- package/dist/client-v2/route.d.ts +17 -0
- package/dist/externalVersion.js +8 -4
- package/dist/locale/en-US.json +19 -2
- package/dist/locale/zh-CN.json +19 -2
- package/dist/server/plugin.d.ts +19 -40
- package/dist/server/plugin.js +168 -31
- package/package.json +5 -2
- package/dist/client/954.40469511861041a3.js +0 -10
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
type PublicFormAppLike = {
|
|
10
|
+
router?: {
|
|
11
|
+
getBasename?: () => string | undefined;
|
|
12
|
+
};
|
|
13
|
+
getPublicPath?: () => string;
|
|
14
|
+
getRouteUrl?: (pathname: string) => string;
|
|
15
|
+
};
|
|
16
|
+
export declare function getPublicFormRoutePath(app: PublicFormAppLike | undefined, pathname: string): string;
|
|
17
|
+
export {};
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-beta.
|
|
11
|
+
"@nocobase/client": "2.1.0-beta.38",
|
|
12
12
|
"react-i18next": "11.18.6",
|
|
13
|
-
"@nocobase/
|
|
14
|
-
"@nocobase/
|
|
13
|
+
"@nocobase/flow-engine": "2.1.0-beta.38",
|
|
14
|
+
"@nocobase/client-v2": "2.1.0-beta.38",
|
|
15
|
+
"@nocobase/plugin-ui-schema-storage": "2.1.0-beta.38",
|
|
16
|
+
"@nocobase/server": "2.1.0-beta.38",
|
|
15
17
|
"react": "18.2.0",
|
|
16
18
|
"@ant-design/icons": "5.6.1",
|
|
17
19
|
"antd": "5.24.2",
|
|
@@ -22,6 +24,8 @@ module.exports = {
|
|
|
22
24
|
"@formily/react": "2.3.7",
|
|
23
25
|
"@formily/core": "2.3.7",
|
|
24
26
|
"@formily/shared": "2.3.7",
|
|
25
|
-
"@
|
|
27
|
+
"@formily/reactive": "2.3.7",
|
|
28
|
+
"ahooks": "3.7.8",
|
|
29
|
+
"@nocobase/database": "2.1.0-beta.38",
|
|
26
30
|
"dayjs": "1.11.13"
|
|
27
31
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -2,17 +2,34 @@
|
|
|
2
2
|
"# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.": "# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.",
|
|
3
3
|
"Add New": "Add New",
|
|
4
4
|
"After successful submission": "After successful submission",
|
|
5
|
+
"Actions": "Actions",
|
|
6
|
+
"Are you sure you want to delete it?": "Are you sure you want to delete it?",
|
|
7
|
+
"Cancel": "Cancel",
|
|
8
|
+
"Collection": "Collection",
|
|
9
|
+
"Configure": "Configure",
|
|
10
|
+
"Configure form": "Configure form",
|
|
5
11
|
"Copy link": "Copy link",
|
|
12
|
+
"Delete": "Delete",
|
|
13
|
+
"Description": "Description",
|
|
14
|
+
"Edit": "Edit",
|
|
6
15
|
"Enable form": "Enable form",
|
|
7
16
|
"Enable password": "Enable password",
|
|
17
|
+
"Enabled": "Enabled",
|
|
8
18
|
"Form": "Form",
|
|
19
|
+
"Incorrect password": "Incorrect password",
|
|
9
20
|
"Link copied successfully": "Link copied successfully",
|
|
21
|
+
"No": "No",
|
|
10
22
|
"Open form": "Open form",
|
|
23
|
+
"Password": "Password",
|
|
11
24
|
"Prompt after successful submission": "Prompt after successful submission",
|
|
12
25
|
"Public forms": "Public forms",
|
|
13
26
|
"QR code": "QR code",
|
|
14
27
|
"Set password": "Set password",
|
|
28
|
+
"Settings": "Settings",
|
|
29
|
+
"Submit": "Submit",
|
|
15
30
|
"The form is not enabled and cannot be accessed": "The form is not enabled and cannot be accessed",
|
|
16
31
|
"The form is not found": "The form is not found",
|
|
17
|
-
"
|
|
18
|
-
|
|
32
|
+
"Title": "Title",
|
|
33
|
+
"Type": "Type",
|
|
34
|
+
"Yes": "Yes"
|
|
35
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -2,17 +2,34 @@
|
|
|
2
2
|
"# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.": "# 提交成功!\n这是一段演示文本,**支持 Markdown 语法**。",
|
|
3
3
|
"Add New": "添加",
|
|
4
4
|
"After successful submission": "提交成功后",
|
|
5
|
+
"Actions": "操作",
|
|
6
|
+
"Are you sure you want to delete it?": "确定删除吗?",
|
|
7
|
+
"Cancel": "取消",
|
|
8
|
+
"Collection": "数据表",
|
|
9
|
+
"Configure": "配置",
|
|
10
|
+
"Configure form": "配置表单",
|
|
5
11
|
"Copy link": "复制链接",
|
|
12
|
+
"Delete": "删除",
|
|
13
|
+
"Description": "描述",
|
|
14
|
+
"Edit": "编辑",
|
|
6
15
|
"Enable form": "启用表单",
|
|
7
16
|
"Enable password": "启用密码",
|
|
17
|
+
"Enabled": "是否启用",
|
|
8
18
|
"Form": "普通表单",
|
|
19
|
+
"Incorrect password": "密码错误",
|
|
9
20
|
"Link copied successfully": "复制地址成功",
|
|
21
|
+
"No": "否",
|
|
10
22
|
"Open form": "查看公开表单",
|
|
23
|
+
"Password": "密码",
|
|
11
24
|
"Prompt after successful submission": "提交成功后的信息提示",
|
|
12
25
|
"Public forms": "公开表单",
|
|
13
26
|
"QR code": "二维码",
|
|
14
27
|
"Set password": "设置密码",
|
|
28
|
+
"Settings": "设置",
|
|
29
|
+
"Submit": "提交",
|
|
15
30
|
"The form is not enabled and cannot be accessed": "该表单未启用,无法访问",
|
|
16
31
|
"The form is not found": "未找到该表单",
|
|
17
|
-
"
|
|
18
|
-
|
|
32
|
+
"Title": "标题",
|
|
33
|
+
"Type": "类型",
|
|
34
|
+
"Yes": "是"
|
|
35
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -8,26 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
10
|
export declare class PluginPublicFormsServer extends Plugin {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
allowNull?: boolean;
|
|
27
|
-
autoIncrement?: boolean;
|
|
28
|
-
}[];
|
|
29
|
-
template: any;
|
|
30
|
-
}[]>;
|
|
11
|
+
protected associationFieldTypes: string[];
|
|
12
|
+
parseCollectionData(dataSourceKey: any, formCollection: any, appends: any): Promise<any[]>;
|
|
13
|
+
getFlowModelTree(uid: string, options?: {
|
|
14
|
+
includeAsyncNode?: boolean;
|
|
15
|
+
}): Promise<any>;
|
|
16
|
+
isFlowModelDescendant(rootUid: string, uid: string): Promise<boolean>;
|
|
17
|
+
validatePublicFormToken(filterByTk: string, token?: string): Promise<import("jsonwebtoken").JwtPayload>;
|
|
18
|
+
getFlowModelByTk(filterByTk: string, options: {
|
|
19
|
+
uid?: string;
|
|
20
|
+
parentId?: string;
|
|
21
|
+
subKey?: string;
|
|
22
|
+
token?: string;
|
|
23
|
+
}): Promise<any>;
|
|
24
|
+
getSchemaAssociationAppends(dataSourceKey: string, collectionName: string, schema: any): any[];
|
|
25
|
+
getFlowModelAssociationAppends(dataSourceKey: string, collectionName: string, flowModel: any): string[];
|
|
31
26
|
getMetaByTk(filterByTk: string, options: {
|
|
32
27
|
password?: string;
|
|
33
28
|
token?: string;
|
|
@@ -36,38 +31,22 @@ export declare class PluginPublicFormsServer extends Plugin {
|
|
|
36
31
|
dataSource?: undefined;
|
|
37
32
|
token?: undefined;
|
|
38
33
|
schema?: undefined;
|
|
34
|
+
flowModel?: undefined;
|
|
39
35
|
title?: undefined;
|
|
40
36
|
} | {
|
|
41
37
|
dataSource: {
|
|
42
38
|
key: any;
|
|
43
39
|
displayName: any;
|
|
44
|
-
collections:
|
|
45
|
-
name: any;
|
|
46
|
-
fields: {
|
|
47
|
-
[x: string]: any;
|
|
48
|
-
name: string;
|
|
49
|
-
field: string;
|
|
50
|
-
rawType: string;
|
|
51
|
-
type: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
interface?: string;
|
|
54
|
-
uiSchema?: any;
|
|
55
|
-
possibleTypes?: string[];
|
|
56
|
-
defaultValue?: any;
|
|
57
|
-
primaryKey?: boolean;
|
|
58
|
-
unique?: boolean;
|
|
59
|
-
allowNull?: boolean;
|
|
60
|
-
autoIncrement?: boolean;
|
|
61
|
-
}[];
|
|
62
|
-
template: any;
|
|
63
|
-
}[];
|
|
40
|
+
collections: any[];
|
|
64
41
|
};
|
|
65
42
|
token: string;
|
|
66
43
|
schema: any;
|
|
44
|
+
flowModel: any;
|
|
67
45
|
title: any;
|
|
68
46
|
passwordRequired?: undefined;
|
|
69
47
|
}>;
|
|
70
48
|
getPublicFormsMeta: (ctx: any, next: any) => Promise<void>;
|
|
49
|
+
getPublicFormFlowModel: (ctx: any, next: any) => Promise<void>;
|
|
71
50
|
parseToken: (ctx: any, next: any) => Promise<any>;
|
|
72
51
|
parseACL: (ctx: any, next: any) => Promise<any>;
|
|
73
52
|
load(): Promise<void>;
|
package/dist/server/plugin.js
CHANGED
|
@@ -35,34 +35,144 @@ var import_hook = require("./hook");
|
|
|
35
35
|
class PasswordError extends Error {
|
|
36
36
|
}
|
|
37
37
|
class PluginPublicFormsServer extends import_server.Plugin {
|
|
38
|
+
associationFieldTypes = ["hasOne", "hasMany", "belongsTo", "belongsToMany", "belongsToArray"];
|
|
38
39
|
async parseCollectionData(dataSourceKey, formCollection, appends) {
|
|
39
40
|
const dataSource = this.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
41
|
+
const serializeCollection = (collection2) => ({
|
|
42
|
+
...collection2.options,
|
|
43
|
+
name: collection2.name,
|
|
44
|
+
filterTargetKey: collection2.filterTargetKey,
|
|
45
|
+
titleField: collection2.titleField,
|
|
46
|
+
fields: collection2.getFields().map((v) => {
|
|
47
|
+
return {
|
|
48
|
+
...v.options
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
});
|
|
40
52
|
const collection = dataSource.collectionManager.getCollection(formCollection);
|
|
41
|
-
const collections = [
|
|
42
|
-
{
|
|
43
|
-
name: collection.name,
|
|
44
|
-
fields: collection.getFields().map((v) => {
|
|
45
|
-
return {
|
|
46
|
-
...v.options
|
|
47
|
-
};
|
|
48
|
-
}),
|
|
49
|
-
template: collection.options.template
|
|
50
|
-
}
|
|
51
|
-
];
|
|
53
|
+
const collections = [serializeCollection(collection)];
|
|
52
54
|
return collections.concat(
|
|
53
55
|
appends.map((v) => {
|
|
54
|
-
const targetCollection =
|
|
55
|
-
return
|
|
56
|
-
...targetCollection.options,
|
|
57
|
-
fields: targetCollection.getFields().map((v2) => {
|
|
58
|
-
return {
|
|
59
|
-
...v2.options
|
|
60
|
-
};
|
|
61
|
-
})
|
|
62
|
-
};
|
|
56
|
+
const targetCollection = dataSource.collectionManager.getCollection(v);
|
|
57
|
+
return serializeCollection(targetCollection);
|
|
63
58
|
})
|
|
64
59
|
);
|
|
65
60
|
}
|
|
61
|
+
async getFlowModelTree(uid, options = {}) {
|
|
62
|
+
var _a;
|
|
63
|
+
const repository = (_a = this.db.getCollection("flowModels")) == null ? void 0 : _a.repository;
|
|
64
|
+
if (!(repository == null ? void 0 : repository.findModelById)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return repository.findModelById(uid, { includeAsyncNode: !!options.includeAsyncNode }).catch(() => null);
|
|
68
|
+
}
|
|
69
|
+
async isFlowModelDescendant(rootUid, uid) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (!rootUid || !uid) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (rootUid === uid) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const repository = this.db.getRepository("flowModelTreePath");
|
|
78
|
+
const node = await ((_b = (_a = repository == null ? void 0 : repository.model) == null ? void 0 : _a.findOne) == null ? void 0 : _b.call(_a, {
|
|
79
|
+
where: {
|
|
80
|
+
ancestor: rootUid,
|
|
81
|
+
descendant: uid
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
return !!node;
|
|
85
|
+
}
|
|
86
|
+
async validatePublicFormToken(filterByTk, token) {
|
|
87
|
+
if (!token) {
|
|
88
|
+
throw new Error("Public form token is required");
|
|
89
|
+
}
|
|
90
|
+
const tokenData = await this.app.authManager.jwt.decode(token);
|
|
91
|
+
if ((tokenData == null ? void 0 : tokenData.formKey) !== filterByTk) {
|
|
92
|
+
throw new Error("Invalid public form token");
|
|
93
|
+
}
|
|
94
|
+
const publicForms = this.db.getRepository("publicForms");
|
|
95
|
+
const instance = await publicForms.findOne({
|
|
96
|
+
filter: {
|
|
97
|
+
key: tokenData.formKey
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (!instance) {
|
|
101
|
+
throw new Error("The form is not found");
|
|
102
|
+
}
|
|
103
|
+
if (!instance.get("enabled")) {
|
|
104
|
+
throw new Error("The form is not enabled");
|
|
105
|
+
}
|
|
106
|
+
return tokenData;
|
|
107
|
+
}
|
|
108
|
+
async getFlowModelByTk(filterByTk, options) {
|
|
109
|
+
var _a;
|
|
110
|
+
await this.validatePublicFormToken(filterByTk, options.token);
|
|
111
|
+
const repository = (_a = this.db.getCollection("flowModels")) == null ? void 0 : _a.repository;
|
|
112
|
+
if (!repository) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (options.uid) {
|
|
116
|
+
if (!await this.isFlowModelDescendant(filterByTk, options.uid)) {
|
|
117
|
+
throw new Error("The flow model is not in this public form");
|
|
118
|
+
}
|
|
119
|
+
return repository.findModelById(options.uid, { includeAsyncNode: true }).catch(() => null);
|
|
120
|
+
}
|
|
121
|
+
if (!options.parentId) {
|
|
122
|
+
throw new Error("parentId is required");
|
|
123
|
+
}
|
|
124
|
+
if (!await this.isFlowModelDescendant(filterByTk, options.parentId)) {
|
|
125
|
+
throw new Error("The flow model parent is not in this public form");
|
|
126
|
+
}
|
|
127
|
+
const flowModel = await repository.findModelByParentId(options.parentId, {
|
|
128
|
+
subKey: options.subKey,
|
|
129
|
+
includeAsyncNode: true
|
|
130
|
+
}).catch(() => null);
|
|
131
|
+
if ((flowModel == null ? void 0 : flowModel.uid) && !await this.isFlowModelDescendant(filterByTk, flowModel.uid)) {
|
|
132
|
+
throw new Error("The flow model is not in this public form");
|
|
133
|
+
}
|
|
134
|
+
return flowModel;
|
|
135
|
+
}
|
|
136
|
+
getSchemaAssociationAppends(dataSourceKey, collectionName, schema) {
|
|
137
|
+
var _a;
|
|
138
|
+
if (!((_a = schema == null ? void 0 : schema.properties) == null ? void 0 : _a.form)) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
const { getAssociationAppends } = (0, import_hook.parseAssociationNames)(dataSourceKey, collectionName, this.app, schema);
|
|
142
|
+
return getAssociationAppends().appends || [];
|
|
143
|
+
}
|
|
144
|
+
getFlowModelAssociationAppends(dataSourceKey, collectionName, flowModel) {
|
|
145
|
+
const dataSource = this.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
146
|
+
const appends = /* @__PURE__ */ new Set();
|
|
147
|
+
const traverse = (node) => {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
if (!node || typeof node !== "object") {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const init = (_b = (_a = node.stepParams) == null ? void 0 : _a.fieldSettings) == null ? void 0 : _b.init;
|
|
153
|
+
const fieldDataSourceKey = (init == null ? void 0 : init.dataSourceKey) || dataSourceKey;
|
|
154
|
+
const fieldCollectionName = (init == null ? void 0 : init.collectionName) || collectionName;
|
|
155
|
+
const fieldPath = init == null ? void 0 : init.fieldPath;
|
|
156
|
+
if (fieldDataSourceKey === dataSourceKey && fieldCollectionName && fieldPath) {
|
|
157
|
+
const collection = dataSource.collectionManager.getCollection(fieldCollectionName);
|
|
158
|
+
const fieldName = String(fieldPath).split(".")[0];
|
|
159
|
+
const collectionField = collection == null ? void 0 : collection.getField(fieldName);
|
|
160
|
+
const collectionFieldOptions = collectionField == null ? void 0 : collectionField.options;
|
|
161
|
+
if (collectionFieldOptions && this.associationFieldTypes.includes(collectionFieldOptions.type) && collectionFieldOptions.target) {
|
|
162
|
+
appends.add(collectionFieldOptions.target);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
Object.values(node.subModels || {}).forEach((subModel) => {
|
|
166
|
+
if (Array.isArray(subModel)) {
|
|
167
|
+
subModel.forEach(traverse);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
traverse(subModel);
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
traverse(flowModel);
|
|
174
|
+
return [...(0, import_hook.fillParentFields)(appends)];
|
|
175
|
+
}
|
|
66
176
|
async getMetaByTk(filterByTk, options) {
|
|
67
177
|
const { token, password } = options;
|
|
68
178
|
const publicForms = this.db.getRepository("publicForms");
|
|
@@ -78,25 +188,40 @@ class PluginPublicFormsServer extends import_server.Plugin {
|
|
|
78
188
|
if (!instance.get("enabled")) {
|
|
79
189
|
return null;
|
|
80
190
|
}
|
|
81
|
-
if (
|
|
82
|
-
if (
|
|
83
|
-
if (password
|
|
191
|
+
if (instance.get("password")) {
|
|
192
|
+
if (password !== void 0) {
|
|
193
|
+
if (this.app.environment.renderJsonTemplate(instance.get("password")) !== password) {
|
|
194
|
+
throw new PasswordError("Please enter your password");
|
|
195
|
+
}
|
|
196
|
+
} else if (token) {
|
|
197
|
+
try {
|
|
198
|
+
await this.validatePublicFormToken(filterByTk, token);
|
|
199
|
+
} catch (error) {
|
|
84
200
|
return {
|
|
85
201
|
passwordRequired: true
|
|
86
202
|
};
|
|
87
203
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
204
|
+
} else {
|
|
205
|
+
return {
|
|
206
|
+
passwordRequired: true
|
|
207
|
+
};
|
|
91
208
|
}
|
|
92
209
|
}
|
|
93
210
|
const keys = instance.collection.split(":");
|
|
94
211
|
const collectionName = keys.pop();
|
|
95
212
|
const dataSourceKey = keys.pop() || "main";
|
|
96
213
|
const title = instance.get("title");
|
|
97
|
-
const schema = await
|
|
98
|
-
|
|
99
|
-
|
|
214
|
+
const [schema, flowModel, completeFlowModel] = await Promise.all([
|
|
215
|
+
uiSchema.getJsonSchema(filterByTk).catch(() => null),
|
|
216
|
+
this.getFlowModelTree(filterByTk),
|
|
217
|
+
this.getFlowModelTree(filterByTk, { includeAsyncNode: true })
|
|
218
|
+
]);
|
|
219
|
+
const appends = [
|
|
220
|
+
.../* @__PURE__ */ new Set([
|
|
221
|
+
...this.getSchemaAssociationAppends(dataSourceKey, collectionName, schema),
|
|
222
|
+
...this.getFlowModelAssociationAppends(dataSourceKey, collectionName, completeFlowModel || flowModel)
|
|
223
|
+
])
|
|
224
|
+
];
|
|
100
225
|
const collections = await this.parseCollectionData(dataSourceKey, collectionName, appends);
|
|
101
226
|
return {
|
|
102
227
|
dataSource: {
|
|
@@ -115,6 +240,7 @@ class PluginPublicFormsServer extends import_server.Plugin {
|
|
|
115
240
|
}
|
|
116
241
|
),
|
|
117
242
|
schema,
|
|
243
|
+
flowModel,
|
|
118
244
|
title
|
|
119
245
|
};
|
|
120
246
|
}
|
|
@@ -133,6 +259,16 @@ class PluginPublicFormsServer extends import_server.Plugin {
|
|
|
133
259
|
}
|
|
134
260
|
await next();
|
|
135
261
|
};
|
|
262
|
+
getPublicFormFlowModel = async (ctx, next) => {
|
|
263
|
+
const token = ctx.get("X-Form-Token");
|
|
264
|
+
const { filterByTk, uid, parentId, subKey } = ctx.action.params;
|
|
265
|
+
try {
|
|
266
|
+
ctx.body = await this.getFlowModelByTk(filterByTk, { uid, parentId, subKey, token });
|
|
267
|
+
} catch (error) {
|
|
268
|
+
ctx.throw(401, error.message);
|
|
269
|
+
}
|
|
270
|
+
await next();
|
|
271
|
+
};
|
|
136
272
|
parseToken = async (ctx, next) => {
|
|
137
273
|
if (!ctx.action) {
|
|
138
274
|
return next();
|
|
@@ -196,9 +332,10 @@ class PluginPublicFormsServer extends import_server.Plugin {
|
|
|
196
332
|
name: `pm.${this.name}`,
|
|
197
333
|
actions: ["publicForms:*"]
|
|
198
334
|
});
|
|
199
|
-
this.app.acl.allow("publicForms", "getMeta", "public");
|
|
335
|
+
this.app.acl.allow("publicForms", ["getMeta", "getFlowModel"], "public");
|
|
200
336
|
this.app.resourceManager.registerActionHandlers({
|
|
201
|
-
"publicForms:getMeta": this.getPublicFormsMeta
|
|
337
|
+
"publicForms:getMeta": this.getPublicFormsMeta,
|
|
338
|
+
"publicForms:getFlowModel": this.getPublicFormFlowModel
|
|
202
339
|
});
|
|
203
340
|
this.app.dataSourceManager.afterAddDataSource((dataSource) => {
|
|
204
341
|
dataSource.resourceManager.use(this.parseToken, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-public-forms",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.38",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"displayName": "Public forms",
|
|
6
6
|
"displayName.ru-RU": "Публичные формы",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/public-form",
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@nocobase/client": "2.x",
|
|
17
|
+
"@nocobase/client-v2": "2.x",
|
|
18
|
+
"@nocobase/flow-engine": "2.x",
|
|
17
19
|
"@nocobase/plugin-client": "2.x",
|
|
20
|
+
"@nocobase/plugin-flow-engine": "2.x",
|
|
18
21
|
"@nocobase/plugin-ui-schema-storage": "2.x",
|
|
19
22
|
"@nocobase/server": "2.x",
|
|
20
23
|
"@nocobase/test": "2.x"
|
|
@@ -22,5 +25,5 @@
|
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"react-device-detect": "2.2.3"
|
|
24
27
|
},
|
|
25
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "d1c585108ff6e51c17b0b52bacb1a2d621d9c119"
|
|
26
29
|
}
|