ag-common 0.0.763 → 0.0.764

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.
@@ -1,4 +1,3 @@
1
- export * from './axiosHelper';
2
1
  export type * from './cognito';
3
2
  export * from './cookie';
4
3
  export * from './date';
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./axiosHelper"), exports);
18
17
  __exportStar(require("./cookie"), exports);
19
18
  __exportStar(require("./date"), exports);
20
19
  __exportStar(require("./debounce"), exports);
@@ -1,4 +1,3 @@
1
- import type { AxiosError } from 'axios';
2
1
  export interface Jwt {
3
2
  access_token: string;
4
3
  expires_at: number;
@@ -49,14 +48,3 @@ export interface User {
49
48
  isAdmin: boolean;
50
49
  jwt?: Jwt;
51
50
  }
52
- export interface AxiosWrapper<T> {
53
- data: T | undefined;
54
- error?: AxiosError<unknown, any>;
55
- loading: boolean;
56
- reFetch: () => Promise<any>;
57
- datetime: number;
58
- }
59
- export interface AxiosWrapperLite<T> {
60
- data: T | undefined;
61
- error?: AxiosError;
62
- }
@@ -1,5 +1,4 @@
1
1
  import type { TLang } from '../../common/helpers/i18n';
2
- import type { AxiosWrapperLite } from './jwt';
3
2
  export type TProtocol = 'http:' | 'https:';
4
3
  export interface URLLite {
5
4
  hash: string;
@@ -14,12 +13,6 @@ export interface URLLite {
14
13
  search: string;
15
14
  username: string;
16
15
  }
17
- export type CacheItems = CacheItem<any>[];
18
- export interface CacheItem<T> {
19
- cacheKey: string;
20
- prefillData: AxiosWrapperLite<T>;
21
- ttlSeconds: number;
22
- }
23
16
  export interface IRequestCommon {
24
17
  url: URLLite;
25
18
  query: Record<string, string>;
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
- "version": "0.0.763",
2
+ "version": "0.0.764",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
- "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
7
- "repository": "github:andreigec/ag-common",
6
+ "author": "admin@gec.dev",
8
7
  "license": "ISC",
9
8
  "scripts": {
10
9
  "preinstall": "npx only-allow pnpm",
@@ -18,57 +17,51 @@
18
17
  "test": "globstar -- node --import tsx --test \"src/**/*.test.ts\""
19
18
  },
20
19
  "dependencies": {
21
- "@aws-sdk/client-apigatewaymanagementapi": "^3.864.0",
22
- "@aws-sdk/client-dynamodb": "^3.868.0",
23
- "@aws-sdk/client-s3": "^3.864.0",
24
- "@aws-sdk/client-ses": "^3.864.0",
25
- "@aws-sdk/client-sqs": "^3.864.0",
26
- "@aws-sdk/client-sts": "^3.864.0",
27
- "@aws-sdk/lib-dynamodb": "^3.868.0",
28
- "@aws-sdk/s3-presigned-post": "^3.864.0",
29
- "@aws-sdk/util-dynamodb": "^3.868.0",
30
- "aws-cdk-lib": "^2.211.0",
31
- "axios": "^1.11.0",
20
+ "@aws-sdk/client-apigatewaymanagementapi": "^3.879.0",
21
+ "@aws-sdk/client-dynamodb": "^3.879.0",
22
+ "@aws-sdk/client-s3": "^3.879.0",
23
+ "@aws-sdk/client-ses": "^3.879.0",
24
+ "@aws-sdk/client-sqs": "^3.879.0",
25
+ "@aws-sdk/client-sts": "^3.879.0",
26
+ "@aws-sdk/lib-dynamodb": "^3.879.0",
27
+ "@aws-sdk/s3-presigned-post": "^3.879.0",
28
+ "aws-cdk-lib": "^2.213.0",
32
29
  "buffer": "^6.0.3",
33
- "constructs": "^10.4.2",
34
30
  "jsonwebtoken": "^9.0.2",
35
31
  "jwks-rsa": "^3.2.0",
36
- "node-cache": "^5.1.2",
37
32
  "react": "^19.1.1",
38
33
  "react-dom": "^19.1.1",
39
34
  "typescript": "^5.9.2"
40
35
  },
41
36
  "devDependencies": {
42
- "@babel/core": "^7.28.3",
43
- "@babel/preset-typescript": "^7.27.1",
44
- "@babel/types": "^7.28.2",
45
37
  "@emotion/react": "^11.14.0",
46
38
  "@emotion/styled": "^11.14.1",
47
39
  "@smithy/types": "^4.3.2",
48
- "@storybook/addon-docs": "^9.1.2",
49
- "@storybook/addon-links": "^9.1.2",
40
+ "@storybook/addon-docs": "^9.1.3",
41
+ "@storybook/addon-links": "^9.1.3",
50
42
  "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
51
43
  "@storybook/addons": "^7.6.17",
52
44
  "@storybook/manager-api": "^8.6.14",
53
- "@storybook/react-webpack5": "^9.1.2",
45
+ "@storybook/react": "^9.1.3",
46
+ "@storybook/react-webpack5": "^9.1.3",
54
47
  "@storybook/theming": "^8.6.14",
55
48
  "@types/jsonwebtoken": "^9.0.10",
56
49
  "@types/node": "^24.3.0",
57
- "@types/react": "^19.1.10",
58
- "@types/react-dom": "^19.1.7",
59
- "@typescript-eslint/eslint-plugin": "^8.40.0",
60
- "@typescript-eslint/parser": "^8.40.0",
50
+ "@types/react": "^19.1.12",
51
+ "@types/react-dom": "^19.1.9",
52
+ "@typescript-eslint/eslint-plugin": "^8.41.0",
53
+ "@typescript-eslint/parser": "^8.41.0",
61
54
  "cross-env": "^10.0.0",
62
- "eslint": "^9.33.0",
55
+ "eslint": "^9.34.0",
63
56
  "eslint-config-e7npm": "^0.1.24",
64
- "eslint-plugin-storybook": "9.1.3",
57
+ "eslint-plugin-storybook": "^9.1.3",
65
58
  "globstar": "^1.0.0",
66
59
  "rimraf": "^6.0.1",
67
- "storybook": "^9.1.2",
68
- "tsx": "^4.20.4"
60
+ "storybook": "^9.1.3",
61
+ "tsx": "^4.20.5"
69
62
  },
70
63
  "resolutions": {
71
- "globals": "15.15.0"
64
+ "globals": "16.3.0"
72
65
  },
73
66
  "files": [
74
67
  "dist/**/*",
@@ -1,17 +0,0 @@
1
- import type { AxiosResponse } from 'axios';
2
- /**
3
- *
4
- * @param body accepts object or json, and passes as-is
5
- * @returns
6
- */
7
- export declare const axiosHelper: <TOut>({ verb, url, body, headers, timeout, retryMax, onStaleAuth, }: {
8
- headers?: {
9
- [a: string]: string;
10
- };
11
- verb: "put" | "post" | "get" | "patch" | "delete";
12
- url: string;
13
- body?: unknown;
14
- timeout?: number;
15
- retryMax?: number;
16
- onStaleAuth?: () => void;
17
- }) => Promise<AxiosResponse<TOut>>;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.axiosHelper = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const const_1 = require("../../common/const");
18
- const log_1 = require("../../common/helpers/log");
19
- const object_1 = require("../../common/helpers/object");
20
- const sleep_1 = require("../../common/helpers/sleep");
21
- /**
22
- *
23
- * @param body accepts object or json, and passes as-is
24
- * @returns
25
- */
26
- const axiosHelper = (_a) => __awaiter(void 0, [_a], void 0, function* ({ verb, url, body, headers, timeout = 30000, retryMax = 0, onStaleAuth, }) {
27
- var _b;
28
- let retry = 0;
29
- let ret;
30
- do {
31
- try {
32
- const setHeaders = Object.assign({ Accept: 'application/json' }, headers);
33
- if (verb === 'get') {
34
- ret = yield axios_1.default.get(url, {
35
- headers: setHeaders,
36
- timeout,
37
- timeoutErrorMessage: `${url} timeout`,
38
- });
39
- return ret;
40
- }
41
- let noBody = false;
42
- let axiosV = axios_1.default.post;
43
- if (verb === 'put') {
44
- axiosV = axios_1.default.put;
45
- }
46
- else if (verb === 'post') {
47
- axiosV = axios_1.default.post;
48
- }
49
- else if (verb === 'patch') {
50
- axiosV = axios_1.default.patch;
51
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
52
- }
53
- else if (verb === 'delete') {
54
- axiosV = axios_1.default.delete;
55
- noBody = true;
56
- }
57
- if (noBody) {
58
- ret = yield axiosV(url, {
59
- headers: setHeaders,
60
- timeout,
61
- timeoutErrorMessage: `${url} timeout`,
62
- });
63
- }
64
- else {
65
- if (body && (0, object_1.isJson)(body)) {
66
- setHeaders['Content-Type'] =
67
- setHeaders['Content-Type'] || 'application/json';
68
- }
69
- ret = yield axiosV(url, body, { headers: setHeaders });
70
- }
71
- return ret;
72
- }
73
- catch (e) {
74
- const em = e;
75
- const c = Number((_b = em.code) !== null && _b !== void 0 ? _b : '500');
76
- // jwt expired or bad response
77
- // 403 returned for old token - will be refreshed
78
- if (c === 401 || c === 403) {
79
- (0, log_1.debug)('auth expired');
80
- onStaleAuth === null || onStaleAuth === void 0 ? void 0 : onStaleAuth();
81
- retry = retryMax;
82
- }
83
- if (!const_1.retryHttpCodes.includes(c) || retry >= retryMax) {
84
- throw em;
85
- }
86
- }
87
- retry += 1;
88
- yield (0, sleep_1.sleep)(const_1.retryHttpMs);
89
- } while (retry <= retryMax);
90
- throw new Error('unexpected');
91
- });
92
- exports.axiosHelper = axiosHelper;