@ossy/sdk 0.0.6-alpha → 0.0.8-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.
- package/build/index.cjs.js +1 -1
- package/build/index.esm.js +1 -1
- package/package.json +1 -1
- package/src/jobs-client.js +3 -1
- package/src/resources-client.js +13 -1
package/build/index.cjs.js
CHANGED
|
@@ -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"},s={Queued:"queued",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({type:t}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.byLocation(t)}create({type:t,resourceId:r}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.create({type:t,location:t,name:`[${s.Queued}] ${r}`,content:{resourceId:r,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})}
|
|
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",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({type:t}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.byLocation(t)}create({type:t,resourceId:r}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!r)throw new Error("Resource ID is required");return this.resources.create({type:t,location:t,name:`[${s.Queued}] ${r}`,content:{resourceId:r,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}`)}byQuery(t){return this.http.get("/resources"+(t?`?${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 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 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})}}exports.JobStatus=s,exports.Jobs=e,exports.SDK=g;
|
package/build/index.esm.js
CHANGED
|
@@ -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"},s={Queued:"queued",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({type:t}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.byLocation(t)}create({type:t,resourceId:r}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.create({type:t,location:t,name:`[${s.Queued}] ${r}`,content:{resourceId:r,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})}
|
|
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",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({type:t}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);return this.resources.byLocation(t)}create({type:t,resourceId:r}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!r)throw new Error("Resource ID is required");return this.resources.create({type:t,location:t,name:`[${s.Queued}] ${r}`,content:{resourceId:r,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}`)}byQuery(t){return this.http.get("/resources"+(t?`?${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 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 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};
|
package/package.json
CHANGED
package/src/jobs-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const Jobs = {
|
|
2
|
-
VisualContentDescriptors: '@ossy/jobs/visual-content-descriptors'
|
|
2
|
+
VisualContentDescriptors: '@ossy/jobs/visual-content-descriptors',
|
|
3
|
+
ResizeCommonWeb: '@ossy/jobs/resize-common-web',
|
|
3
4
|
}
|
|
4
5
|
|
|
5
6
|
export const JobStatus = {
|
|
@@ -28,6 +29,7 @@ export class JobsClient {
|
|
|
28
29
|
create({ type, resourceId }) {
|
|
29
30
|
const jobTypeExists = Object.values(Jobs).includes(type)
|
|
30
31
|
if (!jobTypeExists) throw new Error(`Job type ${type} does not exist`)
|
|
32
|
+
if (!resourceId) throw new Error(`Resource ID is required`)
|
|
31
33
|
return this.resources.create({
|
|
32
34
|
type,
|
|
33
35
|
location: type,
|
package/src/resources-client.js
CHANGED
|
@@ -30,7 +30,7 @@ export class ResourcesClient {
|
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
upload({ location = '/', file }) {
|
|
34
34
|
return this.http.post(`/resources`, {
|
|
35
35
|
type: file.type,
|
|
36
36
|
location: location,
|
|
@@ -43,6 +43,18 @@ export class ResourcesClient {
|
|
|
43
43
|
})
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// This is for uploading different sizes of images
|
|
47
|
+
uploadNamedVersion({ resourceId, name, file }) {
|
|
48
|
+
return this.http.put(`/resources/${resourceId}/${name}`, {
|
|
49
|
+
type: file.type,
|
|
50
|
+
size: file.size
|
|
51
|
+
})
|
|
52
|
+
.then(resource => {
|
|
53
|
+
return fetch(resource.content.uploadUrl, { method: 'PUT', body: file })
|
|
54
|
+
.then(() => resource)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
byId(resourceId) {
|
|
47
59
|
return this.http.get(`/resources/${resourceId}`)
|
|
48
60
|
}
|