@formio/appserver 2.0.0-dev.4 → 2.0.0-dev.40

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.
@@ -15,12 +15,12 @@ declare const _default: {
15
15
  method: boolean;
16
16
  };
17
17
  };
18
- mappingComponents(scope: import("../types/lib").ActionScope): Promise<any>;
19
- settingsForm(scope: import("../types/lib").ActionScope): Promise<any>;
20
- saveToForm(scope: import("../types/lib").ActionScope, resource: string): undefined;
21
- childSubmission(scope: import("../types/lib").ActionScope, req: import("../types/lib").SubmissionRequest, res: import("../types/lib").SubmissionResponse, submission: any): any;
22
- childResponse(scope: import("../types/lib").ActionScope, req: import("../types/lib").SubmissionRequest, res: import("../types/lib").SubmissionResponse): void;
23
- executor(scope: import("../types/lib").ActionScope): Promise<(req: import("../types/lib").SubmissionRequest, res: import("../types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
18
+ mappingComponents(scope: import("src/types/lib").ActionScope): Promise<any>;
19
+ settingsForm(scope: import("src/types/lib").ActionScope): Promise<any>;
20
+ saveToForm(scope: import("src/types/lib").ActionScope, resource: string): undefined;
21
+ childSubmission(scope: import("src/types/lib").ActionScope, req: import("src/types/lib").SubmissionRequest, res: import("src/types/lib").SubmissionResponse, submission: any): any;
22
+ childResponse(scope: import("src/types/lib").ActionScope, req: import("src/types/lib").SubmissionRequest, res: import("src/types/lib").SubmissionResponse): void;
23
+ executor(scope: import("src/types/lib").ActionScope): Promise<(req: import("src/types/lib").SubmissionRequest, res: import("src/types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
24
24
  };
25
25
  login: {
26
26
  readonly info: {
@@ -37,7 +37,7 @@ declare const _default: {
37
37
  method: boolean;
38
38
  };
39
39
  };
40
- settingsForm(scope: import("../types/lib").ActionScope): Promise<({
40
+ settingsForm(scope: import("src/types/lib").ActionScope): Promise<({
41
41
  type: string;
42
42
  label: string;
43
43
  key: string;
@@ -103,8 +103,8 @@ declare const _default: {
103
103
  validate?: undefined;
104
104
  })[]>;
105
105
  waitText(time: number): string;
106
- checkAttempts(scope: import("../types/lib").ActionScope, error: any, user: import("../types/lib").User): Promise<any>;
107
- executor(scope: import("../types/lib").ActionScope): Promise<(req: import("../types/lib").SubmissionRequest, res: import("../types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
106
+ checkAttempts(scope: import("src/types/lib").ActionScope, error: any, user: import("src/types/lib").User): Promise<any>;
107
+ executor(scope: import("src/types/lib").ActionScope): Promise<(req: import("src/types/lib").SubmissionRequest, res: import("src/types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
108
108
  };
109
109
  role: {
110
110
  readonly info: {
@@ -121,7 +121,7 @@ declare const _default: {
121
121
  method: boolean;
122
122
  };
123
123
  };
124
- settingsForm(scope: import("../types/lib").ActionScope): Promise<({
124
+ settingsForm(scope: import("src/types/lib").ActionScope): Promise<({
125
125
  type: string;
126
126
  input: boolean;
127
127
  label: string;
@@ -154,7 +154,7 @@ declare const _default: {
154
154
  required: boolean;
155
155
  };
156
156
  })[]>;
157
- executor(scope: import("../types/lib").ActionScope): Promise<(req: import("../types/lib").SubmissionRequest, res: import("../types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void | import("../types/lib").SubmissionResponse>>;
157
+ executor(scope: import("src/types/lib").ActionScope): Promise<(req: import("src/types/lib").SubmissionRequest, res: import("src/types/lib").SubmissionResponse, next: import("express").NextFunction) => Promise<void | import("src/types/lib").SubmissionResponse>>;
158
158
  };
159
159
  };
160
160
  export default _default;
@@ -17,8 +17,8 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
17
17
  const debug = require('debug')('formio:auth');
18
18
  const error = require('debug')('formio:error');
19
19
  class Auth {
20
- token(user, secret, expire = 240) {
21
- return __awaiter(this, void 0, void 0, function* () {
20
+ token(user_1, secret_1) {
21
+ return __awaiter(this, arguments, void 0, function* (user, secret, expire = 240) {
22
22
  user = Object.assign({}, user);
23
23
  delete user.iat;
24
24
  delete user.exp;
@@ -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 { req, component } = scope;
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)(req.body.access, {
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
- req.body.access.push({
56
+ submission.access.push({
57
57
  type: access.type,
58
58
  resources: value,
59
59
  });
@@ -43,7 +43,7 @@ exports.Prepper = {
43
43
  const { type, form, submission } = scope;
44
44
  try {
45
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* () {
46
+ yield scope.utils.eachComponentDataAsync(form.components, submission.data, (component, compData, compRow, compPath) => __awaiter(this, void 0, void 0, function* () {
47
47
  if (exports.Prepper.preppers.hasOwnProperty(type)) {
48
48
  for (let i = 0; i < exports.Prepper.preppers[type].length; i++) {
49
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) }));
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.referenceSave = exports.referenceLoad = void 0;
16
16
  const lodash_1 = require("lodash");
17
17
  const protect_1 = __importDefault(require("./protect"));
18
+ const core_1 = require("@formio/core");
18
19
  const getResource = (scope) => {
19
20
  var _a, _b, _c, _d, _e;
20
21
  const { component } = scope;
@@ -44,7 +45,7 @@ const referenceLoad = (scope) => __awaiter(void 0, void 0, void 0, function* ()
44
45
  // Make sure to protect this submission like any other submission output.
45
46
  const context = Object.assign(Object.assign({}, scope), { data: {} });
46
47
  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
+ 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: core_1.Utils.getComponentAbsolutePath(comp) }));
48
49
  }));
49
50
  submission.data = context.data;
50
51
  (0, lodash_1.set)(data, path, submission);
package/lib/server.js CHANGED
@@ -7,13 +7,13 @@ exports.Actions = exports.Auth = exports.Database = exports.Prepper = exports.Se
7
7
  // Load the license key.
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const get_1 = __importDefault(require("lodash/get"));
10
- let licenseKey = (0, get_1.default)(process.env, 'LICENSE_KEY', '');
10
+ let licenseKey = (0, get_1.default)(process.env, 'APPSERVER_LICENSE', (0, get_1.default)(process.env, 'LICENSE_KEY', ''));
11
11
  if (!licenseKey) {
12
12
  try {
13
13
  licenseKey = fs_1.default.readFileSync(path_1.default.join((0, process_1.cwd)(), 'license.txt'), 'utf8');
14
14
  }
15
15
  catch (err) {
16
- console.log('No license key found. Please set the LICENSE_KEY environment variable or create a license.txt file in the root of the project.');
16
+ console.log('No license key found. Please set the APPSERVER_LICENSE environment variable or create a license.txt file in the root of the project.');
17
17
  }
18
18
  }
19
19
  const appserver_core_1 = require("@formio/appserver-core");
@@ -36,6 +36,7 @@ export interface ServerConfig {
36
36
  license: string;
37
37
  status: any;
38
38
  cache: boolean;
39
+ maxBodySize: string;
39
40
  }
40
41
  export interface DBConfig {
41
42
  url: string;
@@ -46,9 +47,10 @@ export interface DBConfig {
46
47
  export interface ServerDB {
47
48
  config: DBConfig;
48
49
  connect: (prefix?: string) => Promise<void>;
50
+ saveOne: (collection: string, doc: any) => Promise<any>;
49
51
  save: (collection: string, doc: any) => Promise<any>;
50
- load: (collection: string) => Promise<any>;
51
- remove: (collection: string) => Promise<any>;
52
+ load: (collection: string, query?: any) => Promise<any>;
53
+ remove: (collection: string, query?: any) => Promise<any>;
52
54
  index: (scope: FormScope, query: any) => Promise<any>;
53
55
  create: (scope: FormScope, doc: any, allowFields?: string[]) => Promise<any>;
54
56
  read: (scope: FormScope, id: string) => Promise<any>;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/appserver",
3
- "version": "2.0.0-dev.4",
3
+ "version": "2.0.0-dev.40",
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-dev.1",
33
- "@formio/appserver-core": "^2.0.0-dev.4",
34
- "@formio/appserver-db-mongodb": "^2.0.0-dev.1",
35
- "@formio/appserver-types": "^2.0.0-dev.1",
36
- "@formio/core": "^2.0.0-rc.16",
37
- "@formio/vm": "^0.0.7-rc.7",
38
- "async": "^3.2.4",
32
+ "@formio/appserver-auth-jwt": "^2.0.0-dev.9",
33
+ "@formio/appserver-core": "^2.0.0-dev.38",
34
+ "@formio/appserver-db-mongodb": "^2.0.0-dev.9",
35
+ "@formio/appserver-types": "^2.0.0-dev.11",
36
+ "@formio/core": "^2.1.0-dev.tt.8",
37
+ "@formio/license": "^2.0.0-dev.4",
38
+ "async": "^3.2.5",
39
39
  "bcryptjs": "^2.4.3",
40
40
  "debug": "^4.3.4",
41
- "dotenv": "^16.0.3",
42
- "express": "^4.18.2",
43
- "jsonwebtoken": "^9.0.0",
41
+ "dotenv": "^16.4.5",
42
+ "express": "^4.19.2",
43
+ "jsonwebtoken": "^9.0.2",
44
44
  "lodash": "^4.17.21"
45
45
  },
46
46
  "devDependencies": {
47
- "@types/async": "^3.2.20",
48
- "@types/bcryptjs": "^2.4.2",
49
- "@types/express": "^4.17.17",
50
- "@types/jsonwebtoken": "^9.0.2",
51
- "@types/lodash": "^4.14.194",
52
- "@types/mocha": "^10.0.1",
53
- "@types/node": "^20.1.1",
54
- "mocha": "^10.2.0",
55
- "ts-node": "^10.9.1",
47
+ "@formio/js": "^5.0.0-rc.52",
48
+ "@types/async": "^3.2.24",
49
+ "@types/bcryptjs": "^2.4.6",
50
+ "@types/express": "^4.17.21",
51
+ "@types/jsonwebtoken": "^9.0.6",
52
+ "@types/lodash": "^4.17.0",
53
+ "@types/mocha": "^10.0.6",
54
+ "@types/node": "^20.12.7",
55
+ "mocha": "^10.4.0",
56
+ "ts-node": "^10.9.2",
56
57
  "tsconfig-paths": "^4.2.0",
57
- "typescript": "^5.0.4"
58
+ "typescript": "^5.4.5"
58
59
  }
59
60
  }