serverless-event-orchestrator 1.0.1

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +377 -0
  3. package/dist/dispatcher.d.ts +18 -0
  4. package/dist/dispatcher.d.ts.map +1 -0
  5. package/dist/dispatcher.js +345 -0
  6. package/dist/dispatcher.js.map +1 -0
  7. package/dist/http/body-parser.d.ts +27 -0
  8. package/dist/http/body-parser.d.ts.map +1 -0
  9. package/dist/http/body-parser.js +56 -0
  10. package/dist/http/body-parser.js.map +1 -0
  11. package/dist/http/cors.d.ts +32 -0
  12. package/dist/http/cors.d.ts.map +1 -0
  13. package/dist/http/cors.js +69 -0
  14. package/dist/http/cors.js.map +1 -0
  15. package/dist/http/index.d.ts +4 -0
  16. package/dist/http/index.d.ts.map +1 -0
  17. package/dist/http/index.js +20 -0
  18. package/dist/http/index.js.map +1 -0
  19. package/dist/http/response.d.ts +104 -0
  20. package/dist/http/response.d.ts.map +1 -0
  21. package/dist/http/response.js +164 -0
  22. package/dist/http/response.js.map +1 -0
  23. package/dist/identity/extractor.d.ts +39 -0
  24. package/dist/identity/extractor.d.ts.map +1 -0
  25. package/dist/identity/extractor.js +88 -0
  26. package/dist/identity/extractor.js.map +1 -0
  27. package/dist/identity/index.d.ts +2 -0
  28. package/dist/identity/index.d.ts.map +1 -0
  29. package/dist/identity/index.js +18 -0
  30. package/dist/identity/index.js.map +1 -0
  31. package/dist/index.d.ts +17 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +62 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/types/event-type.enum.d.ts +20 -0
  36. package/dist/types/event-type.enum.d.ts.map +1 -0
  37. package/dist/types/event-type.enum.js +25 -0
  38. package/dist/types/event-type.enum.js.map +1 -0
  39. package/dist/types/index.d.ts +3 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types/index.js +19 -0
  42. package/dist/types/index.js.map +1 -0
  43. package/dist/types/routes.d.ts +163 -0
  44. package/dist/types/routes.d.ts.map +1 -0
  45. package/dist/types/routes.js +3 -0
  46. package/dist/types/routes.js.map +1 -0
  47. package/dist/utils/headers.d.ts +28 -0
  48. package/dist/utils/headers.d.ts.map +1 -0
  49. package/dist/utils/headers.js +61 -0
  50. package/dist/utils/headers.js.map +1 -0
  51. package/dist/utils/index.d.ts +3 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +19 -0
  54. package/dist/utils/index.js.map +1 -0
  55. package/dist/utils/path-matcher.d.ts +33 -0
  56. package/dist/utils/path-matcher.d.ts.map +1 -0
  57. package/dist/utils/path-matcher.js +74 -0
  58. package/dist/utils/path-matcher.js.map +1 -0
  59. package/jest.config.js +32 -0
  60. package/package.json +68 -0
  61. package/src/dispatcher.ts +415 -0
  62. package/src/http/body-parser.ts +60 -0
  63. package/src/http/cors.ts +76 -0
  64. package/src/http/index.ts +3 -0
  65. package/src/http/response.ts +194 -0
  66. package/src/identity/extractor.ts +89 -0
  67. package/src/identity/index.ts +1 -0
  68. package/src/index.ts +92 -0
  69. package/src/types/event-type.enum.ts +20 -0
  70. package/src/types/index.ts +2 -0
  71. package/src/types/routes.ts +182 -0
  72. package/src/utils/headers.ts +72 -0
  73. package/src/utils/index.ts +2 -0
  74. package/src/utils/path-matcher.ts +79 -0
  75. package/tests/cors.test.ts +133 -0
  76. package/tests/dispatcher.test.ts +425 -0
  77. package/tests/headers.test.ts +99 -0
  78. package/tests/identity.test.ts +171 -0
  79. package/tests/path-matcher.test.ts +102 -0
  80. package/tests/response.test.ts +155 -0
  81. package/tsconfig.json +24 -0
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Response utilities for consistent HTTP responses
3
+ * Agnostic to domain-specific error codes - allows injection of custom codes
4
+ */
5
+ /**
6
+ * Standard HTTP status codes
7
+ */
8
+ export declare enum HttpStatus {
9
+ OK = 200,
10
+ CREATED = 201,
11
+ NO_CONTENT = 204,
12
+ BAD_REQUEST = 400,
13
+ UNAUTHORIZED = 401,
14
+ FORBIDDEN = 403,
15
+ NOT_FOUND = 404,
16
+ CONFLICT = 409,
17
+ UNPROCESSABLE_ENTITY = 422,
18
+ INTERNAL_SERVER_ERROR = 500,
19
+ SERVICE_UNAVAILABLE = 503
20
+ }
21
+ /**
22
+ * Standard response structure
23
+ */
24
+ export interface StandardResponse<T = unknown, C = string> {
25
+ status: number;
26
+ code: C;
27
+ data?: T;
28
+ message?: string;
29
+ }
30
+ /**
31
+ * Lambda HTTP response format
32
+ */
33
+ export interface HttpResponse {
34
+ statusCode: number;
35
+ body: string;
36
+ headers?: Record<string, string>;
37
+ }
38
+ /**
39
+ * Default response codes for standard HTTP statuses
40
+ */
41
+ export declare const DefaultResponseCode: {
42
+ readonly SUCCESS: "SUCCESS";
43
+ readonly CREATED: "CREATED";
44
+ readonly BAD_REQUEST: "BAD_REQUEST";
45
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
46
+ readonly FORBIDDEN: "FORBIDDEN";
47
+ readonly NOT_FOUND: "NOT_FOUND";
48
+ readonly CONFLICT: "CONFLICT";
49
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
50
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
51
+ };
52
+ /**
53
+ * Creates a standardized HTTP response
54
+ * @param statusCode - HTTP status code
55
+ * @param data - Response payload
56
+ * @param code - Custom response code
57
+ * @param message - Optional message
58
+ * @param headers - Optional headers
59
+ */
60
+ export declare function createStandardResponse<T, C = string>(statusCode: number, data?: T, code?: C, message?: string, headers?: Record<string, string>): HttpResponse;
61
+ /**
62
+ * Success response (200 OK)
63
+ */
64
+ export declare function successResponse<T>(data?: T, code?: string, headers?: Record<string, string>): HttpResponse;
65
+ /**
66
+ * Created response (201 Created)
67
+ */
68
+ export declare function createdResponse<T>(data?: T, code?: string, headers?: Record<string, string>): HttpResponse;
69
+ /**
70
+ * Bad request response (400)
71
+ */
72
+ export declare function badRequestResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
73
+ /**
74
+ * Unauthorized response (401)
75
+ */
76
+ export declare function unauthorizedResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
77
+ /**
78
+ * Forbidden response (403)
79
+ */
80
+ export declare function forbiddenResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
81
+ /**
82
+ * Not found response (404)
83
+ */
84
+ export declare function notFoundResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
85
+ /**
86
+ * Conflict response (409)
87
+ */
88
+ export declare function conflictResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
89
+ /**
90
+ * Validation error response (422)
91
+ */
92
+ export declare function validationErrorResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
93
+ /**
94
+ * Internal server error response (500)
95
+ */
96
+ export declare function internalErrorResponse(message?: string, code?: string, headers?: Record<string, string>): HttpResponse;
97
+ /**
98
+ * Custom error response with automatic status resolution
99
+ * @param customCode - Your domain-specific error code
100
+ * @param message - Error message
101
+ * @param codeToStatusMap - Mapping of custom codes to HTTP statuses
102
+ */
103
+ export declare function customErrorResponse<C extends string>(customCode: C, message?: string, codeToStatusMap?: Record<C, HttpStatus>, headers?: Record<string, string>): HttpResponse;
104
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/http/response.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,UAAU,MAAM;IAChB,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,QAAQ,MAAM;IACd,oBAAoB,MAAM;IAC1B,qBAAqB,MAAM;IAC3B,mBAAmB,MAAM;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GA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AAY,CAGd"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /**
3
+ * Response utilities for consistent HTTP responses
4
+ * Agnostic to domain-specific error codes - allows injection of custom codes
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DefaultResponseCode = exports.HttpStatus = void 0;
8
+ exports.createStandardResponse = createStandardResponse;
9
+ exports.successResponse = successResponse;
10
+ exports.createdResponse = createdResponse;
11
+ exports.badRequestResponse = badRequestResponse;
12
+ exports.unauthorizedResponse = unauthorizedResponse;
13
+ exports.forbiddenResponse = forbiddenResponse;
14
+ exports.notFoundResponse = notFoundResponse;
15
+ exports.conflictResponse = conflictResponse;
16
+ exports.validationErrorResponse = validationErrorResponse;
17
+ exports.internalErrorResponse = internalErrorResponse;
18
+ exports.customErrorResponse = customErrorResponse;
19
+ /**
20
+ * Standard HTTP status codes
21
+ */
22
+ var HttpStatus;
23
+ (function (HttpStatus) {
24
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
25
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
26
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
27
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
28
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
29
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
30
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
31
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
32
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
33
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
34
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
35
+ })(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
36
+ /**
37
+ * Default response codes for standard HTTP statuses
38
+ */
39
+ exports.DefaultResponseCode = {
40
+ SUCCESS: 'SUCCESS',
41
+ CREATED: 'CREATED',
42
+ BAD_REQUEST: 'BAD_REQUEST',
43
+ UNAUTHORIZED: 'UNAUTHORIZED',
44
+ FORBIDDEN: 'FORBIDDEN',
45
+ NOT_FOUND: 'NOT_FOUND',
46
+ CONFLICT: 'CONFLICT',
47
+ VALIDATION_ERROR: 'VALIDATION_ERROR',
48
+ INTERNAL_ERROR: 'INTERNAL_ERROR',
49
+ };
50
+ /**
51
+ * Creates a standardized HTTP response
52
+ * @param statusCode - HTTP status code
53
+ * @param data - Response payload
54
+ * @param code - Custom response code
55
+ * @param message - Optional message
56
+ * @param headers - Optional headers
57
+ */
58
+ function createStandardResponse(statusCode, data, code, message, headers) {
59
+ const responseCode = code ?? getDefaultCodeForStatus(statusCode);
60
+ const body = {
61
+ status: statusCode,
62
+ code: responseCode,
63
+ ...(data !== undefined && { data }),
64
+ ...(message && { message }),
65
+ };
66
+ return {
67
+ statusCode,
68
+ body: JSON.stringify(body, null, 2),
69
+ headers: {
70
+ 'Content-Type': 'application/json',
71
+ ...headers,
72
+ },
73
+ };
74
+ }
75
+ /**
76
+ * Gets default response code for a status
77
+ */
78
+ function getDefaultCodeForStatus(status) {
79
+ switch (status) {
80
+ case HttpStatus.OK:
81
+ return exports.DefaultResponseCode.SUCCESS;
82
+ case HttpStatus.CREATED:
83
+ return exports.DefaultResponseCode.CREATED;
84
+ case HttpStatus.BAD_REQUEST:
85
+ return exports.DefaultResponseCode.BAD_REQUEST;
86
+ case HttpStatus.UNAUTHORIZED:
87
+ return exports.DefaultResponseCode.UNAUTHORIZED;
88
+ case HttpStatus.FORBIDDEN:
89
+ return exports.DefaultResponseCode.FORBIDDEN;
90
+ case HttpStatus.NOT_FOUND:
91
+ return exports.DefaultResponseCode.NOT_FOUND;
92
+ case HttpStatus.CONFLICT:
93
+ return exports.DefaultResponseCode.CONFLICT;
94
+ case HttpStatus.UNPROCESSABLE_ENTITY:
95
+ return exports.DefaultResponseCode.VALIDATION_ERROR;
96
+ default:
97
+ return exports.DefaultResponseCode.INTERNAL_ERROR;
98
+ }
99
+ }
100
+ /**
101
+ * Success response (200 OK)
102
+ */
103
+ function successResponse(data, code, headers) {
104
+ return createStandardResponse(HttpStatus.OK, data, code ?? exports.DefaultResponseCode.SUCCESS, undefined, headers);
105
+ }
106
+ /**
107
+ * Created response (201 Created)
108
+ */
109
+ function createdResponse(data, code, headers) {
110
+ return createStandardResponse(HttpStatus.CREATED, data, code ?? exports.DefaultResponseCode.CREATED, undefined, headers);
111
+ }
112
+ /**
113
+ * Bad request response (400)
114
+ */
115
+ function badRequestResponse(message, code, headers) {
116
+ return createStandardResponse(HttpStatus.BAD_REQUEST, undefined, code ?? exports.DefaultResponseCode.BAD_REQUEST, message, headers);
117
+ }
118
+ /**
119
+ * Unauthorized response (401)
120
+ */
121
+ function unauthorizedResponse(message, code, headers) {
122
+ return createStandardResponse(HttpStatus.UNAUTHORIZED, undefined, code ?? exports.DefaultResponseCode.UNAUTHORIZED, message, headers);
123
+ }
124
+ /**
125
+ * Forbidden response (403)
126
+ */
127
+ function forbiddenResponse(message, code, headers) {
128
+ return createStandardResponse(HttpStatus.FORBIDDEN, undefined, code ?? exports.DefaultResponseCode.FORBIDDEN, message, headers);
129
+ }
130
+ /**
131
+ * Not found response (404)
132
+ */
133
+ function notFoundResponse(message, code, headers) {
134
+ return createStandardResponse(HttpStatus.NOT_FOUND, undefined, code ?? exports.DefaultResponseCode.NOT_FOUND, message, headers);
135
+ }
136
+ /**
137
+ * Conflict response (409)
138
+ */
139
+ function conflictResponse(message, code, headers) {
140
+ return createStandardResponse(HttpStatus.CONFLICT, undefined, code ?? exports.DefaultResponseCode.CONFLICT, message, headers);
141
+ }
142
+ /**
143
+ * Validation error response (422)
144
+ */
145
+ function validationErrorResponse(message, code, headers) {
146
+ return createStandardResponse(HttpStatus.UNPROCESSABLE_ENTITY, undefined, code ?? exports.DefaultResponseCode.VALIDATION_ERROR, message, headers);
147
+ }
148
+ /**
149
+ * Internal server error response (500)
150
+ */
151
+ function internalErrorResponse(message, code, headers) {
152
+ return createStandardResponse(HttpStatus.INTERNAL_SERVER_ERROR, undefined, code ?? exports.DefaultResponseCode.INTERNAL_ERROR, message, headers);
153
+ }
154
+ /**
155
+ * Custom error response with automatic status resolution
156
+ * @param customCode - Your domain-specific error code
157
+ * @param message - Error message
158
+ * @param codeToStatusMap - Mapping of custom codes to HTTP statuses
159
+ */
160
+ function customErrorResponse(customCode, message, codeToStatusMap, headers) {
161
+ const status = codeToStatusMap?.[customCode] ?? HttpStatus.INTERNAL_SERVER_ERROR;
162
+ return createStandardResponse(status, undefined, customCode, message, headers);
163
+ }
164
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/http/response.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6DH,wDAwBC;AA+BD,0CAEC;AAKD,0CAEC;AAKD,gDAEC;AAKD,oDAEC;AAKD,8CAEC;AAKD,4CAEC;AAKD,4CAEC;AAKD,0DAEC;AAKD,sDAEC;AAQD,kDAQC;AA5LD;;GAEG;AACH,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,yCAAQ,CAAA;IACR,mDAAa,CAAA;IACb,yDAAgB,CAAA;IAChB,2DAAiB,CAAA;IACjB,6DAAkB,CAAA;IAClB,uDAAe,CAAA;IACf,uDAAe,CAAA;IACf,qDAAc,CAAA;IACd,6EAA0B,CAAA;IAC1B,+EAA2B,CAAA;IAC3B,2EAAyB,CAAA;AAC3B,CAAC,EAZW,UAAU,0BAAV,UAAU,QAYrB;AAqBD;;GAEG;AACU,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,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+ * Supports Cognito User Pools and custom authorizers
5
+ */
6
+ /**
7
+ * Extracts identity information from the event's authorizer context
8
+ * @param event - Raw API Gateway event
9
+ * @returns Identity context or undefined if not authenticated
10
+ */
11
+ export declare function extractIdentity(event: any): IdentityContext | undefined;
12
+ /**
13
+ * Extracts the User Pool ID from the issuer URL
14
+ * @param issuer - Cognito issuer URL (e.g., https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxx)
15
+ * @returns User Pool ID or undefined
16
+ */
17
+ export declare function extractUserPoolId(issuer: string | undefined): string | undefined;
18
+ /**
19
+ * Validates that the token issuer matches the expected User Pool
20
+ * @param identity - Extracted identity context
21
+ * @param expectedUserPoolId - Expected User Pool ID
22
+ * @returns True if issuer matches
23
+ */
24
+ export declare function validateIssuer(identity: IdentityContext | undefined, expectedUserPoolId: string): boolean;
25
+ /**
26
+ * Checks if the user belongs to any of the specified groups
27
+ * @param identity - Extracted identity context
28
+ * @param allowedGroups - Groups that grant access
29
+ * @returns True if user is in at least one allowed group
30
+ */
31
+ export declare function hasAnyGroup(identity: IdentityContext | undefined, allowedGroups: string[]): boolean;
32
+ /**
33
+ * Checks if the user belongs to all specified groups
34
+ * @param identity - Extracted identity context
35
+ * @param requiredGroups - Groups required for access
36
+ * @returns True if user is in all required groups
37
+ */
38
+ export declare function hasAllGroups(identity: IdentityContext | undefined, requiredGroups: string[]): boolean;
39
+ //# sourceMappingURL=extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/identity/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,eAAe,GAAG,SAAS,CAcvE;AAcD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAMhF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAKzG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAInG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAIrG"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractIdentity = extractIdentity;
4
+ exports.extractUserPoolId = extractUserPoolId;
5
+ exports.validateIssuer = validateIssuer;
6
+ exports.hasAnyGroup = hasAnyGroup;
7
+ exports.hasAllGroups = hasAllGroups;
8
+ /**
9
+ * Extracts identity context from API Gateway authorizer claims
10
+ * Supports Cognito User Pools and custom authorizers
11
+ */
12
+ /**
13
+ * Extracts identity information from the event's authorizer context
14
+ * @param event - Raw API Gateway event
15
+ * @returns Identity context or undefined if not authenticated
16
+ */
17
+ function extractIdentity(event) {
18
+ const claims = event?.requestContext?.authorizer?.claims;
19
+ if (!claims) {
20
+ return undefined;
21
+ }
22
+ return {
23
+ userId: claims.sub || claims['cognito:username'],
24
+ email: claims.email,
25
+ groups: parseGroups(claims['cognito:groups']),
26
+ issuer: claims.iss,
27
+ claims,
28
+ };
29
+ }
30
+ /**
31
+ * Parses Cognito groups from claims
32
+ * Groups can come as a string or array depending on configuration
33
+ */
34
+ function parseGroups(groups) {
35
+ if (!groups)
36
+ return [];
37
+ if (Array.isArray(groups))
38
+ return groups;
39
+ // Cognito sometimes sends groups as a comma-separated string
40
+ return groups.split(',').map(g => g.trim()).filter(Boolean);
41
+ }
42
+ /**
43
+ * Extracts the User Pool ID from the issuer URL
44
+ * @param issuer - Cognito issuer URL (e.g., https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxx)
45
+ * @returns User Pool ID or undefined
46
+ */
47
+ function extractUserPoolId(issuer) {
48
+ if (!issuer)
49
+ return undefined;
50
+ // Extract the last segment of the issuer URL
51
+ const parts = issuer.split('/');
52
+ return parts[parts.length - 1];
53
+ }
54
+ /**
55
+ * Validates that the token issuer matches the expected User Pool
56
+ * @param identity - Extracted identity context
57
+ * @param expectedUserPoolId - Expected User Pool ID
58
+ * @returns True if issuer matches
59
+ */
60
+ function validateIssuer(identity, expectedUserPoolId) {
61
+ if (!identity?.issuer)
62
+ return false;
63
+ const actualUserPoolId = extractUserPoolId(identity.issuer);
64
+ return actualUserPoolId === expectedUserPoolId;
65
+ }
66
+ /**
67
+ * Checks if the user belongs to any of the specified groups
68
+ * @param identity - Extracted identity context
69
+ * @param allowedGroups - Groups that grant access
70
+ * @returns True if user is in at least one allowed group
71
+ */
72
+ function hasAnyGroup(identity, allowedGroups) {
73
+ if (!identity?.groups || identity.groups.length === 0)
74
+ return false;
75
+ return allowedGroups.some(group => identity.groups?.includes(group));
76
+ }
77
+ /**
78
+ * Checks if the user belongs to all specified groups
79
+ * @param identity - Extracted identity context
80
+ * @param requiredGroups - Groups required for access
81
+ * @returns True if user is in all required groups
82
+ */
83
+ function hasAllGroups(identity, requiredGroups) {
84
+ if (!identity?.groups || identity.groups.length === 0)
85
+ return false;
86
+ return requiredGroups.every(group => identity.groups?.includes(group));
87
+ }
88
+ //# sourceMappingURL=extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../src/identity/extractor.ts"],"names":[],"mappings":";;AAYA,0CAcC;AAmBD,8CAMC;AAQD,wCAKC;AAQD,kCAIC;AAQD,oCAIC;AAtFD;;;GAGG;AAEH;;;;GAIG;AACH,SAAgB,eAAe,CAAC,KAAU;IACxC,MAAM,MAAM,GAAG,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC;IAEzD,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uB;IACxF,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpE,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,QAAqC,EAAE,cAAwB;IAC1F,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpE,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './extractor.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./extractor.js"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * serverless-event-orchestrator
3
+ *
4
+ * A lightweight, type-safe event dispatcher and middleware orchestrator for AWS Lambda.
5
+ * Designed for hexagonal architectures with support for segmented routing,
6
+ * Cognito User Pool validation, and built-in infrastructure middlewares.
7
+ */
8
+ export { dispatchEvent, detectEventType, createOrchestrator } from './dispatcher.js';
9
+ export { EventType, RouteSegment, } from './types/event-type.enum.js';
10
+ export { HttpMethod, MiddlewareFn, RouteConfig, CorsConfig, RateLimitConfig, HttpRouter, SegmentedHttpRouter, SegmentConfig, AdvancedSegmentedRouter, EventBridgeRoutes, LambdaRoutes, SqsRoutes, DispatchRoutes, IdentityContext, RouteMatch, NormalizedEvent, OrchestratorConfig, } from './types/routes.js';
11
+ export { HttpStatus, StandardResponse, HttpResponse, DefaultResponseCode, createStandardResponse, successResponse, createdResponse, badRequestResponse, unauthorizedResponse, forbiddenResponse, notFoundResponse, conflictResponse, validationErrorResponse, internalErrorResponse, customErrorResponse, } from './http/response.js';
12
+ export { parseJsonBody, parseQueryParams, withJsonBodyParser, } from './http/body-parser.js';
13
+ export { isPreflightRequest, createPreflightResponse, applyCorsHeaders, withCors, } from './http/cors.js';
14
+ export { extractIdentity, extractUserPoolId, validateIssuer, hasAnyGroup, hasAllGroups, } from './identity/extractor.js';
15
+ export { matchPath, patternToRegex, hasPathParameters, normalizePath, } from './utils/path-matcher.js';
16
+ export { normalizeHeaders, getHeader, getCorsHeaders, } from './utils/headers.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrF,OAAO,EACL,SAAS,EACT,YAAY,GACb,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,QAAQ,GACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,cAAc,GACf,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * serverless-event-orchestrator
4
+ *
5
+ * A lightweight, type-safe event dispatcher and middleware orchestrator for AWS Lambda.
6
+ * Designed for hexagonal architectures with support for segmented routing,
7
+ * Cognito User Pool validation, and built-in infrastructure middlewares.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getCorsHeaders = exports.getHeader = exports.normalizeHeaders = exports.normalizePath = exports.hasPathParameters = exports.patternToRegex = exports.matchPath = exports.hasAllGroups = exports.hasAnyGroup = exports.validateIssuer = exports.extractUserPoolId = exports.extractIdentity = exports.withCors = exports.applyCorsHeaders = exports.createPreflightResponse = exports.isPreflightRequest = exports.withJsonBodyParser = exports.parseQueryParams = exports.parseJsonBody = exports.customErrorResponse = exports.internalErrorResponse = exports.validationErrorResponse = exports.conflictResponse = exports.notFoundResponse = exports.forbiddenResponse = exports.unauthorizedResponse = exports.badRequestResponse = exports.createdResponse = exports.successResponse = exports.createStandardResponse = exports.DefaultResponseCode = exports.HttpStatus = exports.RouteSegment = exports.EventType = exports.createOrchestrator = exports.detectEventType = void 0;
11
+ // Core dispatcher
12
+ var dispatcher_js_1 = require("./dispatcher.js");
13
+ Object.defineProperty(exports, "dispatchEvent", { enumerable: true, get: function () { return dispatcher_js_1.dispatchEvent; } });
14
+ Object.defineProperty(exports, "detectEventType", { enumerable: true, get: function () { return dispatcher_js_1.detectEventType; } });
15
+ Object.defineProperty(exports, "createOrchestrator", { enumerable: true, get: function () { return dispatcher_js_1.createOrchestrator; } });
16
+ // Types
17
+ var event_type_enum_js_1 = require("./types/event-type.enum.js");
18
+ Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return event_type_enum_js_1.EventType; } });
19
+ Object.defineProperty(exports, "RouteSegment", { enumerable: true, get: function () { return event_type_enum_js_1.RouteSegment; } });
20
+ // HTTP utilities
21
+ var response_js_1 = require("./http/response.js");
22
+ Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return response_js_1.HttpStatus; } });
23
+ Object.defineProperty(exports, "DefaultResponseCode", { enumerable: true, get: function () { return response_js_1.DefaultResponseCode; } });
24
+ Object.defineProperty(exports, "createStandardResponse", { enumerable: true, get: function () { return response_js_1.createStandardResponse; } });
25
+ Object.defineProperty(exports, "successResponse", { enumerable: true, get: function () { return response_js_1.successResponse; } });
26
+ Object.defineProperty(exports, "createdResponse", { enumerable: true, get: function () { return response_js_1.createdResponse; } });
27
+ Object.defineProperty(exports, "badRequestResponse", { enumerable: true, get: function () { return response_js_1.badRequestResponse; } });
28
+ Object.defineProperty(exports, "unauthorizedResponse", { enumerable: true, get: function () { return response_js_1.unauthorizedResponse; } });
29
+ Object.defineProperty(exports, "forbiddenResponse", { enumerable: true, get: function () { return response_js_1.forbiddenResponse; } });
30
+ Object.defineProperty(exports, "notFoundResponse", { enumerable: true, get: function () { return response_js_1.notFoundResponse; } });
31
+ Object.defineProperty(exports, "conflictResponse", { enumerable: true, get: function () { return response_js_1.conflictResponse; } });
32
+ Object.defineProperty(exports, "validationErrorResponse", { enumerable: true, get: function () { return response_js_1.validationErrorResponse; } });
33
+ Object.defineProperty(exports, "internalErrorResponse", { enumerable: true, get: function () { return response_js_1.internalErrorResponse; } });
34
+ Object.defineProperty(exports, "customErrorResponse", { enumerable: true, get: function () { return response_js_1.customErrorResponse; } });
35
+ var body_parser_js_1 = require("./http/body-parser.js");
36
+ Object.defineProperty(exports, "parseJsonBody", { enumerable: true, get: function () { return body_parser_js_1.parseJsonBody; } });
37
+ Object.defineProperty(exports, "parseQueryParams", { enumerable: true, get: function () { return body_parser_js_1.parseQueryParams; } });
38
+ Object.defineProperty(exports, "withJsonBodyParser", { enumerable: true, get: function () { return body_parser_js_1.withJsonBodyParser; } });
39
+ var cors_js_1 = require("./http/cors.js");
40
+ Object.defineProperty(exports, "isPreflightRequest", { enumerable: true, get: function () { return cors_js_1.isPreflightRequest; } });
41
+ Object.defineProperty(exports, "createPreflightResponse", { enumerable: true, get: function () { return cors_js_1.createPreflightResponse; } });
42
+ Object.defineProperty(exports, "applyCorsHeaders", { enumerable: true, get: function () { return cors_js_1.applyCorsHeaders; } });
43
+ Object.defineProperty(exports, "withCors", { enumerable: true, get: function () { return cors_js_1.withCors; } });
44
+ // Identity utilities
45
+ var extractor_js_1 = require("./identity/extractor.js");
46
+ Object.defineProperty(exports, "extractIdentity", { enumerable: true, get: function () { return extractor_js_1.extractIdentity; } });
47
+ Object.defineProperty(exports, "extractUserPoolId", { enumerable: true, get: function () { return extractor_js_1.extractUserPoolId; } });
48
+ Object.defineProperty(exports, "validateIssuer", { enumerable: true, get: function () { return extractor_js_1.validateIssuer; } });
49
+ Object.defineProperty(exports, "hasAnyGroup", { enumerable: true, get: function () { return extractor_js_1.hasAnyGroup; } });
50
+ Object.defineProperty(exports, "hasAllGroups", { enumerable: true, get: function () { return extractor_js_1.hasAllGroups; } });
51
+ // Path utilities
52
+ var path_matcher_js_1 = require("./utils/path-matcher.js");
53
+ Object.defineProperty(exports, "matchPath", { enumerable: true, get: function () { return path_matcher_js_1.matchPath; } });
54
+ Object.defineProperty(exports, "patternToRegex", { enumerable: true, get: function () { return path_matcher_js_1.patternToRegex; } });
55
+ Object.defineProperty(exports, "hasPathParameters", { enumerable: true, get: function () { return path_matcher_js_1.hasPathParameters; } });
56
+ Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return path_matcher_js_1.normalizePath; } });
57
+ // Header utilities
58
+ var headers_js_1 = require("./utils/headers.js");
59
+ Object.defineProperty(exports, "normalizeHeaders", { enumerable: true, get: function () { return headers_js_1.normalizeHeaders; } });
60
+ Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return headers_js_1.getHeader; } });
61
+ Object.defineProperty(exports, "getCorsHeaders", { enumerable: true, get: function () { return headers_js_1.getCorsHeaders; } });
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,kBAAkB;AAClB,iDAAqF;AAA5E,8GAAA,aAAa,OAAA;AAAE,gHAAA,eAAe,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAE3D,QAAQ;AACR,iEAGoC;AAFlC,+GAAA,SAAS,OAAA;AACT,kHAAA,YAAY,OAAA;AAuBd,iBAAiB;AACjB,kDAgB4B;AAf1B,yGAAA,UAAU,OAAA;AAGV,kHAAA,mBAAmB,OAAA;AACnB,qHAAA,sBAAsB,OAAA;AACtB,8GAAA,eAAe,OAAA;AACf,8GAAA,eAAe,OAAA;AACf,iHAAA,kBAAkB,OAAA;AAClB,mHAAA,oBAAoB,OAAA;AACpB,gHAAA,iBAAiB,OAAA;AACjB,+GAAA,gBAAgB,OAAA;AAChB,+GAAA,gBAAgB,OAAA;AAChB,sHAAA,uBAAuB,OAAA;AACvB,oHAAA,qBAAqB,OAAA;AACrB,kHAAA,mBAAmB,OAAA;AAGrB,wDAI+B;AAH7B,+GAAA,aAAa,OAAA;AACb,kHAAA,gBAAgB,OAAA;AAChB,oHAAA,kBAAkB,OAAA;AAGpB,0CAKwB;AAJtB,6GAAA,kBAAkB,OAAA;AAClB,kHAAA,uBAAuB,OAAA;AACvB,2GAAA,gBAAgB,OAAA;AAChB,mGAAA,QAAQ,OAAA;AAGV,qBAAqB;AACrB,wDAMiC;AAL/B,+GAAA,eAAe,OAAA;AACf,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,2GAAA,WAAW,OAAA;AACX,4GAAA,YAAY,OAAA;AAGd,iBAAiB;AACjB,2DAKiC;AAJ/B,4GAAA,SAAS,OAAA;AACT,iHAAA,cAAc,OAAA;AACd,oHAAA,iBAAiB,OAAA;AACjB,gHAAA,aAAa,OAAA;AAGf,mBAAmB;AACnB,iDAI4B;AAH1B,8GAAA,gBAAgB,OAAA;AAChB,uGAAA,SAAS,OAAA;AACT,4GAAA,cAAc,OAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Supported AWS event types for dispatching
3
+ */
4
+ export declare enum EventType {
5
+ EventBridge = "eventbridge",
6
+ ApiGateway = "apigateway",
7
+ Lambda = "lambda",
8
+ Sqs = "sqs",
9
+ Unknown = "unknown"
10
+ }
11
+ /**
12
+ * Route segments for access control categorization
13
+ */
14
+ export declare enum RouteSegment {
15
+ Public = "public",
16
+ Private = "private",
17
+ Backoffice = "backoffice",
18
+ Internal = "internal"
19
+ }
20
+ //# sourceMappingURL=event-type.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-type.enum.d.ts","sourceRoot":"","sources":["../../src/types/event-type.enum.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,SAAS;IACnB,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,QAAQ,aAAa;CACtB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouteSegment = exports.EventType = void 0;
4
+ /**
5
+ * Supported AWS event types for dispatching
6
+ */
7
+ var EventType;
8
+ (function (EventType) {
9
+ EventType["EventBridge"] = "eventbridge";
10
+ EventType["ApiGateway"] = "apigateway";
11
+ EventType["Lambda"] = "lambda";
12
+ EventType["Sqs"] = "sqs";
13
+ EventType["Unknown"] = "unknown";
14
+ })(EventType || (exports.EventType = EventType = {}));
15
+ /**
16
+ * Route segments for access control categorization
17
+ */
18
+ var RouteSegment;
19
+ (function (RouteSegment) {
20
+ RouteSegment["Public"] = "public";
21
+ RouteSegment["Private"] = "private";
22
+ RouteSegment["Backoffice"] = "backoffice";
23
+ RouteSegment["Internal"] = "internal";
24
+ })(RouteSegment || (exports.RouteSegment = RouteSegment = {}));
25
+ //# sourceMappingURL=event-type.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-type.enum.js","sourceRoot":"","sources":["../../src/types/event-type.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,sCAAyB,CAAA;IACzB,8BAAiB,CAAA;IACjB,wBAAW,CAAA;IACX,gCAAmB,CAAA;AACrB,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;AAED;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;IACzB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB"}
@@ -0,0 +1,3 @@
1
+ export * from './event-type.enum.js';
2
+ export * from './routes.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./event-type.enum.js"), exports);
18
+ __exportStar(require("./routes.js"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,8CAA4B"}