From f1c6437e03d143e217737cb862df6241f0929ec1 Mon Sep 17 00:00:00 2001 From: rami-monday Date: Wed, 7 Feb 2024 11:57:28 +0200 Subject: [PATCH 1/4] fix the response type of filter and location types --- package.json | 2 +- ts-tests/monday-sdk-js-module.test.ts | 30 ++++++++++++++++++++++++++- types/client-data.interface.ts | 20 ++++++++++++++++++ types/index.d.ts | 22 ++++++++++---------- 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 296300f3..483479d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monday-sdk-js", - "version": "0.5.3", + "version": "0.5.4", "private": false, "repository": "https://github.com/mondaycom/monday-sdk-js", "main": "src/index.js", diff --git a/ts-tests/monday-sdk-js-module.test.ts b/ts-tests/monday-sdk-js-module.test.ts index 23b66b23..193b73c5 100644 --- a/ts-tests/monday-sdk-js-module.test.ts +++ b/ts-tests/monday-sdk-js-module.test.ts @@ -10,7 +10,7 @@ monday.api("test", { apiVersion: "2023-07" }); monday.setToken("test"); monday.get("context", { appFeatureType: "AppFeatureBoardView" }).then(res => { - const { data }: { data: { app: { id: number }; theme: string; boardId: number; viewMode: string } } = res; + const boardId: number = res.data.boardId; }); monday.get<{ text: string; level: number }>("settings").then(res => { @@ -25,6 +25,34 @@ monday.get("sessionToken").then(res => { const { data }: { data: string } = res; }); +monday.get("location").then(res => { + const { + data + }: { + data: { + href: string; + search: string; + }; + } = res; +}); + +monday.get("filter").then(res => { + const { + data + }: { + data: { + term: string; + rules: { + column_id: string; + compare_value: string[]; + compare_attribute: string; + operator: string; + }[]; + operator: string; + }; + } = res; +}); + monday.set("settings", { text: "this is a test", number: 23 }); monday.listen( diff --git a/types/client-data.interface.ts b/types/client-data.interface.ts index c94e96a5..fd3f22b5 100644 --- a/types/client-data.interface.ts +++ b/types/client-data.interface.ts @@ -1,10 +1,28 @@ import { AppFeatureContextMap, AppFeatureTypes } from "./client-context.type"; +export type LocationResponse = Record & { + href: string; + search: string; +}; + +export type FilterResponse = Record & { + term: string; + rules: { + column_id: string; + compare_value: string[]; + compare_attribute: string; + operator: string; + }[]; + operator: string; +}; + type SubscribableEventsResponse = { context: AppFeatureContextMap[AppFeatureType]; settings: Record; itemIds: number[]; events: Record; + location: LocationResponse; + filter: FilterResponse; }; type SubscribableEvents = keyof SubscribableEventsResponse; @@ -54,6 +72,8 @@ export type GetterResponse; itemIds: number[]; sessionToken: string; + location: LocationResponse; + filter: FilterResponse; }; export interface ClientData { /** diff --git a/types/index.d.ts b/types/index.d.ts index 6fc16a3a..51c44d73 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,22 +1,22 @@ // Original Definitions were contributed by: Josh Parnham -import { MondayClientSdk } from './client-sdk.interface'; -import { MondayServerSdk } from './server-sdk.interface'; +import { MondayClientSdk } from "./client-sdk.interface"; +import { MondayServerSdk } from "./server-sdk.interface"; export as namespace mondaySdk; declare function init( - config?: Partial<{ - clientId: string; - apiToken: string; - apiVersion: string; - }>, + config?: Partial<{ + clientId: string; + apiToken: string; + apiVersion: string; + }> ): MondayClientSdk; declare function init( - config?: Partial<{ - token: string; - apiVersion: string; - }>, + config?: Partial<{ + token: string; + apiVersion: string; + }> ): MondayServerSdk; export = init; From 98b6f0e161c1e83c6e77e4d171e629d77d1e7717 Mon Sep 17 00:00:00 2001 From: rami-monday Date: Wed, 7 Feb 2024 12:00:28 +0200 Subject: [PATCH 2/4] revert unnecessary changes --- ts-tests/monday-sdk-js-module.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts-tests/monday-sdk-js-module.test.ts b/ts-tests/monday-sdk-js-module.test.ts index 193b73c5..021392e6 100644 --- a/ts-tests/monday-sdk-js-module.test.ts +++ b/ts-tests/monday-sdk-js-module.test.ts @@ -10,7 +10,7 @@ monday.api("test", { apiVersion: "2023-07" }); monday.setToken("test"); monday.get("context", { appFeatureType: "AppFeatureBoardView" }).then(res => { - const boardId: number = res.data.boardId; + const { data }: { data: { app: { id: number }; theme: string; boardId: number; viewMode: string } } = res; }); monday.get<{ text: string; level: number }>("settings").then(res => { From f042395504f30c72dc9ac136115321157576b019 Mon Sep 17 00:00:00 2001 From: rami-monday Date: Wed, 7 Feb 2024 12:08:27 +0200 Subject: [PATCH 3/4] optional params --- types/client-data.interface.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/client-data.interface.ts b/types/client-data.interface.ts index fd3f22b5..f48c085b 100644 --- a/types/client-data.interface.ts +++ b/types/client-data.interface.ts @@ -7,13 +7,13 @@ export type LocationResponse = Record & { export type FilterResponse = Record & { term: string; - rules: { - column_id: string; - compare_value: string[]; - compare_attribute: string; - operator: string; - }[]; - operator: string; + rules: (Record & { + column_id?: string; + compare_value?: string[]; + compare_attribute?: string; + operator?: string; + })[]; + operator: string | null; }; type SubscribableEventsResponse = { From 80bd929add1c5cd6d94778d4778f7ffd5308ff2d Mon Sep 17 00:00:00 2001 From: rami-monday Date: Wed, 7 Feb 2024 12:09:38 +0200 Subject: [PATCH 4/4] fix test type --- ts-tests/monday-sdk-js-module.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ts-tests/monday-sdk-js-module.test.ts b/ts-tests/monday-sdk-js-module.test.ts index 021392e6..27edbd1c 100644 --- a/ts-tests/monday-sdk-js-module.test.ts +++ b/ts-tests/monday-sdk-js-module.test.ts @@ -42,13 +42,13 @@ monday.get("filter").then(res => { }: { data: { term: string; - rules: { - column_id: string; - compare_value: string[]; - compare_attribute: string; - operator: string; - }[]; - operator: string; + rules: (Record & { + column_id?: string; + compare_value?: string[]; + compare_attribute?: string; + operator?: string; + })[]; + operator: string | null; }; } = res; });