monday-sdk-js 0.4.9 → 0.4.11

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.9",
3
+ "version": "0.4.11",
4
4
  "private": false,
5
5
  "repository": "https://github.com/mondaycom/monday-sdk-js",
6
6
  "main": "src/index.js",
@@ -5,6 +5,7 @@ describe("constants", () => {
5
5
  //setup
6
6
  beforeEach(() => {
7
7
  process.env.NODE_ENV = "development";
8
+ process.env.MONDAY_DOMAIN = undefined;
8
9
  process.env.MONDAY_COM_PROTOCOL = undefined;
9
10
  process.env.MONDAY_COM_DOMAIN = undefined;
10
11
  process.env.MONDAY_SUBDOMAIN_API = undefined;
@@ -35,44 +36,79 @@ describe("constants", () => {
35
36
  expect(constants.MONDAY_OAUTH_TOKEN_URL).to.eq(MONDAY_OAUTH_TOKEN_URL);
36
37
  });
37
38
 
38
- it("constants should be correct", () => {
39
- const keys = Object.keys(constants);
40
- let key;
41
- let value;
42
- for (let i = 0; i < keys.length; i++) {
43
- key = keys[i];
44
- value = constants[key];
45
-
46
- switch (key) {
47
- case "MONDAY_DOMAIN": {
48
- expect(value).to.eq("monday.com");
49
- break;
50
- }
51
-
52
- case "MONDAY_PROTOCOL": {
53
- expect(value).to.eq("https");
54
- break;
55
- }
56
-
57
- case "MONDAY_API_URL": {
58
- expect(value).to.eq("https://api.monday.com/v2");
59
- break;
60
- }
61
-
62
- case "MONDAY_OAUTH_URL": {
63
- expect(value).to.eq("https://auth.monday.com/oauth2/authorize");
64
- break;
65
- }
66
-
67
- case "MONDAY_OAUTH_TOKEN_URL": {
68
- expect(value).to.eq("https://auth.monday.com/oauth2/token");
69
- break;
70
- }
71
-
72
- default: {
73
- throw new Error(`missing test for this constant: ${key}`);
74
- }
75
- }
76
- }
39
+ describe("check that constants are correct when NODE_ENV is development", () => {
40
+ it("MONDAY_DOMAIN should be correct", () => {
41
+ expect(constants.MONDAY_DOMAIN).to.eq("monday.com");
42
+ });
43
+
44
+ it("MONDAY_PROTOCOL should be correct", () => {
45
+ expect(constants.MONDAY_PROTOCOL).to.eq("https");
46
+ });
47
+
48
+ it("MONDAY_API_URL should be correct", () => {
49
+ expect(constants.MONDAY_API_URL).to.eq("https://api.monday.com/v2");
50
+ });
51
+
52
+ it("MONDAY_OAUTH_URL should be correct", () => {
53
+ expect(constants.MONDAY_OAUTH_URL).to.eq("https://auth.monday.com/oauth2/authorize");
54
+ });
55
+
56
+ it("MONDAY_OAUTH_TOKEN_URL should be correct", () => {
57
+ expect(constants.MONDAY_OAUTH_TOKEN_URL).to.eq("https://auth.monday.com/oauth2/token");
58
+ });
59
+ });
60
+
61
+ describe("check that constants are correct when NODE_ENV is undefined", () => {
62
+ beforeEach(() => {
63
+ process.env.NODE_ENV = undefined;
64
+ process.env.MONDAY_COM_DOMAIN = "should not be used";
65
+ });
66
+
67
+ it("MONDAY_DOMAIN should be correct", () => {
68
+ expect(constants.MONDAY_DOMAIN).to.eq("monday.com");
69
+ });
70
+
71
+ it("MONDAY_PROTOCOL should be correct", () => {
72
+ expect(constants.MONDAY_PROTOCOL).to.eq("https");
73
+ });
74
+
75
+ it("MONDAY_API_URL should be correct", () => {
76
+ expect(constants.MONDAY_API_URL).to.eq("https://api.monday.com/v2");
77
+ });
78
+
79
+ it("MONDAY_OAUTH_URL should be correct", () => {
80
+ expect(constants.MONDAY_OAUTH_URL).to.eq("https://auth.monday.com/oauth2/authorize");
81
+ });
82
+
83
+ it("MONDAY_OAUTH_TOKEN_URL should be correct", () => {
84
+ expect(constants.MONDAY_OAUTH_TOKEN_URL).to.eq("https://auth.monday.com/oauth2/token");
85
+ });
86
+ });
87
+
88
+ describe("check that constants are correct when NODE_ENV is undefined", () => {
89
+ beforeEach(() => {
90
+ process.env.NODE_ENV = "production";
91
+ process.env.MONDAY_COM_DOMAIN = "should not be used";
92
+ });
93
+
94
+ it("MONDAY_DOMAIN should be correct", () => {
95
+ expect(constants.MONDAY_DOMAIN).to.eq("monday.com");
96
+ });
97
+
98
+ it("MONDAY_PROTOCOL should be correct", () => {
99
+ expect(constants.MONDAY_PROTOCOL).to.eq("https");
100
+ });
101
+
102
+ it("MONDAY_API_URL should be correct", () => {
103
+ expect(constants.MONDAY_API_URL).to.eq("https://api.monday.com/v2");
104
+ });
105
+
106
+ it("MONDAY_OAUTH_URL should be correct", () => {
107
+ expect(constants.MONDAY_OAUTH_URL).to.eq("https://auth.monday.com/oauth2/authorize");
108
+ });
109
+
110
+ it("MONDAY_OAUTH_TOKEN_URL should be correct", () => {
111
+ expect(constants.MONDAY_OAUTH_TOKEN_URL).to.eq("https://auth.monday.com/oauth2/token");
112
+ });
77
113
  });
78
114
  });
package/src/constants.js CHANGED
@@ -7,7 +7,9 @@ function isNodeDevStageEnv() {
7
7
  }
8
8
 
9
9
  const getEnvOrDefault = (key, defaultVal) => {
10
- return isNodeDevStageEnv() && process.env[key] !== "undefined" ? process.env[key] : defaultVal;
10
+ return isNodeDevStageEnv() && process.env[key] !== "undefined" && process.env[key] !== undefined
11
+ ? process.env[key]
12
+ : defaultVal;
11
13
  };
12
14
 
13
15
  const MONDAY_PROTOCOL = () => getEnvOrDefault("MONDAY_COM_PROTOCOL", "https");
@@ -0,0 +1,5 @@
1
+ import { ClientData } from './client-data.interface';
2
+ import { ClientExecute } from './client-execute.interface';
3
+ import { ClientApi } from './client-api.interface';
4
+
5
+ export type MondayClientSdk = ClientData & ClientExecute & ClientApi;
package/types/index.d.ts CHANGED
@@ -1,22 +1,9 @@
1
1
  // Original Definitions were contributed by: Josh Parnham <https://github.com/josh->
2
- import { ClientData } from './client-data.interface';
3
- import { ClientExecute } from './client-execute.interface';
4
- import { ClientApi, APIOptions } from './client-api.interface';
2
+ import { MondayClientSdk } from './client-sdk.interface';
3
+ import { MondayServerSdk } from './server-sdk.interface';
5
4
 
6
5
  export as namespace mondaySdk;
7
6
 
8
- type MondayClientSdk = ClientData & ClientExecute & ClientApi;
9
-
10
- interface MondayServerSdk {
11
- setToken(token: string): void;
12
-
13
- setApiVersion(version: string): void;
14
-
15
- api(query: string, options?: APIOptions): Promise<any>;
16
-
17
- oauthToken(code: string, clientId: string, clientSecret: string): Promise<any>;
18
- }
19
-
20
7
  declare function init(
21
8
  config?: Partial<{
22
9
  clientId: string;
@@ -0,0 +1,11 @@
1
+ import { APIOptions } from './client-api.interface';
2
+
3
+ export interface MondayServerSdk {
4
+ setToken(token: string): void;
5
+
6
+ setApiVersion(version: string): void;
7
+
8
+ api(query: string, options?: APIOptions): Promise<any>;
9
+
10
+ oauthToken(code: string, clientId: string, clientSecret: string): Promise<any>;
11
+ }