monday-sdk-js 0.4.1 → 0.4.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.4.1",
3
+ "version": "0.4.3",
4
4
  "private": false,
5
5
  "repository": "https://github.com/mondaycom/monday-sdk-js",
6
6
  "main": "src/index.js",
package/src/constants.js CHANGED
@@ -1,12 +1,18 @@
1
1
  const { isBrowser } = require("./helpers");
2
2
 
3
3
  const isNodeDevEnv = !isBrowser && process.env.NODE_ENV === "development";
4
+ const getEnvOrDefault = (key, defaultVal) => {
5
+ return isNodeDevEnv && typeof process.env[key] !== "undefined" ? process.env[key] : defaultVal;
6
+ };
7
+
8
+ const MONDAY_PROTOCOL = getEnvOrDefault("MONDAY_COM_PROTOCOL", "https");
9
+ const MONDAY_DOMAIN = getEnvOrDefault("MONDAY_COM_DOMAIN", "monday.com");
10
+ const MONDAY_SUBDOMAIN_API = getEnvOrDefault("MONDAY_SUBDOMAIN_API", "api.");
11
+ const MONDAY_OAUTH_SUBDOMAIN = getEnvOrDefault(MONDAY_SUBDOMAIN_API, "auth.");
4
12
 
5
- const MONDAY_PROTOCOL = (isNodeDevEnv && process.env.MONDAY_COM_PROTOCOL) || "https";
6
- const MONDAY_DOMAIN = (isNodeDevEnv && process.env.MONDAY_COM_DOMAIN) || "monday.com";
7
- const MONDAY_API_URL = `${MONDAY_PROTOCOL}://api.${MONDAY_DOMAIN}/v2`;
8
- const MONDAY_OAUTH_URL = `${MONDAY_PROTOCOL}://auth.${MONDAY_DOMAIN}/oauth2/authorize`;
9
- const MONDAY_OAUTH_TOKEN_URL = `${MONDAY_PROTOCOL}://auth.${MONDAY_DOMAIN}/oauth2/token`;
13
+ const MONDAY_API_URL = `${MONDAY_PROTOCOL}://${MONDAY_SUBDOMAIN_API}${MONDAY_DOMAIN}/v2`;
14
+ const MONDAY_OAUTH_URL = `${MONDAY_PROTOCOL}://${MONDAY_OAUTH_SUBDOMAIN}${MONDAY_DOMAIN}/oauth2/authorize`;
15
+ const MONDAY_OAUTH_TOKEN_URL = `${MONDAY_PROTOCOL}://${MONDAY_OAUTH_SUBDOMAIN}${MONDAY_DOMAIN}/oauth2/token`;
10
16
 
11
17
  module.exports = {
12
18
  MONDAY_DOMAIN,
@@ -1,4 +1,4 @@
1
- interface APIOptions {
1
+ export interface APIOptions {
2
2
  /**
3
3
  * Access token for the API
4
4
  * If not set, will use the credentials of the current user (client only)
@@ -12,9 +12,9 @@ interface APIOptions {
12
12
 
13
13
  /**
14
14
  * A string specifying which version of the API should be used
15
- * If not set, will use the default version (stable)
15
+ * If not set, will use the current API version
16
16
  */
17
- apiVersion?: string;
17
+ apiVersion?: string | undefined;
18
18
  }
19
19
 
20
20
  interface OAuthOptions {
@@ -46,6 +46,12 @@ export interface ClientApi {
46
46
  */
47
47
  setToken(token: string): void;
48
48
 
49
+ /**
50
+ * Allows to set the API version for future requests.
51
+ * @param version A string specifying which version of the API should be used
52
+ */
53
+ setApiVersion(version: string): void;
54
+
49
55
  /**
50
56
  * Performs a client-side redirection of the user to the monday OAuth screen with your client ID embedded in the URL,
51
57
  * sin order to get their approval to generate a temporary OAuth token based on your requested permission scopes.
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Original Definitions were contributed by: Josh Parnham <https://github.com/josh->
2
2
  import { ClientData } from './client-data.interface';
3
3
  import { ClientExecute } from './client-execute.interface';
4
- import { ClientApi } from './client-api.interface';
4
+ import { ClientApi, APIOptions } from './client-api.interface';
5
5
 
6
6
  export as namespace mondaySdk;
7
7
 
@@ -10,7 +10,9 @@ type MondayClientSdk = ClientData & ClientExecute & ClientApi;
10
10
  interface MondayServerSdk {
11
11
  setToken(token: string): void;
12
12
 
13
- api(query: string, options?: Partial<{ token: string, variables: object, apiVersion: string } >): Promise<any>;
13
+ setApiVersion(version: string): void;
14
+
15
+ api(query: string, options?: APIOptions): Promise<any>;
14
16
 
15
17
  oauthToken(code: string, clientId: string, clientSecret: string): Promise<any>;
16
18
  }
@@ -19,12 +21,14 @@ declare function init(
19
21
  config?: Partial<{
20
22
  clientId: string;
21
23
  apiToken: string;
24
+ apiVersion: string;
22
25
  }>,
23
26
  ): MondayClientSdk;
24
27
 
25
28
  declare function init(
26
29
  config?: Partial<{
27
30
  token: string;
31
+ apiVersion: string;
28
32
  }>,
29
33
  ): MondayServerSdk;
30
34