@formio/appserver 2.0.0-rc.1 → 2.0.0-rc.31
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 +12 -6
- package/lib/actions/index.d.ts +3 -156
- package/lib/actions/login/LoginAction.d.ts +2 -108
- package/lib/actions/login/LoginAction.js +124 -213
- package/lib/actions/role/RoleAction.d.ts +2 -61
- package/lib/actions/role/RoleAction.js +13 -20
- package/lib/actions/save/SaveAction.d.ts +2 -28
- package/lib/actions/save/SaveAction.js +27 -45
- package/lib/modules/index.d.ts +1 -3
- package/lib/modules/index.js +3 -5
- package/lib/modules/mongodb/db.d.ts +127 -0
- package/lib/modules/mongodb/db.js +832 -0
- package/lib/server.d.ts +5 -174
- package/lib/server.js +61 -58
- package/package.json +25 -25
- package/lib/modules/auth/auth.d.ts +0 -5
- package/lib/modules/auth/auth.js +0 -70
- 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 -60
- 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 -102
- package/lib/types/server.js +0 -2
- package/lib/types/submission.d.ts +0 -47
- package/lib/types/submission.js +0 -2
- package/server.js +0 -1
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: context.data, value: (0, lodash_1.get)(compData, compPath), 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
package/lib/types/server.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { FormScope } from "./form";
|
|
2
|
-
import { PrepScope } from "./submission";
|
|
3
|
-
import { OfflineLicenseStruct } from '@formio/license';
|
|
4
|
-
import { ValidationContext, ProcessTarget } from "@formio/core/types";
|
|
5
|
-
export interface ProjectConfig {
|
|
6
|
-
url: string;
|
|
7
|
-
key: string;
|
|
8
|
-
}
|
|
9
|
-
export interface User {
|
|
10
|
-
_id: string;
|
|
11
|
-
data: any;
|
|
12
|
-
roles: string[];
|
|
13
|
-
form: string;
|
|
14
|
-
project: string;
|
|
15
|
-
metadata: any;
|
|
16
|
-
}
|
|
17
|
-
export interface AuthToken {
|
|
18
|
-
iat?: number;
|
|
19
|
-
exp?: number;
|
|
20
|
-
user: User;
|
|
21
|
-
form: {
|
|
22
|
-
_id: string;
|
|
23
|
-
};
|
|
24
|
-
project: {
|
|
25
|
-
_id: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export interface AuthConfig {
|
|
29
|
-
portal: string;
|
|
30
|
-
secret: string;
|
|
31
|
-
expire: number;
|
|
32
|
-
}
|
|
33
|
-
export interface ServerConfig {
|
|
34
|
-
project: ProjectConfig;
|
|
35
|
-
auth: AuthConfig;
|
|
36
|
-
license: string;
|
|
37
|
-
status: any;
|
|
38
|
-
cache: boolean;
|
|
39
|
-
maxBodySize: string;
|
|
40
|
-
}
|
|
41
|
-
export interface DBConfig {
|
|
42
|
-
url: string;
|
|
43
|
-
ttl?: number;
|
|
44
|
-
dropOnConnect?: boolean;
|
|
45
|
-
config: any;
|
|
46
|
-
}
|
|
47
|
-
export interface ServerDB {
|
|
48
|
-
config: DBConfig;
|
|
49
|
-
connect: (prefix?: string) => Promise<void>;
|
|
50
|
-
saveOne: (collection: string, doc: any) => Promise<any>;
|
|
51
|
-
save: (collection: string, doc: any) => Promise<any>;
|
|
52
|
-
load: (collection: string, query?: any) => Promise<any>;
|
|
53
|
-
remove: (collection: string, query?: any) => Promise<any>;
|
|
54
|
-
index: (scope: FormScope, query: any) => Promise<any>;
|
|
55
|
-
create: (scope: FormScope, doc: any, allowFields?: string[]) => Promise<any>;
|
|
56
|
-
read: (scope: FormScope, id: string) => Promise<any>;
|
|
57
|
-
update: (scope: FormScope, id: string, doc: any, allowFields?: string[]) => Promise<any>;
|
|
58
|
-
delete: (scope: FormScope, id: string) => Promise<any>;
|
|
59
|
-
find: (scope: FormScope, query: any) => Promise<any>;
|
|
60
|
-
findOne: (scope: FormScope, query: any) => Promise<any>;
|
|
61
|
-
formCollection: (scope: FormScope) => Promise<any>;
|
|
62
|
-
addIndexes: (scope: FormScope, indexes: string[]) => Promise<any>;
|
|
63
|
-
removeIndexes: (scope: FormScope, indexes: string[]) => Promise<any>;
|
|
64
|
-
isUnique: (scope: FormScope, context: ValidationContext, value: any) => Promise<boolean | string>;
|
|
65
|
-
}
|
|
66
|
-
export interface AuthModule {
|
|
67
|
-
token: (user: AuthToken, secret: string, expire: number) => Promise<string>;
|
|
68
|
-
user: (token: string, secret: string) => Promise<AuthToken | null>;
|
|
69
|
-
}
|
|
70
|
-
export interface Preppers {
|
|
71
|
-
save: Array<(scope: PrepScope) => Promise<any>>;
|
|
72
|
-
read: Array<(scope: PrepScope) => Promise<any>>;
|
|
73
|
-
}
|
|
74
|
-
export interface Prepper {
|
|
75
|
-
preppers: Preppers;
|
|
76
|
-
prepare: (scope: PrepScope) => Promise<any>;
|
|
77
|
-
}
|
|
78
|
-
export interface ServerScope {
|
|
79
|
-
config: ServerConfig;
|
|
80
|
-
db: ServerDB;
|
|
81
|
-
auth: AuthModule;
|
|
82
|
-
actions: any;
|
|
83
|
-
processors: ProcessTarget;
|
|
84
|
-
prepper: Prepper;
|
|
85
|
-
access?: any;
|
|
86
|
-
hooks?: any;
|
|
87
|
-
template?: any;
|
|
88
|
-
utils?: any;
|
|
89
|
-
util?: any;
|
|
90
|
-
server?: any;
|
|
91
|
-
hook?: (name: string, ...args: any[]) => void;
|
|
92
|
-
licenseKey?: OfflineLicenseStruct;
|
|
93
|
-
}
|
|
94
|
-
export interface AppServerScope {
|
|
95
|
-
config?: ServerConfig;
|
|
96
|
-
db?: ServerDB;
|
|
97
|
-
auth?: AuthModule;
|
|
98
|
-
processors?: ProcessTarget;
|
|
99
|
-
preppers?: Preppers;
|
|
100
|
-
actions?: any;
|
|
101
|
-
hooks?: any;
|
|
102
|
-
}
|
package/lib/types/server.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { FormScope } from './form';
|
|
3
|
-
import { ServerScope } from './server';
|
|
4
|
-
import { ProjectScope } from './project';
|
|
5
|
-
export interface SubmissionResponse extends Response {
|
|
6
|
-
resource?: any;
|
|
7
|
-
proxyRes: (res: any) => void;
|
|
8
|
-
}
|
|
9
|
-
export interface SubmissionScope extends FormScope {
|
|
10
|
-
submission: any;
|
|
11
|
-
}
|
|
12
|
-
export interface SubmissionRequest extends Request {
|
|
13
|
-
user: any;
|
|
14
|
-
token: any;
|
|
15
|
-
decoded: any;
|
|
16
|
-
scope: any;
|
|
17
|
-
admin: any;
|
|
18
|
-
headers: any;
|
|
19
|
-
serverScope: ServerScope;
|
|
20
|
-
projectScope: ProjectScope;
|
|
21
|
-
formScope: FormScope;
|
|
22
|
-
submissionScope: SubmissionScope;
|
|
23
|
-
childRequests: number;
|
|
24
|
-
skipSave: boolean;
|
|
25
|
-
allowProxy: boolean;
|
|
26
|
-
dbQuery: any;
|
|
27
|
-
}
|
|
28
|
-
export interface ProcessScope extends SubmissionScope {
|
|
29
|
-
component: any;
|
|
30
|
-
row: any;
|
|
31
|
-
value: any;
|
|
32
|
-
data: any;
|
|
33
|
-
req: SubmissionRequest;
|
|
34
|
-
res: SubmissionResponse;
|
|
35
|
-
}
|
|
36
|
-
export interface PrepScope extends ProcessScope {
|
|
37
|
-
type: string;
|
|
38
|
-
path: string;
|
|
39
|
-
current: any;
|
|
40
|
-
}
|
|
41
|
-
export interface Mail {
|
|
42
|
-
to: string;
|
|
43
|
-
from: string;
|
|
44
|
-
subject: string;
|
|
45
|
-
text: string;
|
|
46
|
-
html: string;
|
|
47
|
-
}
|
package/lib/types/submission.js
DELETED
package/server.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./lib/server.js');
|