@forgepack/request 1.0.5 → 1.0.6
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 +217 -86
- package/dist/api/client.d.ts +17 -10
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +18 -6
- package/dist/hooks/AuthContext.d.ts +6 -6
- package/dist/hooks/AuthContext.d.ts.map +1 -1
- package/dist/hooks/AuthContext.js +1 -1
- package/dist/hooks/AuthProvider.d.ts +34 -17
- package/dist/hooks/AuthProvider.d.ts.map +1 -1
- package/dist/hooks/AuthProvider.js +26 -15
- package/dist/hooks/useAuth.d.ts +33 -12
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +30 -12
- package/dist/hooks/useRequest.d.ts +37 -17
- package/dist/hooks/useRequest.d.ts.map +1 -1
- package/dist/hooks/useRequest.js +36 -13
- package/dist/index.d.ts +159 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +159 -14
- package/dist/services/api.d.ts +37 -15
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/api.js +40 -14
- package/dist/services/auth.d.ts +76 -19
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +94 -22
- package/dist/services/crud.d.ts +115 -62
- package/dist/services/crud.d.ts.map +1 -1
- package/dist/services/crud.js +132 -85
- package/dist/services/token.d.ts +83 -26
- package/dist/services/token.d.ts.map +1 -1
- package/dist/services/token.js +141 -52
- package/dist/types/auth.d.ts +20 -20
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/error.d.ts +3 -3
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/request.d.ts +8 -8
- package/dist/types/request.d.ts.map +1 -1
- package/dist/types/response.d.ts +15 -15
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/token.d.ts +15 -15
- package/dist/types/token.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +7 -7
- package/dist/utils/constants.js +7 -7
- package/package.json +15 -3
package/dist/types/response.d.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interface
|
|
2
|
+
* Interface representing pagination information
|
|
3
3
|
* @interface PageInfo
|
|
4
4
|
*/
|
|
5
5
|
export interface PageInfo {
|
|
6
|
-
/**
|
|
6
|
+
/** Current page size */
|
|
7
7
|
size: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Current page number */
|
|
9
9
|
number: number;
|
|
10
|
-
/** Total
|
|
10
|
+
/** Total elements across all pages */
|
|
11
11
|
totalElements: number;
|
|
12
|
-
/** Total
|
|
12
|
+
/** Total available pages */
|
|
13
13
|
totalPages: number;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @template T
|
|
16
|
+
* Generic interface representing a paginated API response
|
|
17
|
+
* @template T Type of elements contained in the page
|
|
18
18
|
* @interface Page
|
|
19
19
|
*/
|
|
20
20
|
export interface Page<T = unknown> {
|
|
21
|
-
/** Array
|
|
21
|
+
/** Array with current page elements */
|
|
22
22
|
content: T[];
|
|
23
|
-
/**
|
|
23
|
+
/** Pagination information */
|
|
24
24
|
page: PageInfo;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Interface
|
|
28
|
-
* @template T
|
|
27
|
+
* Interface for generic API responses
|
|
28
|
+
* @template T Type of returned data
|
|
29
29
|
* @interface ApiResponse
|
|
30
30
|
*/
|
|
31
31
|
export interface ApiResponse<T = unknown> {
|
|
32
|
-
/**
|
|
32
|
+
/** Indicates if the operation was successful */
|
|
33
33
|
success: boolean;
|
|
34
|
-
/**
|
|
34
|
+
/** Returned data (if successful) */
|
|
35
35
|
data?: T;
|
|
36
|
-
/**
|
|
36
|
+
/** Response message */
|
|
37
37
|
message?: string;
|
|
38
|
-
/**
|
|
38
|
+
/** Validation errors (if failed) */
|
|
39
39
|
errors?: Array<{
|
|
40
40
|
field: string;
|
|
41
41
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACzC,aAAa,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC/B,UAAU,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO;IAC7B,uCAAuC;IAC1C,OAAO,EAAE,CAAC,EAAE,CAAC;IACV,6BAA6B;IAChC,IAAI,EAAE,QAAQ,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACpC,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACrD"}
|
package/dist/types/token.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interface
|
|
2
|
+
* Interface representing the complete structure of a JWT token
|
|
3
3
|
* @interface Token
|
|
4
4
|
*/
|
|
5
5
|
export interface Token {
|
|
6
|
-
/**
|
|
6
|
+
/** Token header containing algorithm and type */
|
|
7
7
|
header: Header;
|
|
8
|
-
/**
|
|
8
|
+
/** Token payload containing the claims */
|
|
9
9
|
payload: Payload;
|
|
10
|
-
/**
|
|
10
|
+
/** Token signature */
|
|
11
11
|
signature: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Interface
|
|
14
|
+
* Interface representing a JWT token header
|
|
15
15
|
* @interface Header
|
|
16
16
|
*/
|
|
17
17
|
export interface Header {
|
|
18
|
-
/**
|
|
18
|
+
/** Algorithm used to sign the token */
|
|
19
19
|
alg: string;
|
|
20
|
-
/**
|
|
20
|
+
/** Token type */
|
|
21
21
|
typ: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Interface
|
|
24
|
+
* Interface representing a JWT token payload
|
|
25
25
|
* @interface Payload
|
|
26
26
|
*/
|
|
27
27
|
export interface Payload {
|
|
28
|
-
/**
|
|
28
|
+
/** JSON Token Identifier unique identifier */
|
|
29
29
|
jti: string;
|
|
30
|
-
/**
|
|
30
|
+
/** Token issuer */
|
|
31
31
|
iss: string;
|
|
32
|
-
/**
|
|
32
|
+
/** Token issue date/time (Unix timestamp) */
|
|
33
33
|
iat: number;
|
|
34
|
-
/** Token
|
|
34
|
+
/** Token not valid before this date/time (Unix timestamp) */
|
|
35
35
|
nbf: number;
|
|
36
|
-
/**
|
|
36
|
+
/** Token expiration date/time (Unix timestamp) */
|
|
37
37
|
exp: number;
|
|
38
|
-
/**
|
|
38
|
+
/** Token subject (usually user ID) */
|
|
39
39
|
sub: string;
|
|
40
|
-
/**
|
|
40
|
+
/** Token intended audience */
|
|
41
41
|
aud: string;
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/types/token.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK;IAClB,
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/types/token.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK;IAClB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACnB,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACpB,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -4,37 +4,37 @@ import { Search } from '../types/request';
|
|
|
4
4
|
import { Page, PageInfo } from '../types/response';
|
|
5
5
|
import { Header, Payload } from '../types/token';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Empty initial state for authentication data
|
|
8
8
|
* @constant
|
|
9
9
|
*/
|
|
10
10
|
export declare const initialAuth: Auth;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Empty initial state for error messages
|
|
13
13
|
* @constant
|
|
14
14
|
*/
|
|
15
15
|
export declare const initialErrorMessage: ErrorMessage;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Default configuration for searches and pagination
|
|
18
18
|
* @constant
|
|
19
19
|
*/
|
|
20
20
|
export declare const initialSearch: Search;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Empty initial state for pagination information
|
|
23
23
|
* @constant
|
|
24
24
|
*/
|
|
25
25
|
export declare const initialPageInfo: PageInfo;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Empty initial state for paginated responses
|
|
28
28
|
* @constant
|
|
29
29
|
*/
|
|
30
30
|
export declare const initialPage: Page;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Empty initial state for token header
|
|
33
33
|
* @constant
|
|
34
34
|
*/
|
|
35
35
|
export declare const initialHeader: Header;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Empty initial state for token payload
|
|
38
38
|
* @constant
|
|
39
39
|
*/
|
|
40
40
|
export declare const initialPayload: Payload;
|
package/dist/utils/constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initialPayload = exports.initialHeader = exports.initialPage = exports.initialPageInfo = exports.initialSearch = exports.initialErrorMessage = exports.initialAuth = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Empty initial state for authentication data
|
|
6
6
|
* @constant
|
|
7
7
|
*/
|
|
8
8
|
exports.initialAuth = {
|
|
@@ -12,7 +12,7 @@ exports.initialAuth = {
|
|
|
12
12
|
role: []
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Empty initial state for error messages
|
|
16
16
|
* @constant
|
|
17
17
|
*/
|
|
18
18
|
exports.initialErrorMessage = {
|
|
@@ -20,7 +20,7 @@ exports.initialErrorMessage = {
|
|
|
20
20
|
message: ''
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Default configuration for searches and pagination
|
|
24
24
|
* @constant
|
|
25
25
|
*/
|
|
26
26
|
exports.initialSearch = {
|
|
@@ -33,7 +33,7 @@ exports.initialSearch = {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Empty initial state for pagination information
|
|
37
37
|
* @constant
|
|
38
38
|
*/
|
|
39
39
|
exports.initialPageInfo = {
|
|
@@ -43,7 +43,7 @@ exports.initialPageInfo = {
|
|
|
43
43
|
totalPages: 0
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Empty initial state for paginated responses
|
|
47
47
|
* @constant
|
|
48
48
|
*/
|
|
49
49
|
exports.initialPage = {
|
|
@@ -51,7 +51,7 @@ exports.initialPage = {
|
|
|
51
51
|
page: exports.initialPageInfo
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Empty initial state for token header
|
|
55
55
|
* @constant
|
|
56
56
|
*/
|
|
57
57
|
exports.initialHeader = {
|
|
@@ -59,7 +59,7 @@ exports.initialHeader = {
|
|
|
59
59
|
typ: ''
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Empty initial state for token payload
|
|
63
63
|
* @constant
|
|
64
64
|
*/
|
|
65
65
|
exports.initialPayload = {
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgepack/request",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"homepage": "https://
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Opinionated Axios-based HTTP client for React applications with JWT support, interceptors, and API request standardization.",
|
|
5
|
+
"homepage": "https://forgepack.dev/packages/request",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/forgepack/request/issues"
|
|
8
8
|
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"@forgepack:registry": "https://registry.npmjs.org"
|
|
11
|
+
},
|
|
9
12
|
"repository": {
|
|
10
13
|
"type": "git",
|
|
11
14
|
"url": "git+https://github.com/forgepack/request.git"
|
|
@@ -36,6 +39,15 @@
|
|
|
36
39
|
"type": "commonjs",
|
|
37
40
|
"main": "dist/index.js",
|
|
38
41
|
"types": "dist/index.d.ts",
|
|
42
|
+
"module": "dist/index.mjs",
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"import": "./dist/index.mjs",
|
|
47
|
+
"require": "./dist/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": false,
|
|
39
51
|
"files": [
|
|
40
52
|
"dist",
|
|
41
53
|
"README.md",
|