Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the response type of filter and location types #140

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {
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;
Loading