@mintlify/common 1.0.1311 → 1.0.1313

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.
@@ -0,0 +1,155 @@
1
+ import { type QuerySort } from './query/types.js';
2
+ export { columnReference } from './formula/format.js';
3
+ export declare const DATABASE_VIEWS: readonly ['table', 'board'];
4
+ export type DatabaseView = (typeof DATABASE_VIEWS)[number];
5
+ export type DatabaseViewProps = {
6
+ view?: string | null;
7
+ sort?: string | null;
8
+ filter?: string | null;
9
+ groupBy?: string | null;
10
+ };
11
+ export type DatabaseViewPropChanges = Pick<DatabaseViewProps, 'sort' | 'filter' | 'groupBy'>;
12
+ export type DatabaseViewColumn = {
13
+ id: string;
14
+ name: string;
15
+ type: string;
16
+ options?: readonly string[];
17
+ aliases?: readonly string[];
18
+ };
19
+ export type DatabaseViewRow = {
20
+ id: string;
21
+ createdAt: string;
22
+ columns: Readonly<Record<string, unknown>>;
23
+ };
24
+ export type DatabaseSortDirection = 'asc' | 'desc';
25
+ export type DatabaseSortRule = {
26
+ column: string;
27
+ direction: DatabaseSortDirection;
28
+ };
29
+ export declare const DATABASE_FILTER_OPS: readonly ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'contains', 'not_contains', 'empty', 'not_empty', 'any_of', 'contains_any'];
30
+ export type DatabaseFilterOp = (typeof DATABASE_FILTER_OPS)[number];
31
+ export type DatabaseFilterValue = string | number | boolean | string[] | {
32
+ date: string;
33
+ } | null;
34
+ export type DatabaseFilterRule = {
35
+ column: string;
36
+ op: DatabaseFilterOp;
37
+ value: DatabaseFilterValue;
38
+ };
39
+ export type DatabaseFilter = {
40
+ kind: 'none';
41
+ } | {
42
+ kind: 'rules';
43
+ rules: DatabaseFilterRule[];
44
+ } | {
45
+ kind: 'custom';
46
+ source: string;
47
+ };
48
+ export type DatabaseViewWarning = {
49
+ kind: 'unknown_view';
50
+ view: string;
51
+ } | {
52
+ kind: 'unknown_column';
53
+ prop: DatabaseViewPropName;
54
+ column: string;
55
+ } | {
56
+ kind: 'ambiguous_column';
57
+ prop: DatabaseViewPropName;
58
+ column: string;
59
+ } | {
60
+ kind: 'sort_invalid';
61
+ key: string;
62
+ } | {
63
+ kind: 'unsortable';
64
+ column: string;
65
+ type: string;
66
+ } | {
67
+ kind: 'sort_ignored';
68
+ column: string;
69
+ reason: 'duplicate' | 'limit';
70
+ } | {
71
+ kind: 'invalid_date';
72
+ column: string;
73
+ value: string;
74
+ } | {
75
+ kind: 'filter_error';
76
+ source: string;
77
+ message: string;
78
+ } | {
79
+ kind: 'group_by_unsupported';
80
+ column: string;
81
+ type: string;
82
+ };
83
+ export type DatabaseViewPropName = 'sort' | 'filter' | 'groupBy';
84
+ export type DatabaseFilterKind = 'text' | 'number' | 'select' | 'multi' | 'checkbox' | 'date';
85
+ export declare const filterKindOf: (type: string) => DatabaseFilterKind | null;
86
+ export declare const isViewableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
87
+ export declare const isSortableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
88
+ export declare const isGroupableColumn: (column: Pick<DatabaseViewColumn, 'type'>) => boolean;
89
+ export declare const filterOpsFor: (type: string) => readonly DatabaseFilterOp[];
90
+ export declare const isKnownView: (value: unknown) => value is DatabaseView;
91
+ export declare const resolveView: (value: unknown) => DatabaseView;
92
+ export declare const normalizeColumnName: (name: string) => string;
93
+ export declare const isEmptinessOp: (op: DatabaseFilterOp) => op is "empty" | "not_empty";
94
+ export declare const isCompleteRule: ({ op, value }: DatabaseFilterRule) => boolean;
95
+ export declare const isInvalidDateRule: ({ value }: DatabaseFilterRule) => boolean;
96
+ export type DatabaseSortKey = {
97
+ source: string;
98
+ rule: DatabaseSortRule | null;
99
+ };
100
+ export declare const parseSortKeys: (source: string | null | undefined) => DatabaseSortKey[];
101
+ export declare const parseSort: (source: string | null | undefined) => DatabaseSortRule[] | null;
102
+ export declare const serializeSort: (rules: readonly DatabaseSortRule[]) => string | null;
103
+ export declare const parseFilter: (source: string | null | undefined) => DatabaseFilter;
104
+ export declare const serializeFilter: (filter: DatabaseFilter) => string | null;
105
+ export type DatabaseColumnRenames = ReadonlyMap<string, string>;
106
+ export type ColumnNameMatch<Named> = {
107
+ column: Named;
108
+ } | {
109
+ column: null;
110
+ reason: 'unknown' | 'ambiguous';
111
+ };
112
+ export declare const resolveColumnName: <Named extends {
113
+ name: string;
114
+ }>(written: string, candidates: readonly Named[]) => ColumnNameMatch<Named>;
115
+ export declare const matchColumnName: <Named extends {
116
+ name: string;
117
+ }>(written: string, candidates: readonly Named[]) => Named | undefined;
118
+ export declare const renameColumnsInViewProps: (props: DatabaseViewProps, renames: DatabaseColumnRenames) => DatabaseViewPropChanges;
119
+ export declare const renameColumnInViewProps: (props: DatabaseViewProps, from: string, to: string) => DatabaseViewPropChanges;
120
+ export declare const aliasRenames: (columns: readonly DatabaseViewColumn[]) => DatabaseColumnRenames;
121
+ export declare const ambiguousAliases: (columns: readonly DatabaseViewColumn[]) => ReadonlySet<string>;
122
+ export type ResolvedGroupBy = {
123
+ column: DatabaseViewColumn | null;
124
+ warnings: DatabaseViewWarning[];
125
+ };
126
+ export declare const resolveGroupBy: (written: string | null | undefined, columns: readonly DatabaseViewColumn[]) => ResolvedGroupBy;
127
+ export type DatabaseInvalidFilter = 'show-all' | 'hide-all';
128
+ export type ResolveViewOptions = {
129
+ onInvalidFilter?: DatabaseInvalidFilter;
130
+ };
131
+ export type ResolvedDatabaseView = {
132
+ view: DatabaseView;
133
+ sort: DatabaseSortRule[];
134
+ filter: DatabaseFilter;
135
+ groupBy: string | null;
136
+ warnings: DatabaseViewWarning[];
137
+ healed: DatabaseViewPropChanges;
138
+ filterSource: string | null;
139
+ filterInvalid: boolean;
140
+ querySort: QuerySort;
141
+ rulesKey: string;
142
+ matches: (row: DatabaseViewRow) => boolean;
143
+ sortRows: <Row extends DatabaseViewRow>(rows: readonly Row[]) => Row[];
144
+ };
145
+ export declare const resolveViewProps: (written: DatabaseViewProps, columns: readonly DatabaseViewColumn[], { onInvalidFilter }?: ResolveViewOptions) => ResolvedDatabaseView;
146
+ export type FilterDiagnostic = {
147
+ message: string;
148
+ start: number;
149
+ end: number;
150
+ };
151
+ export declare const filterDiagnostic: (source: string, columns: readonly DatabaseViewColumn[]) => FilterDiagnostic | null;
152
+ export type DatabaseViewOptions<Row> = ResolveViewOptions & {
153
+ keep?: (row: Row) => boolean;
154
+ };
155
+ export declare const applyView: <Row extends DatabaseViewRow>(columns: readonly DatabaseViewColumn[], rows: readonly Row[], props: DatabaseViewProps, { keep, onInvalidFilter }?: DatabaseViewOptions<Row>) => Row[];