Skip to content

Commit

Permalink
fix the response type of filter and location types (#140)
Browse files Browse the repository at this point in the history
* fix the response type of filter and location types

* revert unnecessary changes

* optional params

* fix test type
  • Loading branch information
rami-monday authored Feb 7, 2024
1 parent 42d3208 commit 7d08f6f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 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
28 changes: 28 additions & 0 deletions ts-tests/monday-sdk-js-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: (Record<string, any> & {
column_id?: string;
compare_value?: string[];
compare_attribute?: string;
operator?: string;
})[];
operator: string | null;
};
} = 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: (Record<string, any> & {
column_id?: string;
compare_value?: string[];
compare_attribute?: string;
operator?: string;
})[];
operator: string | null;
};

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 7d08f6f

Please sign in to comment.