ag-common 0.0.359 → 0.0.360
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 +1 -1
- package/dist/api/helpers/validations.d.ts +1 -1
- package/dist/api/openapi-postfix.js +22 -16
- package/dist/api/types/aws.d.ts +1 -1
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/i18n.d.ts +3 -3
- package/dist/common/helpers/log.d.ts +1 -1
- package/dist/ui/components/BorderGradient/index.d.ts +1 -1
- package/dist/ui/components/RowOrColumn/index.d.ts +2 -2
- package/dist/ui/components/Search/types.d.ts +3 -3
- package/dist/ui/components/SparkLine/index.d.ts +1 -1
- package/dist/ui/helpers/axiosHelper.js +7 -7
- package/dist/ui/helpers/callOpenApi/cached.d.ts +1 -1
- package/dist/ui/helpers/callOpenApi/helpers.d.ts +6 -0
- package/dist/ui/helpers/callOpenApi/helpers.js +6 -0
- package/dist/ui/helpers/callOpenApi/hook.d.ts +3 -3
- package/dist/ui/helpers/cognito.d.ts +1 -1
- package/dist/ui/helpers/cookie/const.d.ts +4 -4
- package/dist/ui/helpers/routes.d.ts +2 -2
- package/dist/ui/helpers/useGranularHook.d.ts +1 -1
- package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { TGetAndValidateToken } from './validations';
|
|
|
2
2
|
import { User } from '../../ui/helpers/jwt';
|
|
3
3
|
import { TLang } from '../../common/helpers/i18n';
|
|
4
4
|
import { APIGatewayEvent, APIGatewayProxyResult } from '../types';
|
|
5
|
-
export
|
|
5
|
+
export type NextType<T> = ({ event, body, params, userProfile, lang, }: {
|
|
6
6
|
params: Record<string, string>;
|
|
7
7
|
event: APIGatewayEvent;
|
|
8
8
|
body: T;
|
|
@@ -8,7 +8,7 @@ export interface IGetAndValidateToken {
|
|
|
8
8
|
tokenRaw?: string;
|
|
9
9
|
COGNITO_USER_POOL_ID: string;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type TGetAndValidateToken = (p: IGetAndValidateToken) => Promise<{
|
|
12
12
|
error?: APIGatewayProxyResult;
|
|
13
13
|
token?: string;
|
|
14
14
|
userProfile?: User;
|
|
@@ -4,28 +4,34 @@
|
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const process = require('process');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const pathV = require('path');
|
|
8
|
+
const cwd = process.cwd();
|
|
9
|
+
const resolvePath = (p) => pathV.resolve(cwd, p);
|
|
10
10
|
function run() {
|
|
11
|
-
|
|
11
|
+
const files = fs
|
|
12
12
|
.readdirSync(resolvePath('./dist/api'))
|
|
13
|
-
.filter((r) => r.endsWith('.js'))
|
|
14
|
-
.map((s) => `./dist/api/${s}`)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
.filter((r) => r.endsWith('.js') || r.endsWith('.d.ts'))
|
|
14
|
+
.map((s) => `./dist/api/${s}`)
|
|
15
|
+
.filter(fs.existsSync)
|
|
16
|
+
.map((file) => ({ file, content: fs.readFileSync(file).toString() }));
|
|
17
|
+
let found = false;
|
|
18
|
+
files.forEach(({ file, content }) => {
|
|
19
|
+
if (content.includes('url_1')) {
|
|
20
|
+
console.log('removing url_1 from ' + file);
|
|
21
|
+
content = content.replace(/url_1\./gim, '');
|
|
21
22
|
found = true;
|
|
22
23
|
}
|
|
23
|
-
if (
|
|
24
|
-
console.log('fixing queryparams default from ' +
|
|
25
|
-
|
|
24
|
+
if (content.includes('this.configuration.queryParamsStringify(')) {
|
|
25
|
+
console.log('fixing queryparams default from ' + file);
|
|
26
|
+
content = content.replace(/this.configuration.queryParamsStringify\(/gim, '(this.configuration.queryParamsStringify||querystring)(');
|
|
26
27
|
found = true;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
if (content.includes(`import("axios").`)) {
|
|
30
|
+
console.log('fixing axios import from ' + file);
|
|
31
|
+
content = content.replace(/import\("axios"\)\./gim, '');
|
|
32
|
+
found = true;
|
|
33
|
+
}
|
|
34
|
+
fs.writeFileSync(file, content);
|
|
29
35
|
});
|
|
30
36
|
if (!found) {
|
|
31
37
|
console.log('error: no files were fixed');
|
package/dist/api/types/aws.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface ILambdaConfigs {
|
|
|
50
50
|
default?: ILambdaConfig;
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export type TSkOperator = 'BETWEEN' | '<' | '<=' | '=' | '>=' | '>' | '<>' | 'BEGINS_WITH';
|
|
54
54
|
export interface IQueryDynamo {
|
|
55
55
|
pkName: string;
|
|
56
56
|
pkValue: string | number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
type TLangExceptEn = 'id' | 'vi' | 'pt';
|
|
2
|
+
export type TLang = TLangExceptEn | 'en';
|
|
3
3
|
export declare const AllLang: TLang[];
|
|
4
4
|
/**
|
|
5
5
|
* null = wont translate. undefined = fallback to eng
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type TResource = {
|
|
8
8
|
[k in TLangExceptEn]?: string | null;
|
|
9
9
|
} & {
|
|
10
10
|
en: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type TLogType = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
|
|
2
2
|
export declare const GetLogLevel: (l: TLogType) => number;
|
|
3
3
|
export declare const SetLogLevel: (l: TLogType) => void;
|
|
4
4
|
export declare const debug: (...args: unknown[]) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
type IOnClick = React.MouseEvent<HTMLDivElement, MouseEvent> | React.MouseEvent<HTMLAnchorElement, MouseEvent>;
|
|
3
3
|
export interface IBorderGradient {
|
|
4
4
|
canClick?: boolean;
|
|
5
5
|
noGrow?: boolean;
|
|
@@ -8,6 +8,6 @@ export interface IRowOrColumn {
|
|
|
8
8
|
title?: string;
|
|
9
9
|
enableOverflow?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type IFlexColumn = IRowOrColumn;
|
|
12
|
+
export type IFlexRow = IRowOrColumn;
|
|
13
13
|
export declare const RowOrColumn: (props: IRowOrColumn) => JSX.Element;
|
|
@@ -29,9 +29,9 @@ export interface ISearchDialog<T> {
|
|
|
29
29
|
totalItems?: (showing: number, outof: number) => string;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type TSearchModalRes<T> = undefined | {
|
|
33
33
|
foundItem: T;
|
|
34
34
|
searchText: string;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
37
|
-
export
|
|
36
|
+
export type ISearchModal<T> = ISearchDialog<T>;
|
|
37
|
+
export type ISearchInline<T> = ISearchDialog<T>;
|
|
@@ -39,23 +39,23 @@ const axiosHelper = ({ verb, url, body, headers, timeout = 30000, retryMax = 0,
|
|
|
39
39
|
}
|
|
40
40
|
let noBody = false;
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
let
|
|
42
|
+
let axiosV = axios_1.default.post;
|
|
43
43
|
if (verb === 'put') {
|
|
44
|
-
|
|
44
|
+
axiosV = axios_1.default.put;
|
|
45
45
|
}
|
|
46
46
|
else if (verb === 'post') {
|
|
47
|
-
|
|
47
|
+
axiosV = axios_1.default.post;
|
|
48
48
|
}
|
|
49
49
|
else if (verb === 'patch') {
|
|
50
|
-
|
|
50
|
+
axiosV = axios_1.default.patch;
|
|
51
51
|
}
|
|
52
52
|
else if (verb === 'delete') {
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
|
|
54
|
+
axiosV = axios_1.default.delete;
|
|
55
55
|
noBody = true;
|
|
56
56
|
}
|
|
57
57
|
if (noBody) {
|
|
58
|
-
ret = yield
|
|
58
|
+
ret = yield axiosV(url, {
|
|
59
59
|
headers: setHeaders,
|
|
60
60
|
timeout,
|
|
61
61
|
timeoutErrorMessage: `${url} timeout`,
|
|
@@ -66,7 +66,7 @@ const axiosHelper = ({ verb, url, body, headers, timeout = 30000, retryMax = 0,
|
|
|
66
66
|
setHeaders['Content-Type'] =
|
|
67
67
|
setHeaders['Content-Type'] || 'application/json';
|
|
68
68
|
}
|
|
69
|
-
ret = yield
|
|
69
|
+
ret = yield axiosV(url, body, { headers: setHeaders });
|
|
70
70
|
}
|
|
71
71
|
return ret;
|
|
72
72
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ICallOpenApi, OverrideAuth } from './types';
|
|
2
2
|
import { CacheItems } from '../routes';
|
|
3
3
|
import { AxiosWrapperLite } from '../jwt';
|
|
4
|
-
export
|
|
4
|
+
export type TCallOpenApiCached<T, TDefaultApi> = ICallOpenApi<T, TDefaultApi> & {
|
|
5
5
|
/**
|
|
6
6
|
* if falsey, will run callOpenApi directly
|
|
7
7
|
*/
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { ApiResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* shim to convert raw response to an axios style response.
|
|
5
|
+
* must convert all DefaultClass requests to the Raw equivalent
|
|
6
|
+
* @param p
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
3
9
|
export declare const apiResponseToAxiosResponse: <T>(p: () => Promise<ApiResponse<T>>) => Promise<AxiosResponse<T, any>>;
|
|
@@ -11,6 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.apiResponseToAxiosResponse = void 0;
|
|
13
13
|
const array_1 = require("../../../common/helpers/array");
|
|
14
|
+
/**
|
|
15
|
+
* shim to convert raw response to an axios style response.
|
|
16
|
+
* must convert all DefaultClass requests to the Raw equivalent
|
|
17
|
+
* @param p
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
14
20
|
const apiResponseToAxiosResponse = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
21
|
return p()
|
|
16
22
|
.then((r) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ICallOpenApi } from './types';
|
|
2
2
|
import { CacheItems } from '../routes';
|
|
3
3
|
import { AxiosWrapper } from '../jwt';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type TUseCallOpenApiDispatch<A> = (value: A) => A;
|
|
5
|
+
export type TUseCallOpenApi<T> = AxiosWrapper<T> & {
|
|
6
6
|
loaded: boolean;
|
|
7
7
|
loadcount: number;
|
|
8
8
|
setData: (d: TUseCallOpenApiDispatch<T | undefined>) => void;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type TUseCallOpenApiInt<T, TDefaultApi> = ICallOpenApi<T, TDefaultApi> & {
|
|
11
11
|
cacheKey: string;
|
|
12
12
|
/**
|
|
13
13
|
* will shortcut and return the appropriate axioswrapper data if cachekey is found
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const expireDate = "Thu, 01 Jan 1970 00:00:00 UTC";
|
|
2
2
|
export declare const maxCookieLen = 4000;
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type Dispatch<A> = (value: A) => void;
|
|
4
|
+
export type SetStateAction<S> = S | ((prevState: S) => S);
|
|
5
|
+
export type ReturnType<T> = [T, Dispatch<SetStateAction<T>>];
|
|
6
|
+
export type TParse<T> = (s: string | null | undefined) => T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ICognitoAuth } from './cognito';
|
|
2
2
|
import { AxiosWrapperLite } from './jwt';
|
|
3
3
|
import { TLang } from '../../common/helpers/i18n';
|
|
4
|
-
export
|
|
4
|
+
export type TProtocol = 'http:' | 'https:';
|
|
5
5
|
export interface LocationSubset {
|
|
6
6
|
/**
|
|
7
7
|
* slash only path eg /aaa/bbb
|
|
@@ -33,7 +33,7 @@ export interface LocationSubset {
|
|
|
33
33
|
*/
|
|
34
34
|
path: string;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type CacheItems = CacheItem<any>[];
|
|
37
37
|
export interface CacheItem<T> {
|
|
38
38
|
cacheKey: string;
|
|
39
39
|
prefillData: AxiosWrapperLite<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DependencyList, EffectCallback } from 'react';
|
|
2
|
-
|
|
2
|
+
type HookWithDependencies<C, R> = (callback: C, deps: DependencyList) => R;
|
|
3
3
|
export declare const useGranularHook: <T extends HookWithDependencies<C, ReturnType<T>>, C>(hook: T, callback: C, primaryDeps: DependencyList, secondaryDeps: DependencyList) => ReturnType<T>;
|
|
4
4
|
export declare const useGranularEffect: (effect: EffectCallback, primaryDeps: DependencyList, secondaryDeps: DependencyList) => void;
|
|
5
5
|
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.360",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
7
7
|
"repository": "github:andreigec/ag-common",
|
|
8
8
|
"license": "ISC",
|
|
9
|
-
"packageManager": "yarn@3.3.0",
|
|
10
9
|
"scripts": {
|
|
10
|
+
"preinstall": "npx only-allow pnpm",
|
|
11
11
|
"format": "npx eslint --ext .ts,.tsx ./src --fix",
|
|
12
|
-
"build": "rimraf dist &&
|
|
12
|
+
"build": "rimraf dist && npm run lint && tsc",
|
|
13
13
|
"lint": "npx eslint --ext .ts,.tsx ./src",
|
|
14
14
|
"start": "cross-env BROWSER=none start-storybook -p 6006",
|
|
15
15
|
"build-storybook": "build-storybook -o docs --quiet"
|