rest-client-sdk 7.3.0 → 7.5.0
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 +21 -0
- package/dist/index.cjs +580 -1228
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +578 -1224
- package/dist/index.mjs.map +1 -1
- package/dist/types/Mapping/ClassMetadata.d.ts +2 -2
- package/dist/types/RestClientSdk.d.ts +3 -3
- package/dist/types/RestClientSdkInterface.d.ts +1 -1
- package/dist/types/TokenGenerator/AuthorizationCodeFlowTokenGenerator.d.ts +6 -4
- package/dist/types/TokenGenerator/ClientCredentialsGenerator.d.ts +3 -3
- package/dist/types/TokenGenerator/PasswordGenerator.d.ts +3 -3
- package/dist/types/TokenGenerator/ProvidedTokenGenerator.d.ts +1 -1
- package/dist/types/TokenGenerator/TokenGeneratorInterface.d.ts +1 -1
- package/dist/types/TokenGenerator/types.d.ts +3 -3
- package/dist/types/UnitOfWork.d.ts +2 -2
- package/dist/types/serializer/SerializerInterface.d.ts +4 -4
- package/dist/types/utils/logging.d.ts +5 -5
- package/package.json +28 -43
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import AbstractClient from '../client/AbstractClient';
|
|
2
2
|
import Attribute from './Attribute';
|
|
3
3
|
import Relation from './Relation';
|
|
4
|
-
|
|
4
|
+
type AttributeListType = {
|
|
5
5
|
[key: string]: Attribute;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type DefaultSerializedModelType = {
|
|
8
8
|
[key: string]: null | null[];
|
|
9
9
|
};
|
|
10
10
|
declare class ClassMetadata {
|
|
@@ -7,12 +7,12 @@ import UnitOfWork from './UnitOfWork';
|
|
|
7
7
|
import AbstractClient from './client/AbstractClient';
|
|
8
8
|
import SerializerInterface from './serializer/SerializerInterface';
|
|
9
9
|
import { Logger } from './utils/logging';
|
|
10
|
-
|
|
11
|
-
export
|
|
10
|
+
type Entity = any;
|
|
11
|
+
export type MetadataDefinition = {
|
|
12
12
|
entity: Entity;
|
|
13
13
|
list: Iterable<Entity>;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type SdkMetadata = Record<string, MetadataDefinition>;
|
|
16
16
|
declare class RestClientSdk<M extends SdkMetadata> implements RestClientSdkInterface<M> {
|
|
17
17
|
#private;
|
|
18
18
|
config: Config;
|
|
@@ -4,7 +4,7 @@ import { Token } from './TokenGenerator/types';
|
|
|
4
4
|
import TokenStorageInterface from './TokenStorageInterface';
|
|
5
5
|
import AbstractClient from './client/AbstractClient';
|
|
6
6
|
import { Logger } from './utils/logging';
|
|
7
|
-
export
|
|
7
|
+
export type Config = {
|
|
8
8
|
path: string;
|
|
9
9
|
scheme: string;
|
|
10
10
|
port?: number;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import AbstractTokenGenerator from './AbstractTokenGenerator';
|
|
2
2
|
import { Token, TokenResponse } from './types';
|
|
3
|
-
|
|
3
|
+
type AuthorizationCodeFlowTokenGeneratorConfig = {
|
|
4
4
|
clientId: string;
|
|
5
|
-
clientSecret
|
|
5
|
+
clientSecret?: string;
|
|
6
6
|
path: string;
|
|
7
7
|
scheme: string;
|
|
8
8
|
redirectUri: string;
|
|
9
9
|
port?: string;
|
|
10
10
|
scope?: string;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type GenerateTokenParameters = {
|
|
13
13
|
code: string;
|
|
14
14
|
state?: string;
|
|
15
|
+
codeVerifier?: string;
|
|
15
16
|
};
|
|
16
17
|
interface AuthorizationCodeToken extends Token {
|
|
17
18
|
access_token: string;
|
|
@@ -20,7 +21,7 @@ interface AuthorizationCodeToken extends Token {
|
|
|
20
21
|
expires_in?: number;
|
|
21
22
|
scope?: string;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
type AuthorizationCodeFlowResponse = TokenResponse<AuthorizationCodeToken>;
|
|
24
25
|
/**
|
|
25
26
|
* This generator take cares of the second part of the authorization code flow : the part where you have a "code"
|
|
26
27
|
* and you have validated the "state"
|
|
@@ -37,6 +38,7 @@ declare class AuthorizationCodeFlowTokenGenerator extends AbstractTokenGenerator
|
|
|
37
38
|
*/
|
|
38
39
|
refreshToken(oldAccessToken: null | AuthorizationCodeToken): Promise<AuthorizationCodeFlowResponse>;
|
|
39
40
|
checkTokenGeneratorConfig(config: AuthorizationCodeFlowTokenGeneratorConfig): void;
|
|
41
|
+
private _clientSecretParameter;
|
|
40
42
|
private _checkGenerateParameters;
|
|
41
43
|
}
|
|
42
44
|
export default AuthorizationCodeFlowTokenGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AbstractTokenGenerator from './AbstractTokenGenerator';
|
|
2
2
|
import { Token, TokenResponse } from './types';
|
|
3
|
-
|
|
3
|
+
type Config = {
|
|
4
4
|
clientId: string;
|
|
5
5
|
clientSecret: string;
|
|
6
6
|
path: string;
|
|
@@ -8,7 +8,7 @@ declare type Config = {
|
|
|
8
8
|
port?: string;
|
|
9
9
|
scope?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type BaseParameters = {
|
|
12
12
|
scope?: string;
|
|
13
13
|
};
|
|
14
14
|
interface ClientCredentialToken extends Token {
|
|
@@ -18,7 +18,7 @@ interface ClientCredentialToken extends Token {
|
|
|
18
18
|
expires_in?: number;
|
|
19
19
|
scope?: string;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
type ClientCredentialResponse = TokenResponse<ClientCredentialToken>;
|
|
22
22
|
declare class ClientCredentialsGenerator extends AbstractTokenGenerator<ClientCredentialToken, Config> {
|
|
23
23
|
constructor(tokenGeneratorConfig: Config);
|
|
24
24
|
generateToken(baseParameters?: BaseParameters): Promise<ClientCredentialResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AbstractTokenGenerator from './AbstractTokenGenerator';
|
|
2
2
|
import { Token, TokenResponse } from './types';
|
|
3
|
-
|
|
3
|
+
type Config = {
|
|
4
4
|
clientId: string;
|
|
5
5
|
clientSecret: string;
|
|
6
6
|
path: string;
|
|
@@ -8,7 +8,7 @@ declare type Config = {
|
|
|
8
8
|
port?: string;
|
|
9
9
|
scope?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type GenerateTokenParameters = {
|
|
12
12
|
username: string;
|
|
13
13
|
password: string;
|
|
14
14
|
scope?: string;
|
|
@@ -20,7 +20,7 @@ interface PasswordToken extends Token {
|
|
|
20
20
|
expires_in?: number;
|
|
21
21
|
scope?: string;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
type PasswordTokenResponse = TokenResponse<PasswordToken>;
|
|
24
24
|
declare class PasswordGenerator extends AbstractTokenGenerator<PasswordToken, Config> {
|
|
25
25
|
generateToken(baseParameters: GenerateTokenParameters): Promise<PasswordTokenResponse>;
|
|
26
26
|
refreshToken(accessToken: null | PasswordToken): Promise<PasswordTokenResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TokenGeneratorInterface from './TokenGeneratorInterface';
|
|
2
2
|
import { Token } from './types';
|
|
3
|
-
|
|
3
|
+
type RefreshTokenFunc = (oldAccessToken: null | Token) => Promise<Token>;
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated ProvidedTokenGenerator is not an Oauth valid generator.
|
|
6
6
|
* You should use one of the official generator or implement your own custom generator.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token, TokenBody, TokenResponse } from './types';
|
|
2
2
|
/** @deprecated */
|
|
3
|
-
export
|
|
3
|
+
export type TokenBodyReturn<T> = TokenBody<T>;
|
|
4
4
|
export default interface TokenGeneratorInterface<T extends Token> {
|
|
5
5
|
/**
|
|
6
6
|
* This function needs no generate an access token
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* See {@link https://tools.ietf.org/html/rfc6749#section-5.1 Successful Response}
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type Token = {
|
|
5
5
|
access_token: string;
|
|
6
6
|
token_type: string;
|
|
7
7
|
refresh_token?: string;
|
|
@@ -11,12 +11,12 @@ export declare type Token = {
|
|
|
11
11
|
/**
|
|
12
12
|
* see {@link https://tools.ietf.org/html/rfc6749#section-5.2 Error Response}
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type ErrorBody = {
|
|
15
15
|
error: 'invalid_request' | 'invalid_client' | 'invalid_grant' | 'unauthorized_client' | 'unsupported_grant_type' | 'invalid_scope';
|
|
16
16
|
error_description?: string;
|
|
17
17
|
error_uri?: string;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type TokenBody<T> = T | ErrorBody;
|
|
20
20
|
export interface TokenResponse<T extends Token> extends Response {
|
|
21
21
|
json(): Promise<TokenBody<T>>;
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Mapping from './Mapping';
|
|
2
2
|
import ClassMetadata from './Mapping/ClassMetadata';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type Id = string | number;
|
|
4
|
+
type StringKeyObject = Record<string, any>;
|
|
5
5
|
declare class UnitOfWork {
|
|
6
6
|
#private;
|
|
7
7
|
mapping: Mapping;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import ClassMetadata from '../Mapping/ClassMetadata';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
2
|
+
export type Entity = Record<string, unknown>;
|
|
3
|
+
export type NormalizedObject = Record<string, unknown>;
|
|
4
|
+
export type NormalizedList = Iterable<Record<string, unknown>>;
|
|
5
|
+
export type EntityList = Iterable<Entity>;
|
|
6
6
|
export default interface SerializerInterface {
|
|
7
7
|
/**
|
|
8
8
|
* convert an entity to a plain javascript object
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
type SdkRequest = RequestInit & {
|
|
2
2
|
url: string;
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type SdkResponse = {
|
|
5
5
|
status: number;
|
|
6
6
|
headers: Record<string, string>;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type SerializableRequest = {
|
|
9
9
|
url: string;
|
|
10
10
|
method?: string;
|
|
11
11
|
headers?: Record<string, string>;
|
|
12
12
|
body?: string;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type Log = {
|
|
15
15
|
id: string;
|
|
16
16
|
request?: SerializableRequest;
|
|
17
17
|
response?: SdkResponse;
|
|
@@ -20,7 +20,7 @@ export declare type Log = {
|
|
|
20
20
|
response?: number;
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type LoggerHistory = Array<Log>;
|
|
24
24
|
export declare class Logger {
|
|
25
25
|
#private;
|
|
26
26
|
get history(): LoggerHistory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rest-client-sdk",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"description": "Rest Client SDK for API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -15,59 +15,50 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"clean": "
|
|
19
|
-
"test": "yarn lint --quiet &&
|
|
18
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
19
|
+
"test": "yarn lint --quiet && vitest",
|
|
20
20
|
"build": "yarn clean && yarn build:types && yarn build:js",
|
|
21
21
|
"build:types": "tsc --emitDeclarationOnly",
|
|
22
22
|
"build:js": "rollup -c",
|
|
23
23
|
"check:src": "npm run test",
|
|
24
24
|
"prepublishOnly": "npm run clean && npm run check:src && npm run build",
|
|
25
25
|
"lint": "yarn lint:types && yarn lint:eslint",
|
|
26
|
-
"lint:eslint": "eslint
|
|
26
|
+
"lint:eslint": "eslint src/ __tests__/",
|
|
27
27
|
"lint:types": "tsc --noEmit",
|
|
28
28
|
"version": "sed -i \"s/current_version = .*/current_version = $npm_package_version/\" .bumpversion.cfg && git add .bumpversion.cfg"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@types/urijs": "^1.19.
|
|
31
|
+
"@types/urijs": "^1.19.26",
|
|
32
32
|
"deep-diff": "^1.0.2",
|
|
33
|
-
"urijs": "^1.19.
|
|
33
|
+
"urijs": "^1.19.11"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@babel/core": "^7.
|
|
37
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
38
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
39
|
-
"@babel/preset-env": "^7.
|
|
40
|
-
"@babel/preset-typescript": "^7.
|
|
41
|
-
"@
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/urijs": "^1.19.
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"eslint": "^
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint-plugin-react": "^7.19.0",
|
|
55
|
-
"eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0",
|
|
56
|
-
"fetch-mock": "^9",
|
|
57
|
-
"husky": "^4.2.3",
|
|
58
|
-
"immutable": "^4.0.0-rc.12",
|
|
59
|
-
"jest": "^25.2.7",
|
|
60
|
-
"jest-fetch-mock": "^3.0.0",
|
|
61
|
-
"lint-staged": "^10.1.2",
|
|
36
|
+
"@babel/core": "^7.29.7",
|
|
37
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
38
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
39
|
+
"@babel/preset-env": "^7.29.7",
|
|
40
|
+
"@babel/preset-typescript": "^7.29.7",
|
|
41
|
+
"@eslint/js": "^10.0.1",
|
|
42
|
+
"@types/deep-diff": "^1.0.5",
|
|
43
|
+
"@types/urijs": "^1.19.26",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
|
45
|
+
"@typescript-eslint/parser": "^8.62.0",
|
|
46
|
+
"eslint": "^10.6.0",
|
|
47
|
+
"eslint-config-prettier": "^10.1.8",
|
|
48
|
+
"eslint-plugin-import": "^2.32.0",
|
|
49
|
+
"globals": "^14.0.0",
|
|
50
|
+
"husky": "^4.3.8",
|
|
51
|
+
"immutable": "^5.1.8",
|
|
52
|
+
"lint-staged": "^10.5.4",
|
|
53
|
+
"metch-fock": "^1.3.1",
|
|
62
54
|
"pluralize": "^8.0.0",
|
|
63
|
-
"prettier": "^
|
|
64
|
-
"
|
|
65
|
-
"rimraf": "^3.0.0",
|
|
66
|
-
"rollup": "^2.3.3",
|
|
55
|
+
"prettier": "^3.9.1",
|
|
56
|
+
"rollup": "^4.62.2",
|
|
67
57
|
"rollup-plugin-babel": "^4.4.0",
|
|
68
58
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
69
59
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
70
|
-
"typescript": "^
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.9"
|
|
71
62
|
},
|
|
72
63
|
"optionalDependencies": {
|
|
73
64
|
"pluralize": "^8.0.0"
|
|
@@ -95,12 +86,6 @@
|
|
|
95
86
|
"yarn run prettier --write"
|
|
96
87
|
]
|
|
97
88
|
},
|
|
98
|
-
"jest": {
|
|
99
|
-
"automock": false,
|
|
100
|
-
"setupFilesAfterEnv": [
|
|
101
|
-
"./setupJest.js"
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
89
|
"husky": {
|
|
105
90
|
"hooks": {
|
|
106
91
|
"pre-commit": "lint-staged"
|