@ossy/sdk 0.0.8-alpha → 0.0.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/CHANGELOG.md +64 -0
- package/LICENSE +21 -0
- package/build/index.cjs.js +1 -1
- package/build/index.esm.js +1 -1
- package/package.json +15 -22
- package/src/api-tokens-client.js +2 -2
- package/src/jobs-client.js +24 -5
- package/src/resources-client.js +18 -2
- package/src/sdk.js +2 -0
- package/src/user-client.js +32 -0
- package/src/workspaces-client.js +15 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 0.0.9 (2025-10-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 0.0.8 (2025-10-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 0.0.7 (2025-10-25)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 0.0.6 (2025-10-25)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## 0.0.5 (2025-10-25)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## 0.0.4 (2025-10-25)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## 0.0.3 (2025-10-25)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @ossy/sdk
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## 0.0.2 (2025-10-25)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @ossy/sdk
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ossy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/build/index.cjs.js
CHANGED
|
@@ -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")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({
|
|
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")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}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/jobs/"},{type:{$regex:"^@ossy/jobs"}}]})}create({type:t,resourceId:n}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${n}`,content:{resourceId:n,status:s.Queued,result:void 0}})}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}create({name:t,description:e,expiresAt:s}){return this.http.post("/users/me/tokens",{name:t,description:e,expiresAt:s})}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class o{static of(t){return new o(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.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({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))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then(t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then(()=>t))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",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 i{static of(t){return new i(t)}constructor(t){this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.details=()=>this.getUser(),this.history=()=>this.getHistory()}getUser(){return this.http.get("/users/me")}getHistory(){return this.http.get("/users/me/history")}update(t){return this.http.put("/users/me",t)}}class c{static of(t){return new c(t)}constructor(t){this.workspaceId=t?.workspaceId,this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.users=()=>this.getUsers()}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("/resource-templates",e)}getResourceTemplates(t){return this.http.get("/resource-templates")}createApiToken(t,e){return this.http.post("/tokens",{workspaceId:t,description:e})}getApiTokens(t){return this.http.get("/tokens")}inviteUser(t,e){return this.http.post("/invitations",e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}getUsers(){return this.http.get("/users")}}function h(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function u(t){return function e(s){return 0===arguments.length||h(s)?e:t.apply(this,arguments)}}function a(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return h(s)?e:u(function(e){return t(s,e)});default:return h(s)&&h(r)?e:h(s)?u(function(e){return t(e,r)}):h(r)?u(function(e){return t(s,e)}):t(s,r)}}}function p(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var l="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)p(o,n)&&(e[o]=n[o]);s+=1}return e},d=a(function(t,e){return l({},t,e)});const f={"Content-Type":"application/json",Accept:"application/json"};class g{static of(t){return new g(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...f,...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}`,d(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 y{static of(t){return new y(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const h=g.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.user=i.of({...this.config,http:h}),this.auth=t.of({...this.config,http:h}),this.workspaces=c.of({...this.config,http:h}),this.apiTokens=n.of({...this.config,http:h}),this.resources=o.of({...this.config,http:h}),this.jobs=r.of({...this.config,http:h,resources:this.resources})}}exports.JobStatus=s,exports.Jobs=e,exports.SDK=y;
|
package/build/index.esm.js
CHANGED
|
@@ -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")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",Success:"success",Failed:"failed"};class r{static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get({
|
|
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")}}const e={VisualContentDescriptors:"@ossy/jobs/visual-content-descriptors",ResizeCommonWeb:"@ossy/jobs/resize-common-web"},s={Queued:"queued",InProgress:"in progress",Success:"success",Failed:"failed"};class r{static location="/@ossy/jobs/";static of(t){return new r(t)}constructor(t){this.http=t?.http,this.resources=t?.resources}get(t={}){const e="string"==typeof t?{id:t}:t;return e.location=r.location,this.resources.search(e)}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/jobs/"},{type:{$regex:"^@ossy/jobs"}}]})}create({type:t,resourceId:n}){if(!Object.values(e).includes(t))throw new Error(`Job type ${t} does not exist`);if(!n)throw new Error("Resource ID is required");return this.resources.create({type:t,location:r.location,name:`[${s.Queued}] ${n}`,content:{resourceId:n,status:s.Queued,result:void 0}})}}class n{static of(t){return new n(t)}constructor(t){this.http=t?.http}create({name:t,description:e,expiresAt:s}){return this.http.post("/users/me/tokens",{name:t,description:e,expiresAt:s})}getAll(){return this.http.get("/users/me/tokens")}invalidate(t){return this.http.delete(`/users/me/tokens/${t}`)}}class o{static of(t){return new o(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.create(t)}create(t){return this.http.post("/resources",{type:t.type,location:t.location,name:t.name,content:t.content})}upload({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))}uploadNamedVersion({resourceId:t,name:e,file:s}){return this.http.put(`/resources/${t}/${e}`,{type:s.type,size:s.size}).then(t=>fetch(t.content.uploadUrl,{method:"PUT",body:s}).then(()=>t))}byId(t){return this.http.get(`/resources/${t}`)}byLocation(t="/"){return this.http.get(`/resources?location=${t}`)}get(t={}){if("string"==typeof t)return this.byId(t);const e=new URLSearchParams(t).toString();return this.http.get(`/resources?${e}`)}search(t={}){return"string"==typeof t?this.byId(t):this.http.post("/resources/search",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 i{static of(t){return new i(t)}constructor(t){this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.details=()=>this.getUser(),this.history=()=>this.getHistory()}getUser(){return this.http.get("/users/me")}getHistory(){return this.http.get("/users/me/history")}update(t){return this.http.put("/users/me",t)}}class c{static of(t){return new c(t)}constructor(t){this.workspaceId=t?.workspaceId,this.http=t?.http,this.services={enable:t=>this.enableService(t),disable:t=>this.disableService(t)},this.users=()=>this.getUsers()}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("/resource-templates",e)}getResourceTemplates(t){return this.http.get("/resource-templates")}createApiToken(t,e){return this.http.post("/tokens",{workspaceId:t,description:e})}getApiTokens(t){return this.http.get("/tokens")}inviteUser(t,e){return this.http.post("/invitations",e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}getUsers(){return this.http.get("/users")}}function h(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function u(t){return function e(s){return 0===arguments.length||h(s)?e:t.apply(this,arguments)}}function a(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return h(s)?e:u(function(e){return t(s,e)});default:return h(s)&&h(r)?e:h(s)?u(function(e){return t(e,r)}):h(r)?u(function(e){return t(s,e)}):t(s,r)}}}function p(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var l="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)p(o,n)&&(e[o]=n[o]);s+=1}return e},d=a(function(t,e){return l({},t,e)});const f={"Content-Type":"application/json",Accept:"application/json"};class g{static of(t){return new g(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...f,...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}`,d(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 y{static of(t){return new y(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const h=g.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.user=i.of({...this.config,http:h}),this.auth=t.of({...this.config,http:h}),this.workspaces=c.of({...this.config,http:h}),this.apiTokens=n.of({...this.config,http:h}),this.resources=o.of({...this.config,http:h}),this.jobs=r.of({...this.config,http:h,resources:this.resources})}}export{s as JobStatus,e as Jobs,y as SDK};
|
package/package.json
CHANGED
|
@@ -1,43 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/sdk",
|
|
3
3
|
"description": "Sofware Development Kit for interactive with our services",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"url": "git://github.com/ossy-se/
|
|
4
|
+
"version": "0.0.9",
|
|
5
|
+
"url": "git://github.com/ossy-se/packages/sdk",
|
|
6
6
|
"source": "src/index.js",
|
|
7
7
|
"main": "build/index.cjs.js",
|
|
8
8
|
"module": "build/index.esm.js",
|
|
9
9
|
"author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
|
|
10
|
+
"repository": "github:ossy-se/packages",
|
|
11
|
+
"license": "MIT License",
|
|
10
12
|
"scripts": {
|
|
11
13
|
"start": "",
|
|
12
|
-
"build": "
|
|
14
|
+
"build": "rollup -c rollup.config.js",
|
|
13
15
|
"test": ""
|
|
14
16
|
},
|
|
15
|
-
"browserslist": {
|
|
16
|
-
"production": [
|
|
17
|
-
">0.2%",
|
|
18
|
-
"not dead",
|
|
19
|
-
"not op_mini all"
|
|
20
|
-
],
|
|
21
|
-
"development": [
|
|
22
|
-
"last 1 chrome version",
|
|
23
|
-
"last 1 firefox version",
|
|
24
|
-
"last 1 safari version"
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
17
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"ramda": "^0.27.1"
|
|
18
|
+
"ramda": "^0.32.0"
|
|
30
19
|
},
|
|
31
20
|
"devDependencies": {
|
|
32
21
|
"@babel/core": "^7.14.5",
|
|
33
22
|
"@babel/eslint-parser": "^7.15.8",
|
|
34
23
|
"@babel/preset-react": "^7.14.5",
|
|
35
|
-
"@rollup/plugin-commonjs": "^
|
|
36
|
-
"@rollup/plugin-node-resolve": "^
|
|
37
|
-
"babel-loader": "^
|
|
38
|
-
"rollup": "^
|
|
24
|
+
"@rollup/plugin-commonjs": "^28.0.9",
|
|
25
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
26
|
+
"babel-loader": "^10.0.0",
|
|
27
|
+
"rollup": "^4.52.5",
|
|
39
28
|
"rollup-plugin-babel": "^4.4.0",
|
|
40
29
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
41
30
|
"rollup-plugin-terser": "^7.0.2"
|
|
42
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "4e30bab37fa7624b3260cca5b8154c5f863ed8bb"
|
|
43
36
|
}
|
package/src/api-tokens-client.js
CHANGED
|
@@ -8,8 +8,8 @@ export class ApiTokensClient {
|
|
|
8
8
|
this.http = config?.http
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
create(description) {
|
|
12
|
-
return this.http.post('/users/me/tokens', description)
|
|
11
|
+
create({ name, description, expiresAt }) {
|
|
12
|
+
return this.http.post('/users/me/tokens', { name, description, expiresAt })
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
getAll() {
|
package/src/jobs-client.js
CHANGED
|
@@ -5,11 +5,13 @@ export const Jobs = {
|
|
|
5
5
|
|
|
6
6
|
export const JobStatus = {
|
|
7
7
|
Queued: 'queued',
|
|
8
|
+
InProgress: 'in progress',
|
|
8
9
|
Success: 'success',
|
|
9
10
|
Failed: 'failed',
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export class JobsClient {
|
|
14
|
+
static location = '/@ossy/jobs/'
|
|
13
15
|
|
|
14
16
|
static of(config) {
|
|
15
17
|
return new JobsClient(config)
|
|
@@ -20,10 +22,27 @@ export class JobsClient {
|
|
|
20
22
|
this.resources = config?.resources
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
get(
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
return this.resources.
|
|
25
|
+
get(_query = {}) {
|
|
26
|
+
const query = typeof _query === 'string' ? { id: _query } : _query
|
|
27
|
+
query.location = JobsClient.location
|
|
28
|
+
return this.resources.search(query)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getUnprocessed() {
|
|
32
|
+
return this.resources.search({
|
|
33
|
+
$and: [
|
|
34
|
+
{
|
|
35
|
+
$or: [
|
|
36
|
+
{ "content.nextReevaluation": { $exists: false } },
|
|
37
|
+
{ "content.nextReevaluation": null },
|
|
38
|
+
{ "content.nextReevaluation": { $lt: Date.now() } }
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{ 'content.status': { $in: ['queued', 'failed'] } },
|
|
42
|
+
{ "location": "/@ossy/jobs/" },
|
|
43
|
+
{ "type": { $regex: "^@ossy/jobs" } }
|
|
44
|
+
]
|
|
45
|
+
})
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
create({ type, resourceId }) {
|
|
@@ -32,7 +51,7 @@ export class JobsClient {
|
|
|
32
51
|
if (!resourceId) throw new Error(`Resource ID is required`)
|
|
33
52
|
return this.resources.create({
|
|
34
53
|
type,
|
|
35
|
-
location:
|
|
54
|
+
location: JobsClient.location,
|
|
36
55
|
name: `[${JobStatus.Queued}] ${resourceId}`,
|
|
37
56
|
content: {
|
|
38
57
|
resourceId,
|
package/src/resources-client.js
CHANGED
|
@@ -63,8 +63,24 @@ export class ResourcesClient {
|
|
|
63
63
|
return this.http.get(`/resources?location=${location}`)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
get(query = {}) {
|
|
67
|
+
|
|
68
|
+
if (typeof query === 'string') {
|
|
69
|
+
return this.byId(query)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const search = new URLSearchParams(query).toString()
|
|
73
|
+
return this.http.get(`/resources?${search}`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// for complex queries where not all parameters can be serialized in the URL
|
|
77
|
+
search(query = {}) {
|
|
78
|
+
|
|
79
|
+
if (typeof query === 'string') {
|
|
80
|
+
return this.byId(query)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.http.post(`/resources/search`, query)
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
remove(resourceId) {
|
package/src/sdk.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AuthClient } from './auth-client.js'
|
|
|
2
2
|
import { JobsClient } from './jobs-client.js'
|
|
3
3
|
import { ApiTokensClient } from './api-tokens-client.js'
|
|
4
4
|
import { ResourcesClient } from './resources-client.js'
|
|
5
|
+
import { UserClient } from './user-client.js'
|
|
5
6
|
import { WorkspacesClient } from './workspaces-client.js'
|
|
6
7
|
import { Http } from './http.js'
|
|
7
8
|
|
|
@@ -32,6 +33,7 @@ export class SDK {
|
|
|
32
33
|
})
|
|
33
34
|
|
|
34
35
|
this.workspaceId = this.config.workspaceId
|
|
36
|
+
this.user = UserClient.of({ ...this.config, http })
|
|
35
37
|
this.auth = AuthClient.of({ ...this.config, http })
|
|
36
38
|
this.workspaces = WorkspacesClient.of({ ...this.config, http })
|
|
37
39
|
this.apiTokens = ApiTokensClient.of({ ...this.config, http })
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class UserClient {
|
|
2
|
+
|
|
3
|
+
static of(config) {
|
|
4
|
+
return new UserClient(config)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.http = config?.http
|
|
9
|
+
|
|
10
|
+
this.services = {
|
|
11
|
+
enable: x => this.enableService(x),
|
|
12
|
+
disable: x => this.disableService(x)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
this.details = () => this.getUser()
|
|
16
|
+
this.history = () => this.getHistory()
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getUser() {
|
|
21
|
+
return this.http.get('/users/me')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getHistory() {
|
|
25
|
+
return this.http.get('/users/me/history')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
update(user) {
|
|
29
|
+
return this.http.put('/users/me', user)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
package/src/workspaces-client.js
CHANGED
|
@@ -5,12 +5,16 @@ export class WorkspacesClient {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
constructor(config) {
|
|
8
|
+
this.workspaceId = config?.workspaceId
|
|
8
9
|
this.http = config?.http
|
|
9
10
|
|
|
10
11
|
this.services = {
|
|
11
12
|
enable: x => this.enableService(x),
|
|
12
13
|
disable: x => this.disableService(x)
|
|
13
14
|
}
|
|
15
|
+
|
|
16
|
+
this.users = () => this.getUsers()
|
|
17
|
+
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
getAll() {
|
|
@@ -27,33 +31,33 @@ export class WorkspacesClient {
|
|
|
27
31
|
|
|
28
32
|
importResourceTempaltes(workspaceId, templates) {
|
|
29
33
|
return this.http.post(
|
|
30
|
-
`/
|
|
34
|
+
`/resource-templates`,
|
|
31
35
|
templates
|
|
32
36
|
)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
getResourceTemplates(workspaceId) {
|
|
36
40
|
return this.http.get(
|
|
37
|
-
`/
|
|
41
|
+
`/resource-templates`
|
|
38
42
|
)
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
createApiToken(workspaceId, description) {
|
|
42
46
|
return this.http.post(
|
|
43
|
-
`/
|
|
47
|
+
`/tokens`,
|
|
44
48
|
{ workspaceId, description }
|
|
45
49
|
)
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
getApiTokens(workspaceId) {
|
|
49
53
|
return this.http.get(
|
|
50
|
-
`/
|
|
54
|
+
`/tokens`
|
|
51
55
|
)
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
inviteUser(workspaceId, email) {
|
|
55
59
|
return this.http.post(
|
|
56
|
-
`/
|
|
60
|
+
`/invitations`,
|
|
57
61
|
email
|
|
58
62
|
)
|
|
59
63
|
}
|
|
@@ -72,4 +76,10 @@ export class WorkspacesClient {
|
|
|
72
76
|
)
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
getUsers() {
|
|
80
|
+
return this.http.get(
|
|
81
|
+
`/users`
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
}
|