@haustle/notion-orm 0.0.42 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/queryTypes.ts DELETED
@@ -1,169 +0,0 @@
1
- /**
2
- * Column types' for all query options
3
- */
4
- // import { PageObjectResponse }
5
-
6
- import { PageObjectResponse } from "@notionhq/client/build/src/api-endpoints";
7
-
8
- type columnDiscriminatedUnionTypes = PageObjectResponse["properties"];
9
- export type NotionColumnTypes =
10
- columnDiscriminatedUnionTypes[keyof columnDiscriminatedUnionTypes]["type"];
11
- // type SupportedQueryableNotionColumnTypes = Exclude<NotionColumnTypes, "created_by" | >
12
-
13
- export type SupportedNotionColumnTypes = Exclude<
14
- NotionColumnTypes,
15
- | "formula"
16
- | "files"
17
- | "people"
18
- | "relation"
19
- | "rollup"
20
- | "created_by"
21
- | "last_edited_by"
22
- | "created_time"
23
- | "last_edited_time"
24
- >;
25
-
26
- type TextPropertyFilters = {
27
- equals: string;
28
- does_not_equal: string;
29
- contains: string;
30
- does_not_contain: string;
31
- starts_with: string;
32
- ends_with: string;
33
- is_empty: true;
34
- is_not_empty: true;
35
- };
36
-
37
- type NumberPropertyFilters = {
38
- equals: number;
39
- does_not_equals: number;
40
- greater_than: number;
41
- less_than: number;
42
- greater_than_or_equal_to: number;
43
- less_than_or_equal_to: number;
44
- is_empty: true;
45
- is_not_empty: true;
46
- };
47
-
48
- type CheckBoxPropertyFilters = {
49
- equals: boolean;
50
- does_not_equal: boolean;
51
- };
52
-
53
- //
54
- type SelectPropertyFilters<T> = {
55
- equals: (T extends Array<any> ? T[number] : T) | (string & {});
56
- does_not_equal: (T extends Array<any> ? T[number] : T) | (string & {});
57
- is_empty: true;
58
- is_not_empty: true;
59
- };
60
-
61
- // pay in array --> need to turn into union
62
- type MultiSelectPropertyFilters<T> = {
63
- contains: (T extends Array<any> ? T[number] : T) | (string & {});
64
- does_not_contain: (T extends Array<any> ? T[number] : T) | (string & {});
65
- is_empty: true;
66
- is_not_empty: true;
67
- };
68
-
69
- type StatusPropertyFilters<T> = SelectPropertyFilters<T>;
70
-
71
- type ISO8601Date = string;
72
- type DatePropertyFilters = {
73
- equals: ISO8601Date;
74
- before: ISO8601Date;
75
- after: ISO8601Date;
76
- on_or_before: ISO8601Date;
77
- is_empty: true;
78
- is_not_empty: true;
79
- on_or_after: string;
80
- past_week: {};
81
- past_month: {};
82
- past_year: {};
83
- this_week: {};
84
- next_week: {};
85
- next_month: {};
86
- next_year: {};
87
- };
88
-
89
- export type FilterOptions<T = []> = {
90
- rich_text: TextPropertyFilters;
91
- title: TextPropertyFilters;
92
- number: NumberPropertyFilters;
93
- checkbox: CheckBoxPropertyFilters;
94
- select: SelectPropertyFilters<T>;
95
- multi_select: MultiSelectPropertyFilters<T>;
96
- url: TextPropertyFilters;
97
- date: DatePropertyFilters;
98
- status: StatusPropertyFilters<T>;
99
- email: TextPropertyFilters;
100
- phone_number: TextPropertyFilters;
101
- };
102
-
103
- /**
104
- * Types to build query object user types out
105
- */
106
-
107
- type ColumnNameToNotionColumnType<T> = Record<
108
- keyof T,
109
- SupportedNotionColumnTypes
110
- >;
111
- type ColumnNameToPossibleValues = Record<string, any>;
112
- // T is a column name to column type
113
- // Y is the collection type
114
- export type SingleFilter<
115
- Y extends Record<string, any>,
116
- T extends ColumnNameToNotionColumnType<Y>
117
- > = {
118
- // Passing the type from collection
119
- [Property in keyof Y]?: Partial<FilterOptions<Y[Property]>[T[Property]]>;
120
- };
121
-
122
- export type CompoundFilters<
123
- Y extends Record<string, any>,
124
- T extends Record<keyof Y, SupportedNotionColumnTypes>
125
- > =
126
- | { and: Array<SingleFilter<Y, T> | CompoundFilters<Y, T>> }
127
- | { or: Array<SingleFilter<Y, T> | CompoundFilters<Y, T>> };
128
-
129
- export type QueryFilter<
130
- Y extends Record<string, any>,
131
- T extends Record<keyof Y, SupportedNotionColumnTypes>
132
- > = SingleFilter<Y, T> | CompoundFilters<Y, T>;
133
-
134
- export type Query<
135
- Y extends Record<string, any>,
136
- T extends Record<keyof Y, SupportedNotionColumnTypes>
137
- > = {
138
- filter?: QueryFilter<Y, T>;
139
- sort?: [];
140
- };
141
-
142
- export type apiFilterQuery = {
143
- filter?: apiSingleFilter | apiAndFilter | apiOrFilter;
144
- };
145
-
146
- /**
147
- * Transform the types above to build types to
148
- * actually build schema for query request
149
- */
150
-
151
- type apiColumnTypeToOptions = {
152
- [prop in keyof FilterOptions]?: Partial<FilterOptions[prop]>;
153
- };
154
- export interface apiSingleFilter extends apiColumnTypeToOptions {
155
- property: string;
156
- }
157
-
158
- export type apiFilterType =
159
- | apiSingleFilter
160
- | apiAndFilter
161
- | apiOrFilter
162
- | undefined;
163
- type apiAndFilter = {
164
- and: Array<apiFilterType>;
165
- };
166
-
167
- type apiOrFilter = {
168
- or: Array<apiFilterType>;
169
- };