@formio/appserver 2.0.0-dev.9 → 2.0.0-rc.1
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/README.md +19 -10
- package/lib/actions/index.d.ts +0 -1
- package/lib/prepare/access.js +3 -3
- package/lib/prepare/index.js +2 -3
- package/lib/prepare/reference.js +1 -1
- package/lib/server.d.ts +1 -2
- package/lib/types/server.d.ts +1 -0
- package/lib/types/submission.d.ts +3 -0
- package/package.json +21 -20
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
## Form.io
|
|
2
|
-
The Form.io
|
|
1
|
+
## Form.io App Server
|
|
2
|
+
The Form.io App Server is a performant run-time application server used to serve single project templates (including forms, resources, roles, etc) at a single deployed endpoint.
|
|
3
|
+
|
|
4
|
+
It's goals are as follows:
|
|
5
|
+
- Provide a single project runtime server where non-submission resources are cached in memory.
|
|
6
|
+
- Enable multi-tenant / multi-database deployments.
|
|
7
|
+
- Provide extensible server-side functionality
|
|
8
|
+
- Support other databases besides MongoDB compliant databases for submission data.
|
|
3
9
|
|
|
4
10
|
### Installation
|
|
5
11
|
To use this library, you must mount it within an Express.js application. As an example, you can create a simple Express.js application with this library by first creating a new [Express.js application](https://expressjs.com/en/starter/installing.html) and then install and use the Server as follows.
|
|
6
12
|
|
|
7
13
|
```
|
|
8
|
-
npm install --save @formio/appserver
|
|
14
|
+
npm install --save @formio/appserver@rc
|
|
9
15
|
```
|
|
10
16
|
|
|
11
17
|
Then within your server.js file, you would add the following.
|
|
@@ -31,6 +37,9 @@ const { Server } = require('@formio/appserver');
|
|
|
31
37
|
})();
|
|
32
38
|
```
|
|
33
39
|
|
|
40
|
+
### License
|
|
41
|
+
The Form.io App Server does require a license to run. If you are interested in trying out this technology, please contact us @ https://form.io/contact-us
|
|
42
|
+
|
|
34
43
|
### Running Locally
|
|
35
44
|
To run this library locally, you can clone the repository, and then npm install.
|
|
36
45
|
|
|
@@ -58,27 +67,27 @@ This library uses environment variables to configure the configurations required
|
|
|
58
67
|
| MONGO | yes | Your MongoDB Connection string to use the default DB. | mongodb://localhost:27017/appserver |
|
|
59
68
|
| PROJECT_ENDPOINT | yes | The endpoint for your deployed Form.io Enterprise project. | https://mydeployment.com/myproject |
|
|
60
69
|
| PROJECT_KEY | yes | The API Key for your deployed Form.io Enterprise Project. | abc123 |
|
|
61
|
-
| LICENSE_KEY | yes | Your License Key for this
|
|
70
|
+
| LICENSE_KEY | yes | Your License Key for this App Server deployment. | <LONG LICENSE KEY> |
|
|
62
71
|
| PORT | no | The port that your server will run on. Default 3005 | 3005 |
|
|
63
72
|
| JWT_SECRET | yes | The key used to protect your JWT authentication tokens. | YOUR_SECRET_KEY |
|
|
64
73
|
| JWT_EXPIRE_TIME | no | The number of minutes to expire your JWT token. | 240 |
|
|
65
|
-
| PORTAL_SECRET | no | Provides the ability to connect to the
|
|
74
|
+
| PORTAL_SECRET | no | Provides the ability to connect to the App Server via the Remote Environment Connection within your Developer Portal. | YOUR_SECRET_KEY |
|
|
66
75
|
| PROJECT_CACHE | no | Disables the cache for project resources (such as Project template, Project Settings, and Access Settings). Default "true" | true |
|
|
67
76
|
| MONGO_CONFIG | no | Additional configurations to add to the DB connection string | {} |
|
|
68
77
|
|
|
69
78
|
### Developer Portal Connection
|
|
70
|
-
Once you have the
|
|
79
|
+
Once you have the App Server running within your own environment, and connected to your own database, you can now deploy your new changes to your forms, resources, project settings, etc. To accomplish this, you must first run the App Server using the ```PORTAL_SECRET``` described above.
|
|
71
80
|
|
|
72
81
|
Once you have this set, you can then log into your Developer Portal, and then navigate to your Project.
|
|
73
82
|
|
|
74
|
-
Once there, you will then go to your **Staging | Connect Environment**. Here you will put your
|
|
83
|
+
Once there, you will then go to your **Staging | Connect Environment**. Here you will put your App Server endpoint and the PORTAL_SECRET value. You will then want to set the **Project Path Type** to use **Subdirectory**. Then click **Continue**.
|
|
75
84
|
|
|
76
|
-
You will then see the next page, where you will select your Stage in the dropdown. You should see it since the
|
|
85
|
+
You will then see the next page, where you will select your Stage in the dropdown. You should see it since the App Server connects to the project on bootup.
|
|
77
86
|
|
|
78
|
-
Once you are connected, any changes you make within the Developer portal will now be directly reflected within your
|
|
87
|
+
Once you are connected, any changes you make within the Developer portal will now be directly reflected within your App Server deployment.
|
|
79
88
|
|
|
80
89
|
### Custom Configuration
|
|
81
|
-
The
|
|
90
|
+
The App Server is very extensible, and many things can be altered and modified as well as custom implementations of different components are possible using configurations.
|
|
82
91
|
|
|
83
92
|
The following configurations can be provided to the Server instance. Here are some configurations that are supported.
|
|
84
93
|
|
package/lib/actions/index.d.ts
CHANGED
package/lib/prepare/access.js
CHANGED
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const find_1 = __importDefault(require("lodash/find"));
|
|
16
16
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
17
17
|
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const {
|
|
18
|
+
const { component, submission } = scope;
|
|
19
19
|
let { value } = scope;
|
|
20
20
|
if (!value ||
|
|
21
21
|
!component ||
|
|
@@ -43,7 +43,7 @@ exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
43
43
|
value = (0, uniq_1.default)(value.map((val) => val._id ? val._id.toString() : val.toString()));
|
|
44
44
|
// Iterate through each submissionAccess object and assign the appropriate access roles.
|
|
45
45
|
component.submissionAccess.map((access) => {
|
|
46
|
-
const perm = (0, find_1.default)(
|
|
46
|
+
const perm = (0, find_1.default)(submission.access, {
|
|
47
47
|
type: access.type,
|
|
48
48
|
});
|
|
49
49
|
if (perm) {
|
|
@@ -53,7 +53,7 @@ exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
53
53
|
perm.resources = (0, uniq_1.default)(perm.resources.concat(value));
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
|
|
56
|
+
submission.access.push({
|
|
57
57
|
type: access.type,
|
|
58
58
|
resources: value,
|
|
59
59
|
});
|
package/lib/prepare/index.js
CHANGED
|
@@ -20,7 +20,6 @@ const persist_1 = __importDefault(require("./persist"));
|
|
|
20
20
|
const protect_1 = __importDefault(require("./protect"));
|
|
21
21
|
const password_1 = __importDefault(require("./password"));
|
|
22
22
|
const reference_1 = require("./reference");
|
|
23
|
-
const core_1 = require("@formio/core");
|
|
24
23
|
exports.Preppers = {
|
|
25
24
|
bcrypt: bcrypt_1.default,
|
|
26
25
|
access: access_1.default,
|
|
@@ -43,10 +42,10 @@ exports.Prepper = {
|
|
|
43
42
|
const { type, form, submission } = scope;
|
|
44
43
|
try {
|
|
45
44
|
debug(`Preparing data for ${form.name}...`);
|
|
46
|
-
yield scope.utils.
|
|
45
|
+
yield scope.utils.eachComponentDataAsync(form.components, submission.data, (component, compData, compRow, compPath) => __awaiter(this, void 0, void 0, function* () {
|
|
47
46
|
if (exports.Prepper.preppers.hasOwnProperty(type)) {
|
|
48
47
|
for (let i = 0; i < exports.Prepper.preppers[type].length; i++) {
|
|
49
|
-
yield exports.Prepper.preppers[type][i](Object.assign(Object.assign({}, scope), { component, row: compRow, data, value: (0, get_1.default)(compData, compPath), path:
|
|
48
|
+
yield exports.Prepper.preppers[type][i](Object.assign(Object.assign({}, scope), { component, row: compRow, data, value: (0, get_1.default)(compData, compPath), path: compPath }));
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}));
|
package/lib/prepare/reference.js
CHANGED
|
@@ -44,7 +44,7 @@ const referenceLoad = (scope) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
44
44
|
// Make sure to protect this submission like any other submission output.
|
|
45
45
|
const context = Object.assign(Object.assign({}, scope), { data: {} });
|
|
46
46
|
yield scope.utils.eachComponentDataAsync(resource.clientForm.components, submission.data, (comp, compData, compRow, compPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
yield (0, protect_1.default)(Object.assign(Object.assign({}, context), { component: comp, row: compRow, data:
|
|
47
|
+
yield (0, protect_1.default)(Object.assign(Object.assign({}, context), { component: comp, row: compRow, data: context.data, value: (0, lodash_1.get)(compData, compPath), path: compPath }));
|
|
48
48
|
}));
|
|
49
49
|
submission.data = context.data;
|
|
50
50
|
(0, lodash_1.set)(data, path, submission);
|
package/lib/server.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
1
|
import { Server as CoreServer } from '@formio/appserver-core';
|
|
3
2
|
import { Database, Auth } from "./modules";
|
|
4
3
|
import Actions from "./actions";
|
|
@@ -7,7 +6,7 @@ import { AppServerScope } from '@formio/appserver-types';
|
|
|
7
6
|
export declare const Modules: {
|
|
8
7
|
db: typeof Database;
|
|
9
8
|
auth: typeof Auth;
|
|
10
|
-
processors: ProcessTarget;
|
|
9
|
+
processors: import("@formio/core").ProcessTarget;
|
|
11
10
|
prepper: import("@formio/appserver-types").Prepper;
|
|
12
11
|
actions: {
|
|
13
12
|
save: {
|
package/lib/types/server.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface SubmissionScope extends FormScope {
|
|
|
12
12
|
export interface SubmissionRequest extends Request {
|
|
13
13
|
user: any;
|
|
14
14
|
token: any;
|
|
15
|
+
decoded: any;
|
|
15
16
|
scope: any;
|
|
16
17
|
admin: any;
|
|
17
18
|
headers: any;
|
|
@@ -21,6 +22,8 @@ export interface SubmissionRequest extends Request {
|
|
|
21
22
|
submissionScope: SubmissionScope;
|
|
22
23
|
childRequests: number;
|
|
23
24
|
skipSave: boolean;
|
|
25
|
+
allowProxy: boolean;
|
|
26
|
+
dbQuery: any;
|
|
24
27
|
}
|
|
25
28
|
export interface ProcessScope extends SubmissionScope {
|
|
26
29
|
component: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/appserver",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"description": "A highly performant and extensible Application Server for Form.io Multi-Tenant Deployments.",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,31 +29,32 @@
|
|
|
29
29
|
],
|
|
30
30
|
"homepage": "https://github.com/formio/appserver#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@formio/appserver-auth-jwt": "^2.0.0-
|
|
33
|
-
"@formio/appserver-core": "^2.0.0-
|
|
34
|
-
"@formio/appserver-db-mongodb": "^2.0.0-
|
|
35
|
-
"@formio/appserver-types": "^2.0.0-
|
|
36
|
-
"@formio/core": "^2.
|
|
37
|
-
"@formio/
|
|
38
|
-
"async": "^3.2.
|
|
39
|
-
"bcryptjs": "^
|
|
40
|
-
"debug": "^4.
|
|
41
|
-
"dotenv": "^16.
|
|
42
|
-
"express": "^
|
|
32
|
+
"@formio/appserver-auth-jwt": "^2.0.0-rc.1",
|
|
33
|
+
"@formio/appserver-core": "^2.0.0-rc.1",
|
|
34
|
+
"@formio/appserver-db-mongodb": "^2.0.0-rc.2",
|
|
35
|
+
"@formio/appserver-types": "^2.0.0-rc.1",
|
|
36
|
+
"@formio/core": "^2.4.1",
|
|
37
|
+
"@formio/license": "2.0.0",
|
|
38
|
+
"async": "^3.2.6",
|
|
39
|
+
"bcryptjs": "^3.0.2",
|
|
40
|
+
"debug": "^4.4.1",
|
|
41
|
+
"dotenv": "^16.5.0",
|
|
42
|
+
"express": "^5.1.0",
|
|
43
43
|
"jsonwebtoken": "^9.0.2",
|
|
44
44
|
"lodash": "^4.17.21"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"@formio/js": "^5.1.2",
|
|
47
48
|
"@types/async": "^3.2.24",
|
|
48
|
-
"@types/bcryptjs": "^
|
|
49
|
-
"@types/express": "^
|
|
50
|
-
"@types/jsonwebtoken": "^9.0.
|
|
51
|
-
"@types/lodash": "^4.17.
|
|
52
|
-
"@types/mocha": "^10.0.
|
|
53
|
-
"@types/node": "^
|
|
54
|
-
"mocha": "^
|
|
49
|
+
"@types/bcryptjs": "^3.0.0",
|
|
50
|
+
"@types/express": "^5.0.2",
|
|
51
|
+
"@types/jsonwebtoken": "^9.0.9",
|
|
52
|
+
"@types/lodash": "^4.17.17",
|
|
53
|
+
"@types/mocha": "^10.0.10",
|
|
54
|
+
"@types/node": "^22.15.24",
|
|
55
|
+
"mocha": "^11.5.0",
|
|
55
56
|
"ts-node": "^10.9.2",
|
|
56
57
|
"tsconfig-paths": "^4.2.0",
|
|
57
|
-
"typescript": "^5.
|
|
58
|
+
"typescript": "^5.8.3"
|
|
58
59
|
}
|
|
59
60
|
}
|