Skip to content

Commit

Permalink
refactor: notion filter prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed Feb 15, 2024
1 parent 808ceca commit 6574fcb
Showing 1 changed file with 15 additions and 76 deletions.
91 changes: 15 additions & 76 deletions src/notion/types/notion-query-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,87 +42,26 @@ export interface CommonTypeFilter {
}

// TODO: Fix TProp later, it should be only string
export type NumberPropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'number' }>,
'property'
> & {
property: TProp;
};


// TODO: Fix TProp later, it should be only string
export type DatePropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'date' }>,
'property'
> & {
property: TProp;
};


// TODO: Fix TProp later, it should be only string
export type TitlePropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'title' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type RichTextPropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'rich_text' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type SelectPropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'select' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type StatusPropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'status' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type PeoplePropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'people' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type UrlPropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'url' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type CreatedTimePropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'created_time' }>,
'property'
> & {
property: TProp;
};

// TODO: Fix TProp later, it should be only string
export type LastEditedTimePropFilter<TProp extends keyof any = string> = Omit<
Extract<PropertyFilter, { type?: 'last_edited_time' }>,
/**
* Extract the property filter from the original type
*/
export type ExtractPropertyFilter<TSignature, TProp extends keyof any> = Omit<

Check warning on line 48 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
Extract<PropertyFilter, TSignature>,
'property'
> & {
property: TProp;
};

export type NumberPropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'number' }, TProp>;

Check warning on line 55 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
export type DatePropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'date' }, TProp>;

Check warning on line 56 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
export type TitlePropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'title' }, TProp>;

Check warning on line 57 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
export type RichTextPropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'rich_text' }, TProp>;

Check warning on line 58 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
export type SelectPropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'select' }, TProp>;

Check warning on line 59 in src/notion/types/notion-query-filter.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
export type StatusPropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'status' }, TProp>;
export type PeoplePropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'people' }, TProp>;
export type UrlPropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'url' }, TProp>;
export type CreatedTimePropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'created_time' }, TProp>;
export type LastEditedTimePropFilter<TProp extends keyof any = string> = ExtractPropertyFilter<{ type?: 'last_edited_time' }, TProp>;

/**
* The redefined type is still matched the original type
Expand Down

0 comments on commit 6574fcb

Please sign in to comment.