@bwi-mentorspaces/application-utils-npm 0.0.4

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.
Files changed (163) hide show
  1. package/chat/index.d.ts +36 -0
  2. package/chat/index.js +59 -0
  3. package/chat/index.js.map +1 -0
  4. package/chat/stream/enum/index.d.ts +27 -0
  5. package/chat/stream/enum/index.js +35 -0
  6. package/chat/stream/enum/index.js.map +1 -0
  7. package/chat/stream/index.d.ts +9 -0
  8. package/chat/stream/index.js +18 -0
  9. package/chat/stream/index.js.map +1 -0
  10. package/chat/stream/models/_/channel.data.d.ts +19 -0
  11. package/chat/stream/models/_/channel.data.js +3 -0
  12. package/chat/stream/models/_/channel.data.js.map +1 -0
  13. package/chat/stream/models/_/channel.member.d.ts +14 -0
  14. package/chat/stream/models/_/channel.member.js +12 -0
  15. package/chat/stream/models/_/channel.member.js.map +1 -0
  16. package/chat/stream/models/_/channel.response.d.ts +8 -0
  17. package/chat/stream/models/_/channel.response.js +3 -0
  18. package/chat/stream/models/_/channel.response.js.map +1 -0
  19. package/chat/stream/models/_/message.response.d.ts +8 -0
  20. package/chat/stream/models/_/message.response.js +3 -0
  21. package/chat/stream/models/_/message.response.js.map +1 -0
  22. package/chat/stream/models/_/stream.config.d.ts +22 -0
  23. package/chat/stream/models/_/stream.config.js +3 -0
  24. package/chat/stream/models/_/stream.config.js.map +1 -0
  25. package/chat/stream/models/_/user.response.d.ts +8 -0
  26. package/chat/stream/models/_/user.response.js +3 -0
  27. package/chat/stream/models/_/user.response.js.map +1 -0
  28. package/chat/stream/models/index.d.ts +7 -0
  29. package/chat/stream/models/index.js +6 -0
  30. package/chat/stream/models/index.js.map +1 -0
  31. package/chat/stream/stream.api.d.ts +63 -0
  32. package/chat/stream/stream.api.js +77 -0
  33. package/chat/stream/stream.api.js.map +1 -0
  34. package/chat/stream/stream.auth.d.ts +70 -0
  35. package/chat/stream/stream.auth.js +81 -0
  36. package/chat/stream/stream.auth.js.map +1 -0
  37. package/chat/stream/stream.base.d.ts +56 -0
  38. package/chat/stream/stream.base.js +94 -0
  39. package/chat/stream/stream.base.js.map +1 -0
  40. package/chat/stream/stream.channel.d.ts +118 -0
  41. package/chat/stream/stream.channel.js +275 -0
  42. package/chat/stream/stream.channel.js.map +1 -0
  43. package/chat/stream/stream.error.d.ts +19 -0
  44. package/chat/stream/stream.error.js +18 -0
  45. package/chat/stream/stream.error.js.map +1 -0
  46. package/chat/stream/stream.media.d.ts +0 -0
  47. package/chat/stream/stream.media.js +1 -0
  48. package/chat/stream/stream.media.js.map +1 -0
  49. package/chat/stream/stream.member.d.ts +75 -0
  50. package/chat/stream/stream.member.js +176 -0
  51. package/chat/stream/stream.member.js.map +1 -0
  52. package/chat/stream/stream.message.d.ts +59 -0
  53. package/chat/stream/stream.message.js +113 -0
  54. package/chat/stream/stream.message.js.map +1 -0
  55. package/chat/stream/stream.user.d.ts +49 -0
  56. package/chat/stream/stream.user.js +91 -0
  57. package/chat/stream/stream.user.js.map +1 -0
  58. package/core/_/api-error.d.ts +24 -0
  59. package/core/_/api-error.js +22 -0
  60. package/core/_/api-error.js.map +1 -0
  61. package/core/_/api-response.d.ts +25 -0
  62. package/core/_/api-response.js +22 -0
  63. package/core/_/api-response.js.map +1 -0
  64. package/core/_/cors-headers.d.ts +16 -0
  65. package/core/_/cors-headers.js +33 -0
  66. package/core/_/cors-headers.js.map +1 -0
  67. package/core/_/model.d.ts +31 -0
  68. package/core/_/model.js +3 -0
  69. package/core/_/model.js.map +1 -0
  70. package/core/_/service-request.d.ts +66 -0
  71. package/core/_/service-request.js +105 -0
  72. package/core/_/service-request.js.map +1 -0
  73. package/core/index.d.ts +10 -0
  74. package/core/index.js +12 -0
  75. package/core/index.js.map +1 -0
  76. package/deployment/_/serverless.d.ts +26 -0
  77. package/deployment/_/serverless.js +44 -0
  78. package/deployment/_/serverless.js.map +1 -0
  79. package/deployment/index.d.ts +2 -0
  80. package/deployment/index.js +6 -0
  81. package/deployment/index.js.map +1 -0
  82. package/endpoint-test-factory/_/test-factory.d.ts +45 -0
  83. package/endpoint-test-factory/_/test-factory.js +92 -0
  84. package/endpoint-test-factory/_/test-factory.js.map +1 -0
  85. package/endpoint-test-factory/index.d.ts +2 -0
  86. package/endpoint-test-factory/index.js +6 -0
  87. package/endpoint-test-factory/index.js.map +1 -0
  88. package/enums/index.d.ts +92 -0
  89. package/enums/index.js +3 -0
  90. package/enums/index.js.map +1 -0
  91. package/meet/index.d.ts +36 -0
  92. package/meet/index.js +59 -0
  93. package/meet/index.js.map +1 -0
  94. package/meet/twilio/enum/index.d.ts +6 -0
  95. package/meet/twilio/enum/index.js +11 -0
  96. package/meet/twilio/enum/index.js.map +1 -0
  97. package/meet/twilio/index.d.ts +5 -0
  98. package/meet/twilio/index.js +12 -0
  99. package/meet/twilio/index.js.map +1 -0
  100. package/meet/twilio/models/_/room.data.d.ts +6 -0
  101. package/meet/twilio/models/_/room.data.js +3 -0
  102. package/meet/twilio/models/_/room.data.js.map +1 -0
  103. package/meet/twilio/models/_/twilio.config.d.ts +29 -0
  104. package/meet/twilio/models/_/twilio.config.js +3 -0
  105. package/meet/twilio/models/_/twilio.config.js.map +1 -0
  106. package/meet/twilio/models/index.d.ts +3 -0
  107. package/meet/twilio/models/index.js +3 -0
  108. package/meet/twilio/models/index.js.map +1 -0
  109. package/meet/twilio/twilio.api.d.ts +28 -0
  110. package/meet/twilio/twilio.api.js +46 -0
  111. package/meet/twilio/twilio.api.js.map +1 -0
  112. package/meet/twilio/twilio.auth.d.ts +55 -0
  113. package/meet/twilio/twilio.auth.js +84 -0
  114. package/meet/twilio/twilio.auth.js.map +1 -0
  115. package/meet/twilio/twilio.base.d.ts +41 -0
  116. package/meet/twilio/twilio.base.js +54 -0
  117. package/meet/twilio/twilio.base.js.map +1 -0
  118. package/meet/twilio/twilio.room.d.ts +46 -0
  119. package/meet/twilio/twilio.room.js +125 -0
  120. package/meet/twilio/twilio.room.js.map +1 -0
  121. package/package.json +57 -0
  122. package/swagger/_/swagger.config.d.ts +21 -0
  123. package/swagger/_/swagger.config.js +3 -0
  124. package/swagger/_/swagger.config.js.map +1 -0
  125. package/swagger/_/swagger.d.ts +37 -0
  126. package/swagger/_/swagger.js +79 -0
  127. package/swagger/_/swagger.js.map +1 -0
  128. package/swagger/index.d.ts +3 -0
  129. package/swagger/index.js +6 -0
  130. package/swagger/index.js.map +1 -0
  131. package/types/index.d.ts +19 -0
  132. package/types/index.js +3 -0
  133. package/types/index.js.map +1 -0
  134. package/utils/_/encoder.d.ts +19 -0
  135. package/utils/_/encoder.js +28 -0
  136. package/utils/_/encoder.js.map +1 -0
  137. package/utils/_/encryptor.d.ts +26 -0
  138. package/utils/_/encryptor.js +68 -0
  139. package/utils/_/encryptor.js.map +1 -0
  140. package/utils/_/hasher.d.ts +25 -0
  141. package/utils/_/hasher.js +64 -0
  142. package/utils/_/hasher.js.map +1 -0
  143. package/utils/_/object-mapper.d.ts +12 -0
  144. package/utils/_/object-mapper.js +23 -0
  145. package/utils/_/object-mapper.js.map +1 -0
  146. package/utils/_/string-formatter.d.ts +34 -0
  147. package/utils/_/string-formatter.js +50 -0
  148. package/utils/_/string-formatter.js.map +1 -0
  149. package/utils/_/utc-date.d.ts +35 -0
  150. package/utils/_/utc-date.js +85 -0
  151. package/utils/_/utc-date.js.map +1 -0
  152. package/utils/index.d.ts +7 -0
  153. package/utils/index.js +16 -0
  154. package/utils/index.js.map +1 -0
  155. package/validators/_/checker.d.ts +62 -0
  156. package/validators/_/checker.js +99 -0
  157. package/validators/_/checker.js.map +1 -0
  158. package/validators/_/regex.d.ts +98 -0
  159. package/validators/_/regex.js +143 -0
  160. package/validators/_/regex.js.map +1 -0
  161. package/validators/index.d.ts +3 -0
  162. package/validators/index.js +8 -0
  163. package/validators/index.js.map +1 -0
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiResponse = void 0;
4
+ /**
5
+ * Implementation of api response model declarations
6
+ */
7
+ class ApiResponse {
8
+ /**
9
+ * ApiResponse constructor
10
+ *
11
+ * @param {number} status response status
12
+ * @param {T | undefined} result response result as type T
13
+ * @param {IApiError | undefined} error response error
14
+ */
15
+ constructor(status, result, error) {
16
+ this.status = status;
17
+ this.result = result ? result : undefined;
18
+ this.error = error ? error : undefined;
19
+ }
20
+ }
21
+ exports.ApiResponse = ApiResponse;
22
+ //# sourceMappingURL=api-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-response.js","sourceRoot":"","sources":["../../../core/_/api-response.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACH,MAAa,WAAW;IAMpB;;;;;;OAMG;IACH,YAAY,MAAc,EAAE,MAAsB,EAAE,KAA6B;QAC7E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAE,MAAY,CAAC,CAAC,CAAC,SAAS,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,KAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;CACJ;AAlBD,kCAkBC"}
@@ -0,0 +1,16 @@
1
+ import Express from "express";
2
+ import { Method, Header } from "../../enums";
3
+ /**
4
+ * Cors Headers implementation
5
+ */
6
+ export declare abstract class CorsHeaders {
7
+ /**
8
+ * CorsHeaders constructor
9
+ *
10
+ * @param {Express.Response} res express response
11
+ * @param {Method[]} methods array of allowed Methods | defaults to all
12
+ * @param {string?} origin allowed origin url | * default
13
+ * @param {Header[]} headers array of allowed headers | defaults to AWS CORS headers
14
+ */
15
+ static set(res: Express.Response, methods?: Method[], origin?: string, headers?: Header[]): void;
16
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CorsHeaders = void 0;
4
+ /**
5
+ * Cors Headers implementation
6
+ */
7
+ class CorsHeaders {
8
+ /**
9
+ * CorsHeaders constructor
10
+ *
11
+ * @param {Express.Response} res express response
12
+ * @param {Method[]} methods array of allowed Methods | defaults to all
13
+ * @param {string?} origin allowed origin url | * default
14
+ * @param {Header[]} headers array of allowed headers | defaults to AWS CORS headers
15
+ */
16
+ static set(res, methods, origin, headers) {
17
+ res.header["Access-Control-Allow-Origin" /* AccessControlAllowOrigin */] = origin ? origin.toString() : "*";
18
+ res.header["Access-Control-Allow-Methods" /* AccessControlAllowMethods */] = methods
19
+ ? methods.join(",")
20
+ : ["GET" /* GET */, "POST" /* POST */, "PUT" /* PUT */, "PATCH" /* PATCH */, "DELETE" /* DELETE */, "OPTIONS" /* OPTIONS */].join(",");
21
+ res.header["Access-Control-Allow-Headers" /* AccessControlAllowHeaders */] = headers
22
+ ? headers.join(",")
23
+ : [
24
+ "Content-Type" /* ContentType */,
25
+ "Authorization" /* Authorization */,
26
+ "X-Api-Key" /* XApiKey */,
27
+ "X-Amz-Date" /* XAmzDate */,
28
+ "X-Amz-Security-Token" /* XAmzSecurityToken */
29
+ ].join(",");
30
+ }
31
+ }
32
+ exports.CorsHeaders = CorsHeaders;
33
+ //# sourceMappingURL=cors-headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors-headers.js","sourceRoot":"","sources":["../../../core/_/cors-headers.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAsB,WAAW;IAC7B;;;;;;;OAOG;IACH,MAAM,CAAC,GAAG,CAAC,GAAqB,EAAE,OAAkB,EAAE,MAAe,EAAE,OAAkB;QACrF,GAAG,CAAC,MAAM,8DAAiC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/E,GAAG,CAAC,MAAM,gEAAkC,GAAG,OAAO;YAClD,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;YACnB,CAAC,CAAC,0HAAkF,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnG,GAAG,CAAC,MAAM,gEAAkC,GAAG,OAAO;YAClD,CAAC,CAAE,OAAoB,CAAC,IAAI,CAAC,GAAG,CAAC;YACjC,CAAC,CAAC;;;;;;aAMC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;CACJ;AAxBD,kCAwBC"}
@@ -0,0 +1,31 @@
1
+ import { Any } from "../../types";
2
+ /**
3
+ * Status model declarations
4
+ */
5
+ export interface IStatus {
6
+ code: number;
7
+ message: string;
8
+ }
9
+ /**
10
+ * Data filter model declarations
11
+ */
12
+ export interface IDataFilter {
13
+ filter: string;
14
+ data: Any;
15
+ }
16
+ /**
17
+ * Pagination request model declarations
18
+ */
19
+ export interface IPaginationRequest {
20
+ perPage: number;
21
+ page: number;
22
+ }
23
+ /**
24
+ * Pagination response model declarations
25
+ */
26
+ export interface IPaginationResponse<T> {
27
+ currentPage: number;
28
+ lastPage: number;
29
+ totalCount: number;
30
+ data: T;
31
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../core/_/model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Service request header model declarations
3
+ */
4
+ export interface IServiceRequestHeader {
5
+ name: string;
6
+ value: string;
7
+ }
8
+ /**
9
+ * Service request body model declarations
10
+ */
11
+ export interface IServiceRequestBody<TRequest> {
12
+ value: TRequest;
13
+ contentType: string;
14
+ }
15
+ /**
16
+ * Service request model declarations
17
+ */
18
+ interface IServiceRequest<TRequest, TResponse> {
19
+ url: string;
20
+ method: string;
21
+ headers: IServiceRequestHeader[];
22
+ body: IServiceRequestBody<TRequest>;
23
+ /**
24
+ * Send method declaration
25
+ */
26
+ send(): Promise<TResponse>;
27
+ }
28
+ /**
29
+ * Implementation of service request model declarations
30
+ */
31
+ export declare class ServiceRequest<TRequest, TResponse> implements IServiceRequest<TRequest, TResponse> {
32
+ private _url;
33
+ private _method;
34
+ private _headers;
35
+ private _body;
36
+ /**
37
+ * Setter for url property
38
+ */
39
+ set url(value: string);
40
+ /**
41
+ * Setter for method property
42
+ */
43
+ set method(value: string);
44
+ /**
45
+ * Setter for headers property
46
+ */
47
+ set headers(value: IServiceRequestHeader[]);
48
+ /**
49
+ * Setter for body property
50
+ */
51
+ set body(value: IServiceRequestBody<TRequest>);
52
+ /**
53
+ * Send method
54
+ * Call after setting up url, method, headers and body if applicable
55
+ *
56
+ * @returns {Promise<TResponse>} promise of API Response object of type TResponse
57
+ */
58
+ send(): Promise<TResponse>;
59
+ /**
60
+ * Setup request headers map
61
+ *
62
+ * @returns {Record<string, string>} map of request headers
63
+ */
64
+ private setHeaders;
65
+ }
66
+ export {};
@@ -0,0 +1,105 @@
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.ServiceRequest = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ /**
18
+ * Implementation of service request model declarations
19
+ */
20
+ class ServiceRequest {
21
+ constructor() {
22
+ // properties
23
+ this._url = "";
24
+ this._method = "";
25
+ this._headers = undefined;
26
+ this._body = undefined;
27
+ }
28
+ /**
29
+ * Setter for url property
30
+ */
31
+ set url(value) {
32
+ this._url = value;
33
+ }
34
+ /**
35
+ * Setter for method property
36
+ */
37
+ set method(value) {
38
+ this._method = value;
39
+ }
40
+ /**
41
+ * Setter for headers property
42
+ */
43
+ set headers(value) {
44
+ this._headers = value;
45
+ }
46
+ /**
47
+ * Setter for body property
48
+ */
49
+ set body(value) {
50
+ this._body = value;
51
+ }
52
+ /**
53
+ * Send method
54
+ * Call after setting up url, method, headers and body if applicable
55
+ *
56
+ * @returns {Promise<TResponse>} promise of API Response object of type TResponse
57
+ */
58
+ send() {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
61
+ // set config / options
62
+ const options = {
63
+ url: this._url,
64
+ method: this._method
65
+ };
66
+ // set headers
67
+ options.headers = this.setHeaders();
68
+ // set body (if exists)
69
+ if (this._body) {
70
+ options.headers["Content-Type" /* ContentType */] = this._body.contentType;
71
+ options.data = this._body.value;
72
+ }
73
+ // exec
74
+ yield (0, axios_1.default)(options)
75
+ .then((xr) => {
76
+ resolve(xr.data);
77
+ })
78
+ .catch((xe) => {
79
+ reject(xe.response.data);
80
+ });
81
+ }));
82
+ });
83
+ }
84
+ /**
85
+ * Setup request headers map
86
+ *
87
+ * @returns {Record<string, string>} map of request headers
88
+ */
89
+ setHeaders() {
90
+ const map = {};
91
+ if (this._headers) {
92
+ this._headers.forEach((header) => {
93
+ map[header.name] = header.value;
94
+ });
95
+ }
96
+ // set default headers
97
+ map["Content-Type" /* ContentType */] = "application/json" /* ApplicationJson */;
98
+ map["Accept" /* Accept */] = "*";
99
+ map["Accept-Charset" /* AcceptCharset */] = "*";
100
+ map["Accept-Encoding" /* AcceptEncoding */] = "*";
101
+ return map;
102
+ }
103
+ }
104
+ exports.ServiceRequest = ServiceRequest;
105
+ //# sourceMappingURL=service-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-request.js","sourceRoot":"","sources":["../../../core/_/service-request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA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gBAClC,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,EAAc,EAAE,EAAE;oBACtB,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAiB,CAAC,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACX,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KAAA;IAED;;;;OAIG;IACK,UAAU;QACd,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAA6B,EAAE,EAAE;gBACpD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;YACpC,CAAC,CAAC,CAAC;SACN;QAED,sBAAsB;QACtB,GAAG,kCAAoB,2CAA2B,CAAC;QACnD,GAAG,uBAAe,GAAG,GAAG,CAAC;QACzB,GAAG,sCAAsB,GAAG,GAAG,CAAC;QAChC,GAAG,wCAAuB,GAAG,GAAG,CAAC;QAEjC,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA1FD,wCA0FC"}
@@ -0,0 +1,10 @@
1
+ import { IApiResponse, ApiResponse } from "./_/api-response";
2
+ import { IApiError, ApiError } from "./_/api-error";
3
+ import { IStatus, IDataFilter, IPaginationResponse, IPaginationRequest } from "./_/model";
4
+ import { IServiceRequestHeader, IServiceRequestBody, ServiceRequest } from "./_/service-request";
5
+ import { CorsHeaders } from "./_/cors-headers";
6
+ export { IApiResponse, ApiResponse };
7
+ export { IApiError, ApiError };
8
+ export { IStatus, IDataFilter, IPaginationRequest, IPaginationResponse };
9
+ export { IServiceRequestHeader, IServiceRequestBody, ServiceRequest };
10
+ export { CorsHeaders };
package/core/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CorsHeaders = exports.ServiceRequest = exports.ApiError = exports.ApiResponse = void 0;
4
+ const api_response_1 = require("./_/api-response");
5
+ Object.defineProperty(exports, "ApiResponse", { enumerable: true, get: function () { return api_response_1.ApiResponse; } });
6
+ const api_error_1 = require("./_/api-error");
7
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return api_error_1.ApiError; } });
8
+ const service_request_1 = require("./_/service-request");
9
+ Object.defineProperty(exports, "ServiceRequest", { enumerable: true, get: function () { return service_request_1.ServiceRequest; } });
10
+ const cors_headers_1 = require("./_/cors-headers");
11
+ Object.defineProperty(exports, "CorsHeaders", { enumerable: true, get: function () { return cors_headers_1.CorsHeaders; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../core/index.ts"],"names":[],"mappings":";;;AAAA,mDAA6D;AAMtC,4FANA,0BAAW,OAMA;AALlC,6CAAoD;AAMhC,yFANA,oBAAQ,OAMA;AAJ5B,yDAAiG;AAM5C,+FANA,gCAAc,OAMA;AALnE,mDAA+C;AAMtC,4FANA,0BAAW,OAMA"}
@@ -0,0 +1,26 @@
1
+ /// <reference types="express-serve-static-core" />
2
+ /**
3
+ * Serverless handler declarations
4
+ */
5
+ interface IServerless {
6
+ handler: Function;
7
+ }
8
+ /**
9
+ * Serverless Handler implementation
10
+ */
11
+ export declare class Serverless implements IServerless {
12
+ private _app;
13
+ /**
14
+ * Serverless handler constructor
15
+ *
16
+ * @param {Express.Application} app express instance
17
+ */
18
+ constructor(app: Express.Application);
19
+ /**
20
+ * handler getter
21
+ *
22
+ * @returns {Handler} serverless handler
23
+ */
24
+ get handler(): Function;
25
+ }
26
+ export {};
@@ -0,0 +1,44 @@
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.Serverless = void 0;
16
+ const serverless_http_1 = __importDefault(require("serverless-http"));
17
+ /**
18
+ * Serverless Handler implementation
19
+ */
20
+ class Serverless {
21
+ /**
22
+ * Serverless handler constructor
23
+ *
24
+ * @param {Express.Application} app express instance
25
+ */
26
+ constructor(app) {
27
+ this._app = app;
28
+ }
29
+ // getter / setter
30
+ /**
31
+ * handler getter
32
+ *
33
+ * @returns {Handler} serverless handler
34
+ */
35
+ get handler() {
36
+ const handler = (0, serverless_http_1.default)(this._app);
37
+ return (event, context) => __awaiter(this, void 0, void 0, function* () {
38
+ const result = yield handler(event, context);
39
+ return result;
40
+ });
41
+ }
42
+ }
43
+ exports.Serverless = Serverless;
44
+ //# sourceMappingURL=serverless.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverless.js","sourceRoot":"","sources":["../../../deployment/_/serverless.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,sEAAsD;AAUtD;;GAEG;AACH,MAAa,UAAU;IAGnB;;;;OAIG;IACH,YAAY,GAAwB;QAChC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,kBAAkB;IAClB;;;;OAIG;IACH,IAAI,OAAO;QACP,MAAM,OAAO,GAAY,IAAA,yBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,CAAO,KAA6B,EAAE,OAAgB,EAAE,EAAE;YAC7D,MAAM,MAAM,GAA4B,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACtE,OAAO,MAAM,CAAC;QAClB,CAAC,CAAA,CAAC;IACN,CAAC;CACJ;AAzBD,gCAyBC"}
@@ -0,0 +1,2 @@
1
+ import { Serverless } from "./_/serverless";
2
+ export { Serverless };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Serverless = void 0;
4
+ const serverless_1 = require("./_/serverless");
5
+ Object.defineProperty(exports, "Serverless", { enumerable: true, get: function () { return serverless_1.Serverless; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../deployment/index.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAEnC,2FAFA,uBAAU,OAEA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * MUST READ Setup.md
3
+ *
4
+ * Access @ node_modules/application-utils-npm/endpoint-test-factory/_/Setup.md
5
+ */
6
+ import Express from "express";
7
+ import { Response } from "supertest";
8
+ import { Any } from "../../types";
9
+ import { Method } from "../../enums";
10
+ /**
11
+ * Test factory class
12
+ */
13
+ export declare class TestFactory {
14
+ private _xprs;
15
+ private _debug;
16
+ /**
17
+ * Test Factor Constructor
18
+ *
19
+ * @param {Express.Application} app service express instance
20
+ * @param {boolean?} debug flag for debugging
21
+ */
22
+ constructor(app: Express.Application, debug?: boolean);
23
+ /**
24
+ * getter for app
25
+ *
26
+ * @returns {Request.SuperTest<Request.Test>} supertest request
27
+ */
28
+ private get app();
29
+ /**
30
+ * Log message (this.log) if debug = true
31
+ *
32
+ * @param {any[]} msg message to log as arguments
33
+ */
34
+ log(...msg: Any[]): void;
35
+ /**
36
+ * Run test
37
+ *
38
+ * @param {Method} method enum value for GET, POST, PUT, DELETE
39
+ * @param {string} path api call path
40
+ * @param {object?} data post data
41
+ * @param {Map?} headers map of headers to add to request
42
+ * @returns {void}
43
+ */
44
+ test(method: Method, path: string, data?: object, headers?: Map<string, string>): Promise<Response>;
45
+ }
@@ -0,0 +1,92 @@
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.TestFactory = void 0;
16
+ const supertest_1 = __importDefault(require("supertest"));
17
+ /**
18
+ * Test factory class
19
+ */
20
+ class TestFactory {
21
+ /**
22
+ * Test Factor Constructor
23
+ *
24
+ * @param {Express.Application} app service express instance
25
+ * @param {boolean?} debug flag for debugging
26
+ */
27
+ constructor(app, debug) {
28
+ this._xprs = app;
29
+ this._debug = debug ? debug : false;
30
+ }
31
+ /**
32
+ * getter for app
33
+ *
34
+ * @returns {Request.SuperTest<Request.Test>} supertest request
35
+ */
36
+ get app() {
37
+ return (0, supertest_1.default)(this._xprs);
38
+ }
39
+ /**
40
+ * Log message (this.log) if debug = true
41
+ *
42
+ * @param {any[]} msg message to log as arguments
43
+ */
44
+ log(...msg) {
45
+ if (this._debug) {
46
+ console.log(msg);
47
+ }
48
+ }
49
+ /**
50
+ * Run test
51
+ *
52
+ * @param {Method} method enum value for GET, POST, PUT, DELETE
53
+ * @param {string} path api call path
54
+ * @param {object?} data post data
55
+ * @param {Map?} headers map of headers to add to request
56
+ * @returns {void}
57
+ */
58
+ test(method, path, data, headers) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ let res;
61
+ let reqHeaders = {};
62
+ if (headers && headers.size > 0) {
63
+ headers.forEach((value, name) => {
64
+ reqHeaders = Object.assign(Object.assign({}, headers), { [name]: value });
65
+ });
66
+ this.log("Request Headers: ", reqHeaders);
67
+ }
68
+ switch (method) {
69
+ case "GET" /* GET */:
70
+ res = yield this.app.get(path).set(reqHeaders);
71
+ break;
72
+ case "POST" /* POST */:
73
+ res = yield this.app.post(path).send(data).set(reqHeaders);
74
+ break;
75
+ case "PATCH" /* PATCH */:
76
+ res = yield this.app.patch(path).send(data).set(reqHeaders);
77
+ break;
78
+ case "PUT" /* PUT */:
79
+ res = yield this.app.put(path).send(data).set(reqHeaders);
80
+ break;
81
+ case "DELETE" /* DELETE */:
82
+ res = yield this.app.delete(path).send(data).set(reqHeaders);
83
+ break;
84
+ default:
85
+ break;
86
+ }
87
+ return res;
88
+ });
89
+ }
90
+ }
91
+ exports.TestFactory = TestFactory;
92
+ //# sourceMappingURL=test-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-factory.js","sourceRoot":"","sources":["../../../endpoint-test-factory/_/test-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,0DAAgC;AAKhC;;GAEG;AACH,MAAa,WAAW;IAIpB;;;;;OAKG;IACH,YAAY,GAAwB,EAAE,KAAe;QACjD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAE,KAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,IAAY,GAAG;QACX,OAAO,IAAA,mBAAO,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,GAAG,GAAU;QACpB,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACpB;IACL,CAAC;IAED;;;;;;;;OAQG;IACU,IAAI,CAAC,MAAc,EAAE,IAAY,EAAE,IAAa,EAAE,OAA6B;;YACxF,IAAI,GAAa,CAAC;YAElB,IAAI,UAAU,G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./_/test-factory";
2
+ export { TestFactory };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestFactory = void 0;
4
+ const test_factory_1 = require("./_/test-factory");
5
+ Object.defineProperty(exports, "TestFactory", { enumerable: true, get: function () { return test_factory_1.TestFactory; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../endpoint-test-factory/index.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAEtC,4FAFA,0BAAW,OAEA"}