@ossy/sdk 0.0.13-alpha → 0.0.15

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 ADDED
@@ -0,0 +1,112 @@
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.15 (2025-10-27)
7
+
8
+ **Note:** Version bump only for package @ossy/sdk
9
+
10
+
11
+
12
+
13
+
14
+ ## 0.0.14 (2025-10-27)
15
+
16
+ **Note:** Version bump only for package @ossy/sdk
17
+
18
+
19
+
20
+
21
+
22
+ ## 0.0.13 (2025-10-27)
23
+
24
+ **Note:** Version bump only for package @ossy/sdk
25
+
26
+
27
+
28
+
29
+
30
+ ## 0.0.12 (2025-10-27)
31
+
32
+ **Note:** Version bump only for package @ossy/sdk
33
+
34
+
35
+
36
+
37
+
38
+ ## 0.0.11 (2025-10-27)
39
+
40
+ **Note:** Version bump only for package @ossy/sdk
41
+
42
+
43
+
44
+
45
+
46
+ ## 0.0.10 (2025-10-25)
47
+
48
+ **Note:** Version bump only for package @ossy/sdk
49
+
50
+
51
+
52
+
53
+
54
+ ## 0.0.9 (2025-10-25)
55
+
56
+ **Note:** Version bump only for package @ossy/sdk
57
+
58
+
59
+
60
+
61
+
62
+ ## 0.0.8 (2025-10-25)
63
+
64
+ **Note:** Version bump only for package @ossy/sdk
65
+
66
+
67
+
68
+
69
+
70
+ ## 0.0.7 (2025-10-25)
71
+
72
+ **Note:** Version bump only for package @ossy/sdk
73
+
74
+
75
+
76
+
77
+
78
+ ## 0.0.6 (2025-10-25)
79
+
80
+ **Note:** Version bump only for package @ossy/sdk
81
+
82
+
83
+
84
+
85
+
86
+ ## 0.0.5 (2025-10-25)
87
+
88
+ **Note:** Version bump only for package @ossy/sdk
89
+
90
+
91
+
92
+
93
+
94
+ ## 0.0.4 (2025-10-25)
95
+
96
+ **Note:** Version bump only for package @ossy/sdk
97
+
98
+
99
+
100
+
101
+
102
+ ## 0.0.3 (2025-10-25)
103
+
104
+ **Note:** Version bump only for package @ossy/sdk
105
+
106
+
107
+
108
+
109
+
110
+ ## 0.0.2 (2025-10-25)
111
+
112
+ **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/package.json CHANGED
@@ -1,30 +1,29 @@
1
1
  {
2
2
  "name": "@ossy/sdk",
3
- "description": "Sofware Development Kit for interactive with our services",
4
- "version": "0.0.13-alpha",
5
- "url": "git://github.com/ossy-se/ossy.git",
6
- "source": "src/index.js",
7
- "main": "build/index.cjs.js",
8
- "module": "build/index.esm.js",
3
+ "description": "Sofware Development Kit for interacting with our services",
4
+ "version": "0.0.15",
5
+ "url": "git://github.com/ossy-se/packages/sdk",
6
+ "source": "src/public.index.ts",
7
+ "module": "build/public.index.js",
8
+ "types": "build/public.index.d.ts",
9
+ "type": "module",
9
10
  "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ossy-se/packages.git"
14
+ },
15
+ "license": "MIT",
10
16
  "scripts": {
11
17
  "start": "",
12
- "build": "rm -rf && rollup -c rollup.config.js",
18
+ "build": "rollup -c rollup.config.js",
13
19
  "test": ""
14
20
  },
15
21
  "dependencies": {
16
- "ramda": "^0.27.1"
22
+ "ramda": "^0.32.0"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org"
17
27
  },
18
- "devDependencies": {
19
- "@babel/core": "^7.14.5",
20
- "@babel/eslint-parser": "^7.15.8",
21
- "@babel/preset-react": "^7.14.5",
22
- "@rollup/plugin-commonjs": "^21.0.1",
23
- "@rollup/plugin-node-resolve": "^13.0.0",
24
- "babel-loader": "^8.2.2",
25
- "rollup": "^2.37.1",
26
- "rollup-plugin-babel": "^4.4.0",
27
- "rollup-plugin-peer-deps-external": "^2.2.4",
28
- "rollup-plugin-terser": "^7.0.2"
29
- }
28
+ "gitHead": "7fb7d504578d7c75c110ff7a14a7fd53acc89f0a"
30
29
  }
package/rollup.config.js CHANGED
@@ -1,30 +1,38 @@
1
- import babel from 'rollup-plugin-babel'
2
- import { nodeResolve } from '@rollup/plugin-node-resolve'
1
+ import typescript from '@rollup/plugin-typescript'
2
+ import { nodeResolve as resolveDependencies } from '@rollup/plugin-node-resolve'
3
+ import resolveCommonJsDependencies from '@rollup/plugin-commonjs'
3
4
  import removeOwnPeerDependencies from 'rollup-plugin-peer-deps-external'
4
- import commonjs from '@rollup/plugin-commonjs'
5
- import { terser as minifyJS } from 'rollup-plugin-terser'
6
- import pkg from './package.json'
5
+ import minifyJS from '@rollup/plugin-terser'
6
+ import pkg from './package.json' with { type: 'json' };
7
+ import { dts } from "rollup-plugin-dts"
7
8
 
