@ossy/sdk 0.0.12-alpha → 0.0.14-alpha

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static of(e){return new t(e)}constructor(t){this.http=t?.http}signUp(t){return this.http.post("/users/sign-up",t)}signIn(t){return this.http.post("/users/sign-in",t)}verifySignIn(t){return this.http.get(`/users/verify-sign-in?token=${t}`)}verifyInvitation(t,e){return this.http.get(`/workspaces/${t}/invitations?token=${e}`)}getAuthenticatedUser(){return this.http.get("/users/me")}getAuthenticatedUserHistory(){return this.http.get("/users/me/history")}getUser(t){return this.http.get(`/users/${t}`)}signOff(){return this.http.get("/users/sign-off")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}create({type:t,resourceId:o}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!o)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${o}`,content:{resourceId:o,status:s.Queued,result:void 0}})}}class o{static of(t){return new o(t)}constructor(t){this.http=t?.http}create(t){return this.http.post("/users/me/tokens",t)}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}createDirectory({location:t,name:e}){return this.http.post("/resources",{type:"directory",location:t,name:e})}createDocument(t){return this.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({location:t="/",file:e}){return this.http.post("/resources",{type:e.type,location:t,name:e.name,size:e.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:e}).then((()=>t))))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then((()=>t))))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",t)}remove(t){return this.http.delete(`/resources/${t}`)}updateContent(t,e){return this.http.put(`/resources/${t}/content`,e)}move(t,e){return this.http.put(`/resources/${t}/location`,e)}rename(t,e){return this.http.put(`/resources/${t}/name`,e)}}class i{static of(t){return new i(t)}constructor(t){this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)}}getAll(){return this.http.get("/workspaces")}byId(t){return this.http.get(`/workspaces/${t}`)}create(t){return this.http.post("/workspaces",t)}importResourceTempaltes(t,e){return this.http.post(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function h(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function u(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:h((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?h((function(e){return t(e,r)})):c(r)?h((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),s=1,r=arguments.length;s<r;){var o=arguments[s];if(null!=o)for(var n in o)a(n,o)&&(e[n]=o[n]);s+=1}return e},l=u((function(t,e){return p({},t,e)}));const f={"Content-Type":"application/json",Accept:"application/json"};class d{static of(t){return new d(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...f,...t.headers})),"function"==typeof t?.headers&&(this.getHeaders=t.headers)}post(t,e){const s={method:"POST",body:JSON.stringify(e)};return this.fetch(t,s)}get(t){return this.fetch(t,{method:"GET"})}delete(t){return this.fetch(t,{method:"DELETE"})}put(t,e){const s={method:"PUT",body:JSON.stringify(e)};return this.fetch(t,s)}async fetch(t,e){const s={headers:await this.getHeaders(),credentials:"include"};return fetch(`${this.baseUrl}${t}`,l(e,s)).then((t=>{const e=t.headers.get("Content-Type")||"",s=t.status;return 400===s?t.json().then((t=>Promise.reject(t.error))):[200,204].includes(s)?e.includes("application/json")?t.json():t:Promise.reject(t)}))}}class g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=d.of({baseUrl:this.config?.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config?.workspaceId,Authorization:this.config?.apiKey}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=o.of({...this.config,http:c}),this.resources=n.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}exports.JobStatus=s,exports.Jobs=e,exports.SDK=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{static of(e){return new t(e)}constructor(t){this.http=t?.http}signUp(t){return this.http.post("/users/sign-up",t)}signIn(t){return this.http.post("/users/sign-in",t)}verifySignIn(t){return this.http.get(`/users/verify-sign-in?token=${t}`)}verifyInvitation(t,e){return this.http.get(`/workspaces/${t}/invitations?token=${e}`)}getAuthenticatedUser(){return this.http.get("/users/me")}getAuthenticatedUserHistory(){return this.http.get("/users/me/history")}getUser(t){return this.http.get(`/users/${t}`)}signOff(){return this.http.get("/users/sign-off")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}getUnprocessed(){return this.resources.search({$and:[{$or:[{"content.nextReevaluation":{$exists:!1}},{"content.nextReevaluation":null},{"content.nextReevaluation":{$lt:Date.now()}}]},{"content.status":{$in:["queued","failed"]}},{location:"/@ossy/jobs/"},{type:{$regex:"^@ossy/jobs"}}]})}create({type:t,resourceId:n}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${n}`,content:{resourceId:n,status:s.Queued,result:void 0}})}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}create(t){return this.http.post("/users/me/tokens",t)}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class o{static of(t){return new o(t)}constructor(t){this.http=t?.http}createDirectory({location:t,name:e}){return this.http.post("/resources",{type:"directory",location:t,name:e})}createDocument(t){return this.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({location:t="/",file:e}){return this.http.post("/resources",{type:e.type,location:t,name:e.name,size:e.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:e}).then((()=>t))))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then((()=>t))))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",t)}remove(t){return this.http.delete(`/resources/${t}`)}updateContent(t,e){return this.http.put(`/resources/${t}/content`,e)}move(t,e){return this.http.put(`/resources/${t}/location`,e)}rename(t,e){return this.http.put(`/resources/${t}/name`,e)}}class i{static of(t){return new i(t)}constructor(t){this.workspaceId=t?.workspaceId,this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.users=()=>this.getUsers()}getAll(){return this.http.get("/workspaces")}byId(t){return this.http.get(`/workspaces/${t}`)}create(t){return this.http.post("/workspaces",t)}importResourceTempaltes(t,e){return this.http.post(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}getUsers(){return this.http.get(`/workspaces/${this.workspaceId}/users`)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function u(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function h(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:u((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?u((function(e){return t(e,r)})):c(r)?u((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),s=1,r=arguments.length;s<r;){var n=arguments[s];if(null!=n)for(var o in n)a(o,n)&&(e[o]=n[o]);s+=1}return e},l=h((function(t,e){return p({},t,e)}));const d={"Content-Type":"application/json",Accept:"application/json"};class f{static of(t){return new f(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...d,...t.headers})),"function"==typeof t?.headers&&(this.getHeaders=t.headers)}post(t,e){const s={method:"POST",body:JSON.stringify(e)};return this.fetch(t,s)}get(t){return this.fetch(t,{method:"GET"})}delete(t){return this.fetch(t,{method:"DELETE"})}put(t,e){const s={method:"PUT",body:JSON.stringify(e)};return this.fetch(t,s)}async fetch(t,e){const s={headers:await this.getHeaders(),credentials:"include"};return fetch(`${this.baseUrl}${t}`,l(e,s)).then((t=>{const e=t.headers.get("Content-Type")||"",s=t.status;return 400===s?t.json().then((t=>Promise.reject(t.error))):[200,204].includes(s)?e.includes("application/json")?t.json():t:Promise.reject(t)}))}}class g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=f.of({baseUrl:this.config?.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config?.workspaceId,Authorization:this.config?.apiKey}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=n.of({...this.config,http:c}),this.resources=o.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}exports.JobStatus=s,exports.Jobs=e,exports.SDK=g;
@@ -1 +1 @@
1
- class t{static of(e){return new t(e)}constructor(t){this.http=t?.http}signUp(t){return this.http.post("/users/sign-up",t)}signIn(t){return this.http.post("/users/sign-in",t)}verifySignIn(t){return this.http.get(`/users/verify-sign-in?token=${t}`)}verifyInvitation(t,e){return this.http.get(`/workspaces/${t}/invitations?token=${e}`)}getAuthenticatedUser(){return this.http.get("/users/me")}getAuthenticatedUserHistory(){return this.http.get("/users/me/history")}getUser(t){return this.http.get(`/users/${t}`)}signOff(){return this.http.get("/users/sign-off")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}create({type:t,resourceId:n}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${n}`,content:{resourceId:n,status:s.Queued,result:void 0}})}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}create(t){return this.http.post("/users/me/tokens",t)}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class o{static of(t){return new o(t)}constructor(t){this.http=t?.http}createDirectory({location:t,name:e}){return this.http.post("/resources",{type:"directory",location:t,name:e})}createDocument(t){return this.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({location:t="/",file:e}){return this.http.post("/resources",{type:e.type,location:t,name:e.name,size:e.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:e}).then((()=>t))))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then((()=>t))))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",t)}remove(t){return this.http.delete(`/resources/${t}`)}updateContent(t,e){return this.http.put(`/resources/${t}/content`,e)}move(t,e){return this.http.put(`/resources/${t}/location`,e)}rename(t,e){return this.http.put(`/resources/${t}/name`,e)}}class i{static of(t){return new i(t)}constructor(t){this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)}}getAll(){return this.http.get("/workspaces")}byId(t){return this.http.get(`/workspaces/${t}`)}create(t){return this.http.post("/workspaces",t)}importResourceTempaltes(t,e){return this.http.post(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function h(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function u(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:h((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?h((function(e){return t(e,r)})):c(r)?h((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),s=1,r=arguments.length;s<r;){var n=arguments[s];if(null!=n)for(var o in n)a(o,n)&&(e[o]=n[o]);s+=1}return e},l=u((function(t,e){return p({},t,e)}));const f={"Content-Type":"application/json",Accept:"application/json"};class d{static of(t){return new d(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...f,...t.headers})),"function"==typeof t?.headers&&(this.getHeaders=t.headers)}post(t,e){const s={method:"POST",body:JSON.stringify(e)};return this.fetch(t,s)}get(t){return this.fetch(t,{method:"GET"})}delete(t){return this.fetch(t,{method:"DELETE"})}put(t,e){const s={method:"PUT",body:JSON.stringify(e)};return this.fetch(t,s)}async fetch(t,e){const s={headers:await this.getHeaders(),credentials:"include"};return fetch(`${this.baseUrl}${t}`,l(e,s)).then((t=>{const e=t.headers.get("Content-Type")||"",s=t.status;return 400===s?t.json().then((t=>Promise.reject(t.error))):[200,204].includes(s)?e.includes("application/json")?t.json():t:Promise.reject(t)}))}}class g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=d.of({baseUrl:this.config?.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config?.workspaceId,Authorization:this.config?.apiKey}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=n.of({...this.config,http:c}),this.resources=o.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}export{s as JobStatus,e as Jobs,g as SDK};
1
+ class t{static of(e){return new t(e)}constructor(t){this.http=t?.http}signUp(t){return this.http.post("/users/sign-up",t)}signIn(t){return this.http.post("/users/sign-in",t)}verifySignIn(t){return this.http.get(`/users/verify-sign-in?token=${t}`)}verifyInvitation(t,e){return this.http.get(`/workspaces/${t}/invitations?token=${e}`)}getAuthenticatedUser(){return this.http.get("/users/me")}getAuthenticatedUserHistory(){return this.http.get("/users/me/history")}getUser(t){return this.http.get(`/users/${t}`)}signOff(){return this.http.get("/users/sign-off")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}getUnprocessed(){return this.resources.search({$and:[{$or:[{"content.nextReevaluation":{$exists:!1}},{"content.nextReevaluation":null},{"content.nextReevaluation":{$lt:Date.now()}}]},{"content.status":{$in:["queued","failed"]}},{location:"/@ossy/jobs/"},{type:{$regex:"^@ossy/jobs"}}]})}create({type:t,resourceId:n}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${n}`,content:{resourceId:n,status:s.Queued,result:void 0}})}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}create(t){return this.http.post("/users/me/tokens",t)}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class o{static of(t){return new o(t)}constructor(t){this.http=t?.http}createDirectory({location:t,name:e}){return this.http.post("/resources",{type:"directory",location:t,name:e})}createDocument(t){return this.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({location:t="/",file:e}){return this.http.post("/resources",{type:e.type,location:t,name:e.name,size:e.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:e}).then((()=>t))))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then((t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then((()=>t))))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",t)}remove(t){return this.http.delete(`/resources/${t}`)}updateContent(t,e){return this.http.put(`/resources/${t}/content`,e)}move(t,e){return this.http.put(`/resources/${t}/location`,e)}rename(t,e){return this.http.put(`/resources/${t}/name`,e)}}class i{static of(t){return new i(t)}constructor(t){this.workspaceId=t?.workspaceId,this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.users=()=>this.getUsers()}getAll(){return this.http.get("/workspaces")}byId(t){return this.http.get(`/workspaces/${t}`)}create(t){return this.http.post("/workspaces",t)}importResourceTempaltes(t,e){return this.http.post(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}getUsers(){return this.http.get(`/workspaces/${this.workspaceId}/users`)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function h(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function u(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:h((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?h((function(e){return t(e,r)})):c(r)?h((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),s=1,r=arguments.length;s<r;){var n=arguments[s];if(null!=n)for(var o in n)a(o,n)&&(e[o]=n[o]);s+=1}return e},l=u((function(t,e){return p({},t,e)}));const d={"Content-Type":"application/json",Accept:"application/json"};class f{static of(t){return new f(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...d,...t.headers})),"function"==typeof t?.headers&&(this.getHeaders=t.headers)}post(t,e){const s={method:"POST",body:JSON.stringify(e)};return this.fetch(t,s)}get(t){return this.fetch(t,{method:"GET"})}delete(t){return this.fetch(t,{method:"DELETE"})}put(t,e){const s={method:"PUT",body:JSON.stringify(e)};return this.fetch(t,s)}async fetch(t,e){const s={headers:await this.getHeaders(),credentials:"include"};return fetch(`${this.baseUrl}${t}`,l(e,s)).then((t=>{const e=t.headers.get("Content-Type")||"",s=t.status;return 400===s?t.json().then((t=>Promise.reject(t.error))):[200,204].includes(s)?e.includes("application/json")?t.json():t:Promise.reject(t)}))}}class g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=f.of({baseUrl:this.config?.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config?.workspaceId,Authorization:this.config?.apiKey}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=n.of({...this.config,http:c}),this.resources=o.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}export{s as JobStatus,e as Jobs,g as SDK};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/sdk",
3
3
  "description": "Sofware Development Kit for interactive with our services",
4
- "version": "0.0.12-alpha",
4
+ "version": "0.0.14-alpha",
5
5
  "url": "git://github.com/ossy-se/ossy.git",
6
6
  "source": "src/index.js",
7
7
  "main": "build/index.cjs.js",
@@ -28,6 +28,23 @@ export class JobsClient {
28
28
  return this.resources.search(query)
29
29
  }
30
30
 
31
+ getUnprocessed() {
32
+ return this.resources.search({
33
+ $and: [
34
+ {
35
+ $or: [
36
+ { "content.nextReevaluation": { $exists: false } },
37
+ { "content.nextReevaluation": null },
38
+ { "content.nextReevaluation": { $lt: Date.now() } }
39
+ ]
40
+ },
41
+ { 'content.status': { $in: ['queued', 'failed'] } },
42
+ { "location": "/@ossy/jobs/" },
43
+ { "type": { $regex: "^@ossy/jobs" } }
44
+ ]
45
+ })
46
+ }
47
+
31
48
  create({ type, resourceId }) {
32
49
  const jobTypeExists = Object.values(Jobs).includes(type)
33
50
  if (!jobTypeExists) throw new Error(`Job type ${type} does not exist`)
@@ -5,12 +5,16 @@ export class WorkspacesClient {
5
5
  }
6
6
 
7
7
  constructor(config) {
8
+ this.workspaceId = config?.workspaceId
8
9
  this.http = config?.http
9
10
 
10
11
  this.services = {
11
12
  enable: x => this.enableService(x),
12
13
  disable: x => this.disableService(x)
13
14
  }
15
+
16
+ this.users = () => this.getUsers()
17
+
14
18
  }
15
19
 
16
20
  getAll() {
@@ -72,4 +76,10 @@ export class WorkspacesClient {
72
76
  )
73
77
  }
74
78
 
79
+ getUsers() {
80
+ return this.http.get(
81
+ `/workspaces/${this.workspaceId}/users`
82
+ )
83
+ }
84
+
75
85
  }