Skip to content

Commit

Permalink
fix the response type of filter and location types
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-monday committed Feb 7, 2024
1 parent 42d3208 commit f1c6437
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
30 changes: 29 additions & 1 deletion ts-tests/monday-sdk-js-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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(
Expand Down
20 changes: 20 additions & 0 deletions types/client-data.interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import { AppFeatureContextMap, AppFeatureTypes } from "./client-context.type";

export type LocationResponse = Record<string, any> & {
href: string;
search: string;
};

export type FilterResponse = Record<string, any> & {
term: string;
rules: {
column_id: string;
compare_value: string[];
compare_attribute: string;
operator: string;
}[];
operator: string;
};

type SubscribableEventsResponse<AppFeatureType extends AppFeatureTypes = AppFeatureTypes> = {
context: AppFeatureContextMap[AppFeatureType];
settings: Record<string, any>;
itemIds: number[];
events: Record<string, any>;
location: LocationResponse;
filter: FilterResponse;
};

type SubscribableEvents = keyof SubscribableEventsResponse;
Expand Down Expand Up @@ -54,6 +72,8 @@ export type GetterResponse<AppFeatureType extends AppFeatureTypes = AppFeatureTy
settings: Record<string, any>;
itemIds: number[];
sessionToken: string;
location: LocationResponse;
filter: FilterResponse;
};
export interface ClientData {
/**
Expand Down
22 changes: 11 additions & 11 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Original Definitions were contributed by: Josh Parnham <https://github.com/josh->
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;

0 comments on commit f1c6437

Please sign in to comment.