@dartcom/ui-kit 10.1.3 → 10.1.4
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/dist/configs/global/global.d.ts +4 -2
- package/dist/configs/global/global.d.ts.map +1 -1
- package/dist/configs/global/types.d.ts +4 -0
- package/dist/configs/global/types.d.ts.map +1 -1
- package/dist/index.cjs +18 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/services/api/api.d.ts +6 -24
- package/dist/services/api/api.d.ts.map +1 -1
- package/dist/services/api/types.d.ts +25 -0
- package/dist/services/api/types.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { ApiService } from '../../services/api';
|
|
2
|
-
import { ResponseData } from './types';
|
|
2
|
+
import { BackendError, ResponseData } from './types';
|
|
3
3
|
export interface ConfigOptions {
|
|
4
4
|
apiKey: string;
|
|
5
5
|
backendUrl: string;
|
|
6
6
|
onCheck?: (data: ResponseData) => void;
|
|
7
|
+
onError?: (error: BackendError) => void;
|
|
7
8
|
}
|
|
8
9
|
export declare class GlobalConfig {
|
|
10
|
+
private configOptions;
|
|
9
11
|
private _apiService;
|
|
10
12
|
get apiService(): ApiService;
|
|
11
13
|
private static _instance;
|
|
12
14
|
static get instance(): GlobalConfig;
|
|
13
15
|
static initialize(options: ConfigOptions): void;
|
|
14
16
|
static deactivate(): void;
|
|
15
|
-
constructor(
|
|
17
|
+
constructor(configOptions: ConfigOptions);
|
|
16
18
|
private _apiKey;
|
|
17
19
|
private _isValidApiKey;
|
|
18
20
|
get isValidApiKey(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/configs/global/global.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/configs/global/global.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACzC;AAED,qBAAa,YAAY;IAyBX,OAAO,CAAC,aAAa;IAxBjC,OAAO,CAAC,WAAW,CAAa;IAChC,IAAW,UAAU,eAEpB;IAED,OAAO,CAAC,MAAM,CAAC,SAAS,CAAgC;IACxD,WAAkB,QAAQ,iBAQzB;WACa,UAAU,CAAC,OAAO,EAAE,aAAa;WAKjC,UAAU;gBAIJ,aAAa,EAAE,aAAa;IAehD,OAAO,CAAC,OAAO,CAAM;IAErB,OAAO,CAAC,cAAc,CAAS;IAC/B,IAAW,aAAa,YAEvB;IACD,IAAW,aAAa,CAAC,KAAK,SAAA,EAE7B;YAEa,gBAAgB;CAgC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/configs/global/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/configs/global/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;IACpC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -16817,23 +16817,23 @@ class ApiService {
|
|
|
16817
16817
|
return Promise.reject(error);
|
|
16818
16818
|
});
|
|
16819
16819
|
}
|
|
16820
|
-
async get({ url, config
|
|
16820
|
+
async get({ url, config }) {
|
|
16821
16821
|
const response = await this.client.get(url, config);
|
|
16822
16822
|
return response.data;
|
|
16823
16823
|
}
|
|
16824
|
-
async post({ url, body, config
|
|
16824
|
+
async post({ url, body, config }) {
|
|
16825
16825
|
const response = await this.client.post(url, body, config);
|
|
16826
16826
|
return response.data;
|
|
16827
16827
|
}
|
|
16828
|
-
async put({ url, body, config
|
|
16828
|
+
async put({ url, body, config }) {
|
|
16829
16829
|
const response = await this.client.put(url, body, config);
|
|
16830
16830
|
return response.data;
|
|
16831
16831
|
}
|
|
16832
|
-
async patch({ url, body, config
|
|
16832
|
+
async patch({ url, body, config }) {
|
|
16833
16833
|
const response = await this.client.patch(url, body, config);
|
|
16834
16834
|
return response.data;
|
|
16835
16835
|
}
|
|
16836
|
-
async delete({ url, config
|
|
16836
|
+
async delete({ url, config }) {
|
|
16837
16837
|
const response = await this.client.delete(url, config);
|
|
16838
16838
|
return response.data;
|
|
16839
16839
|
}
|
|
@@ -16845,6 +16845,7 @@ const createApiService = (baseURL) => {
|
|
|
16845
16845
|
};
|
|
16846
16846
|
|
|
16847
16847
|
class GlobalConfig {
|
|
16848
|
+
configOptions;
|
|
16848
16849
|
_apiService;
|
|
16849
16850
|
get apiService() {
|
|
16850
16851
|
return this._apiService;
|
|
@@ -16864,13 +16865,14 @@ class GlobalConfig {
|
|
|
16864
16865
|
static deactivate() {
|
|
16865
16866
|
this._instance = null;
|
|
16866
16867
|
}
|
|
16867
|
-
constructor(
|
|
16868
|
-
this.
|
|
16869
|
-
this.
|
|
16868
|
+
constructor(configOptions) {
|
|
16869
|
+
this.configOptions = configOptions;
|
|
16870
|
+
this._apiKey = configOptions.apiKey;
|
|
16871
|
+
this._apiService = createApiService(configOptions.backendUrl);
|
|
16870
16872
|
this._getCheckKeyData().then((data) => {
|
|
16871
16873
|
if (data) {
|
|
16872
16874
|
const { valid } = data;
|
|
16873
|
-
onCheck?.(data);
|
|
16875
|
+
configOptions.onCheck?.(data);
|
|
16874
16876
|
this.isValidApiKey = valid;
|
|
16875
16877
|
}
|
|
16876
16878
|
});
|
|
@@ -16894,11 +16896,17 @@ class GlobalConfig {
|
|
|
16894
16896
|
},
|
|
16895
16897
|
})
|
|
16896
16898
|
.then((data) => data)
|
|
16897
|
-
.catch((
|
|
16899
|
+
.catch((error) => {
|
|
16900
|
+
const { response, message } = error;
|
|
16901
|
+
this.configOptions.onError?.(error);
|
|
16898
16902
|
if (response) {
|
|
16899
16903
|
const { data: { detail }, } = response;
|
|
16900
16904
|
return detail;
|
|
16901
16905
|
}
|
|
16906
|
+
return {
|
|
16907
|
+
reason: message,
|
|
16908
|
+
valid: false,
|
|
16909
|
+
};
|
|
16902
16910
|
});
|
|
16903
16911
|
return checkKeyData;
|
|
16904
16912
|
}
|