ag-common 0.0.13 → 0.0.17
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/dist/api/helpers/validateOpenApi.d.ts +3 -1
- package/dist/api/helpers/validateOpenApi.js +3 -1
- package/dist/ui/helpers/axiosHelper.js +3 -2
- package/dist/ui/helpers/routes.d.ts +2 -1
- package/dist/ui/helpers/useResize.d.ts +1 -1
- package/dist/ui/helpers/useResize.js +3 -2
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { APIGatewayEvent, APIGatewayProxyResult } from 'aws-lambda';
|
|
2
2
|
import { User } from '../../ui/helpers/jwt';
|
|
3
|
-
|
|
3
|
+
import { TLang } from '../../common/helpers/i18n';
|
|
4
|
+
export declare type NextType<T> = ({ event, body, params, userProfile, lang, }: {
|
|
4
5
|
params: Record<string, string>;
|
|
5
6
|
event: APIGatewayEvent;
|
|
6
7
|
body: T;
|
|
7
8
|
userProfile?: User;
|
|
9
|
+
lang: TLang;
|
|
8
10
|
}) => Promise<APIGatewayProxyResult>;
|
|
9
11
|
export declare function validateOpenApi<T>({ event, next, authorized, schema, COGNITO_USER_POOL_ID, }: {
|
|
10
12
|
COGNITO_USER_POOL_ID: string;
|
|
@@ -18,6 +18,7 @@ const validations_1 = require("./validations");
|
|
|
18
18
|
const log_1 = require("../../common/helpers/log");
|
|
19
19
|
const object_1 = require("../../common/helpers/object");
|
|
20
20
|
const api_1 = require("./api");
|
|
21
|
+
const i18n_1 = require("../../common/helpers/i18n");
|
|
21
22
|
//
|
|
22
23
|
const getOperation = ({ path, method, resource, schema, }) => {
|
|
23
24
|
var _a;
|
|
@@ -42,7 +43,7 @@ const getOperation = ({ path, method, resource, schema, }) => {
|
|
|
42
43
|
return { operation, pathParams };
|
|
43
44
|
};
|
|
44
45
|
function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID, }) {
|
|
45
|
-
var _a, _b, _c, _d;
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
const request = {
|
|
48
49
|
method: event.httpMethod,
|
|
@@ -110,6 +111,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
110
111
|
event,
|
|
111
112
|
body: (event.body && JSON.parse(event.body)),
|
|
112
113
|
userProfile,
|
|
114
|
+
lang: (0, i18n_1.getValidatedLang)((_e = event.headers['x-lang']) !== null && _e !== void 0 ? _e : ''),
|
|
113
115
|
});
|
|
114
116
|
return res;
|
|
115
117
|
});
|
|
@@ -24,7 +24,7 @@ const axiosHelper = ({ verb, url, body, headers, timeout = 30000, retryMax = 0,
|
|
|
24
24
|
let retry = 0;
|
|
25
25
|
do {
|
|
26
26
|
try {
|
|
27
|
-
const setHeaders = Object.assign({
|
|
27
|
+
const setHeaders = Object.assign({ Accept: 'application/json' }, headers);
|
|
28
28
|
if (verb === 'get') {
|
|
29
29
|
const ret = yield axios_1.default.get(url, {
|
|
30
30
|
headers: setHeaders,
|
|
@@ -60,7 +60,8 @@ const axiosHelper = ({ verb, url, body, headers, timeout = 30000, retryMax = 0,
|
|
|
60
60
|
else {
|
|
61
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
62
|
if (body && (0, object_1.isJson)(body)) {
|
|
63
|
-
setHeaders['Content-Type'] =
|
|
63
|
+
setHeaders['Content-Type'] =
|
|
64
|
+
setHeaders['Content-Type'] || 'application/json';
|
|
64
65
|
}
|
|
65
66
|
ret = yield axios(url, body, { headers: setHeaders });
|
|
66
67
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { TLang } from '../..';
|
|
2
3
|
import { ICognitoAuth, ICognitoAuthProviderProps } from './cognito';
|
|
3
4
|
import { AuthedUserContext } from './jwt';
|
|
4
5
|
export interface LocationSubset {
|
|
@@ -24,7 +25,7 @@ export interface IRequestCommon {
|
|
|
24
25
|
url: LocationSubset;
|
|
25
26
|
headerTitle?: string;
|
|
26
27
|
seed?: number;
|
|
27
|
-
lang:
|
|
28
|
+
lang: TLang;
|
|
28
29
|
}
|
|
29
30
|
export interface IStateCommon<TRequest extends IRequestCommon> extends IInitialStateCommon {
|
|
30
31
|
request: TRequest;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useResize = void 0;
|
|
3
4
|
const react_1 = require("react");
|
|
4
5
|
function getWindowDimensions() {
|
|
5
6
|
if (typeof window !== 'undefined') {
|
|
@@ -12,7 +13,7 @@ function getWindowDimensions() {
|
|
|
12
13
|
return undefined;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function useResize() {
|
|
16
17
|
const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions());
|
|
17
18
|
(0, react_1.useEffect)(() => {
|
|
18
19
|
function handleResize() {
|
|
@@ -30,4 +31,4 @@ function UseWindowDimensions() {
|
|
|
30
31
|
}, [windowDimensions]);
|
|
31
32
|
return windowDimensions;
|
|
32
33
|
}
|
|
33
|
-
exports.
|
|
34
|
+
exports.useResize = useResize;
|