8
- export default {
9
- input: pkg.source,
10
- output: [
11
- {
12
- file: pkg.main,
13
- format: 'cjs'
14
- },
15
- {
16
- file: pkg.module,
17
- format: 'esm'
18
- }
19
- ],
20
- plugins: [
21
- nodeResolve(),
22
- commonjs(),
23
- babel({
24
- exclude: ['**/node_modules/**/*'],
25
- presets: ['@babel/preset-react']
26
- }),
27
- removeOwnPeerDependencies(),
28
- minifyJS()
29
- ]
30
- }
9
+ export default [
10
+ {
11
+ input: pkg.source,
12
+ output: [
13
+ {
14
+ dir: 'build',
15
+ preserveModules: true,
16
+ format: 'esm'
17
+ }
18
+ ],
19
+ plugins: [
20
+ resolveCommonJsDependencies(),
21
+ resolveDependencies(),
22
+ resolveCommonJsDependencies(),
23
+ typescript({
24
+ tsconfig: "./tsconfig.json",
25
+ outDir: 'build',
26
+ }),
27
+ removeOwnPeerDependencies(),
28
+ minifyJS()
29
+ ]
30
+ },
31
+ {
32
+ input: "build/types/public.index.d.ts",
33
+ output: [{ file: "build/public.index.d.ts", format: "es" }],
34
+ plugins: [
35
+ dts()
36
+ ],
37
+ },
38
+ ]
@@ -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() {
@@ -0,0 +1,2 @@
1
+ export * from './sdk.js'
2
+ export { Jobs, JobStatus } from './jobs-client.js'
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 })
@@ -42,4 +44,3 @@ export class SDK {
42
44
 
43
45
  }
44
46
 
45
-
@@ -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
+ }
@@ -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
- `/workspaces/${workspaceId}/resource-templates`,
34
+ `/resource-templates`,
31
35
  templates
32
36
  )
33
37
  }
34
38
 
35
39
  getResourceTemplates(workspaceId) {
36
40
  return this.http.get(
37
- `/workspaces/${workspaceId}/resource-templates`
41
+ `/resource-templates`
38
42
  )
39
43
  }
40
44
 
41
45
  createApiToken(workspaceId, description) {
42
46
  return this.http.post(
43
- `/workspaces/${workspaceId}/tokens`,
47
+ `/tokens`,
44
48
  { workspaceId, description }
45
49
  )
46
50
  }
47
51
 
48
52
  getApiTokens(workspaceId) {
49
53
  return this.http.get(
50
- `/workspaces/${workspaceId}/tokens`
54
+ `/tokens`
51
55
  )
52
56
  }
53
57
 
54
58
  inviteUser(workspaceId, email) {
55
59
  return this.http.post(
56
- `/workspaces/${workspaceId}/invitations`,
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
  }
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es6",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "node",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "incremental": false,
15
+ "declaration": true,
16
+ "declarationDir": "./build/types"
17
+ },
18
+ "exclude": [
19
+ "build",
20
+ "node_modules",
21
+ "src/**/*.test.tsx",
22
+ "src/**/*.stories.tsx",
23
+ "rollup.config.js",
24
+ "src/data.mock.ts"
25
+ ]
26
+ }
@@ -1 +0,0 @@
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(t){return this.http.post("/users/me/tokens",t)}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)}}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(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function u(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function h(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:u((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?u((function(e){return t(e,r)})):c(r)?u((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="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)a(o,n)&&(e[o]=n[o]);s+=1}return e},l=h((function(t,e){return p({},t,e)}));const d={"Content-Type":"application/json",Accept:"application/json"};class f{static of(t){return new f(t)}constructor(t){this.baseUrl=t.baseUrl,"object"==typeof t?.headers&&(this.getHeaders=()=>Promise.resolve({...d,...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}`,l(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 g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=f.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.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=n.of({...this.config,http:c}),this.resources=o.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}exports.JobStatus=s,exports.Jobs=e,exports.SDK=g;
@@ -1 +0,0 @@
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(t){return this.http.post("/users/me/tokens",t)}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)}}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(`/workspaces/${t}/resource-templates`,e)}getResourceTemplates(t){return this.http.get(`/workspaces/${t}/resource-templates`)}createApiToken(t,e){return this.http.post(`/workspaces/${t}/tokens`,{workspaceId:t,description:e})}getApiTokens(t){return this.http.get(`/workspaces/${t}/tokens`)}inviteUser(t,e){return this.http.post(`/workspaces/${t}/invitations`,e)}enableService(t){return this.http.post("/services/enable",t)}disableService(t){return this.http.post("/services/disable",t)}}function c(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function u(t){return function e(s){return 0===arguments.length||c(s)?e:t.apply(this,arguments)}}function h(t){return function e(s,r){switch(arguments.length){case 0:return e;case 1:return c(s)?e:u((function(e){return t(s,e)}));default:return c(s)&&c(r)?e:c(s)?u((function(e){return t(e,r)})):c(r)?u((function(e){return t(s,e)})):t(s,r)}}}function a(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var p="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)a(o,n)&&(e[o]=n[o]);s+=1}return e},l=h((function(t,e){return p({},t,e)}));const f={"Content-Type":"application/json",Accept:"application/json"};class d{static of(t){return new d(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}`,l(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 g{static of(t){return new g(t)}constructor(t){this.updateConfig(t)}updateConfig(e){const s=this.config||{};this.config={...s,...e};const c=d.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.auth=t.of({...this.config,http:c}),this.workspaces=i.of({...this.config,http:c}),this.apiTokens=n.of({...this.config,http:c}),this.resources=o.of({...this.config,http:c}),this.jobs=r.of({...this.config,http:c,resources:this.resources})}}export{s as JobStatus,e as Jobs,g as SDK};