-
Notifications
You must be signed in to change notification settings - Fork 272
supporting aliyun oss data source #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dcde6df
Merge pull request #717 from lowcoder-org/dev
FalkWolsky c6f99ca
rollback git ignore
584827e
Merge branch 'main' into feature/aliyun-oss
encorearon 2836fcd
移除不需要的文件
02393ac
Merge branch 'dev' into feature/aliyun-oss
encorearon ff909c5
Merge branch 'dev' into feature/aliyun-oss
FalkWolsky ccc323b
Merge branch 'dev' into feature/aliyun-oss
FalkWolsky ab18284
Merge branch 'dev' into feature/aliyun-oss
FalkWolsky 1b05a0e
Merge branch 'dev' into feature/aliyun-oss
FalkWolsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/dataSourceConfig.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ConfigToType } from "lowcoder-sdk/dataSource"; | ||
import { AliyunOssI18nTranslator } from "./i18n"; | ||
|
||
const getDataSourceConfig = (i18n: AliyunOssI18nTranslator) => { | ||
const dataSourceConfig = { | ||
type: "dataSource", | ||
params: [ | ||
{ | ||
key: "accessKeyId", | ||
label: "Access key ID", | ||
type: "textInput", | ||
placeholder: "<Your Access key ID>", | ||
rules: [{ required: true, message: i18n.trans("akRequiredMessage") }], | ||
}, | ||
{ | ||
key: "accessKeySecret", | ||
label: "Secret key", | ||
type: "password", | ||
placeholder: "<Your Access key Secrect>", | ||
rules: [{ required: true, message: i18n.trans("skRequiredMessage") }], | ||
}, | ||
{ | ||
key: "arn", | ||
label: "ARN", | ||
type: "password", | ||
tooltip: i18n.trans("arnTooltip"), | ||
placeholder: "<Your Aliyun ARN>", | ||
rules: [{ required: true, message: i18n.trans("arnRequiredMessage") }], | ||
}, | ||
{ | ||
key: "endpointUrl", | ||
label: "STS Endpoint", | ||
type: "textInput", | ||
tooltip: i18n.trans("endpointUrlTooltip"), | ||
default: "sts.cn-hangzhou.aliyuncs.com", | ||
rules: [{ required: true }], | ||
}, | ||
{ | ||
key: "region", | ||
type: "textInput", | ||
label: i18n.trans("region"), | ||
defaultValue: "oss-cn-hangzhou", | ||
rules: [{ required: true }], | ||
}, | ||
], | ||
} as const; | ||
return dataSourceConfig; | ||
}; | ||
|
||
export default getDataSourceConfig; | ||
|
||
export type DataSourceDataType = ConfigToType<ReturnType<typeof getDataSourceConfig>>; |
30 changes: 30 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/i18n/en.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const en = { | ||
name: "OSS", | ||
description: "Supports Aliyun Object Storage Service (Based on STS)", | ||
skRequiredMessage: "Please input the SecretKey", | ||
akRequiredMessage: "Please input the AccessKey", | ||
arnRequiredMessage: "Please input the ARN", | ||
endpointUrlTooltip: "Endpoint url of STS service", | ||
arnTooltip: "The global resource descriptor for the role", | ||
bucket: "Bucket", | ||
returnSignedUrl: "Return signed url", | ||
actions: "Actions", | ||
prefix: "Prefix to filter", | ||
delimiter: "Delimiter", | ||
limit: "Limit", | ||
fileName: "File name", | ||
dataType: "Data type", | ||
data: "Data", | ||
dataTooltip:"The content of the data only supports BASE64 encoding, for example: window.btoa(xxx).", | ||
region: "OSS Region", | ||
messages: { | ||
bucketRequired: "Bucket is required", | ||
}, | ||
actionName: { | ||
listBuckets: "List buckets", | ||
listObjects: "List files", | ||
uploadFile: "Upload file", | ||
readFile: "Read file", | ||
deleteFile: "Delete file", | ||
}, | ||
}; |
9 changes: 9 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/i18n/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { en } from "./en"; | ||
import { zh } from "./zh"; | ||
import { I18n } from "../../../common/i18n"; | ||
|
||
export default function getI18nTranslator(languages: string[]) { | ||
return new I18n<typeof en>({ zh, en }, languages); | ||
} | ||
|
||
export type AliyunOssI18nTranslator = ReturnType<typeof getI18nTranslator>; |
32 changes: 32 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/i18n/zh.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { en } from "./en"; | ||
|
||
export const zh: typeof en = { | ||
name: "阿里云对象存储", | ||
description: "支持OSS对象存储服务(基于 STS 身份认证)", | ||
skRequiredMessage: "请输入 SecretKey", | ||
akRequiredMessage: "请输入 AccessKey", | ||
arnRequiredMessage: "请输入阿里云ARN", | ||
endpointUrlTooltip: "STS 服务接入点", | ||
arnTooltip: "角色的全局资源描述符", | ||
bucket: "存储桶", | ||
region: "OSS 区域", | ||
returnSignedUrl: "返回文件签名地址", | ||
actions: "方法", | ||
prefix: "前缀", | ||
delimiter: "分隔符", | ||
limit: "最大文件数", | ||
fileName: "文件名", | ||
dataType: "数据类型", | ||
data: "数据", | ||
dataTooltip:"数据内容仅支持 BASE64 编码,例:window.btoa(xxx)", | ||
messages: { | ||
bucketRequired: "需要提供存储桶名称", | ||
}, | ||
actionName: { | ||
listBuckets: "查询桶列表", | ||
listObjects: "获取文件列表", | ||
uploadFile: "上传文件", | ||
readFile: "读取文件", | ||
deleteFile: "删除文件", | ||
}, | ||
}; |
39 changes: 39 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DataSourcePluginFactory, PluginContext } from "lowcoder-sdk/dataSource"; | ||
import getI18nTranslator from "./i18n"; | ||
import getDataSourceConfig, { DataSourceDataType } from "./dataSourceConfig"; | ||
import run, { validateDataSourceConfig } from "./run"; | ||
import getQueryConfig, { ActionDataType } from "./queryConfig"; | ||
import { ServiceError } from "../../common/error"; | ||
|
||
const ossPlugin: DataSourcePluginFactory = (context: PluginContext) => { | ||
const i18n = getI18nTranslator(context.languages); | ||
return { | ||
id: "oss", | ||
name: i18n.trans("name"), | ||
icon: "https://img.alicdn.com/tfs/TB1_ZXuNcfpK1RjSZFOXXa6nFXa-32-32.ico", | ||
description: i18n.trans("description"), | ||
category: "api", | ||
dataSourceConfig: getDataSourceConfig(i18n), | ||
queryConfig: getQueryConfig(i18n), | ||
|
||
validateDataSourceConfig: async (dataSourceConfig: DataSourceDataType) => { | ||
return validateDataSourceConfig(dataSourceConfig); | ||
}, | ||
|
||
run: async ( | ||
action: ActionDataType, | ||
dataSourceConfig: DataSourceDataType, | ||
ctx: PluginContext | ||
) => { | ||
const i18n = getI18nTranslator(ctx.languages); | ||
try { | ||
return await run(action, dataSourceConfig, i18n); | ||
} catch (e:any) { | ||
throw new ServiceError(e.message, 400); | ||
} | ||
}, | ||
}; | ||
}; | ||
|
||
export default ossPlugin; | ||
|
80 changes: 80 additions & 0 deletions
server/node-service/src/plugins/aliyunOss/queryConfig.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ActionParamConfig, Config, ConfigToType, QueryConfig } from "lowcoder-sdk/dataSource"; | ||
import { AliyunOssI18nTranslator } from "./i18n"; | ||
|
||
function getQueryConfig(i18n: AliyunOssI18nTranslator) { | ||
const bucketActionParam = { | ||
key: "bucket", | ||
type: "textInput", | ||
label: i18n.trans("bucket"), | ||
} as const; | ||
|
||
const queryConfig = { | ||
type: "query", | ||
label: i18n.trans("actions"), | ||
actions: [ | ||
// { | ||
// actionName: "listBuckets", | ||
// label: i18n.trans("actionName.listBuckets"), | ||
// params: [], | ||
// }, | ||
{ | ||
actionName: "listObjects", | ||
label: i18n.trans("actionName.listObjects"), | ||
params: [ | ||
bucketActionParam, | ||
{ | ||
key: "prefix", | ||
type: "textInput", | ||
label: i18n.trans("prefix"), | ||
}, | ||
{ | ||
key: "delimiter", | ||
type: "textInput", | ||
label: i18n.trans("delimiter"), | ||
}, | ||
{ | ||
key: "limit", | ||
type: "numberInput", | ||
defaultValue: 10, | ||
label: i18n.trans("limit"), | ||
} | ||
], | ||
}, | ||
{ | ||
actionName: "uploadData", | ||
label: i18n.trans("actionName.uploadFile"), | ||
params: [ | ||
bucketActionParam, | ||
{ | ||
key: "fileName", | ||
type: "textInput", | ||
label: i18n.trans("fileName"), | ||
}, | ||
{ | ||
key: "data", | ||
type: "textInput", | ||
label: i18n.trans("data"), | ||
tooltip: i18n.trans("dataTooltip"), | ||
}, | ||
], | ||
}, | ||
// { | ||
// actionName: "deleteFile", | ||
// label: i18n.trans("actionName.deleteFile"), | ||
// params: [ | ||
// bucketActionParam, | ||
// { | ||
// key: "fileName", | ||
// type: "textInput", | ||
// label: i18n.trans("fileName"), | ||
// }, | ||
// ], | ||
// }, | ||
], | ||
} as const; | ||
return queryConfig; | ||
} | ||
|
||
export type ActionDataType = ConfigToType<ReturnType<typeof getQueryConfig>>; | ||
|
||
export default getQueryConfig; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.