@researchdatabox/redbox-core-types 1.1.1 → 1.2.0
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/package.json +24 -24
- package/dist/Attachment.d.ts +0 -15
- package/dist/Attachment.js +0 -32
- package/dist/CoreController.d.ts +0 -106
- package/dist/CoreController.js +0 -278
- package/dist/CoreService.d.ts +0 -41
- package/dist/CoreService.js +0 -112
- package/dist/Datastream.d.ts +0 -10
- package/dist/Datastream.js +0 -35
- package/dist/DatastreamService.d.ts +0 -11
- package/dist/DatastreamService.js +0 -2
- package/dist/DatastreamServiceResponse.d.ts +0 -11
- package/dist/DatastreamServiceResponse.js +0 -34
- package/dist/QueueService.d.ts +0 -8
- package/dist/QueueService.js +0 -20
- package/dist/RecordAuditParams.d.ts +0 -5
- package/dist/RecordAuditParams.js +0 -6
- package/dist/RecordsService.d.ts +0 -13
- package/dist/RecordsService.js +0 -2
- package/dist/SearchService.d.ts +0 -6
- package/dist/SearchService.js +0 -2
- package/dist/StorageService.d.ts +0 -17
- package/dist/StorageService.js +0 -2
- package/dist/StorageServiceResponse.d.ts +0 -14
- package/dist/StorageServiceResponse.js +0 -33
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -28
- package/dist/model/APIActionResponse.d.ts +0 -5
- package/dist/model/APIActionResponse.js +0 -10
- package/dist/model/APIErrorResponse.d.ts +0 -5
- package/dist/model/APIErrorResponse.js +0 -10
- package/dist/model/APIHarvestResponse.d.ts +0 -8
- package/dist/model/APIHarvestResponse.js +0 -13
- package/dist/model/APIObjectActionResponse.d.ts +0 -6
- package/dist/model/APIObjectActionResponse.js +0 -11
- package/dist/model/ListAPIResponse.d.ts +0 -6
- package/dist/model/ListAPIResponse.js +0 -10
- package/dist/model/ListAPISummary.d.ts +0 -6
- package/dist/model/ListAPISummary.js +0 -11
- package/dist/model/RBValidationError.d.ts +0 -3
- package/dist/model/RBValidationError.js +0 -10
- package/dist/model/RecordAuditModel.d.ts +0 -6
- package/dist/model/RecordAuditModel.js +0 -14
- package/dist/model/RequestDetails.d.ts +0 -25
- package/dist/model/RequestDetails.js +0 -30
- package/dist/model/User.d.ts +0 -11
- package/dist/model/User.js +0 -6
- package/dist/model/api/CreateUserAPIResponse.d.ts +0 -8
- package/dist/model/api/CreateUserAPIResponse.js +0 -6
- package/dist/model/api/UserAPITokenAPIResponse.d.ts +0 -5
- package/dist/model/api/UserAPITokenAPIResponse.js +0 -6
- package/dist/model/api/index.d.ts +0 -2
- package/dist/model/api/index.js +0 -7
- package/dist/model/index.d.ts +0 -11
- package/dist/model/index.js +0 -34
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@researchdatabox/redbox-core-types",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"/dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
-
},
|
|
13
|
-
"author": "",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"lodash": "^4.17.21",
|
|
17
|
-
"moment": "^2.29.1",
|
|
18
|
-
"path-exists": "^4.0.0",
|
|
19
|
-
"rxjs": "^6.6.2",
|
|
20
|
-
"rxjs-compat": "^6.6.7",
|
|
21
|
-
"stream": "0.0.2",
|
|
22
|
-
"typescript": "^4.3.5"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@researchdatabox/redbox-core-types",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"lodash": "^4.17.21",
|
|
17
|
+
"moment": "^2.29.1",
|
|
18
|
+
"path-exists": "^4.0.0",
|
|
19
|
+
"rxjs": "^6.6.2",
|
|
20
|
+
"rxjs-compat": "^6.6.7",
|
|
21
|
+
"stream": "0.0.2",
|
|
22
|
+
"typescript": "^4.3.5"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/dist/Attachment.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base class for information regarding an attachment, also includes payload
|
|
3
|
-
*
|
|
4
|
-
* @author <a target='_' href='https://github.com/shilob'>Shilo Banihit</a>
|
|
5
|
-
*/
|
|
6
|
-
export declare class Attachment {
|
|
7
|
-
dateUpdated: any;
|
|
8
|
-
label: string;
|
|
9
|
-
contentType: string;
|
|
10
|
-
dateCreated: any;
|
|
11
|
-
body: any;
|
|
12
|
-
readstream: any;
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
15
|
-
export default Attachment;
|
package/dist/Attachment.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) 2020 Queensland Cyber Infrastructure Foundation (http://www.qcif.edu.au/)
|
|
3
|
-
//
|
|
4
|
-
// GNU GENERAL PUBLIC LICENSE
|
|
5
|
-
// Version 2, June 1991
|
|
6
|
-
//
|
|
7
|
-
// This program is free software; you can redistribute it and/or modify
|
|
8
|
-
// it under the terms of the GNU General Public License as published by
|
|
9
|
-
// the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
// (at your option) any later version.
|
|
11
|
-
//
|
|
12
|
-
// This program is distributed in the hope that it will be useful,
|
|
13
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
// GNU General Public License for more details.
|
|
16
|
-
//
|
|
17
|
-
// You should have received a copy of the GNU General Public License along
|
|
18
|
-
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
-
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Attachment = void 0;
|
|
22
|
-
/**
|
|
23
|
-
* Base class for information regarding an attachment, also includes payload
|
|
24
|
-
*
|
|
25
|
-
* @author <a target='_' href='https://github.com/shilob'>Shilo Banihit</a>
|
|
26
|
-
*/
|
|
27
|
-
class Attachment {
|
|
28
|
-
constructor() {
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Attachment = Attachment;
|
|
32
|
-
exports.default = Attachment;
|
package/dist/CoreController.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { APIErrorResponse } from './model/APIErrorResponse';
|
|
2
|
-
export declare module Controllers.Core {
|
|
3
|
-
/**
|
|
4
|
-
* Core controller which defines common logic between controllers.
|
|
5
|
-
*
|
|
6
|
-
* Workflow details:
|
|
7
|
-
* - First, the "_handleRequest" method must be called. It ensures common stuff happens, and bind some data into the option object.
|
|
8
|
-
* - It calls a magic method such as "__beforeIndex" if the request was coming from an "index" method.
|
|
9
|
-
* - If it doesn't find any specific magic method to call, it calls directly the "__beforeEach" method.
|
|
10
|
-
* - If it does find a custom magic method, then the "__beforeIndex" will automatically call the "__beforeEach" once it is done.
|
|
11
|
-
* - Once all the "__before" magic methods have been called, the caller's callback function is called.
|
|
12
|
-
*
|
|
13
|
-
* The options object contains specific stuff that belongs to the controllers logic, I could have use the req but I prefer not.
|
|
14
|
-
*
|
|
15
|
-
* The public methods such as index/show/etc. are defined but send by default a 404 response if they are not overridden in the child class.
|
|
16
|
-
* They exists just to bind by default all these methods without take care if they exists or not in order to speed up development.
|
|
17
|
-
*/
|
|
18
|
-
class Controller {
|
|
19
|
-
/**
|
|
20
|
-
* Overrides for the settings in `config/controllers.js`
|
|
21
|
-
* (specific to the controller where it's defined)
|
|
22
|
-
* Specific to sails. Don't rename.
|
|
23
|
-
*/
|
|
24
|
-
protected _config: any;
|
|
25
|
-
/**
|
|
26
|
-
* Exported methods. Must be overridden by the child to add custom methods.
|
|
27
|
-
*/
|
|
28
|
-
protected _exportedMethods: string[];
|
|
29
|
-
/**
|
|
30
|
-
* Theme used by the controller by default.
|
|
31
|
-
* Could be overridden by the user theme. (One day, when the feature will be done...)
|
|
32
|
-
*/
|
|
33
|
-
protected _theme: string;
|
|
34
|
-
/**
|
|
35
|
-
* Layout used by the controller by default.
|
|
36
|
-
*/
|
|
37
|
-
protected _layout: string;
|
|
38
|
-
/**
|
|
39
|
-
* Relative path to a layout from a view.
|
|
40
|
-
*/
|
|
41
|
-
protected _layoutRelativePath: string;
|
|
42
|
-
/**
|
|
43
|
-
* Default exported methods.
|
|
44
|
-
* These methods will be accessible.
|
|
45
|
-
*/
|
|
46
|
-
private _defaultExportedMethods;
|
|
47
|
-
/**
|
|
48
|
-
**************************************************************************************************
|
|
49
|
-
**************************************** Public methods ******************************************
|
|
50
|
-
**************************************************************************************************
|
|
51
|
-
*/
|
|
52
|
-
/**
|
|
53
|
-
* Returns an object that contains all exported methods of the controller.
|
|
54
|
-
* These methods must be defined in either the "_defaultExportedMethods" or "_exportedMethods" arrays.
|
|
55
|
-
*
|
|
56
|
-
* @returns {*}
|
|
57
|
-
*/
|
|
58
|
-
exports(): any;
|
|
59
|
-
/**
|
|
60
|
-
**************************************************************************************************
|
|
61
|
-
**************************************** Protected methods ******************************************
|
|
62
|
-
**************************************************************************************************
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* Acts as a requests workflow handler to automatically call magic methods such as "__before".
|
|
66
|
-
* Used to call magic methods before the targeted methods is called.
|
|
67
|
-
* Bind some data as well, like the current controller and action name.
|
|
68
|
-
*
|
|
69
|
-
* @param req Request.
|
|
70
|
-
* @param res Response.
|
|
71
|
-
* @param callback Function to execute.
|
|
72
|
-
* @param options Object that contains options.
|
|
73
|
-
* controller Controller Child controller class. (static)
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
protected _handleRequest(req: any, res: any, callback: any, options?: any): void;
|
|
77
|
-
/**
|
|
78
|
-
**************************************************************************************************
|
|
79
|
-
**************************************** Controller basic methods ********************************
|
|
80
|
-
**************************************************************************************************
|
|
81
|
-
*/
|
|
82
|
-
/**
|
|
83
|
-
* Displays the global content, displays several resources.
|
|
84
|
-
* This method is just to return a 404 error and explain the role.
|
|
85
|
-
*
|
|
86
|
-
* @param req Request.
|
|
87
|
-
* @param res Response.
|
|
88
|
-
* @param callback Function to execute.
|
|
89
|
-
* @param options Object that contains options.
|
|
90
|
-
*/
|
|
91
|
-
index(req: any, res: any, callback: any, options?: any): void;
|
|
92
|
-
_getResolvedView(branding: string, portal: string, view: string): string;
|
|
93
|
-
_getResolvedLayout(branding: string, portal: string): string;
|
|
94
|
-
sendView(req: any, res: any, view: string, locals?: any): void;
|
|
95
|
-
respond(req: any, res: any, ajaxCb: any, normalCb: any, forceAjax?: boolean): any;
|
|
96
|
-
protected isAjax(req: any): boolean;
|
|
97
|
-
protected ajaxOk(req: any, res: any, msg?: string, data?: any, forceAjax?: boolean): void;
|
|
98
|
-
protected ajaxFail(req: any, res: any, msg?: string, data?: any, forceAjax?: boolean): void;
|
|
99
|
-
protected apiFail(req: any, res: any, statusCode?: number, errorResponse?: APIErrorResponse): any;
|
|
100
|
-
protected apiRespond(req: any, res: any, jsonObj?: any, statusCode?: number): void;
|
|
101
|
-
protected ajaxRespond(req: any, res: any, jsonObj: any, forceAjax: any): void;
|
|
102
|
-
protected getNg2Apps(viewPath: any): {
|
|
103
|
-
ng2_apps: any;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
package/dist/CoreController.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controllers = void 0;
|
|
4
|
-
const pathExists = require("path-exists");
|
|
5
|
-
const APIErrorResponse_1 = require("./model/APIErrorResponse");
|
|
6
|
-
var Controllers;
|
|
7
|
-
(function (Controllers) {
|
|
8
|
-
var Core;
|
|
9
|
-
(function (Core) {
|
|
10
|
-
/**
|
|
11
|
-
* Core controller which defines common logic between controllers.
|
|
12
|
-
*
|
|
13
|
-
* Workflow details:
|
|
14
|
-
* - First, the "_handleRequest" method must be called. It ensures common stuff happens, and bind some data into the option object.
|
|
15
|
-
* - It calls a magic method such as "__beforeIndex" if the request was coming from an "index" method.
|
|
16
|
-
* - If it doesn't find any specific magic method to call, it calls directly the "__beforeEach" method.
|
|
17
|
-
* - If it does find a custom magic method, then the "__beforeIndex" will automatically call the "__beforeEach" once it is done.
|
|
18
|
-
* - Once all the "__before" magic methods have been called, the caller's callback function is called.
|
|
19
|
-
*
|
|
20
|
-
* The options object contains specific stuff that belongs to the controllers logic, I could have use the req but I prefer not.
|
|
21
|
-
*
|
|
22
|
-
* The public methods such as index/show/etc. are defined but send by default a 404 response if they are not overridden in the child class.
|
|
23
|
-
* They exists just to bind by default all these methods without take care if they exists or not in order to speed up development.
|
|
24
|
-
*/
|
|
25
|
-
class Controller {
|
|
26
|
-
constructor() {
|
|
27
|
-
/**
|
|
28
|
-
* Overrides for the settings in `config/controllers.js`
|
|
29
|
-
* (specific to the controller where it's defined)
|
|
30
|
-
* Specific to sails. Don't rename.
|
|
31
|
-
*/
|
|
32
|
-
this._config = {};
|
|
33
|
-
/**
|
|
34
|
-
* Exported methods. Must be overridden by the child to add custom methods.
|
|
35
|
-
*/
|
|
36
|
-
this._exportedMethods = [];
|
|
37
|
-
/**
|
|
38
|
-
* Theme used by the controller by default.
|
|
39
|
-
* Could be overridden by the user theme. (One day, when the feature will be done...)
|
|
40
|
-
*/
|
|
41
|
-
this._theme = 'default';
|
|
42
|
-
/**
|
|
43
|
-
* Layout used by the controller by default.
|
|
44
|
-
*/
|
|
45
|
-
this._layout = 'default';
|
|
46
|
-
/**
|
|
47
|
-
* Relative path to a layout from a view.
|
|
48
|
-
*/
|
|
49
|
-
this._layoutRelativePath = '../_layouts/';
|
|
50
|
-
/**
|
|
51
|
-
* Default exported methods.
|
|
52
|
-
* These methods will be accessible.
|
|
53
|
-
*/
|
|
54
|
-
this._defaultExportedMethods = [
|
|
55
|
-
// Sails controller custom config.
|
|
56
|
-
'_config',
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
**************************************************************************************************
|
|
61
|
-
**************************************** Public methods ******************************************
|
|
62
|
-
**************************************************************************************************
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* Returns an object that contains all exported methods of the controller.
|
|
66
|
-
* These methods must be defined in either the "_defaultExportedMethods" or "_exportedMethods" arrays.
|
|
67
|
-
*
|
|
68
|
-
* @returns {*}
|
|
69
|
-
*/
|
|
70
|
-
exports() {
|
|
71
|
-
// Merge default array and custom array from child.
|
|
72
|
-
var methods = this._defaultExportedMethods.concat(this._exportedMethods);
|
|
73
|
-
var exportedMethods = {};
|
|
74
|
-
for (var i = 0; i < methods.length; i++) {
|
|
75
|
-
// Check if the method exists.
|
|
76
|
-
if (typeof this[methods[i]] !== 'undefined') {
|
|
77
|
-
// Check that the method shouldn't be private. (Exception for _config, which is a sails config)
|
|
78
|
-
if (methods[i][0] !== '_' || methods[i] === '_config') {
|
|
79
|
-
if (_.isFunction(this[methods[i]])) {
|
|
80
|
-
exportedMethods[methods[i]] = this[methods[i]].bind(this);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
exportedMethods[methods[i]] = this[methods[i]];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
console.error('The method "' + methods[i] + '" is not public and cannot be exported. ' + this);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
console.error('The method "' + methods[i] + '" does not exist on the controller ' + this);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return exportedMethods;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
**************************************************************************************************
|
|
98
|
-
**************************************** Protected methods ******************************************
|
|
99
|
-
**************************************************************************************************
|
|
100
|
-
*/
|
|
101
|
-
/**
|
|
102
|
-
* Acts as a requests workflow handler to automatically call magic methods such as "__before".
|
|
103
|
-
* Used to call magic methods before the targeted methods is called.
|
|
104
|
-
* Bind some data as well, like the current controller and action name.
|
|
105
|
-
*
|
|
106
|
-
* @param req Request.
|
|
107
|
-
* @param res Response.
|
|
108
|
-
* @param callback Function to execute.
|
|
109
|
-
* @param options Object that contains options.
|
|
110
|
-
* controller Controller Child controller class. (static)
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
_handleRequest(req, res, callback, options = {}) {
|
|
114
|
-
callback(req, res, options);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
**************************************************************************************************
|
|
118
|
-
**************************************** Controller basic methods ********************************
|
|
119
|
-
**************************************************************************************************
|
|
120
|
-
*/
|
|
121
|
-
/**
|
|
122
|
-
* Displays the global content, displays several resources.
|
|
123
|
-
* This method is just to return a 404 error and explain the role.
|
|
124
|
-
*
|
|
125
|
-
* @param req Request.
|
|
126
|
-
* @param res Response.
|
|
127
|
-
* @param callback Function to execute.
|
|
128
|
-
* @param options Object that contains options.
|
|
129
|
-
*/
|
|
130
|
-
index(req, res, callback, options = {}) {
|
|
131
|
-
res.notFound();
|
|
132
|
-
}
|
|
133
|
-
_getResolvedView(branding, portal, view) {
|
|
134
|
-
var resolvedView = null;
|
|
135
|
-
//Check if view exists for branding and portal
|
|
136
|
-
var viewToTest = sails.config.appPath + "/views/" + branding + "/" + portal + "/" + view + ".ejs";
|
|
137
|
-
if (pathExists.sync(viewToTest)) {
|
|
138
|
-
resolvedView = branding + "/" + portal + "/" + view;
|
|
139
|
-
}
|
|
140
|
-
// If view doesn't exist, next try for portal with default branding
|
|
141
|
-
if (resolvedView == null) {
|
|
142
|
-
viewToTest = sails.config.appPath + "/views/default/" + portal + "/" + view + ".ejs";
|
|
143
|
-
if (pathExists.sync(viewToTest)) {
|
|
144
|
-
resolvedView = "default/" + portal + "/" + view;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// If view still doesn't exist, next try for default portal with default branding
|
|
148
|
-
if (resolvedView == null) {
|
|
149
|
-
viewToTest = sails.config.appPath + "/views/default/default/" + view + ".ejs";
|
|
150
|
-
if (pathExists.sync(viewToTest)) {
|
|
151
|
-
resolvedView = "default/default/" + view;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return resolvedView;
|
|
155
|
-
}
|
|
156
|
-
_getResolvedLayout(branding, portal) {
|
|
157
|
-
var resolvedLayout = null;
|
|
158
|
-
//Check if view exists for branding and portal
|
|
159
|
-
var layoutToTest = sails.config.appPath + "/views/" + branding + "/" + portal + "/layout/layout.ejs";
|
|
160
|
-
if (pathExists.sync(layoutToTest)) {
|
|
161
|
-
resolvedLayout = branding + "/" + portal + "/layout";
|
|
162
|
-
}
|
|
163
|
-
// If view doesn't exist, next try for portal with default branding
|
|
164
|
-
if (resolvedLayout == null) {
|
|
165
|
-
layoutToTest = sails.config.appPath + "/views/default/" + portal + "/layout.ejs";
|
|
166
|
-
if (pathExists.sync(layoutToTest)) {
|
|
167
|
-
resolvedLayout = "/default/" + portal + "/layout";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// If view still doesn't exist, next try for default portal with default branding
|
|
171
|
-
if (resolvedLayout == null) {
|
|
172
|
-
layoutToTest = sails.config.appPath + "/views/default/default/" + "layout.ejs";
|
|
173
|
-
if (pathExists.sync(layoutToTest)) {
|
|
174
|
-
resolvedLayout = "default/default/layout";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return resolvedLayout;
|
|
178
|
-
}
|
|
179
|
-
sendView(req, res, view, locals = {}) {
|
|
180
|
-
if (req.options.locals == null) {
|
|
181
|
-
req.options.locals = {};
|
|
182
|
-
}
|
|
183
|
-
var mergedLocal = Object.assign({}, req.options.locals, locals);
|
|
184
|
-
var branding = mergedLocal['branding'];
|
|
185
|
-
var portal = mergedLocal['portal'];
|
|
186
|
-
var resolvedView = this._getResolvedView(branding, portal, view);
|
|
187
|
-
var resolvedLayout = this._getResolvedLayout(branding, portal);
|
|
188
|
-
// If we can resolve a layout set it.
|
|
189
|
-
if (resolvedLayout != null && mergedLocal["layout"] != false) {
|
|
190
|
-
res.locals.layout = resolvedLayout;
|
|
191
|
-
}
|
|
192
|
-
// View still doesn't exist so return a 404
|
|
193
|
-
if (resolvedView == null) {
|
|
194
|
-
res.notFound(mergedLocal, "404");
|
|
195
|
-
}
|
|
196
|
-
// Add some properties blueprints usually adds
|
|
197
|
-
// TODO: Doesn't seem to be binding properly. Investigate
|
|
198
|
-
mergedLocal.view = {};
|
|
199
|
-
mergedLocal.view.pathFromApp = resolvedView;
|
|
200
|
-
mergedLocal.view.ext = 'ejs';
|
|
201
|
-
// merge with ng2 app...
|
|
202
|
-
_.merge(mergedLocal, this.getNg2Apps(view));
|
|
203
|
-
let fullViewPath = sails.config.appPath + "/views/" + resolvedView;
|
|
204
|
-
mergedLocal['templateDirectoryLocation'] = fullViewPath.substring(0, fullViewPath.lastIndexOf('/') + 1);
|
|
205
|
-
sails.log.debug("resolvedView");
|
|
206
|
-
sails.log.debug(resolvedView);
|
|
207
|
-
sails.log.debug("mergedLocal");
|
|
208
|
-
sails.log.debug(mergedLocal);
|
|
209
|
-
res.view(resolvedView, mergedLocal);
|
|
210
|
-
}
|
|
211
|
-
respond(req, res, ajaxCb, normalCb, forceAjax = false) {
|
|
212
|
-
if (this.isAjax(req) || forceAjax == true) {
|
|
213
|
-
return ajaxCb(req, res);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
return normalCb(req, res);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
isAjax(req) {
|
|
220
|
-
return req.headers['x-source'] == 'jsclient';
|
|
221
|
-
}
|
|
222
|
-
ajaxOk(req, res, msg = '', data = null, forceAjax = false) {
|
|
223
|
-
if (!data) {
|
|
224
|
-
data = { status: true, message: msg };
|
|
225
|
-
}
|
|
226
|
-
this.ajaxRespond(req, res, data, forceAjax);
|
|
227
|
-
}
|
|
228
|
-
ajaxFail(req, res, msg = '', data = null, forceAjax = false) {
|
|
229
|
-
if (!data) {
|
|
230
|
-
data = { status: false, message: msg };
|
|
231
|
-
}
|
|
232
|
-
this.ajaxRespond(req, res, data, forceAjax);
|
|
233
|
-
}
|
|
234
|
-
apiFail(req, res, statusCode = 500, errorResponse = new APIErrorResponse_1.APIErrorResponse()) {
|
|
235
|
-
// this.apiRespond(req, res, errorResponse, statusCode);
|
|
236
|
-
res.set('Cache-control', 'no-cache');
|
|
237
|
-
res.set('Pragma', 'no-cache');
|
|
238
|
-
res.set('Expires', 0);
|
|
239
|
-
res.status(statusCode);
|
|
240
|
-
return res.json(errorResponse);
|
|
241
|
-
}
|
|
242
|
-
apiRespond(req, res, jsonObj = null, statusCode = 200) {
|
|
243
|
-
var ajaxMsg = "Got ajax request, don't know what do...";
|
|
244
|
-
this.respond(req, res, (req, res) => {
|
|
245
|
-
sails.log.verbose(ajaxMsg);
|
|
246
|
-
res.notFound(ajaxMsg);
|
|
247
|
-
}, (req, res) => {
|
|
248
|
-
res.set('Cache-control', 'no-cache');
|
|
249
|
-
res.set('Pragma', 'no-cache');
|
|
250
|
-
res.set('Expires', 0);
|
|
251
|
-
res.status(statusCode);
|
|
252
|
-
return res.json(jsonObj);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
ajaxRespond(req, res, jsonObj = null, forceAjax) {
|
|
256
|
-
var notAjaxMsg = "Got non-ajax request, don't know what do...";
|
|
257
|
-
this.respond(req, res, (req, res) => {
|
|
258
|
-
res.set('Cache-control', 'no-cache');
|
|
259
|
-
res.set('Pragma', 'no-cache');
|
|
260
|
-
res.set('Expires', 0);
|
|
261
|
-
return res.json(jsonObj);
|
|
262
|
-
}, (req, res) => {
|
|
263
|
-
sails.log.verbose(notAjaxMsg);
|
|
264
|
-
res.notFound(notAjaxMsg);
|
|
265
|
-
}, forceAjax);
|
|
266
|
-
}
|
|
267
|
-
getNg2Apps(viewPath) {
|
|
268
|
-
if (sails.config.ng2.use_bundled && sails.config.ng2.apps[viewPath]) {
|
|
269
|
-
return { ng2_apps: sails.config.ng2.apps[viewPath] };
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
return { ng2_apps: [] };
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
Core.Controller = Controller;
|
|
277
|
-
})(Core = Controllers.Core || (Controllers.Core = {}));
|
|
278
|
-
})(Controllers = exports.Controllers || (exports.Controllers = {}));
|
package/dist/CoreService.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs/Rx';
|
|
2
|
-
export declare module Services.Core {
|
|
3
|
-
class Service {
|
|
4
|
-
/**
|
|
5
|
-
* Exported methods. Must be overridden by the child to add custom methods.
|
|
6
|
-
*/
|
|
7
|
-
protected _exportedMethods: string[];
|
|
8
|
-
/**
|
|
9
|
-
* Default exported methods.
|
|
10
|
-
* These methods will be accessible.
|
|
11
|
-
*/
|
|
12
|
-
private _defaultExportedMethods;
|
|
13
|
-
protected logHeader: string;
|
|
14
|
-
/**
|
|
15
|
-
* Returns an RxJS Observable wrapped nice and tidy for your subscribing pleasure
|
|
16
|
-
*/
|
|
17
|
-
protected getObservable(q: any, method?: string, type?: string): Observable<any>;
|
|
18
|
-
/**
|
|
19
|
-
* Wrapper for straightforward query, no chaining..
|
|
20
|
-
*/
|
|
21
|
-
protected exec(q: any, successFn: any, errorFn: any): void;
|
|
22
|
-
/**
|
|
23
|
-
* Returns an object that contains all exported methods of the controller.
|
|
24
|
-
* These methods must be defined in either the "_defaultExportedMethods" or "_exportedMethods" arrays.
|
|
25
|
-
*
|
|
26
|
-
* @returns {*}
|
|
27
|
-
*/
|
|
28
|
-
exports(): any;
|
|
29
|
-
/**
|
|
30
|
-
* returns a string that is 'true' or 'false' (literal) depending on whether the 'options.triggerCondition' is met!
|
|
31
|
-
*
|
|
32
|
-
* @author <a target='_' href='https://github.com/shilob'>Shilo Banihit</a>
|
|
33
|
-
* @param oid
|
|
34
|
-
* @param record
|
|
35
|
-
* @param options
|
|
36
|
-
* @return
|
|
37
|
-
*/
|
|
38
|
-
protected metTriggerCondition(oid: any, record: any, options: any): string;
|
|
39
|
-
protected sleep(ms: any): Promise<unknown>;
|
|
40
|
-
}
|
|
41
|
-
}
|
package/dist/CoreService.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Services = void 0;
|
|
4
|
-
const Rx_1 = require("rxjs/Rx");
|
|
5
|
-
// changed to a manual lodash load instead of relying on Sails global object
|
|
6
|
-
// this enables testing of installable hooks that rely on services at load-time (i.e. index.js)
|
|
7
|
-
const _ = require("lodash");
|
|
8
|
-
var Services;
|
|
9
|
-
(function (Services) {
|
|
10
|
-
var Core;
|
|
11
|
-
(function (Core) {
|
|
12
|
-
class Service {
|
|
13
|
-
constructor() {
|
|
14
|
-
/**
|
|
15
|
-
* Exported methods. Must be overridden by the child to add custom methods.
|
|
16
|
-
*/
|
|
17
|
-
this._exportedMethods = [];
|
|
18
|
-
/**
|
|
19
|
-
* Default exported methods.
|
|
20
|
-
* These methods will be accessible.
|
|
21
|
-
*/
|
|
22
|
-
this._defaultExportedMethods = [
|
|
23
|
-
// Sails controller custom config.
|
|
24
|
-
'_config',
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Returns an RxJS Observable wrapped nice and tidy for your subscribing pleasure
|
|
29
|
-
*/
|
|
30
|
-
getObservable(q, method = 'exec', type = 'node') {
|
|
31
|
-
if (type == 'node')
|
|
32
|
-
return Rx_1.Observable.bindNodeCallback(q[method].bind(q))();
|
|
33
|
-
else
|
|
34
|
-
return Rx_1.Observable.bindCallback(q[method].bind(q))();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Wrapper for straightforward query, no chaining..
|
|
38
|
-
*/
|
|
39
|
-
exec(q, successFn, errorFn) {
|
|
40
|
-
this.getObservable(q).subscribe(successFn, errorFn);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Returns an object that contains all exported methods of the controller.
|
|
44
|
-
* These methods must be defined in either the "_defaultExportedMethods" or "_exportedMethods" arrays.
|
|
45
|
-
*
|
|
46
|
-
* @returns {*}
|
|
47
|
-
*/
|
|
48
|
-
exports() {
|
|
49
|
-
// Merge default array and custom array from child.
|
|
50
|
-
var methods = this._defaultExportedMethods.concat(this._exportedMethods);
|
|
51
|
-
var exportedMethods = {};
|
|
52
|
-
for (var i = 0; i < methods.length; i++) {
|
|
53
|
-
// Check if the method exists.
|
|
54
|
-
if (typeof this[methods[i]] !== 'undefined') {
|
|
55
|
-
// Check that the method shouldn't be private. (Exception for _config, which is a sails config)
|
|
56
|
-
if (methods[i][0] !== '_' || methods[i] === '_config') {
|
|
57
|
-
if (_.isFunction(this[methods[i]])) {
|
|
58
|
-
exportedMethods[methods[i]] = this[methods[i]].bind(this);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
exportedMethods[methods[i]] = this[methods[i]];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
console.error('The method "' + methods[i] + '" is not public and cannot be exported. ' + this);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
console.error('The method "' + methods[i] + '" does not exist on the controller ' + this);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return exportedMethods;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* returns a string that is 'true' or 'false' (literal) depending on whether the 'options.triggerCondition' is met!
|
|
76
|
-
*
|
|
77
|
-
* @author <a target='_' href='https://github.com/shilob'>Shilo Banihit</a>
|
|
78
|
-
* @param oid
|
|
79
|
-
* @param record
|
|
80
|
-
* @param options
|
|
81
|
-
* @return
|
|
82
|
-
*/
|
|
83
|
-
metTriggerCondition(oid, record, options) {
|
|
84
|
-
const triggerCondition = _.get(options, "triggerCondition", "");
|
|
85
|
-
const forceRun = _.get(options, "forceRun", false);
|
|
86
|
-
const variables = {
|
|
87
|
-
imports: {
|
|
88
|
-
record: record,
|
|
89
|
-
oid: oid
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
if (!_.isUndefined(triggerCondition) && !_.isEmpty(triggerCondition)) {
|
|
93
|
-
const compiled = _.template(triggerCondition, variables);
|
|
94
|
-
return compiled();
|
|
95
|
-
}
|
|
96
|
-
else if (forceRun) {
|
|
97
|
-
return "true";
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// if trigger condition is not set, fail fast!
|
|
101
|
-
return "false";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
sleep(ms) {
|
|
105
|
-
return new Promise(resolve => {
|
|
106
|
-
setTimeout(resolve, ms);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
Core.Service = Service;
|
|
111
|
-
})(Core = Services.Core || (Services.Core = {}));
|
|
112
|
-
})(Services = exports.Services || (exports.Services = {}));
|