@syntropix/database 0.0.5 → 0.0.6
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/dist/core/dataClient.js +3 -0
- package/dist/core/syntropix.d.ts +1 -1
- package/dist/core/syntropix.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/basemodel.d.ts +4 -3
- package/dist/types/basemodel.js +36 -35
- package/dist/types/common.d.ts +32 -28
- package/dist/types/common.js +11 -12
- package/dist/types/data-type.d.ts +48 -38
- package/dist/types/data-type.js +17 -18
- package/dist/types/dto/table.d.ts +6 -6
- package/dist/types/field.d.ts +60 -41
- package/dist/types/field.js +35 -32
- package/dist/types/filter.d.ts +43 -44
- package/dist/types/filter.js +56 -41
- package/dist/types/requests.d.ts +25 -14
- package/dist/types/requests.js +6 -1
- package/package.json +1 -1
package/dist/types/filter.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Filter types for database queries
|
|
2
2
|
export var SortType;
|
|
3
3
|
(function (SortType) {
|
|
4
|
-
SortType["
|
|
5
|
-
SortType["
|
|
4
|
+
SortType["Descending"] = "Descending";
|
|
5
|
+
SortType["Ascending"] = "Ascending";
|
|
6
6
|
})(SortType || (SortType = {}));
|
|
7
7
|
export var FilterOperation;
|
|
8
8
|
(function (FilterOperation) {
|
|
@@ -39,72 +39,72 @@ export const OR = (...conditions) => conditions;
|
|
|
39
39
|
export const EQ = (field, value) => ({
|
|
40
40
|
column: field,
|
|
41
41
|
operator: FilterOperation.EQ,
|
|
42
|
-
|
|
42
|
+
staticValue: value,
|
|
43
43
|
});
|
|
44
44
|
export const NE = (field, value) => ({
|
|
45
45
|
column: field,
|
|
46
46
|
operator: FilterOperation.NEQ,
|
|
47
|
-
|
|
47
|
+
staticValue: value,
|
|
48
48
|
});
|
|
49
49
|
export const GT = (field, value) => ({
|
|
50
50
|
column: field,
|
|
51
51
|
operator: FilterOperation.GT,
|
|
52
|
-
|
|
52
|
+
staticValue: value,
|
|
53
53
|
});
|
|
54
54
|
export const GTE = (field, value) => ({
|
|
55
55
|
column: field,
|
|
56
56
|
operator: FilterOperation.GTE,
|
|
57
|
-
|
|
57
|
+
staticValue: value,
|
|
58
58
|
});
|
|
59
59
|
export const LT = (field, value) => ({
|
|
60
60
|
column: field,
|
|
61
61
|
operator: FilterOperation.LT,
|
|
62
|
-
|
|
62
|
+
staticValue: value,
|
|
63
63
|
});
|
|
64
64
|
export const LTE = (field, value) => ({
|
|
65
65
|
column: field,
|
|
66
66
|
operator: FilterOperation.LTE,
|
|
67
|
-
|
|
67
|
+
staticValue: value,
|
|
68
68
|
});
|
|
69
69
|
export const IN = (field, values) => ({
|
|
70
70
|
column: field,
|
|
71
71
|
operator: FilterOperation.In,
|
|
72
|
-
|
|
72
|
+
staticValue: values,
|
|
73
73
|
});
|
|
74
74
|
export const CONTAINS = (field, value) => ({
|
|
75
75
|
column: field,
|
|
76
76
|
operator: FilterOperation.Contains,
|
|
77
|
-
|
|
77
|
+
staticValue: value,
|
|
78
78
|
});
|
|
79
79
|
export const OVERLAP = (field, value) => ({
|
|
80
80
|
column: field,
|
|
81
81
|
operator: FilterOperation.Overlap,
|
|
82
|
-
|
|
82
|
+
staticValue: value,
|
|
83
83
|
});
|
|
84
84
|
export const I_LIKE = (field, pattern) => ({
|
|
85
85
|
column: field,
|
|
86
86
|
operator: FilterOperation.ILike,
|
|
87
|
-
|
|
87
|
+
staticValue: pattern,
|
|
88
88
|
});
|
|
89
89
|
export const NOT_I_LIKE = (field, pattern) => ({
|
|
90
90
|
column: field,
|
|
91
91
|
operator: FilterOperation.NotILike,
|
|
92
|
-
|
|
92
|
+
staticValue: pattern,
|
|
93
93
|
});
|
|
94
94
|
export const NOT_IN = (field, values) => ({
|
|
95
95
|
column: field,
|
|
96
96
|
operator: FilterOperation.NotIn,
|
|
97
|
-
|
|
97
|
+
staticValue: values,
|
|
98
98
|
});
|
|
99
99
|
export const LIKE = (field, pattern) => ({
|
|
100
100
|
column: field,
|
|
101
101
|
operator: FilterOperation.Like,
|
|
102
|
-
|
|
102
|
+
staticValue: pattern,
|
|
103
103
|
});
|
|
104
104
|
export const NOT_LIKE = (field, pattern) => ({
|
|
105
105
|
column: field,
|
|
106
106
|
operator: FilterOperation.NotLike,
|
|
107
|
-
|
|
107
|
+
staticValue: pattern,
|
|
108
108
|
});
|
|
109
109
|
export const IS_NULL = (field) => ({
|
|
110
110
|
column: field,
|
|
@@ -117,93 +117,108 @@ export const IS_NOT_NULL = (field) => ({
|
|
|
117
117
|
export const BETWEEN = (field, min, max) => ({
|
|
118
118
|
column: field,
|
|
119
119
|
operator: FilterOperation.Between,
|
|
120
|
-
|
|
120
|
+
staticValue: [min, max],
|
|
121
121
|
});
|
|
122
122
|
// Column comparison (compare two columns)
|
|
123
123
|
export const EQ_COL = (field, otherField) => ({
|
|
124
124
|
column: field,
|
|
125
125
|
operator: FilterOperation.EQ,
|
|
126
|
-
|
|
126
|
+
columnValue: otherField,
|
|
127
127
|
});
|
|
128
128
|
export const NE_COL = (field, otherField) => ({
|
|
129
129
|
column: field,
|
|
130
130
|
operator: FilterOperation.NEQ,
|
|
131
|
-
|
|
131
|
+
columnValue: otherField,
|
|
132
132
|
});
|
|
133
133
|
export const GT_COL = (field, otherField) => ({
|
|
134
134
|
column: field,
|
|
135
135
|
operator: FilterOperation.GT,
|
|
136
|
-
|
|
136
|
+
columnValue: otherField,
|
|
137
137
|
});
|
|
138
138
|
export const GTE_COL = (field, otherField) => ({
|
|
139
139
|
column: field,
|
|
140
140
|
operator: FilterOperation.GTE,
|
|
141
|
-
|
|
141
|
+
columnValue: otherField,
|
|
142
142
|
});
|
|
143
143
|
export const LT_COL = (field, otherField) => ({
|
|
144
144
|
column: field,
|
|
145
145
|
operator: FilterOperation.LT,
|
|
146
|
-
|
|
146
|
+
columnValue: otherField,
|
|
147
147
|
});
|
|
148
148
|
export const LTE_COL = (field, otherField) => ({
|
|
149
149
|
column: field,
|
|
150
150
|
operator: FilterOperation.LTE,
|
|
151
|
-
|
|
151
|
+
columnValue: otherField,
|
|
152
152
|
});
|
|
153
153
|
// Similarity operations
|
|
154
154
|
export const SIMILARITY = (field, value, options) => ({
|
|
155
155
|
column: field,
|
|
156
156
|
operator: FilterOperation.Similarity,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
staticValue: value,
|
|
158
|
+
simiarityOptions: options,
|
|
159
159
|
});
|
|
160
160
|
export const SIMILARITY_DISTANCE = (field, value, options) => ({
|
|
161
161
|
column: field,
|
|
162
162
|
operator: FilterOperation.SimilarityDistance,
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
staticValue: value,
|
|
164
|
+
simiarityOptions: options,
|
|
165
165
|
});
|
|
166
166
|
export const WORD_SIMILARITY = (field, value, options) => ({
|
|
167
167
|
column: field,
|
|
168
168
|
operator: FilterOperation.WordSimilarity,
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
staticValue: value,
|
|
170
|
+
simiarityOptions: options,
|
|
171
171
|
});
|
|
172
172
|
export const WORD_SIMILARITY_DISTANCE = (field, value, options) => ({
|
|
173
173
|
column: field,
|
|
174
174
|
operator: FilterOperation.WordSimilarityDistance,
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
staticValue: value,
|
|
176
|
+
simiarityOptions: options,
|
|
177
177
|
});
|
|
178
178
|
export const STRICT_WORD_SIMILARITY = (field, value, options) => ({
|
|
179
179
|
column: field,
|
|
180
180
|
operator: FilterOperation.StrictWordSimilarity,
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
staticValue: value,
|
|
182
|
+
simiarityOptions: options,
|
|
183
183
|
});
|
|
184
184
|
export const STRICT_WORD_SIMILARITY_DISTANCE = (field, value, options) => ({
|
|
185
185
|
column: field,
|
|
186
186
|
operator: FilterOperation.StrictWordSimilarityDistance,
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
staticValue: value,
|
|
188
|
+
simiarityOptions: options,
|
|
189
189
|
});
|
|
190
190
|
export const EUCLIDEAN_DISTANCE = (field, value, options) => ({
|
|
191
191
|
column: field,
|
|
192
192
|
operator: FilterOperation.EuclideanDistance,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
staticValue: value,
|
|
194
|
+
simiarityOptions: options,
|
|
195
195
|
});
|
|
196
196
|
export const NEGATIVE_INNER_PRODUCT = (field, value, options) => ({
|
|
197
197
|
column: field,
|
|
198
198
|
operator: FilterOperation.NegativeInnerProduct,
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
staticValue: value,
|
|
200
|
+
simiarityOptions: options,
|
|
201
201
|
});
|
|
202
202
|
export const COSINE_DISTANCE = (field, value, options) => ({
|
|
203
203
|
column: field,
|
|
204
204
|
operator: FilterOperation.CosineDistance,
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
staticValue: value,
|
|
206
|
+
simiarityOptions: options,
|
|
207
207
|
});
|
|
208
208
|
// Helper function for values (backward compatibility)
|
|
209
209
|
export const Value = (value) => value;
|
|
210
|
+
// Helper function for wrapping filter
|
|
211
|
+
export function FilterWrapper(filter) {
|
|
212
|
+
if (filter === undefined) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if (!Array.isArray(filter)) {
|
|
216
|
+
return OR(AND(filter));
|
|
217
|
+
}
|
|
218
|
+
else if (!filter.every((item) => Array.isArray(item))) {
|
|
219
|
+
return OR(filter);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return filter;
|
|
223
|
+
}
|
|
224
|
+
}
|
package/dist/types/requests.d.ts
CHANGED
|
@@ -1,43 +1,54 @@
|
|
|
1
1
|
import { Aggregate, Column, ForeignKey, GroupBy, Index, Join, Sort } from './common';
|
|
2
|
-
import { Filter } from './filter';
|
|
2
|
+
import { Filter, FilterGroup, FilterItem } from './filter';
|
|
3
|
+
export declare const SyntropixDBAccessType: {
|
|
4
|
+
readonly None: "None";
|
|
5
|
+
readonly Read: "Read";
|
|
6
|
+
readonly Write: "Write";
|
|
7
|
+
readonly Admin: "Admin";
|
|
8
|
+
};
|
|
9
|
+
export type SyntropixDBAccessType = (typeof SyntropixDBAccessType)[keyof typeof SyntropixDBAccessType];
|
|
3
10
|
export interface TableCreate {
|
|
4
11
|
name: string;
|
|
5
12
|
description?: string;
|
|
6
13
|
columns: Column[];
|
|
7
|
-
|
|
14
|
+
foreignKeys: ForeignKey[];
|
|
8
15
|
indexes: Index[];
|
|
16
|
+
defaultAccess?: SyntropixDBAccessType;
|
|
17
|
+
metadata?: Record<string, any>;
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
path?: string;
|
|
9
20
|
}
|
|
10
21
|
export interface TableDrop {
|
|
11
22
|
name: string;
|
|
12
23
|
}
|
|
13
24
|
export interface TableRename {
|
|
14
25
|
name: string;
|
|
15
|
-
|
|
26
|
+
newName: string;
|
|
16
27
|
}
|
|
17
28
|
export interface TableTruncate {
|
|
18
29
|
name: string;
|
|
19
30
|
}
|
|
20
31
|
export interface TableAddColumn {
|
|
21
|
-
|
|
32
|
+
tableName: string;
|
|
22
33
|
column: Column;
|
|
23
34
|
}
|
|
24
35
|
export interface TableDropColumn {
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
tableName: string;
|
|
37
|
+
columnName: string;
|
|
27
38
|
}
|
|
28
39
|
export interface TableModifyColumn {
|
|
29
|
-
|
|
40
|
+
tableName: string;
|
|
30
41
|
column: Column;
|
|
31
42
|
}
|
|
32
43
|
export interface TableGetSchema {
|
|
33
|
-
|
|
44
|
+
tableName: string;
|
|
34
45
|
}
|
|
35
46
|
export interface InsertData {
|
|
36
47
|
columns: string[];
|
|
37
48
|
values: any[][];
|
|
38
49
|
}
|
|
39
50
|
export interface Insert {
|
|
40
|
-
|
|
51
|
+
tableName: string;
|
|
41
52
|
data: InsertData;
|
|
42
53
|
}
|
|
43
54
|
export interface UpdatePayload {
|
|
@@ -46,27 +57,27 @@ export interface UpdatePayload {
|
|
|
46
57
|
values: any[];
|
|
47
58
|
}
|
|
48
59
|
export interface Update {
|
|
49
|
-
|
|
60
|
+
tableName: string;
|
|
50
61
|
payload: UpdatePayload;
|
|
51
62
|
}
|
|
52
63
|
export interface DeleteDataPayload {
|
|
53
64
|
filter: Filter;
|
|
54
65
|
}
|
|
55
66
|
export interface DeleteData {
|
|
56
|
-
|
|
67
|
+
tableName: string;
|
|
57
68
|
payload: DeleteDataPayload;
|
|
58
69
|
}
|
|
59
70
|
export interface QueryPayload {
|
|
60
|
-
filter?: Filter;
|
|
71
|
+
filter?: Filter | FilterGroup | FilterItem;
|
|
61
72
|
sort?: Sort[];
|
|
62
73
|
aggregate?: Aggregate[];
|
|
63
74
|
join?: Join[];
|
|
64
75
|
limit?: number;
|
|
65
76
|
offset?: number;
|
|
66
|
-
|
|
77
|
+
groupBy?: GroupBy;
|
|
67
78
|
select?: string[];
|
|
68
79
|
}
|
|
69
80
|
export interface Query {
|
|
70
|
-
|
|
81
|
+
tableName: string;
|
|
71
82
|
query: QueryPayload;
|
|
72
83
|
}
|
package/dist/types/requests.js
CHANGED