@formio/appserver 2.0.0-dev.9 → 2.0.0-rc.3
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 +31 -16
- package/lib/actions/index.d.ts +11 -12
- package/lib/actions/login/LoginAction.d.ts +3 -2
- package/lib/actions/login/LoginAction.spec.d.ts +1 -0
- package/lib/actions/login/LoginAction.spec.js +15 -0
- package/lib/actions/role/RoleAction.spec.d.ts +1 -0
- package/lib/actions/role/RoleAction.spec.js +15 -0
- package/lib/actions/save/SaveAction.spec.d.ts +1 -0
- package/lib/actions/save/SaveAction.spec.js +15 -0
- package/lib/modules/auth/auth.spec.d.ts +1 -0
- package/lib/modules/auth/auth.spec.js +93 -0
- package/lib/modules/index.d.ts +1 -1
- package/lib/modules/index.js +2 -2
- package/lib/modules/mongodb/db.d.ts +128 -0
- package/lib/modules/mongodb/db.js +706 -0
- package/lib/modules/mongodb/db.spec.d.ts +1 -0
- package/lib/modules/mongodb/db.spec.js +714 -0
- package/lib/server.d.ts +3 -7
- package/lib/server.js +8 -12
- package/package.json +26 -25
- package/lib/prepare/access.d.ts +0 -3
- package/lib/prepare/access.js +0 -62
- package/lib/prepare/bcrypt.d.ts +0 -3
- package/lib/prepare/bcrypt.js +0 -25
- package/lib/prepare/index.d.ts +0 -11
- package/lib/prepare/index.js +0 -61
- package/lib/prepare/password.d.ts +0 -3
- package/lib/prepare/password.js +0 -27
- package/lib/prepare/persist.d.ts +0 -3
- package/lib/prepare/persist.js +0 -24
- package/lib/prepare/protect.d.ts +0 -3
- package/lib/prepare/protect.js +0 -28
- package/lib/prepare/reference.d.ts +0 -3
- package/lib/prepare/reference.js +0 -71
- package/lib/types/action.d.ts +0 -7
- package/lib/types/action.js +0 -2
- package/lib/types/form.d.ts +0 -4
- package/lib/types/form.js +0 -2
- package/lib/types/index.d.ts +0 -5
- package/lib/types/index.js +0 -21
- package/lib/types/project.d.ts +0 -4
- package/lib/types/project.js +0 -2
- package/lib/types/server.d.ts +0 -101
- package/lib/types/server.js +0 -2
- package/lib/types/submission.d.ts +0 -44
- package/lib/types/submission.js +0 -2
package/lib/server.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
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";
|
|
5
|
-
import {
|
|
6
|
-
import { AppServerScope } from '@formio/appserver-types';
|
|
4
|
+
import { AppServerScope, AppServerProcessors } from '@formio/appserver-types';
|
|
7
5
|
export declare const Modules: {
|
|
8
6
|
db: typeof Database;
|
|
9
7
|
auth: typeof Auth;
|
|
10
|
-
processors:
|
|
11
|
-
prepper: import("@formio/appserver-types").Prepper;
|
|
8
|
+
processors: AppServerProcessors;
|
|
12
9
|
actions: {
|
|
13
10
|
save: {
|
|
14
11
|
readonly info: {
|
|
@@ -113,7 +110,7 @@ export declare const Modules: {
|
|
|
113
110
|
validate?: undefined;
|
|
114
111
|
})[]>;
|
|
115
112
|
waitText(time: number): string;
|
|
116
|
-
checkAttempts(scope: import("@formio/appserver-types").ActionScope, error: any, user: import("@formio/
|
|
113
|
+
checkAttempts(scope: import("@formio/appserver-types").ActionScope, error: any, user: import("@formio/core").Submission): Promise<any>;
|
|
117
114
|
executor(scope: import("@formio/appserver-types").ActionScope): Promise<(req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
|
|
118
115
|
};
|
|
119
116
|
role: {
|
|
@@ -171,7 +168,6 @@ export declare const Modules: {
|
|
|
171
168
|
export declare class Server extends CoreServer {
|
|
172
169
|
constructor(config?: AppServerScope);
|
|
173
170
|
}
|
|
174
|
-
export { Prepper };
|
|
175
171
|
export { Database };
|
|
176
172
|
export { Auth };
|
|
177
173
|
export { Actions };
|
package/lib/server.js
CHANGED
|
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Actions = exports.Auth = exports.Database = exports.
|
|
6
|
+
exports.Actions = exports.Auth = exports.Database = exports.Server = exports.Modules = void 0;
|
|
7
7
|
// Load the license key.
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const get_1 = __importDefault(require("lodash/get"));
|
|
11
|
+
const process_1 = require("process");
|
|
10
12
|
let licenseKey = (0, get_1.default)(process.env, 'APPSERVER_LICENSE', (0, get_1.default)(process.env, 'LICENSE_KEY', ''));
|
|
11
13
|
if (!licenseKey) {
|
|
12
14
|
try {
|
|
@@ -22,20 +24,18 @@ Object.defineProperty(exports, "Database", { enumerable: true, get: function ()
|
|
|
22
24
|
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return modules_1.Auth; } });
|
|
23
25
|
const actions_1 = __importDefault(require("./actions"));
|
|
24
26
|
exports.Actions = actions_1.default;
|
|
25
|
-
const prepare_1 = require("./prepare");
|
|
26
|
-
Object.defineProperty(exports, "Prepper", { enumerable: true, get: function () { return prepare_1.Prepper; } });
|
|
27
|
-
const process_1 = require("process");
|
|
28
|
-
const path_1 = __importDefault(require("path"));
|
|
29
27
|
const defaultsDeep_1 = __importDefault(require("lodash/defaultsDeep"));
|
|
30
|
-
const core_1 = require("@formio/core");
|
|
31
28
|
const packageJson = require('../package.json');
|
|
32
29
|
const appCorePackage = require('@formio/appserver-core/package.json');
|
|
33
30
|
const corePackage = require('@formio/core');
|
|
34
31
|
exports.Modules = {
|
|
35
32
|
db: modules_1.Database,
|
|
36
33
|
auth: modules_1.Auth,
|
|
37
|
-
processors:
|
|
38
|
-
|
|
34
|
+
processors: {
|
|
35
|
+
read: [],
|
|
36
|
+
submission: [],
|
|
37
|
+
evaluate: []
|
|
38
|
+
},
|
|
39
39
|
actions: actions_1.default
|
|
40
40
|
};
|
|
41
41
|
class Server extends appserver_core_1.Server {
|
|
@@ -43,9 +43,6 @@ class Server extends appserver_core_1.Server {
|
|
|
43
43
|
if (config.processors) {
|
|
44
44
|
exports.Modules.processors = config.processors;
|
|
45
45
|
}
|
|
46
|
-
if (config.preppers) {
|
|
47
|
-
exports.Modules.prepper.preppers = config.preppers;
|
|
48
|
-
}
|
|
49
46
|
if (!config.actions) {
|
|
50
47
|
config.actions = {};
|
|
51
48
|
}
|
|
@@ -55,7 +52,6 @@ class Server extends appserver_core_1.Server {
|
|
|
55
52
|
config: (0, get_1.default)(process.env, 'MONGO_CONFIG', "{}")
|
|
56
53
|
}),
|
|
57
54
|
processors: exports.Modules.processors,
|
|
58
|
-
prepper: exports.Modules.prepper,
|
|
59
55
|
auth: config.auth || new exports.Modules.auth(),
|
|
60
56
|
actions: Object.assign(Object.assign({}, exports.Modules.actions), config.actions),
|
|
61
57
|
config: (0, defaultsDeep_1.default)(config.config || {}, {
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/appserver",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
4
|
"description": "A highly performant and extensible Application Server for Form.io Multi-Tenant Deployments.",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build:
|
|
8
|
-
"build:db": "cd src/modules/db && npm run build && cd ../../..",
|
|
7
|
+
"build:db": "cd src/modules/mongodb && npm run build && cd ../../..",
|
|
9
8
|
"build:auth": "cd src/modules/auth && npm run build && cd ../../..",
|
|
10
9
|
"build:modules": "npm run build:db && npm run build:auth",
|
|
11
|
-
"build": "npm run build:
|
|
12
|
-
"test": "mocha
|
|
10
|
+
"build": "npm run build:modules && tsc",
|
|
11
|
+
"test": "mocha",
|
|
13
12
|
"prepack": "npm run build"
|
|
14
13
|
},
|
|
15
14
|
"repository": {
|
|
@@ -29,31 +28,33 @@
|
|
|
29
28
|
],
|
|
30
29
|
"homepage": "https://github.com/formio/appserver#readme",
|
|
31
30
|
"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": "
|
|
37
|
-
"@formio/
|
|
38
|
-
"async": "^3.2.
|
|
39
|
-
"bcryptjs": "^
|
|
40
|
-
"debug": "^4.
|
|
41
|
-
"dotenv": "^
|
|
42
|
-
"express": "^
|
|
31
|
+
"@formio/appserver-auth-jwt": "^2.0.0-rc.3",
|
|
32
|
+
"@formio/appserver-core": "^2.0.0-rc.3",
|
|
33
|
+
"@formio/appserver-db-mongodb": "^2.0.0-rc.3",
|
|
34
|
+
"@formio/appserver-types": "^2.0.0-rc.3",
|
|
35
|
+
"@formio/core": "2.4.0-dev.286.23ccfc3",
|
|
36
|
+
"@formio/license": "2.0.1",
|
|
37
|
+
"async": "^3.2.6",
|
|
38
|
+
"bcryptjs": "^3.0.2",
|
|
39
|
+
"debug": "^4.4.1",
|
|
40
|
+
"dotenv": "^17.2.1",
|
|
41
|
+
"express": "^5.1.0",
|
|
43
42
|
"jsonwebtoken": "^9.0.2",
|
|
44
43
|
"lodash": "^4.17.21"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/
|
|
54
|
-
"
|
|
46
|
+
"@formio/js": "^5.2.0",
|
|
47
|
+
"@types/async": "^3.2.25",
|
|
48
|
+
"@types/bcryptjs": "^3.0.0",
|
|
49
|
+
"@types/express": "^5.0.3",
|
|
50
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
51
|
+
"@types/lodash": "^4.17.20",
|
|
52
|
+
"@types/mocha": "^10.0.10",
|
|
53
|
+
"@types/node": "^24.3.0",
|
|
54
|
+
"cross-env": "^10.0.0",
|
|
55
|
+
"mocha": "^11.7.1",
|
|
55
56
|
"ts-node": "^10.9.2",
|
|
56
57
|
"tsconfig-paths": "^4.2.0",
|
|
57
|
-
"typescript": "^5.
|
|
58
|
+
"typescript": "^5.9.2"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/lib/prepare/access.d.ts
DELETED
package/lib/prepare/access.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const find_1 = __importDefault(require("lodash/find"));
|
|
16
|
-
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
17
|
-
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const { req, component } = scope;
|
|
19
|
-
let { value } = scope;
|
|
20
|
-
if (!value ||
|
|
21
|
-
!component ||
|
|
22
|
-
!component.key ||
|
|
23
|
-
!(component.submissionAccess || component.defaultPermission)) {
|
|
24
|
-
// Return early if the conditions are not met.
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
// Normalize the submissionAccess property.
|
|
28
|
-
if (!component.submissionAccess) {
|
|
29
|
-
component.submissionAccess = [
|
|
30
|
-
{
|
|
31
|
-
type: component.defaultPermission,
|
|
32
|
-
roles: [],
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
if (!Array.isArray(value)) {
|
|
37
|
-
value = [value];
|
|
38
|
-
}
|
|
39
|
-
if (!value.length) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// Convert the value to an array of ids.
|
|
43
|
-
value = (0, uniq_1.default)(value.map((val) => val._id ? val._id.toString() : val.toString()));
|
|
44
|
-
// Iterate through each submissionAccess object and assign the appropriate access roles.
|
|
45
|
-
component.submissionAccess.map((access) => {
|
|
46
|
-
const perm = (0, find_1.default)(req.body.access, {
|
|
47
|
-
type: access.type,
|
|
48
|
-
});
|
|
49
|
-
if (perm) {
|
|
50
|
-
if (!perm.resources) {
|
|
51
|
-
perm.resources = [];
|
|
52
|
-
}
|
|
53
|
-
perm.resources = (0, uniq_1.default)(perm.resources.concat(value));
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
req.body.access.push({
|
|
57
|
-
type: access.type,
|
|
58
|
-
resources: value,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
package/lib/prepare/bcrypt.d.ts
DELETED
package/lib/prepare/bcrypt.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const set_1 = __importDefault(require("lodash/set"));
|
|
16
|
-
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
17
|
-
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const { component, data, value, path } = scope;
|
|
19
|
-
if (!value) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (component.type === 'password' && !value.hasOwnProperty('hash')) {
|
|
23
|
-
(0, set_1.default)(data, path, { hash: bcryptjs_1.default.hashSync(value, bcryptjs_1.default.genSaltSync(10)) });
|
|
24
|
-
}
|
|
25
|
-
});
|
package/lib/prepare/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PrepScope, Prepper as PrepperType } from '@formio/appserver-types';
|
|
2
|
-
export declare const Preppers: {
|
|
3
|
-
bcrypt: (scope: PrepScope) => Promise<void>;
|
|
4
|
-
access: (scope: PrepScope) => Promise<void>;
|
|
5
|
-
persist: (scope: PrepScope) => Promise<void>;
|
|
6
|
-
protect: (scope: PrepScope) => Promise<void>;
|
|
7
|
-
password: (scope: PrepScope) => Promise<void>;
|
|
8
|
-
referenceLoad: (scope: PrepScope) => Promise<void>;
|
|
9
|
-
referenceSave: (scope: PrepScope) => Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export declare const Prepper: PrepperType;
|
package/lib/prepare/index.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Prepper = exports.Preppers = void 0;
|
|
16
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
17
|
-
const bcrypt_1 = __importDefault(require("./bcrypt"));
|
|
18
|
-
const access_1 = __importDefault(require("./access"));
|
|
19
|
-
const persist_1 = __importDefault(require("./persist"));
|
|
20
|
-
const protect_1 = __importDefault(require("./protect"));
|
|
21
|
-
const password_1 = __importDefault(require("./password"));
|
|
22
|
-
const reference_1 = require("./reference");
|
|
23
|
-
const core_1 = require("@formio/core");
|
|
24
|
-
exports.Preppers = {
|
|
25
|
-
bcrypt: bcrypt_1.default,
|
|
26
|
-
access: access_1.default,
|
|
27
|
-
persist: persist_1.default,
|
|
28
|
-
protect: protect_1.default,
|
|
29
|
-
password: password_1.default,
|
|
30
|
-
referenceLoad: reference_1.referenceLoad,
|
|
31
|
-
referenceSave: reference_1.referenceSave
|
|
32
|
-
};
|
|
33
|
-
const debug = require('debug')('formio:prepare');
|
|
34
|
-
const error = require('debug')('formio:error');
|
|
35
|
-
exports.Prepper = {
|
|
36
|
-
preppers: {
|
|
37
|
-
save: [exports.Preppers.persist, exports.Preppers.access, exports.Preppers.password, exports.Preppers.bcrypt, exports.Preppers.referenceSave],
|
|
38
|
-
read: [exports.Preppers.protect, exports.Preppers.referenceLoad]
|
|
39
|
-
},
|
|
40
|
-
prepare(scope) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
let data = {};
|
|
43
|
-
const { type, form, submission } = scope;
|
|
44
|
-
try {
|
|
45
|
-
debug(`Preparing data for ${form.name}...`);
|
|
46
|
-
yield scope.utils.eachComponentData(form.components, submission.data, (component, compData, compRow, compPath) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (exports.Prepper.preppers.hasOwnProperty(type)) {
|
|
48
|
-
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: core_1.Utils.getComponentAbsolutePath(component) }));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
error(err);
|
|
56
|
-
data = {};
|
|
57
|
-
}
|
|
58
|
-
return data;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
package/lib/prepare/password.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
16
|
-
const set_1 = __importDefault(require("lodash/set"));
|
|
17
|
-
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
// Check if they do not provide a password in the save, but one exists in the current record.
|
|
19
|
-
// Do not allow them to wipe out their password by saving data that does not include one.
|
|
20
|
-
const { type, component, row, current, path, data } = scope;
|
|
21
|
-
if (component.type === 'password' && type === 'save') {
|
|
22
|
-
const currentPass = (0, get_1.default)(current, `data.${path}`);
|
|
23
|
-
if (!(0, get_1.default)(row, component.key) && currentPass) {
|
|
24
|
-
(0, set_1.default)(data, path, currentPass);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
package/lib/prepare/persist.d.ts
DELETED
package/lib/prepare/persist.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const set_1 = __importDefault(require("lodash/set"));
|
|
16
|
-
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const { component, data, value, path } = scope;
|
|
18
|
-
if (!value) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!component.hasOwnProperty('persistent') || component.persistent === 'server' || component.persistent === true) {
|
|
22
|
-
(0, set_1.default)(data, path, value);
|
|
23
|
-
}
|
|
24
|
-
});
|
package/lib/prepare/protect.d.ts
DELETED
package/lib/prepare/protect.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const set_1 = __importDefault(require("lodash/set"));
|
|
16
|
-
exports.default = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const { component, data, value, path } = scope;
|
|
18
|
-
if (!value) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!component.hasOwnProperty('protected') ||
|
|
22
|
-
!component.protected) {
|
|
23
|
-
// Passwords are always protected.
|
|
24
|
-
if (component.type !== 'password') {
|
|
25
|
-
(0, set_1.default)(data, path, value);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
package/lib/prepare/reference.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.referenceSave = exports.referenceLoad = void 0;
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
17
|
-
const protect_1 = __importDefault(require("./protect"));
|
|
18
|
-
const getResource = (scope) => {
|
|
19
|
-
var _a, _b, _c, _d, _e;
|
|
20
|
-
const { component } = scope;
|
|
21
|
-
const resourceId = (_a = component.data) === null || _a === void 0 ? void 0 : _a.resource;
|
|
22
|
-
let resource = (_b = scope.server) === null || _b === void 0 ? void 0 : _b.project.forms[resourceId];
|
|
23
|
-
if (!resource) {
|
|
24
|
-
for (let name in (_c = scope.server) === null || _c === void 0 ? void 0 : _c.project.forms) {
|
|
25
|
-
const form = (_d = scope.server) === null || _d === void 0 ? void 0 : _d.project.forms[name].clientForm;
|
|
26
|
-
if (form._id.toString() === resourceId) {
|
|
27
|
-
resource = (_e = scope.server) === null || _e === void 0 ? void 0 : _e.project.forms[name];
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return resource;
|
|
33
|
-
};
|
|
34
|
-
const referenceLoad = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
const { component, data, value, path } = scope;
|
|
36
|
-
if (!value) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (component.reference) {
|
|
40
|
-
const resource = getResource(scope);
|
|
41
|
-
if (resource) {
|
|
42
|
-
const submission = yield resource.loadSubmission(value._id);
|
|
43
|
-
if (submission) {
|
|
44
|
-
// Make sure to protect this submission like any other submission output.
|
|
45
|
-
const context = Object.assign(Object.assign({}, scope), { data: {} });
|
|
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: compData, value: (0, lodash_1.get)(compRow, comp.key), path: compPath }));
|
|
48
|
-
}));
|
|
49
|
-
submission.data = context.data;
|
|
50
|
-
(0, lodash_1.set)(data, path, submission);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
exports.referenceLoad = referenceLoad;
|
|
56
|
-
const referenceSave = (scope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
const { component, data, value, path } = scope;
|
|
58
|
-
if (!value || !value._id) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (component.reference && value._id) {
|
|
62
|
-
const resource = getResource(scope);
|
|
63
|
-
if (resource) {
|
|
64
|
-
(0, lodash_1.set)(data, path, {
|
|
65
|
-
_id: value._id,
|
|
66
|
-
form: resource.clientForm._id
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
exports.referenceSave = referenceSave;
|
package/lib/types/action.d.ts
DELETED
package/lib/types/action.js
DELETED
package/lib/types/form.d.ts
DELETED
package/lib/types/form.js
DELETED
package/lib/types/index.d.ts
DELETED
package/lib/types/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./action"), exports);
|
|
18
|
-
__exportStar(require("./form"), exports);
|
|
19
|
-
__exportStar(require("./project"), exports);
|
|
20
|
-
__exportStar(require("./submission"), exports);
|
|
21
|
-
__exportStar(require("./server"), exports);
|
package/lib/types/project.d.ts
DELETED
package/lib/types/project.js
DELETED