@ossy/sdk 0.6.5 → 0.6.7

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,3 +1,56 @@
1
+ declare namespace Jobs {
2
+ let VisualContentDescriptors: string;
3
+ let ResizeCommonWeb: string;
4
+ }
5
+ declare namespace JobStatus {
6
+ let Queued: string;
7
+ let InProgress: string;
8
+ let Success: string;
9
+ let Failed: string;
10
+ }
11
+
12
+ interface Field {
13
+ label: string;
14
+ name: string;
15
+ type: string;
16
+ description: string;
17
+ placeholder?: string;
18
+ required: boolean;
19
+ options?: string[];
20
+ }
21
+
22
+ interface Resource<T = any> {
23
+ id: string;
24
+ name: string;
25
+ location: string;
26
+ belongsTo: string;
27
+ type: string;
28
+ createdBy: string;
29
+ created: string;
30
+ lastUpdated: string;
31
+ content: T;
32
+ }
33
+
34
+ interface ResourceTemplate {
35
+ id: string;
36
+ name: string;
37
+ description: string;
38
+ categoryName: string;
39
+ icon: string;
40
+ fields: Field[];
41
+ }
42
+
43
+ interface Workspace {
44
+ id: string;
45
+ name: string;
46
+ createdBy: string;
47
+ created: string;
48
+ users: string[];
49
+ invitations: any[];
50
+ resourceTemplates: ResourceTemplate[];
51
+ services: Record<string, boolean>;
52
+ }
53
+
1
54
  interface SDKConfig {
2
55
  apiUrl?: string;
3
56
  workspaceId?: string;
@@ -136,15 +189,5 @@ declare class SDK {
136
189
  makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
137
190
  }
138
191
 
139
- declare namespace Jobs {
140
- let VisualContentDescriptors: string;
141
- let ResizeCommonWeb: string;
142
- }
143
- declare namespace JobStatus {
144
- let Queued: string;
145
- let InProgress: string;
146
- let Success: string;
147
- let Failed: string;
148
- }
149
-
150
192
  export { JobStatus, Jobs, SDK };
193
+ export type { Field, Resource, ResourceTemplate, Workspace };
@@ -1 +1 @@
1
- export{SDK}from"./sdk.js";export{JobStatus,Jobs}from"./jobs-client.js";
1
+ export{JobStatus,Jobs}from"./jobs-client.js";export{SDK}from"./sdk.js";
package/build/sdk.js CHANGED
@@ -1 +1 @@
1
- import{ApiTokenInvalidate as e,ApiTokenCreate as t,ApiTokenGetAll as s,WorkspacesDisableService as i,WorkspacesEnableService as n,WorkspacesInviteUser as a,WorkspacesGetApiTokens as h,WorkspacesCreateApiToken as o,WorkspacesGetResourceTemplates as r,WorkspacesImportResourceTemplates as d,WorkspacesCreate as u,WorkspacesGet as c,WorkspacesList as m,WorkspacesGetCurrent as k,WorkspacesGetUsers as b,UserCurrentGetHistory as p,UserCurrentUpdate as l,UserCurrentGet as R,ResourcesRename as q,ResourcesMove as g,ResourcesUpdateContent as y,ResourcesRemove as U,ResourcesSearch as f,ResourcesList as j,ResourcesGet as v,ResourcesUploadNamedVersion as z,ResourcesUpload as w,ResourcesCreate as I,ResourcesCreateDirectory as O,AuthSignOff as T,AuthGetUser as A,AuthGetAuthenticatedUserHistory as S,AuthGetAuthenticatedUser as C,AuthVerifyInvitation as P,AuthVerifySignIn as $,AuthSignIn as N,AuthSignUp as x}from"./Actions.js";class D{static of(e){return new D(e)}constructor(e){this.baseUrl="https://api.ossy.se/api/v0",this.makeRequest=e=>t=>{let s={};(t||e.payload)&&(s=Object.assign(Object.assign({},e.payload||{}),t||{}));let i="apiUrl"in s?null==s?void 0:s.apiUrl:this.baseUrl,n="workspaceId"in s?s.workspaceId:this.workspaceId,a="authorization"in s?s.authorization:this.authorization,h=e.endpoint;if(s){const t=Object.keys(s);console.log("[@ossy/sdk] payloadKeys",t),console.log("[@ossy/sdk] action.endpoint",e.endpoint),h=e.endpoint,h=t.reduce((e,t)=>e.replace(`:${t}`,`${s[t]}`),e.endpoint),console.log("[@ossy/sdk] endpoint after",h)}const o=`${i}${h}`,r={method:e.method,credentials:"include",headers:{"Content-Type":"application/json"}};return n&&(r.headers=Object.assign(Object.assign({},r.headers),{workspaceId:n})),a&&(r.headers=Object.assign(Object.assign({},r.headers),{Authorization:a})),"GET"!==r.method&&s&&(r.body=JSON.stringify(s)),fetch(o,r).then(e=>{const t=e.headers.get("Content-Type")||"",s=e.status;return 400===s?e.json().then(e=>Promise.reject(e.error)):[200,204].includes(s)?t.includes("application/json")?e.json():e:Promise.reject(e)})},this.updateConfig(e)}updateConfig(e){this.baseUrl=e.apiUrl||this.baseUrl,this.workspaceId=e.workspaceId||this.workspaceId,this.authorization=e.authorization||this.authorization}get apiTokens(){return{list:this.makeRequest(s).bind(this),create:this.makeRequest(t).bind(this),invalidate:this.makeRequest(e).bind(this)}}get workspaces(){return{current:this.makeRequest(k).bind(this),list:this.makeRequest(m).bind(this),get:this.makeRequest(c).bind(this),create:this.makeRequest(u).bind(this),importResourceTemplates:this.makeRequest(d).bind(this),getResourceTemplates:this.makeRequest(r).bind(this),createApiToken:this.makeRequest(o).bind(this),getApiTokens:this.makeRequest(h).bind(this),inviteUser:this.makeRequest(a).bind(this),enableService:this.makeRequest(n).bind(this),disableService:this.makeRequest(i).bind(this)}}get users(){return{list:this.makeRequest(b).bind(this)}}get currentUser(){return{get:this.makeRequest(R).bind(this),update:this.makeRequest(l).bind(this),history:this.makeRequest(p).bind(this)}}get resources(){return{createDirectory:this.makeRequest(O).bind(this),create:this.makeRequest(I).bind(this),upload:({location:e="/",file:t})=>{const s={type:t.type,location:e,name:t.name,size:t.size};return this.makeRequest(w)(s).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:t}).then(()=>e))},uploadNamedVersion:({id:e,name:t,file:s})=>{const i={id:e,name:t,size:s.size};this.makeRequest(z)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},get:this.makeRequest(v).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(j)({search:t})},search:this.makeRequest(f).bind(this),remove:this.makeRequest(U).bind(this),updateContent:this.makeRequest(y).bind(this),move:this.makeRequest(g).bind(this),rename:this.makeRequest(q).bind(this)}}get auth(){return{signUp:this.makeRequest(x).bind(this),signIn:this.makeRequest(N).bind(this),verifySignIn:this.makeRequest($).bind(this),verifyInvitation:this.makeRequest(P).bind(this),getAuthenticatedUser:this.makeRequest(C).bind(this),getAuthenticatedUserHistory:this.makeRequest(S).bind(this),getUser:this.makeRequest(A).bind(this),signOff:this.makeRequest(T).bind(this)}}}export{D as SDK};
1
+ import{ApiTokenInvalidate as e,ApiTokenCreate as t,ApiTokenGetAll as s,WorkspacesDisableService as i,WorkspacesEnableService as n,WorkspacesInviteUser as a,WorkspacesGetApiTokens as h,WorkspacesCreateApiToken as r,WorkspacesGetResourceTemplates as o,WorkspacesImportResourceTemplates as d,WorkspacesCreate as u,WorkspacesGet as c,WorkspacesList as m,WorkspacesGetCurrent as b,WorkspacesGetUsers as k,UserCurrentGetHistory as p,UserCurrentUpdate as R,UserCurrentGet as l,ResourcesRename as q,ResourcesMove as g,ResourcesUpdateContent as U,ResourcesRemove as y,ResourcesSearch as f,ResourcesList as j,ResourcesGet as v,ResourcesUploadNamedVersion as z,ResourcesUpload as w,ResourcesCreate as I,ResourcesCreateDirectory as O,AuthSignOff as T,AuthGetUser as A,AuthGetAuthenticatedUserHistory as S,AuthGetAuthenticatedUser as C,AuthVerifyInvitation as P,AuthVerifySignIn as $,AuthSignIn as N,AuthSignUp as x}from"./Actions.js";class D{static of(e){return new D(e)}constructor(e){this.baseUrl="https://api.ossy.se/api/v0",this.makeRequest=e=>t=>{let s={};(t||e.payload)&&(s=Object.assign(Object.assign({},e.payload||{}),t||{}));let i="apiUrl"in s?null==s?void 0:s.apiUrl:this.baseUrl,n="workspaceId"in s?s.workspaceId:this.workspaceId,a="authorization"in s?s.authorization:this.authorization,h=e.endpoint;if(s){const t=Object.keys(s);h=e.endpoint,h=t.reduce((e,t)=>e.replace(`:${t}`,`${s[t]}`),e.endpoint)}const r=`${i}${h}`,o={method:e.method,credentials:"include",headers:{"Content-Type":"application/json"}};return n&&(o.headers=Object.assign(Object.assign({},o.headers),{workspaceId:n})),a&&(o.headers=Object.assign(Object.assign({},o.headers),{Authorization:a})),"GET"!==o.method&&s&&(o.body=JSON.stringify(s)),fetch(r,o).then(e=>{const t=e.headers.get("Content-Type")||"",s=e.status;return 400===s?e.json().then(e=>Promise.reject(e.error)):[200,204].includes(s)?t.includes("application/json")?e.json():e:Promise.reject(e)})},this.updateConfig(e)}updateConfig(e){this.baseUrl=e.apiUrl||this.baseUrl,this.workspaceId=e.workspaceId||this.workspaceId,this.authorization=e.authorization||this.authorization}get apiTokens(){return{list:this.makeRequest(s).bind(this),create:this.makeRequest(t).bind(this),invalidate:this.makeRequest(e).bind(this)}}get workspaces(){return{current:this.makeRequest(b).bind(this),list:this.makeRequest(m).bind(this),get:this.makeRequest(c).bind(this),create:this.makeRequest(u).bind(this),importResourceTemplates:this.makeRequest(d).bind(this),getResourceTemplates:this.makeRequest(o).bind(this),createApiToken:this.makeRequest(r).bind(this),getApiTokens:this.makeRequest(h).bind(this),inviteUser:this.makeRequest(a).bind(this),enableService:this.makeRequest(n).bind(this),disableService:this.makeRequest(i).bind(this)}}get users(){return{list:this.makeRequest(k).bind(this)}}get currentUser(){return{get:this.makeRequest(l).bind(this),update:this.makeRequest(R).bind(this),history:this.makeRequest(p).bind(this)}}get resources(){return{createDirectory:this.makeRequest(O).bind(this),create:this.makeRequest(I).bind(this),upload:({location:e="/",file:t})=>{const s={type:t.type,location:e,name:t.name,size:t.size};return this.makeRequest(w)(s).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:t}).then(()=>e))},uploadNamedVersion:({id:e,name:t,file:s})=>{const i={id:e,name:t,size:s.size};this.makeRequest(z)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},get:this.makeRequest(v).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(j)({search:t})},search:this.makeRequest(f).bind(this),remove:this.makeRequest(y).bind(this),updateContent:this.makeRequest(U).bind(this),move:this.makeRequest(g).bind(this),rename:this.makeRequest(q).bind(this)}}get auth(){return{signUp:this.makeRequest(x).bind(this),signIn:this.makeRequest(N).bind(this),verifySignIn:this.makeRequest($).bind(this),verifyInvitation:this.makeRequest(P).bind(this),getAuthenticatedUser:this.makeRequest(C).bind(this),getAuthenticatedUserHistory:this.makeRequest(S).bind(this),getUser:this.makeRequest(A).bind(this),signOff:this.makeRequest(T).bind(this)}}}export{D as SDK};
@@ -0,0 +1,9 @@
1
+ export interface Field {
2
+ label: string;
3
+ name: string;
4
+ type: string;
5
+ description: string;
6
+ placeholder?: string;
7
+ required: boolean;
8
+ options?: string[];
9
+ }
@@ -0,0 +1,11 @@
1
+ export interface Resource<T = any> {
2
+ id: string;
3
+ name: string;
4
+ location: string;
5
+ belongsTo: string;
6
+ type: string;
7
+ createdBy: string;
8
+ created: string;
9
+ lastUpdated: string;
10
+ content: T;
11
+ }
@@ -0,0 +1,9 @@
1
+ import { Field } from "./Field";
2
+ export interface ResourceTemplate {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ categoryName: string;
7
+ icon: string;
8
+ fields: Field[];
9
+ }
@@ -0,0 +1,11 @@
1
+ import { ResourceTemplate } from "./ResourceTemplate";
2
+ export interface Workspace {
3
+ id: string;
4
+ name: string;
5
+ createdBy: string;
6
+ created: string;
7
+ users: string[];
8
+ invitations: any[];
9
+ resourceTemplates: ResourceTemplate[];
10
+ services: Record<string, boolean>;
11
+ }
@@ -1,2 +1,6 @@
1
- export * from './sdk.js';
2
1
  export { Jobs, JobStatus } from './jobs-client.js';
2
+ export * from './Field';
3
+ export * from './Resource';
4
+ export * from './ResourceTemplate';
5
+ export * from './Workspace';
6
+ export * from './sdk';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/sdk",
3
3
  "description": "Sofware Development Kit for interacting with our services",
4
- "version": "0.6.5",
4
+ "version": "0.6.7",
5
5
  "url": "git://github.com/ossy-se/packages/sdk",
6
6
  "source": "src/public.index.ts",
7
7
  "module": "build/public.index.js",
@@ -26,5 +26,5 @@
26
26
  "/build",
27
27
  "README.md"
28
28
  ],
29
- "gitHead": "43ef8405cfcfb7d367b93a7c3a664abc7b8f4d0e"
29
+ "gitHead": "3b5cde28a8fac3e27a4f22b52e9d8f8ce69a12c6"
30
30
  }