@creator.co/wapi 1.2.2 → 1.2.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 (135) hide show
  1. package/.eslintrc.cjs +29 -22
  2. package/.github/workflows/npmpublish.yml +2 -5
  3. package/.github/workflows/prs.yml +1 -1
  4. package/README.md +1 -3
  5. package/dist/index.d.ts +11 -0
  6. package/dist/index.js +24 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/jest.config.d.ts +3 -0
  9. package/dist/jest.config.js +34 -0
  10. package/dist/jest.config.js.map +1 -0
  11. package/dist/package.json +64 -0
  12. package/dist/src/API/Request.d.ts +140 -0
  13. package/dist/src/API/Request.js +182 -0
  14. package/dist/src/API/Request.js.map +1 -0
  15. package/dist/src/API/Response.d.ts +256 -0
  16. package/dist/src/API/Response.js +398 -0
  17. package/dist/src/API/Response.js.map +1 -0
  18. package/dist/src/API/Utils.d.ts +63 -0
  19. package/dist/src/API/Utils.js +104 -0
  20. package/dist/src/API/Utils.js.map +1 -0
  21. package/dist/src/BaseEvent/EventProcessor.d.ts +81 -0
  22. package/dist/src/BaseEvent/EventProcessor.js +182 -0
  23. package/dist/src/BaseEvent/EventProcessor.js.map +1 -0
  24. package/dist/src/BaseEvent/Process.d.ts +74 -0
  25. package/dist/src/BaseEvent/Process.js +142 -0
  26. package/dist/src/BaseEvent/Process.js.map +1 -0
  27. package/dist/src/BaseEvent/Transaction.d.ts +29 -0
  28. package/dist/src/BaseEvent/Transaction.js +244 -0
  29. package/dist/src/BaseEvent/Transaction.js.map +1 -0
  30. package/dist/src/Config/Configuration.d.ts +131 -0
  31. package/dist/src/Config/Configuration.js +153 -0
  32. package/dist/src/Config/Configuration.js.map +1 -0
  33. package/dist/src/Config/EnvironmentVar.d.ts +101 -0
  34. package/dist/src/Config/EnvironmentVar.js +213 -0
  35. package/dist/src/Config/EnvironmentVar.js.map +1 -0
  36. package/dist/src/Crypto/Crypto.d.ts +57 -0
  37. package/dist/src/Crypto/Crypto.js +126 -0
  38. package/dist/src/Crypto/Crypto.js.map +1 -0
  39. package/dist/src/Crypto/JWT.d.ts +64 -0
  40. package/dist/src/Crypto/JWT.js +74 -0
  41. package/dist/src/Crypto/JWT.js.map +1 -0
  42. package/dist/src/Globals.d.ts +161 -0
  43. package/dist/src/Globals.js +173 -0
  44. package/dist/src/Globals.js.map +1 -0
  45. package/dist/src/Logger/Logger.d.ts +180 -0
  46. package/dist/src/Logger/Logger.js +412 -0
  47. package/dist/src/Logger/Logger.js.map +1 -0
  48. package/dist/src/Mailer/Mailer.d.ts +107 -0
  49. package/dist/src/Mailer/Mailer.js +313 -0
  50. package/dist/src/Mailer/Mailer.js.map +1 -0
  51. package/dist/src/Publisher/Publisher.d.ts +47 -0
  52. package/dist/src/Publisher/Publisher.js +141 -0
  53. package/dist/src/Publisher/Publisher.js.map +1 -0
  54. package/dist/src/Server/RouteResolver.d.ts +41 -0
  55. package/dist/src/Server/RouteResolver.js +135 -0
  56. package/dist/src/Server/RouteResolver.js.map +1 -0
  57. package/dist/src/Server/Router.d.ts +104 -0
  58. package/dist/src/Server/Router.js +45 -0
  59. package/dist/src/Server/Router.js.map +1 -0
  60. package/dist/src/Server/lib/ContainerServer.d.ts +58 -0
  61. package/dist/src/Server/lib/ContainerServer.js +143 -0
  62. package/dist/src/Server/lib/ContainerServer.js.map +1 -0
  63. package/dist/src/Server/lib/Server.d.ts +60 -0
  64. package/dist/src/Server/lib/Server.js +137 -0
  65. package/dist/src/Server/lib/Server.js.map +1 -0
  66. package/dist/src/Server/lib/container/GenericHandler.d.ts +4 -0
  67. package/dist/src/Server/lib/container/GenericHandler.js +138 -0
  68. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -0
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +67 -0
  70. package/dist/src/Server/lib/container/GenericHandlerEvent.js +189 -0
  71. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -0
  72. package/dist/src/Server/lib/container/HealthHandler.d.ts +3 -0
  73. package/dist/src/Server/lib/container/HealthHandler.js +45 -0
  74. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -0
  75. package/dist/src/Server/lib/container/Proxy.d.ts +95 -0
  76. package/dist/src/Server/lib/container/Proxy.js +201 -0
  77. package/dist/src/Server/lib/container/Proxy.js.map +1 -0
  78. package/dist/src/Server/lib/container/Utils.d.ts +18 -0
  79. package/dist/src/Server/lib/container/Utils.js +84 -0
  80. package/dist/src/Server/lib/container/Utils.js.map +1 -0
  81. package/dist/src/Validation/Validator.d.ts +21 -0
  82. package/dist/src/Validation/Validator.js +48 -0
  83. package/dist/src/Validation/Validator.js.map +1 -0
  84. package/index.ts +12 -10
  85. package/jest.config.ts +14 -21
  86. package/package.json +3 -3
  87. package/src/API/Request.ts +17 -35
  88. package/src/API/Response.ts +24 -42
  89. package/src/API/Utils.ts +5 -7
  90. package/src/BaseEvent/EventProcessor.ts +16 -24
  91. package/src/BaseEvent/Process.ts +7 -12
  92. package/src/BaseEvent/Transaction.ts +25 -43
  93. package/src/Config/Configuration.ts +8 -14
  94. package/src/Config/EnvironmentVar.ts +10 -20
  95. package/src/Crypto/Crypto.ts +10 -10
  96. package/src/Crypto/JWT.ts +4 -10
  97. package/src/Globals.ts +19 -25
  98. package/src/Logger/Logger.ts +36 -51
  99. package/src/Mailer/Mailer.ts +19 -31
  100. package/src/Publisher/Publisher.ts +7 -12
  101. package/src/Server/RouteResolver.ts +5 -6
  102. package/src/Server/Router.ts +7 -12
  103. package/src/Server/lib/ContainerServer.ts +5 -5
  104. package/src/Server/lib/Server.ts +26 -38
  105. package/src/Server/lib/container/GenericHandler.ts +8 -13
  106. package/src/Server/lib/container/GenericHandlerEvent.ts +21 -35
  107. package/src/Server/lib/container/HealthHandler.ts +2 -2
  108. package/src/Server/lib/container/Proxy.ts +26 -38
  109. package/src/Server/lib/container/Utils.ts +2 -2
  110. package/src/Validation/Validator.ts +6 -6
  111. package/tests/API/Request.test.ts +107 -111
  112. package/tests/API/Response.test.ts +86 -91
  113. package/tests/API/Utils.test.ts +64 -64
  114. package/tests/BaseEvent/EventProcessor.test.ts +68 -84
  115. package/tests/BaseEvent/Process.test.ts +11 -11
  116. package/tests/BaseEvent/Transaction.test.ts +44 -53
  117. package/tests/Config/Config.test.ts +50 -50
  118. package/tests/Config/EnvironmentVar.test.ts +50 -59
  119. package/tests/Crypto/Crypto.test.ts +20 -22
  120. package/tests/Crypto/JWT.test.ts +40 -40
  121. package/tests/Logger/Logger.test.ts +24 -36
  122. package/tests/Mailer/Mailer.test.ts +21 -29
  123. package/tests/Publisher/Publisher.test.ts +18 -18
  124. package/tests/Server/RouteResolver.test.ts +56 -59
  125. package/tests/Server/Router.test.ts +16 -16
  126. package/tests/Server/lib/ContainerServer.test.ts +83 -85
  127. package/tests/Server/lib/Server.test.ts +4 -4
  128. package/tests/Server/lib/container/GenericHandler.test.ts +31 -41
  129. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +35 -36
  130. package/tests/Server/lib/container/HealthHandler.test.ts +7 -7
  131. package/tests/Server/lib/container/Proxy.test.ts +66 -79
  132. package/tests/Server/lib/container/Utils.test.ts +16 -17
  133. package/tests/Test.utils.ts +9 -9
  134. package/tests/Validation/Validator.test.ts +28 -40
  135. package/tests/main.test.ts +2 -2
