Skip to content
Merged
7 changes: 7 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export default [
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
},
},
];
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
"dependencies": {
"@alicloud/cloudapi20160714": "^4.7.8",
"@alicloud/ecs20140526": "^7.4.2",
"@alicloud/elasticsearch20170613": "^3.1.0",
"@alicloud/fc20230330": "^4.6.6",
"@alicloud/ims20190815": "^2.3.2",
"@alicloud/nas20170626": "^3.1.4",
"@alicloud/openapi-client": "^0.4.15",
"@alicloud/ram20150501": "^1.2.0",
"@alicloud/rds20140815": "^13.1.0",
"@alicloud/ros-cdk-apigateway": "^1.11.0",
"@alicloud/ros-cdk-core": "^1.11.0",
"@alicloud/ros-cdk-dns": "^1.11.0",
Expand Down
89 changes: 89 additions & 0 deletions src/common/aliyunClient/esOperations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import EsClient from '@alicloud/elasticsearch20170613';
import { Context } from '../../types';

export type EsConfig = {
AppName: string;
AppVersion: string;
Authentication?: {
BasicAuth?: Array<{
Password: string;
}>;
};
QuotaInfo: {
AppType: string;
MinCu: number;
};
Description?: string;
Network?: Array<{
Type: string;
Enabled: boolean;
WhiteIpGroup?: Array<{
GroupName: string;
Ips: string[];
}>;
}>;
ChargeType?: string;
RegionId?: string;
};

export type EsInfo = {
AppId?: string;
AppName?: string;
AppVersion?: string;
Status?: string;
Description?: string;
CreateTime?: number;
ModifiedTime?: number;
RegionId?: string;
QuotaInfo?: {
AppType?: string;
MinCu?: number;
};
Network?: Array<{
Type?: string;
Enabled?: boolean;
WhiteIpGroup?: Array<{
GroupName?: string;
Ips?: string[];
}>;
Endpoint?: string;
}>;
};

export const createEsOperations = (_esClient: EsClient, _context: Context) => {
const operations = {
createApp: async (_config: EsConfig): Promise<string> => {
// Note: Elasticsearch Serverless API support is limited.
// This implementation uses the regular Elasticsearch instance API as a workaround.
// For production use, consider using ROS API or wait for dedicated serverless SDK.

throw new Error(
'Elasticsearch Serverless direct API is not yet supported. ' +
'Please use ROS-based deployment or wait for dedicated SDK support.',
);
},

getApp: async (_appId: string): Promise<EsInfo | null> => {
throw new Error(
'Elasticsearch Serverless direct API is not yet supported. ' +
'Please use ROS-based deployment or wait for dedicated SDK support.',
);
},

updateApp: async (_appId: string, _config: EsConfig): Promise<void> => {
throw new Error(
'Elasticsearch Serverless direct API is not yet supported. ' +
'Please use ROS-based deployment or wait for dedicated SDK support.',
);
},

deleteApp: async (_appId: string): Promise<void> => {
throw new Error(
'Elasticsearch Serverless direct API is not yet supported. ' +
'Please use ROS-based deployment or wait for dedicated SDK support.',
);
},
};

return operations;
};
18 changes: 18 additions & 0 deletions src/common/aliyunClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import RamClient from '@alicloud/ram20150501';
import EcsClient from '@alicloud/ecs20140526';
import NasClient from '@alicloud/nas20170626';
import CloudApiClient from '@alicloud/cloudapi20160714';
import RdsClient from '@alicloud/rds20140815';
import EsClient from '@alicloud/elasticsearch20170613';
import * as $OpenApi from '@alicloud/openapi-client';
import OSS from 'ali-oss';
import { Context } from '../../types';
Expand All @@ -14,10 +16,14 @@ import { createEcsOperations } from './ecsOperations';
import { createNasOperations } from './nasOperations';
import { createApigwOperations } from './apigwOperations';
import { createOssOperations } from './ossOperations';
import { createRdsOperations } from './rdsOperations';
import { createEsOperations } from './esOperations';

export * from './types';
export * from './apigwOperations';
export * from './ossOperations';
export * from './rdsOperations';
export * from './esOperations';

const initializeSdkClients = (context: Context) => {
const baseConfig = {
Expand Down Expand Up @@ -58,6 +64,14 @@ const initializeSdkClients = (context: Context) => {
apigwConfig.endpoint = `apigateway.${context.region}.aliyuncs.com`;
const apigwClient = new CloudApiClient(apigwConfig);

const rdsConfig = new $OpenApi.Config(baseConfig);
rdsConfig.endpoint = `rds.aliyuncs.com`;
const rdsClient = new RdsClient(rdsConfig);

const esConfig = new $OpenApi.Config(baseConfig);
esConfig.endpoint = `elasticsearch.${context.region}.aliyuncs.com`;
const esClient = new EsClient(esConfig);

return {
fc3: fc3Client,
sls: slsClient,
Expand All @@ -66,6 +80,8 @@ const initializeSdkClients = (context: Context) => {
nas: nasClient,
oss: ossClient,
apigw: apigwClient,
rds: rdsClient,
es: esClient,
};
};

Expand All @@ -80,5 +96,7 @@ export const createAliyunClient = (context: Context) => {
nas: createNasOperations(sdkClients.nas),
oss: createOssOperations(sdkClients.oss, context.region),
apigw: createApigwOperations(sdkClients.apigw),
rds: createRdsOperations(sdkClients.rds, context),
es: createEsOperations(sdkClients.es, context),
};
};
Loading