@syntropix/database 0.1.1 → 0.2.1

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/index.d.cts CHANGED
@@ -1,19 +1,4 @@
1
- declare class ClientConfig {
2
- apiKey?: string;
3
- baseUrl?: string;
4
- timeout?: number;
5
- retries?: number;
6
- constructor(config?: any);
7
- }
8
-
9
- declare class Client {
10
- protected config: ClientConfig;
11
- constructor(config: ClientConfig);
12
- private headers;
13
- private url;
14
- get(path: string, data?: Record<string, any>): Promise<Record<string, any>>;
15
- post(path: string, data?: Record<string, any>): Promise<Record<string, any>>;
16
- }
1
+ import { ObjectId } from 'bson';
17
2
 
18
3
  interface StringType {
19
4
  String: number;
@@ -33,54 +18,121 @@ interface MoneyType {
33
18
  interface DecimalType {
34
19
  Decimal: [number, number] | null;
35
20
  }
36
- type ArrayDataTypeMap = typeof ArrayDataType;
37
- type ArrayDataTypeValues = ArrayDataTypeMap[keyof ArrayDataTypeMap];
38
- type ArrayDataTypeReturnTypes = ReturnType<Extract<ArrayDataTypeValues, (...args: any[]) => any>>;
39
- declare const ArrayDataType: {
40
- readonly String: (maxLength: number) => StringType;
41
- readonly Text: "Text";
42
- readonly Integer: "Integer";
43
- readonly BigInteger: "BigInteger";
44
- readonly Double: "Double";
45
- readonly Decimal: (precision: number, scale: number) => DecimalType;
46
- readonly DateTime: "DateTime";
47
- readonly Timestamp: "Timestamp";
48
- readonly Date: "Date";
49
- readonly Boolean: "Boolean";
50
- readonly Money: (precision: number, scale: number) => MoneyType;
51
- readonly Uuid: "Uuid";
52
- readonly Enum: (name: string, variants: string[]) => EnumType;
53
- readonly Json: "Json";
54
- };
55
- type ArrayDataType = Exclude<ArrayDataTypeValues, (...args: any[]) => any> | ArrayDataTypeReturnTypes;
56
21
  interface ArrayType {
57
- Array: ArrayDataType;
22
+ Array: ArrayDataTypeSchema;
58
23
  }
59
- type DataTypeMap = typeof ColumnDataType;
60
- type DataTypeValues = DataTypeMap[keyof DataTypeMap];
61
- type DataTypeReturnTypes = ReturnType<Extract<DataTypeValues, (...args: any[]) => any>>;
62
- declare const ColumnDataType: {
63
- readonly Integer: "Integer";
64
- readonly String: (maxLength: number) => StringType;
65
- readonly Text: "Text";
66
- readonly Boolean: "Boolean";
67
- readonly DateTime: "DateTime";
68
- readonly Timestamp: "Timestamp";
69
- readonly Date: "Date";
70
- readonly Json: "Json";
71
- readonly Uuid: "Uuid";
72
- readonly Double: "Double";
73
- readonly Vector: (dimensions: number) => VectorType;
74
- readonly Array: (dataType: ArrayDataType) => ArrayType;
75
- readonly Enum: (name: string, variants: string[]) => EnumType;
76
- readonly Money: (precision: number, scale: number) => MoneyType;
77
- readonly Decimal: (precision: number, scale: number) => DecimalType;
24
+ type ArrayDataTypeSchema = StringType | DecimalType | MoneyType | EnumType | 'Text' | 'Integer' | 'BigInteger' | 'Double' | 'DateTime' | 'Timestamp' | 'Date' | 'Boolean' | 'Uuid' | 'Json';
25
+ type ColumnDataTypeSchema = StringType | VectorType | ArrayType | EnumType | MoneyType | DecimalType | 'Text' | 'Integer' | 'BigInteger' | 'Double' | 'DateTime' | 'Timestamp' | 'Date' | 'Boolean' | 'Uuid' | 'Json';
26
+
27
+ declare const AccessType: {
28
+ readonly None: "None";
29
+ readonly Read: "Read";
30
+ readonly Write: "Write";
31
+ readonly Admin: "Admin";
32
+ };
33
+ type AccessType = (typeof AccessType)[keyof typeof AccessType];
34
+
35
+ interface SyntropixDBColumn {
36
+ id: string;
37
+ name: string;
38
+ displayName: string;
39
+ description: string;
40
+ columnType: ColumnDataTypeSchema;
41
+ isPrimaryKey: boolean;
42
+ isNullable: boolean;
43
+ autoIncrement: boolean;
44
+ default: any | null;
45
+ defaultAccess: AccessType | null;
46
+ }
47
+ interface ColumnCreateOptions {
48
+ type?: ColumnDataTypeSchema;
49
+ name?: string;
50
+ displayName?: string;
51
+ description?: string;
52
+ primary?: boolean;
53
+ nullable?: boolean;
54
+ autoIncrement?: boolean;
55
+ default?: any;
56
+ defaultAccess?: AccessType;
57
+ }
58
+
59
+ declare const IndexType: {
60
+ readonly Gin: "Gin";
61
+ readonly GinTrgmOps: "GinTrgmOps";
62
+ readonly IvfflatL2Ops: "IvfflatL2Ops";
63
+ readonly InfflatCosineOps: "InfflatCosineOps";
64
+ readonly InfflatIpOps: "InfflatIpOps";
78
65
  };
79
- type ColumnDataType = Exclude<DataTypeValues, (...args: any[]) => any> | DataTypeReturnTypes;
66
+ type IndexType = (typeof IndexType)[keyof typeof IndexType];
67
+ interface SyntropixDBIndex {
68
+ name?: string;
69
+ unique: boolean;
70
+ nullsNotDistinct: boolean;
71
+ columns: string[];
72
+ indexType: IndexType;
73
+ }
74
+
75
+ declare const ForeignKeyAction: {
76
+ readonly Cascade: "Cascade";
77
+ readonly Restrict: "Restrict";
78
+ readonly SetNull: "SetNull";
79
+ readonly NoAction: "NoAction";
80
+ readonly SetDefault: "SetDefault";
81
+ };
82
+ type ForeignKeyAction = (typeof ForeignKeyAction)[keyof typeof ForeignKeyAction];
83
+ interface SyntropixDBForeignKey {
84
+ name?: string;
85
+ fromTableName: string;
86
+ fromColumnName: string;
87
+ toTableName: string;
88
+ toColumnName: string;
89
+ onDelete?: ForeignKeyAction;
90
+ onUpdate?: ForeignKeyAction;
91
+ }
92
+
93
+ interface FieldOptions {
94
+ name?: string;
95
+ displayName?: string;
96
+ description?: string;
97
+ isPrimaryKey?: boolean;
98
+ isNullable?: boolean;
99
+ autoIncrement?: boolean;
100
+ default?: any;
101
+ defaultAccess?: AccessType;
102
+ }
103
+ interface ForeignKeyFieldOptions extends FieldOptions {
104
+ onDelete?: ForeignKeyAction;
105
+ onUpdate?: ForeignKeyAction;
106
+ }
80
107
 
81
- declare enum SortType {
82
- Descending = "Descending",
83
- Ascending = "Ascending"
108
+ declare const SortType: {
109
+ readonly Descending: "Descending";
110
+ readonly Ascending: "Ascending";
111
+ };
112
+ type SortType = (typeof SortType)[keyof typeof SortType];
113
+ declare enum AggregateFunction {
114
+ Count = "Count",
115
+ Sum = "Sum",
116
+ Avg = "Avg",
117
+ Min = "Min",
118
+ Max = "Max",
119
+ CountDistinct = "CountDistinct"
120
+ }
121
+ interface Join {
122
+ table: string;
123
+ on: any;
124
+ }
125
+ interface Aggregate {
126
+ column: string;
127
+ function: AggregateFunction;
128
+ alias: string;
129
+ }
130
+ interface GroupBy {
131
+ columns: string[];
132
+ }
133
+ interface Sort {
134
+ column: string;
135
+ direction: SortType;
84
136
  }
85
137
  interface SimilarityOptions {
86
138
  threshold: number;
@@ -116,7 +168,7 @@ declare enum FilterOperation {
116
168
  CosineDistance = "CosineDistance"
117
169
  }
118
170
  interface FilterItem {
119
- column: string;
171
+ columnName: string;
120
172
  operator: FilterOperation;
121
173
  staticValue?: any;
122
174
  columnValue?: string;
@@ -124,105 +176,27 @@ interface FilterItem {
124
176
  }
125
177
  type FilterGroup = FilterItem[];
126
178
  type Filter = FilterGroup[];
127
- declare const AND: (...conditions: FilterItem[]) => FilterGroup;
128
- declare const OR: (...conditions: FilterGroup[]) => Filter;
129
- declare const EQ: (field: string, value: any) => FilterItem;
130
- declare const NE: (field: string, value: any) => FilterItem;
131
- declare const GT: (field: string, value: any) => FilterItem;
132
- declare const GTE: (field: string, value: any) => FilterItem;
133
- declare const LT: (field: string, value: any) => FilterItem;
134
- declare const LTE: (field: string, value: any) => FilterItem;
135
- declare const IN: (field: string, values: any[]) => FilterItem;
136
- declare const CONTAINS: (field: string, value: any) => FilterItem;
137
- declare const OVERLAP: (field: string, value: any) => FilterItem;
138
- declare const I_LIKE: (field: string, pattern: string) => FilterItem;
139
- declare const NOT_I_LIKE: (field: string, pattern: string) => FilterItem;
140
- declare const NOT_IN: (field: string, values: any[]) => FilterItem;
141
- declare const LIKE: (field: string, pattern: string) => FilterItem;
142
- declare const NOT_LIKE: (field: string, pattern: string) => FilterItem;
143
- declare const IS_NULL: (field: string) => FilterItem;
144
- declare const IS_NOT_NULL: (field: string) => FilterItem;
145
- declare const BETWEEN: (field: string, min: any, max: any) => FilterItem;
146
- declare const EQ_COL: (field: string, otherField: string) => FilterItem;
147
- declare const NE_COL: (field: string, otherField: string) => FilterItem;
148
- declare const GT_COL: (field: string, otherField: string) => FilterItem;
149
- declare const GTE_COL: (field: string, otherField: string) => FilterItem;
150
- declare const LT_COL: (field: string, otherField: string) => FilterItem;
151
- declare const LTE_COL: (field: string, otherField: string) => FilterItem;
152
- declare const SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
153
- declare const SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
154
- declare const WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
155
- declare const WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
156
- declare const STRICT_WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
157
- declare const STRICT_WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
158
- declare const EUCLIDEAN_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
159
- declare const NEGATIVE_INNER_PRODUCT: (field: string, value: any, options: SimilarityOptions) => FilterItem;
160
- declare const COSINE_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
161
- declare const Value: (value: any) => any;
162
- declare function FilterWrapper(filter: Filter | FilterGroup | FilterItem | undefined): Filter | undefined;
163
179
 
164
- declare enum ForeignKeyAction {
165
- Cascade = "Cascade",
166
- Restrict = "Restrict",
167
- SetNull = "SetNull",
168
- NoAction = "NoAction",
169
- SetDefault = "SetDefault"
170
- }
171
- declare enum AggregateFunction {
172
- Count = "Count",
173
- Sum = "Sum",
174
- Avg = "Avg",
175
- Min = "Min",
176
- Max = "Max",
177
- CountDistinct = "CountDistinct"
178
- }
179
- interface Sort {
180
- column: string;
181
- direction: SortType;
182
- }
183
- interface Join {
184
- table: string;
185
- on: any;
186
- }
187
- interface Aggregate {
188
- column: string;
189
- function: AggregateFunction;
190
- alias: string;
191
- }
192
- interface GroupBy {
193
- columns: string[];
194
- }
195
- interface ForeignKey$1 {
196
- name?: string;
197
- fromTableName: string;
198
- fromColumnName: string;
199
- toTableName: string;
200
- toColumnName: string;
201
- onDelete?: ForeignKeyAction;
202
- onUpdate?: ForeignKeyAction;
203
- }
204
- interface Column$1 {
205
- name: string;
206
- displayName?: string;
207
- description?: string;
208
- columnType: ColumnDataType;
209
- isPrimaryKey?: boolean;
210
- isNullable?: boolean;
211
- autoIncrement?: boolean;
212
- default?: any;
213
- defaultAccess?: SyntropixDBAccessType;
214
- }
215
- interface Index {
216
- name: string;
217
- columns: string[];
218
- unique?: boolean;
219
- }
220
180
  interface SyntropixDBTable {
221
181
  id: string;
222
182
  name: string;
183
+ displayName: string;
223
184
  description: string;
224
185
  createdAt: Date;
225
- columns: Column$1[];
186
+ schema: string;
187
+ defaultAccess: AccessType | null;
188
+ columns: SyntropixDBColumn[];
189
+ foreignKeys: SyntropixDBForeignKey[];
190
+ indexes: SyntropixDBIndex[];
191
+ }
192
+ interface SyntropixDBTableSchema {
193
+ id: string;
194
+ column_access: Record<string, AccessType>;
195
+ metadata: Record<string, any>;
196
+ path: string;
197
+ table: SyntropixDBTable;
198
+ visible: boolean;
199
+ table_access: AccessType;
226
200
  }
227
201
  interface SyntropixDBTableListItem {
228
202
  id: string;
@@ -231,84 +205,89 @@ interface SyntropixDBTableListItem {
231
205
  metadata: Record<string, any>;
232
206
  path: string;
233
207
  visible: boolean;
234
- access: SyntropixDBAccessType;
208
+ access: AccessType;
235
209
  }
236
210
 
237
- declare const SyntropixDBAccessType: {
238
- readonly None: "None";
239
- readonly Read: "Read";
240
- readonly Write: "Write";
241
- readonly Admin: "Admin";
242
- };
243
- type SyntropixDBAccessType = (typeof SyntropixDBAccessType)[keyof typeof SyntropixDBAccessType];
244
- interface TableCreate {
211
+ interface ColumnCreateDto {
245
212
  name: string;
246
213
  displayName?: string;
247
- description?: string;
248
- columns: Column$1[];
249
- foreignKeys: ForeignKey$1[];
250
- indexes: Index[];
251
- defaultAccess?: SyntropixDBAccessType;
214
+ description: string;
215
+ columnType: ColumnDataTypeSchema;
216
+ isPrimaryKey: boolean;
217
+ isNullable: boolean;
218
+ autoIncrement: boolean;
219
+ default?: any;
220
+ defaultAccess?: AccessType;
221
+ }
222
+
223
+ interface TableCreateDto {
224
+ name: string;
225
+ displayName?: string;
226
+ description: string;
227
+ columns: ColumnCreateDto[];
228
+ foreignKeys: SyntropixDBForeignKey[];
229
+ indexes: SyntropixDBIndex[];
230
+ defaultAccess?: AccessType;
252
231
  metadata?: Record<string, any>;
253
232
  visible?: boolean;
254
233
  path?: string;
255
234
  }
256
- interface TableDrop {
235
+ interface TableGetSchemaDto {
257
236
  tableName: string;
258
237
  }
259
- interface TableRename {
238
+ interface TableDropDto {
260
239
  tableName: string;
261
- newTableName: string;
262
240
  }
263
- interface TableTruncate {
241
+ interface TableRenameDto {
264
242
  tableName: string;
243
+ newTableName: string;
265
244
  }
266
- interface TableAddColumn {
245
+ interface TableTruncateDto {
267
246
  tableName: string;
268
- column: Column$1;
269
247
  }
270
- interface TableDropColumn {
248
+ interface TableAddColumnDto {
271
249
  tableName: string;
272
- columnName: string;
250
+ column: SyntropixDBColumn;
273
251
  }
274
- interface TableModifyColumn {
252
+ interface TableDropColumnDto {
275
253
  tableName: string;
276
- column: Column$1;
254
+ columnName: string;
277
255
  }
278
- interface TableGetSchema {
256
+ interface TableModifyColumnDto {
279
257
  tableName: string;
258
+ column: SyntropixDBColumn;
280
259
  }
281
- interface TableGetList {
260
+ interface TableGetListDto {
282
261
  search?: string;
283
262
  path?: string;
284
263
  page?: number;
285
264
  pageSize?: number;
286
265
  }
287
- interface InsertData {
266
+ interface InsertDataDto {
288
267
  columns: string[];
289
268
  values: any[][];
290
269
  }
291
- interface Insert {
270
+ interface InsertDto {
292
271
  tableName: string;
293
- data: InsertData;
272
+ data: InsertDataDto;
294
273
  }
295
- interface UpdatePayload {
274
+ interface UpdatePayloadDto {
296
275
  filter: Filter;
297
276
  columns: string[];
298
277
  values: any[];
299
278
  }
300
- interface Update {
279
+ interface UpdateDto {
301
280
  tableName: string;
302
- payload: UpdatePayload;
281
+ payload: UpdatePayloadDto;
303
282
  }
304
- interface DeleteDataPayload {
283
+ interface DeleteDataPayloadDto {
305
284
  filter: Filter;
306
285
  }
307
- interface DeleteData {
286
+ interface DeleteDataDto {
308
287
  tableName: string;
309
- payload: DeleteDataPayload;
288
+ payload: DeleteDataPayloadDto;
310
289
  }
311
- interface QueryPayload {
290
+ interface QueryPayloadDto {
312
291
  filter?: Filter | FilterGroup | FilterItem;
313
292
  sort?: Sort[];
314
293
  aggregate?: Aggregate[];
@@ -318,57 +297,88 @@ interface QueryPayload {
318
297
  groupBy?: GroupBy;
319
298
  select?: string[];
320
299
  }
321
- interface Query {
300
+ interface QueryDto {
322
301
  tableName: string;
323
- query: QueryPayload;
302
+ query: QueryPayloadDto;
324
303
  }
325
304
 
326
- declare class DataClient {
327
- private client;
328
- constructor(config?: ClientConfig);
329
- insertData(data: Insert): Promise<any>;
330
- insertOne(data: Insert): Promise<any>;
331
- updateByPrimaryKey(pk: string, data: Update): Promise<any>;
332
- queryOne(data: Query, model?: any): Promise<any>;
333
- queryMany(data: Query, model?: any): Promise<any>;
334
- updateData(data: Update): Promise<any>;
335
- deleteData(data: DeleteData): Promise<any>;
305
+ interface ColumnCreateResponse {
306
+ id: string;
307
+ name: string;
308
+ displayName: string;
309
+ description: string;
310
+ columnType: ColumnDataTypeSchema;
311
+ isPrimaryKey: boolean;
312
+ isNullable: boolean;
313
+ autoIncrement: boolean;
314
+ default: any | null;
315
+ defaultAccess: AccessType | null;
316
+ }
317
+
318
+ interface SyntropixSuccessResponse<T> {
319
+ status: 'success';
320
+ data: T;
336
321
  }
322
+ interface SyntropixErrorResponse {
323
+ status: 'error';
324
+ message: string;
325
+ }
326
+ type SyntropixResponse<T> = SyntropixSuccessResponse<T> | SyntropixErrorResponse;
337
327
 
338
328
  interface TableCreateResponse {
339
- _id: {
340
- $oid: string;
341
- };
342
- table: {
343
- id: string;
344
- name: string;
345
- description: string;
346
- createdAt: any;
347
- columns: Column$1[];
348
- foreignKeys: ForeignKey$1[];
349
- indexes: Index[];
350
- schema: string;
351
- defaultAccess: string | null;
352
- };
353
- createdAt: any;
354
- updatedAt: any;
329
+ _id: ObjectId;
330
+ table: SyntropixDBTable;
331
+ createdAt: Date;
332
+ updatedAt: Date;
355
333
  createdBy: string;
356
334
  metadata: Record<string, any>;
357
- triggers: any[];
335
+ path: string;
336
+ visible: boolean;
337
+ }
338
+ type TableSchemaResponse = SyntropixDBTableSchema;
339
+ type TableListResponse = SyntropixDBTableListItem[];
340
+
341
+ declare class ClientConfig {
342
+ apiKey?: string;
343
+ baseUrl?: string;
344
+ timeout?: number;
345
+ retries?: number;
346
+ constructor(config?: any);
347
+ }
348
+
349
+ declare class BaseClient {
350
+ protected config: ClientConfig;
351
+ constructor(config: ClientConfig);
352
+ private headers;
353
+ private url;
354
+ get<T>(path: string, data?: Record<string, any>): Promise<T>;
355
+ post<T>(path: string, data?: Record<string, any>): Promise<T>;
356
+ }
357
+
358
+ declare class DataClient {
359
+ private client;
360
+ constructor(config?: ClientConfig);
361
+ insertData(data: InsertDto): Promise<any>;
362
+ insertOne(data: InsertDto): Promise<any>;
363
+ updateByPrimaryKey(pk: string, data: UpdateDto): Promise<any>;
364
+ queryOne(data: QueryDto, model?: any): Promise<any>;
365
+ queryMany(data: QueryDto, model?: any): Promise<any>;
366
+ updateData(data: UpdateDto): Promise<any>;
367
+ deleteData(data: DeleteDataDto): Promise<any>;
358
368
  }
359
369
 
360
370
  declare class TableClient {
361
371
  private client;
362
372
  constructor(config?: ClientConfig);
363
- createTable(data: TableCreate): Promise<TableCreateResponse>;
364
- dropTable(data: TableDrop): Promise<any>;
365
- renameTable(data: TableRename): Promise<any>;
366
- truncateTable(data: TableTruncate): Promise<any>;
367
- addColumn(data: TableAddColumn): Promise<any>;
368
- dropColumn(data: TableDropColumn): Promise<any>;
369
- modifyColumn(data: TableModifyColumn): Promise<any>;
370
- getTableSchema(data: TableGetSchema): Promise<SyntropixDBTable>;
371
- getTableList(data: TableGetList): Promise<SyntropixDBTableListItem[]>;
373
+ createTable(data: TableCreateDto): Promise<TableCreateResponse>;
374
+ dropTable(data: TableDropDto): Promise<any>;
375
+ renameTable(data: TableRenameDto): Promise<any>;
376
+ truncateTable(data: TableTruncateDto): Promise<any>;
377
+ addColumn(data: TableAddColumnDto): Promise<any>;
378
+ dropColumn(data: TableDropColumnDto): Promise<any>;
379
+ modifyColumn(data: TableModifyColumnDto): Promise<any>;
380
+ getTableSchema(data: TableGetSchemaDto): Promise<TableSchemaResponse>;
381
+ getTableList(data: TableGetListDto): Promise<TableListResponse>;
372
382
  }
373
383
 
374
384
  declare class SyntropixClient {
@@ -382,190 +392,78 @@ declare class SyntropixClient {
382
392
 
383
393
  declare abstract class Field {
384
394
  name: string;
395
+ displayName: string;
385
396
  description: string;
386
- columnType: ColumnDataType;
397
+ columnType: ColumnDataTypeSchema;
387
398
  isPrimaryKey: boolean;
388
399
  isNullable: boolean;
389
400
  autoIncrement: boolean;
390
401
  default?: any;
391
- defaultAccess?: SyntropixDBAccessType;
392
- constructor(columnType: ColumnDataType, options?: {
393
- name?: string;
394
- description?: string;
395
- isPrimaryKey?: boolean;
396
- isNullable?: boolean;
397
- autoIncrement?: boolean;
398
- default?: any;
399
- defaultAccess?: SyntropixDBAccessType;
400
- });
401
- into(): Column$1;
402
+ defaultAccess?: AccessType;
403
+ constructor(columnType: ColumnDataTypeSchema, options?: FieldOptions);
404
+ intoColumnCreateDto(): ColumnCreateDto;
402
405
  }
403
406
  declare class ForeignKeyField extends Field {
404
407
  tableName: string;
405
408
  columnName: string;
406
409
  onDelete: ForeignKeyAction;
407
410
  onUpdate: ForeignKeyAction;
408
- constructor(columnType: ColumnDataType, tableName: string, columnName: string, options?: {
409
- onDelete?: ForeignKeyAction;
410
- onUpdate?: ForeignKeyAction;
411
- description?: string;
412
- isPrimaryKey?: boolean;
413
- isNullable?: boolean;
414
- default?: any;
415
- defaultAccess?: SyntropixDBAccessType;
416
- });
411
+ constructor(columnType: ColumnDataTypeSchema, tableName: string, columnName: string, options?: ForeignKeyFieldOptions);
417
412
  }
418
413
  declare class StringField extends Field {
419
- constructor(maxLength: number, options?: {
420
- description?: string;
421
- isPrimaryKey?: boolean;
422
- isNullable?: boolean;
423
- default?: string;
424
- defaultAccess?: SyntropixDBAccessType;
425
- });
414
+ constructor(maxLength: number, options?: FieldOptions);
426
415
  }
427
416
  declare class TextField extends Field {
428
- constructor(options?: {
429
- description?: string;
430
- isPrimaryKey?: boolean;
431
- isNullable?: boolean;
432
- default?: string;
433
- defaultAccess?: SyntropixDBAccessType;
434
- });
417
+ constructor(options?: FieldOptions);
435
418
  }
436
419
  declare class IntegerField extends Field {
437
- constructor(options?: {
438
- description?: string;
439
- isPrimaryKey?: boolean;
440
- isNullable?: boolean;
441
- autoIncrement?: boolean;
442
- default?: number;
443
- defaultAccess?: SyntropixDBAccessType;
444
- });
420
+ constructor(options?: FieldOptions);
445
421
  }
446
422
  declare class BooleanField extends Field {
447
- constructor(options?: {
448
- description?: string;
449
- isPrimaryKey?: boolean;
450
- isNullable?: boolean;
451
- default?: boolean;
452
- defaultAccess?: SyntropixDBAccessType;
453
- });
423
+ constructor(options?: FieldOptions);
454
424
  }
455
425
  declare class DateTimeField extends Field {
456
- constructor(options?: {
457
- description?: string;
458
- isPrimaryKey?: boolean;
459
- isNullable?: boolean;
460
- default?: Date;
461
- defaultAccess?: SyntropixDBAccessType;
462
- });
426
+ constructor(options?: FieldOptions);
463
427
  }
464
428
  declare class TimestampField extends Field {
465
- constructor(options?: {
466
- description?: string;
467
- isPrimaryKey?: boolean;
468
- isNullable?: boolean;
469
- default?: Date;
470
- defaultAccess?: SyntropixDBAccessType;
471
- });
429
+ constructor(options?: FieldOptions);
472
430
  }
473
431
  declare class DateField extends Field {
474
- constructor(options?: {
475
- description?: string;
476
- isPrimaryKey?: boolean;
477
- isNullable?: boolean;
478
- default?: Date;
479
- defaultAccess?: SyntropixDBAccessType;
480
- });
432
+ constructor(options?: FieldOptions);
481
433
  }
482
434
  declare class JsonField extends Field {
483
- constructor(options?: {
484
- description?: string;
485
- isPrimaryKey?: boolean;
486
- isNullable?: boolean;
487
- default?: Record<string, any>;
488
- defaultAccess?: SyntropixDBAccessType;
489
- });
435
+ constructor(options?: FieldOptions);
490
436
  }
491
437
  declare class UuidField extends Field {
492
- constructor(options?: {
493
- description?: string;
494
- isPrimaryKey?: boolean;
495
- isNullable?: boolean;
496
- default?: string;
497
- defaultAccess?: SyntropixDBAccessType;
498
- });
438
+ constructor(options?: FieldOptions);
499
439
  }
500
440
  declare class VectorField extends Field {
501
- constructor(dimensions: number, options?: {
502
- description?: string;
503
- isPrimaryKey?: boolean;
504
- isNullable?: boolean;
505
- default?: number[];
506
- defaultAccess?: SyntropixDBAccessType;
507
- });
441
+ constructor(dimensions: number, options?: FieldOptions);
508
442
  }
509
443
  declare class ArrayField extends Field {
510
- constructor(dataType: ArrayDataType, options?: {
511
- description?: string;
512
- isPrimaryKey?: boolean;
513
- isNullable?: boolean;
514
- default?: any[];
515
- defaultAccess?: SyntropixDBAccessType;
516
- });
444
+ constructor(dataType: ArrayDataTypeSchema, options?: FieldOptions);
517
445
  }
518
446
  declare class EnumField extends Field {
519
- constructor(name: string, variants: string[], options?: {
520
- description?: string;
521
- isPrimaryKey?: boolean;
522
- isNullable?: boolean;
523
- default?: string;
524
- defaultAccess?: SyntropixDBAccessType;
525
- });
447
+ constructor(name: string, variants: string[], options?: FieldOptions);
526
448
  }
527
449
  declare class MoneyField extends Field {
528
- constructor(precision: number, scale: number, options?: {
529
- description?: string;
530
- isPrimaryKey?: boolean;
531
- isNullable?: boolean;
532
- default?: number;
533
- defaultAccess?: SyntropixDBAccessType;
534
- });
450
+ constructor(precision: number, scale: number, options?: FieldOptions);
535
451
  }
536
452
  declare class DecimalField extends Field {
537
- constructor(precision: number, scale: number, options?: {
538
- description?: string;
539
- isPrimaryKey?: boolean;
540
- isNullable?: boolean;
541
- default?: number;
542
- defaultAccess?: SyntropixDBAccessType;
543
- });
453
+ constructor(precision: number, scale: number, options?: FieldOptions);
544
454
  }
545
455
  declare class DoubleField extends Field {
546
- constructor(options?: {
547
- description?: string;
548
- isPrimaryKey?: boolean;
549
- isNullable?: boolean;
550
- default?: number;
551
- defaultAccess?: SyntropixDBAccessType;
552
- });
456
+ constructor(options?: FieldOptions);
553
457
  }
554
458
 
555
- declare function Column(options?: {
556
- type?: ColumnDataType;
557
- name?: string;
558
- description?: string;
559
- primary?: boolean;
560
- nullable?: boolean;
561
- autoIncrement?: boolean;
562
- default?: any;
563
- }): (target: any, propertyKey: string) => void;
459
+ declare function Column(options?: ColumnCreateOptions): (target: any, propertyKey: string) => void;
460
+ declare function Description(description: string): (target: any) => void;
564
461
  declare function ForeignKey(tableName: string, columnName: string, options?: {
565
- type?: ColumnDataType;
462
+ type?: ColumnDataTypeSchema;
463
+ displayName?: string;
566
464
  name?: string;
567
- onDelete?: string;
568
- onUpdate?: string;
465
+ onDelete?: ForeignKeyAction;
466
+ onUpdate?: ForeignKeyAction;
569
467
  description?: string;
570
468
  nullable?: boolean;
571
469
  default?: any;
@@ -575,22 +473,25 @@ declare class BaseModel {
575
473
  private _extra;
576
474
  constructor(data?: Record<string, any>);
577
475
  protected static getTableName(): string;
476
+ protected static getDisplayName(): string;
578
477
  static getDescription(): string;
579
- protected static getIndexes(): Index[];
478
+ protected static getIndexes(): SyntropixDBIndex[];
580
479
  protected static getFields(): Record<string, Field>;
581
480
  protected static getPrimaryKeyName(): string;
582
481
  protected static getAssociations(): ForeignKeyField[];
583
482
  protected getFields(): Record<string, Field>;
584
483
  protected getTableName(): string;
484
+ protected getDisplayName(): string;
585
485
  protected getPrimaryKeyName(): string;
586
486
  protected getPrimaryKey(): Field | undefined;
587
487
  protected get client(): SyntropixClient;
588
- static createTable(_client?: SyntropixClient | null): Promise<TableCreateResponse>;
589
- static dropTable(_client?: SyntropixClient | null): Promise<any>;
590
- static renameTable(newName: string, _client?: SyntropixClient | null): Promise<any>;
591
- static truncateTable(_client?: SyntropixClient | null): Promise<any>;
592
- static create<T extends BaseModel>(this: new (data?: any) => T, data: Record<string, any>, _client?: SyntropixClient | null): Promise<any>;
593
- save(_client?: SyntropixClient | null): Promise<any>;
488
+ static createTable(client?: SyntropixClient): Promise<TableCreateResponse>;
489
+ static dropTable(client?: SyntropixClient): Promise<any>;
490
+ static renameTable(newName: string, client?: SyntropixClient): Promise<any>;
491
+ static truncateTable(client?: SyntropixClient): Promise<any>;
492
+ static getTableSchema(client?: SyntropixClient): Promise<TableSchemaResponse>;
493
+ static create<T extends BaseModel>(this: new (data?: any) => T, data: Record<string, any>, client?: SyntropixClient): Promise<any>;
494
+ save(client?: SyntropixClient): Promise<any>;
594
495
  remove(filter?: Filter, _client?: SyntropixClient | null): Promise<number>;
595
496
  static bulkCreate<T extends BaseModel>(this: new (data?: any) => T, datas: Record<string, any>[], batchSize?: number, _client?: SyntropixClient | null): Promise<number>;
596
497
  static update<T extends BaseModel>(this: new (data?: any) => T, filter: Filter, data: Record<string, any>, _client?: SyntropixClient | null): Promise<number>;
@@ -617,4 +518,75 @@ declare class BaseModel {
617
518
  toJSON(): Record<string, any>;
618
519
  }
619
520
 
620
- export { AND, type Aggregate, AggregateFunction, ArrayField, BETWEEN, BaseModel, BooleanField, CONTAINS, COSINE_DISTANCE, Client, ClientConfig, Column, ColumnDataType, DateField, DateTimeField, DecimalField, type DeleteData, type DeleteDataPayload, DoubleField, EQ, EQ_COL, EUCLIDEAN_DISTANCE, EnumField, Field, type Filter, type FilterGroup, type FilterItem, FilterOperation, FilterWrapper, ForeignKey, ForeignKeyAction, ForeignKeyField, GT, GTE, GTE_COL, GT_COL, type GroupBy, IN, IS_NOT_NULL, IS_NULL, I_LIKE, type Index, type Insert, type InsertData, IntegerField, type Join, JsonField, LIKE, LT, LTE, LTE_COL, LT_COL, MoneyField, NE, NEGATIVE_INNER_PRODUCT, NE_COL, NOT_IN, NOT_I_LIKE, NOT_LIKE, OR, OVERLAP, type Query, type QueryPayload, SIMILARITY, SIMILARITY_DISTANCE, STRICT_WORD_SIMILARITY, STRICT_WORD_SIMILARITY_DISTANCE, type SimilarityOptions, type Sort, SortType, StringField, SyntropixClient, SyntropixDBAccessType, type SyntropixDBTable, type SyntropixDBTableListItem, type TableAddColumn, type TableCreate, type TableDrop, type TableDropColumn, type TableGetList, type TableGetSchema, type TableModifyColumn, type TableRename, type TableTruncate, TextField, TimestampField, type Update, type UpdatePayload, UuidField, Value, VectorField, WORD_SIMILARITY, WORD_SIMILARITY_DISTANCE };
521
+ declare const ArrayDataType: {
522
+ readonly String: (maxLength: number) => StringType;
523
+ readonly Decimal: (precision: number, scale: number) => DecimalType;
524
+ readonly Text: "Text";
525
+ readonly Integer: "Integer";
526
+ readonly BigInteger: "BigInteger";
527
+ readonly Double: "Double";
528
+ readonly DateTime: "DateTime";
529
+ readonly Timestamp: "Timestamp";
530
+ readonly Date: "Date";
531
+ readonly Boolean: "Boolean";
532
+ readonly Money: (precision: number, scale: number) => MoneyType;
533
+ readonly Uuid: "Uuid";
534
+ readonly Enum: (name: string, variants: string[]) => EnumType;
535
+ readonly Json: "Json";
536
+ };
537
+ declare const ColumnDataType: {
538
+ readonly Integer: "Integer";
539
+ readonly String: (maxLength: number) => StringType;
540
+ readonly Text: "Text";
541
+ readonly Boolean: "Boolean";
542
+ readonly DateTime: "DateTime";
543
+ readonly Timestamp: "Timestamp";
544
+ readonly Date: "Date";
545
+ readonly Json: "Json";
546
+ readonly Uuid: "Uuid";
547
+ readonly Double: "Double";
548
+ readonly Vector: (dimensions: number) => VectorType;
549
+ readonly Array: (dataType: ArrayDataTypeSchema) => ArrayType;
550
+ readonly Enum: (name: string, variants: string[]) => EnumType;
551
+ readonly Money: (precision: number, scale: number) => MoneyType;
552
+ readonly Decimal: (precision: number, scale: number) => DecimalType;
553
+ };
554
+
555
+ declare const AND: (...conditions: FilterItem[]) => FilterGroup;
556
+ declare const OR: (...conditions: FilterGroup[]) => Filter;
557
+ declare const EQ: (field: string, value: any) => FilterItem;
558
+ declare const NE: (field: string, value: any) => FilterItem;
559
+ declare const GT: (field: string, value: any) => FilterItem;
560
+ declare const GTE: (field: string, value: any) => FilterItem;
561
+ declare const LT: (field: string, value: any) => FilterItem;
562
+ declare const LTE: (field: string, value: any) => FilterItem;
563
+ declare const IN: (field: string, values: any[]) => FilterItem;
564
+ declare const CONTAINS: (field: string, value: any) => FilterItem;
565
+ declare const OVERLAP: (field: string, value: any) => FilterItem;
566
+ declare const I_LIKE: (field: string, pattern: string) => FilterItem;
567
+ declare const NOT_I_LIKE: (field: string, pattern: string) => FilterItem;
568
+ declare const NOT_IN: (field: string, values: any[]) => FilterItem;
569
+ declare const LIKE: (field: string, pattern: string) => FilterItem;
570
+ declare const NOT_LIKE: (field: string, pattern: string) => FilterItem;
571
+ declare const IS_NULL: (field: string) => FilterItem;
572
+ declare const IS_NOT_NULL: (field: string) => FilterItem;
573
+ declare const BETWEEN: (field: string, min: any, max: any) => FilterItem;
574
+ declare const EQ_COL: (field: string, otherField: string) => FilterItem;
575
+ declare const NE_COL: (field: string, otherField: string) => FilterItem;
576
+ declare const GT_COL: (field: string, otherField: string) => FilterItem;
577
+ declare const GTE_COL: (field: string, otherField: string) => FilterItem;
578
+ declare const LT_COL: (field: string, otherField: string) => FilterItem;
579
+ declare const LTE_COL: (field: string, otherField: string) => FilterItem;
580
+ declare const SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
581
+ declare const SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
582
+ declare const WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
583
+ declare const WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
584
+ declare const STRICT_WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
585
+ declare const STRICT_WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
586
+ declare const EUCLIDEAN_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
587
+ declare const NEGATIVE_INNER_PRODUCT: (field: string, value: any, options: SimilarityOptions) => FilterItem;
588
+ declare const COSINE_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
589
+ declare const Value: (value: any) => any;
590
+ declare function FilterWrapper(filter: Filter | FilterGroup | FilterItem | undefined): Filter | undefined;
591
+
592
+ export { AND, AccessType, type Aggregate, AggregateFunction, ArrayDataType, type ArrayDataTypeSchema, ArrayField, type ArrayType, BETWEEN, BaseClient, BaseModel, BooleanField, CONTAINS, COSINE_DISTANCE, ClientConfig, Column, type ColumnCreateDto, type ColumnCreateOptions, type ColumnCreateResponse, ColumnDataType, type ColumnDataTypeSchema, DataClient, DateField, DateTimeField, DecimalField, type DecimalType, type DeleteDataDto, type DeleteDataPayloadDto, Description, DoubleField, EQ, EQ_COL, EUCLIDEAN_DISTANCE, EnumField, type EnumType, Field, type FieldOptions, type Filter, type FilterGroup, type FilterItem, FilterOperation, FilterWrapper, ForeignKey, ForeignKeyAction, ForeignKeyField, type ForeignKeyFieldOptions, GT, GTE, GTE_COL, GT_COL, type GroupBy, IN, IS_NOT_NULL, IS_NULL, I_LIKE, IndexType, type InsertDataDto, type InsertDto, IntegerField, type Join, JsonField, LIKE, LT, LTE, LTE_COL, LT_COL, MoneyField, type MoneyType, NE, NEGATIVE_INNER_PRODUCT, NE_COL, NOT_IN, NOT_I_LIKE, NOT_LIKE, OR, OVERLAP, type QueryDto, type QueryPayloadDto, SIMILARITY, SIMILARITY_DISTANCE, STRICT_WORD_SIMILARITY, STRICT_WORD_SIMILARITY_DISTANCE, type SimilarityOptions, type Sort, SortType, StringField, type StringType, SyntropixClient, type SyntropixDBColumn, type SyntropixDBForeignKey, type SyntropixDBIndex, type SyntropixDBTable, type SyntropixDBTableListItem, type SyntropixDBTableSchema, type SyntropixErrorResponse, type SyntropixResponse, type SyntropixSuccessResponse, type TableAddColumnDto, TableClient, type TableCreateDto, type TableCreateResponse, type TableDropColumnDto, type TableDropDto, type TableGetListDto, type TableGetSchemaDto, type TableListResponse, type TableModifyColumnDto, type TableRenameDto, type TableSchemaResponse, type TableTruncateDto, TextField, TimestampField, type UpdateDto, type UpdatePayloadDto, UuidField, Value, VectorField, type VectorType, WORD_SIMILARITY, WORD_SIMILARITY_DISTANCE };