@dj1029/plugin-smart-sl 0.0.2 → 0.0.3
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/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { IIntegration, TIntegrationProvider } from '@metad/contracts';
|
|
2
2
|
import { IntegrationStrategy, TIntegrationStrategyParams } from '@xpert-ai/plugin-sdk';
|
|
3
3
|
import { TSmartBIIntegrationConfig } from './types.js';
|
|
4
|
-
import { HttpClientService } from './http-client.service.js';
|
|
5
4
|
export declare class SmartBIIntegrationStrategy implements IntegrationStrategy<TSmartBIIntegrationConfig> {
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
5
|
+
private axiosInstance;
|
|
6
|
+
constructor();
|
|
8
7
|
meta: TIntegrationProvider;
|
|
9
8
|
/**
|
|
10
9
|
* 预留的执行方法,当前未使用
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrationStrategy.d.ts","sourceRoot":"","sources":["../../src/lib/integrationStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE7F,OAAO,EAAE,mBAAmB,EAA0B,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EAAyB,yBAAyB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"integrationStrategy.d.ts","sourceRoot":"","sources":["../../src/lib/integrationStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE7F,OAAO,EAAE,mBAAmB,EAA0B,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EAAyB,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAK7E,qBAEa,0BAA2B,YAAW,mBAAmB,CAAC,yBAAyB,CAAC;IAC7F,OAAO,CAAC,aAAa,CAAC;;IAoBtB,IAAI,EAAE,oBAAoB,CA6BzB;IAED;;;;OAIG;IACH,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/E,cAAc,CAAC,MAAM,EAAC,yBAAyB;CA0BxD"}
|
|
@@ -3,10 +3,11 @@ import { IntegrationFeatureEnum } from '@metad/contracts';
|
|
|
3
3
|
import { Injectable } from '@nestjs/common';
|
|
4
4
|
import { IntegrationStrategyKey } from '@xpert-ai/plugin-sdk';
|
|
5
5
|
import { SmartBIName, iconImage } from './types.js';
|
|
6
|
-
import { HttpClientService } from './http-client.service.js';
|
|
6
|
+
// import { HttpClientService } from './http-client.service.js';
|
|
7
|
+
import axios from 'axios';
|
|
7
8
|
let SmartBIIntegrationStrategy = class SmartBIIntegrationStrategy {
|
|
8
|
-
constructor(httpClient) {
|
|
9
|
-
|
|
9
|
+
// constructor(private httpClient: HttpClientService) {}
|
|
10
|
+
constructor() {
|
|
10
11
|
this.meta = {
|
|
11
12
|
name: SmartBIName,
|
|
12
13
|
label: {
|
|
@@ -37,6 +38,20 @@ let SmartBIIntegrationStrategy = class SmartBIIntegrationStrategy {
|
|
|
37
38
|
},
|
|
38
39
|
features: [IntegrationFeatureEnum.SSO, IntegrationFeatureEnum.KNOWLEDGE],
|
|
39
40
|
};
|
|
41
|
+
this.axiosInstance = axios.create({
|
|
42
|
+
baseURL: 'https://www.antsfind.com:449', // 设置基础URL
|
|
43
|
+
timeout: 10000, // 设置超时时间
|
|
44
|
+
headers: { 'Content-Type': 'application/json' }, // 设置默认头信息
|
|
45
|
+
});
|
|
46
|
+
// 添加拦截器(例如,请求和响应拦截)
|
|
47
|
+
this.axiosInstance.interceptors.request.use(config => {
|
|
48
|
+
// 在发送请求之前做些什么,例如设置认证头信息等
|
|
49
|
+
// config.headers['Authorization'] = `Bearer ${process.env.API_TOKEN}`; // 示例:从环境变量获取token
|
|
50
|
+
return config;
|
|
51
|
+
}, error => {
|
|
52
|
+
// 对请求错误做些什么
|
|
53
|
+
return Promise.reject(error);
|
|
54
|
+
});
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* 预留的执行方法,当前未使用
|
|
@@ -56,12 +71,19 @@ let SmartBIIntegrationStrategy = class SmartBIIntegrationStrategy {
|
|
|
56
71
|
if (!config.passWord) {
|
|
57
72
|
throw new Error('passWord is required');
|
|
58
73
|
}
|
|
59
|
-
return this.
|
|
74
|
+
return this.axiosInstance.post('/login', {
|
|
75
|
+
username: config.userName,
|
|
76
|
+
password: config.passWord
|
|
77
|
+
});
|
|
78
|
+
// return this.httpClient.post(
|
|
79
|
+
// '/login',
|
|
80
|
+
// {username:config.userName, password:config.passWord}
|
|
81
|
+
// )
|
|
60
82
|
}
|
|
61
83
|
};
|
|
62
84
|
SmartBIIntegrationStrategy = __decorate([
|
|
63
85
|
Injectable(),
|
|
64
86
|
IntegrationStrategyKey(SmartBIName),
|
|
65
|
-
__metadata("design:paramtypes", [
|
|
87
|
+
__metadata("design:paramtypes", [])
|
|
66
88
|
], SmartBIIntegrationStrategy);
|
|
67
89
|
export { SmartBIIntegrationStrategy };
|