@ossy/sdk 1.25.2 → 1.26.0
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
|
@@ -68,6 +68,15 @@ declare const WorkspacesDisableService: Action<{
|
|
|
68
68
|
service: any;
|
|
69
69
|
}>;
|
|
70
70
|
declare const WorkspacesGetUsers: Action;
|
|
71
|
+
declare const WorkspacesAddMember: Action<{
|
|
72
|
+
userId: string;
|
|
73
|
+
workspaceId: string;
|
|
74
|
+
createdBy?: string;
|
|
75
|
+
}>;
|
|
76
|
+
declare const WorkspacesRemoveMember: Action<{
|
|
77
|
+
userId: string;
|
|
78
|
+
workspaceId: string;
|
|
79
|
+
}>;
|
|
71
80
|
declare const UserCurrentGet: Action;
|
|
72
81
|
declare const UserCurrentGetHistory: Action;
|
|
73
82
|
declare const UserCurrentUpdate: Action<{
|
|
@@ -190,6 +199,15 @@ declare class SDK {
|
|
|
190
199
|
};
|
|
191
200
|
get users(): {
|
|
192
201
|
list: (_payload?: Required<{} | undefined>) => Promise<any>;
|
|
202
|
+
addWorkspace: (_payload?: Required<{
|
|
203
|
+
userId: string;
|
|
204
|
+
workspaceId: string;
|
|
205
|
+
createdBy?: string;
|
|
206
|
+
} | undefined>) => Promise<any>;
|
|
207
|
+
removeWorkspace: (_payload?: Required<{
|
|
208
|
+
userId: string;
|
|
209
|
+
workspaceId: string;
|
|
210
|
+
} | undefined>) => Promise<any>;
|
|
193
211
|
};
|
|
194
212
|
get currentUser(): {
|
|
195
213
|
get: (_payload?: Required<{} | undefined>) => Promise<any>;
|
|
@@ -273,4 +291,34 @@ declare class SDK {
|
|
|
273
291
|
makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
|
|
274
292
|
}
|
|
275
293
|
|
|
276
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Unified interface for all SDK adapters.
|
|
296
|
+
*
|
|
297
|
+
* Adapters translate the generic `dispatch` / `query` calls into
|
|
298
|
+
* concrete operations — direct MongoDB writes (EventStoreAdapter),
|
|
299
|
+
* HTTP calls (HttpAdapter), or an in-memory store (InMemoryAdapter).
|
|
300
|
+
*
|
|
301
|
+
* Action names follow the pattern `{domain}/{verb}`, e.g.:
|
|
302
|
+
* - `workspaces/create`
|
|
303
|
+
* - `resources/create`
|
|
304
|
+
* - `user/join-workspace`
|
|
305
|
+
*
|
|
306
|
+
* Query names follow the same pattern, e.g.:
|
|
307
|
+
* - `workspaces/list`
|
|
308
|
+
* - `resources/list`
|
|
309
|
+
* - `resources/search`
|
|
310
|
+
*/
|
|
311
|
+
interface OssySdkAdapter {
|
|
312
|
+
/**
|
|
313
|
+
* Dispatch a write action. Returns the resulting entity/resource,
|
|
314
|
+
* or null for fire-and-forget operations.
|
|
315
|
+
*/
|
|
316
|
+
dispatch(action: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
317
|
+
/**
|
|
318
|
+
* Execute a read query. Returns the matching data.
|
|
319
|
+
*/
|
|
320
|
+
query(name: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export { ApiTokenCreate, ApiTokenGetAll, ApiTokenInvalidate, AuthGetAuthenticatedUser, AuthGetAuthenticatedUserHistory, AuthGetUser, AuthSignIn, AuthSignOff, AuthSignUp, AuthVerifyInvitation, AuthVerifySignIn, ResourceUpdateAccess, ResourcesCreate, ResourcesCreateDirectory, ResourcesGet, ResourcesList, ResourcesMove, ResourcesRemove, ResourcesRename, ResourcesSearch, ResourcesUpdateContent, ResourcesUpload, ResourcesUploadNamedVersion, SDK, UserCurrentGet, UserCurrentGetHistory, UserCurrentUpdate, WorkspacesAddMember, WorkspacesCreate, WorkspacesCreateApiToken, WorkspacesDisableService, WorkspacesEnableService, WorkspacesGet, WorkspacesGetApiTokens, WorkspacesGetCurrent, WorkspacesGetResourceTemplates, WorkspacesGetUsers, WorkspacesImportResourceTemplates, WorkspacesInviteUser, WorkspacesList, WorkspacesRemoveMember };
|
|
324
|
+
export type { OssySdkAdapter };
|
package/build/public.index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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:
|
|
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:o}){if(!Object.values(e).includes(i))throw new Error(`Task type ${i} does not exist`);if(!o)throw new Error("Resource ID is required");return this.resources.create({type:i,location:s.location,name:`[${t.Queued}] ${o}`,content:{resourceId:o,status:t.Queued,result:void 0}})}}s.location="/@ossy/tasks/";const i={id:"api-tokens.get-all",endpoint:"/users/me/tokens",method:"GET"},o={id:"api-tokens.create",endpoint:"/users/me/tokens",method:"POST"},n={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:"workspaces.add-member",endpoint:"/users/:userId/workspaces",method:"POST"},R={id:"workspaces.remove-member",endpoint:"/users/:userId/workspaces/:workspaceId",method:"DELETE"},q={id:"user.get",endpoint:"/users/me",method:"GET"},w={id:"user.get-history",endpoint:"/users/me/history",method:"GET"},y={id:"user.update",endpoint:"/users/me",method:"PUT"},v={id:"resources.create-directory",endpoint:"/resources",method:"POST",payload:{type:"directory"}},E={id:"resources.create",endpoint:"/resources",method:"POST"},f={id:"resources.upload",endpoint:"/resources",method:"POST"},P={id:"resources.upload-named-version",endpoint:"/resources/:id/:name",method:"PUT"},O={id:"resources.get",endpoint:"/resources/:id",method:"GET"},U={id:"resources.list",endpoint:"/resources?:search",method:"GET"},S={id:"resources.search",endpoint:"/resources/search",method:"POST"},G={id:"resources.update-access",endpoint:"/resources/:id/access",method:"PUT"},I={id:"resources.remove",endpoint:"/resources/:id",method:"DELETE"},j={id:"resources.update-content",endpoint:"/resources/:id/content",method:"PUT"},z={id:"resources.move",endpoint:"/resources/:id/location",method:"PUT"},$={id:"resources.rename",endpoint:"/resources/:id/name",method:"PUT"},x={id:"auth.sign-up",endpoint:"/users/sign-up",method:"POST"},C={id:"auth.sign-in",endpoint:"/users/sign-in",method:"POST"},D={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"},L={id:"auth.get-authenticated-user",endpoint:"/users/me",method:"GET"},Q={id:"auth.get-authenticated-user-history",endpoint:"/users/me/history",method:"GET"},W={id:"auth.get-user",endpoint:"/users/:id",method:"GET"},N={id:"auth.sign-off",endpoint:"/users/sign-off",method:"GET"};class V{static of(e){return new V(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,o="workspaceId"in s?s.workspaceId:this.workspaceId,n="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 o&&(d.headers=Object.assign(Object.assign({},d.headers),{workspaceId:o})),n&&(d.headers=Object.assign(Object.assign({},d.headers),{Authorization:n})),"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(o).bind(this),invalidate:this.makeRequest(n).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),addWorkspace:this.makeRequest(T).bind(this),removeWorkspace:this.makeRequest(R).bind(this)}}get currentUser(){return{get:this.makeRequest(q).bind(this),update:this.makeRequest(y).bind(this),history:this.makeRequest(w).bind(this)}}get resources(){return{createDirectory:this.makeRequest(v).bind(this),create:this.makeRequest(E).bind(this),access:this.makeRequest(G).bind(this),upload:({location:e="/",file:t})=>{const s={type:t.type,location:e,name:t.name,size:t.size};return this.makeRequest(f)(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(P)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:s}).then(()=>e))},get:this.makeRequest(O).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(U)({search:t})},search:this.makeRequest(S).bind(this),remove:this.makeRequest(I).bind(this),updateContent:this.makeRequest(j).bind(this),move:this.makeRequest(z).bind(this),rename:this.makeRequest($).bind(this)}}get auth(){return{signUp:this.makeRequest(x).bind(this),signIn:this.makeRequest(C).bind(this),verifySignIn:this.makeRequest(D).bind(this),verifyInvitation:this.makeRequest(A).bind(this),getAuthenticatedUser:this.makeRequest(L).bind(this),getAuthenticatedUserHistory:this.makeRequest(Q).bind(this),getUser:this.makeRequest(W).bind(this),signOff:this.makeRequest(N).bind(this)}}get tasks(){return s.of({resources:this.resources})}}export{o as ApiTokenCreate,i as ApiTokenGetAll,n as ApiTokenInvalidate,L as AuthGetAuthenticatedUser,Q as AuthGetAuthenticatedUserHistory,W as AuthGetUser,C as AuthSignIn,N as AuthSignOff,x as AuthSignUp,A as AuthVerifyInvitation,D as AuthVerifySignIn,G as ResourceUpdateAccess,E as ResourcesCreate,v as ResourcesCreateDirectory,O as ResourcesGet,U as ResourcesList,z as ResourcesMove,I as ResourcesRemove,$ as ResourcesRename,S as ResourcesSearch,j as ResourcesUpdateContent,f as ResourcesUpload,P as ResourcesUploadNamedVersion,V as SDK,t as TaskStatus,e as Tasks,q as UserCurrentGet,w as UserCurrentGetHistory,y as UserCurrentUpdate,T as WorkspacesAddMember,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,R as WorkspacesRemoveMember};
|
package/build/types/Actions.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ export declare const WorkspacesDisableService: Action<{
|
|
|
35
35
|
service: any;
|
|
36
36
|
}>;
|
|
37
37
|
export declare const WorkspacesGetUsers: Action;
|
|
38
|
+
export declare const WorkspacesAddMember: Action<{
|
|
39
|
+
userId: string;
|
|
40
|
+
workspaceId: string;
|
|
41
|
+
createdBy?: string;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const WorkspacesRemoveMember: Action<{
|
|
44
|
+
userId: string;
|
|
45
|
+
workspaceId: string;
|
|
46
|
+
}>;
|
|
38
47
|
export declare const UserCurrentGet: Action;
|
|
39
48
|
export declare const UserCurrentGetHistory: Action;
|
|
40
49
|
export declare const UserCurrentUpdate: Action<{
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified interface for all SDK adapters.
|
|
3
|
+
*
|
|
4
|
+
* Adapters translate the generic `dispatch` / `query` calls into
|
|
5
|
+
* concrete operations — direct MongoDB writes (EventStoreAdapter),
|
|
6
|
+
* HTTP calls (HttpAdapter), or an in-memory store (InMemoryAdapter).
|
|
7
|
+
*
|
|
8
|
+
* Action names follow the pattern `{domain}/{verb}`, e.g.:
|
|
9
|
+
* - `workspaces/create`
|
|
10
|
+
* - `resources/create`
|
|
11
|
+
* - `user/join-workspace`
|
|
12
|
+
*
|
|
13
|
+
* Query names follow the same pattern, e.g.:
|
|
14
|
+
* - `workspaces/list`
|
|
15
|
+
* - `resources/list`
|
|
16
|
+
* - `resources/search`
|
|
17
|
+
*/
|
|
18
|
+
export interface OssySdkAdapter {
|
|
19
|
+
/**
|
|
20
|
+
* Dispatch a write action. Returns the resulting entity/resource,
|
|
21
|
+
* or null for fire-and-forget operations.
|
|
22
|
+
*/
|
|
23
|
+
dispatch(action: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Execute a read query. Returns the matching data.
|
|
26
|
+
*/
|
|
27
|
+
query(name: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
28
|
+
}
|
package/build/types/sdk.d.ts
CHANGED
|
@@ -48,6 +48,15 @@ export declare class SDK {
|
|
|
48
48
|
};
|
|
49
49
|
get users(): {
|
|
50
50
|
list: (_payload?: Required<{} | undefined>) => Promise<any>;
|
|
51
|
+
addWorkspace: (_payload?: Required<{
|
|
52
|
+
userId: string;
|
|
53
|
+
workspaceId: string;
|
|
54
|
+
createdBy?: string;
|
|
55
|
+
} | undefined>) => Promise<any>;
|
|
56
|
+
removeWorkspace: (_payload?: Required<{
|
|
57
|
+
userId: string;
|
|
58
|
+
workspaceId: string;
|
|
59
|
+
} | undefined>) => Promise<any>;
|
|
51
60
|
};
|
|
52
61
|
get currentUser(): {
|
|
53
62
|
get: (_payload?: Required<{} | undefined>) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/sdk",
|
|
3
3
|
"description": "Software Development Kit for interacting with our services",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.26.0",
|
|
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.
|
|
24
|
+
"@ossy/types": "^1.26.0"
|
|
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": "40e96d148d991ef4ad60fe9090f19b836ff8eb00"
|
|
40
40
|
}
|