@ossy/sdk 1.23.4 → 1.23.5
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
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Resource,
|
|
1
|
+
import { Resource, Task, TaskType, Action, SDKConfig } from '@ossy/types';
|
|
2
2
|
export * from '@ossy/types';
|
|
3
|
-
export { Action,
|
|
3
|
+
export { Action, TaskStatus, Tasks } from '@ossy/types';
|
|
4
4
|
|
|
5
5
|
interface ResourcesClient {
|
|
6
|
-
search: (payload: Record<string, unknown>) => Promise<Resource<
|
|
6
|
+
search: (payload: Record<string, unknown>) => Promise<Resource<Task>[]>;
|
|
7
7
|
create: (data: {
|
|
8
8
|
type: string;
|
|
9
9
|
location: string;
|
|
@@ -13,24 +13,24 @@ interface ResourcesClient {
|
|
|
13
13
|
status: string;
|
|
14
14
|
result: undefined;
|
|
15
15
|
};
|
|
16
|
-
}) => Promise<Resource<
|
|
16
|
+
}) => Promise<Resource<Task>>;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface TasksClientConfig {
|
|
19
19
|
http?: unknown;
|
|
20
20
|
resources: ResourcesClient;
|
|
21
21
|
}
|
|
22
|
-
declare class
|
|
22
|
+
declare class TasksClient {
|
|
23
23
|
static location: string;
|
|
24
24
|
private http?;
|
|
25
25
|
private resources;
|
|
26
|
-
static of(config:
|
|
27
|
-
constructor(config:
|
|
28
|
-
get(_query?: string | Record<string, unknown>): Promise<Resource<
|
|
29
|
-
getUnprocessed(): Promise<Resource<
|
|
26
|
+
static of(config: TasksClientConfig): TasksClient;
|
|
27
|
+
constructor(config: TasksClientConfig);
|
|
28
|
+
get(_query?: string | Record<string, unknown>): Promise<Resource<Task>[]>;
|
|
29
|
+
getUnprocessed(): Promise<Resource<Task>[]>;
|
|
30
30
|
create({ type, resourceId }: {
|
|
31
|
-
type:
|
|
31
|
+
type: TaskType;
|
|
32
32
|
resourceId: string;
|
|
33
|
-
}): Promise<Resource<
|
|
33
|
+
}): Promise<Resource<Task>>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
declare const ApiTokenGetAll: Action;
|
|
@@ -269,7 +269,7 @@ declare class SDK {
|
|
|
269
269
|
} | undefined>) => Promise<any>;
|
|
270
270
|
signOff: (_payload?: Required<{} | undefined>) => Promise<any>;
|
|
271
271
|
};
|
|
272
|
-
get
|
|
272
|
+
get tasks(): TasksClient;
|
|
273
273
|
makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
|
|
274
274
|
}
|
|
275
275
|
|
package/build/public.index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={VisualContentDescriptors:"@ossy/
|
|
1
|
+
const e={VisualContentDescriptors:"@ossy/tasks/visual-content-descriptors",ResizeCommonWeb:"@ossy/tasks/resize-common-web"},t={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class s{static of(e){return new s(e)}constructor(e){this.http=null==e?void 0:e.http,this.resources=e.resources}get(e={}){const t="string"==typeof e?{id:e}:e;return t.location=s.location,this.resources.search({query:t})}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/tasks/"},{type:{$regex:"^@ossy/media-tasks"}}]})}create({type:i,resourceId:n}){if(!Object.values(e).includes(i))throw new Error(`Task type ${i} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:i,location:s.location,name:`[${t.Queued}] ${n}`,content:{resourceId:n,status:t.Queued,result:void 0}})}}s.location="/@ossy/tasks/";const i={id:"api-tokens.get-all",endpoint:"/users/me/tokens",method:"GET"},n={id:"api-tokens.create",endpoint:"/users/me/tokens",method:"POST"},o={id:"api-tokens.invalidate",endpoint:"/users/me/tokens/:id",method:"DELETE"},r={id:"workspaces.get-all",endpoint:"/workspaces",method:"GET"},a={id:"workspaces.get-current",endpoint:"/workspaces/current",method:"GET"},d={id:"workspaces.get",endpoint:"/workspaces/:id",method:"GET"},u={id:"workspaces.create",endpoint:"/workspaces",method:"POST"},h={id:"workspaces.import-resource-templates",endpoint:"/resource-templates",method:"POST"},c={id:"workspaces.get-resource-templates",endpoint:"/resource-templates",method:"GET"},p={id:"workspaces.create-api-token",endpoint:"/tokens",method:"POST"},m={id:"workspaces.get-api-tokens",endpoint:"/tokens",method:"GET"},k={id:"workspaces.invite-user",endpoint:"/invitations",method:"POST"},l={id:"workspaces.enable-service",endpoint:"/services/enable",method:"POST"},b={id:"workspaces.disable-service",endpoint:"/services/disable",method:"POST"},g={id:"workspaces.get-users",endpoint:"/users",method:"GET"},T={id:"user.get",endpoint:"/users/me",method:"GET"},R={id:"user.get-history",endpoint:"/users/me/history",method:"GET"},q={id:"user.update",endpoint:"/users/me",method:"PUT"},y={id:"resources.create-directory",endpoint:"/resources",method:"POST",payload:{type:"directory"}},w={id:"resources.create",endpoint:"/resources",method:"POST"},v={id:"resources.upload",endpoint:"/resources",method:"POST"},f={id:"resources.upload-named-version",endpoint:"/resources/:id/:name",method:"PUT"},E={id:"resources.get",endpoint:"/resources/:id",method:"GET"},P={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"},S={id:"resources.remove",endpoint:"/resources/:id",method:"DELETE"},G={id:"resources.update-content",endpoint:"/resources/:id/content",method:"PUT"},j={id:"resources.move",endpoint:"/resources/:id/location",method:"PUT"},I={id:"resources.rename",endpoint:"/resources/:id/name",method:"PUT"},z={id:"auth.sign-up",endpoint:"/users/sign-up",method:"POST"},$={id:"auth.sign-in",endpoint:"/users/sign-in",method:"POST"},x={id:"auth.verify-sign-in",endpoint:"/users/verify-sign-in?token=:token",method:"GET"},C={id:"auth.verify-invitation",endpoint:"/workspaces/:workspaceId/invitations?token=:token",method:"GET"},D={id:"auth.get-authenticated-user",endpoint:"/users/me",method:"GET"},A={id:"auth.get-authenticated-user-history",endpoint:"/users/me/history",method:"GET"},L={id:"auth.get-user",endpoint:"/users/:id",method:"GET"},Q={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 a=`${i}${r}`,d={method:e.method,credentials:"include",headers:{"Content-Type":"application/json"}};return n&&(d.headers=Object.assign(Object.assign({},d.headers),{workspaceId:n})),o&&(d.headers=Object.assign(Object.assign({},d.headers),{Authorization:o})),"GET"!==d.method&&s&&(d.body=JSON.stringify(s)),fetch(a,d).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(i).bind(this),create:this.makeRequest(n).bind(this),invalidate:this.makeRequest(o).bind(this)}}get workspaces(){return{current:this.makeRequest(a).bind(this),list:this.makeRequest(r).bind(this),get:this.makeRequest(d).bind(this),create:this.makeRequest(u).bind(this),importResourceTemplates:this.makeRequest(h).bind(this),getResourceTemplates:this.makeRequest(c).bind(this),createApiToken:this.makeRequest(p).bind(this),getApiTokens:this.makeRequest(m).bind(this),inviteUser:this.makeRequest(k).bind(this),enableService:this.makeRequest(l).bind(this),disableService:this.makeRequest(b).bind(this)}}get users(){return{list:this.makeRequest(g).bind(this)}}get currentUser(){return{get:this.makeRequest(T).bind(this),update:this.makeRequest(q).bind(this),history:this.makeRequest(R).bind(this)}}get resources(){return{createDirectory:this.makeRequest(y).bind(this),create:this.makeRequest(w).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(v)(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(f)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},get:this.makeRequest(E).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(P)({search:t})},search:this.makeRequest(U).bind(this),remove:this.makeRequest(S).bind(this),updateContent:this.makeRequest(G).bind(this),move:this.makeRequest(j).bind(this),rename:this.makeRequest(I).bind(this)}}get auth(){return{signUp:this.makeRequest(z).bind(this),signIn:this.makeRequest($).bind(this),verifySignIn:this.makeRequest(x).bind(this),verifyInvitation:this.makeRequest(C).bind(this),getAuthenticatedUser:this.makeRequest(D).bind(this),getAuthenticatedUserHistory:this.makeRequest(A).bind(this),getUser:this.makeRequest(L).bind(this),signOff:this.makeRequest(Q).bind(this)}}get tasks(){return s.of({resources:this.resources})}}export{n as ApiTokenCreate,i as ApiTokenGetAll,o as ApiTokenInvalidate,D as AuthGetAuthenticatedUser,A as AuthGetAuthenticatedUserHistory,L as AuthGetUser,$ as AuthSignIn,Q as AuthSignOff,z as AuthSignUp,C as AuthVerifyInvitation,x as AuthVerifySignIn,O as ResourceUpdateAccess,w as ResourcesCreate,y as ResourcesCreateDirectory,E as ResourcesGet,P as ResourcesList,j as ResourcesMove,S as ResourcesRemove,I as ResourcesRename,U as ResourcesSearch,G as ResourcesUpdateContent,v as ResourcesUpload,f as ResourcesUploadNamedVersion,N as SDK,t as TaskStatus,e as Tasks,T as UserCurrentGet,R as UserCurrentGetHistory,q as UserCurrentUpdate,u as WorkspacesCreate,p as WorkspacesCreateApiToken,b as WorkspacesDisableService,l as WorkspacesEnableService,d as WorkspacesGet,m as WorkspacesGetApiTokens,a as WorkspacesGetCurrent,c as WorkspacesGetResourceTemplates,g as WorkspacesGetUsers,h as WorkspacesImportResourceTemplates,k as WorkspacesInviteUser,r as WorkspacesList};
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./sdk.js";
|
|
2
|
-
export {
|
|
2
|
+
export { Tasks, TaskStatus } from "./tasks-client.js";
|
package/build/types/sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Action } from './Actions';
|
|
2
2
|
import { SDKConfig } from './config';
|
|
3
|
-
import {
|
|
3
|
+
import { TasksClient } from './tasks-client';
|
|
4
4
|
export declare class SDK {
|
|
5
5
|
workspaceId?: string;
|
|
6
6
|
authorization?: string;
|
|
@@ -127,6 +127,6 @@ export declare class SDK {
|
|
|
127
127
|
} | undefined>) => Promise<any>;
|
|
128
128
|
signOff: (_payload?: Required<{} | undefined>) => Promise<any>;
|
|
129
129
|
};
|
|
130
|
-
get
|
|
130
|
+
get tasks(): TasksClient;
|
|
131
131
|
makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
|
|
132
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { Tasks, TaskStatus, TaskType, Resource, Task } from '@ossy/types';
|
|
2
|
+
export { Tasks, TaskStatus };
|
|
3
3
|
interface ResourcesClient {
|
|
4
|
-
search: (payload: Record<string, unknown>) => Promise<Resource<
|
|
4
|
+
search: (payload: Record<string, unknown>) => Promise<Resource<Task>[]>;
|
|
5
5
|
create: (data: {
|
|
6
6
|
type: string;
|
|
7
7
|
location: string;
|
|
@@ -11,22 +11,22 @@ interface ResourcesClient {
|
|
|
11
11
|
status: string;
|
|
12
12
|
result: undefined;
|
|
13
13
|
};
|
|
14
|
-
}) => Promise<Resource<
|
|
14
|
+
}) => Promise<Resource<Task>>;
|
|
15
15
|
}
|
|
16
|
-
interface
|
|
16
|
+
interface TasksClientConfig {
|
|
17
17
|
http?: unknown;
|
|
18
18
|
resources: ResourcesClient;
|
|
19
19
|
}
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class TasksClient {
|
|
21
21
|
static location: string;
|
|
22
22
|
private http?;
|
|
23
23
|
private resources;
|
|
24
|
-
static of(config:
|
|
25
|
-
constructor(config:
|
|
26
|
-
get(_query?: string | Record<string, unknown>): Promise<Resource<
|
|
27
|
-
getUnprocessed(): Promise<Resource<
|
|
24
|
+
static of(config: TasksClientConfig): TasksClient;
|
|
25
|
+
constructor(config: TasksClientConfig);
|
|
26
|
+
get(_query?: string | Record<string, unknown>): Promise<Resource<Task>[]>;
|
|
27
|
+
getUnprocessed(): Promise<Resource<Task>[]>;
|
|
28
28
|
create({ type, resourceId }: {
|
|
29
|
-
type:
|
|
29
|
+
type: TaskType;
|
|
30
30
|
resourceId: string;
|
|
31
|
-
}): Promise<Resource<
|
|
31
|
+
}): Promise<Resource<Task>>;
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/sdk",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "1.23.
|
|
3
|
+
"description": "Software Development Kit for interacting with our services",
|
|
4
|
+
"version": "1.23.5",
|
|
5
5
|
"url": "git://github.com/ossy-se/packages/sdk",
|
|
6
6
|
"source": "src/public.index.ts",
|
|
7
7
|
"main": "build/public.index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ossy/types": "^1.23.
|
|
24
|
+
"@ossy/types": "^1.23.5"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"/build",
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "d8bcbdb5771d6dbbdcce2df410a4e22b424c408a"
|
|
40
40
|
}
|