ts-ag 1.0.5 → 1.0.7
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.
- package/README.md +2 -5
- package/dist/cognito/errors.d.ts.map +1 -1
- package/dist/cognito/errors.js +14 -56
- package/dist/cognito/password.d.ts.map +1 -1
- package/dist/cognito/password.js +3 -12
- package/dist/cognito/user.d.ts.map +1 -1
- package/dist/cognito/user.js +1 -4
- package/dist/dynamo/errors.d.ts.map +1 -1
- package/dist/dynamo/errors.js +1 -3
- package/dist/lambda/client-types.d.ts +17 -17
- package/dist/lambda/client-types.d.ts.map +1 -1
- package/dist/lambda/client-types.js +1 -9
- package/dist/lambda/client.d.ts.map +1 -1
- package/dist/lambda/client.js +4 -5
- package/dist/lambda/deserializer.d.ts +1 -2
- package/dist/lambda/deserializer.d.ts.map +1 -1
- package/dist/lambda/deserializer.js +12 -11
- package/dist/lambda/errors.d.ts +3 -3
- package/dist/lambda/errors.d.ts.map +1 -1
- package/dist/lambda/errors.js +3 -12
- package/dist/lambda/handlerUtils.d.ts.map +1 -1
- package/dist/lambda/handlerUtils.js +1 -4
- package/dist/lambda/response.d.ts.map +1 -1
- package/dist/lambda/response.js +8 -69
- package/dist/lambda/serializer.d.ts +1 -6
- package/dist/lambda/serializer.d.ts.map +1 -1
- package/dist/lambda/serializer.js +15 -15
- package/dist/lambda/server/authentication.d.ts +1 -1
- package/dist/rehype/browser.d.ts.map +1 -1
- package/dist/rehype/flat-toc.d.ts.map +1 -1
- package/dist/rehype/flat-toc.js +1 -7
- package/dist/rehype/index.d.ts.map +1 -1
- package/dist/s3/errors.d.ts.map +1 -1
- package/dist/s3/errors.js +2 -6
- package/dist/scripts/clean-dist.d.ts +3 -0
- package/dist/scripts/clean-dist.d.ts.map +1 -0
- package/dist/scripts/{clean.js → clean-dist.js} +6 -4
- package/dist/scripts/ts-alias.js +17 -26
- package/dist/ses/errors.d.ts.map +1 -1
- package/dist/ses/errors.js +1 -3
- package/dist/utils/valibot.js +1 -1
- package/package.json +69 -58
- package/src/cognito/errors.ts +14 -56
- package/src/cognito/password.ts +3 -12
- package/src/cognito/user.ts +1 -4
- package/src/dynamo/errors.ts +1 -3
- package/src/lambda/client-types.ts +26 -64
- package/src/lambda/client.ts +3 -5
- package/src/lambda/deserializer.ts +11 -11
- package/src/lambda/errors.ts +3 -12
- package/src/lambda/handlerUtils.ts +4 -21
- package/src/lambda/response.ts +8 -69
- package/src/lambda/serializer.ts +14 -14
- package/src/rehype/browser.ts +1 -1
- package/src/rehype/flat-toc.ts +5 -21
- package/src/rehype/index.ts +1 -1
- package/src/s3/errors.ts +2 -6
- package/src/scripts/{clean.ts → clean-dist.ts} +8 -6
- package/src/scripts/ts-alias.ts +19 -27
- package/src/ses/errors.ts +1 -3
- package/src/utils/valibot.ts +1 -1
- package/dist/lambda/authentication.d.ts +0 -2
- package/dist/lambda/authentication.d.ts.map +0 -1
- package/dist/lambda/authentication.js +0 -1
- package/dist/scripts/clean.d.ts +0 -3
- package/dist/scripts/clean.d.ts.map +0 -1
- package/dist/ts-alias.d.ts +0 -3
- package/dist/ts-alias.d.ts.map +0 -1
- package/dist/ts-alias.js +0 -167
- package/dist/types/optional.d.ts +0 -4
- package/dist/types/optional.d.ts.map +0 -1
- package/dist/types/optional.js +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
# Typescript
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`svelte.config.js` the aliases are added just for typescript, so that they are not resolved by the packaging process.
|
|
5
|
-
|
|
6
|
-
This allows consumers to bring their own shadcn components just so long as they resolve `$shadcn`
|
|
3
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/cognito/errors.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,uBAAuB;;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRo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AwC,GAAG,OAAO,mCAAmC,CAAC;AAClG,MAAM,MAAM,8BAA8B,GAAG,OAAO,yBAAyB,CAAC;AAC9E,MAAM,MAAM,+BAA+B,GAAG,OAAO,0BAA0B,CAAC;AAChF,MAAM,MAAM,2BAA2B,GAAG,OAAO,sBAAsB,CAAC;AACxE,MAAM,MAAM,6BAA6B,GAAG,OAAO,wBAAwB,CAAC;AAE5E,MAAM,MAAM,kBAAkB,GAC1B,4BAA4B,GAC5B,2BAA2B,GAC3B,uBAAuB,GACvB,wBAAwB,GACxB,uBAAuB,GACvB,2BAA2B,GAC3B,+BAA+B,GAC/B,kCAAkC,GAClC,iCAAiC,GACjC,kCAAkC,GAClC,wCAAwC,GACxC,8BAA8B,GAC9B,+BAA+B,GAC/B,2BAA2B,GAC3B,6BAA6B,CAAC;AAuClC;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB,CAO9D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;EA4B7D"}
|
package/dist/cognito/errors.js
CHANGED
|
@@ -1,67 +1,25 @@
|
|
|
1
1
|
import { error_lambda_badRequest, error_lambda_conflict, error_lambda_internal, error_lambda_unauthorized, error_lambda_forbidden, error_lambda_notFound } from '../lambda/errors.js';
|
|
2
|
-
export const error_cognito_forbidden = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
type: 'cognito_role'
|
|
13
|
-
};
|
|
14
|
-
export const error_cognito_input = {
|
|
15
|
-
group: 'cognito',
|
|
16
|
-
type: 'cognito_input'
|
|
17
|
-
};
|
|
18
|
-
export const error_cognito_auth = {
|
|
19
|
-
group: 'cognito',
|
|
20
|
-
type: 'cognito_auth'
|
|
21
|
-
};
|
|
22
|
-
export const error_cognito_notFound = {
|
|
23
|
-
group: 'cognito',
|
|
24
|
-
type: 'cognito_notFound'
|
|
25
|
-
};
|
|
26
|
-
export const error_cognito_userNotFound = {
|
|
27
|
-
group: 'cognito',
|
|
28
|
-
type: 'cognito_userNotFound'
|
|
29
|
-
};
|
|
30
|
-
export const error_cognito_tooManyRequests = {
|
|
31
|
-
group: 'cognito',
|
|
32
|
-
type: 'cognito_tooManyRequests'
|
|
33
|
-
};
|
|
34
|
-
export const error_cognito_passwordPolicy = {
|
|
35
|
-
group: 'cognito',
|
|
36
|
-
type: 'cognito_passwordPolicy'
|
|
37
|
-
};
|
|
38
|
-
export const error_cognito_passwordHistory = {
|
|
39
|
-
group: 'cognito',
|
|
40
|
-
type: 'cognito_passwordHistory'
|
|
41
|
-
};
|
|
2
|
+
export const error_cognito_forbidden = { group: 'cognito', type: 'cognito_forbidden' };
|
|
3
|
+
export const error_cognito_internal = { group: 'cognito', type: 'cognito_internal' };
|
|
4
|
+
export const error_cognito_role = { group: 'cognito', type: 'cognito_role' };
|
|
5
|
+
export const error_cognito_input = { group: 'cognito', type: 'cognito_input' };
|
|
6
|
+
export const error_cognito_auth = { group: 'cognito', type: 'cognito_auth' };
|
|
7
|
+
export const error_cognito_notFound = { group: 'cognito', type: 'cognito_notFound' };
|
|
8
|
+
export const error_cognito_userNotFound = { group: 'cognito', type: 'cognito_userNotFound' };
|
|
9
|
+
export const error_cognito_tooManyRequests = { group: 'cognito', type: 'cognito_tooManyRequests' };
|
|
10
|
+
export const error_cognito_passwordPolicy = { group: 'cognito', type: 'cognito_passwordPolicy' };
|
|
11
|
+
export const error_cognito_passwordHistory = { group: 'cognito', type: 'cognito_passwordHistory' };
|
|
42
12
|
export const error_cognito_passwordResetRequired = {
|
|
43
13
|
group: 'cognito',
|
|
44
14
|
type: 'cognito_passwordResetRequired'
|
|
45
15
|
};
|
|
46
16
|
// Confirm forgot password
|
|
47
|
-
export const error_cognito_codeExpired = {
|
|
48
|
-
|
|
49
|
-
type: 'cognito_codeExpired'
|
|
50
|
-
};
|
|
51
|
-
export const error_cognito_codeMismatch = {
|
|
52
|
-
group: 'cognito',
|
|
53
|
-
type: 'cognito_codeMismatch'
|
|
54
|
-
};
|
|
17
|
+
export const error_cognito_codeExpired = { group: 'cognito', type: 'cognito_codeExpired' };
|
|
18
|
+
export const error_cognito_codeMismatch = { group: 'cognito', type: 'cognito_codeMismatch' };
|
|
55
19
|
// Forgot password
|
|
56
|
-
export const error_cognito_delivery = {
|
|
57
|
-
group: 'cognito',
|
|
58
|
-
type: 'cognito_delivery'
|
|
59
|
-
};
|
|
20
|
+
export const error_cognito_delivery = { group: 'cognito', type: 'cognito_delivery' };
|
|
60
21
|
// Confirm signup
|
|
61
|
-
export const error_cognito_userExists = {
|
|
62
|
-
group: 'cognito',
|
|
63
|
-
type: 'cognito_userExists'
|
|
64
|
-
};
|
|
22
|
+
export const error_cognito_userExists = { group: 'cognito', type: 'cognito_userExists' };
|
|
65
23
|
const awsToCognitoErrorMap = {
|
|
66
24
|
ForbiddenException: error_cognito_forbidden,
|
|
67
25
|
NotAuthorizedException: error_cognito_auth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/cognito/password.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKlG;AAID;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,qLAe1B,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/cognito/password.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKlG;AAID;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,qLAe1B,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;;;;6HAiBjC,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;qHAgBzB,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;sHAe1B,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;;;;;;yHAoBjB,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;;;;yHAmBzB,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,MAAM,0IAUlB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;;;;8HAoBzB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;wIAqBlB,CAAC;AAGF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAmC5B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;EAgC7B,CAAC"}
|
package/dist/cognito/password.js
CHANGED
|
@@ -209,10 +209,7 @@ export const signUp = ResultAsync.fromThrowable((a) => {
|
|
|
209
209
|
SecretHash: secretHash,
|
|
210
210
|
UserAttributes: Object.entries(a)
|
|
211
211
|
.filter(([key]) => !['username', 'password', 'clientId', 'clientSecret'].includes(key))
|
|
212
|
-
.map(([key, value]) => ({
|
|
213
|
-
Name: key,
|
|
214
|
-
Value: value
|
|
215
|
-
}))
|
|
212
|
+
.map(([key, value]) => ({ Name: key, Value: value }))
|
|
216
213
|
}));
|
|
217
214
|
}, (e) => {
|
|
218
215
|
console.error('SignUpCommand error', e);
|
|
@@ -240,10 +237,7 @@ export const verifyOAuthToken = ResultAsync.fromThrowable(async (a) => {
|
|
|
240
237
|
console.log('verifyOAuthToken: params', params.toString());
|
|
241
238
|
const tokenRes = await fetch(`https://${a.cognitoDomain}/oauth2/token`, {
|
|
242
239
|
method: 'POST',
|
|
243
|
-
headers: {
|
|
244
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
245
|
-
Authorization: `Basic ${basicAuth}`
|
|
246
|
-
},
|
|
240
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded', Authorization: `Basic ${basicAuth}` },
|
|
247
241
|
body: params.toString()
|
|
248
242
|
});
|
|
249
243
|
if (!tokenRes.ok) {
|
|
@@ -273,10 +267,7 @@ export const refreshOAuthToken = ResultAsync.fromThrowable(async (a) => {
|
|
|
273
267
|
console.log('refreshOAuthToken: params', params.toString());
|
|
274
268
|
const tokenRes = await fetch(`https://${a.cognitoDomain}/oauth2/token`, {
|
|
275
269
|
method: 'POST',
|
|
276
|
-
headers: {
|
|
277
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
278
|
-
Authorization: `Basic ${basicAuth}`
|
|
279
|
-
},
|
|
270
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded', Authorization: `Basic ${basicAuth}` },
|
|
280
271
|
body: params.toString()
|
|
281
272
|
});
|
|
282
273
|
if (!tokenRes.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/cognito/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EAEd,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,GAAG;IAClF,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/cognito/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EAEd,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,GAAG;IAClF,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;8EAW1B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,0BAUnE;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;oJAazB,CAAC"}
|
package/dist/cognito/user.js
CHANGED
|
@@ -9,10 +9,7 @@ export const getUserDetails = ResultAsync.fromThrowable(async (a) => {
|
|
|
9
9
|
console.log('getUserDetails: Getting details for user: ', a.username);
|
|
10
10
|
const cognitoClient = getCognitoClient();
|
|
11
11
|
const res = await cognitoClient.send(new AdminGetUserCommand({ UserPoolId: a.userPoolId, Username: a.username }));
|
|
12
|
-
return {
|
|
13
|
-
...res,
|
|
14
|
-
UserAttributes: extractAttributes(res.UserAttributes)
|
|
15
|
-
};
|
|
12
|
+
return { ...res, UserAttributes: extractAttributes(res.UserAttributes) };
|
|
16
13
|
}, (e) => {
|
|
17
14
|
console.error('getUserDetails:error:', e);
|
|
18
15
|
return error_cognito(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/dynamo/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/dynamo/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;CAA8B,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC;AAEpD,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,iBAAiB;;;EAE3D"}
|
package/dist/dynamo/errors.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { error_lambda_internal } from '../lambda/errors.js';
|
|
2
|
-
export const error_dynamo = {
|
|
3
|
-
type: 'dynamo'
|
|
4
|
-
};
|
|
2
|
+
export const error_dynamo = { type: 'dynamo' };
|
|
5
3
|
export function error_lambda_fromDynamo(e) {
|
|
6
4
|
return error_lambda_internal('Internal server error');
|
|
7
5
|
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import type { ErrorBody, SuccessCode, ErrorCode } from
|
|
1
|
+
import type { ErrorBody, SuccessCode, ErrorCode } from './handlerUtils.js';
|
|
2
2
|
/**
|
|
3
3
|
* Extracts the requestInput type from an API endpoint definition
|
|
4
4
|
* @template E - Union type of all API endpoints
|
|
5
5
|
* @template P - Path string literal type (e.g. 'payments/account')
|
|
6
6
|
* @template M - HTTP method string literal type (e.g. 'GET', 'POST')
|
|
7
7
|
*/
|
|
8
|
-
export type ApiInput<E extends ApiEndpoints, P extends E[
|
|
8
|
+
export type ApiInput<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = Extract<E, {
|
|
9
9
|
path: P;
|
|
10
10
|
method: M;
|
|
11
|
-
}>[
|
|
11
|
+
}>['requestInput'];
|
|
12
12
|
/**
|
|
13
13
|
* Extracts the requestOutput type from an API endpoint definition
|
|
14
14
|
* @template E - Union type of all API endpoints
|
|
15
15
|
* @template P - Path string literal type (e.g. 'payments/account')
|
|
16
16
|
* @template M - HTTP method string literal type (e.g. 'GET', 'POST')
|
|
17
17
|
*/
|
|
18
|
-
export type ApiOutput<E extends ApiEndpoints, P extends E[
|
|
18
|
+
export type ApiOutput<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = Extract<E, {
|
|
19
19
|
path: P;
|
|
20
20
|
method: M;
|
|
21
|
-
}>[
|
|
21
|
+
}>['requestOutput'];
|
|
22
22
|
/**
|
|
23
23
|
* Extracts the response type from an API endpoint definition
|
|
24
24
|
* @template E - Union type of all API endpoints
|
|
25
25
|
* @template P - Path string literal type (e.g. 'payments/account')
|
|
26
26
|
* @template M - HTTP method string literal type (e.g. 'GET', 'POST')
|
|
27
27
|
*/
|
|
28
|
-
export type ApiResponse<E extends ApiEndpoints, P extends E[
|
|
28
|
+
export type ApiResponse<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = Extract<E, {
|
|
29
29
|
path: P;
|
|
30
30
|
method: M;
|
|
31
|
-
}>[
|
|
31
|
+
}>['response'];
|
|
32
32
|
/**
|
|
33
33
|
* Extracts the sucessful body type from an API endpoint definition
|
|
34
34
|
* @template E - Union type of all API endpoints
|
|
35
35
|
* @template P - Path string literal type (e.g. 'payments/account')
|
|
36
36
|
* @template M - HTTP method string literal type (e.g. 'GET', 'POST')
|
|
37
37
|
*/
|
|
38
|
-
export type ApiSuccessBody<E extends ApiEndpoints, P extends E[
|
|
38
|
+
export type ApiSuccessBody<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = Extract<Extract<E, {
|
|
39
39
|
path: P;
|
|
40
40
|
method: M;
|
|
41
|
-
}>[
|
|
41
|
+
}>['response'], {
|
|
42
42
|
status: SuccessCode;
|
|
43
|
-
}>[
|
|
43
|
+
}>['json'] extends () => Promise<infer R> ? R : unknown;
|
|
44
44
|
/**
|
|
45
45
|
* Extracts the sucessful body type from an API endpoint definition
|
|
46
46
|
* @template E - Union type of all API endpoints
|
|
47
47
|
* @template P - Path string literal type (e.g. 'payments/account')
|
|
48
48
|
* @template M - HTTP method string literal type (e.g. 'GET', 'POST')
|
|
49
49
|
*/
|
|
50
|
-
export type ApiErrorBody<E extends ApiEndpoints, P extends E[
|
|
50
|
+
export type ApiErrorBody<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = Extract<Extract<E, {
|
|
51
51
|
path: P;
|
|
52
52
|
method: M;
|
|
53
|
-
}>[
|
|
53
|
+
}>['response'], {
|
|
54
54
|
status: ErrorCode;
|
|
55
|
-
}>[
|
|
55
|
+
}>['json'] extends () => Promise<infer R> ? R : unknown;
|
|
56
56
|
/**
|
|
57
57
|
* Converts a RawApiGatewayHandler response type to a fetch like response type.
|
|
58
58
|
*/
|
|
@@ -61,11 +61,11 @@ type ConvertToFetch<T> = T extends {
|
|
|
61
61
|
body: object;
|
|
62
62
|
headers: object;
|
|
63
63
|
} ? {
|
|
64
|
-
ok: T[
|
|
65
|
-
json: () => Promise<T[
|
|
66
|
-
status: T[
|
|
64
|
+
ok: T['statusCode'] extends SuccessCode ? true : false;
|
|
65
|
+
json: () => Promise<T['body']>;
|
|
66
|
+
status: T['statusCode'];
|
|
67
67
|
} : T;
|
|
68
|
-
export type CleanResponse = Omit<Response,
|
|
68
|
+
export type CleanResponse = Omit<Response, 'status' | 'ok' | 'json'>;
|
|
69
69
|
export type FetchResponse<T extends (...args: any) => any> = ConvertToFetch<Awaited<ReturnType<T>>> & CleanResponse;
|
|
70
70
|
export declare const HTTPMethods: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"];
|
|
71
71
|
export type HTTPMethod = (typeof HTTPMethods)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-types.d.ts","sourceRoot":"","sources":["../../src/lambda/client-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK3E;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"client-types.d.ts","sourceRoot":"","sources":["../../src/lambda/client-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE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C,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACzC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,aAAa,CAErB,MAAM,OAAO,CACT;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,GACvD;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,CAC9D,CACF,CAAC;CACH,CAAC"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
// ------------------------ Proper types ------------------
|
|
2
2
|
// This is used by createApiRequest and createFormFunction
|
|
3
|
-
export const HTTPMethods = [
|
|
4
|
-
"GET",
|
|
5
|
-
"POST",
|
|
6
|
-
"PUT",
|
|
7
|
-
"DELETE",
|
|
8
|
-
"PATCH",
|
|
9
|
-
"OPTIONS",
|
|
10
|
-
"HEAD",
|
|
11
|
-
];
|
|
3
|
+
export const HTTPMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lambda/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lambda/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA0D7E,QAAA,MAAM,WAAW,uEAAwE,CAAC;AAC1F,KAAK,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,MAAM,kBAAkB,CAAC,GAAG,SAAS,YAAY,IAAI,CACzD,IAAI,SAAS,GAAG,CAAC,MAAM,CAAC,EACxB,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,EAErD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,YAAY,EACvD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7E,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,kBAAkB,CAAC,GAAG,CAAC,CAmBzB"}
|
package/dist/lambda/client.js
CHANGED
|
@@ -3,7 +3,9 @@ import { parse } from 'devalue';
|
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
const bodyMethods = ['POST', 'PUT', 'PATCH'];
|
|
5
5
|
const queryMethods = ['GET', 'DELETE'];
|
|
6
|
-
async function _apiRequest(path, method, input, schema,
|
|
6
|
+
async function _apiRequest(path, method, input, schema,
|
|
7
|
+
// This was here because of the deserializer being different in prod
|
|
8
|
+
environment, apiUrl, headers) {
|
|
7
9
|
if (schema) {
|
|
8
10
|
if (schema.async === true)
|
|
9
11
|
v.parseAsync(schema, input);
|
|
@@ -25,10 +27,7 @@ async function _apiRequest(path, method, input, schema, environment, apiUrl, hea
|
|
|
25
27
|
if (queryString)
|
|
26
28
|
url += `?${queryString}`;
|
|
27
29
|
}
|
|
28
|
-
headers = {
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
...(headers || {})
|
|
31
|
-
};
|
|
30
|
+
headers = { 'Content-Type': 'application/json', ...(headers || {}) };
|
|
32
31
|
const response = await fetch(url, {
|
|
33
32
|
method,
|
|
34
33
|
headers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../src/lambda/deserializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../src/lambda/deserializer.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
export {};
|
|
2
|
+
// async function deserialize(data: string, env: string | 'production'): Promise<any> {
|
|
3
|
+
// if (env === 'production') {
|
|
4
|
+
// const { parse: prodParse } = await import('@ungap/structured-clone/json');
|
|
5
|
+
// return prodParse(data);
|
|
6
|
+
// } else {
|
|
7
|
+
// const cycle = await import('cycle');
|
|
8
|
+
// return JSON.parse(cycle.default.retrocycle(data));
|
|
9
|
+
// }
|
|
10
|
+
// }
|
|
11
|
+
//
|
|
12
|
+
// export { deserialize };
|
package/dist/lambda/errors.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The separation means that they can be returned from functions that are certainly run inside a lambda fucntion but theyre not the actual return of the lambda.
|
|
7
7
|
* Im not sure it this is optimal behaviour and if not we will migrate to only using the errorResponse function
|
|
8
8
|
*/
|
|
9
|
-
export declare const error_lambda_badRequest: (message: string, fieldName?: string, fieldValue?: string) => {
|
|
9
|
+
export declare const error_lambda_badRequest: (message: string, fieldName?: string | undefined, fieldValue?: string | undefined) => {
|
|
10
10
|
type: "lambda_badRequest";
|
|
11
11
|
message: string;
|
|
12
12
|
fieldName: string | undefined;
|
|
@@ -20,13 +20,13 @@ export declare const error_lambda_forbidden: (message: string) => {
|
|
|
20
20
|
type: "lambda_forbidden";
|
|
21
21
|
message: string;
|
|
22
22
|
};
|
|
23
|
-
export declare const error_lambda_notFound: (message: string, fieldName?: string, fieldValue?: string) => {
|
|
23
|
+
export declare const error_lambda_notFound: (message: string, fieldName?: string | undefined, fieldValue?: string | undefined) => {
|
|
24
24
|
type: "lambda_notFound";
|
|
25
25
|
message: string;
|
|
26
26
|
fieldName: string | undefined;
|
|
27
27
|
fieldValue: string | undefined;
|
|
28
28
|
};
|
|
29
|
-
export declare const error_lambda_conflict: (message: string, fieldName?: string, fieldValue?: string) => {
|
|
29
|
+
export declare const error_lambda_conflict: (message: string, fieldName?: string | undefined, fieldValue?: string | undefined) => {
|
|
30
30
|
type: "lambda_conflict";
|
|
31
31
|
message: string;
|
|
32
32
|
fieldName: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lambda/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lambda/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,uBAAuB;;;;;CAKlC,CAAC;AACH,eAAO,MAAM,yBAAyB;;;CAA2E,CAAC;AAElH,eAAO,MAAM,sBAAsB;;;CAAwE,CAAC;AAE5G,eAAO,MAAM,qBAAqB;;;;;CAKhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;CAKhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;CAAuE,CAAC;AAE1G,MAAM,MAAM,4BAA4B,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACtF,MAAM,MAAM,8BAA8B,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC1F,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACpF,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAClF,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAClF,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAElF,MAAM,MAAM,iBAAiB,GACzB,4BAA4B,GAC5B,8BAA8B,GAC9B,2BAA2B,GAC3B,0BAA0B,GAC1B,0BAA0B,GAC1B,0BAA0B,CAAC"}
|
package/dist/lambda/errors.js
CHANGED
|
@@ -12,14 +12,8 @@ export const error_lambda_badRequest = (message, fieldName, fieldValue) => ({
|
|
|
12
12
|
fieldName,
|
|
13
13
|
fieldValue
|
|
14
14
|
});
|
|
15
|
-
export const error_lambda_unauthorized = (message) => ({
|
|
16
|
-
|
|
17
|
-
message
|
|
18
|
-
});
|
|
19
|
-
export const error_lambda_forbidden = (message) => ({
|
|
20
|
-
type: 'lambda_forbidden',
|
|
21
|
-
message
|
|
22
|
-
});
|
|
15
|
+
export const error_lambda_unauthorized = (message) => ({ type: 'lambda_unauthorized', message });
|
|
16
|
+
export const error_lambda_forbidden = (message) => ({ type: 'lambda_forbidden', message });
|
|
23
17
|
export const error_lambda_notFound = (message, fieldName, fieldValue) => ({
|
|
24
18
|
type: 'lambda_notFound',
|
|
25
19
|
message,
|
|
@@ -32,7 +26,4 @@ export const error_lambda_conflict = (message, fieldName, fieldValue) => ({
|
|
|
32
26
|
fieldName,
|
|
33
27
|
fieldValue
|
|
34
28
|
});
|
|
35
|
-
export const error_lambda_internal = (message) => ({
|
|
36
|
-
type: 'lambda_internal',
|
|
37
|
-
message
|
|
38
|
-
});
|
|
29
|
+
export const error_lambda_internal = (message) => ({ type: 'lambda_internal', message });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlerUtils.d.ts","sourceRoot":"","sources":["../../src/lambda/handlerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAInE,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC1C,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"handlerUtils.d.ts","sourceRoot":"","sources":["../../src/lambda/handlerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAInE,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC1C,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACtE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACtE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAChC,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAG1E,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAGpG,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEhG;;;;;;;;;;;;;EAaE;AACF,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAKrF"}
|
|
@@ -17,9 +17,6 @@ export const wrapHandler = baseWrapHandler<APIGatewayProxyEventV2WithLambdaAutho
|
|
|
17
17
|
export function wrapHandler(handler) {
|
|
18
18
|
return async (event, context) => {
|
|
19
19
|
const result = await handler(event, context);
|
|
20
|
-
return {
|
|
21
|
-
...result,
|
|
22
|
-
body: result.body ? stringify(result.body) : undefined
|
|
23
|
-
};
|
|
20
|
+
return { ...result, body: result.body ? stringify(result.body) : undefined };
|
|
24
21
|
};
|
|
25
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/lambda/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAsB,MAAM,mBAAmB,CAAC;AAEnF,iBAAS,KAAK,CAAC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/lambda/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAsB,MAAM,mBAAmB,CAAC;AAEnF,iBAAS,KAAK,CAAC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;EAI9D;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,GAAG,MAAM,CAAC,GAAG;IAClF,OAAO,EAAE,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,IAAI,EAAE,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,IAAI,SAAS,MAAM,GAAG,EAAE,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,IAC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,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,MAAM,CAAA;CAAE,CAAC;AAEzG,wBAAgB,cAAc,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,EACvF,CAAC,EAAE,iBAAiB,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,GAAE,IAAiB,EACvB,MAAM,GAAE,MAAqB,GAC5B,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAoBnC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,EAAE,OAAO,EAAE,GAAG,sCAQzG;AAED,wBAAgB,WAAW,CAAC,IAAI,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS;;;;;EAG/B"}
|
package/dist/lambda/response.js
CHANGED
|
@@ -2,78 +2,22 @@ import { error_lambda_badRequest } from './errors.js';
|
|
|
2
2
|
function field(obj) {
|
|
3
3
|
return obj.fieldName === undefined || obj.fieldValue === undefined
|
|
4
4
|
? {}
|
|
5
|
-
: {
|
|
6
|
-
field: {
|
|
7
|
-
name: obj.fieldName,
|
|
8
|
-
value: obj.fieldValue
|
|
9
|
-
}
|
|
10
|
-
};
|
|
5
|
+
: { field: { name: obj.fieldName, value: obj.fieldValue } };
|
|
11
6
|
}
|
|
12
7
|
export function response_error(e, headers, type = '', extras = {}) {
|
|
13
8
|
switch (e.type) {
|
|
14
9
|
case 'lambda_badRequest':
|
|
15
|
-
return {
|
|
16
|
-
headers,
|
|
17
|
-
statusCode: 400,
|
|
18
|
-
body: {
|
|
19
|
-
message: e.message,
|
|
20
|
-
type: type,
|
|
21
|
-
...field(e),
|
|
22
|
-
...extras
|
|
23
|
-
}
|
|
24
|
-
};
|
|
10
|
+
return { headers, statusCode: 400, body: { message: e.message, type: type, ...field(e), ...extras } };
|
|
25
11
|
case 'lambda_unauthorized':
|
|
26
|
-
return {
|
|
27
|
-
headers,
|
|
28
|
-
statusCode: 401,
|
|
29
|
-
body: {
|
|
30
|
-
message: e.message,
|
|
31
|
-
type: type,
|
|
32
|
-
...extras
|
|
33
|
-
}
|
|
34
|
-
};
|
|
12
|
+
return { headers, statusCode: 401, body: { message: e.message, type: type, ...extras } };
|
|
35
13
|
case 'lambda_forbidden':
|
|
36
|
-
return {
|
|
37
|
-
headers,
|
|
38
|
-
statusCode: 403,
|
|
39
|
-
body: {
|
|
40
|
-
message: e.message,
|
|
41
|
-
type: type,
|
|
42
|
-
...extras
|
|
43
|
-
}
|
|
44
|
-
};
|
|
14
|
+
return { headers, statusCode: 403, body: { message: e.message, type: type, ...extras } };
|
|
45
15
|
case 'lambda_notFound':
|
|
46
|
-
return {
|
|
47
|
-
headers,
|
|
48
|
-
statusCode: 404,
|
|
49
|
-
body: {
|
|
50
|
-
message: e.message,
|
|
51
|
-
type: type,
|
|
52
|
-
...field(e),
|
|
53
|
-
...extras
|
|
54
|
-
}
|
|
55
|
-
};
|
|
16
|
+
return { headers, statusCode: 404, body: { message: e.message, type: type, ...field(e), ...extras } };
|
|
56
17
|
case 'lambda_conflict':
|
|
57
|
-
return {
|
|
58
|
-
headers,
|
|
59
|
-
statusCode: 409,
|
|
60
|
-
body: {
|
|
61
|
-
message: e.message,
|
|
62
|
-
type: type,
|
|
63
|
-
...field(e),
|
|
64
|
-
...extras
|
|
65
|
-
}
|
|
66
|
-
};
|
|
18
|
+
return { headers, statusCode: 409, body: { message: e.message, type: type, ...field(e), ...extras } };
|
|
67
19
|
default:
|
|
68
|
-
return {
|
|
69
|
-
headers,
|
|
70
|
-
statusCode: 500,
|
|
71
|
-
body: {
|
|
72
|
-
message: 'Unknown error',
|
|
73
|
-
type: type,
|
|
74
|
-
...extras
|
|
75
|
-
}
|
|
76
|
-
};
|
|
20
|
+
return { headers, statusCode: 500, body: { message: 'Unknown error', type: type, ...extras } };
|
|
77
21
|
}
|
|
78
22
|
}
|
|
79
23
|
/**
|
|
@@ -91,10 +35,5 @@ export function response_valibotError(res, headers) {
|
|
|
91
35
|
}
|
|
92
36
|
}
|
|
93
37
|
export function response_ok(body, headers, cookies) {
|
|
94
|
-
return {
|
|
95
|
-
headers,
|
|
96
|
-
cookies,
|
|
97
|
-
statusCode: 200,
|
|
98
|
-
body
|
|
99
|
-
};
|
|
38
|
+
return { headers, cookies, statusCode: 200, body };
|
|
100
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/lambda/serializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/lambda/serializer.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
export {};
|
|
2
|
+
// /**
|
|
3
|
+
// * Turns object into string.
|
|
4
|
+
// *
|
|
5
|
+
// * Uses different methods in production and otherwise for more readable output
|
|
6
|
+
// */
|
|
7
|
+
// export async function stringify(data: any) {
|
|
8
|
+
// if (process.env.PUBLIC_ENVIRONMENT === 'production') {
|
|
9
|
+
// const { stringify: prodStrigify } = await import('@ungap/structured-clone/json');
|
|
10
|
+
// return prodStrigify(data);
|
|
11
|
+
// } else {
|
|
12
|
+
// const { decycle } = (await import('cycle')).default;
|
|
13
|
+
// return JSON.stringify(decycle(data), null);
|
|
14
|
+
// }
|
|
15
|
+
// }
|
|
@@ -3,7 +3,7 @@ import { Result } from 'neverthrow';
|
|
|
3
3
|
/**
|
|
4
4
|
* Wraps cookies parse along with the api gateway event with neverthrow
|
|
5
5
|
*/
|
|
6
|
-
export declare const getCookies: (event: APIGatewayProxyEventV2WithLambdaAuthorizer<any> | APIGatewayRequestAuthorizerEventV2) => Result<
|
|
6
|
+
export declare const getCookies: (event: APIGatewayProxyEventV2WithLambdaAuthorizer<any> | APIGatewayRequestAuthorizerEventV2) => Result<import("cookie").Cookies, {
|
|
7
7
|
type: "lambda_unauthorized";
|
|
8
8
|
message: string;
|
|
9
9
|
}>;
|