@nocobase/plugin-public-forms 2.1.0-alpha.4 → 2.1.0-alpha.45
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/LICENSE +201 -0
- package/README.md +99 -0
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/192.8517b0a03feac7ee.js +10 -0
- package/dist/client/397.b68774708fca6416.js +10 -0
- package/dist/client/595.b7c06702cf42a9f1.js +10 -0
- 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 +6 -3
- package/LICENSE.txt +0 -172
- package/dist/client/299daa599f56ed18.js +0 -10
- package/dist/client/6d049e4a903a70c8.js +0 -10
- package/dist/client/9001d28b0af050a8.js +0 -10
- package/dist/client/9e93e160b756c6d1.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-alpha.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.45",
|
|
12
12
|
"react-i18next": "11.18.6",
|
|
13
|
-
"@nocobase/
|
|
14
|
-
"@nocobase/
|
|
13
|
+
"@nocobase/flow-engine": "2.1.0-alpha.45",
|
|
14
|
+
"@nocobase/client-v2": "2.1.0-alpha.45",
|
|
15
|
+
"@nocobase/plugin-ui-schema-storage": "2.1.0-alpha.45",
|
|
16
|
+
"@nocobase/server": "2.1.0-alpha.45",
|
|
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-alpha.45",
|
|
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-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.45",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"displayName": "Public forms",
|
|
6
6
|
"displayName.ru-RU": "Публичные формы",
|
|
@@ -8,13 +8,16 @@
|
|
|
8
8
|
"description": "Share public forms externally to collect information from anonymous users",
|
|
9
9
|
"description.ru-RU": "Позволяет распространять публичные формы для сбора информации от анонимных пользователей.",
|
|
10
10
|
"description.zh-CN": "对外分享公开表单,向匿名用户收集信息。",
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/public-form",
|
|
13
13
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/public-form",
|
|
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": "e9e24987e12d0ad10a5db8815b1e1b7b447f1938"
|
|
26
29
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
Updated Date: October 2, 2025
|
|
2
|
-
|
|
3
|
-
NocoBase License Agreement
|
|
4
|
-
|
|
5
|
-
NOCOBASE PTE. LTD.,a Singaporean Exempt Private Company Limited by Shares with its principal place of business located at 112 ROBINSON ROAD, #03-01, SINGAPORE ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("The User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
|
|
6
|
-
|
|
7
|
-
This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
|
|
8
|
-
|
|
9
|
-
The Company reserves the right to formulate and modify this Agreement from time to time as needed. If there are changes, the Company will announce them in the form of website announcements, without further individual notification. The changed Agreement will automatically take effect once it is announced, becoming part of this Agreement.
|
|
10
|
-
|
|
11
|
-
==============
|
|
12
|
-
1. Definitions
|
|
13
|
-
==============
|
|
14
|
-
|
|
15
|
-
1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
|
|
16
|
-
|
|
17
|
-
1.2 "Community Edition" refers to the free version of the Software provided to the User through public channels.
|
|
18
|
-
|
|
19
|
-
1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. It consists of three versions: Standard Edition, Professional Edition, and Enterprise Edition.
|
|
20
|
-
|
|
21
|
-
1.4 "Marketplace" refers to the marketplace provided by the Company for selling Software plugins and solutions.
|
|
22
|
-
|
|
23
|
-
1.5 "Commercial Plugin" refers to the paid plugins sold in the Marketplace.
|
|
24
|
-
|
|
25
|
-
1.6 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
|
|
26
|
-
|
|
27
|
-
1.7 "Customer" refers to the clients who purchase the User's Upper Layer Application.
|
|
28
|
-
|
|
29
|
-
1.8 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
|
|
30
|
-
|
|
31
|
-
===================================
|
|
32
|
-
2. Intellectual Property Protection
|
|
33
|
-
===================================
|
|
34
|
-
|
|
35
|
-
Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
|
|
36
|
-
|
|
37
|
-
=============
|
|
38
|
-
3. Disclaimer
|
|
39
|
-
=============
|
|
40
|
-
|
|
41
|
-
3.1 The User shall not use the Software and Commercial Plugins to engage in activities that contravene applicable laws and regulations or offend against public order or religious prohibitions. All legal liabilities and consequences arising from the User’s use shall be borne by the User.
|
|
42
|
-
|
|
43
|
-
3.2 The Company shall not be liable for any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of profits, business interruption, data loss, or business information disclosure) caused by the User's use of the Software and Commercial Plugins, even if it has been previously informed of the possibility of such damages.
|
|
44
|
-
|
|
45
|
-
===============
|
|
46
|
-
4. License Type
|
|
47
|
-
===============
|
|
48
|
-
|
|
49
|
-
4.1 This Agreement serves as the unified license agreement for NocoBase Software, applying to both the Community Edition and the Commercial Editions.
|
|
50
|
-
|
|
51
|
-
4.2 For the Community Edition, this Agreement incorporates and references the full text of the GNU Affero General Public License v3.0 (“AGPL-3.0”, available at: https://www.gnu.org/licenses/agpl-3.0.html ). Community Edition users must comply with the AGPL-3.0 License as well as the supplementary terms set forth in this Agreement. In case of any inconsistency between AGPL-3.0 and this Agreement, the supplementary terms of this Agreement shall prevail.
|
|
52
|
-
|
|
53
|
-
4.3 For the Commercial Edition (including Standard, Professional, and Enterprise Editions), only the Commercial License terms contained in this Agreement apply. Commercial Edition users are not subject to AGPL-3.0 obligations.
|
|
54
|
-
|
|
55
|
-
4.4 For Commercial Plugins, only the Commercial Plugin License terms contained in this Agreement apply.
|
|
56
|
-
|
|
57
|
-
================================================
|
|
58
|
-
5. Rights and Obligations of Open Source License
|
|
59
|
-
================================================
|
|
60
|
-
|
|
61
|
-
5.1 The Software can be used for commercial purposes.
|
|
62
|
-
|
|
63
|
-
5.2 The User can sell plugins developed for the Software in the Marketplace.
|
|
64
|
-
|
|
65
|
-
5.3 Outside the Marketplace, changes and plugins to the Software developed by the User or third parties, and third-party applications developed based on the Software must all be open-sourced under the AGPL-3.0 license.
|
|
66
|
-
|
|
67
|
-
5.4 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
|
|
68
|
-
|
|
69
|
-
5.5 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
|
|
70
|
-
|
|
71
|
-
5.6 It is not allowed to provide to the public any form of no-code, zero-code, or low-code platform SaaS/PaaS products using the original or modified Software.
|
|
72
|
-
|
|
73
|
-
5.7 Comply with all requirements of the AGPL-3.0 License, including but not limited to:
|
|
74
|
-
(a) Any modifications, extensions, or derivative works of the Software must be released under the AGPL-3.0 License;
|
|
75
|
-
(b) If Upper Layer Applications are provided as a network service (including SaaS or PaaS), the complete corresponding source code must be made available to all users of the service;
|
|
76
|
-
(c) The Software may not be combined with other software under incompatible licenses in a manner that would violate the AGPL-3.0 License;
|
|
77
|
-
(d) No additional contractual restrictions may be imposed when redistributing the Software.
|
|
78
|
-
|
|
79
|
-
===============================
|
|
80
|
-
6. Rights of Commercial License
|
|
81
|
-
===============================
|
|
82
|
-
|
|
83
|
-
6.1 Obtain a permanent commercial license of the Software.
|
|
84
|
-
|
|
85
|
-
6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
|
|
86
|
-
|
|
87
|
-
6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
|
|
88
|
-
|
|
89
|
-
6.4 Changes and plugins to the Software, and applications integrated with the Software do not need to be open sourced.
|
|
90
|
-
|
|
91
|
-
6.5 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
|
|
92
|
-
|
|
93
|
-
6.6 Can sell plugins developed for Software in the Marketplace.
|
|
94
|
-
|
|
95
|
-
6.7 The User holding a Professional or Enterprise Edition License can sell Upper Layer Application to its Customers.
|
|
96
|
-
|
|
97
|
-
6.8 Exemption from AGPL-3.0 obligations, including but not limited to:
|
|
98
|
-
(a) the requirement to release source code of modifications, extensions, or derivative works;
|
|
99
|
-
(b) the requirement to provide source code when offering the Software as a network service;
|
|
100
|
-
(c) restrictions on combining the Software with other software under different license terms; and
|
|
101
|
-
(d) limitations on adding contractual terms for redistribution.
|
|
102
|
-
The User remains bound by this Agreement and by its commercial license contract.
|
|
103
|
-
|
|
104
|
-
6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
|
|
105
|
-
|
|
106
|
-
====================================
|
|
107
|
-
7. Obligations of Commercial License
|
|
108
|
-
====================================
|
|
109
|
-
|
|
110
|
-
7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
|
|
111
|
-
|
|
112
|
-
7.2 It is not allowed to sell, transfer, lease, share, gift, or distribute the Commercial License.
|
|
113
|
-
|
|
114
|
-
7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of no-code, zero-code, low-code platform, or developer tools developed based on Software.
|
|
115
|
-
|
|
116
|
-
7.4 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS/PaaS products to the public using the original or modified Software.
|
|
117
|
-
|
|
118
|
-
7.5 It is not allowed for the User holding a Standard Edition license to sell Upper Layer Application to Customers without a Commercial license.
|
|
119
|
-
|
|
120
|
-
7.6 It is not allowed for the User holding a Professional or Enterprise Edition license to sell Upper Layer Application to Customers without a Commercial license with access to further development and configuration.
|
|
121
|
-
|
|
122
|
-
7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
123
|
-
|
|
124
|
-
7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
125
|
-
|
|
126
|
-
7.9 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
|
|
127
|
-
|
|
128
|
-
======================================
|
|
129
|
-
8. Rights of Commercial Plugin License
|
|
130
|
-
======================================
|
|
131
|
-
|
|
132
|
-
8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
|
|
133
|
-
|
|
134
|
-
8.2 Receive plugin upgrades and exclusive technical support during the upgrade validity period.
|
|
135
|
-
|
|
136
|
-
8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
|
|
137
|
-
|
|
138
|
-
8.4 The User holding a Professional or Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to its customers.
|
|
139
|
-
|
|
140
|
-
8.5 Exemption from AGPL-3.0 obligations.
|
|
141
|
-
|
|
142
|
-
8.6 If there are other agreements in the contract regarding the above rights, the contract agreement shall prevail.
|
|
143
|
-
|
|
144
|
-
===========================================
|
|
145
|
-
9. Obligations of Commercial Plugin License
|
|
146
|
-
===========================================
|
|
147
|
-
|
|
148
|
-
9.1 It is not allowed to remove or change any intellectual property statements about NocoBase and the plugin authors in the code.
|
|
149
|
-
|
|
150
|
-
9.2 It is not allowed to sell, transfer, lease, share, or gift the Commercial Plugin.
|
|
151
|
-
|
|
152
|
-
9.3 It is not allowed to use reverse engineering, decompilation, or other methods to attempt to discover the source code of Commercial Plugins without obtaining a source code license.
|
|
153
|
-
|
|
154
|
-
9.4 It is not allowed to disclose the source code of Commercial Plugins to any third party.
|
|
155
|
-
|
|
156
|
-
9.5 It is not allowed for the User holding a Community or Standard Edition license to use Commercial Plugins in Upper Layer Applications sold to its customers. Such Commercial Plugins are limited to internal use within the licensed company only.
|
|
157
|
-
|
|
158
|
-
9.6 If there is any violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
159
|
-
|
|
160
|
-
9.7 If there are other agreements in the contract regarding the above obligations, the contract agreement shall prevail.
|
|
161
|
-
|
|
162
|
-
=============================================================
|
|
163
|
-
10. Legal Jurisdiction, Interpretation, and Dispute Resolution
|
|
164
|
-
=============================================================
|
|
165
|
-
|
|
166
|
-
10.1 Except for Mainland China, the interpretation, application, and all matters related to this agreement are subject to the jurisdiction of Singapore law.
|
|
167
|
-
|
|
168
|
-
10.2 Any dispute related to this Agreement should first be resolved through friendly negotiation. If the negotiation fails to resolve the dispute, the dispute should be submitted to the International Chamber of Commerce (ICC) for arbitration. The arbitration venue should be Singapore, conducted in English.
|
|
169
|
-
|
|
170
|
-
10.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
|
|
171
|
-
|
|
172
|
-
10.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
|