@ossy/sdk 0.7.7 → 0.7.9
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/public.index.d.ts +3 -25
- package/build/public.index.js +1 -1
- package/build/types/Actions.d.ts +2 -7
- package/build/types/config.d.ts +1 -5
- package/build/types/jobs-client.d.ts +3 -10
- package/package.json +10 -3
- package/build/Actions.js +0 -1
- package/build/jobs-client.js +0 -1
- package/build/sdk.js +0 -1
package/build/public.index.d.ts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
+
import { SDKConfig, Action } from '@ossy/types';
|
|
1
2
|
export * from '@ossy/types';
|
|
2
|
-
|
|
3
|
-
declare namespace Jobs {
|
|
4
|
-
let VisualContentDescriptors: string;
|
|
5
|
-
let ResizeCommonWeb: string;
|
|
6
|
-
}
|
|
7
|
-
declare namespace JobStatus {
|
|
8
|
-
let Queued: string;
|
|
9
|
-
let InProgress: string;
|
|
10
|
-
let Success: string;
|
|
11
|
-
let Failed: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface SDKConfig {
|
|
15
|
-
apiUrl?: string;
|
|
16
|
-
workspaceId?: string;
|
|
17
|
-
authorization?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Action<Payload extends (Record<string, string | boolean | number> & SDKConfig) | undefined = {}> {
|
|
21
|
-
id: string;
|
|
22
|
-
endpoint: string;
|
|
23
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
24
|
-
payload?: Payload;
|
|
25
|
-
}
|
|
3
|
+
export { JobStatus, Jobs } from '@ossy/types';
|
|
26
4
|
|
|
27
5
|
declare class SDK {
|
|
28
6
|
workspaceId?: string;
|
|
@@ -153,4 +131,4 @@ declare class SDK {
|
|
|
153
131
|
makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
|
|
154
132
|
}
|
|
155
133
|
|
|
156
|
-
export {
|
|
134
|
+
export { SDK };
|
package/build/public.index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},t={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"},s={id:"api-tokens.get-all",endpoint:"/users/me/tokens",method:"GET"},i={id:"api-tokens.create",endpoint:"/users/me/tokens",method:"POST"},n={id:"api-tokens.invalidate",endpoint:"/users/me/tokens/:id",method:"DELETE"},o={id:"workspaces.get-all",endpoint:"/workspaces",method:"GET"},r={id:"workspaces.get-current",endpoint:"/workspaces/current",method:"GET"},d={id:"workspaces.get",endpoint:"/workspaces/:id",method:"GET"},a={id:"workspaces.create",endpoint:"/workspaces",method:"POST"},h={id:"workspaces.import-resource-templates",endpoint:"/resource-templates",method:"POST"},u={id:"workspaces.get-resource-templates",endpoint:"/resource-templates",method:"GET"},c={id:"workspaces.create-api-token",endpoint:"/tokens",method:"POST"},p={id:"workspaces.get-api-tokens",endpoint:"/tokens",method:"GET"},m={id:"workspaces.invite-user",endpoint:"/invitations",method:"POST"},k={id:"workspaces.enable-service",endpoint:"/services/enable",method:"POST"},b={id:"workspaces.disable-service",endpoint:"/services/disable",method:"POST"},l={id:"workspaces.get-users",endpoint:"/users",method:"GET"},g={id:"user.get",endpoint:"/users/me",method:"GET"},T={id:"user.get-history",endpoint:"/users/me/history",method:"GET"},R={id:"user.update",endpoint:"/users/me",method:"PUT"},q={id:"resources.create-directory",endpoint:"/resources",method:"POST",payload:{type:"directory"}},y={id:"resources.create",endpoint:"/resources",method:"POST"},w={id:"resources.upload",endpoint:"/resources",method:"POST"},v={id:"resources.upload-named-version",endpoint:"/resources/:id/:name",method:"PUT"},P={id:"resources.get",endpoint:"/resources/:id",method:"GET"},E={id:"resources.list",endpoint:"/resources?:search",method:"GET"},U={id:"resources.search",endpoint:"/resources/search",method:"POST"},O={id:"resources.update-access",endpoint:"/resources/:id/access",method:"PUT"},f={id:"resources.remove",endpoint:"/resources/:id",method:"DELETE"},S={id:"resources.update-content",endpoint:"/resources/:id/content",method:"PUT"},G={id:"resources.move",endpoint:"/resources/:id/location",method:"PUT"},j={id:"resources.rename",endpoint:"/resources/:id/name",method:"PUT"},z={id:"auth.sign-up",endpoint:"/users/sign-up",method:"POST"},I={id:"auth.sign-in",endpoint:"/users/sign-in",method:"POST"},C={id:"auth.verify-sign-in",endpoint:"/users/verify-sign-in?token=:token",method:"GET"},A={id:"auth.verify-invitation",endpoint:"/workspaces/:workspaceId/invitations?token=:token",method:"GET"},D={id:"auth.get-authenticated-user",endpoint:"/users/me",method:"GET"},$={id:"auth.get-authenticated-user-history",endpoint:"/users/me/history",method:"GET"},J={id:"auth.get-user",endpoint:"/users/:id",method:"GET"},L={id:"auth.sign-off",endpoint:"/users/sign-off",method:"GET"};class N{static of(e){return new N(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,o="authorization"in s?s.authorization:this.authorization,r=e.endpoint;if(s){const t=Object.keys(s);r=e.endpoint,r=t.reduce((e,t)=>e.replace(`:${t}`,`${s[t]}`),e.endpoint)}const d=`${i}${r}`,a={method:e.method,credentials:"include",headers:{"Content-Type":"application/json"}};return n&&(a.headers=Object.assign(Object.assign({},a.headers),{workspaceId:n})),o&&(a.headers=Object.assign(Object.assign({},a.headers),{Authorization:o})),"GET"!==a.method&&s&&(a.body=JSON.stringify(s)),fetch(d,a).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(i).bind(this),invalidate:this.makeRequest(n).bind(this)}}get workspaces(){return{current:this.makeRequest(r).bind(this),list:this.makeRequest(o).bind(this),get:this.makeRequest(d).bind(this),create:this.makeRequest(a).bind(this),importResourceTemplates:this.makeRequest(h).bind(this),getResourceTemplates:this.makeRequest(u).bind(this),createApiToken:this.makeRequest(c).bind(this),getApiTokens:this.makeRequest(p).bind(this),inviteUser:this.makeRequest(m).bind(this),enableService:this.makeRequest(k).bind(this),disableService:this.makeRequest(b).bind(this)}}get users(){return{list:this.makeRequest(l).bind(this)}}get currentUser(){return{get:this.makeRequest(g).bind(this),update:this.makeRequest(R).bind(this),history:this.makeRequest(T).bind(this)}}get resources(){return{createDirectory:this.makeRequest(q).bind(this),create:this.makeRequest(y).bind(this),access:this.makeRequest(O).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(v)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},get:this.makeRequest(P).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(E)({search:t})},search:this.makeRequest(U).bind(this),remove:this.makeRequest(f).bind(this),updateContent:this.makeRequest(S).bind(this),move:this.makeRequest(G).bind(this),rename:this.makeRequest(j).bind(this)}}get auth(){return{signUp:this.makeRequest(z).bind(this),signIn:this.makeRequest(I).bind(this),verifySignIn:this.makeRequest(C).bind(this),verifyInvitation:this.makeRequest(A).bind(this),getAuthenticatedUser:this.makeRequest(D).bind(this),getAuthenticatedUserHistory:this.makeRequest($).bind(this),getUser:this.makeRequest(J).bind(this),signOff:this.makeRequest(L).bind(this)}}}export{t as JobStatus,e as Jobs,N as SDK};
|
package/build/types/Actions.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
id: string;
|
|
4
|
-
endpoint: string;
|
|
5
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
6
|
-
payload?: Payload;
|
|
7
|
-
}
|
|
1
|
+
import type { Action } from '@ossy/types';
|
|
2
|
+
export type { Action };
|
|
8
3
|
export declare const ApiTokenGetAll: Action;
|
|
9
4
|
export declare const ApiTokenCreate: Action<{
|
|
10
5
|
name: string;
|
package/build/types/config.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export namespace Jobs {
|
|
2
|
-
let VisualContentDescriptors: string;
|
|
3
|
-
let ResizeCommonWeb: string;
|
|
4
|
-
}
|
|
5
|
-
export namespace JobStatus {
|
|
6
|
-
let Queued: string;
|
|
7
|
-
let InProgress: string;
|
|
8
|
-
let Success: string;
|
|
9
|
-
let Failed: string;
|
|
10
|
-
}
|
|
11
1
|
export class JobsClient {
|
|
12
2
|
static location: string;
|
|
13
3
|
static of(config: any): JobsClient;
|
|
@@ -21,3 +11,6 @@ export class JobsClient {
|
|
|
21
11
|
resourceId: any;
|
|
22
12
|
}): any;
|
|
23
13
|
}
|
|
14
|
+
import { Jobs } from '@ossy/types';
|
|
15
|
+
import { JobStatus } from '@ossy/types';
|
|
16
|
+
export { Jobs, JobStatus };
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/sdk",
|
|
3
3
|
"description": "Sofware Development Kit for interacting with our services",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.9",
|
|
5
5
|
"url": "git://github.com/ossy-se/packages/sdk",
|
|
6
6
|
"source": "src/public.index.ts",
|
|
7
|
+
"main": "build/public.index.js",
|
|
7
8
|
"module": "build/public.index.js",
|
|
8
9
|
"types": "build/public.index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./build/public.index.js",
|
|
13
|
+
"types": "./build/public.index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
9
16
|
"type": "module",
|
|
10
17
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
11
18
|
"repository": {
|
|
@@ -14,7 +21,7 @@
|
|
|
14
21
|
},
|
|
15
22
|
"license": "MIT",
|
|
16
23
|
"dependencies": {
|
|
17
|
-
"@ossy/types": "^0.0.
|
|
24
|
+
"@ossy/types": "^0.0.8"
|
|
18
25
|
},
|
|
19
26
|
"scripts": {
|
|
20
27
|
"start": "",
|
|
@@ -29,5 +36,5 @@
|
|
|
29
36
|
"/build",
|
|
30
37
|
"README.md"
|
|
31
38
|
],
|
|
32
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "c4fe33a8cd5f590321c5f008d7407da95f094820"
|
|
33
40
|
}
|
package/build/Actions.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e={id:"api-tokens.get-all",endpoint:"/users/me/tokens",method:"GET"},s={id:"api-tokens.create",endpoint:"/users/me/tokens",method:"POST"},o={id:"api-tokens.invalidate",endpoint:"/users/me/tokens/:id",method:"DELETE"},t={id:"workspaces.get-all",endpoint:"/workspaces",method:"GET"},d={id:"workspaces.get-current",endpoint:"/workspaces/current",method:"GET"},i={id:"workspaces.get",endpoint:"/workspaces/:id",method:"GET"},r={id:"workspaces.create",endpoint:"/workspaces",method:"POST"},n={id:"workspaces.import-resource-templates",endpoint:"/resource-templates",method:"POST"},p={id:"workspaces.get-resource-templates",endpoint:"/resource-templates",method:"GET"},a={id:"workspaces.create-api-token",endpoint:"/tokens",method:"POST"},c={id:"workspaces.get-api-tokens",endpoint:"/tokens",method:"GET"},u={id:"workspaces.invite-user",endpoint:"/invitations",method:"POST"},m={id:"workspaces.enable-service",endpoint:"/services/enable",method:"POST"},h={id:"workspaces.disable-service",endpoint:"/services/disable",method:"POST"},T={id:"workspaces.get-users",endpoint:"/users",method:"GET"},k={id:"user.get",endpoint:"/users/me",method:"GET"},E={id:"user.get-history",endpoint:"/users/me/history",method:"GET"},g={id:"user.update",endpoint:"/users/me",method:"PUT"},P={id:"resources.create-directory",endpoint:"/resources",method:"POST",payload:{type:"directory"}},l={id:"resources.create",endpoint:"/resources",method:"POST"},w={id:"resources.upload",endpoint:"/resources",method:"POST"},G={id:"resources.upload-named-version",endpoint:"/resources/:id/:name",method:"PUT"},v={id:"resources.get",endpoint:"/resources/:id",method:"GET"},O={id:"resources.list",endpoint:"/resources?:search",method:"GET"},S={id:"resources.search",endpoint:"/resources/search",method:"POST"},y={id:"resources.update-access",endpoint:"/resources/:id/access",method:"PUT"},f={id:"resources.remove",endpoint:"/resources/:id",method:"DELETE"},U={id:"resources.update-content",endpoint:"/resources/:id/content",method:"PUT"},b={id:"resources.move",endpoint:"/resources/:id/location",method:"PUT"},D={id:"resources.rename",endpoint:"/resources/:id/name",method:"PUT"},L={id:"auth.sign-up",endpoint:"/users/sign-up",method:"POST"},x={id:"auth.sign-in",endpoint:"/users/sign-in",method:"POST"},I={id:"auth.verify-sign-in",endpoint:"/users/verify-sign-in?token=:token",method:"GET"},j={id:"auth.verify-invitation",endpoint:"/workspaces/:workspaceId/invitations?token=:token",method:"GET"},q={id:"auth.get-authenticated-user",endpoint:"/users/me",method:"GET"},z={id:"auth.get-authenticated-user-history",endpoint:"/users/me/history",method:"GET"},A={id:"auth.get-user",endpoint:"/users/:id",method:"GET"},B={id:"auth.sign-off",endpoint:"/users/sign-off",method:"GET"};export{s as ApiTokenCreate,e as ApiTokenGetAll,o as ApiTokenInvalidate,q as AuthGetAuthenticatedUser,z as AuthGetAuthenticatedUserHistory,A as AuthGetUser,x as AuthSignIn,B as AuthSignOff,L as AuthSignUp,j as AuthVerifyInvitation,I as AuthVerifySignIn,y as ResourceUpdateAccess,l as ResourcesCreate,P as ResourcesCreateDirectory,v as ResourcesGet,O as ResourcesList,b as ResourcesMove,f as ResourcesRemove,D as ResourcesRename,S as ResourcesSearch,U as ResourcesUpdateContent,w as ResourcesUpload,G as ResourcesUploadNamedVersion,k as UserCurrentGet,E as UserCurrentGetHistory,g as UserCurrentUpdate,r as WorkspacesCreate,a as WorkspacesCreateApiToken,h as WorkspacesDisableService,m as WorkspacesEnableService,i as WorkspacesGet,c as WorkspacesGetApiTokens,d as WorkspacesGetCurrent,p as WorkspacesGetResourceTemplates,T as WorkspacesGetUsers,n as WorkspacesImportResourceTemplates,u as WorkspacesInviteUser,t as WorkspacesList};
|
package/build/jobs-client.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const s={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},e={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};export{e as JobStatus,s as Jobs};
|
package/build/sdk.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,ResourceUpdateAccess as I,ResourcesCreate as O,ResourcesCreateDirectory as T,AuthSignOff as A,AuthGetUser as S,AuthGetAuthenticatedUserHistory as C,AuthGetAuthenticatedUser as P,AuthVerifyInvitation as $,AuthVerifySignIn as N,AuthSignIn as x,AuthSignUp as D}from"./Actions.js";class E{static of(e){return new E(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(T).bind(this),create:this.makeRequest(O).bind(this),access: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(D).bind(this),signIn:this.makeRequest(x).bind(this),verifySignIn:this.makeRequest(N).bind(this),verifyInvitation:this.makeRequest($).bind(this),getAuthenticatedUser:this.makeRequest(P).bind(this),getAuthenticatedUserHistory:this.makeRequest(C).bind(this),getUser:this.makeRequest(S).bind(this),signOff:this.makeRequest(A).bind(this)}}}export{E as SDK};
|