@ossy/sdk 0.1.3 → 0.1.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.
@@ -0,0 +1 @@
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"},n={id:"workspaces.create",endpoint:"/workspaces",method:"POST"},r={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"},l={id:"resources.create-directory",endpoint:"/resources",method:"POST",payload:{type:"directory"}},w={id:"resources.create",endpoint:"/resources",method:"POST"},P={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.remove",endpoint:"/resources/:id",method:"DELETE"},f={id:"resources.update-content",endpoint:"/resources/:id/content",method:"PUT"},U={id:"resources.move",endpoint:"/resources/:id/location",method:"PUT"},b={id:"resources.rename",endpoint:"/resources/:id/name",method:"PUT"},D={id:"auth.sign-up",endpoint:"/users/sign-up",method:"POST"},L={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"},I={id:"auth.verify-invitation",endpoint:"/workspaces/:workspaceId/invitations?token=:token",method:"GET"},j={id:"auth.get-authenticated-user",endpoint:"/users/me",method:"GET"},q={id:"auth.get-authenticated-user-history",endpoint:"/users/me/history",method:"GET"},z={id:"auth.get-user",endpoint:"/users/:id",method:"GET"},A={id:"auth.sign-off",endpoint:"/users/sign-off",method:"GET"};export{s as ApiTokenCreate,e as ApiTokenGetAll,o as ApiTokenInvalidate,j as AuthGetAuthenticatedUser,q as AuthGetAuthenticatedUserHistory,z as AuthGetUser,L as AuthSignIn,A as AuthSignOff,D as AuthSignUp,I as AuthVerifyInvitation,x as AuthVerifySignIn,w as ResourcesCreate,l as ResourcesCreateDirectory,v as ResourcesGet,O as ResourcesList,U as ResourcesMove,y as ResourcesRemove,b as ResourcesRename,S as ResourcesSearch,f as ResourcesUpdateContent,P as ResourcesUpload,G as ResourcesUploadNamedVersion,k as UserCurrentGet,E as UserCurrentGetHistory,g as UserCurrentUpdate,n 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,r as WorkspacesImportResourceTemplates,u as WorkspacesInviteUser,t as WorkspacesList};
@@ -0,0 +1 @@
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};
@@ -0,0 +1,150 @@
1
+ interface SDKConfig {
2
+ apiUrl?: string;
3
+ workspaceId?: string;
4
+ authorization?: string;
5
+ }
6
+
7
+ interface Action<Payload extends (Record<string, string | boolean | number> & SDKConfig) | undefined = {}> {
8
+ id: string;
9
+ endpoint: string;
10
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
11
+ payload?: Payload;
12
+ }
13
+
14
+ declare class SDK {
15
+ workspaceId?: string;
16
+ authorization?: string;
17
+ baseUrl: string;
18
+ static of(config: SDKConfig): SDK;
19
+ constructor(config: SDKConfig);
20
+ updateConfig(intendedConfig: SDKConfig): void;
21
+ get apiTokens(): {
22
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
23
+ create: (_payload?: Required<{
24
+ name: string;
25
+ description: string;
26
+ expiresAt: string;
27
+ } | undefined>) => Promise<any>;
28
+ invalidate: (_payload?: Required<{
29
+ id: string;
30
+ } | undefined>) => Promise<any>;
31
+ };
32
+ get workspaces(): {
33
+ current: (_payload?: Required<{} | undefined>) => Promise<any>;
34
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
35
+ get: (_payload?: Required<{
36
+ id: string;
37
+ } | undefined>) => Promise<any>;
38
+ create: (_payload?: Required<{
39
+ name: string;
40
+ } | undefined>) => Promise<any>;
41
+ importResourceTemplates: (_payload?: Required<{
42
+ templates: any;
43
+ } | undefined>) => Promise<any>;
44
+ getResourceTemplates: (_payload?: Required<{} | undefined>) => Promise<any>;
45
+ createApiToken: (_payload?: Required<{
46
+ description: string;
47
+ } | undefined>) => Promise<any>;
48
+ getApiTokens: (_payload?: Required<{} | undefined>) => Promise<any>;
49
+ inviteUser: (_payload?: Required<{
50
+ email: string;
51
+ } | undefined>) => Promise<any>;
52
+ enableService: (_payload?: Required<{
53
+ service: any;
54
+ } | undefined>) => Promise<any>;
55
+ disableService: (_payload?: Required<{
56
+ service: any;
57
+ } | undefined>) => Promise<any>;
58
+ };
59
+ get users(): {
60
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
61
+ };
62
+ get currentUser(): {
63
+ get: (_payload?: Required<{} | undefined>) => Promise<any>;
64
+ update: (_payload?: Required<{
65
+ user: any;
66
+ } | undefined>) => Promise<any>;
67
+ history: (_payload?: Required<{} | undefined>) => Promise<any>;
68
+ };
69
+ get resources(): {
70
+ createDirectory: (_payload?: Required<{
71
+ type?: "directory";
72
+ location: string;
73
+ name: string;
74
+ } | undefined>) => Promise<any>;
75
+ create: (_payload?: Required<{
76
+ type: string;
77
+ location: string;
78
+ name: string;
79
+ content?: any;
80
+ } | undefined>) => Promise<any>;
81
+ upload: ({ location, file }: {
82
+ location: string;
83
+ file: File;
84
+ }) => Promise<any>;
85
+ uploadNamedVersion: ({ id, name, file }: {
86
+ id: string;
87
+ name: string;
88
+ file: File;
89
+ }) => void;
90
+ get: (_payload?: Required<{
91
+ id: string;
92
+ } | undefined>) => Promise<any>;
93
+ list: (query: ({
94
+ location?: string;
95
+ })) => Promise<any>;
96
+ search: (_payload?: Required<{
97
+ query: any;
98
+ } | undefined>) => Promise<any>;
99
+ remove: (_payload?: Required<{
100
+ id: string;
101
+ } | undefined>) => Promise<any>;
102
+ updateContent: (_payload?: Required<{
103
+ id: string;
104
+ content: any;
105
+ } | undefined>) => Promise<any>;
106
+ move: (_payload?: Required<{
107
+ id: string;
108
+ target: string;
109
+ } | undefined>) => Promise<any>;
110
+ rename: (_payload?: Required<{
111
+ id: string;
112
+ name: string;
113
+ } | undefined>) => Promise<any>;
114
+ };
115
+ get auth(): {
116
+ signUp: (_payload?: Required<{
117
+ email: string;
118
+ } | undefined>) => Promise<any>;
119
+ signIn: (_payload?: Required<{
120
+ email: string;
121
+ } | undefined>) => Promise<any>;
122
+ verifySignIn: (_payload?: Required<{
123
+ token: string;
124
+ } | undefined>) => Promise<any>;
125
+ verifyInvitation: (_payload?: Required<{
126
+ workspaceId: string;
127
+ token: string;
128
+ } | undefined>) => Promise<any>;
129
+ getAuthenticatedUser: (_payload?: Required<{} | undefined>) => Promise<any>;
130
+ getAuthenticatedUserHistory: (_payload?: Required<{} | undefined>) => Promise<any>;
131
+ getUser: (_payload?: Required<{
132
+ id: string;
133
+ } | undefined>) => Promise<any>;
134
+ signOff: (_payload?: Required<{} | undefined>) => Promise<any>;
135
+ };
136
+ makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
137
+ }
138
+
139
+ declare namespace Jobs {
140
+ let VisualContentDescriptors: string;
141
+ let ResizeCommonWeb: string;
142
+ }
143
+ declare namespace JobStatus {
144
+ let Queued: string;
145
+ let InProgress: string;
146
+ let Success: string;
147
+ let Failed: string;
148
+ }
149
+
150
+ export { JobStatus, Jobs, SDK };
@@ -0,0 +1 @@
1
+ export{SDK}from"./sdk.js";export{JobStatus,Jobs}from"./jobs-client.js";
package/build/sdk.js ADDED
@@ -0,0 +1 @@
1
+ import{ApiTokenInvalidate as e,ApiTokenCreate as t,ApiTokenGetAll as i,WorkspacesDisableService as s,WorkspacesEnableService as n,WorkspacesInviteUser as a,WorkspacesGetApiTokens as h,WorkspacesCreateApiToken as r,WorkspacesGetResourceTemplates as o,WorkspacesImportResourceTemplates as u,WorkspacesCreate as d,WorkspacesGet as m,WorkspacesList as c,WorkspacesGetCurrent as k,WorkspacesGetUsers as b,UserCurrentGetHistory as p,UserCurrentUpdate as l,UserCurrentGet as R,ResourcesRename as q,ResourcesMove as g,ResourcesUpdateContent as U,ResourcesRemove as y,ResourcesSearch as f,ResourcesList as z,ResourcesGet as v,ResourcesUploadNamedVersion as j,ResourcesUpload as w,ResourcesCreate as I,ResourcesCreateDirectory as T,AuthSignOff as S,AuthGetUser as A,AuthGetAuthenticatedUserHistory as C,AuthGetAuthenticatedUser as O,AuthVerifyInvitation as P,AuthVerifySignIn as N,AuthSignIn as $,AuthSignUp as x}from"./Actions.js";class D{static of(e){return new D(e)}constructor(e){this.baseUrl="https://api.ossy.se/api/v0",this.makeRequest=e=>t=>{let i={};(t||e.payload)&&(i=Object.assign(Object.assign({},e.payload||{}),t||{}));let s,n="apiUrl"in i?null==i?void 0:i.apiUrl:this.baseUrl,a="workspaceId"in i?i.workspaceId:this.workspaceId,h="authorization"in i?i.authorization:this.authorization,r=e.endpoint;if(i){s=JSON.stringify(i);r=(e.endpoint.match(/:([a-zA-Z0-9_]+)/g)||[]).map(e=>e.slice(1)).reduce((e,t)=>e.replace(String(t),String(i[t])),e.endpoint)}return fetch(`${n}${r}`,{credentials:"include",headers:{"Content-Type":"application/json",workspaceId:a,Authorization:h},method:e.method,body:s}).then(e=>{const t=e.headers.get("Content-Type")||"",i=e.status;return 400===i?e.json().then(e=>Promise.reject(e.error)):[200,204].includes(i)?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(t).bind(this),invalidate:this.makeRequest(e).bind(this)}}get workspaces(){return{current:this.makeRequest(k).bind(this),list:this.makeRequest(c).bind(this),get:this.makeRequest(m).bind(this),create:this.makeRequest(d).bind(this),importResourceTemplates:this.makeRequest(u).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(s).bind(this)}}get users(){return{list:this.makeRequest(b).bind(this)}}get currentUser(){return{get:this.makeRequest(R).bind(this),update:this.makeRequest(l).bind(this),history:this.makeRequest(p).bind(this)}}get resources(){return{createDirectory:this.makeRequest(T).bind(this),create:this.makeRequest(I).bind(this),upload:({location:e="/",file:t})=>{const i={type:t.type,location:e,name:t.name,size:t.size};return this.makeRequest(w)(i).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:t}).then(()=>e))},uploadNamedVersion:({id:e,name:t,file:i})=>{const s={id:e,name:t,size:i.size};this.makeRequest(j)(s).then(e=>fetch(e.content.uploadUrl,{method:"PUT",body:i}).then(()=>e))},get:this.makeRequest(v).bind(this),list:e=>{const t=new URLSearchParams(Object.assign({},e)).toString();return this.makeRequest(z)({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(x).bind(this),signIn:this.makeRequest($).bind(this),verifySignIn:this.makeRequest(N).bind(this),verifyInvitation:this.makeRequest(P).bind(this),getAuthenticatedUser:this.makeRequest(O).bind(this),getAuthenticatedUserHistory:this.makeRequest(C).bind(this),getUser:this.makeRequest(A).bind(this),signOff:this.makeRequest(S).bind(this)}}}export{D as SDK};
@@ -0,0 +1,112 @@
1
+ import { SDKConfig } from "./config";
2
+ export interface Action<Payload extends (Record<string, string | boolean | number> & SDKConfig) | undefined = {}> {
3
+ id: string;
4
+ endpoint: string;
5
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
6
+ payload?: Payload;
7
+ }
8
+ export declare const ApiTokenGetAll: Action;
9
+ export declare const ApiTokenCreate: Action<{
10
+ name: string;
11
+ description: string;
12
+ expiresAt: string;
13
+ }>;
14
+ export declare const ApiTokenInvalidate: Action<{
15
+ id: string;
16
+ }>;
17
+ export declare const WorkspacesList: Action;
18
+ export declare const WorkspacesGetCurrent: Action;
19
+ export declare const WorkspacesGet: Action<{
20
+ id: string;
21
+ }>;
22
+ export declare const WorkspacesCreate: Action<{
23
+ name: string;
24
+ }>;
25
+ export declare const WorkspacesImportResourceTemplates: Action<{
26
+ templates: any;
27
+ }>;
28
+ export declare const WorkspacesGetResourceTemplates: Action;
29
+ export declare const WorkspacesCreateApiToken: Action<{
30
+ description: string;
31
+ }>;
32
+ export declare const WorkspacesGetApiTokens: Action;
33
+ export declare const WorkspacesInviteUser: Action<{
34
+ email: string;
35
+ }>;
36
+ export declare const WorkspacesEnableService: Action<{
37
+ service: any;
38
+ }>;
39
+ export declare const WorkspacesDisableService: Action<{
40
+ service: any;
41
+ }>;
42
+ export declare const WorkspacesGetUsers: Action;
43
+ export declare const UserCurrentGet: Action;
44
+ export declare const UserCurrentGetHistory: Action;
45
+ export declare const UserCurrentUpdate: Action<{
46
+ user: any;
47
+ }>;
48
+ export declare const ResourcesCreateDirectory: Action<{
49
+ type?: 'directory';
50
+ location: string;
51
+ name: string;
52
+ }>;
53
+ export declare const ResourcesCreate: Action<{
54
+ type: string;
55
+ location: string;
56
+ name: string;
57
+ content?: any;
58
+ }>;
59
+ export declare const ResourcesUpload: Action<{
60
+ location: string;
61
+ type: string;
62
+ name: string;
63
+ size: number;
64
+ }>;
65
+ export declare const ResourcesUploadNamedVersion: Action<{
66
+ id: string;
67
+ name: string;
68
+ size: number;
69
+ }>;
70
+ export declare const ResourcesGet: Action<{
71
+ id: string;
72
+ }>;
73
+ export declare const ResourcesList: Action<{
74
+ search?: string;
75
+ }>;
76
+ export declare const ResourcesSearch: Action<{
77
+ query: any;
78
+ }>;
79
+ export declare const ResourcesRemove: Action<{
80
+ id: string;
81
+ }>;
82
+ export declare const ResourcesUpdateContent: Action<{
83
+ id: string;
84
+ content: any;
85
+ }>;
86
+ export declare const ResourcesMove: Action<{
87
+ id: string;
88
+ target: string;
89
+ }>;
90
+ export declare const ResourcesRename: Action<{
91
+ id: string;
92
+ name: string;
93
+ }>;
94
+ export declare const AuthSignUp: Action<{
95
+ email: string;
96
+ }>;
97
+ export declare const AuthSignIn: Action<{
98
+ email: string;
99
+ }>;
100
+ export declare const AuthVerifySignIn: Action<{
101
+ token: string;
102
+ }>;
103
+ export declare const AuthVerifyInvitation: Action<{
104
+ workspaceId: string;
105
+ token: string;
106
+ }>;
107
+ export declare const AuthGetAuthenticatedUser: Action;
108
+ export declare const AuthGetAuthenticatedUserHistory: Action;
109
+ export declare const AuthGetUser: Action<{
110
+ id: string;
111
+ }>;
112
+ export declare const AuthSignOff: Action;
@@ -0,0 +1,5 @@
1
+ export interface SDKConfig {
2
+ apiUrl?: string;
3
+ workspaceId?: string;
4
+ authorization?: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./sdk.js";
2
+ export { Jobs, JobStatus } from "./jobs-client.js";
@@ -0,0 +1,23 @@
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
+ export class JobsClient {
12
+ static location: string;
13
+ static of(config: any): JobsClient;
14
+ constructor(config: any);
15
+ http: any;
16
+ resources: any;
17
+ get(_query?: {}): any;
18
+ getUnprocessed(): any;
19
+ create({ type, resourceId }: {
20
+ type: any;
21
+ resourceId: any;
22
+ }): any;
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from './sdk.js';
2
+ export { Jobs, JobStatus } from './jobs-client.js';
@@ -0,0 +1,126 @@
1
+ import { Action } from './Actions';
2
+ import { SDKConfig } from './config';
3
+ export declare class SDK {
4
+ workspaceId?: string;
5
+ authorization?: string;
6
+ baseUrl: string;
7
+ static of(config: SDKConfig): SDK;
8
+ constructor(config: SDKConfig);
9
+ updateConfig(intendedConfig: SDKConfig): void;
10
+ get apiTokens(): {
11
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
12
+ create: (_payload?: Required<{
13
+ name: string;
14
+ description: string;
15
+ expiresAt: string;
16
+ } | undefined>) => Promise<any>;
17
+ invalidate: (_payload?: Required<{
18
+ id: string;
19
+ } | undefined>) => Promise<any>;
20
+ };
21
+ get workspaces(): {
22
+ current: (_payload?: Required<{} | undefined>) => Promise<any>;
23
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
24
+ get: (_payload?: Required<{
25
+ id: string;
26
+ } | undefined>) => Promise<any>;
27
+ create: (_payload?: Required<{
28
+ name: string;
29
+ } | undefined>) => Promise<any>;
30
+ importResourceTemplates: (_payload?: Required<{
31
+ templates: any;
32
+ } | undefined>) => Promise<any>;
33
+ getResourceTemplates: (_payload?: Required<{} | undefined>) => Promise<any>;
34
+ createApiToken: (_payload?: Required<{
35
+ description: string;
36
+ } | undefined>) => Promise<any>;
37
+ getApiTokens: (_payload?: Required<{} | undefined>) => Promise<any>;
38
+ inviteUser: (_payload?: Required<{
39
+ email: string;
40
+ } | undefined>) => Promise<any>;
41
+ enableService: (_payload?: Required<{
42
+ service: any;
43
+ } | undefined>) => Promise<any>;
44
+ disableService: (_payload?: Required<{
45
+ service: any;
46
+ } | undefined>) => Promise<any>;
47
+ };
48
+ get users(): {
49
+ list: (_payload?: Required<{} | undefined>) => Promise<any>;
50
+ };
51
+ get currentUser(): {
52
+ get: (_payload?: Required<{} | undefined>) => Promise<any>;
53
+ update: (_payload?: Required<{
54
+ user: any;
55
+ } | undefined>) => Promise<any>;
56
+ history: (_payload?: Required<{} | undefined>) => Promise<any>;
57
+ };
58
+ get resources(): {
59
+ createDirectory: (_payload?: Required<{
60
+ type?: "directory";
61
+ location: string;
62
+ name: string;
63
+ } | undefined>) => Promise<any>;
64
+ create: (_payload?: Required<{
65
+ type: string;
66
+ location: string;
67
+ name: string;
68
+ content?: any;
69
+ } | undefined>) => Promise<any>;
70
+ upload: ({ location, file }: {
71
+ location: string;
72
+ file: File;
73
+ }) => Promise<any>;
74
+ uploadNamedVersion: ({ id, name, file }: {
75
+ id: string;
76
+ name: string;
77
+ file: File;
78
+ }) => void;
79
+ get: (_payload?: Required<{
80
+ id: string;
81
+ } | undefined>) => Promise<any>;
82
+ list: (query: ({
83
+ location?: string;
84
+ })) => Promise<any>;
85
+ search: (_payload?: Required<{
86
+ query: any;
87
+ } | undefined>) => Promise<any>;
88
+ remove: (_payload?: Required<{
89
+ id: string;
90
+ } | undefined>) => Promise<any>;
91
+ updateContent: (_payload?: Required<{
92
+ id: string;
93
+ content: any;
94
+ } | undefined>) => Promise<any>;
95
+ move: (_payload?: Required<{
96
+ id: string;
97
+ target: string;
98
+ } | undefined>) => Promise<any>;
99
+ rename: (_payload?: Required<{
100
+ id: string;
101
+ name: string;
102
+ } | undefined>) => Promise<any>;
103
+ };
104
+ get auth(): {
105
+ signUp: (_payload?: Required<{
106
+ email: string;
107
+ } | undefined>) => Promise<any>;
108
+ signIn: (_payload?: Required<{
109
+ email: string;
110
+ } | undefined>) => Promise<any>;
111
+ verifySignIn: (_payload?: Required<{
112
+ token: string;
113
+ } | undefined>) => Promise<any>;
114
+ verifyInvitation: (_payload?: Required<{
115
+ workspaceId: string;
116
+ token: string;
117
+ } | undefined>) => Promise<any>;
118
+ getAuthenticatedUser: (_payload?: Required<{} | undefined>) => Promise<any>;
119
+ getAuthenticatedUserHistory: (_payload?: Required<{} | undefined>) => Promise<any>;
120
+ getUser: (_payload?: Required<{
121
+ id: string;
122
+ } | undefined>) => Promise<any>;
123
+ signOff: (_payload?: Required<{} | undefined>) => Promise<any>;
124
+ };
125
+ makeRequest: <T extends Action>(action: T) => (_payload?: Required<T["payload"]>) => Promise<any>;
126
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/sdk",
3
3
  "description": "Sofware Development Kit for interacting with our services",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "url": "git://github.com/ossy-se/packages/sdk",
6
6
  "source": "src/public.index.ts",
7
7
  "module": "build/public.index.js",
@@ -22,5 +22,9 @@
22
22
  "access": "public",
23
23
  "registry": "https://registry.npmjs.org"
24
24
  },
25
- "gitHead": "80c0c70120640e7b389d1881a71b2376fd523095"
25
+ "files": [
26
+ "/build",
27
+ "README.md"
28
+ ],
29
+ "gitHead": "a768d71e76cc523f367cd764a403c0960f8d2e93"
26
30
  }
package/CHANGELOG.md DELETED
@@ -1,155 +0,0 @@
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.1.3 (2025-10-31)
7
-
8
- **Note:** Version bump only for package @ossy/sdk
9
-
10
-
11
-
12
-
13
-
14
- ## 0.1.2 (2025-10-31)
15
-
16
- **Note:** Version bump only for package @ossy/sdk
17
-
18
-
19
-
20
-
21
-
22
- ## 0.1.1 (2025-10-31)
23
-
24
- **Note:** Version bump only for package @ossy/sdk
25
-
26
-
27
-
28
-
29
-
30
- # 0.1.0 (2025-10-30)
31
-
32
-
33
- ### Features
34
-
35
- * **sdk:** get current workspace ([#4](https://github.com/ossy-se/packages/issues/4)) ([afce7d5](https://github.com/ossy-se/packages/commit/afce7d5787af42691f62c9eba672ea1be000e19e))
36
-
37
-
38
-
39
-
40
-
41
- ## 0.0.16 (2025-10-30)
42
-
43
- **Note:** Version bump only for package @ossy/sdk
44
-
45
-
46
-
47
-
48
-
49
- ## 0.0.15 (2025-10-27)
50
-
51
- **Note:** Version bump only for package @ossy/sdk
52
-
53
-
54
-
55
-
56
-
57
- ## 0.0.14 (2025-10-27)
58
-
59
- **Note:** Version bump only for package @ossy/sdk
60
-
61
-
62
-
63
-
64
-
65
- ## 0.0.13 (2025-10-27)
66
-
67
- **Note:** Version bump only for package @ossy/sdk
68
-
69
-
70
-
71
-
72
-
73
- ## 0.0.12 (2025-10-27)
74
-
75
- **Note:** Version bump only for package @ossy/sdk
76
-
77
-
78
-
79
-
80
-
81
- ## 0.0.11 (2025-10-27)
82
-
83
- **Note:** Version bump only for package @ossy/sdk
84
-
85
-
86
-
87
-
88
-
89
- ## 0.0.10 (2025-10-25)
90
-
91
- **Note:** Version bump only for package @ossy/sdk
92
-
93
-
94
-
95
-
96
-
97
- ## 0.0.9 (2025-10-25)
98
-
99
- **Note:** Version bump only for package @ossy/sdk
100
-
101
-
102
-
103
-
104
-
105
- ## 0.0.8 (2025-10-25)
106
-
107
- **Note:** Version bump only for package @ossy/sdk
108
-
109
-
110
-
111
-
112
-
113
- ## 0.0.7 (2025-10-25)
114
-
115
- **Note:** Version bump only for package @ossy/sdk
116
-
117
-
118
-
119
-
120
-
121
- ## 0.0.6 (2025-10-25)
122
-
123
- **Note:** Version bump only for package @ossy/sdk
124
-
125
-
126
-
127
-
128
-
129
- ## 0.0.5 (2025-10-25)
130
-
131
- **Note:** Version bump only for package @ossy/sdk
132
-
133
-
134
-
135
-
136
-
137
- ## 0.0.4 (2025-10-25)
138
-
139
- **Note:** Version bump only for package @ossy/sdk
140
-
141
-
142
-
143
-
144
-
145
- ## 0.0.3 (2025-10-25)
146
-
147
- **Note:** Version bump only for package @ossy/sdk
148
-
149
-
150
-
151
-
152
-
153
- ## 0.0.2 (2025-10-25)
154
-
155
- **Note:** Version bump only for package @ossy/sdk
package/rollup.config.js DELETED
@@ -1,38 +0,0 @@
1
- import typescript from '@rollup/plugin-typescript'
2
- import { nodeResolve as resolveDependencies } from '@rollup/plugin-node-resolve'
3
- import resolveCommonJsDependencies from '@rollup/plugin-commonjs'
4
- import removeOwnPeerDependencies from 'rollup-plugin-peer-deps-external'
5
- import minifyJS from '@rollup/plugin-terser'
6
- import pkg from './package.json' with { type: 'json' };
7
- import { dts } from "rollup-plugin-dts"
8
-
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
- ]
package/src/Actions.ts DELETED
@@ -1,243 +0,0 @@
1
- import { SDKConfig } from "./config";
2
-
3
- export interface Action<Payload extends (Record<string, string | boolean | number> & SDKConfig) | undefined = {}> {
4
- id: string;
5
- endpoint: string;
6
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
7
- payload?: Payload
8
- }
9
-
10
- export const ApiTokenGetAll: Action = {
11
- id: 'api-tokens.get-all',
12
- endpoint: '/users/me/tokens',
13
- method: 'GET'
14
- }
15
-
16
- export const ApiTokenCreate: Action<{
17
- name: string,
18
- description: string,
19
- expiresAt: string;
20
- }> = {
21
- id: 'api-tokens.create',
22
- endpoint: '/users/me/tokens',
23
- method: 'POST'
24
- }
25
-
26
- export const ApiTokenInvalidate: Action<{ id: string }> = {
27
- id: 'api-tokens.invalidate',
28
- endpoint: '/users/me/tokens/:id',
29
- method: 'DELETE'
30
- }
31
-
32
- // WorkspacesClient actions
33
- export const WorkspacesList: Action = {
34
- id: 'workspaces.get-all',
35
- endpoint: '/workspaces',
36
- method: 'GET'
37
- }
38
-
39
- export const WorkspacesGetCurrent: Action = {
40
- id: 'workspaces.get-current',
41
- endpoint: '/workspaces/current',
42
- method: 'GET'
43
- }
44
-
45
- export const WorkspacesGet: Action<{ id: string }> = {
46
- id: 'workspaces.get',
47
- endpoint: '/workspaces/:id',
48
- method: 'GET'
49
- }
50
-
51
- export const WorkspacesCreate: Action<{ name: string }> = {
52
- id: 'workspaces.create',
53
- endpoint: '/workspaces',
54
- method: 'POST'
55
- }
56
-
57
- export const WorkspacesImportResourceTemplates: Action<{ templates: any }> = {
58
- id: 'workspaces.import-resource-templates',
59
- endpoint: '/resource-templates',
60
- method: 'POST'
61
- }
62
-
63
- export const WorkspacesGetResourceTemplates: Action = {
64
- id: 'workspaces.get-resource-templates',
65
- endpoint: '/resource-templates',
66
- method: 'GET'
67
- }
68
-
69
- export const WorkspacesCreateApiToken: Action<{ description: string }> = {
70
- id: 'workspaces.create-api-token',
71
- endpoint: '/tokens',
72
- method: 'POST'
73
- }
74
-
75
- export const WorkspacesGetApiTokens: Action = {
76
- id: 'workspaces.get-api-tokens',
77
- endpoint: '/tokens',
78
- method: 'GET'
79
- }
80
-
81
- export const WorkspacesInviteUser: Action<{ email: string }> = {
82
- id: 'workspaces.invite-user',
83
- endpoint: '/invitations',
84
- method: 'POST'
85
- }
86
-
87
- export const WorkspacesEnableService: Action<{ service: any }> = {
88
- id: 'workspaces.enable-service',
89
- endpoint: '/services/enable',
90
- method: 'POST'
91
- }
92
-
93
- export const WorkspacesDisableService: Action<{ service: any }> = {
94
- id: 'workspaces.disable-service',
95
- endpoint: '/services/disable',
96
- method: 'POST'
97
- }
98
-
99
- export const WorkspacesGetUsers: Action = {
100
- id: 'workspaces.get-users',
101
- endpoint: '/users',
102
- method: 'GET'
103
- }
104
-
105
- // UserClient actions
106
- export const UserCurrentGet: Action = {
107
- id: 'user.get',
108
- endpoint: '/users/me',
109
- method: 'GET'
110
- }
111
-
112
- export const UserCurrentGetHistory: Action = {
113
- id: 'user.get-history',
114
- endpoint: '/users/me/history',
115
- method: 'GET'
116
- }
117
-
118
- export const UserCurrentUpdate: Action<{ user: any }> = {
119
- id: 'user.update',
120
- endpoint: '/users/me',
121
- method: 'PUT'
122
- }
123
-
124
- // ResourcesClient actions
125
- export const ResourcesCreateDirectory: Action<{ type?: 'directory', location: string, name: string }> = {
126
- id: 'resources.create-directory',
127
- endpoint: '/resources',
128
- method: 'POST',
129
- //@ts-ignore
130
- payload: {
131
- type: 'directory'
132
- }
133
- }
134
-
135
- export const ResourcesCreate: Action<{ type: string, location: string, name: string, content?: any }> = {
136
- id: 'resources.create',
137
- endpoint: '/resources',
138
- method: 'POST'
139
- }
140
-
141
- export const ResourcesUpload: Action<{ location: string, type: string, name: string, size: number }> = {
142
- id: 'resources.upload',
143
- endpoint: '/resources',
144
- method: 'POST'
145
- }
146
-
147
- // This is for uploading different sizes of images etc.
148
- export const ResourcesUploadNamedVersion: Action<{ id: string, name: string, size: number }> = {
149
- id: 'resources.upload-named-version',
150
- endpoint: '/resources/:id/:name',
151
- method: 'PUT'
152
- }
153
-
154
- export const ResourcesGet: Action<{ id: string }> = {
155
- id: 'resources.get',
156
- endpoint: '/resources/:id',
157
- method: 'GET',
158
- }
159
-
160
- export const ResourcesList: Action<{ search?: string }> = {
161
- id: 'resources.list',
162
- endpoint: '/resources?:search',
163
- method: 'GET',
164
- }
165
-
166
- export const ResourcesSearch: Action<{ query: any }> = {
167
- id: 'resources.search',
168
- endpoint: '/resources/search',
169
- method: 'POST'
170
- }
171
-
172
- export const ResourcesRemove: Action<{ id: string }> = {
173
- id: 'resources.remove',
174
- endpoint: '/resources/:id',
175
- method: 'DELETE'
176
- }
177
-
178
- export const ResourcesUpdateContent: Action<{ id: string, content: any }> = {
179
- id: 'resources.update-content',
180
- endpoint: '/resources/:id/content',
181
- method: 'PUT'
182
- }
183
-
184
- export const ResourcesMove: Action<{ id: string, target: string }> = {
185
- id: 'resources.move',
186
- endpoint: '/resources/:id/location',
187
- method: 'PUT'
188
- }
189
-
190
- export const ResourcesRename: Action<{ id: string, name: string }> = {
191
- id: 'resources.rename',
192
- endpoint: '/resources/:id/name',
193
- method: 'PUT'
194
- }
195
-
196
- // AuthClient actions
197
- export const AuthSignUp: Action<{ email: string }> = {
198
- id: 'auth.sign-up',
199
- endpoint: '/users/sign-up',
200
- method: 'POST'
201
- }
202
-
203
- export const AuthSignIn: Action<{ email: string }> = {
204
- id: 'auth.sign-in',
205
- endpoint: '/users/sign-in',
206
- method: 'POST'
207
- }
208
-
209
- export const AuthVerifySignIn: Action<{ token: string }> = {
210
- id: 'auth.verify-sign-in',
211
- endpoint: '/users/verify-sign-in?token=:token',
212
- method: 'GET'
213
- }
214
-
215
- export const AuthVerifyInvitation: Action<{ workspaceId: string, token: string }> = {
216
- id: 'auth.verify-invitation',
217
- endpoint: '/workspaces/:workspaceId/invitations?token=:token',
218
- method: 'GET'
219
- }
220
-
221
- export const AuthGetAuthenticatedUser: Action = {
222
- id: 'auth.get-authenticated-user',
223
- endpoint: '/users/me',
224
- method: 'GET'
225
- }
226
-
227
- export const AuthGetAuthenticatedUserHistory: Action = {
228
- id: 'auth.get-authenticated-user-history',
229
- endpoint: '/users/me/history',
230
- method: 'GET'
231
- }
232
-
233
- export const AuthGetUser: Action<{ id: string }> = {
234
- id: 'auth.get-user',
235
- endpoint: '/users/:id',
236
- method: 'GET'
237
- }
238
-
239
- export const AuthSignOff: Action = {
240
- id: 'auth.sign-off',
241
- endpoint: '/users/sign-off',
242
- method: 'GET'
243
- }
package/src/config.ts DELETED
@@ -1,5 +0,0 @@
1
- export interface SDKConfig {
2
- apiUrl?: string;
3
- workspaceId?: string;
4
- authorization?: string
5
- }
package/src/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './sdk.js'
2
- export { Jobs, JobStatus } from './jobs-client.js'
@@ -1,66 +0,0 @@
1
- export const Jobs = {
2
- VisualContentDescriptors: '@ossy/jobs/visual-content-descriptors',
3
- ResizeCommonWeb: '@ossy/jobs/resize-common-web',
4
- }
5
-
6
- export const JobStatus = {
7
- Queued: 'queued',
8
- InProgress: 'in progress',
9
- Success: 'success',
10
- Failed: 'failed',
11
- }
12
-
13
- export class JobsClient {
14
- static location = '/@ossy/jobs/'
15
-
16
- static of(config) {
17
- return new JobsClient(config)
18
- }
19
-
20
- constructor(config) {
21
- this.http = config?.http
22
- this.resources = config?.resources
23
- }
24
-
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
- })
46
- }
47
-
48
- create({ type, resourceId }) {
49
- const jobTypeExists = Object.values(Jobs).includes(type)
50
- if (!jobTypeExists) throw new Error(`Job type ${type} does not exist`)
51
- if (!resourceId) throw new Error(`Resource ID is required`)
52
- return this.resources.create({
53
- type,
54
- location: JobsClient.location,
55
- name: `[${JobStatus.Queued}] ${resourceId}`,
56
- content: {
57
- resourceId,
58
- status: JobStatus.Queued,
59
- result: undefined
60
- }
61
- })
62
- }
63
-
64
-
65
- }
66
-
@@ -1,2 +0,0 @@
1
- export * from './sdk.js'
2
- export { Jobs, JobStatus } from './jobs-client.js'
package/src/sdk.ts DELETED
@@ -1,210 +0,0 @@
1
- import {
2
- Action,
3
- ApiTokenCreate,
4
- ApiTokenGetAll,
5
- ApiTokenInvalidate,
6
- WorkspacesList,
7
- WorkspacesCreate,
8
- WorkspacesImportResourceTemplates,
9
- WorkspacesGetResourceTemplates,
10
- WorkspacesCreateApiToken,
11
- WorkspacesGetApiTokens,
12
- WorkspacesInviteUser,
13
- WorkspacesEnableService,
14
- WorkspacesDisableService,
15
- WorkspacesGetUsers,
16
- ResourcesCreateDirectory,
17
- ResourcesCreate,
18
- ResourcesUpload,
19
- ResourcesUploadNamedVersion,
20
- ResourcesGet,
21
- ResourcesList,
22
- ResourcesSearch,
23
- ResourcesRemove,
24
- ResourcesUpdateContent,
25
- ResourcesMove,
26
- ResourcesRename,
27
- AuthSignUp,
28
- AuthSignIn,
29
- AuthVerifySignIn,
30
- AuthVerifyInvitation,
31
- AuthGetAuthenticatedUser,
32
- AuthGetAuthenticatedUserHistory,
33
- AuthGetUser,
34
- AuthSignOff,
35
- WorkspacesGet,
36
- WorkspacesGetCurrent,
37
- UserCurrentGet,
38
- UserCurrentGetHistory,
39
- UserCurrentUpdate
40
- } from './Actions';
41
- import { SDKConfig } from './config'
42
-
43
- export class SDK {
44
-
45
- workspaceId?: string;
46
- authorization?: string;
47
- baseUrl = 'https://api.ossy.se/api/v0'
48
-
49
- static of(config: SDKConfig) {
50
- return new SDK(config)
51
- }
52
-
53
- constructor(config: SDKConfig) {
54
- this.updateConfig(config)
55
- }
56
-
57
- updateConfig(intendedConfig: SDKConfig) {
58
- this.baseUrl = intendedConfig.apiUrl || this.baseUrl
59
- this.workspaceId = intendedConfig.workspaceId || this.workspaceId
60
- this.authorization = intendedConfig.authorization || this.authorization
61
- }
62
-
63
- get apiTokens() {
64
- return {
65
- list: this.makeRequest(ApiTokenGetAll).bind(this),
66
- create: this.makeRequest(ApiTokenCreate).bind(this),
67
- invalidate: this.makeRequest(ApiTokenInvalidate).bind(this)
68
- }
69
- }
70
-
71
- get workspaces() {
72
- return {
73
- current: this.makeRequest(WorkspacesGetCurrent).bind(this),
74
- list: this.makeRequest(WorkspacesList).bind(this),
75
- get: this.makeRequest(WorkspacesGet).bind(this),
76
- create: this.makeRequest(WorkspacesCreate).bind(this),
77
- importResourceTemplates: this.makeRequest(WorkspacesImportResourceTemplates).bind(this),
78
- getResourceTemplates: this.makeRequest(WorkspacesGetResourceTemplates).bind(this),
79
- createApiToken: this.makeRequest(WorkspacesCreateApiToken).bind(this),
80
- getApiTokens: this.makeRequest(WorkspacesGetApiTokens).bind(this),
81
- inviteUser: this.makeRequest(WorkspacesInviteUser).bind(this),
82
- enableService: this.makeRequest(WorkspacesEnableService).bind(this),
83
- disableService: this.makeRequest(WorkspacesDisableService).bind(this),
84
- };
85
- }
86
-
87
- get users () {
88
- return {
89
- list: this.makeRequest(WorkspacesGetUsers).bind(this),
90
- }
91
- }
92
-
93
- get currentUser () {
94
- return {
95
- get: this.makeRequest(UserCurrentGet).bind(this),
96
- update: this.makeRequest(UserCurrentUpdate).bind(this),
97
- history: this.makeRequest(UserCurrentGetHistory).bind(this),
98
- }
99
- }
100
-
101
- get resources() {
102
- return {
103
- createDirectory: this.makeRequest(ResourcesCreateDirectory).bind(this),
104
- create: this.makeRequest(ResourcesCreate).bind(this),
105
- upload: ({ location = '/', file }: { location: string; file: File} ) => {
106
- const payload = {
107
- type: file.type,
108
- location: location,
109
- name: file.name,
110
- size: file.size
111
- }
112
- return this.makeRequest(ResourcesUpload)(payload)
113
- .then(resource => {
114
- return fetch(resource.content.uploadUrl, { method: 'PUT', body: file })
115
- .then(() => resource)
116
- })
117
- },
118
- uploadNamedVersion: ({ id, name, file }: { id: string, name: string, file: File }) => {
119
- const payload = {
120
- id: id,
121
- name: name,
122
- size: file.size
123
- }
124
- this.makeRequest(ResourcesUploadNamedVersion)(payload)
125
- .then(resource => {
126
- return fetch(resource.content.uploadUrl, { method: 'PUT', body: file })
127
- .then(() => resource)
128
- })
129
- },
130
- get: this.makeRequest(ResourcesGet).bind(this),
131
- list: (query: ({ location?: string; })) => {
132
- const search = new URLSearchParams({ ...query }).toString()
133
- return this.makeRequest(ResourcesList)({ search })
134
- },
135
- search: this.makeRequest(ResourcesSearch).bind(this),
136
- remove: this.makeRequest(ResourcesRemove).bind(this),
137
- updateContent: this.makeRequest(ResourcesUpdateContent).bind(this),
138
- move: this.makeRequest(ResourcesMove).bind(this),
139
- rename: this.makeRequest(ResourcesRename).bind(this),
140
- };
141
- }
142
-
143
- get auth() {
144
- return {
145
- signUp: this.makeRequest(AuthSignUp).bind(this),
146
- signIn: this.makeRequest(AuthSignIn).bind(this),
147
- verifySignIn: this.makeRequest(AuthVerifySignIn).bind(this),
148
- verifyInvitation: this.makeRequest(AuthVerifyInvitation).bind(this),
149
- getAuthenticatedUser: this.makeRequest(AuthGetAuthenticatedUser).bind(this),
150
- getAuthenticatedUserHistory: this.makeRequest(AuthGetAuthenticatedUserHistory).bind(this),
151
- getUser: this.makeRequest(AuthGetUser).bind(this),
152
- signOff: this.makeRequest(AuthSignOff).bind(this),
153
- };
154
- }
155
-
156
- makeRequest = <T extends Action>(action: T) => {
157
- return (_payload?: Required<T['payload']>) => {
158
-
159
- let payload: Required<T['payload']> = {} as Required<T['payload']>;
160
-
161
- if (!!_payload || action.payload) {
162
- payload = {
163
- ...(action.payload || {} as Required<T['payload']>),
164
- ...(_payload || {} as Required<T['payload']>)
165
- }
166
- }
167
-
168
- let baseUrl: string = 'apiUrl' in payload ? payload?.apiUrl as string : this.baseUrl
169
- let workspaceId = 'workspaceId' in payload ? payload.workspaceId : this.workspaceId;
170
- let authorization = 'authorization' in payload ? payload.authorization : this.authorization;
171
- let body: string | undefined = undefined;
172
- let endpoint = action.endpoint;
173
-
174
- if (payload) {
175
- body = JSON.stringify(payload);
176
-
177
- const paramNames = (action.endpoint.match(/:([a-zA-Z0-9_]+)/g) || []).map(
178
- param => param.slice(1) as keyof T['payload']
179
- );
180
-
181
- endpoint = paramNames.reduce(
182
- (endpoint, paramName) => endpoint.replace(String(paramName), String(payload[paramName])),
183
- action.endpoint
184
- )
185
- }
186
-
187
- return fetch(`${baseUrl}${endpoint}`, {
188
- credentials: 'include',
189
- headers: {
190
- 'Content-Type': 'application/json',
191
- workspaceId: workspaceId as string,
192
- Authorization: authorization as string
193
-
194
- },
195
- method: action.method,
196
- body
197
- }).then(response => {
198
- const contentType = response.headers.get('Content-Type') || ''
199
- const status = response.status
200
- const okResponseCodes = [200, 204]
201
- if (status === 400) return response.json().then(content => Promise.reject(content.error))
202
- if (!okResponseCodes.includes(status)) return Promise.reject(response)
203
- if (contentType.includes('application/json')) return response.json()
204
- return response
205
- })
206
- }
207
- }
208
-
209
- }
210
-
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
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
- }