@ikonintegration/ikapi 5.0.2 → 5.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 (132) hide show
  1. package/package.json +1 -1
  2. package/src/BaseEvent/Launchable/ContainerExec.ts +6 -2
  3. package/src/Mailer/Mailer.ts +42 -52
  4. package/dist/index.d.ts +0 -17
  5. package/dist/index.js +0 -28
  6. package/dist/index.js.map +0 -1
  7. package/dist/package-lock.json +0 -11901
  8. package/dist/package.json +0 -82
  9. package/dist/src/API/Request.d.ts +0 -125
  10. package/dist/src/API/Request.js +0 -185
  11. package/dist/src/API/Request.js.map +0 -1
  12. package/dist/src/API/Response.d.ts +0 -188
  13. package/dist/src/API/Response.js +0 -270
  14. package/dist/src/API/Response.js.map +0 -1
  15. package/dist/src/BaseEvent/DynamoTransaction.d.ts +0 -70
  16. package/dist/src/BaseEvent/DynamoTransaction.js +0 -104
  17. package/dist/src/BaseEvent/DynamoTransaction.js.map +0 -1
  18. package/dist/src/BaseEvent/EventProcessor.d.ts +0 -58
  19. package/dist/src/BaseEvent/EventProcessor.js +0 -101
  20. package/dist/src/BaseEvent/EventProcessor.js.map +0 -1
  21. package/dist/src/BaseEvent/Launchable/ContainerExec.d.ts +0 -42
  22. package/dist/src/BaseEvent/Launchable/ContainerExec.js +0 -102
  23. package/dist/src/BaseEvent/Launchable/ContainerExec.js.map +0 -1
  24. package/dist/src/BaseEvent/Launchable/index.d.ts +0 -34
  25. package/dist/src/BaseEvent/Launchable/index.js +0 -43
  26. package/dist/src/BaseEvent/Launchable/index.js.map +0 -1
  27. package/dist/src/BaseEvent/Launchable/types.d.ts +0 -10
  28. package/dist/src/BaseEvent/Launchable/types.js +0 -2
  29. package/dist/src/BaseEvent/Launchable/types.js.map +0 -1
  30. package/dist/src/BaseEvent/Process.d.ts +0 -50
  31. package/dist/src/BaseEvent/Process.js +0 -64
  32. package/dist/src/BaseEvent/Process.js.map +0 -1
  33. package/dist/src/BaseEvent/StepTransaction.d.ts +0 -23
  34. package/dist/src/BaseEvent/StepTransaction.js +0 -27
  35. package/dist/src/BaseEvent/StepTransaction.js.map +0 -1
  36. package/dist/src/BaseEvent/Transaction.d.ts +0 -149
  37. package/dist/src/BaseEvent/Transaction.js +0 -224
  38. package/dist/src/BaseEvent/Transaction.js.map +0 -1
  39. package/dist/src/Cache/Redis.d.ts +0 -29
  40. package/dist/src/Cache/Redis.js +0 -80
  41. package/dist/src/Cache/Redis.js.map +0 -1
  42. package/dist/src/Cache/types.d.ts +0 -31
  43. package/dist/src/Cache/types.js +0 -2
  44. package/dist/src/Cache/types.js.map +0 -1
  45. package/dist/src/Config/Configuration.d.ts +0 -123
  46. package/dist/src/Config/Configuration.js +0 -109
  47. package/dist/src/Config/Configuration.js.map +0 -1
  48. package/dist/src/Config/EnvironmentVar.d.ts +0 -74
  49. package/dist/src/Config/EnvironmentVar.js +0 -138
  50. package/dist/src/Config/EnvironmentVar.js.map +0 -1
  51. package/dist/src/Crypto/Crypto.d.ts +0 -45
  52. package/dist/src/Crypto/Crypto.js +0 -72
  53. package/dist/src/Crypto/Crypto.js.map +0 -1
  54. package/dist/src/Database/Database.d.ts +0 -21
  55. package/dist/src/Database/Database.js +0 -15
  56. package/dist/src/Database/Database.js.map +0 -1
  57. package/dist/src/Database/DatabaseManager.d.ts +0 -47
  58. package/dist/src/Database/DatabaseManager.js +0 -60
  59. package/dist/src/Database/DatabaseManager.js.map +0 -1
  60. package/dist/src/Database/DatabaseTransaction.d.ts +0 -101
  61. package/dist/src/Database/DatabaseTransaction.js +0 -126
  62. package/dist/src/Database/DatabaseTransaction.js.map +0 -1
  63. package/dist/src/Database/index.d.ts +0 -10
  64. package/dist/src/Database/index.js +0 -15
  65. package/dist/src/Database/index.js.map +0 -1
  66. package/dist/src/Database/integrations/dynamo/DynamoDatabase.d.ts +0 -35
  67. package/dist/src/Database/integrations/dynamo/DynamoDatabase.js +0 -59
  68. package/dist/src/Database/integrations/dynamo/DynamoDatabase.js.map +0 -1
  69. package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +0 -66
  70. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +0 -86
  71. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +0 -1
  72. package/dist/src/Database/integrations/kysely/KyselyTransaction.d.ts +0 -70
  73. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +0 -118
  74. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +0 -1
  75. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +0 -36
  76. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +0 -54
  77. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +0 -1
  78. package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +0 -63
  79. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +0 -61
  80. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +0 -1
  81. package/dist/src/Database/types.d.ts +0 -76
  82. package/dist/src/Database/types.js +0 -2
  83. package/dist/src/Database/types.js.map +0 -1
  84. package/dist/src/Globals.d.ts +0 -93
  85. package/dist/src/Globals.js +0 -99
  86. package/dist/src/Globals.js.map +0 -1
  87. package/dist/src/Logger/Logger.d.ts +0 -161
  88. package/dist/src/Logger/Logger.js +0 -299
  89. package/dist/src/Logger/Logger.js.map +0 -1
  90. package/dist/src/Mailer/Mailer.d.ts +0 -78
  91. package/dist/src/Mailer/Mailer.js +0 -182
  92. package/dist/src/Mailer/Mailer.js.map +0 -1
  93. package/dist/src/Publisher/Publisher.d.ts +0 -39
  94. package/dist/src/Publisher/Publisher.js +0 -77
  95. package/dist/src/Publisher/Publisher.js.map +0 -1
  96. package/dist/src/Server/RouteResolver.d.ts +0 -33
  97. package/dist/src/Server/RouteResolver.js +0 -100
  98. package/dist/src/Server/RouteResolver.js.map +0 -1
  99. package/dist/src/Server/Router.d.ts +0 -157
  100. package/dist/src/Server/Router.js +0 -32
  101. package/dist/src/Server/Router.js.map +0 -1
  102. package/dist/src/Server/lib/ContainerServer.d.ts +0 -42
  103. package/dist/src/Server/lib/ContainerServer.js +0 -66
  104. package/dist/src/Server/lib/ContainerServer.js.map +0 -1
  105. package/dist/src/Server/lib/Server.d.ts +0 -45
  106. package/dist/src/Server/lib/Server.js +0 -93
  107. package/dist/src/Server/lib/Server.js.map +0 -1
  108. package/dist/src/Server/lib/container/GenericHandler.d.ts +0 -9
  109. package/dist/src/Server/lib/container/GenericHandler.js +0 -82
  110. package/dist/src/Server/lib/container/GenericHandler.js.map +0 -1
  111. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +0 -52
  112. package/dist/src/Server/lib/container/GenericHandlerEvent.js +0 -132
  113. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +0 -1
  114. package/dist/src/Server/lib/container/HealthHandler.d.ts +0 -9
  115. package/dist/src/Server/lib/container/HealthHandler.js +0 -19
  116. package/dist/src/Server/lib/container/HealthHandler.js.map +0 -1
  117. package/dist/src/Server/lib/container/Proxy.d.ts +0 -67
  118. package/dist/src/Server/lib/container/Proxy.js +0 -143
  119. package/dist/src/Server/lib/container/Proxy.js.map +0 -1
  120. package/dist/src/Server/lib/container/Utils.d.ts +0 -14
  121. package/dist/src/Server/lib/container/Utils.js +0 -37
  122. package/dist/src/Server/lib/container/Utils.js.map +0 -1
  123. package/dist/src/Util/AsyncSingleton.d.ts +0 -31
  124. package/dist/src/Util/AsyncSingleton.js +0 -83
  125. package/dist/src/Util/AsyncSingleton.js.map +0 -1
  126. package/dist/src/Util/Utils.d.ts +0 -61
  127. package/dist/src/Util/Utils.js +0 -147
  128. package/dist/src/Util/Utils.js.map +0 -1
  129. package/dist/src/Validation/Validator.d.ts +0 -17
  130. package/dist/src/Validation/Validator.js +0 -39
  131. package/dist/src/Validation/Validator.js.map +0 -1
  132. package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/package.json DELETED
