codatta-frontier-sdk 0.1.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/README.md +80 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +190 -0
- package/dist/index.mjs +139 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Codatta Frontier SDK
|
|
2
|
+
|
|
3
|
+
Codatta Frontier 平台的 API 客户端 SDK。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install codatta-frontier-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> **注意**: `axios` 是 peerDependency,请确保项目中已安装 `axios >= 1.0.0`。
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { FrontierSDK } from 'codatta-frontier-sdk'
|
|
17
|
+
|
|
18
|
+
const sdk = new FrontierSDK()
|
|
19
|
+
|
|
20
|
+
// 获取任务详情
|
|
21
|
+
const taskDetail = await sdk.getTaskDetail('task-id')
|
|
22
|
+
|
|
23
|
+
// 获取任务列表
|
|
24
|
+
const taskList = await sdk.getTaskList({
|
|
25
|
+
frontier_id: 'frontier-id',
|
|
26
|
+
page_num: 1,
|
|
27
|
+
page_size: 10
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// 提交任务
|
|
31
|
+
const result = await sdk.submitTask('task-id', { field: 'value' })
|
|
32
|
+
|
|
33
|
+
// 获取提交列表
|
|
34
|
+
const submissions = await sdk.getSubmissionList({
|
|
35
|
+
page_num: 1,
|
|
36
|
+
page_size: 10,
|
|
37
|
+
frontier_id: 'frontier-id'
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// 获取 Frontier 信息
|
|
41
|
+
const frontierInfo = await sdk.getFrontierInfo('frontier-id')
|
|
42
|
+
|
|
43
|
+
// 获取提交详情
|
|
44
|
+
const submissionDetail = await sdk.getSubmissionDetail('submission-id')
|
|
45
|
+
|
|
46
|
+
// 上传文件(支持进度回调)
|
|
47
|
+
const uploadResult = await sdk.uploadFile(file, (event) => {
|
|
48
|
+
console.log(`Upload progress: ${Math.round((event.loaded * 100) / (event.total ?? 1))}%`)
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
### `new FrontierSDK()`
|
|
55
|
+
|
|
56
|
+
创建 SDK 实例。无需传入任何参数,SDK 内部自动处理:
|
|
57
|
+
|
|
58
|
+
- **Token**: 从 `cookie` (`auth`) 或 `localStorage` (`auth`) 中自动获取
|
|
59
|
+
- **Channel**: 根据 `userAgent` / `location.hash` 自动判断(App 或 Web)
|
|
60
|
+
- **Device**: 根据 `userAgent` 自动判断(移动端或 PC)
|
|
61
|
+
|
|
62
|
+
### 方法
|
|
63
|
+
|
|
64
|
+
| 方法 | 说明 |
|
|
65
|
+
|------|------|
|
|
66
|
+
| `getTaskDetail(taskId)` | 获取任务详情 |
|
|
67
|
+
| `submitTask(taskId, data)` | 提交任务数据 |
|
|
68
|
+
| `getTaskList(params)` | 获取任务列表(分页) |
|
|
69
|
+
| `getSubmissionList(params)` | 获取提交列表(分页) |
|
|
70
|
+
| `getFrontierInfo(frontierId)` | 获取 Frontier 详情 |
|
|
71
|
+
| `getSubmissionDetail(submissionId)` | 获取提交详情 |
|
|
72
|
+
| `uploadFile(file, onProgress?)` | 上传文件 |
|
|
73
|
+
|
|
74
|
+
## 构建
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run build
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
输出 ESM (`dist/index.mjs`) 和 CJS (`dist/index.cjs`) 以及类型声明文件。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("axios");/*! js-cookie v3.0.5 | MIT */function u(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)r[n]=e[n]}return r}var h={read:function(r){return r[0]==='"'&&(r=r.slice(1,-1)),r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(r){return encodeURIComponent(r).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function l(r,t){function e(o,i,s){if(!(typeof document>"u")){s=u({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var a in s)s[a]&&(c+="; "+a,s[a]!==!0&&(c+="="+s[a].split(";")[0]));return document.cookie=o+"="+r.write(i,o)+c}}function n(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},c=0;c<i.length;c++){var a=i[c].split("="),m=a.slice(1).join("=");try{var p=decodeURIComponent(a[0]);if(s[p]=r.read(m,p),o===p)break}catch{}}return o?s[o]:s}}return Object.create({set:e,get:n,remove:function(o,i){e(o,"",u({},i,{expires:-1}))},withAttributes:function(o){return l(this.converter,u({},this.attributes,o))},withConverter:function(o){return l(u({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(r)}})}var g=l(h,{path:"/"});class v{constructor(){this.request=d.create({timeout:3e4}),this.setupRequestInterceptor(),this.setupResponseInterceptor()}setupRequestInterceptor(){this.request.interceptors.request.use(t=>{var s;const e=navigator.userAgent.toLowerCase(),n=e.includes("codatta")||((s=location.hash)==null?void 0:s.toLowerCase().includes("codatta")),o=g.get("auth")||localStorage.getItem("auth"),i=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(e);return o&&(t.headers.token=o),t.headers.channel=n?"codatta-ios-app":"codatta-platform-website",t.headers.device=i?"mobile":"web",t})}setupResponseInterceptor(){this.request.interceptors.response.use(t=>{const e=t.data,n=Object.getOwnPropertyNames(e).includes("code"),o=Object.getOwnPropertyNames(e).includes("success");return n&&(e==null?void 0:e.code)!=="000000"?Promise.reject(new d.AxiosError(e==null?void 0:e.message,e==null?void 0:e.code,t.config,t.request,t)):o&&(e==null?void 0:e.success)!==!0?Promise.reject(new d.AxiosError(e==null?void 0:e.errorMessage,e==null?void 0:e.errorCode,t.config,t.request,t)):t},t=>{if(t.status===401){localStorage.removeItem("uid"),localStorage.removeItem("token"),localStorage.removeItem("auth");const e=new URL(window.location.href),n=e.pathname+e.search;window.location.href=`/account/signin?from=${encodeURIComponent(n)}`}return Promise.reject(t)})}async getTaskDetail(t){return(await this.request.post("/v2/frontier/task/detail",{task_id:t})).data}async submitTask(t,e){return(await this.request.post("/v2/frontier/task/submit",{task_id:t,data_submission:e})).data}async getTaskList(t){return(await this.request.post("/v2/frontier/task/list",t)).data}async getSubmissionList(t){return(await this.request.post("/v2/submission/list",t)).data}async getFrontierInfo(t){return(await this.request.get(`/v2/frontier/info?frontier_id=${t}`)).data}async getSubmissionDetail(t){return(await this.request.get("/v2/submission/user/detail",{params:{submission_id:t}})).data}async uploadFile(t,e){const n=new FormData;return n.append("file",t),(await this.request.post("/file/upload",n,{headers:{"Content-Type":t.type},onUploadProgress:e})).data.data}}var f=(r=>(r.TWITTER="x",r.TELEGRAM="telegram",r.DISCORD="discord",r.WEBSITE="website",r.DOC="doc",r))(f||{});exports.FrontierSDK=v;exports.MediaName=f;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { AxiosProgressEvent } from 'axios';
|
|
2
|
+
|
|
3
|
+
export declare type ActiveStatus = 'ACTIVE' | 'INACTIVE' | 'COMPLETED';
|
|
4
|
+
|
|
5
|
+
export declare interface CMUDataRequirements {
|
|
6
|
+
num: string;
|
|
7
|
+
querytext: string;
|
|
8
|
+
status: number;
|
|
9
|
+
part1: {
|
|
10
|
+
select?: string;
|
|
11
|
+
videos: Array<VideoItem>;
|
|
12
|
+
};
|
|
13
|
+
part2: {
|
|
14
|
+
videos: Array<VideoItem>;
|
|
15
|
+
questions: Array<{
|
|
16
|
+
title: string;
|
|
17
|
+
select?: string;
|
|
18
|
+
options: Array<{
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface FrontierItemType {
|
|
28
|
+
id?: number;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
logo_url: string;
|
|
32
|
+
banner?: string;
|
|
33
|
+
media_link?: Array<{
|
|
34
|
+
name: MediaName;
|
|
35
|
+
value: string;
|
|
36
|
+
}>;
|
|
37
|
+
qualification?: string;
|
|
38
|
+
videos?: Array<VideoItem>;
|
|
39
|
+
reputation_permission?: number;
|
|
40
|
+
frontier_id?: string;
|
|
41
|
+
adopt_count: number;
|
|
42
|
+
rewards: FrontierRewardItem[];
|
|
43
|
+
dataset_url: string | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare interface FrontierRewardItem {
|
|
47
|
+
reward_type: string;
|
|
48
|
+
reward_type_name: string;
|
|
49
|
+
reward_value: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare class FrontierSDK {
|
|
53
|
+
private request;
|
|
54
|
+
constructor();
|
|
55
|
+
private setupRequestInterceptor;
|
|
56
|
+
private setupResponseInterceptor;
|
|
57
|
+
getTaskDetail(taskId: string): Promise<Response_2<TaskDetail>>;
|
|
58
|
+
submitTask(taskId: string, data: object): Promise<Response_2<TaskDetail>>;
|
|
59
|
+
getTaskList(params: {
|
|
60
|
+
frontier_id: string;
|
|
61
|
+
page_num: number;
|
|
62
|
+
page_size: number;
|
|
63
|
+
task_types?: string;
|
|
64
|
+
}): Promise<PaginationResponse<TaskDetail[]>>;
|
|
65
|
+
getSubmissionList(data: TPagination & {
|
|
66
|
+
frontier_id?: string;
|
|
67
|
+
task_ids?: string;
|
|
68
|
+
}): Promise<PaginationResponse<TaskDetail[]>>;
|
|
69
|
+
getFrontierInfo(frontierId: string): Promise<Response_2<FrontierItemType>>;
|
|
70
|
+
getSubmissionDetail(submissionId: string): Promise<Response_2<SubmissionRecord>>;
|
|
71
|
+
uploadFile(file: File, onProgress?: (event: AxiosProgressEvent) => void): Promise<{
|
|
72
|
+
file_path: string;
|
|
73
|
+
original_name: string;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare enum MediaName {
|
|
78
|
+
TWITTER = "x",
|
|
79
|
+
TELEGRAM = "telegram",
|
|
80
|
+
DISCORD = "discord",
|
|
81
|
+
WEBSITE = "website",
|
|
82
|
+
DOC = "doc"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export declare interface PaginationResponse<T> {
|
|
86
|
+
data: T;
|
|
87
|
+
total: number;
|
|
88
|
+
page_num: number;
|
|
89
|
+
page_size: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export declare type RankingGrade = 'S' | 'A' | 'B' | 'C' | 'D';
|
|
93
|
+
|
|
94
|
+
declare interface Response_2<T> {
|
|
95
|
+
data: T;
|
|
96
|
+
success: true;
|
|
97
|
+
errorCode: number;
|
|
98
|
+
errorMessage: string;
|
|
99
|
+
}
|
|
100
|
+
export { Response_2 as Response }
|
|
101
|
+
|
|
102
|
+
export declare interface SubmissionRecord {
|
|
103
|
+
submission_time: number;
|
|
104
|
+
frontier_name: string;
|
|
105
|
+
task_name: string;
|
|
106
|
+
result: number;
|
|
107
|
+
rating_name: RankingGrade;
|
|
108
|
+
status: 'ADOPT' | 'PENDING' | 'REFUSED';
|
|
109
|
+
submission_id: string;
|
|
110
|
+
rewards: SubmissionReward[];
|
|
111
|
+
data_submission?: {
|
|
112
|
+
data: {
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
};
|
|
115
|
+
taskId: string;
|
|
116
|
+
templateId: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export declare interface SubmissionReward {
|
|
121
|
+
reward_type: string;
|
|
122
|
+
reward_amount: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare interface TaskDetail {
|
|
126
|
+
frontier_id: string;
|
|
127
|
+
task_id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
create_time: number;
|
|
130
|
+
submission_id: string;
|
|
131
|
+
task_type: string;
|
|
132
|
+
task_type_name: string;
|
|
133
|
+
template_id: string;
|
|
134
|
+
data_display: {
|
|
135
|
+
gif_resource: string;
|
|
136
|
+
template_id: string;
|
|
137
|
+
related_task_id?: string;
|
|
138
|
+
hide?: boolean;
|
|
139
|
+
link?: string;
|
|
140
|
+
bot_id?: string;
|
|
141
|
+
data_source?: string;
|
|
142
|
+
web_template_url?: string;
|
|
143
|
+
app_template_url?: string;
|
|
144
|
+
};
|
|
145
|
+
questions?: CMUDataRequirements[];
|
|
146
|
+
data_submission?: {
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
lifelog_report?: string;
|
|
149
|
+
};
|
|
150
|
+
question_status?: number;
|
|
151
|
+
data_requirements: unknown;
|
|
152
|
+
reward_info: readonly TaskRewardInfo[];
|
|
153
|
+
qualification_datas: unknown[];
|
|
154
|
+
status: 'PENDING' | 'SUBMITTED' | 'REFUSED' | 'ADOPT';
|
|
155
|
+
txHashUrl: string;
|
|
156
|
+
result: RankingGrade;
|
|
157
|
+
chain_status: 0 | 1 | 2 | 3 | 4;
|
|
158
|
+
qualification?: string;
|
|
159
|
+
qualification_flag: 0 | 1;
|
|
160
|
+
reputation: number;
|
|
161
|
+
reward_points: null | number;
|
|
162
|
+
user_reputation_flag: 0 | 1 | 2;
|
|
163
|
+
tags: string[];
|
|
164
|
+
audit_reason?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export declare interface TaskRewardInfo {
|
|
168
|
+
reward_icon: string;
|
|
169
|
+
reward_mode: string;
|
|
170
|
+
reward_type: string;
|
|
171
|
+
reward_value: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export declare type TaskType = 'submission' | 'validation';
|
|
175
|
+
|
|
176
|
+
export declare type TaskTypeName = 'Contribute' | 'Review';
|
|
177
|
+
|
|
178
|
+
export declare interface TPagination {
|
|
179
|
+
page_num: number;
|
|
180
|
+
page_size: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare interface VideoItem {
|
|
184
|
+
video_id: string;
|
|
185
|
+
desc?: string;
|
|
186
|
+
image_url?: string;
|
|
187
|
+
video_url: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import m, { AxiosError as l } from "axios";
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */
|
|
3
|
+
function u(r) {
|
|
4
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
5
|
+
var e = arguments[t];
|
|
6
|
+
for (var n in e)
|
|
7
|
+
r[n] = e[n];
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
var h = {
|
|
12
|
+
read: function(r) {
|
|
13
|
+
return r[0] === '"' && (r = r.slice(1, -1)), r.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
14
|
+
},
|
|
15
|
+
write: function(r) {
|
|
16
|
+
return encodeURIComponent(r).replace(
|
|
17
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
18
|
+
decodeURIComponent
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function d(r, t) {
|
|
23
|
+
function e(s, i, o) {
|
|
24
|
+
if (!(typeof document > "u")) {
|
|
25
|
+
o = u({}, t, o), typeof o.expires == "number" && (o.expires = new Date(Date.now() + o.expires * 864e5)), o.expires && (o.expires = o.expires.toUTCString()), s = encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
26
|
+
var c = "";
|
|
27
|
+
for (var a in o)
|
|
28
|
+
o[a] && (c += "; " + a, o[a] !== !0 && (c += "=" + o[a].split(";")[0]));
|
|
29
|
+
return document.cookie = s + "=" + r.write(i, s) + c;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function n(s) {
|
|
33
|
+
if (!(typeof document > "u" || arguments.length && !s)) {
|
|
34
|
+
for (var i = document.cookie ? document.cookie.split("; ") : [], o = {}, c = 0; c < i.length; c++) {
|
|
35
|
+
var a = i[c].split("="), f = a.slice(1).join("=");
|
|
36
|
+
try {
|
|
37
|
+
var p = decodeURIComponent(a[0]);
|
|
38
|
+
if (o[p] = r.read(f, p), s === p)
|
|
39
|
+
break;
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return s ? o[s] : o;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return Object.create(
|
|
47
|
+
{
|
|
48
|
+
set: e,
|
|
49
|
+
get: n,
|
|
50
|
+
remove: function(s, i) {
|
|
51
|
+
e(
|
|
52
|
+
s,
|
|
53
|
+
"",
|
|
54
|
+
u({}, i, {
|
|
55
|
+
expires: -1
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
withAttributes: function(s) {
|
|
60
|
+
return d(this.converter, u({}, this.attributes, s));
|
|
61
|
+
},
|
|
62
|
+
withConverter: function(s) {
|
|
63
|
+
return d(u({}, this.converter, s), this.attributes);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
attributes: { value: Object.freeze(t) },
|
|
68
|
+
converter: { value: Object.freeze(r) }
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
var g = d(h, { path: "/" });
|
|
73
|
+
class I {
|
|
74
|
+
constructor() {
|
|
75
|
+
this.request = m.create({
|
|
76
|
+
timeout: 3e4
|
|
77
|
+
}), this.setupRequestInterceptor(), this.setupResponseInterceptor();
|
|
78
|
+
}
|
|
79
|
+
// ─── Interceptors ──────────────────────────────────────────────────────────
|
|
80
|
+
setupRequestInterceptor() {
|
|
81
|
+
this.request.interceptors.request.use((t) => {
|
|
82
|
+
var o;
|
|
83
|
+
const e = navigator.userAgent.toLowerCase(), n = e.includes("codatta") || ((o = location.hash) == null ? void 0 : o.toLowerCase().includes("codatta")), s = g.get("auth") || localStorage.getItem("auth"), i = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(e);
|
|
84
|
+
return s && (t.headers.token = s), t.headers.channel = n ? "codatta-ios-app" : "codatta-platform-website", t.headers.device = i ? "mobile" : "web", t;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
setupResponseInterceptor() {
|
|
88
|
+
this.request.interceptors.response.use(
|
|
89
|
+
(t) => {
|
|
90
|
+
const e = t.data, n = Object.getOwnPropertyNames(e).includes("code"), s = Object.getOwnPropertyNames(e).includes("success");
|
|
91
|
+
return n && (e == null ? void 0 : e.code) !== "000000" ? Promise.reject(new l(e == null ? void 0 : e.message, e == null ? void 0 : e.code, t.config, t.request, t)) : s && (e == null ? void 0 : e.success) !== !0 ? Promise.reject(new l(e == null ? void 0 : e.errorMessage, e == null ? void 0 : e.errorCode, t.config, t.request, t)) : t;
|
|
92
|
+
},
|
|
93
|
+
(t) => {
|
|
94
|
+
if (t.status === 401) {
|
|
95
|
+
localStorage.removeItem("uid"), localStorage.removeItem("token"), localStorage.removeItem("auth");
|
|
96
|
+
const e = new URL(window.location.href), n = e.pathname + e.search;
|
|
97
|
+
window.location.href = `/account/signin?from=${encodeURIComponent(n)}`;
|
|
98
|
+
}
|
|
99
|
+
return Promise.reject(t);
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
// ─── API Methods ───────────────────────────────────────────────────────────
|
|
104
|
+
async getTaskDetail(t) {
|
|
105
|
+
return (await this.request.post("/v2/frontier/task/detail", { task_id: t })).data;
|
|
106
|
+
}
|
|
107
|
+
async submitTask(t, e) {
|
|
108
|
+
return (await this.request.post("/v2/frontier/task/submit", {
|
|
109
|
+
task_id: t,
|
|
110
|
+
data_submission: e
|
|
111
|
+
})).data;
|
|
112
|
+
}
|
|
113
|
+
async getTaskList(t) {
|
|
114
|
+
return (await this.request.post("/v2/frontier/task/list", t)).data;
|
|
115
|
+
}
|
|
116
|
+
async getSubmissionList(t) {
|
|
117
|
+
return (await this.request.post("/v2/submission/list", t)).data;
|
|
118
|
+
}
|
|
119
|
+
async getFrontierInfo(t) {
|
|
120
|
+
return (await this.request.get(`/v2/frontier/info?frontier_id=${t}`)).data;
|
|
121
|
+
}
|
|
122
|
+
async getSubmissionDetail(t) {
|
|
123
|
+
return (await this.request.get("/v2/submission/user/detail", {
|
|
124
|
+
params: { submission_id: t }
|
|
125
|
+
})).data;
|
|
126
|
+
}
|
|
127
|
+
async uploadFile(t, e) {
|
|
128
|
+
const n = new FormData();
|
|
129
|
+
return n.append("file", t), (await this.request.post("/file/upload", n, {
|
|
130
|
+
headers: { "Content-Type": t.type },
|
|
131
|
+
onUploadProgress: e
|
|
132
|
+
})).data.data;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var w = /* @__PURE__ */ ((r) => (r.TWITTER = "x", r.TELEGRAM = "telegram", r.DISCORD = "discord", r.WEBSITE = "website", r.DOC = "doc", r))(w || {});
|
|
136
|
+
export {
|
|
137
|
+
I as FrontierSDK,
|
|
138
|
+
w as MediaName
|
|
139
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codatta-frontier-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Codatta Frontier SDK - API client for Codatta Frontier platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "vite build",
|
|
21
|
+
"dev": "vite build --watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"js-cookie": "^3.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"axios": ">=1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/js-cookie": "^3.0.0",
|
|
31
|
+
"axios": "^1.7.0",
|
|
32
|
+
"typescript": "^5.5.0",
|
|
33
|
+
"vite": "^6.0.0",
|
|
34
|
+
"vite-plugin-dts": "^4.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|