@@ -0,0 +1,29 @@
1
+ import type { APIGatewayEvent, Context, SQSEvent } from 'aws-lambda';
2
+ import Request from '../API/Request';
3
+ import Response, { ResponseErrorType } from '../API/Response';
4
+ import Logger, { LoggerConfig } from '../Logger/Logger';
5
+ import Publisher, { PublisherConfig } from '../Publisher/Publisher';
6
+ export type TransactionExecution<TransactionType, ResponseInnerType, MiscRespType = null> = (transaction: TransactionType) => Promise<Response<ResponseInnerType> | Response<ResponseErrorType> | MiscRespType>;
7
+ export type TransactionConfig = {
8
+ throwOnErrors?: boolean;
9
+ syncReturn?: boolean;
10
+ logger?: LoggerConfig;
11
+ publisher?: PublisherConfig;
12
+ };
13
+ export default class Transaction<InputType = object, ResponseInnerType = null, MiscRespType = null> {
14
+ private event;
15
+ private context;
16
+ private response;
17
+ private syncReturn;
18
+ private retrowErrors;
19
+ readonly logger: Logger;
20
+ readonly request: Request<InputType>;
21
+ readonly publisher: Publisher;
22
+ responseProxy: (response: Response<ResponseInnerType>) => Promise<void>;
23
+ constructor(event: APIGatewayEvent | SQSEvent, context: Context, config?: TransactionConfig);
24
+ execute(executionFunc: TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>): Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType>;
25
+ private iexecute;
26
+ private executeDBTransactions;
27
+ private executeLoggerFlush;
28
+ private getErrorResponse;
29
+ }
@@ -0,0 +1,244 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var Request_1 = require("../API/Request");
40
+ var Response_1 = require("../API/Response");
41
+ var Globals_1 = require("../Globals");
42
+ var Logger_1 = require("../Logger/Logger");
43
+ var Publisher_1 = require("../Publisher/Publisher");
44
+ var Transaction = /** @class */ (function () {
45
+ //
46
+ function Transaction(event, context, config) {
47
+ var transactionId = context.awsRequestId
48
+ ? context.awsRequestId
49
+ : event.requestContext
50
+ ? event.requestContext.requestId
51
+ : 'unknown';
52
+ // transaction ctx
53
+ this.event = event;
54
+ this.context = context;
55
+ this.response = null;
56
+ // when set, this will be called with the response context right before calling the context suceed/fail - useful for writing the resp for example.
57
+ this.responseProxy = null;
58
+ // transaction flags
59
+ this.syncReturn = !!(config === null || config === void 0 ? void 0 : config.syncReturn);
60
+ this.retrowErrors = !!(config === null || config === void 0 ? void 0 : config.throwOnErrors); /* retrow internal errors */
61
+ // components
62
+ this.logger = new Logger_1.default(config === null || config === void 0 ? void 0 : config.logger, transactionId);
63
+ this.request = new Request_1.default(this.event, this.context, this.logger);
64
+ this.publisher = new Publisher_1.default(config === null || config === void 0 ? void 0 : config.publisher);
65
+ }
66
+ //Main interface
67
+ Transaction.prototype.execute = function (executionFunc) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ var _this = this;
70
+ return __generator(this, function (_a) {
71
+ switch (_a.label) {
72
+ case 0: return [4 /*yield*/, this.executeLoggerFlush(function () { return __awaiter(_this, void 0, void 0, function () {
73
+ var _this = this;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0: return [4 /*yield*/, this.executeDBTransactions(function () { return __awaiter(_this, void 0, void 0, function () {
77
+ return __generator(this, function (_a) {
78
+ switch (_a.label) {
79
+ case 0: return [4 /*yield*/, this.iexecute(executionFunc)];
80
+ case 1: return [2 /*return*/, _a.sent()];
81
+ }
82
+ });
83
+ }); })];
84
+ case 1:
85
+ _a.sent();
86
+ return [2 /*return*/];
87
+ }
88
+ });
89
+ }); })
90
+ // return raw response if sync return is requested
91
+ ];
92
+ case 1:
93
+ _a.sent();
94
+ // return raw response if sync return is requested
95
+ if (this.syncReturn)
96
+ return [2 /*return*/, this.response
97
+ // allow request to async succeed through lambda context
98
+ ];
99
+ // allow request to async succeed through lambda context
100
+ return [2 /*return*/, null];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ //Executions
106
+ Transaction.prototype.iexecute = function (executionFunc) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var executionFailed, _a, e_1;
109
+ return __generator(this, function (_b) {
110
+ switch (_b.label) {
111
+ case 0:
112
+ executionFailed = true //failed til we say no!
113
+ ;
114
+ _b.label = 1;
115
+ case 1:
116
+ _b.trys.push([1, 8, , 10]);
117
+ //Execute
118
+ this.logger.debug('Starting main request code');
119
+ _a = this;
120
+ return [4 /*yield*/, executionFunc(this)
121
+ //Answer client
122
+ ];
123
+ case 2:
124
+ _a.response = _b.sent();
125
+ if (!(this.response && this.response instanceof Response_1.default)) return [3 /*break*/, 4];
126
+ return [4 /*yield*/, this.response.build(this.context, this, this.syncReturn)];
127
+ case 3:
128
+ _b.sent();
129
+ executionFailed = !!(this.response.getBody() && this.response.getBody()['rollback']);
130
+ return [3 /*break*/, 7];
131
+ case 4:
132
+ if (!(this.syncReturn && this.response)) return [3 /*break*/, 5];
133
+ this.logger.log('Sync return with different response object');
134
+ this.logger.debug(this.response);
135
+ executionFailed = false;
136
+ return [3 /*break*/, 7];
137
+ case 5:
138
+ this.response = this.getErrorResponse(Globals_1.default.ErrorResponseInvalidServerResponse, Globals_1.default.ErrorCode_APIError);
139
+ return [4 /*yield*/, this.response.build(this.context, this, this.syncReturn)];
140
+ case 6:
141
+ _b.sent();
142
+ this.logger.error('Invalid response object from main request code.');
143
+ _b.label = 7;
144
+ case 7: return [3 /*break*/, 10];
145
+ case 8:
146
+ e_1 = _b.sent();
147
+ /*EXECUTION FAIL*/
148
+ this.logger.error('Exception when executing main request code.');
149
+ this.logger.exception(e_1);
150
+ //retrow?
151
+ if (this.retrowErrors)
152
+ throw e_1;
153
+ //envelope exception?
154
+ this.response = this.getErrorResponse(Globals_1.default.ErrorResponseUnhandledError, Globals_1.default.ErrorCode_APIError);
155
+ return [4 /*yield*/, this.response.build(this.context, this, this.syncReturn)];
156
+ case 9:
157
+ _b.sent();
158
+ return [3 /*break*/, 10];
159
+ case 10: return [2 /*return*/, executionFailed];
160
+ }
161
+ });
162
+ });
163
+ };
164
+ Transaction.prototype.executeDBTransactions = function (safeExecution) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var e_2;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0:
170
+ _a.trys.push([0, 2, , 3]);
171
+ // //start DB
172
+ // if (this.db) await this.db.connect();
173
+ // //start transaction
174
+ // if (this.db) await this.db.beginTransaction();
175
+ // //
176
+ // let executionFailed =
177
+ return [4 /*yield*/, safeExecution()
178
+ // //Commit if not failed, rollback if failed
179
+ // if (!executionFailed) {
180
+ // if (this.db) await this.db.commit();
181
+ // } else {
182
+ // this.logger.log("Rolling back DB transactions. Main code failed!");
183
+ // if (this.db) await this.db.rollback();
184
+ // }
185
+ // //Cleanup DB after execution
186
+ // if (this.db) await this.db.cleanup();
187
+ ];
188
+ case 1:
189
+ // //start DB
190
+ // if (this.db) await this.db.connect();
191
+ // //start transaction
192
+ // if (this.db) await this.db.beginTransaction();
193
+ // //
194
+ // let executionFailed =
195
+ _a.sent();
196
+ return [3 /*break*/, 3];
197
+ case 2:
198
+ e_2 = _a.sent();
199
+ this.logger.error('Exception when executing DB transactions.');
200
+ this.logger.log(e_2.stack);
201
+ //retrow?
202
+ if (this.retrowErrors)
203
+ throw e_2;
204
+ return [3 /*break*/, 3];
205
+ case 3: return [2 /*return*/];
206
+ }
207
+ });
208
+ });
209
+ };
210
+ Transaction.prototype.executeLoggerFlush = function (safeExecution) {
211
+ return __awaiter(this, void 0, void 0, function () {
212
+ var e_3;
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0:
216
+ _a.trys.push([0, 2, 3, 4]);
217
+ return [4 /*yield*/, safeExecution()];
218
+ case 1:
219
+ _a.sent();
220
+ return [3 /*break*/, 4];
221
+ case 2:
222
+ e_3 = _a.sent();
223
+ this.logger.error('Exception when flushing logs.');
224
+ this.logger.exception(e_3);
225
+ //retrow?
226
+ if (this.retrowErrors)
227
+ throw e_3;
228
+ return [3 /*break*/, 4];
229
+ case 3:
230
+ this.logger.debug('Transaction ended');
231
+ return [7 /*endfinally*/];
232
+ case 4: return [2 /*return*/];
233
+ }
234
+ });
235
+ });
236
+ };
237
+ /* Response support */
238
+ Transaction.prototype.getErrorResponse = function (error, code) {
239
+ return Response_1.default.BadRequestResponseWithRollback(error, code);
240
+ };
241
+ return Transaction;
242
+ }());
243
+ exports.default = Transaction;
244
+ //# sourceMappingURL=Transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/BaseEvent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CAAyC;4BACzC,WAAW;4BACX,wEAAwE;4BACxE,2CAA2C;4BAC3C,IAAI;4BACJ,+BAA+B;4BAC/B,wCAAwC;0BATnB;;wBANrB,aAAa;wBACb,wCAAwC;wBACxC,sBAAsB;wBACtB,iDAAiD;wBACjD,KAAK;wBACL,wBAAwB;wBACxB,SAAqB,CAAA;;;;wBAWrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;wBAC9D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAC,CAAC,KAAK,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;;;;KAEjC;IACa,wCAAkB,GAAhC,UAAiC,aAAa;;;;;;;wBAE1C,qBAAM,aAAa,EAAE,EAAA;;wBAArB,SAAqB,CAAA;;;;wBAErB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;wBAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAC,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;wBAE9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;;;;;;KAEzC;IACD,sBAAsB;IACd,sCAAgB,GAAxB,UAAyB,KAAa,EAAE,IAAY;QAClD,OAAO,kBAAQ,CAAC,8BAA8B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC7D,CAAC;IACH,kBAAC;AAAD,CAAC,AA7ID,IA6IC"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * ${1:Description placeholder}
3
+ *
4
+ * @export
5
+ * @typedef {ConfigurationSchema}
6
+ */
7
+ export type ConfigurationSchema = {
8
+ [name: string]: {
9
+ isLocal?: boolean;
10
+ isRemote?: boolean;
11
+ required?: boolean;
12
+ cachingPolicy?: string;
13
+ };
14
+ };
15
+ /**
16
+ * ${1:Description placeholder}
17
+ *
18
+ * @typedef {ExtractRemote}
19
+ * @template Type
20
+ */
21
+ type ExtractRemote<Type> = {
22
+ [Property in keyof Type]-?: Type[Property] extends {
23
+ isRemote: true;
24
+ } ? Property : null;
25
+ };
26
+ /**
27
+ * ${1:Description placeholder}
28
+ *
29
+ * @typedef {ExtractLocal}
30
+ * @template Type
31
+ */
32
+ type ExtractLocal<Type> = {
33
+ [Property in keyof Type]-?: Type[Property] extends {
34
+ isLocal: true;
35
+ } ? Property : null;
36
+ };
37
+ /**
38
+ * ${1:Description placeholder}
39
+ *
40
+ * @typedef {OmitKeysByValueType}
41
+ * @template T
42
+ * @template U
43
+ */
44
+ type OmitKeysByValueType<T, U> = {
45
+ [P in keyof T]: T[P] extends U ? never : P;
46
+ }[keyof T];
47
+ /**
48
+ * ${1:Description placeholder}
49
+ *
50
+ * @typedef {OmitByValueType}
51
+ * @template T
52
+ * @template V
53
+ */
54
+ type OmitByValueType<T, V> = T extends infer _ ? {
55
+ [key in OmitKeysByValueType<T, V>]: T[key];
56
+ } : never;
57
+ /**
58
+ * ${1:Description placeholder}
59
+ *
60
+ * @export
61
+ * @class Configuration
62
+ * @typedef {Configuration}
63
+ * @template {ConfigurationSchema} T
64
+ */
65
+ export default class Configuration<T extends ConfigurationSchema> {
66
+ /**
67
+ * ${1:Description placeholder}
68
+ *
69
+ * @private
70
+ * @readonly
71
+ * @type {T}
72
+ */
73
+ private readonly schema;
74
+ /**
75
+ * ${1:Description placeholder}
76
+ *
77
+ * @private
78
+ * @readonly
79
+ * @type {string}
80
+ */
81
+ private readonly remotePrefix;
82
+ /**
83
+ * Creates an instance of Configuration.
84
+ *
85
+ * @constructor
86
+ * @param {T} schema
87
+ * @param {string} remotePrefix
88
+ */
89
+ constructor(schema: T, remotePrefix: string);
90
+ /**
91
+ * ${1:Description placeholder}
92
+ *
93
+ * @public
94
+ * @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName
95
+ * @returns {*}
96
+ */
97
+ get(propName: keyof OmitByValueType<ExtractLocal<T>, null>): any;
98
+ /**
99
+ * ${1:Description placeholder}
100
+ *
101
+ * @public
102
+ * @async
103
+ * @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName
104
+ * @returns {Promise<any>}
105
+ */
106
+ asyncGet(propName: keyof OmitByValueType<ExtractRemote<T>, null>): Promise<any>;
107
+ /**
108
+ * ${1:Description placeholder}
109
+ *
110
+ * @private
111
+ * @param {string} valueKey
112
+ * @returns {*}
113
+ */
114
+ private getCachedValue;
115
+ /**
116
+ * ${1:Description placeholder}
117
+ *
118
+ * @private
119
+ * @param {string} valueKey
120
+ * @param {*} value
121
+ * @param {string} [policy="1d"]
122
+ */
123
+ private cacheValue;
124
+ /**
125
+ * ${1:Description placeholder}
126
+ *
127
+ * @private
128
+ */
129
+ private resetCache;
130
+ }
131
+ export {};
@@ -0,0 +1,153 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var MemCache = require("node-cache");
40
+ var DurationParser = require("parse-duration");
41
+ var EnvironmentVar_1 = require("./EnvironmentVar");
42
+ // Hold cached values at nodeVM level
43
+ // eslint-disable-next-line no-var
44
+ /**
45
+ * ${1:Description placeholder}
46
+ *
47
+ * @type {*}
48
+ */
49
+ var cacheStore = new MemCache();
50
+ /**
51
+ * ${1:Description placeholder}
52
+ *
53
+ * @export
54
+ * @class Configuration
55
+ * @typedef {Configuration}
56
+ * @template {ConfigurationSchema} T
57
+ */
58
+ var Configuration = /** @class */ (function () {
59
+ /**
60
+ * Creates an instance of Configuration.
61
+ *
62
+ * @constructor
63
+ * @param {T} schema
64
+ * @param {string} remotePrefix
65
+ */
66
+ function Configuration(schema, remotePrefix) {
67
+ this.schema = schema;
68
+ this.remotePrefix = remotePrefix;
69
+ }
70
+ /**
71
+ * ${1:Description placeholder}
72
+ *
73
+ * @public
74
+ * @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName
75
+ * @returns {*}
76
+ */
77
+ Configuration.prototype.get = function (propName) {
78
+ var propString = propName;
79
+ var propSchema = this.schema[propString];
80
+ var v = this.getCachedValue(propString);
81
+ v =
82
+ v ||
83
+ new EnvironmentVar_1.default(propString, EnvironmentVar_1.EnvironmentType.Local, !propSchema.required, this.remotePrefix).syncResolve();
84
+ this.cacheValue(propString, v, propSchema.cachingPolicy);
85
+ return v;
86
+ };
87
+ /**
88
+ * ${1:Description placeholder}
89
+ *
90
+ * @public
91
+ * @async
92
+ * @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName
93
+ * @returns {Promise<any>}
94
+ */
95
+ Configuration.prototype.asyncGet = function (propName) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ var propString, propSchema, v, _a;
98
+ return __generator(this, function (_b) {
99
+ switch (_b.label) {
100
+ case 0:
101
+ propString = propName;
102
+ propSchema = this.schema[propString];
103
+ v = this.getCachedValue(propString);
104
+ _a = v;
105
+ if (_a) return [3 /*break*/, 2];
106
+ return [4 /*yield*/, new EnvironmentVar_1.default(propString, EnvironmentVar_1.EnvironmentType.PlainRemote, !propSchema.required, this.remotePrefix).resolve()];
107
+ case 1:
108
+ _a = (_b.sent());
109
+ _b.label = 2;
110
+ case 2:
111
+ v = _a;
112
+ this.cacheValue(propString, v, propSchema.cachingPolicy);
113
+ return [2 /*return*/, v];
114
+ }
115
+ });
116
+ });
117
+ };
118
+ // caching layer
119
+ /**
120
+ * ${1:Description placeholder}
121
+ *
122
+ * @private
123
+ * @param {string} valueKey
124
+ * @returns {*}
125
+ */
126
+ Configuration.prototype.getCachedValue = function (valueKey) {
127
+ return cacheStore.get(valueKey);
128
+ };
129
+ /**
130
+ * ${1:Description placeholder}
131
+ *
132
+ * @private
133
+ * @param {string} valueKey
134
+ * @param {*} value
135
+ * @param {string} [policy="1d"]
136
+ */
137
+ Configuration.prototype.cacheValue = function (valueKey, value, policy) {
138
+ if (policy === void 0) { policy = '1d'; }
139
+ cacheStore.set(valueKey, value, DurationParser(policy, 's'));
140
+ };
141
+ // unit-test support
142
+ /**
143
+ * ${1:Description placeholder}
144
+ *
145
+ * @private
146
+ */
147
+ Configuration.prototype.resetCache = function () {
148
+ cacheStore = new MemCache();
149
+ };
150
+ return Configuration;
151
+ }());
152
+ exports.default = Configuration;
153
+ //# sourceMappingURL=Configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/Config/Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAsC;AACtC,+CAAgD;AAEhD,mDAAkE;AAElE,qCAAqC;AACrC,kCAAkC;AAClC;;;;GAIG;AACH,IAAI,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAA;AAwE/B;;;;;;;GAOG;AACH;IAiBE;;;;;;OAMG;IACH,uBAAY,MAAS,EAAE,YAAoB;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;OAMG;IACI,2BAAG,GAAV,UAAW,QAAsD;QAC/D,IAAM,UAAU,GAAG,QAAkB,CAAA;QACrC,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAC1C,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;QACvC,CAAC;YACC,CAAC;gBACD,IAAI,wBAAc,CAChB,UAAU,EACV,gCAAe,CAAC,KAAK,EACrB,CAAC,UAAU,CAAC,QAAQ,EACpB,IAAI,CAAC,YAAY,CAClB,CAAC,WAAW,EAAE,CAAA;QACjB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,aAAa,CA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entType {
8
+ PlainRemote = 0,
9
+ SecureRemote = 1,
10
+ Local = 2
11
+ }
12
+ /**
13
+ * ${1:Description placeholder}
14
+ *
15
+ * @export
16
+ * @class EnvironmentVar
17
+ * @typedef {EnvironmentVar}
18
+ * @template T
19
+ */
20
+ export default class EnvironmentVar<T> {
21
+ /**
22
+ * ${1:Description placeholder}
23
+ *
24
+ * @private
25
+ * @readonly
26
+ * @type {string}
27
+ */
28
+ private readonly paramName;
29
+ /**
30
+ * ${1:Description placeholder}
31
+ *
32
+ * @private
33
+ * @readonly
34
+ * @type {EnvironmentType}
35
+ */
36
+ private readonly type;
37
+ /**
38
+ * ${1:Description placeholder}
39
+ *
40
+ * @private
41
+ * @readonly
42
+ * @type {boolean}
43
+ */
44
+ private readonly optional;
45
+ /**
46
+ * ${1:Description placeholder}
47
+ *
48
+ * @private
49
+ * @readonly
50
+ * @type {string}
51
+ */
52
+ private readonly paramPrefix;
53
+ /**
54
+ * Creates an instance of EnvironmentVar.
55
+ *
56
+ * @constructor
57
+ * @param {string} paramName
58
+ * @param {EnvironmentType} type
59
+ * @param {?boolean} [optional]
60
+ * @param {string} [paramPrefix=`/creatorco-api-\${process.env.STAGE\}/env/`]
61
+ */
62
+ constructor(paramName: string, type: EnvironmentType, optional?: boolean, paramPrefix?: string);
63
+ /**
64
+ * ${1:Description placeholder}
65
+ *
66
+ * @public
67
+ * @returns {T}
68
+ */
69
+ syncResolve(): T;
70
+ /**
71
+ * ${1:Description placeholder}
72
+ *
73
+ * @public
74
+ * @async
75
+ * @returns {unknown}
76
+ */
77
+ resolve(): Promise<T>;
78
+ /**
79
+ * ${1:Description placeholder}
80
+ *
81
+ * @private
82
+ * @returns {T}
83
+ */
84
+ private getLocalValue;
85
+ /**
86
+ * ${1:Description placeholder}
87
+ *
88
+ * @private
89
+ * @async
90
+ * @returns {Promise<T>}
91
+ */
92
+ private getPlainValue;
93
+ /**
94
+ * ${1:Description placeholder}
95
+ *
96
+ * @private
97
+ * @async
98
+ * @returns {Promise<T>}
99
+ */
100
+ private getSecureValue;
101
+ }