Skip to content

Commit

Permalink
fixing the type of get response
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-monday committed Jan 10, 2024
1 parent 96bc10a commit 107975c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.2",
"version": "0.5.3",
"private": false,
"repository": "https://github.com/mondaycom/monday-sdk-js",
"main": "src/index.js",
Expand Down
6 changes: 6 additions & 0 deletions types/client-context.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ type AppVersion = {
};
};

export type Permissions = {
approvedScopes: string[];
requiredScopes: string[];
};

export type BaseContext = {
themeConfig?: Theme;
theme: string;
Expand All @@ -40,6 +45,7 @@ export type BaseContext = {
region: string;
app: App;
appVersion: AppVersion;
permissions: Permissions;
};

export type AppFeatureBoardViewContext = BaseContext & {
Expand Down
30 changes: 16 additions & 14 deletions types/client-data.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ type SubscribableEvents = keyof SubscribableEventsResponse;

type SettableTypes = "settings";

interface GetResponse {
data: {
success: boolean;
value: any;
version?: any;
};
type StorageResponse = {
success: boolean;
value: any;
version?: any;
};

type Response<T = StorageResponse> = {
data: T;
errorMessage?: string | undefined;
method: string;
requestId: string;
type?: string | undefined;
}
};

interface DeleteResponse {
type DeleteResponse = {
data: {
success: boolean;
value: any;
Expand All @@ -32,7 +34,7 @@ interface DeleteResponse {
method: string;
requestId: string;
type?: string | undefined;
}
};

interface SetResponse {
data: {
Expand Down Expand Up @@ -70,8 +72,8 @@ export interface ClientData {
AppFeatureType extends AppFeatureTypes = AppFeatureTypes
>(
type: T,
params?: object & { appFeatureType?: AppFeatureType }
): Promise<GetterResponse<AppFeatureType>[T] & CustomResponse>;
params?: Record<string, any> & { appFeatureType?: AppFeatureType }
): Promise<Response<GetterResponse<AppFeatureType>[T] & CustomResponse>>;

/**
* Creates a listener which allows subscribing to certain types of client-side events.
Expand All @@ -86,7 +88,7 @@ export interface ClientData {
>(
typeOrTypes: T | ReadonlyArray<T>,
callback: (res: { data: SubscribableEventsResponse<AppFeatureType>[T] & CustomResponse }) => void,
params?: object & { appFeatureType?: AppFeatureType }
params?: Record<string, any> & { appFeatureType?: AppFeatureType }
): void;

/**
Expand All @@ -110,7 +112,7 @@ export interface ClientData {
* Returns a stored value from the database under `key` for the app (**without any reference to the instance**)
* @param {string} key - Used to access to stored data
*/
getItem(key: string): Promise<GetResponse>;
getItem(key: string): Promise<Response>;

/**
* Deletes a stored value from the database under `key` for the app (**without any reference to the instance**)
Expand All @@ -135,7 +137,7 @@ export interface ClientData {
* Returns a stored value from the database under `key` for a specific app instance
* @param key
*/
getItem(key: string): Promise<GetResponse>;
getItem(key: string): Promise<Response>;

/**
* Deletes a stored value from the database under `key` for a specific app instance
Expand Down

0 comments on commit 107975c

Please sign in to comment.