@@ -1,82 +0,0 @@
1
- {
2
- "name": "@ikonintegration/ikapi",
3
- "version": "5.0.2",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "module",
8
- "scripts": {
9
- "build": "task build",
10
- "clean": "task clean",
11
- "lint-fix": "task lint-fix",
12
- "lint": "task lint",
13
- "docs": "task docs",
14
- "test": "task test",
15
- "test-ts": "task test-ts",
16
- "test-js": "task test-js",
17
- "test-dev": "task test-dev"
18
- },
19
- "author": "",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@aws-sdk/client-dynamodb": "^3.650.0",
23
- "@aws-sdk/client-kms": "^3.650.0",
24
- "@aws-sdk/client-secrets-manager": "^3.650.0",
25
- "@aws-sdk/client-ses": "^3.650.0",
26
- "@aws-sdk/client-sns": "^3.650.0",
27
- "@aws-sdk/client-ssm": "^3.650.0",
28
- "@aws-sdk/credential-provider-node": "^3.650.0",
29
- "@aws-sdk/util-dynamodb": "^3.650.0",
30
- "@smithy/node-http-handler": "^3.2.0",
31
- "@types/email-templates": "^10.0.1",
32
- "@types/nodemailer": "^6.4.10",
33
- "@types/object-hash": "^3.0.4",
34
- "abind": "^1.0.5",
35
- "cors": "^2.8.5",
36
- "cuid": "^3.0.0",
37
- "dotenv": "^16.4.1",
38
- "email-templates": "^12.0.1",
39
- "express": "^4.21.0",
40
- "json-stringify-safe": "^5.0.1",
41
- "kysely": "^0.27.2",
42
- "node-cache": "^5.1.2",
43
- "object-hash": "^3.0.0",
44
- "parse-duration": "^1.1.0",
45
- "path-to-regexp": "^8.1.0",
46
- "pg": "^8.11.3",
47
- "redis": "^4.7.0",
48
- "sha1": "^1.1.1",
49
- "stack-trace": "0.0.10",
50
- "zod": "^3.23.4"
51
- },
52
- "devDependencies": {
53
- "@go-task/cli": "^3.39.0",
54
- "@jest/globals": "^29.7.0",
55
- "@types/aws-lambda": "^8.10.145",
56
- "@types/chai": "^4.3.19",
57
- "@types/cors": "^2.8.15",
58
- "@types/express": "^4.17.19",
59
- "@types/jest": "^29.5.13",
60
- "@types/node": "^20.12.7",
61
- "@types/path-to-regexp": "^1.7.0",
62
- "@types/pg": "^8.11.9",
63
- "@types/supertest": "^6.0.2",
64
- "@typescript-eslint/eslint-plugin": "^7.7.1",
65
- "@typescript-eslint/parser": "^7.7.1",
66
- "aws-lambda": "^1.0.7",
67
- "aws-sdk-client-mock": "^4.0.0",
68
- "chai": "^4.4.1",
69
- "eslint": "^8.48.0",
70
- "eslint-config-prettier": "^9.0.0",
71
- "eslint-plugin-import": "^2.30.0",
72
- "eslint-plugin-prettier": "^5.0.0",
73
- "eslint-plugin-require-extensions": "^0.1.3",
74
- "jest": "^29.7.0",
75
- "jest-junit": "^16.0.0",
76
- "prettier": "^3.2.5",
77
- "supertest": "^7.0.0",
78
- "ts-jest": "^29.2.5",
79
- "ts-node": "^10.9.1",
80
- "typescript": "^5.6.2"
81
- }
82
- }
@@ -1,125 +0,0 @@
1
- import type { Context, APIGatewayEvent } from 'aws-lambda';
2
- import Logger from '../Logger/Logger.js';
3
- /**
4
- * Represents a request object with generic types for input, query parameters, and path parameters.
5
- * @class Request
6
- * @template InputType - The type of the input data for the request.
7
- * @template PathParamsType - The type of the path parameters for the request.
8
- * @template QueryParamsType - The type of the query parameters for the request.
9
- */
10
- export default class Request<InputType, PathParamsType, QueryParamsType> {
11
- /**
12
- * Represents an API Gateway event for a request.
13
- * @type {APIGatewayEvent}
14
- */
15
- private requestEvent;
16
- /**
17
- * The context object for the current instance.
18
- */
19
- private context;
20
- /**
21
- * Constructs a new instance of the class.
22
- * @param {APIGatewayEvent} requestEvent - The API Gateway event object.
23
- * @param {Context} context - The context object.
24
- * @param {Logger} logger - The logger object.
25
- * @returns None
26
- */
27
- constructor(requestEvent: APIGatewayEvent, context: Context, logger: Logger);
28
- /**
29
- * Checks if the specified query parameter exists and has a valid value.
30
- * @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
31
- * @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
32
- */
33
- containsQueryParam(paramName: keyof QueryParamsType): boolean;
34
- /**
35
- * Retrieves the value of a query parameter from the URL.
36
- * @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
37
- * @returns {string | null} The value of the query parameter, or null if it does not exist.
38
- */
39
- getQueryParam(paramName: keyof QueryParamsType): string;
40
- /**
41
- * Retrieves the value of the specified header from the request event headers.
42
- * @param {string} headerName - The name of the header to retrieve.
43
- * @returns {string | null} - The value of the header, or null if the header is not found.
44
- */
45
- getHeader(headerName: string): string | null;
46
- /**
47
- * Retrieves the value of a context parameter from the request context object.
48
- * @param {string} cxtParam - The name of the context parameter to retrieve.
49
- * @returns The value of the context parameter, or null if it does not exist.
50
- */
51
- getContextParam(cxtParam: string): any | null;
52
- /**
53
- * Checks if the given parameter name exists in the PathParamsType object.
54
- * @param {keyof PathParamsType} paramName - The name of the parameter to check.
55
- * @returns {boolean} - True if the parameter exists, false otherwise.
56
- */
57
- containsPathParam(paramName: keyof PathParamsType): boolean;
58
- /**
59
- * Retrieves the value of a specific path parameter from the URL.
60
- * @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
61
- * @returns {string} The value of the path parameter, or null if it does not exist.
62
- */
63
- getPathParam(paramName: keyof PathParamsType): string;
64
- /**
65
- * Retrieves the body of the request event and parses it if it is a string.
66
- * @returns {InputType} The parsed body of the request event.
67
- */
68
- getBody(raw?: boolean): InputType;
69
- /**
70
- * Retrieves the path from the request event.
71
- * @returns {string} The path of the request event.
72
- */
73
- getPath(): string;
74
- /**
75
- * Retrieves the HTTP method of the current request.
76
- * @returns {string} The HTTP method of the request.
77
- */
78
- getMethod(): HttpMethod;
79
- /**
80
- * Retrieves the path parameters from the request event.
81
- * @returns {PathParamsType | null} - The path parameters object, or null if not found.
82
- */
83
- getPathParams(): PathParamsType;
84
- /**
85
- * Retrieves the query parameters from the request event.
86
- * @returns {QueryParamsType | null} - The query parameters object, or null if not found.
87
- */
88
- getQueryParams(): QueryParamsType;
89
- /**
90
- * Retrieves the value of the 'Authorization' header from the request.
91
- * @returns The value of the 'Authorization' header, or null if it is not present.
92
- */
93
- getAuthorizationHeader(): string | null;
94
- /**
95
- * Retrieves the request ID associated with the current execution context.
96
- * @returns {string} The request ID.
97
- */
98
- getRequestID(): string;
99
- /**
100
- * Retrieves the origin IP address of the request.
101
- * @returns {string} The origin IP address. If the IP address is not available, it returns 'unknown'.
102
- */
103
- getOriginIP(): string;
104
- /**
105
- * Sets the fixed path parameters in the request event object.
106
- * @param {any[]} keys - An array of keys representing the path parameter names.
107
- * @param {any[]} result - An array of values representing the path parameter values.
108
- * @returns None
109
- */
110
- setFixedPathParams(keys: any[], result: any[]): void;
111
- }
112
- /**
113
- * Enum representing the HTTP methods.
114
- */
115
- export declare enum HttpMethod {
116
- GET = "GET",
117
- HEAD = "HEAD",
118
- POST = "POST",
119
- PUT = "PUT",
120
- DELETE = "DELETE",
121
- CONNECT = "CONNECT",
122
- OPTIONS = "OPTIONS",
123
- TRACE = "TRACE",
124
- PATCH = "PATCH"
125
- }
@@ -1,185 +0,0 @@
1
- import Utils from '../Util/Utils.js';
2
- /**
3
- * Represents a request object with generic types for input, query parameters, and path parameters.
4
- * @class Request
5
- * @template InputType - The type of the input data for the request.
6
- * @template PathParamsType - The type of the path parameters for the request.
7
- * @template QueryParamsType - The type of the query parameters for the request.
8
- */
9
- export default class Request {
10
- /**
11
- * Constructs a new instance of the class.
12
- * @param {APIGatewayEvent} requestEvent - The API Gateway event object.
13
- * @param {Context} context - The context object.
14
- * @param {Logger} logger - The logger object.
15
- * @returns None
16
- */
17
- constructor(requestEvent, context, logger) {
18
- this.requestEvent = requestEvent;
19
- this.context = context;
20
- logger.debug('Request info:', requestEvent);
21
- logger.debug('Request context:', context);
22
- }
23
- /**
24
- * Checks if the specified query parameter exists and has a valid value.
25
- * @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
26
- * @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
27
- */
28
- containsQueryParam(paramName) {
29
- const val = this.getQueryParam(paramName);
30
- return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val));
31
- }
32
- /**
33
- * Retrieves the value of a query parameter from the URL.
34
- * @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
35
- * @returns {string | null} The value of the query parameter, or null if it does not exist.
36
- */
37
- getQueryParam(paramName) {
38
- return Utils.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, String(paramName));
39
- }
40
- /**
41
- * Retrieves the value of the specified header from the request event headers.
42
- * @param {string} headerName - The name of the header to retrieve.
43
- * @returns {string | null} - The value of the header, or null if the header is not found.
44
- */
45
- getHeader(headerName) {
46
- return Utils.caseInsensitiveObjectForKey(this.requestEvent.headers, headerName);
47
- }
48
- /**
49
- * Retrieves the value of a context parameter from the request context object.
50
- * @param {string} cxtParam - The name of the context parameter to retrieve.
51
- * @returns The value of the context parameter, or null if it does not exist.
52
- */
53
- getContextParam(cxtParam) {
54
- return Utils.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam);
55
- }
56
- /**
57
- * Checks if the given parameter name exists in the PathParamsType object.
58
- * @param {keyof PathParamsType} paramName - The name of the parameter to check.
59
- * @returns {boolean} - True if the parameter exists, false otherwise.
60
- */
61
- containsPathParam(paramName) {
62
- const val = this.getPathParam(paramName);
63
- return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val));
64
- }
65
- /**
66
- * Retrieves the value of a specific path parameter from the URL.
67
- * @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
68
- * @returns {string} The value of the path parameter, or null if it does not exist.
69
- */
70
- getPathParam(paramName) {
71
- return Utils.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, String(paramName));
72
- }
73
- /**
74
- * Retrieves the body of the request event and parses it if it is a string.
75
- * @returns {InputType} The parsed body of the request event.
76
- */
77
- getBody(raw) {
78
- const body = this.requestEvent.body;
79
- if (raw)
80
- return Utils.isHybridlessContainer() ? this.requestEvent['rawBody'] : body;
81
- if (typeof body === 'string' || body instanceof String) {
82
- try {
83
- return JSON.parse(body);
84
- }
85
- catch (e) {
86
- console.error('Error while getting request body!', e);
87
- }
88
- }
89
- return body;
90
- }
91
- /**
92
- * Retrieves the path from the request event.
93
- * @returns {string} The path of the request event.
94
- */
95
- getPath() {
96
- return this.requestEvent.path;
97
- }
98
- /**
99
- * Retrieves the HTTP method of the current request.
100
- * @returns {string} The HTTP method of the request.
101
- */
102
- getMethod() {
103
- if (this.requestEvent.httpMethod) {
104
- const httpMethod = this.requestEvent.httpMethod.toUpperCase();
105
- if (httpMethod in HttpMethod) {
106
- return HttpMethod[httpMethod];
107
- }
108
- }
109
- throw new Error(`Invalid HTTP method: ${this.requestEvent.httpMethod}`);
110
- }
111
- /**
112
- * Retrieves the path parameters from the request event.
113
- * @returns {PathParamsType | null} - The path parameters object, or null if not found.
114
- */
115
- getPathParams() {
116
- // type conversion guaranteed by validation
117
- return this.requestEvent.pathParameters;
118
- }
119
- /**
120
- * Retrieves the query parameters from the request event.
121
- * @returns {QueryParamsType | null} - The query parameters object, or null if not found.
122
- */
123
- getQueryParams() {
124
- // type conversion guaranteed by validation
125
- return this.requestEvent.queryStringParameters;
126
- }
127
- /**
128
- * Retrieves the value of the 'Authorization' header from the request.
129
- * @returns The value of the 'Authorization' header, or null if it is not present.
130
- */
131
- getAuthorizationHeader() {
132
- return this.getHeader('Authorization');
133
- }
134
- /**
135
- * Retrieves the request ID associated with the current execution context.
136
- * @returns {string} The request ID.
137
- */
138
- getRequestID() {
139
- if (this.context.awsRequestId)
140
- return this.context.awsRequestId;
141
- return this.requestEvent.requestContext ? this.requestEvent.requestContext.requestId : 'unknown';
142
- }
143
- /**
144
- * Retrieves the origin IP address of the request.
145
- * @returns {string} The origin IP address. If the IP address is not available, it returns 'unknown'.
146
- */
147
- getOriginIP() {
148
- var _a;
149
- const origin = (_a = this.getContextParam('identity')) === null || _a === void 0 ? void 0 : _a.sourceIp;
150
- const hOrigin = this.getHeader('X-Forwarded-For');
151
- return origin ? origin : hOrigin ? hOrigin : 'unknown';
152
- }
153
- /**
154
- * Sets the fixed path parameters in the request event object.
155
- * @param {any[]} keys - An array of keys representing the path parameter names.
156
- * @param {any[]} result - An array of values representing the path parameter values.
157
- * @returns None
158
- */
159
- setFixedPathParams(keys, result) {
160
- if (!this.requestEvent.pathParameters)
161
- this.requestEvent.pathParameters = {};
162
- keys.forEach((key, index) => {
163
- var _a;
164
- if ((_a = this.requestEvent) === null || _a === void 0 ? void 0 : _a.pathParameters) {
165
- this.requestEvent.pathParameters[key.name] = result[index + 1];
166
- }
167
- });
168
- }
169
- }
170
- /**
171
- * Enum representing the HTTP methods.
172
- */
173
- export var HttpMethod;
174
- (function (HttpMethod) {
175
- HttpMethod["GET"] = "GET";
176
- HttpMethod["HEAD"] = "HEAD";
177
- HttpMethod["POST"] = "POST";
178
- HttpMethod["PUT"] = "PUT";
179
- HttpMethod["DELETE"] = "DELETE";
180
- HttpMethod["CONNECT"] = "CONNECT";
181
- HttpMethod["OPTIONS"] = "OPTIONS";
182
- HttpMethod["TRACE"] = "TRACE";
183
- HttpMethod["PATCH"] = "PATCH";
184
- })(HttpMethod || (HttpMethod = {}));
185
- //# sourceMappingURL=Request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,kBAAkB,CAAA;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAW1B;;;;;;OAMG;IACH,YAAY,YAA6B,EAAE,OAAgB,EAAE,MAAc;QACzE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA;QAC3C,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED;;;;OAIG;IACI,kBAAkB,CAAC,SAAgC;QACxD,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,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transaction.js';
3
- /**
4
- * Represents an error response from an API.
5
- * @typedef {Object} ResponseErrorType
6
- * @property {string} err - The error message.
7
- * @property {string} [errCode] - The error code, if available.
8
- */
9
- export type ResponseErrorType = {
10
- err: string;
11
- errCode?: string;
12
- };
13
- /**
14
- * Represents a response object with various methods for building and manipulating the response.
15
- * @template BodyType - The type of the response body.
16
- */
17
- export default class Response<BodyType = null> {
18
- /**
19
- * The private property that stores the status code.
20
- * @type {number}
21
- * @private
22
- */
23
- private statusCode;
24
- /**
25
- * Private property representing the body of an object.
26
- * @type {any}
27
- * @private
28
- */
29
- private body;
30
- /**
31
- * Indicates whether the object is currently piping out.
32
- * @type {boolean}
33
- */
34
- private isPipingOut;
35
- /**
36
- * Private property that stores the headers as an object.
37
- */
38
- private headers;
39
- /**
40
- * Determines whether streaming is enabled or not.
41
- * @returns {boolean} - True if streaming is enabled, false otherwise.
42
- */
43
- readonly shouldStream: boolean;
44
- /**
45
- * Indicates whether the request body should be treated as raw data.
46
- * @type {boolean}
47
- */
48
- readonly rawBody: boolean;
49
- /**
50
- * A boolean flag indicating whether to throw an error when encountering errors.
51
- * If set to true, any errors encountered will result in an exception being thrown.
52
- * If set to false, errors will be logged but the program will continue execution.
53
- */
54
- readonly throwOnErrors: boolean;
55
- /**
56
- * Indicates whether the transaction ID is disabled.
57
- * @type {boolean}
58
- */
59
- readonly disableTransactionID: boolean;
60
- /**
61
- * Constructs a new Response object with the given status code, body, and optional behavior.
62
- * @param {number} statusCode - The HTTP status code of the response.
63
- * @param {BodyType} body - The body of the response.
64
- * @param {Object} [optBehaviour] - Optional behavior configuration for the response.
65
- * @param {boolean} [optBehaviour.shouldStream] - Indicates whether the response should be streamed.
66
- * @param {boolean} [optBehaviour.rawBody] - Indicates whether the response body should be treated as raw data.
67
- * @param {boolean} [optBehaviour.throwOnErrors] - Indicates whether errors should be thrown for non-successful status codes.
68
- * @param {boolean} [optBehaviour
69
- */
70
- constructor(statusCode: number, body: BodyType, optBehaviour?: {
71
- shouldStream?: boolean;
72
- rawBody?: boolean;
73
- throwOnErrors?: boolean;
74
- disableTransactionID?: boolean;
75
- } | undefined);
76
- /**
77
- * Get the status code of the response.
78
- * @returns {number} The status code.
79
- */
80
- getCode(): number;
81
- /**
82
- * Get the body of the object.
83
- * @returns {BodyType} The body of the object.
84
- */
85
- getBody(): BodyType;
86
- /**
87
- * Appends a key-value pair into the body object.
88
- * @param {string} key - The key to append.
89
- * @param {any} value - The value to append.
90
- * @returns None
91
- */
92
- appendIntoBody(key: string, value: any): void;
93
- /**
94
- * Appends a header to the existing headers object.
95
- * @param {string} key - The key of the header.
96
- * @param {any} value - The value of the header.
97
- * @returns None
98
- */
99
- appendHeader(key: string, value: any): void;
100
- /**
101
- * Builds the response for the given context and transaction.
102
- * @param {Context} context - The context object.
103
- * @param {Transaction<any, any, any>} transaction - The transaction object.
104
- * @param {boolean} optDoNotCallContext - Optional flag to indicate whether to call the context or not.
105
- * @returns {Promise<void>} - A promise that resolves when the response is built.
106
- */
107
- build(context: Context, transaction: Transaction<any, any, any, any, any>, optDoNotCallContext: boolean): Promise<void>;
108
- /**
109
- * Private method that pipes the response to the given context.
110
- * @param {Context} context - The context object provided by AWS Lambda.
111
- * @returns None
112
- */
113
- private pipe;
114
- /**
115
- * Private method that handles the raw context of a transaction.
116
- * @param {Context} context - The context object.
117
- * @param {Transaction<null, BodyType>} transaction - The transaction object.
118
- * @returns None
119
- */
120
- private rawContext;
121
- /**
122
- * Generates a response object for a missing path parameter error.
123
- * @param {string} paramName - The name of the missing path parameter.
124
- * @returns {Response<ResponseErrorType>} - The response object with error details.
125
- */
126
- static MissingParamResponse(paramName: string): Response<ResponseErrorType>;
127
- /**
128
- * Creates a response object for a missing query parameter error.
129
- * @param {string} paramName - The name of the missing query parameter.
130
- * @returns {Response<ResponseErrorType>} - The response object with error details.
131
- */
132
- static MissingQueryResponse(paramName: string): Response<ResponseErrorType>;
133
- /**
134
- * Creates a BadRequestResponse object with the given parameters.
135
- * @param {string} [msg] - The error message.
136
- * @param {string} [errCode] - The error code.
137
- * @param {any} [optBody] - Optional additional body data.
138
- * @returns {Response<ResponseErrorType>} - The BadRequestResponse object.
139
- */
140
- static BadRequestResponse(msg?: string, errCode?: string, optBody?: any): Response<ResponseErrorType>;
141
- /**
142
- * Creates a BadRequestResponse object with rollback option.
143
- * @param {string} msg - The error message.
144
- * @param {string} [errCode] - The error code.
145
- * @param {any} [optBody] - Optional body to include in the response.
146
- * @returns {Response<ResponseErrorType>} - The BadRequestResponse object.
147
- */
148
- static BadRequestResponseWithRollback(msg: string, errCode?: string, optBody?: any): Response<ResponseErrorType>;
149
- /**
150
- * Creates an unauthorized response with the given error message and error code.
151
- * @param {string} msg - The error message.
152
- * @param {string} [errCode] - The error code (optional).
153
- * @returns {Response<ResponseErrorType>} - The unauthorized response.
154
- */
155
- static UnauthorizedResponse(msg: string, errCode?: string): Response<ResponseErrorType>;
156
- /**
157
- * Creates a success response object with the given body.
158
- * @param {BodyType} body - The body of the response.
159
- * @returns {Response<BodyType>} - The success response object.
160
- */
161
- static SuccessResponse<BodyType>(body: BodyType): Response<BodyType>;
162
- /**
163
- * Creates a redirect response with the specified URL.
164
- * @param {string} url - The URL to redirect to.
165
- * @returns {Response<null>} - The redirect response.
166
- */
167
- static RedirectResponse(url: string): Response<null>;
168
- /**
169
- * Creates a success response with no content.
170
- * @returns {Response<null>} A response object with a status code of 204 and no content.
171
- */
172
- static SuccessNoContentResponse(): Response<null>;
173
- /**
174
- * Creates a success response object with a streaming body and specified content type.
175
- * @param {any} stream - The stream object to be used as the response body.
176
- * @param {string} contentType - The content type of the response.
177
- * @returns {Response} - The success response object.
178
- */
179
- static SuccessStreamResponse(stream: any, contentType: string): Response;
180
- /**
181
- * Creates a simple HTTP response with the given body and optional status code.
182
- * @param {BodyType} body - The body of the response.
183
- * @param {number} [optionalCode] - The optional status code of the response. Defaults to 200.
184
- * @returns {Response<BodyType>} - The created response object.
185
- */
186
- static SimpleResponse<BodyType>(body: BodyType, optionalCode?: number): Response<BodyType>;
187
- static StepFunctionResponse<BodyType>(body: BodyType, optionalCode?: number): Response<BodyType>;
188
- }