@ossy/sdk 0.0.1-alpha → 0.0.3-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")}}class e{static of(t){return new e(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 s{static of(t){return new s(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.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}uploadFile({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))))}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}`)}updateResourceContent(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 r{static of(t){return new r(t)}constructor(t){this.http=t?.http}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)}}function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(t){return function e(s){return 0===arguments.length||n(s)?e:t.apply(this,arguments)}}function i(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return n(s)?e:o((function(e){return t(s,e)}));default:return n(s)&&n(r)?e:n(s)?o((function(e){return t(e,r)})):n(r)?o((function(e){return t(s,e)})):t(s,r)}}}function c(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var h="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)c(o,n)&&(e[o]=n[o]);s+=1}return e},u=i((function(t,e){return h({},t,e)}));const p={"Content-Type":"application/json",Accept:"application/json"};class a{static of(t){return new a(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...p,...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}`,u(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 f{static of(t){return new f(t)}constructor(t){this.updateConfig(t)}updateConfig(n){const o=this.config||{};this.config={...o,...n};const i=a.of({baseUrl:this.config.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config.workspaceId}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:i}),this.apiTokens=e.of({...this.config,http:i}),this.resources=s.of({...this.config,http:i}),this.workspaces=r.of({...this.config,http:i})}}exports.SDK=f;
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")}}class e{static of(t){return new e(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 s{static of(t){return new s(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.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}uploadFile({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))))}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 r{static of(t){return new r(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 n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(t){return function e(s){return 0===arguments.length||n(s)?e:t.apply(this,arguments)}}function i(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return n(s)?e:o((function(e){return t(s,e)}));default:return n(s)&&n(r)?e:n(s)?o((function(e){return t(e,r)})):n(r)?o((function(e){return t(s,e)})):t(s,r)}}}function c(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var h="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)c(o,n)&&(e[o]=n[o]);s+=1}return e},u=i((function(t,e){return h({},t,e)}));const p={"Content-Type":"application/json",Accept:"application/json"};class a{static of(t){return new a(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...p,...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}`,u(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 l{static of(t){return new l(t)}constructor(t){this.updateConfig(t)}updateConfig(n){const o=this.config||{};this.config={...o,...n};const i=a.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:i}),this.apiTokens=e.of({...this.config,http:i}),this.resources=s.of({...this.config,http:i}),this.workspaces=r.of({...this.config,http:i})}}exports.SDK=l;
@@ -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")}}class e{static of(t){return new e(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 s{static of(t){return new s(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.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}uploadFile({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))))}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}`)}updateResourceContent(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 r{static of(t){return new r(t)}constructor(t){this.http=t?.http}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)}}function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(t){return function e(s){return 0===arguments.length||n(s)?e:t.apply(this,arguments)}}function i(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return n(s)?e:o((function(e){return t(s,e)}));default:return n(s)&&n(r)?e:n(s)?o((function(e){return t(e,r)})):n(r)?o((function(e){return t(s,e)})):t(s,r)}}}function c(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var h="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)c(o,n)&&(e[o]=n[o]);s+=1}return e},u=i((function(t,e){return h({},t,e)}));const p={"Content-Type":"application/json",Accept:"application/json"};class a{static of(t){return new a(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...p,...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}`,u(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 f{static of(t){return new f(t)}constructor(t){this.updateConfig(t)}updateConfig(n){const o=this.config||{};this.config={...o,...n};const i=a.of({baseUrl:this.config.apiUrl||"https://api.ossy.se/api/v0",headers:{workspaceId:this.config.workspaceId}});this.workspaceId=this.config.workspaceId,this.auth=t.of({...this.config,http:i}),this.apiTokens=e.of({...this.config,http:i}),this.resources=s.of({...this.config,http:i}),this.workspaces=r.of({...this.config,http:i})}}export{f 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")}}class e{static of(t){return new e(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 s{static of(t){return new s(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.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}uploadFile({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))))}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 r{static of(t){return new r(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 n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(t){return function e(s){return 0===arguments.length||n(s)?e:t.apply(this,arguments)}}function i(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return n(s)?e:o((function(e){return t(s,e)}));default:return n(s)&&n(r)?e:n(s)?o((function(e){return t(e,r)})):n(r)?o((function(e){return t(s,e)})):t(s,r)}}}function c(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var h="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)c(o,n)&&(e[o]=n[o]);s+=1}return e},u=i((function(t,e){return h({},t,e)}));const p={"Content-Type":"application/json",Accept:"application/json"};class a{static of(t){return new a(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...p,...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}`,u(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 l{static of(t){return new l(t)}constructor(t){this.updateConfig(t)}updateConfig(n){const o=this.config||{};this.config={...o,...n};const i=a.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:i}),this.apiTokens=e.of({...this.config,http:i}),this.resources=s.of({...this.config,http:i}),this.workspaces=r.of({...this.config,http:i})}}export{l 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.1-alpha",
4
+ "version": "0.0.3-alpha",
5
5
  "url": "git://github.com/ossy-se/ossy.git",
6
6
  "source": "src/index.js",
7
7
  "main": "build/index.cjs.js",
@@ -54,7 +54,7 @@ export class ResourcesClient {
54
54
  return this.http.delete(`/resources/${resourceId}`)
55
55
  }
56
56
 
57
- updateResourceContent(resourceId, resourceContent) {
57
+ updateContent(resourceId, resourceContent) {
58
58
  return this.http.put(`/resources/${resourceId}/content`, resourceContent)
59
59
  }
60
60
 
package/src/sdk.js CHANGED
@@ -23,8 +23,11 @@ export class SDK {
23
23
  }
24
24
 
25
25
  const http = Http.of({
26
- baseUrl: this.config.apiUrl || 'https://api.ossy.se/api/v0',
27
- headers: { workspaceId: this.config.workspaceId }
26
+ baseUrl: this.config?.apiUrl || 'https://api.ossy.se/api/v0',
27
+ headers: {
28
+ workspaceId: this.config?.workspaceId,
29
+ Authorization: this.config?.apiKey
30
+ }
28
31
  })
29
32
 
30
33
  this.workspaceId = this.config.workspaceId
@@ -6,6 +6,11 @@ export class WorkspacesClient {
6
6
 
7
7
  constructor(config) {
8
8
  this.http = config?.http
9
+
10
+ this.services = {
11
+ enable: x => this.enableService(x),
12
+ disable: x => this.disableService(x)
13
+ }
9
14
  }
10
15
 
11
16
  getAll() {
@@ -53,4 +58,18 @@ export class WorkspacesClient {
53
58
  )
54
59
  }
55
60
 
61
+ enableService(service) {
62
+ return this.http.post(
63
+ `/services/enable`,
64
+ service
65
+ )
66
+ }
67
+
68
+ disableService(service) {
69
+ return this.http.post(
70
+ `/services/disable`,
71
+ service
72
+ )
73
+ }
74
+
56
75
  }