rest-client-sdk 7.2.3 → 7.4.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.
@@ -1,10 +1,10 @@
1
1
  import AbstractClient from '../client/AbstractClient';
2
2
  import Attribute from './Attribute';
3
3
  import Relation from './Relation';
4
- declare type AttributeListType = {
4
+ type AttributeListType = {
5
5
  [key: string]: Attribute;
6
6
  };
7
- export declare type DefaultSerializedModelType = {
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
- declare type Entity = any;
11
- export declare type MetadataDefinition = {
10
+ type Entity = any;
11
+ export type MetadataDefinition = {
12
12
  entity: Entity;
13
13
  list: Iterable<Entity>;
14
14
  };
15
- export declare type SdkMetadata = Record<string, MetadataDefinition>;
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 declare type Config = {
7
+ export type Config = {
8
8
  path: string;
9
9
  scheme: string;
10
10
  port?: number;
@@ -1,6 +1,6 @@
1
1
  import AbstractTokenGenerator from './AbstractTokenGenerator';
2
2
  import { Token, TokenResponse } from './types';
3
- declare type AuthorizationCodeFlowTokenGeneratorConfig = {
3
+ type AuthorizationCodeFlowTokenGeneratorConfig = {
4
4
  clientId: string;
5
5
  clientSecret: string;
6
6
  path: string;
@@ -9,7 +9,7 @@ declare type AuthorizationCodeFlowTokenGeneratorConfig = {
9
9
  port?: string;
10
10
  scope?: string;
11
11
  };
12
- declare type GenerateTokenParameters = {
12
+ type GenerateTokenParameters = {
13
13
  code: string;
14
14
  state?: string;
15
15
  };
@@ -20,7 +20,7 @@ interface AuthorizationCodeToken extends Token {
20
20
  expires_in?: number;
21
21
  scope?: string;
22
22
  }
23
- declare type AuthorizationCodeFlowResponse = TokenResponse<AuthorizationCodeToken>;
23
+ type AuthorizationCodeFlowResponse = TokenResponse<AuthorizationCodeToken>;
24
24
  /**
25
25
  * This generator take cares of the second part of the authorization code flow : the part where you have a "code"
26
26
  * and you have validated the "state"
@@ -1,6 +1,6 @@
1
1
  import AbstractTokenGenerator from './AbstractTokenGenerator';
2
2
  import { Token, TokenResponse } from './types';
3
- declare type Config = {
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
- declare type BaseParameters = {
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
- declare type ClientCredentialResponse = TokenResponse<ClientCredentialToken>;
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
- declare type Config = {
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
- declare type GenerateTokenParameters = {
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
- declare type PasswordTokenResponse = TokenResponse<PasswordToken>;
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
- declare type RefreshTokenFunc = (oldAccessToken: null | Token) => Promise<Token>;
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 declare type TokenBodyReturn<T> = TokenBody<T>;
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 declare type Token = {
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 declare type ErrorBody = {
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 declare type TokenBody<T> = T | ErrorBody;
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
- declare type Id = string | number;
4
- declare type StringKeyObject = Record<string, any>;
3
+ type Id = string | number;
4
+ type StringKeyObject = Record<string, any>;
5
5
  declare class UnitOfWork {
6
6
  #private;
7
7
  mapping: Mapping;
@@ -55,6 +55,15 @@ declare class AbstractClient<D extends MetadataDefinition> {
55
55
  * @param {Record<string, unknown>} requestParams parameters that will be send as second parameter to the `fetch` call
56
56
  */
57
57
  update(entity: D['entity'], queryParam?: Record<string, unknown>, requestParams?: Record<string, unknown>): Promise<D['entity']>;
58
+ /**
59
+ * partially update an entity using the `PATCH` HTTP verb
60
+ *
61
+ * @param {Record<string, unknown>} entity the entity to update
62
+ * @param {Record<string, unknown>} queryParam query parameters that will be added to the request
63
+ * @param {Record<string, unknown>} requestParams parameters that will be send as second parameter to the `fetch` call
64
+ */
65
+ patch(entity: D['entity'], queryParam?: Record<string, unknown>, requestParams?: Record<string, unknown>): Promise<D['entity']>;
66
+ private _update;
58
67
  /**
59
68
  * delete an entity
60
69
  *
@@ -1,8 +1,8 @@
1
1
  import ClassMetadata from '../Mapping/ClassMetadata';
2
- export declare type Entity = Record<string, unknown>;
3
- export declare type NormalizedObject = Record<string, unknown>;
4
- export declare type NormalizedList = Iterable<Record<string, unknown>>;
5
- export declare type EntityList = Iterable<Entity>;
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
- declare type SdkRequest = RequestInit & {
1
+ type SdkRequest = RequestInit & {
2
2
  url: string;
3
3
  };
4
- declare type SdkResponse = {
4
+ type SdkResponse = {
5
5
  status: number;
6
6
  headers: Record<string, string>;
7
7
  };
8
- export declare type SerializableRequest = {
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 declare type Log = {
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 declare type LoggerHistory = Array<Log>;
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.2.3",
3
+ "version": "7.4.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": "rimraf dist",
19
- "test": "yarn lint --quiet && jest",
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 --ext js,jsx,jsx,ts,tsx src/",
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.9",
31
+ "@types/urijs": "^1.19.26",
32
32
  "deep-diff": "^1.0.2",
33
- "urijs": "^1.19.2"
33
+ "urijs": "^1.19.11"
34
34
  },
35
35
  "devDependencies": {
36
- "@babel/core": "^7.10.5",
37
- "@babel/plugin-proposal-class-properties": "^7.10.4",
38
- "@babel/plugin-proposal-object-rest-spread": "^7.10.4",
39
- "@babel/preset-env": "^7.10.4",
40
- "@babel/preset-typescript": "^7.10.4",
41
- "@types/deep-diff": "^1.0.0",
42
- "@types/jest": "^26.0.22",
43
- "@types/urijs": "^1.19.9",
44
- "@typescript-eslint/eslint-plugin": "^3.6.1",
45
- "@typescript-eslint/parser": "^3.6.1",
46
- "babel-jest": "^25.2.6",
47
- "core-js": "^3.6.4",
48
- "eslint": "^6.8.0",
49
- "eslint-config-airbnb": "^18.1.0",
50
- "eslint-config-prettier": "^6.10.1",
51
- "eslint-plugin-import": "^2.31.0",
52
- "eslint-plugin-jsx-a11y": "^6.2.3",
53
- "eslint-plugin-prettier": "^3.1.2",
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": "^2.0.2",
64
- "regenerator-runtime": "^0.13.5",
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": "^3.9.6"
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"