codatta-frontier-sdk 0.1.2 → 0.1.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.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 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;
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}}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
@@ -129,7 +129,7 @@ class C {
129
129
  return n.append("file", t), (await this.request.post("/api/file/upload", n, {
130
130
  params: { content_type: t.type },
131
131
  onUploadProgress: e
132
- })).data.data;
132
+ })).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 || {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codatta-frontier-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Codatta Frontier SDK - API client for Codatta Frontier platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",