@kontent-ai/core-sdk 10.0.0-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/.npmignore +14 -0
- package/LICENSE.md +9 -0
- package/README.md +30 -0
- package/dist/cjs/helpers/enum.helper.d.ts +8 -0
- package/dist/cjs/helpers/enum.helper.js +79 -0
- package/dist/cjs/helpers/enum.helper.js.map +1 -0
- package/dist/cjs/helpers/header.helper.d.ts +13 -0
- package/dist/cjs/helpers/header.helper.js +24 -0
- package/dist/cjs/helpers/header.helper.js.map +1 -0
- package/dist/cjs/helpers/headers-helper.d.ts +3 -0
- package/dist/cjs/helpers/headers-helper.js +37 -0
- package/dist/cjs/helpers/headers-helper.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +5 -0
- package/dist/cjs/helpers/index.js +22 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/helpers/retry-helper.d.ts +37 -0
- package/dist/cjs/helpers/retry-helper.js +152 -0
- package/dist/cjs/helpers/retry-helper.js.map +1 -0
- package/dist/cjs/helpers/url.helper.d.ts +10 -0
- package/dist/cjs/helpers/url.helper.js +30 -0
- package/dist/cjs/helpers/url.helper.js.map +1 -0
- package/dist/cjs/http/http.debugger.d.ts +6 -0
- package/dist/cjs/http/http.debugger.js +26 -0
- package/dist/cjs/http/http.debugger.js.map +1 -0
- package/dist/cjs/http/http.functions.d.ts +11 -0
- package/dist/cjs/http/http.functions.js +381 -0
- package/dist/cjs/http/http.functions.js.map +1 -0
- package/dist/cjs/http/http.models.d.ts +73 -0
- package/dist/cjs/http/http.models.js +3 -0
- package/dist/cjs/http/http.models.js.map +1 -0
- package/dist/cjs/http/http.service.d.ts +19 -0
- package/dist/cjs/http/http.service.js +110 -0
- package/dist/cjs/http/http.service.js.map +1 -0
- package/dist/cjs/http/ihttp.service.d.ts +9 -0
- package/dist/cjs/http/ihttp.service.js +3 -0
- package/dist/cjs/http/ihttp.service.js.map +1 -0
- package/dist/cjs/http/index.d.ts +6 -0
- package/dist/cjs/http/index.js +23 -0
- package/dist/cjs/http/index.js.map +1 -0
- package/dist/cjs/http/test-http.service.d.ts +17 -0
- package/dist/cjs/http/test-http.service.js +47 -0
- package/dist/cjs/http/test-http.service.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/models/index.d.ts +3 -0
- package/dist/cjs/models/index.js +20 -0
- package/dist/cjs/models/index.js.map +1 -0
- package/dist/cjs/models/isdk-info.d.ts +14 -0
- package/dist/cjs/models/isdk-info.js +3 -0
- package/dist/cjs/models/isdk-info.js.map +1 -0
- package/dist/cjs/models/parameters.d.ts +16 -0
- package/dist/cjs/models/parameters.js +30 -0
- package/dist/cjs/models/parameters.js.map +1 -0
- package/dist/cjs/models/url.models.d.ts +3 -0
- package/dist/cjs/models/url.models.js +3 -0
- package/dist/cjs/models/url.models.js.map +1 -0
- package/dist/cjs/sdk-info.generated.d.ts +2 -0
- package/dist/cjs/sdk-info.generated.js +9 -0
- package/dist/cjs/sdk-info.generated.js.map +1 -0
- package/dist/es2015/helpers/enum.helper.d.ts +8 -0
- package/dist/es2015/helpers/enum.helper.js +50 -0
- package/dist/es2015/helpers/enum.helper.js.map +1 -0
- package/dist/es2015/helpers/header.helper.d.ts +13 -0
- package/dist/es2015/helpers/header.helper.js +19 -0
- package/dist/es2015/helpers/header.helper.js.map +1 -0
- package/dist/es2015/helpers/headers-helper.d.ts +3 -0
- package/dist/es2015/helpers/headers-helper.js +11 -0
- package/dist/es2015/helpers/headers-helper.js.map +1 -0
- package/dist/es2015/helpers/index.d.ts +5 -0
- package/dist/es2015/helpers/index.js +6 -0
- package/dist/es2015/helpers/index.js.map +1 -0
- package/dist/es2015/helpers/retry-helper.d.ts +37 -0
- package/dist/es2015/helpers/retry-helper.js +145 -0
- package/dist/es2015/helpers/retry-helper.js.map +1 -0
- package/dist/es2015/helpers/url.helper.d.ts +10 -0
- package/dist/es2015/helpers/url.helper.js +23 -0
- package/dist/es2015/helpers/url.helper.js.map +1 -0
- package/dist/es2015/http/http.debugger.d.ts +6 -0
- package/dist/es2015/http/http.debugger.js +19 -0
- package/dist/es2015/http/http.debugger.js.map +1 -0
- package/dist/es2015/http/http.functions.d.ts +11 -0
- package/dist/es2015/http/http.functions.js +244 -0
- package/dist/es2015/http/http.functions.js.map +1 -0
- package/dist/es2015/http/http.models.d.ts +73 -0
- package/dist/es2015/http/http.models.js +2 -0
- package/dist/es2015/http/http.models.js.map +1 -0
- package/dist/es2015/http/http.service.d.ts +19 -0
- package/dist/es2015/http/http.service.js +45 -0
- package/dist/es2015/http/http.service.js.map +1 -0
- package/dist/es2015/http/ihttp.service.d.ts +9 -0
- package/dist/es2015/http/ihttp.service.js +2 -0
- package/dist/es2015/http/ihttp.service.js.map +1 -0
- package/dist/es2015/http/index.d.ts +6 -0
- package/dist/es2015/http/index.js +7 -0
- package/dist/es2015/http/index.js.map +1 -0
- package/dist/es2015/http/test-http.service.d.ts +17 -0
- package/dist/es2015/http/test-http.service.js +41 -0
- package/dist/es2015/http/test-http.service.js.map +1 -0
- package/dist/es2015/index.d.ts +3 -0
- package/dist/es2015/index.js +5 -0
- package/dist/es2015/index.js.map +1 -0
- package/dist/es2015/models/index.d.ts +3 -0
- package/dist/es2015/models/index.js +4 -0
- package/dist/es2015/models/index.js.map +1 -0
- package/dist/es2015/models/isdk-info.d.ts +14 -0
- package/dist/es2015/models/isdk-info.js +2 -0
- package/dist/es2015/models/isdk-info.js.map +1 -0
- package/dist/es2015/models/parameters.d.ts +16 -0
- package/dist/es2015/models/parameters.js +26 -0
- package/dist/es2015/models/parameters.js.map +1 -0
- package/dist/es2015/models/url.models.d.ts +3 -0
- package/dist/es2015/models/url.models.js +2 -0
- package/dist/es2015/models/url.models.js.map +1 -0
- package/dist/es2015/sdk-info.generated.d.ts +2 -0
- package/dist/es2015/sdk-info.generated.js +6 -0
- package/dist/es2015/sdk-info.generated.js.map +1 -0
- package/dist/es5/helpers/enum.helper.d.ts +8 -0
- package/dist/es5/helpers/enum.helper.js +66 -0
- package/dist/es5/helpers/enum.helper.js.map +1 -0
- package/dist/es5/helpers/header.helper.d.ts +13 -0
- package/dist/es5/helpers/header.helper.js +21 -0
- package/dist/es5/helpers/header.helper.js.map +1 -0
- package/dist/es5/helpers/headers-helper.d.ts +3 -0
- package/dist/es5/helpers/headers-helper.js +23 -0
- package/dist/es5/helpers/headers-helper.js.map +1 -0
- package/dist/es5/helpers/index.d.ts +5 -0
- package/dist/es5/helpers/index.js +6 -0
- package/dist/es5/helpers/index.js.map +1 -0
- package/dist/es5/helpers/retry-helper.d.ts +37 -0
- package/dist/es5/helpers/retry-helper.js +149 -0
- package/dist/es5/helpers/retry-helper.js.map +1 -0
- package/dist/es5/helpers/url.helper.d.ts +10 -0
- package/dist/es5/helpers/url.helper.js +27 -0
- package/dist/es5/helpers/url.helper.js.map +1 -0
- package/dist/es5/http/http.debugger.d.ts +6 -0
- package/dist/es5/http/http.debugger.js +23 -0
- package/dist/es5/http/http.debugger.js.map +1 -0
- package/dist/es5/http/http.functions.d.ts +11 -0
- package/dist/es5/http/http.functions.js +337 -0
- package/dist/es5/http/http.functions.js.map +1 -0
- package/dist/es5/http/http.models.d.ts +73 -0
- package/dist/es5/http/http.models.js +2 -0
- package/dist/es5/http/http.models.js.map +1 -0
- package/dist/es5/http/http.service.d.ts +19 -0
- package/dist/es5/http/http.service.js +72 -0
- package/dist/es5/http/http.service.js.map +1 -0
- package/dist/es5/http/ihttp.service.d.ts +9 -0
- package/dist/es5/http/ihttp.service.js +2 -0
- package/dist/es5/http/ihttp.service.js.map +1 -0
- package/dist/es5/http/index.d.ts +6 -0
- package/dist/es5/http/index.js +7 -0
- package/dist/es5/http/index.js.map +1 -0
- package/dist/es5/http/test-http.service.d.ts +17 -0
- package/dist/es5/http/test-http.service.js +44 -0
- package/dist/es5/http/test-http.service.js.map +1 -0
- package/dist/es5/index.d.ts +3 -0
- package/dist/es5/index.js +5 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/models/index.d.ts +3 -0
- package/dist/es5/models/index.js +4 -0
- package/dist/es5/models/index.js.map +1 -0
- package/dist/es5/models/isdk-info.d.ts +14 -0
- package/dist/es5/models/isdk-info.js +2 -0
- package/dist/es5/models/isdk-info.js.map +1 -0
- package/dist/es5/models/parameters.d.ts +16 -0
- package/dist/es5/models/parameters.js +27 -0
- package/dist/es5/models/parameters.js.map +1 -0
- package/dist/es5/models/url.models.d.ts +3 -0
- package/dist/es5/models/url.models.js +2 -0
- package/dist/es5/models/url.models.js.map +1 -0
- package/dist/es5/sdk-info.generated.d.ts +2 -0
- package/dist/es5/sdk-info.generated.js +6 -0
- package/dist/es5/sdk-info.generated.js.map +1 -0
- package/dist/umd/kontent-core.umd.js +3476 -0
- package/dist/umd/kontent-core.umd.js.map +1 -0
- package/dist/umd/kontent-core.umd.min.js +2 -0
- package/dist/umd/kontent-core.umd.min.js.map +1 -0
- package/dist/umd/report.json +1 -0
- package/dist/umd/report.min.json +1 -0
- package/dist/umd/stats.json +11920 -0
- package/dist/umd/stats.min.json +13789 -0
- package/lib/helpers/enum.helper.ts +63 -0
- package/lib/helpers/header.helper.ts +23 -0
- package/lib/helpers/headers-helper.ts +15 -0
- package/lib/helpers/index.ts +5 -0
- package/lib/helpers/retry-helper.ts +204 -0
- package/lib/helpers/url.helper.ts +26 -0
- package/lib/http/http.debugger.ts +21 -0
- package/lib/http/http.functions.ts +312 -0
- package/lib/http/http.models.ts +83 -0
- package/lib/http/http.service.ts +91 -0
- package/lib/http/ihttp.service.ts +20 -0
- package/lib/http/index.ts +6 -0
- package/lib/http/test-http.service.ts +70 -0
- package/lib/index.ts +4 -0
- package/lib/models/index.ts +3 -0
- package/lib/models/isdk-info.ts +15 -0
- package/lib/models/parameters.ts +25 -0
- package/lib/models/url.models.ts +3 -0
- package/lib/sdk-info.generated.ts +7 -0
- package/package.json +87 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ResponseType } from 'axios';
|
|
2
|
+
|
|
3
|
+
export interface IResponseRetryStrategyResult {
|
|
4
|
+
options: IRetryStrategyOptions;
|
|
5
|
+
retryAttempts: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IResponse<TRawData> {
|
|
9
|
+
data: TRawData;
|
|
10
|
+
headers: IHeader[];
|
|
11
|
+
rawResponse: any;
|
|
12
|
+
status: number;
|
|
13
|
+
retryStrategy: IResponseRetryStrategyResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IRetryStrategyOptions {
|
|
17
|
+
/**
|
|
18
|
+
* back-off interval between retries
|
|
19
|
+
*/
|
|
20
|
+
deltaBackoffMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum allowed number of attempts
|
|
23
|
+
*/
|
|
24
|
+
maxAttempts?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Indicates if jitter is added to retry
|
|
27
|
+
*/
|
|
28
|
+
addJitter?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Determines if error can be retried. There are errors that are never retried
|
|
31
|
+
* such as when request is cancelled or the response status is 404 and so on...
|
|
32
|
+
*/
|
|
33
|
+
canRetryError?: (error: any) => boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IHttpQueryCall {
|
|
37
|
+
url: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IHttpPostQueryCall extends IHttpQueryCall {
|
|
41
|
+
body: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IHttpPutQueryCall extends IHttpQueryCall {
|
|
45
|
+
body: any;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IHttpPatchQueryCall extends IHttpQueryCall {
|
|
49
|
+
body: any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IHttpDeleteQueryCall extends IHttpQueryCall {}
|
|
53
|
+
|
|
54
|
+
export interface IHttpGetQueryCall extends IHttpQueryCall {}
|
|
55
|
+
|
|
56
|
+
export interface IHttpCancelRequestToken<TCancelToken> {
|
|
57
|
+
token: TCancelToken;
|
|
58
|
+
cancel: (cancelMessage?: string) => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface IHttpQueryOptions<TCancelToken> {
|
|
62
|
+
/**
|
|
63
|
+
* retry strategy
|
|
64
|
+
*/
|
|
65
|
+
retryStrategy?: IRetryStrategyOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Request headers
|
|
68
|
+
*/
|
|
69
|
+
headers?: IHeader[];
|
|
70
|
+
/**
|
|
71
|
+
* Response type
|
|
72
|
+
*/
|
|
73
|
+
responseType?: ResponseType;
|
|
74
|
+
/**
|
|
75
|
+
* Cancel token
|
|
76
|
+
*/
|
|
77
|
+
cancelToken?: IHttpCancelRequestToken<TCancelToken>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface IHeader {
|
|
81
|
+
header: string;
|
|
82
|
+
value: string;
|
|
83
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig, CancelToken } from 'axios';
|
|
2
|
+
|
|
3
|
+
import * as HttpFunctions from './http.functions';
|
|
4
|
+
import { IHttpFunctionsConfig } from './http.functions';
|
|
5
|
+
import {
|
|
6
|
+
IResponse,
|
|
7
|
+
IHttpDeleteQueryCall,
|
|
8
|
+
IHttpGetQueryCall,
|
|
9
|
+
IHttpPatchQueryCall,
|
|
10
|
+
IHttpPostQueryCall,
|
|
11
|
+
IHttpPutQueryCall,
|
|
12
|
+
IHttpQueryOptions,
|
|
13
|
+
IHttpCancelRequestToken
|
|
14
|
+
} from './http.models';
|
|
15
|
+
import { IHttpService } from './ihttp.service';
|
|
16
|
+
|
|
17
|
+
export class HttpService implements IHttpService<CancelToken> {
|
|
18
|
+
private readonly axiosInstance: AxiosInstance;
|
|
19
|
+
|
|
20
|
+
private readonly functionsConfig: IHttpFunctionsConfig;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private opts?: {
|
|
24
|
+
axiosRequestConfig?: AxiosRequestConfig;
|
|
25
|
+
logErrorsToConsole?: boolean;
|
|
26
|
+
}
|
|
27
|
+
) {
|
|
28
|
+
this.axiosInstance = axios.create(opts?.axiosRequestConfig);
|
|
29
|
+
this.functionsConfig = this.getFunctionsConfig();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async getAsync<TRawData>(
|
|
33
|
+
call: IHttpGetQueryCall,
|
|
34
|
+
options?: IHttpQueryOptions<CancelToken>
|
|
35
|
+
): Promise<IResponse<TRawData>> {
|
|
36
|
+
return await HttpFunctions.getWithRetryAsync<TRawData>(this.axiosInstance, call, this.functionsConfig, options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async postAsync<TRawData>(
|
|
40
|
+
call: IHttpPostQueryCall,
|
|
41
|
+
options?: IHttpQueryOptions<CancelToken>
|
|
42
|
+
): Promise<IResponse<TRawData>> {
|
|
43
|
+
return await HttpFunctions.postWithRetryAsync<TRawData>(
|
|
44
|
+
this.axiosInstance,
|
|
45
|
+
call,
|
|
46
|
+
this.functionsConfig,
|
|
47
|
+
options
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async putAsync<TRawData>(
|
|
52
|
+
call: IHttpPutQueryCall,
|
|
53
|
+
options?: IHttpQueryOptions<CancelToken>
|
|
54
|
+
): Promise<IResponse<TRawData>> {
|
|
55
|
+
return await HttpFunctions.putWithRetryAsync<TRawData>(this.axiosInstance, call, this.functionsConfig, options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async patchAsync<TRawData>(
|
|
59
|
+
call: IHttpPatchQueryCall,
|
|
60
|
+
options?: IHttpQueryOptions<CancelToken>
|
|
61
|
+
): Promise<IResponse<TRawData>> {
|
|
62
|
+
return await HttpFunctions.patchWithRetryAsync<TRawData>(
|
|
63
|
+
this.axiosInstance,
|
|
64
|
+
call,
|
|
65
|
+
this.functionsConfig,
|
|
66
|
+
options
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async deleteAsync<TRawData>(
|
|
71
|
+
call: IHttpDeleteQueryCall,
|
|
72
|
+
options?: IHttpQueryOptions<CancelToken>
|
|
73
|
+
): Promise<IResponse<TRawData>> {
|
|
74
|
+
return await HttpFunctions.deleteWithRetryAsync<TRawData>(
|
|
75
|
+
this.axiosInstance,
|
|
76
|
+
call,
|
|
77
|
+
this.functionsConfig,
|
|
78
|
+
options
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
createCancelToken(): IHttpCancelRequestToken<CancelToken> {
|
|
83
|
+
return HttpFunctions.createCancelToken();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private getFunctionsConfig(): IHttpFunctionsConfig {
|
|
87
|
+
return {
|
|
88
|
+
logErrorsToConsole: this.opts?.logErrorsToConsole ?? true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IResponse,
|
|
3
|
+
IHttpDeleteQueryCall,
|
|
4
|
+
IHttpGetQueryCall,
|
|
5
|
+
IHttpPostQueryCall,
|
|
6
|
+
IHttpPutQueryCall,
|
|
7
|
+
IHttpQueryOptions,
|
|
8
|
+
IHttpPatchQueryCall,
|
|
9
|
+
IHttpCancelRequestToken,
|
|
10
|
+
} from './http.models';
|
|
11
|
+
|
|
12
|
+
export interface IHttpService<TCancelToken> {
|
|
13
|
+
getAsync<TRawData>(call: IHttpGetQueryCall, options?: IHttpQueryOptions<TCancelToken>): Promise<IResponse<TRawData>>;
|
|
14
|
+
postAsync<TRawData>(call: IHttpPostQueryCall, options?: IHttpQueryOptions<TCancelToken>): Promise<IResponse<TRawData>>;
|
|
15
|
+
putAsync<TRawData>(call: IHttpPutQueryCall, options?: IHttpQueryOptions<TCancelToken>): Promise<IResponse<TRawData>>;
|
|
16
|
+
patchAsync<TRawData>(call: IHttpPatchQueryCall, options?: IHttpQueryOptions<TCancelToken>): Promise<IResponse<TRawData>>;
|
|
17
|
+
deleteAsync<TRawData>(call: IHttpDeleteQueryCall, options?: IHttpQueryOptions<TCancelToken>): Promise<IResponse<TRawData>>;
|
|
18
|
+
|
|
19
|
+
createCancelToken(): IHttpCancelRequestToken<TCancelToken>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IResponse,
|
|
3
|
+
IHttpDeleteQueryCall,
|
|
4
|
+
IHttpGetQueryCall,
|
|
5
|
+
IHttpPatchQueryCall,
|
|
6
|
+
IHttpPostQueryCall,
|
|
7
|
+
IHttpPutQueryCall,
|
|
8
|
+
IHttpQueryOptions,
|
|
9
|
+
IHttpCancelRequestToken
|
|
10
|
+
} from './http.models';
|
|
11
|
+
import { IHttpService } from './ihttp.service';
|
|
12
|
+
|
|
13
|
+
export class TestHttpService implements IHttpService<undefined> {
|
|
14
|
+
public response?: IResponse<any> = undefined;
|
|
15
|
+
public error?: any = undefined;
|
|
16
|
+
|
|
17
|
+
constructor(config: { response?: IResponse<any>; error?: any }) {
|
|
18
|
+
Object.assign(this, config);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getAsync<TRawData>(call: IHttpGetQueryCall, options?: IHttpQueryOptions<undefined>): Promise<IResponse<TRawData>> {
|
|
22
|
+
return this.resolveTestCall();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
postAsync<TRawData>(
|
|
26
|
+
call: IHttpPostQueryCall,
|
|
27
|
+
options?: IHttpQueryOptions<undefined>
|
|
28
|
+
): Promise<IResponse<TRawData>> {
|
|
29
|
+
return this.resolveTestCall();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
putAsync<TRawData>(call: IHttpPutQueryCall, options?: IHttpQueryOptions<undefined>): Promise<IResponse<TRawData>> {
|
|
33
|
+
return this.resolveTestCall();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
patchAsync<TRawData>(
|
|
37
|
+
call: IHttpPatchQueryCall,
|
|
38
|
+
options?: IHttpQueryOptions<undefined>
|
|
39
|
+
): Promise<IResponse<TRawData>> {
|
|
40
|
+
return this.resolveTestCall();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
deleteAsync<TRawData>(
|
|
44
|
+
call: IHttpDeleteQueryCall,
|
|
45
|
+
options?: IHttpQueryOptions<undefined>
|
|
46
|
+
): Promise<IResponse<TRawData>> {
|
|
47
|
+
return this.resolveTestCall();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
createCancelToken(): IHttpCancelRequestToken<undefined> {
|
|
51
|
+
return {
|
|
52
|
+
cancel: () => {},
|
|
53
|
+
token: undefined
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private resolveTestCall(): Promise<IResponse<any>> {
|
|
58
|
+
const promise = new Promise<IResponse<any>>((resolve, reject) => {
|
|
59
|
+
if (this.response) {
|
|
60
|
+
resolve(this.response);
|
|
61
|
+
}
|
|
62
|
+
if (this.error) {
|
|
63
|
+
reject(this.error);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
throw Error(`Missing test data`);
|
|
67
|
+
});
|
|
68
|
+
return promise;
|
|
69
|
+
}
|
|
70
|
+
}
|
package/lib/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IQueryParameter } from './url.models';
|
|
2
|
+
|
|
3
|
+
export namespace Parameters {
|
|
4
|
+
export class CustomParameter implements IQueryParameter {
|
|
5
|
+
/**
|
|
6
|
+
* Custom parameter
|
|
7
|
+
* @constructor
|
|
8
|
+
* @param {string} name - Name of the parameter
|
|
9
|
+
* @param {string} value - Value of the parameter
|
|
10
|
+
*/
|
|
11
|
+
constructor(public name: string, public value: string) {
|
|
12
|
+
if (!name) {
|
|
13
|
+
throw Error(`Name of the custom parameter is not specified`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public getParam(): string {
|
|
18
|
+
return this.name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getParamValue(): string {
|
|
22
|
+
return this.value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kontent-ai/core-sdk",
|
|
3
|
+
"version": "10.0.0-0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/kontent-ai/kontent-core-js"
|
|
7
|
+
},
|
|
8
|
+
"private": false,
|
|
9
|
+
"author": "richard sustek",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"description": "Core package with shared / common functionality for Kontent.ai SDKs",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"Kontent.ai",
|
|
14
|
+
"Kontent AI",
|
|
15
|
+
"Kontent SDK Core"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">= 8"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/cjs/index.js",
|
|
21
|
+
"module": "./dist/es5/index.js",
|
|
22
|
+
"es2015": "./dist/es2015/index.js",
|
|
23
|
+
"types": "./dist/cjs/index.d.ts",
|
|
24
|
+
"standard-version": {
|
|
25
|
+
"scripts": {
|
|
26
|
+
"postchangelog": "npm run set-sdk-version"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"release": "standard-version",
|
|
31
|
+
"release:major": "npm run ts-lint:check && standard-version --release-as major",
|
|
32
|
+
"release:major:beta": "npm run ts-lint:check && standard-version --prerelease --release-as major",
|
|
33
|
+
"release:beta": "standard-version --prerelease",
|
|
34
|
+
"ts-lint:fix": "tslint --project ./tsconfig.json --fix",
|
|
35
|
+
"ts-lint:check": "tslint --project ./tsconfig.json",
|
|
36
|
+
"test:node": "npm run build:cjs && mocha -- \"test/node/**/*.js\" --timeout 15000",
|
|
37
|
+
"test:browser": "karma start karma.conf.js",
|
|
38
|
+
"test:dev": "karma start karma-dev.conf.js",
|
|
39
|
+
"test:ci": "karma start karma-ci.conf.js",
|
|
40
|
+
"test:all": "npm run test:node && npm run test:ci",
|
|
41
|
+
"new-patch": "npm version patch && npm run set-sdk-version && npm run check-version",
|
|
42
|
+
"new-minor": "npm version minor && npm run set-sdk-version && npm run check-version",
|
|
43
|
+
"new-major": "npm version major && npm run set-sdk-version && npm run check-version",
|
|
44
|
+
"prepublishOnly": "npm run ts-lint:check && npm run check-version && npm run build:all && npm run test:all",
|
|
45
|
+
"webpack:dev": "webpack --mode development --config webpack.config.js --progress",
|
|
46
|
+
"webpack:prod": "webpack --mode production --config webpack.config.js --progress",
|
|
47
|
+
"set-sdk-version": "node ./misc/set-sdk-version.js",
|
|
48
|
+
"check-version": "ts-node ./misc/verify-sdk-version.ts",
|
|
49
|
+
"publish:beta": "npm publish --tag=next",
|
|
50
|
+
"build:umd": "npm run webpack:dev && npm run webpack:prod",
|
|
51
|
+
"build:es2015": "tsc --p tsconfig.es2015.json",
|
|
52
|
+
"build:es5": "tsc --p tsconfig.es5.json",
|
|
53
|
+
"build:cjs": "tsc --p tsconfig.cjs.json",
|
|
54
|
+
"build:all": "npm run build:umd && npm run build:cjs && npm run build:es5 && npm run build:es2015",
|
|
55
|
+
"bundle-stats:min": "npm run build:umd && webpack-bundle-analyzer dist/_bundles/stats.min.json",
|
|
56
|
+
"bundle-stats": "npm run build:umd && webpack-bundle-analyzer dist/_bundles/stats.json"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"axios": "0.27.2"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/jasmine": "4.0.3",
|
|
63
|
+
"@types/node": "18.0.3",
|
|
64
|
+
"colors": "1.4.0",
|
|
65
|
+
"core-js": "3.23.4",
|
|
66
|
+
"jasmine-core": "4.2.0",
|
|
67
|
+
"jasmine-spec-reporter": "7.0.0",
|
|
68
|
+
"karma": "6.4.0",
|
|
69
|
+
"karma-chrome-launcher": "3.1.1",
|
|
70
|
+
"karma-cli": "2.0.0",
|
|
71
|
+
"karma-jasmine": "5.1.0",
|
|
72
|
+
"karma-jasmine-html-reporter": "2.0.0",
|
|
73
|
+
"karma-sourcemap-loader": "0.3.8",
|
|
74
|
+
"karma-typescript": "5.5.3",
|
|
75
|
+
"karma-typescript-es6-transform": "5.5.3",
|
|
76
|
+
"karma-webpack": "5.0.0",
|
|
77
|
+
"mocha": "10.0.0",
|
|
78
|
+
"standard-version": "9.5.0",
|
|
79
|
+
"ts-loader": "9.3.1",
|
|
80
|
+
"ts-node": "10.8.2",
|
|
81
|
+
"tslint": "6.1.3",
|
|
82
|
+
"typescript": "4.7.4",
|
|
83
|
+
"webpack": "5.73.0",
|
|
84
|
+
"webpack-bundle-analyzer": "4.5.0",
|
|
85
|
+
"webpack-cli": "4.10.0"
|
|
86
|
+
}
|
|
87
|
+
}
|