totoms 1.0.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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +413 -0
  3. package/dist/api/TotoAPIController.d.ts +30 -0
  4. package/dist/api/TotoAPIController.d.ts.map +1 -0
  5. package/dist/api/TotoAPIController.js +226 -0
  6. package/dist/api/TotoAPIController.js.map +1 -0
  7. package/dist/auth/TotoToken.d.ts +3 -0
  8. package/dist/auth/TotoToken.d.ts.map +1 -0
  9. package/dist/auth/TotoToken.js +8 -0
  10. package/dist/auth/TotoToken.js.map +1 -0
  11. package/dist/core/TotoMicroservice.d.ts +27 -0
  12. package/dist/core/TotoMicroservice.d.ts.map +1 -0
  13. package/dist/core/TotoMicroservice.js +52 -0
  14. package/dist/core/TotoMicroservice.js.map +1 -0
  15. package/dist/dlg/SmokeDelegate.d.ts +12 -0
  16. package/dist/dlg/SmokeDelegate.d.ts.map +1 -0
  17. package/dist/dlg/SmokeDelegate.js +10 -0
  18. package/dist/dlg/SmokeDelegate.js.map +1 -0
  19. package/dist/evt/IMessageBus.d.ts +35 -0
  20. package/dist/evt/IMessageBus.d.ts.map +1 -0
  21. package/dist/evt/IMessageBus.js +21 -0
  22. package/dist/evt/IMessageBus.js.map +1 -0
  23. package/dist/evt/MessageBus.d.ts +37 -0
  24. package/dist/evt/MessageBus.d.ts.map +1 -0
  25. package/dist/evt/MessageBus.js +81 -0
  26. package/dist/evt/MessageBus.js.map +1 -0
  27. package/dist/evt/TotoMessage.d.ts +9 -0
  28. package/dist/evt/TotoMessage.d.ts.map +1 -0
  29. package/dist/evt/TotoMessage.js +2 -0
  30. package/dist/evt/TotoMessage.js.map +1 -0
  31. package/dist/evt/TotoMessageHandler.d.ts +16 -0
  32. package/dist/evt/TotoMessageHandler.d.ts.map +1 -0
  33. package/dist/evt/TotoMessageHandler.js +14 -0
  34. package/dist/evt/TotoMessageHandler.js.map +1 -0
  35. package/dist/evt/impl/aws/SNSImpl.d.ts +24 -0
  36. package/dist/evt/impl/aws/SNSImpl.d.ts.map +1 -0
  37. package/dist/evt/impl/aws/SNSImpl.js +201 -0
  38. package/dist/evt/impl/aws/SNSImpl.js.map +1 -0
  39. package/dist/evt/impl/aws/SQSImpl.d.ts +19 -0
  40. package/dist/evt/impl/aws/SQSImpl.d.ts.map +1 -0
  41. package/dist/evt/impl/aws/SQSImpl.js +96 -0
  42. package/dist/evt/impl/aws/SQSImpl.js.map +1 -0
  43. package/dist/evt/impl/gcp/GCPPubSubImpl.d.ts +22 -0
  44. package/dist/evt/impl/gcp/GCPPubSubImpl.d.ts.map +1 -0
  45. package/dist/evt/impl/gcp/GCPPubSubImpl.js +93 -0
  46. package/dist/evt/impl/gcp/GCPPubSubImpl.js.map +1 -0
  47. package/dist/index.d.ts +25 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +20 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/integration/RegistryCache.d.ts +24 -0
  52. package/dist/integration/RegistryCache.d.ts.map +1 -0
  53. package/dist/integration/RegistryCache.js +74 -0
  54. package/dist/integration/RegistryCache.js.map +1 -0
  55. package/dist/integration/TotoAPI.d.ts +22 -0
  56. package/dist/integration/TotoAPI.d.ts.map +1 -0
  57. package/dist/integration/TotoAPI.js +84 -0
  58. package/dist/integration/TotoAPI.js.map +1 -0
  59. package/dist/integration/TotoRegistryAPI.d.ts +26 -0
  60. package/dist/integration/TotoRegistryAPI.d.ts.map +1 -0
  61. package/dist/integration/TotoRegistryAPI.js +67 -0
  62. package/dist/integration/TotoRegistryAPI.js.map +1 -0
  63. package/dist/logger/TotoLogger.d.ts +13 -0
  64. package/dist/logger/TotoLogger.d.ts.map +1 -0
  65. package/dist/logger/TotoLogger.js +48 -0
  66. package/dist/logger/TotoLogger.js.map +1 -0
  67. package/dist/model/APIConfiguration.d.ts +17 -0
  68. package/dist/model/APIConfiguration.d.ts.map +1 -0
  69. package/dist/model/APIConfiguration.js +2 -0
  70. package/dist/model/APIConfiguration.js.map +1 -0
  71. package/dist/model/AuthProviders.d.ts +5 -0
  72. package/dist/model/AuthProviders.d.ts.map +1 -0
  73. package/dist/model/AuthProviders.js +5 -0
  74. package/dist/model/AuthProviders.js.map +1 -0
  75. package/dist/model/TotoControllerConfig.d.ts +29 -0
  76. package/dist/model/TotoControllerConfig.d.ts.map +1 -0
  77. package/dist/model/TotoControllerConfig.js +77 -0
  78. package/dist/model/TotoControllerConfig.js.map +1 -0
  79. package/dist/model/TotoDelegate.d.ts +19 -0
  80. package/dist/model/TotoDelegate.d.ts.map +1 -0
  81. package/dist/model/TotoDelegate.js +12 -0
  82. package/dist/model/TotoDelegate.js.map +1 -0
  83. package/dist/model/TotoEnvironment.d.ts +16 -0
  84. package/dist/model/TotoEnvironment.d.ts.map +1 -0
  85. package/dist/model/TotoEnvironment.js +2 -0
  86. package/dist/model/TotoEnvironment.js.map +1 -0
  87. package/dist/model/TotoPathOptions.d.ts +6 -0
  88. package/dist/model/TotoPathOptions.d.ts.map +1 -0
  89. package/dist/model/TotoPathOptions.js +2 -0
  90. package/dist/model/TotoPathOptions.js.map +1 -0
  91. package/dist/model/TotoRuntimeError.d.ts +7 -0
  92. package/dist/model/TotoRuntimeError.d.ts.map +1 -0
  93. package/dist/model/TotoRuntimeError.js +9 -0
  94. package/dist/model/TotoRuntimeError.js.map +1 -0
  95. package/dist/model/UserContext.d.ts +6 -0
  96. package/dist/model/UserContext.d.ts.map +1 -0
  97. package/dist/model/UserContext.js +2 -0
  98. package/dist/model/UserContext.js.map +1 -0
  99. package/dist/util/CorrelationId.d.ts +2 -0
  100. package/dist/util/CorrelationId.d.ts.map +1 -0
  101. package/dist/util/CorrelationId.js +7 -0
  102. package/dist/util/CorrelationId.js.map +1 -0
  103. package/dist/util/CrossCloudSecret.d.ts +10 -0
  104. package/dist/util/CrossCloudSecret.d.ts.map +1 -0
  105. package/dist/util/CrossCloudSecret.js +45 -0
  106. package/dist/util/CrossCloudSecret.js.map +1 -0
  107. package/dist/util/ErrorUtil.d.ts +3 -0
  108. package/dist/util/ErrorUtil.d.ts.map +1 -0
  109. package/dist/util/ErrorUtil.js +11 -0
  110. package/dist/util/ErrorUtil.js.map +1 -0
  111. package/dist/util/TokenUtil.d.ts +4 -0
  112. package/dist/util/TokenUtil.d.ts.map +1 -0
  113. package/dist/util/TokenUtil.js +21 -0
  114. package/dist/util/TokenUtil.js.map +1 -0
  115. package/dist/validation/GoogleAuthCheck.d.ts +7 -0
  116. package/dist/validation/GoogleAuthCheck.d.ts.map +1 -0
  117. package/dist/validation/GoogleAuthCheck.js +24 -0
  118. package/dist/validation/GoogleAuthCheck.js.map +1 -0
  119. package/dist/validation/Validator.d.ts +33 -0
  120. package/dist/validation/Validator.d.ts.map +1 -0
  121. package/dist/validation/Validator.js +111 -0
  122. package/dist/validation/Validator.js.map +1 -0
  123. package/package.json +90 -0
