monday-sdk-js 0.5.1 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monday-sdk-js",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "private": false,
5
5
  "repository": "https://github.com/mondaycom/monday-sdk-js",
6
6
  "main": "src/index.js",
@@ -38,7 +38,7 @@ export interface ClientApi {
38
38
  * Placeholders may be used, which will be substituted by the variables object passed within the options.
39
39
  * @param options
40
40
  */
41
- api(query: string, options?: APIOptions): Promise<{ data: object }>;
41
+ api<T = any>(query: string, options?: APIOptions): Promise<{ data: T, account_id: number }>;
42
42
 
43
43
  /**
44
44
  * Instead of passing the API token to the `api()` method on each request, you can set the API token once using:
@@ -58,4 +58,4 @@ export interface ClientApi {
58
58
  * @param object An object with options
59
59
  */
60
60
  oauth(object?: OAuthOptions): void;
61
- }
61
+ }
@@ -32,6 +32,11 @@ type AppVersion = {
32
32
  };
33
33
  };
34
34
 
35
+ export type Permissions = {
36
+ approvedScopes: string[];
37
+ requiredScopes: string[];
38
+ };
39
+
35
40
  export type BaseContext = {
36
41
  themeConfig?: Theme;
37
42
  theme: string;
@@ -40,6 +45,7 @@ export type BaseContext = {
40
45
  region: string;
41
46
  app: App;
42
47
  appVersion: AppVersion;
48
+ permissions: Permissions;
43
49
  };
44
50
 
45
51
  export type AppFeatureBoardViewContext = BaseContext & {
@@ -11,19 +11,21 @@ type SubscribableEvents = keyof SubscribableEventsResponse;
11
11
 
12
12
  type SettableTypes = "settings";
13
13
 
14
- interface GetResponse {
15
- data: {
16
- success: boolean;
17
- value: any;
18
- version?: any;
19
- };
14
+ type StorageResponse = {
15
+ success: boolean;
16
+ value: any;
17
+ version?: any;
18
+ };
19
+
20
+ type Response<T = StorageResponse> = {
21
+ data: T;
20
22
  errorMessage?: string | undefined;
21
23
  method: string;
22
24
  requestId: string;
23
25
  type?: string | undefined;
24
- }
26
+ };
25
27
 
26
- interface DeleteResponse {
28
+ type DeleteResponse = {
27
29
  data: {
28
30
  success: boolean;
29
31
  value: any;
@@ -32,7 +34,7 @@ interface DeleteResponse {
32
34
  method: string;
33
35
  requestId: string;
34
36
  type?: string | undefined;
35
- }
37
+ };
36
38
 
37
39
  interface SetResponse {
38
40
  data: {
@@ -70,8 +72,8 @@ export interface ClientData {
70
72
  AppFeatureType extends AppFeatureTypes = AppFeatureTypes
71
73
  >(
72
74
  type: T,
73
- params?: object & { appFeatureType?: AppFeatureType }
74
- ): Promise<GetterResponse<AppFeatureType>[T] & CustomResponse>;
75
+ params?: Record<string, any> & { appFeatureType?: AppFeatureType }
76
+ ): Promise<Response<GetterResponse<AppFeatureType>[T] & CustomResponse>>;
75
77
 
76
78
  /**
77
79
  * Creates a listener which allows subscribing to certain types of client-side events.
@@ -86,7 +88,7 @@ export interface ClientData {
86
88
  >(
87
89
  typeOrTypes: T | ReadonlyArray<T>,
88
90
  callback: (res: { data: SubscribableEventsResponse<AppFeatureType>[T] & CustomResponse }) => void,
89
- params?: object & { appFeatureType?: AppFeatureType }
91
+ params?: Record<string, any> & { appFeatureType?: AppFeatureType }
90
92
  ): void;
91
93
 
92
94
  /**
@@ -110,7 +112,7 @@ export interface ClientData {
110
112
  * Returns a stored value from the database under `key` for the app (**without any reference to the instance**)
111
113
  * @param {string} key - Used to access to stored data
112
114
  */
113
- getItem(key: string): Promise<GetResponse>;
115
+ getItem(key: string): Promise<Response>;
114
116
 
115
117
  /**
116
118
  * Deletes a stored value from the database under `key` for the app (**without any reference to the instance**)
@@ -135,7 +137,7 @@ export interface ClientData {
135
137
  * Returns a stored value from the database under `key` for a specific app instance
136
138
  * @param key
137
139
  */
138
- getItem(key: string): Promise<GetResponse>;
140
+ getItem(key: string): Promise<Response>;
139
141
 
140
142
  /**
141
143
  * Deletes a stored value from the database under `key` for a specific app instance
@@ -5,7 +5,7 @@ export interface MondayServerSdk {
5
5
 
6
6
  setApiVersion(version: string): void;
7
7
 
8
- api(query: string, options?: APIOptions): Promise<any>;
8
+ api<T = any>(query: string, options?: APIOptions): Promise<T>;
9
9
 
10
10
  oauthToken(code: string, clientId: string, clientSecret: string): Promise<any>;
11
11
  }