codatta-frontier-sdk 0.1.0 → 0.1.2

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.cjs CHANGED
@@ -1 +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;
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 g={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 h=l(g,{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=h.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("/api/v2/frontier/task/detail",{task_id:t})).data}async submitTask(t,e){return(await this.request.post("/api/v2/frontier/task/submit",{task_id:t,data_submission:e})).data}async getTaskList(t){return(await this.request.post("/api/v2/frontier/task/list",t)).data}async getSubmissionList(t){return(await this.request.post("/api/v2/submission/list",t)).data}async getFrontierInfo(t){return(await this.request.get(`/api/v2/frontier/info?frontier_id=${t}`)).data}async getSubmissionDetail(t){return(await this.request.get("/api/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("/api/file/upload",n,{params:{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.mjs CHANGED
@@ -70,7 +70,7 @@ function d(r, t) {
70
70
  );
71
71
  }
72
72
  var g = d(h, { path: "/" });
73
- class I {
73
+ class C {
74
74
  constructor() {
75
75
  this.request = m.create({
76
76
  timeout: 3e4
@@ -102,38 +102,38 @@ class I {
102
102
  }
103
103
  // ─── API Methods ───────────────────────────────────────────────────────────
104
104
  async getTaskDetail(t) {
105
- return (await this.request.post("/v2/frontier/task/detail", { task_id: t })).data;
105
+ return (await this.request.post("/api/v2/frontier/task/detail", { task_id: t })).data;
106
106
  }
107
107
  async submitTask(t, e) {
108
- return (await this.request.post("/v2/frontier/task/submit", {
108
+ return (await this.request.post("/api/v2/frontier/task/submit", {
109
109
  task_id: t,
110
110
  data_submission: e
111
111
  })).data;
112
112
  }
113
113
  async getTaskList(t) {
114
- return (await this.request.post("/v2/frontier/task/list", t)).data;
114
+ return (await this.request.post("/api/v2/frontier/task/list", t)).data;
115
115
  }
116
116
  async getSubmissionList(t) {
117
- return (await this.request.post("/v2/submission/list", t)).data;
117
+ return (await this.request.post("/api/v2/submission/list", t)).data;
118
118
  }
119
119
  async getFrontierInfo(t) {
120
- return (await this.request.get(`/v2/frontier/info?frontier_id=${t}`)).data;
120
+ return (await this.request.get(`/api/v2/frontier/info?frontier_id=${t}`)).data;
121
121
  }
122
122
  async getSubmissionDetail(t) {
123
- return (await this.request.get("/v2/submission/user/detail", {
123
+ return (await this.request.get("/api/v2/submission/user/detail", {
124
124
  params: { submission_id: t }
125
125
  })).data;
126
126
  }
127
127
  async uploadFile(t, e) {
128
128
  const n = new FormData();
129
- return n.append("file", t), (await this.request.post("/file/upload", n, {
130
- headers: { "Content-Type": t.type },
129
+ return n.append("file", t), (await this.request.post("/api/file/upload", n, {
130
+ params: { content_type: t.type },
131
131
  onUploadProgress: e
132
132
  })).data.data;
133
133
  }
134
134
  }
135
135
  var w = /* @__PURE__ */ ((r) => (r.TWITTER = "x", r.TELEGRAM = "telegram", r.DISCORD = "discord", r.WEBSITE = "website", r.DOC = "doc", r))(w || {});
136
136
  export {
137
- I as FrontierSDK,
137
+ C as FrontierSDK,
138
138
  w as MediaName
139
139
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codatta-frontier-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Codatta Frontier SDK - API client for Codatta Frontier platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",