@@ -0,0 +1,22 @@
1
+ import { TotoControllerConfig } from "..";
2
+ export declare class TotoAPI {
3
+ protected apiName: string;
4
+ protected authToken: string;
5
+ protected config: TotoControllerConfig;
6
+ constructor(apiName: string, config: TotoControllerConfig, authToken?: string);
7
+ protected get<T>(request: TotoAPIRequest, ResponseClass: TotoAPIResponseConstructor<T>): Promise<T>;
8
+ protected post<T>(request: TotoAPIRequest, ResponseClass: TotoAPIResponseConstructor<T>): Promise<T>;
9
+ protected put<T>(request: TotoAPIRequest, ResponseClass: TotoAPIResponseConstructor<T>): Promise<T>;
10
+ protected delete<T>(request: TotoAPIRequest, ResponseClass: TotoAPIResponseConstructor<T>): Promise<T>;
11
+ private call;
12
+ }
13
+ export declare class TotoAPIRequest {
14
+ path: string;
15
+ cid: string;
16
+ body?: any;
17
+ constructor(path: string, body?: any, cid?: string);
18
+ }
19
+ export interface TotoAPIResponseConstructor<T> {
20
+ fromParsedHTTPResponseBody(body: any): T;
21
+ }
22
+ //# sourceMappingURL=TotoAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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uidv4 } from "uuid";
3
+ import { Logger, newTotoServiceToken, RegistryCache, TotoRuntimeError } from "..";
4
+ export class TotoAPI {
5
+ constructor(apiName, config, authToken) {
6
+ this.authToken = authToken || newTotoServiceToken(config);
7
+ this.apiName = apiName;
8
+ this.config = config;
9
+ }
10
+ async get(request, ResponseClass) {
11
+ return this.call("GET", request, ResponseClass);
12
+ }
13
+ async post(request, ResponseClass) {
14
+ return this.call("POST", request, ResponseClass);
15
+ }
16
+ async put(request, ResponseClass) {
17
+ return this.call("PUT", request, ResponseClass);
18
+ }
19
+ async delete(request, ResponseClass) {
20
+ return this.call("DELETE", request, ResponseClass);
21
+ }
22
+ async call(method, request, ResponseClass) {
23
+ const logger = Logger.getInstance();
24
+ const endpoint = await RegistryCache.getInstance().getEndpoint(this.apiName);
25
+ if (!endpoint || !endpoint.endpointURL) {
26
+ logger?.compute(request.cid, `TotoAPI Error: Unable to find endpoint for API [${this.apiName}]`, "error");
27
+ throw new TotoRuntimeError(500, `TotoAPI Error: Unable to find endpoint for API [${this.apiName}]`);
28
+ }
29
+ logger.compute(request.cid, `Calling ${method} ${endpoint.endpointURL}${request.path}`);
30
+ return new Promise((success, failure) => {
31
+ const req = {
32
+ uri: `${endpoint.endpointURL}${request.path}`,
33
+ method: method,
34
+ headers: {
35
+ 'x-correlation-id': request.cid,
36
+ 'Authorization': `Bearer ${this.authToken}`,
37
+ 'Content-Type': 'application/json'
38
+ },
39
+ };
40
+ if (request.body) {
41
+ req.body = JSON.stringify(request.body);
42
+ }
43
+ http(req, (err, resp, body) => {
44
+ handleResponse(err, resp, body, ResponseClass).then(success).catch(failure);
45
+ });
46
+ });
47
+ }
48
+ }
49
+ export class TotoAPIRequest {
50
+ constructor(path, body, cid) {
51
+ this.path = path;
52
+ this.cid = cid || uuidv4();
53
+ this.body = body;
54
+ if (!this.path.startsWith('/')) {
55
+ this.path = `/${this.path}`;
56
+ }
57
+ }
58
+ }
59
+ async function handleResponse(err, resp, body, ResponseClass) {
60
+ if (err) {
61
+ console.log(err);
62
+ throw new TotoRuntimeError(500, `HTTP Request Error: ${err}`);
63
+ }
64
+ try {
65
+ const parsedBody = parseBody(body);
66
+ return ResponseClass.fromParsedHTTPResponseBody(parsedBody);
67
+ }
68
+ catch (error) {
69
+ if (error instanceof TotoRuntimeError)
70
+ throw error;
71
+ console.log(body);
72
+ throw new TotoRuntimeError(500, `HTTP Response Error: ${error}`);
73
+ }
74
+ }
75
+ function parseBody(body) {
76
+ try {
77
+ return JSON.parse(body);
78
+ }
79
+ catch (error) {
80
+ console.log(body);
81
+ throw new TotoRuntimeError(500, `JSON Parse Error. Invalid Response Body: ${body}`);
82
+ }
83
+ }
84
+ //# sourceMappingURL=TotoAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoAPI.js","sourceRoot":"","sources":["../../src/integration/TotoAPI.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAwB,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAExG,MAAM,OAAO,OAAO;IAMhB,YAAY,OAAe,EAAE,MAA4B,EAAE,SAAkB;QACzE,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,GAAG,CAAI,OAAuB,EAAE,aAA4C;QACxF,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IACpD,CAAC;IAES,KAAK,CAAC,IAAI,CAAI,OAAuB,EAAE,aAA4C;QACzF,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC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AAC;IACD,OAAO,KAAK,EAAE,CAAC;QAEX,IAAI,KAAK,YAAY,gBAAgB;YAAE,MAAM,KAAK,CAAC;QAEnD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,wBAAwB,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,IAAS;IACxB,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;AACL,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { TotoControllerConfig, SupportedHyperscalers } from "..";
2
+ export declare class TotoRegistryAPI {
3
+ protected config: TotoControllerConfig;
4
+ constructor(config: TotoControllerConfig);
5
+ registerAPI(request: RegisterAPIRequest): Promise<RegisterAPIResponse>;
6
+ getAPIs(): Promise<GetAPIsResponse>;
7
+ }
8
+ export interface GetAPIsResponse {
9
+ apis: APIEndpoint[];
10
+ }
11
+ export interface APIEndpoint {
12
+ apiName: string;
13
+ endpointURL: string;
14
+ }
15
+ export interface RegisterAPIResponse {
16
+ inserted: boolean;
17
+ updated: boolean;
18
+ insertedId: string;
19
+ }
20
+ export interface RegisterAPIRequest {
21
+ apiName: string;
22
+ endpointURL?: string;
23
+ hyperscaler?: SupportedHyperscalers;
24
+ basePath?: string;
25
+ }
26
+ //# sourceMappingURL=TotoRegistryAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoRegistryAPI.d.ts","sourceRoot":"","sources":["../../src/integration/TotoRegistryAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,oBAAoB,EAAU,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAGhH,qBAAa,eAAe;IAEZ,SAAS,CAAC,MAAM,EAAE,oBAAoB;gBAA5B,MAAM,EAAE,oBAAoB;IAQ5C,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAG,mBAAmB,CAAE;IAwBzE,OAAO,IAAI,OAAO,CAAG,eAAe,CAAE;CAmB3C;AAEL,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IAE/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAErB"}
@@ -0,0 +1,67 @@
1
+ import http from "request";
2
+ import { newTotoServiceToken, TotoRuntimeError, Logger } from "..";
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ export class TotoRegistryAPI {
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ async registerAPI(request) {
9
+ const logger = Logger.getInstance();
10
+ logger.compute("", `Registering API [ ${request.apiName} ] with Toto Registry at [ ${this.config.getTotoRegistryEndpoint()} ].`, "info");
11
+ return new Promise((success, failure) => {
12
+ http({
13
+ uri: `${this.config.getTotoRegistryEndpoint()}/apis`,
14
+ method: 'POST',
15
+ headers: {
16
+ 'x-correlation-id': uuidv4(),
17
+ 'Authorization': "Bearer " + newTotoServiceToken(this.config),
18
+ 'Content-Type': 'application/json'
19
+ },
20
+ body: JSON.stringify(request)
21
+ }, (err, resp, body) => {
22
+ handleResponse(err, resp, body).then(success).catch(failure);
23
+ });
24
+ });
25
+ }
26
+ async getAPIs() {
27
+ return new Promise((success, failure) => {
28
+ http({
29
+ uri: `${this.config.getTotoRegistryEndpoint()}/apis`,
30
+ method: 'GET',
31
+ headers: {
32
+ 'x-correlation-id': uuidv4(),
33
+ 'Authorization': "Bearer " + newTotoServiceToken(this.config),
34
+ 'Content-Type': 'application/json'
35
+ }
36
+ }, (err, resp, body) => {
37
+ handleResponse(err, resp, body).then(success).catch(failure);
38
+ });
39
+ });
40
+ }
41
+ }
42
+ async function handleResponse(err, resp, body) {
43
+ if (err) {
44
+ console.log(err);
45
+ throw new TotoRuntimeError(500, `HTTP Request Error: ${err}`);
46
+ }
47
+ try {
48
+ const parsedBody = parseBody(body);
49
+ return parsedBody;
50
+ }
51
+ catch (error) {
52
+ if (error instanceof TotoRuntimeError)
53
+ throw error;
54
+ console.log(body);
55
+ throw new TotoRuntimeError(500, `HTTP Response Error: ${error}`);
56
+ }
57
+ }
58
+ function parseBody(body) {
59
+ try {
60
+ return JSON.parse(body);
61
+ }
62
+ catch (error) {
63
+ console.log(body);
64
+ throw new TotoRuntimeError(500, `JSON Parse Error. Invalid Response Body: ${body}`);
65
+ }
66
+ }
67
+ //# sourceMappingURL=TotoRegistryAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoRegistryAPI.js","sourceRoot":"","sources":["../../src/integration/TotoRegistryAPI.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAwB,MAAM,EAAyB,MAAM,IAAI,CAAC;AAChH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,OAAO,eAAe;IAExB,YAAsB,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;IAAI,CAAC;IAQvD,KAAK,CAAC,WAAW,CAAC,OAA2B;QAErC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CA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E,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACjF,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC;CAEJ;AAmCL,KAAK,UAAU,cAAc,CAAI,GAAQ,EAAE,IAAS,EAAE,IAAS;IAE3D,IAAI,GAAG,EAAE,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,uBAAuB,GAAG,EAAE,CAAC,CAAC;IAClE,CAAC;IAGD,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAEnC,OAAO,UAAe,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QAEX,IAAI,KAAK,YAAY,gBAAgB;YAAE,MAAM,KAAK,CAAC;QAEnD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,wBAAwB,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,IAAS;IACxB,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;AACL,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare class Logger {
2
+ private apiName;
3
+ private static instance;
4
+ private constructor();
5
+ static init(apiName: string): Logger;
6
+ static getInstance(): Logger;
7
+ apiIn(correlationId: string | string[] | undefined, method: string, path: string, msgId?: string): void;
8
+ apiOut(correlationId: string | string[] | undefined, api: string, method: string, path: string, msgId?: string): void;
9
+ eventIn(correlationId: string | string[] | undefined, topic: string, msgId?: string): void;
10
+ eventOut(correlationId: string | string[] | undefined, topic: string, msgId?: string): void;
11
+ compute(correlationId: string | string[] | undefined, message: string, logLevel?: string): void;
12
+ }
13
+ //# sourceMappingURL=TotoLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoLogger.d.ts","sourceRoot":"","sources":["../../src/logger/TotoLogger.ts"],"names":[],"mappings":"AAIA,qBAAa,MAAM;IAIG,OAAO,CAAC,OAAO;IAFnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAEhC,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAUpC,MAAM,CAAC,WAAW,IAAI,MAAM;IAU5B,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAWhG,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAW9G,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAWnF,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAYpF,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAYzF"}
@@ -0,0 +1,48 @@
1
+ import moment from 'moment-timezone';
2
+ import { TotoRuntimeError } from '../model/TotoRuntimeError';
3
+ export class Logger {
4
+ constructor(apiName) {
5
+ this.apiName = apiName;
6
+ }
7
+ static init(apiName) {
8
+ if (!Logger.instance) {
9
+ Logger.instance = new Logger(apiName);
10
+ }
11
+ return Logger.instance;
12
+ }
13
+ static getInstance() {
14
+ if (!Logger.instance) {
15
+ throw new TotoRuntimeError(500, "Logger instance not initialized. Call Logger.init(apiName) first.");
16
+ }
17
+ return Logger.instance;
18
+ }
19
+ apiIn(correlationId, method, path, msgId) {
20
+ let ts = moment().tz('Europe/Rome').format('YYYY-MM-DD HH:mm:ss.SSS');
21
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [api-in] - [info] - Recevied HTTP call [${method}] ${path}`);
22
+ }
23
+ apiOut(correlationId, api, method, path, msgId) {
24
+ let ts = moment().tz('Europe/Rome').format('YYYY-MM-DD HH:mm:ss.SSS');
25
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [api-out] - [info] - Executing HTTP call to api [${api}] [${method}] ${path}`);
26
+ }
27
+ eventIn(correlationId, topic, msgId) {
28
+ let ts = moment().tz('Europe/Rome').format('YYYY-MM-DD HH:mm:ss.SSS');
29
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [event-in] - [info] - Recevied event from topic [${topic}]`);
30
+ }
31
+ eventOut(correlationId, topic, msgId) {
32
+ let ts = moment().tz('Europe/Rome').format('YYYY-MM-DD HH:mm:ss.SSS');
33
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [event-out] - [info] - Publishing event to topic [${topic}]`);
34
+ }
35
+ compute(correlationId, message, logLevel) {
36
+ let ts = moment().tz('Europe/Rome').format('YYYY-MM-DD HH:mm:ss.SSS');
37
+ logLevel = logLevel ?? "info";
38
+ if (logLevel == 'info')
39
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [info] - ${message}`);
40
+ else if (logLevel == 'error')
41
+ console.error(`[${ts}] - [${correlationId}] - [${this.apiName}] - [info] - ${message}`);
42
+ else if (logLevel == 'warn')
43
+ console.warn(`[${ts}] - [${correlationId}] - [${this.apiName}] - [info] - ${message}`);
44
+ else
45
+ console.info(`[${ts}] - [${correlationId}] - [${this.apiName}] - [info] - ${message}`);
46
+ }
47
+ }
48
+ //# sourceMappingURL=TotoLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoLogger.js","sourceRoot":"","sources":["../../src/logger/TotoLogger.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,OAAO,MAAM;IAIjB,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAI,CAAC;IAKhD,MAAM,CAAC,IAAI,CAAC,OAAe;QACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IAKD,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,mEAAmE,CAAC,CAAC;QACvG,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IAKD,KAAK,CAAC,aAA4C,EAAE,MAAc,EAAE,IAAY,EAAE,KAAc;QAE9F,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;QAEtE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,aAAa,QAAQ,IAAI,CAAC,OAAO,+CAA+C,MAAM,KAAK,IAAI,EAAE,CAAC,CAAA;IAE/H,CAAC;IAKD,MAAM,CAAC,aAA4C,EAAE,GAAW,EAAE,M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YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,aAAa,QAAQ,IAAI,CAAC,OAAO,gBAAgB,OAAO,EAAE,CAAC,CAAA;aAChH,IAAI,QAAQ,IAAI,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,aAAa,QAAQ,IAAI,CAAC,OAAO,gBAAgB,OAAO,EAAE,CAAC,CAAA;;YAC9G,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,aAAa,QAAQ,IAAI,CAAC,OAAO,gBAAgB,OAAO,EAAE,CAAC,CAAA;IAE7F,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import { TotoControllerConfig, TotoDelegate, TotoMessageBus } from "..";
2
+ export interface APIConfiguration {
3
+ apiEndpoints: TotoAPIEndpoint[];
4
+ apiOptions?: APIOptions;
5
+ }
6
+ export interface TotoAPIEndpoint {
7
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
8
+ path: string;
9
+ delegate: new (messageBus: TotoMessageBus, config: TotoControllerConfig) => TotoDelegate;
10
+ }
11
+ export interface APIOptions {
12
+ noAuth?: boolean;
13
+ noCorrelationId?: boolean;
14
+ minAppVersion?: string;
15
+ customAuthProvider?: string;
16
+ }
17
+ //# sourceMappingURL=APIConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIConfiguration.d.ts","sourceRoot":"","sources":["../../src/model/APIConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAExE,MAAM,WAAW,gBAAgB;IAK7B,YAAY,EAAE,eAAe,EAAE,CAAC;IAKhC,UAAU,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAoB,KAAK,YAAY,CAAC;CAC5F;AAED,MAAM,WAAW,UAAU;IAMvB,MAAM,CAAC,EAAE,OAAO,CAAC;IAMjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAM1B,aAAa,CAAC,EAAE,MAAM,CAAC;IAMvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAG/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=APIConfiguration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIConfiguration.js","sourceRoot":"","sources":["../../src/model/APIConfiguration.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare const AUTH_PROVIDERS: {
2
+ google: string;
3
+ toto: string;
4
+ };
5
+ //# sourceMappingURL=AuthProviders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviders.d.ts","sourceRoot":"","sources":["../../src/model/AuthProviders.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc;;;CAG1B,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const AUTH_PROVIDERS = {
2
+ google: "google",
3
+ toto: "toto"
4
+ };
5
+ //# sourceMappingURL=AuthProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProviders.js","sourceRoot":"","sources":["../../src/model/AuthProviders.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACf,CAAA"}
@@ -0,0 +1,29 @@
1
+ import { Db, MongoClient } from "mongodb";
2
+ import { SecretsManager } from "..";
3
+ import { APIOptions } from "./APIConfiguration";
4
+ export declare abstract class TotoControllerConfig {
5
+ protected mongoHost: string | undefined;
6
+ protected mongoUser: string | undefined;
7
+ protected mongoPwd: string | undefined;
8
+ protected jwtSigningKey: string | undefined;
9
+ protected expectedAudience: string | undefined;
10
+ protected secretsManager: SecretsManager;
11
+ totoRegistryEndpoint: string | undefined;
12
+ private static mongoClient;
13
+ private static mongoClientPromise;
14
+ constructor(secretsManager: SecretsManager);
15
+ load(): Promise<any>;
16
+ setSecretsManager(secretsManager: SecretsManager): void;
17
+ abstract getMongoSecretNames(): {
18
+ userSecretName: string;
19
+ pwdSecretName: string;
20
+ } | null;
21
+ abstract getProps(): APIOptions;
22
+ getSigningKey(): string;
23
+ getExpectedAudience(): string;
24
+ getTotoRegistryEndpoint(): string;
25
+ getMongoDb(dbName: string): Promise<Db>;
26
+ getMongoClient(dbName: string): Promise<MongoClient>;
27
+ static closeMongoClient(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=TotoControllerConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoControllerConfig.d.ts","sourceRoot":"","sources":["../../src/model/TotoControllerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAoB,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,8BAAsB,oBAAoB;IAEtC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,SAAS,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAElC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhD,OAAO,CAAC,MAAM,CAAC,WAAW,CAA4B;IACtD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAqC;gBAE1D,cAAc,EAAE,cAAc;IAOpC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAqCnB,iBAAiB,CAAC,cAAc,EAAE,cAAc;IAYvD,QAAQ,CAAC,mBAAmB,IAAI;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAKxF,QAAQ,CAAC,QAAQ,IAAI,UAAU;IAK/B,aAAa,IAAI,MAAM;IAQvB,mBAAmB,IAAI,MAAM;IAE7B,uBAAuB,IAAI,MAAM;IAU3B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAavC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;WAkC7C,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAUjD"}
@@ -0,0 +1,77 @@
1
+ import { MongoClient } from "mongodb";
2
+ export class TotoControllerConfig {
3
+ constructor(secretsManager) {
4
+ this.secretsManager = secretsManager;
5
+ }
6
+ async load() {
7
+ if (this.mongoHost && this.jwtSigningKey && this.expectedAudience && this.totoRegistryEndpoint) {
8
+ return;
9
+ }
10
+ let promises = [];
11
+ promises.push(this.secretsManager.getSecret('mongo-host').then((value) => {
12
+ this.mongoHost = value;
13
+ }));
14
+ promises.push(this.secretsManager.getSecret('jwt-signing-key').then((value) => {
15
+ this.jwtSigningKey = value;
16
+ }));
17
+ promises.push(this.secretsManager.getSecret('toto-expected-audience').then((value) => {
18
+ this.expectedAudience = value;
19
+ }));
20
+ promises.push(this.secretsManager.getSecret('toto-registry-endpoint').then((value) => {
21
+ this.totoRegistryEndpoint = value;
22
+ }));
23
+ if (this.getMongoSecretNames() != null && this.getMongoSecretNames() != undefined) {
24
+ promises.push(this.secretsManager.getSecret(this.getMongoSecretNames().userSecretName).then((value) => {
25
+ this.mongoUser = value;
26
+ }));
27
+ promises.push(this.secretsManager.getSecret(this.getMongoSecretNames().pwdSecretName).then((value) => {
28
+ this.mongoPwd = value;
29
+ }));
30
+ }
31
+ await Promise.all(promises);
32
+ }
33
+ setSecretsManager(secretsManager) { this.secretsManager = secretsManager; }
34
+ getSigningKey() { return this.jwtSigningKey; }
35
+ getExpectedAudience() { return String(this.expectedAudience); }
36
+ getTotoRegistryEndpoint() { return String(this.totoRegistryEndpoint); }
37
+ async getMongoDb(dbName) {
38
+ const client = await this.getMongoClient(dbName);
39
+ return client.db(dbName);
40
+ }
41
+ async getMongoClient(dbName) {
42
+ if (TotoControllerConfig.mongoClient)
43
+ return TotoControllerConfig.mongoClient;
44
+ if (TotoControllerConfig.mongoClientPromise)
45
+ return TotoControllerConfig.mongoClientPromise;
46
+ const mongoUrl = `mongodb://${this.mongoUser}:${this.mongoPwd}@${this.mongoHost}:27017/${dbName}`;
47
+ TotoControllerConfig.mongoClientPromise = new MongoClient(mongoUrl, {
48
+ serverSelectionTimeoutMS: 5000,
49
+ socketTimeoutMS: 30000,
50
+ maxPoolSize: 80,
51
+ }).connect().then(client => {
52
+ TotoControllerConfig.mongoClient = client;
53
+ TotoControllerConfig.mongoClientPromise = null;
54
+ return client;
55
+ }).catch(error => {
56
+ TotoControllerConfig.mongoClientPromise = null;
57
+ throw error;
58
+ });
59
+ return TotoControllerConfig.mongoClientPromise;
60
+ }
61
+ static async closeMongoClient() {
62
+ if (TotoControllerConfig.mongoClient) {
63
+ await TotoControllerConfig.mongoClient.close();
64
+ TotoControllerConfig.mongoClient = null;
65
+ }
66
+ }
67
+ }
68
+ TotoControllerConfig.mongoClient = null;
69
+ TotoControllerConfig.mongoClientPromise = null;
70
+ const shutdown = async () => {
71
+ console.log('Shutting down gracefully...');
72
+ await TotoControllerConfig.closeMongoClient();
73
+ process.exit(0);
74
+ };
75
+ process.on('SIGINT', shutdown);
76
+ process.on('SIGTERM', shutdown);
77
+ //# sourceMappingURL=TotoControllerConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoControllerConfig.js","sourceRoot":"","sources":["../../src/model/TotoControllerConfig.ts"],"names":[],"mappings":"AA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AAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Request } from "express";
2
+ import { UserContext } from "./UserContext";
3
+ import { TotoMessageBus } from "../evt/MessageBus";
4
+ import { TotoControllerConfig } from "./TotoControllerConfig";
5
+ export declare abstract class TotoDelegate {
6
+ protected messageBus: TotoMessageBus;
7
+ protected config: TotoControllerConfig;
8
+ protected cid?: string;
9
+ constructor(messageBus: TotoMessageBus, config: TotoControllerConfig);
10
+ processRequest(req: Request | FakeRequest, userContext?: UserContext): Promise<any>;
11
+ protected abstract do(req: Request | FakeRequest, userContext?: UserContext): Promise<any>;
12
+ }
13
+ export interface FakeRequest {
14
+ query: any;
15
+ params: any;
16
+ headers: any;
17
+ body: any;
18
+ }
19
+ //# sourceMappingURL=TotoDelegate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoDelegate.d.ts","sourceRoot":"","sources":["../../src/model/TotoDelegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,8BAAsB,YAAY;IAIlB,SAAS,CAAC,UAAU,EAAE,cAAc;IAAE,SAAS,CAAC,MAAM,EAAE,oBAAoB;IAFxF,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAa;gBAEb,UAAU,EAAE,cAAc,EAAY,MAAM,EAAE,oBAAoB;IAU3E,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAQhG,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;CAE7F;AAED,MAAM,WAAW,WAAW;IAExB,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,GAAG,CAAA;CAEZ"}
@@ -0,0 +1,12 @@
1
+ export class TotoDelegate {
2
+ constructor(messageBus, config) {
3
+ this.messageBus = messageBus;
4
+ this.config = config;
5
+ this.cid = undefined;
6
+ }
7
+ async processRequest(req, userContext) {
8
+ this.cid = req.headers['x-correlation-id'] || req.headers['X-Correlation-Id'];
9
+ return this.do(req, userContext);
10
+ }
11
+ }
12
+ //# sourceMappingURL=TotoDelegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoDelegate.js","sourceRoot":"","sources":["../../src/model/TotoDelegate.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,YAAY;IAI9B,YAAsB,UAA0B,EAAY,MAA4B;QAAlE,eAAU,GAAV,UAAU,CAAgB;QAAY,WAAM,GAAN,MAAM,CAAsB;QAF9E,QAAG,GAAY,SAAS,CAAC;IAEyD,CAAC;IAUtF,KAAK,CAAC,cAAc,CAAC,GAA0B,EAAE,WAAyB;QAG7E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACrC,CAAC;CAIJ"}
@@ -0,0 +1,16 @@
1
+ export type SupportedHyperscalers = "aws" | "gcp" | "azure";
2
+ export interface TotoEnvironment {
3
+ hyperscaler: SupportedHyperscalers;
4
+ hyperscalerConfiguration: GCPConfiguration | AWSConfiguration | AzureConfiguration;
5
+ }
6
+ export interface GCPConfiguration {
7
+ gcpProjectId: string;
8
+ }
9
+ export interface AWSConfiguration {
10
+ environment: "dev" | "test" | "prod";
11
+ awsRegion: string;
12
+ }
13
+ export interface AzureConfiguration {
14
+ azureRegion: string;
15
+ }
16
+ //# sourceMappingURL=TotoEnvironment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoEnvironment.d.ts","sourceRoot":"","sources":["../../src/model/TotoEnvironment.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,qBAAqB,CAAC;IACnC,wBAAwB,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;CACtF;AAED,MAAM,WAAW,gBAAgB;IAC7B,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TotoEnvironment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoEnvironment.js","sourceRoot":"","sources":["../../src/model/TotoEnvironment.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface TotoPathOptions {
2
+ noAuth: boolean;
3
+ contentType: string;
4
+ ignoreBasePath?: boolean;
5
+ }
6
+ //# sourceMappingURL=TotoPathOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoPathOptions.d.ts","sourceRoot":"","sources":["../../src/model/TotoPathOptions.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAI5B,MAAM,EAAE,OAAO,CAAC;IAIhB,WAAW,EAAE,MAAM,CAAC;IAcpB,cAAc,CAAC,EAAE,OAAO,CAAA;CAE3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TotoPathOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoPathOptions.js","sourceRoot":"","sources":["../../src/model/TotoPathOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export declare class TotoRuntimeError extends Error {
2
+ code: number;
3
+ message: string;
4
+ subcode: string | undefined;
5
+ constructor(code: number, message: string, subcode?: string);
6
+ }
7
+ //# sourceMappingURL=TotoRuntimeError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoRuntimeError.d.ts","sourceRoot":"","sources":["../../src/model/TotoRuntimeError.ts"],"names":[],"mappings":"AACA,qBAAa,gBAAiB,SAAQ,KAAK;IAEvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEhB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAO5D"}
@@ -0,0 +1,9 @@
1
+ export class TotoRuntimeError extends Error {
2
+ constructor(code, message, subcode) {
3
+ super();
4
+ this.code = code;
5
+ this.message = message;
6
+ this.subcode = subcode;
7
+ }
8
+ }
9
+ //# sourceMappingURL=TotoRuntimeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TotoRuntimeError.js","sourceRoot":"","sources":["../../src/model/TotoRuntimeError.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAMvC,YAAY,IAAY,EAAE,OAAe,EAAE,OAAgB;QACzD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export interface UserContext {
2
+ userId: string;
3
+ email: string;
4
+ authProvider: string;
5
+ }
6
+ //# sourceMappingURL=UserContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserContext.d.ts","sourceRoot":"","sources":["../../src/model/UserContext.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAExB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAA;CAEvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UserContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserContext.js","sourceRoot":"","sources":["../../src/model/UserContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare function correlationId(): string;
2
+ //# sourceMappingURL=CorrelationId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CorrelationId.d.ts","sourceRoot":"","sources":["../../src/util/CorrelationId.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,IAAI,MAAM,CAOtC"}
@@ -0,0 +1,7 @@
1
+ import moment from 'moment-timezone';
2
+ export function correlationId() {
3
+ let ts = moment().tz('Europe/Rome').format('YYYYMMDDHHmmssSSS');
4
+ let random = (Math.random() * 100000).toFixed(0).padStart(5, '0');
5
+ return ts + '' + random;
6
+ }
7
+ //# sourceMappingURL=CorrelationId.js.map