@qoretechnologies/ts-toolkit 0.4.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/QorusAuthenticator.d.ts +181 -0
- package/dist/QorusAuthenticator.d.ts.map +1 -0
- package/dist/QorusAuthenticator.js +386 -0
- package/dist/QorusAuthenticator.js.map +1 -0
- package/dist/QorusConfigItems.d.ts +13 -0
- package/dist/QorusConfigItems.d.ts.map +1 -0
- package/dist/QorusConfigItems.js +41 -0
- package/dist/QorusConfigItems.js.map +1 -0
- package/dist/QorusDataProvider.d.ts +206 -0
- package/dist/QorusDataProvider.d.ts.map +1 -0
- package/dist/QorusDataProvider.js +262 -0
- package/dist/QorusDataProvider.js.map +1 -0
- package/dist/QorusOptions.d.ts +108 -0
- package/dist/QorusOptions.d.ts.map +1 -0
- package/dist/QorusOptions.js +181 -0
- package/dist/QorusOptions.js.map +1 -0
- package/dist/QorusRequest.d.ts +91 -0
- package/dist/QorusRequest.d.ts.map +1 -0
- package/dist/QorusRequest.js +103 -0
- package/dist/QorusRequest.js.map +1 -0
- package/dist/QorusValidator.d.ts +33 -0
- package/dist/QorusValidator.d.ts.map +1 -0
- package/dist/QorusValidator.js +385 -0
- package/dist/QorusValidator.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/managers/LocalStorage.d.ts +24 -0
- package/dist/managers/LocalStorage.d.ts.map +1 -0
- package/dist/managers/LocalStorage.js +46 -0
- package/dist/managers/LocalStorage.js.map +1 -0
- package/dist/managers/error/Error.d.ts +7 -0
- package/dist/managers/error/Error.d.ts.map +1 -0
- package/dist/managers/error/Error.js +16 -0
- package/dist/managers/error/Error.js.map +1 -0
- package/dist/managers/error/ErrorInternal.d.ts +6 -0
- package/dist/managers/error/ErrorInternal.d.ts.map +1 -0
- package/dist/managers/error/ErrorInternal.js +14 -0
- package/dist/managers/error/ErrorInternal.js.map +1 -0
- package/dist/managers/error/ErrorQorusRequest.d.ts +11 -0
- package/dist/managers/error/ErrorQorusRequest.d.ts.map +1 -0
- package/dist/managers/error/ErrorQorusRequest.js +22 -0
- package/dist/managers/error/ErrorQorusRequest.js.map +1 -0
- package/dist/managers/error/errorCodes.d.ts +8 -0
- package/dist/managers/error/errorCodes.d.ts.map +1 -0
- package/dist/managers/error/errorCodes.js +30 -0
- package/dist/managers/error/errorCodes.js.map +1 -0
- package/dist/managers/logger.d.ts +11 -0
- package/dist/managers/logger.d.ts.map +1 -0
- package/dist/managers/logger.js +22 -0
- package/dist/managers/logger.js.map +1 -0
- package/dist/utils/apiPaths.d.ts +63 -0
- package/dist/utils/apiPaths.d.ts.map +1 -0
- package/dist/utils/apiPaths.js +37 -0
- package/dist/utils/apiPaths.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.d.ts +107 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +108 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TObjectWithStringKey } from '../src';
|
|
2
|
+
import { IDataProviderChildren } from './QorusDataProvider';
|
|
3
|
+
/**
|
|
4
|
+
* QorusOptions is a helper class which makes working Qorus constructor_options easier
|
|
5
|
+
* - Validate constructor_options property value
|
|
6
|
+
* - set and get constructor_options property values
|
|
7
|
+
* @returns QorusOptions class object
|
|
8
|
+
* @Category QorusOptions
|
|
9
|
+
*/
|
|
10
|
+
export declare class QorusOptions {
|
|
11
|
+
/** Name of the provider option */
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Array of constructor_options with validated values
|
|
15
|
+
*/
|
|
16
|
+
qorusOptions: TQorusOptions;
|
|
17
|
+
constructor(children: IDataProviderChildren);
|
|
18
|
+
/**
|
|
19
|
+
* A getter to get constructor options property object
|
|
20
|
+
* @param propertyName Name of the property
|
|
21
|
+
* @returns Property object with name and value
|
|
22
|
+
*/
|
|
23
|
+
get(optionName: string): IQorusPropertyOptions | undefined;
|
|
24
|
+
private adjustChildren;
|
|
25
|
+
/**
|
|
26
|
+
* A validator method to check if all the required properties for constructor_options contains a value
|
|
27
|
+
* @returns True if values for all the required properties exist, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
validateRequired(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get all values required for the provider
|
|
32
|
+
* @returns Array of values for the constructor options if required values exist, undefined otherwise
|
|
33
|
+
*/
|
|
34
|
+
getAll(): TObjectWithStringKey | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* A parser function to modify options object
|
|
37
|
+
* @param children Children for which options will be created
|
|
38
|
+
* @returns Object with constructor options
|
|
39
|
+
*/
|
|
40
|
+
private createJsTypes;
|
|
41
|
+
/**
|
|
42
|
+
* A private function to convert types to js types
|
|
43
|
+
* @param type Type to be converted
|
|
44
|
+
* @returns Converted type
|
|
45
|
+
*/
|
|
46
|
+
private convertToJsType;
|
|
47
|
+
/**
|
|
48
|
+
* A getter to get property type
|
|
49
|
+
* @param propertyName Name of the property
|
|
50
|
+
* @return Types accepted by the property
|
|
51
|
+
*/
|
|
52
|
+
getType(propertyName: string): string[] | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* A getter to get js types for a property
|
|
55
|
+
* @param propertyName name of the property
|
|
56
|
+
* @returns js types accepted by the property
|
|
57
|
+
*/
|
|
58
|
+
getJsType(propertyName: string): string[] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* A setter to set constructor options property value
|
|
61
|
+
* @param propertyName Name of the property
|
|
62
|
+
* @param propertyValue Value for the property
|
|
63
|
+
* @returns Property object
|
|
64
|
+
*/
|
|
65
|
+
set(propertyName: string, value: any): IQorusPropertyOptions | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* A method to validate if the provided value can be used by the property
|
|
68
|
+
* @param propertyName Name of the property
|
|
69
|
+
* @param propertyValue Value for the property
|
|
70
|
+
* @returns True if value can be used, False otherwise
|
|
71
|
+
*/
|
|
72
|
+
validate(propertyName: string, value: any): boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Property object for constructor_options
|
|
76
|
+
*/
|
|
77
|
+
export type TQorusOptions = Record<string, IQorusPropertyOptions>;
|
|
78
|
+
export interface IQorusPropertyOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Accepted types for the constructor_options property
|
|
81
|
+
*/
|
|
82
|
+
type: string[];
|
|
83
|
+
/**
|
|
84
|
+
* Description of constructor_options property
|
|
85
|
+
*/
|
|
86
|
+
desc: string;
|
|
87
|
+
/**
|
|
88
|
+
* Verifies if the constructor_options property is required
|
|
89
|
+
*/
|
|
90
|
+
required: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Verifies if the constructor_options property is sensitive
|
|
93
|
+
*/
|
|
94
|
+
sensitive: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Property value for a constructor_options property
|
|
97
|
+
*/
|
|
98
|
+
value?: any;
|
|
99
|
+
/**
|
|
100
|
+
* Converted Qorus types to jsTypes
|
|
101
|
+
*/
|
|
102
|
+
jsType?: string[] | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Name of a constructor_options property
|
|
105
|
+
*/
|
|
106
|
+
name?: string;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=QorusOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QorusOptions.d.ts","sourceRoot":"","sources":["../src/QorusOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAY5D;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB,mCAAmC;IACnC,IAAI,SAAM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importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.QorusOptions = void 0;
|
|
7
|
+
const ErrorInternal_1 = __importDefault(require("./managers/error/ErrorInternal"));
|
|
8
|
+
const logger_1 = __importDefault(require("./managers/logger"));
|
|
9
|
+
const QorusValidator_1 = __importDefault(require("./QorusValidator"));
|
|
10
|
+
const qorusDataTypesToJsTypesMapper = {
|
|
11
|
+
'object<InputStream>': 'object',
|
|
12
|
+
'object<AbstractDatasource>': 'object',
|
|
13
|
+
'hash<auto>': 'object',
|
|
14
|
+
softint: 'number',
|
|
15
|
+
softbool: 'boolean',
|
|
16
|
+
'softlist<string>': 'array',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* QorusOptions is a helper class which makes working Qorus constructor_options easier
|
|
20
|
+
* - Validate constructor_options property value
|
|
21
|
+
* - set and get constructor_options property values
|
|
22
|
+
* @returns QorusOptions class object
|
|
23
|
+
* @Category QorusOptions
|
|
24
|
+
*/
|
|
25
|
+
class QorusOptions {
|
|
26
|
+
constructor(children) {
|
|
27
|
+
/** Name of the provider option */
|
|
28
|
+
this.name = '';
|
|
29
|
+
/**
|
|
30
|
+
* Array of constructor_options with validated values
|
|
31
|
+
*/
|
|
32
|
+
this.qorusOptions = {};
|
|
33
|
+
this.name = children.name;
|
|
34
|
+
this.qorusOptions = children.constructor_options;
|
|
35
|
+
this.adjustChildren();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A getter to get constructor options property object
|
|
39
|
+
* @param propertyName Name of the property
|
|
40
|
+
* @returns Property object with name and value
|
|
41
|
+
*/
|
|
42
|
+
get(optionName) {
|
|
43
|
+
if (this.qorusOptions && this.qorusOptions.hasOwnProperty(optionName)) {
|
|
44
|
+
return this.qorusOptions[optionName];
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
adjustChildren() {
|
|
50
|
+
if (this.qorusOptions) {
|
|
51
|
+
Object.keys(this.qorusOptions).forEach((key) => {
|
|
52
|
+
this.qorusOptions[key].jsType = this.createJsTypes(this.qorusOptions[key].type);
|
|
53
|
+
this.qorusOptions[key].name = key;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A validator method to check if all the required properties for constructor_options contains a value
|
|
59
|
+
* @returns True if values for all the required properties exist, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
validateRequired() {
|
|
62
|
+
let result = true;
|
|
63
|
+
for (const key in this.qorusOptions) {
|
|
64
|
+
if (this.qorusOptions[key].required) {
|
|
65
|
+
if (!this.qorusOptions[key].value) {
|
|
66
|
+
result = false;
|
|
67
|
+
logger_1.default.error(`${key} is required for ${this.name} provider`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get all values required for the provider
|
|
75
|
+
* @returns Array of values for the constructor options if required values exist, undefined otherwise
|
|
76
|
+
*/
|
|
77
|
+
getAll() {
|
|
78
|
+
const isValid = this.validateRequired();
|
|
79
|
+
if (!isValid) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const allOptions = {};
|
|
83
|
+
Object.keys(this.qorusOptions).forEach((key) => {
|
|
84
|
+
if (this.qorusOptions[key].value) {
|
|
85
|
+
allOptions[key] = this.qorusOptions[key].value;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return allOptions;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A parser function to modify options object
|
|
92
|
+
* @param children Children for which options will be created
|
|
93
|
+
* @returns Object with constructor options
|
|
94
|
+
*/
|
|
95
|
+
createJsTypes(types) {
|
|
96
|
+
if (!types)
|
|
97
|
+
return [];
|
|
98
|
+
const jsTypes = [];
|
|
99
|
+
types.forEach((type) => {
|
|
100
|
+
jsTypes.push(this.convertToJsType(type));
|
|
101
|
+
});
|
|
102
|
+
return jsTypes;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A private function to convert types to js types
|
|
106
|
+
* @param type Type to be converted
|
|
107
|
+
* @returns Converted type
|
|
108
|
+
*/
|
|
109
|
+
convertToJsType(type) {
|
|
110
|
+
if (qorusDataTypesToJsTypesMapper.hasOwnProperty(type)) {
|
|
111
|
+
return qorusDataTypesToJsTypesMapper[type];
|
|
112
|
+
}
|
|
113
|
+
else
|
|
114
|
+
return type;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A getter to get property type
|
|
118
|
+
* @param propertyName Name of the property
|
|
119
|
+
* @return Types accepted by the property
|
|
120
|
+
*/
|
|
121
|
+
getType(propertyName) {
|
|
122
|
+
if (this.qorusOptions.hasOwnProperty(propertyName)) {
|
|
123
|
+
if (!this.qorusOptions[propertyName].type) {
|
|
124
|
+
logger_1.default.error(new ErrorInternal_1.default(`Property ${propertyName} doesn't exist in constructor options of ${this.name}`));
|
|
125
|
+
}
|
|
126
|
+
return this.qorusOptions[propertyName].type;
|
|
127
|
+
}
|
|
128
|
+
logger_1.default.error(new ErrorInternal_1.default(`Property ${propertyName} doesn't exist in constructor options of ${this.name}`));
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A getter to get js types for a property
|
|
133
|
+
* @param propertyName name of the property
|
|
134
|
+
* @returns js types accepted by the property
|
|
135
|
+
*/
|
|
136
|
+
getJsType(propertyName) {
|
|
137
|
+
if (this.qorusOptions.hasOwnProperty(propertyName) && this.qorusOptions[propertyName].jsType) {
|
|
138
|
+
return this.qorusOptions[propertyName].jsType;
|
|
139
|
+
}
|
|
140
|
+
logger_1.default.error(new ErrorInternal_1.default(`Property ${propertyName} doesn't exist in constructor options of ${this.name}`));
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A setter to set constructor options property value
|
|
145
|
+
* @param propertyName Name of the property
|
|
146
|
+
* @param propertyValue Value for the property
|
|
147
|
+
* @returns Property object
|
|
148
|
+
*/
|
|
149
|
+
set(propertyName, value) {
|
|
150
|
+
const isValid = this.validate(propertyName, value);
|
|
151
|
+
if (!isValid) {
|
|
152
|
+
throw new ErrorInternal_1.default(`Value is not valid for the property ${propertyName}`);
|
|
153
|
+
}
|
|
154
|
+
if (this.qorusOptions.hasOwnProperty(propertyName)) {
|
|
155
|
+
this.qorusOptions[propertyName].value = value;
|
|
156
|
+
}
|
|
157
|
+
return this.qorusOptions[propertyName];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A method to validate if the provided value can be used by the property
|
|
161
|
+
* @param propertyName Name of the property
|
|
162
|
+
* @param propertyValue Value for the property
|
|
163
|
+
* @returns True if value can be used, False otherwise
|
|
164
|
+
*/
|
|
165
|
+
validate(propertyName, value) {
|
|
166
|
+
var _a;
|
|
167
|
+
const types = (_a = this.get(propertyName)) === null || _a === void 0 ? void 0 : _a.type;
|
|
168
|
+
if (types) {
|
|
169
|
+
let result = false;
|
|
170
|
+
types.forEach((type) => {
|
|
171
|
+
if (QorusValidator_1.default.validate(type, value)) {
|
|
172
|
+
result = true;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.QorusOptions = QorusOptions;
|
|
181
|
+
//# sourceMappingURL=QorusOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QorusOptions.js","sourceRoot":"","sources":["../src/QorusOptions.ts"],"names":[],"mappings":";;;;;;AACA,mFAA2D;AAC3D,+DAAuC;AAEvC,sEAA8C;AAE9C,MAAM,6BAA6B,GAAG;IACpC,qBAAqB,EAAE,QAAQ;IAC/B,4BAA4B,EAAE,QAAQ;IACtC,YAA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AAY,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;SAC/C;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,YAAoB,EAAE,KAAU;;QACvC,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,0CAAE,IAAI,CAAC;QAC3C,IAAI,KAAK,EAAE;YACT,IAAI,MAAM,GAAG,KAAK,CAAC;YACnB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,IAAI,wBAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;oBACxC,MAAM,GAAG,IAAI,CAAC;iBACf;YACH,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtKD,oCAsKC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { IEndpoint } from './QorusAuthenticator';
|
|
2
|
+
export type TQorusRequestHeader = Record<string, TQorusRecordOptions>;
|
|
3
|
+
export type TQorusRecordOptions = string | number | boolean;
|
|
4
|
+
export interface IQorusRequestResponse<T = any> {
|
|
5
|
+
/**Response data from an api call*/
|
|
6
|
+
data: T;
|
|
7
|
+
/**Response status from an api call */
|
|
8
|
+
status: number;
|
|
9
|
+
/** Response status text from an api call*/
|
|
10
|
+
statusText: string;
|
|
11
|
+
/** Response Headers */
|
|
12
|
+
headers: TQorusRequestHeader;
|
|
13
|
+
/** Response config parameter of a api call */
|
|
14
|
+
config: Record<string, any>;
|
|
15
|
+
/** Request type of the api call */
|
|
16
|
+
request?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface IQorusRequestParams {
|
|
19
|
+
/**
|
|
20
|
+
* Headers to include in an https request to Qorus server api
|
|
21
|
+
*/
|
|
22
|
+
headers?: TQorusRequestHeader;
|
|
23
|
+
/**
|
|
24
|
+
* Path for a https request to Qorus server
|
|
25
|
+
*/
|
|
26
|
+
path: string;
|
|
27
|
+
/**
|
|
28
|
+
* Data to include in an https request to Qorus server api
|
|
29
|
+
*/
|
|
30
|
+
data?: any;
|
|
31
|
+
/**
|
|
32
|
+
* URL Parameters to include in an https request to Qorus server api
|
|
33
|
+
*/
|
|
34
|
+
params?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
export interface IDefaultHeaders {
|
|
37
|
+
/**
|
|
38
|
+
* Content type for the Qorus request
|
|
39
|
+
*/
|
|
40
|
+
'Content-Type': string;
|
|
41
|
+
/**
|
|
42
|
+
* Accepted data format type by Qorus server
|
|
43
|
+
*/
|
|
44
|
+
Accept: string;
|
|
45
|
+
/**
|
|
46
|
+
* Any record with type string
|
|
47
|
+
*/
|
|
48
|
+
[x: string]: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* QorusRequest class is wrapper for https request to Qorus server apis
|
|
52
|
+
* - Adds default headers to the https request
|
|
53
|
+
* - Allows creation of request parameters from a js object
|
|
54
|
+
* - Allows custom headers and data object
|
|
55
|
+
* @returns QorusRequest class object
|
|
56
|
+
* @Category QorusRequest
|
|
57
|
+
*/
|
|
58
|
+
export declare class QorusRequest {
|
|
59
|
+
/**
|
|
60
|
+
* Default headers for the QorusRequest
|
|
61
|
+
*/
|
|
62
|
+
defaultHeaders: IDefaultHeaders;
|
|
63
|
+
private makeRequest;
|
|
64
|
+
/**
|
|
65
|
+
* Get request creator for the QorusToolkit
|
|
66
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a get request
|
|
67
|
+
* @returns Result of the get request
|
|
68
|
+
*/
|
|
69
|
+
get<T>(props: IQorusRequestParams, endpoint?: IEndpoint): Promise<T | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Post request creator for the QorusToolkit
|
|
72
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a post request
|
|
73
|
+
* @returns Result of the post request
|
|
74
|
+
*/
|
|
75
|
+
post<T>(props: IQorusRequestParams, endpoint?: IEndpoint): Promise<T | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* Put request creator for the QorusToolkit
|
|
78
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a put request
|
|
79
|
+
* @returns Result of the put request
|
|
80
|
+
*/
|
|
81
|
+
put<T>(props: IQorusRequestParams, endpoint?: IEndpoint): Promise<T | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete request creator for the QorusToolkit
|
|
84
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a delete request
|
|
85
|
+
* @returns Result of the delete request
|
|
86
|
+
*/
|
|
87
|
+
deleteReq<T>(props: IQorusRequestParams, endpoint?: IEndpoint): Promise<T | undefined>;
|
|
88
|
+
}
|
|
89
|
+
declare const _default: QorusRequest;
|
|
90
|
+
export default _default;
|
|
91
|
+
//# sourceMappingURL=QorusRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QorusRequest.d.ts","sourceRoot":"","sources":["../src/QorusRequest.ts"],"names":[],"mappings":"AAGA,OAA2B,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGrE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C,mCAAmC;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,mCAAmC;IACnC,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAE9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,cAAc,EAAE,eAAe,CAAsE;IAErG,OAAO,CAAC,WAAW,CA+CjB;IAEF;;;;OAIG;IACG,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKtF;;;;OAIG;IACG,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKvF;;;;OAIG;IACG,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKtF;;;;OAIG;IACG,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAI7F;;AAED,wBAAkC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.QorusRequest = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
const ErrorInternal_1 = __importDefault(require("./managers/error/ErrorInternal"));
|
|
9
|
+
const ErrorQorusRequest_1 = __importDefault(require("./managers/error/ErrorQorusRequest"));
|
|
10
|
+
const QorusAuthenticator_1 = __importDefault(require("./QorusAuthenticator"));
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
/**
|
|
13
|
+
* QorusRequest class is wrapper for https request to Qorus server apis
|
|
14
|
+
* - Adds default headers to the https request
|
|
15
|
+
* - Allows creation of request parameters from a js object
|
|
16
|
+
* - Allows custom headers and data object
|
|
17
|
+
* @returns QorusRequest class object
|
|
18
|
+
* @Category QorusRequest
|
|
19
|
+
*/
|
|
20
|
+
class QorusRequest {
|
|
21
|
+
constructor() {
|
|
22
|
+
/**
|
|
23
|
+
* Default headers for the QorusRequest
|
|
24
|
+
*/
|
|
25
|
+
this.defaultHeaders = { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
26
|
+
this.makeRequest = async (type, props, endpoint) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const { path, data, headers = this.defaultHeaders, params } = props;
|
|
29
|
+
let selectedEndpoint;
|
|
30
|
+
if ((0, utils_1.isValidStringArray)([endpoint === null || endpoint === void 0 ? void 0 : endpoint.url, endpoint === null || endpoint === void 0 ? void 0 : endpoint.endpointId])) {
|
|
31
|
+
selectedEndpoint = endpoint;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
selectedEndpoint = QorusAuthenticator_1.default.getSelectedEndpoint();
|
|
35
|
+
}
|
|
36
|
+
if (headers != this.defaultHeaders) {
|
|
37
|
+
Object.assign(headers, Object.assign(Object.assign({}, this.defaultHeaders), { headers }));
|
|
38
|
+
}
|
|
39
|
+
if (selectedEndpoint === null || selectedEndpoint === void 0 ? void 0 : selectedEndpoint.url) {
|
|
40
|
+
Object.assign(headers, Object.assign(Object.assign({}, headers), { 'Qorus-Token': (_a = selectedEndpoint === null || selectedEndpoint === void 0 ? void 0 : selectedEndpoint.authToken) !== null && _a !== void 0 ? _a : '' }));
|
|
41
|
+
const requestParams = new URLSearchParams(params).toString();
|
|
42
|
+
let fetchUrl;
|
|
43
|
+
if (requestParams.length) {
|
|
44
|
+
fetchUrl = `${selectedEndpoint === null || selectedEndpoint === void 0 ? void 0 : selectedEndpoint.url}${path}?${requestParams}`;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
fetchUrl = `${selectedEndpoint === null || selectedEndpoint === void 0 ? void 0 : selectedEndpoint.url}${path}`;
|
|
48
|
+
}
|
|
49
|
+
const promise = await (0, node_fetch_1.default)(fetchUrl, {
|
|
50
|
+
method: type,
|
|
51
|
+
headers: headers,
|
|
52
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
53
|
+
});
|
|
54
|
+
if (!promise.ok) {
|
|
55
|
+
const text = await promise.text();
|
|
56
|
+
throw new ErrorQorusRequest_1.default(text);
|
|
57
|
+
}
|
|
58
|
+
const json = await promise.json();
|
|
59
|
+
return { data: json };
|
|
60
|
+
}
|
|
61
|
+
throw new ErrorInternal_1.default('Initialize an endpoint using QorusAuthenticator to use QorusRequest');
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get request creator for the QorusToolkit
|
|
66
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a get request
|
|
67
|
+
* @returns Result of the get request
|
|
68
|
+
*/
|
|
69
|
+
async get(props, endpoint) {
|
|
70
|
+
const result = await this.makeRequest('GET', props, endpoint);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Post request creator for the QorusToolkit
|
|
75
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a post request
|
|
76
|
+
* @returns Result of the post request
|
|
77
|
+
*/
|
|
78
|
+
async post(props, endpoint) {
|
|
79
|
+
const result = await this.makeRequest('POST', props, endpoint);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Put request creator for the QorusToolkit
|
|
84
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a put request
|
|
85
|
+
* @returns Result of the put request
|
|
86
|
+
*/
|
|
87
|
+
async put(props, endpoint) {
|
|
88
|
+
const result = await this.makeRequest('PUT', props, endpoint);
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Delete request creator for the QorusToolkit
|
|
93
|
+
* @param props QorusRequestParams endpoint url is mandatory to make a delete request
|
|
94
|
+
* @returns Result of the delete request
|
|
95
|
+
*/
|
|
96
|
+
async deleteReq(props, endpoint) {
|
|
97
|
+
const result = await this.makeRequest('DELETE', props, endpoint);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.QorusRequest = QorusRequest;
|
|
102
|
+
exports.default = new QorusRequest();
|
|
103
|
+
//# sourceMappingURL=QorusRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QorusRequest.js","sourceRoot":"","sources":["../src/QorusRequest.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAgD;AAChD,mFAA2D;AAC3D,2FAAmE;AACnE,8EAAqE;AACrE,mCAA6C;AA4D7C;;;;;;;GAOG;AACH,MAAa,YAAY;IAAzB;QACE;;WAEG;QACH,mBAAc,GAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;QAE7F,gBAAW,GAAG,KAAK,EACzB,IAAuC,EACvC,KAA0B,EAC1B,QAAoB,EACN,EAAE;;YAChB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YACpE,IAAI,gBAAuC,CAAC;YAE5C,IAAI,IAAA,0BAAkB,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0,0 +1,33 @@
|
|
|
1
|
+
import { TQorusType } from './utils/validation';
|
|
2
|
+
export declare const versions: (string | number)[];
|
|
3
|
+
/**
|
|
4
|
+
* QorusValidator is a helper class to verify the validity for Qorus types and their values
|
|
5
|
+
* - Verify if a value can be used for Qorus type
|
|
6
|
+
* @returns QorusValidator class object
|
|
7
|
+
* @Category QorusValidator
|
|
8
|
+
*/
|
|
9
|
+
export declare class QorusValidator {
|
|
10
|
+
/**
|
|
11
|
+
* Verifies if the type can be null or not
|
|
12
|
+
* @param type Type of the object
|
|
13
|
+
* @returns True if the the type can be null, False otherwise
|
|
14
|
+
*/
|
|
15
|
+
private nullType;
|
|
16
|
+
/**
|
|
17
|
+
* Validate property for the provider-options for data-provider
|
|
18
|
+
* @param type type of value for the property
|
|
19
|
+
* @param value value for the property
|
|
20
|
+
* @param canBeNull if the value can be null
|
|
21
|
+
* @returns True if the value can be accepted for the type, False otherwise
|
|
22
|
+
*/
|
|
23
|
+
validate(type: string | TQorusType, value?: any, canBeNull?: boolean): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get QorusType from the value
|
|
26
|
+
* @param value Any accepted type value
|
|
27
|
+
* @returns QorusType string
|
|
28
|
+
*/
|
|
29
|
+
getTypeFromValue(value: any): 'string' | 'int' | 'list' | 'bool' | 'float' | 'hash' | 'date' | 'null' | 'none';
|
|
30
|
+
}
|
|
31
|
+
declare const _default: QorusValidator;
|
|
32
|
+
export default _default;
|
|
33
|
+
//# sourceMappingURL=QorusValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QorusValidator.d.ts","sourceRoot":"","sources":["../src/QorusValidator.ts"],"names":[],"mappings":"AAIA,OAAO,EAUL,UAAU,EAEX,MAAM,oBAAoB,CAAC;AAK5B,eAAO,MAAM,QAAQ,qBAA+B,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,cAAc;IACzB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAQhB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO;IAsW9E;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;CAkC/G;;AAED,wBAAoC"}
|