@syntropix/database 0.0.4 → 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.
Files changed (49) hide show
  1. package/dist/core/dataClient.js +3 -0
  2. package/dist/core/syntropix.d.ts +1 -1
  3. package/dist/core/syntropix.js +2 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/types/basemodel.d.ts +4 -3
  7. package/dist/types/basemodel.js +36 -35
  8. package/dist/types/common.d.ts +32 -28
  9. package/dist/types/common.js +11 -12
  10. package/dist/types/data-type.d.ts +48 -38
  11. package/dist/types/data-type.js +17 -18
  12. package/dist/types/dto/table.d.ts +6 -6
  13. package/dist/types/field.d.ts +60 -41
  14. package/dist/types/field.js +35 -32
  15. package/dist/types/filter.d.ts +43 -44
  16. package/dist/types/filter.js +56 -41
  17. package/dist/types/requests.d.ts +25 -14
  18. package/dist/types/requests.js +6 -1
  19. package/package.json +5 -2
  20. package/.editorconfig +0 -8
  21. package/.env +0 -2
  22. package/.gitattributes +0 -4
  23. package/.husky/pre-commit +0 -1
  24. package/.prettierrc +0 -8
  25. package/.vscode/settings.json +0 -1
  26. package/.yarnrc.yml +0 -1
  27. package/eslint.config.mjs +0 -23
  28. package/examples/advanced-usage.ts +0 -214
  29. package/examples/tsconfig.json +0 -13
  30. package/examples/usage.ts +0 -94
  31. package/jest.config.ts +0 -9
  32. package/src/core/client.ts +0 -41
  33. package/src/core/config.ts +0 -29
  34. package/src/core/dataClient.ts +0 -78
  35. package/src/core/syntropix.ts +0 -27
  36. package/src/core/tableClient.ts +0 -86
  37. package/src/index.ts +0 -10
  38. package/src/types/basemodel.ts +0 -558
  39. package/src/types/common.ts +0 -83
  40. package/src/types/data-type.ts +0 -23
  41. package/src/types/dto/base.ts +0 -4
  42. package/src/types/dto/table.ts +0 -21
  43. package/src/types/field.ts +0 -277
  44. package/src/types/filter.ts +0 -281
  45. package/src/types/requests.ts +0 -91
  46. package/test.json +0 -48
  47. package/tests/basic.test.ts +0 -141
  48. package/tests/tsconfig.json +0 -8
  49. package/tsconfig.json +0 -18
@@ -1,20 +1,23 @@
1
1
  import { Column, ForeignKeyAction } from './common';
2
2
  import { ColumnType } from './data-type';
3
+ import { SyntropixDBAccessType } from './requests';
3
4
  export declare abstract class Field {
4
5
  name: string;
5
6
  description: string;
6
- column_type: ColumnType;
7
- is_primary_key: boolean;
8
- is_nullable: boolean;
9
- auto_increment: boolean;
7
+ columnType: ColumnType;
8
+ isPrimaryKey: boolean;
9
+ isNullable: boolean;
10
+ autoIncrement: boolean;
10
11
  default?: any;
12
+ defaultAccess?: SyntropixDBAccessType;
11
13
  constructor(column_type: ColumnType, options?: {
12
14
  name?: string;
13
15
  description?: string;
14
- is_primary_key?: boolean;
15
- is_nullable?: boolean;
16
- auto_increment?: boolean;
16
+ isPrimaryKey?: boolean;
17
+ isNullable?: boolean;
18
+ autoIncrement?: boolean;
17
19
  default?: any;
20
+ defaultAccess?: SyntropixDBAccessType;
18
21
  });
19
22
  into(): Column;
20
23
  }
@@ -23,133 +26,149 @@ export declare class ForeignKeyField extends Field {
23
26
  columnName: string;
24
27
  onDelete: ForeignKeyAction;
25
28
  onUpdate: ForeignKeyAction;
26
- constructor(column_type: ColumnType, tableName: string, columnName: string, options?: {
29
+ constructor(columnType: ColumnType, tableName: string, columnName: string, options?: {
27
30
  onDelete?: ForeignKeyAction;
28
31
  onUpdate?: ForeignKeyAction;
29
32
  description?: string;
30
- is_primary_key?: boolean;
31
- is_nullable?: boolean;
33
+ isPrimaryKey?: boolean;
34
+ isNullable?: boolean;
32
35
  default?: any;
36
+ defaultAccess?: SyntropixDBAccessType;
33
37
  });
34
38
  }
35
39
  export declare class StringField extends Field {
36
40
  constructor(maxLength: number, options?: {
37
41
  description?: string;
38
- is_primary_key?: boolean;
39
- is_nullable?: boolean;
42
+ isPrimaryKey?: boolean;
43
+ isNullable?: boolean;
40
44
  default?: string;
45
+ defaultAccess?: SyntropixDBAccessType;
41
46
  });
42
47
  }
43
48
  export declare class TextField extends Field {
44
49
  constructor(options?: {
45
50
  description?: string;
46
- is_primary_key?: boolean;
47
- is_nullable?: boolean;
51
+ isPrimaryKey?: boolean;
52
+ isNullable?: boolean;
48
53
  default?: string;
54
+ defaultAccess?: SyntropixDBAccessType;
49
55
  });
50
56
  }
51
57
  export declare class IntegerField extends Field {
52
58
  constructor(options?: {
53
59
  description?: string;
54
- is_primary_key?: boolean;
55
- is_nullable?: boolean;
56
- auto_increment?: boolean;
60
+ isPrimaryKey?: boolean;
61
+ isNullable?: boolean;
62
+ autoIncrement?: boolean;
57
63
  default?: number;
64
+ defaultAccess?: SyntropixDBAccessType;
58
65
  });
59
66
  }
60
67
  export declare class BooleanField extends Field {
61
68
  constructor(options?: {
62
69
  description?: string;
63
- is_primary_key?: boolean;
64
- is_nullable?: boolean;
70
+ isPrimaryKey?: boolean;
71
+ isNullable?: boolean;
65
72
  default?: boolean;
73
+ defaultAccess?: SyntropixDBAccessType;
66
74
  });
67
75
  }
68
76
  export declare class DateTimeField extends Field {
69
77
  constructor(options?: {
70
78
  description?: string;
71
- is_primary_key?: boolean;
72
- is_nullable?: boolean;
79
+ isPrimaryKey?: boolean;
80
+ isNullable?: boolean;
73
81
  default?: Date;
82
+ defaultAccess?: SyntropixDBAccessType;
74
83
  });
75
84
  }
76
85
  export declare class TimestampField extends Field {
77
86
  constructor(options?: {
78
87
  description?: string;
79
- is_primary_key?: boolean;
80
- is_nullable?: boolean;
88
+ isPrimaryKey?: boolean;
89
+ isNullable?: boolean;
81
90
  default?: Date;
91
+ defaultAccess?: SyntropixDBAccessType;
82
92
  });
83
93
  }
84
94
  export declare class DateField extends Field {
85
95
  constructor(options?: {
86
96
  description?: string;
87
- is_primary_key?: boolean;
88
- is_nullable?: boolean;
97
+ isPrimaryKey?: boolean;
98
+ isNullable?: boolean;
89
99
  default?: Date;
100
+ defaultAccess?: SyntropixDBAccessType;
90
101
  });
91
102
  }
92
103
  export declare class JsonField extends Field {
93
104
  constructor(options?: {
94
105
  description?: string;
95
- is_primary_key?: boolean;
96
- is_nullable?: boolean;
106
+ isPrimaryKey?: boolean;
107
+ isNullable?: boolean;
97
108
  default?: Record<string, any>;
109
+ defaultAccess?: SyntropixDBAccessType;
98
110
  });
99
111
  }
100
112
  export declare class UuidField extends Field {
101
113
  constructor(options?: {
102
114
  description?: string;
103
- is_primary_key?: boolean;
104
- is_nullable?: boolean;
115
+ isPrimaryKey?: boolean;
116
+ isNullable?: boolean;
105
117
  default?: string;
118
+ defaultAccess?: SyntropixDBAccessType;
106
119
  });
107
120
  }
108
121
  export declare class VectorField extends Field {
109
122
  constructor(dimensions: number, options?: {
110
123
  description?: string;
111
- is_primary_key?: boolean;
112
- is_nullable?: boolean;
124
+ isPrimaryKey?: boolean;
125
+ isNullable?: boolean;
113
126
  default?: number[];
127
+ defaultAccess?: SyntropixDBAccessType;
114
128
  });
115
129
  }
116
130
  export declare class ArrayField extends Field {
117
131
  constructor(dataType: ColumnType, options?: {
118
132
  description?: string;
119
- is_primary_key?: boolean;
120
- is_nullable?: boolean;
133
+ isPrimaryKey?: boolean;
134
+ isNullable?: boolean;
121
135
  default?: any[];
136
+ defaultAccess?: SyntropixDBAccessType;
122
137
  });
123
138
  }
124
139
  export declare class EnumField extends Field {
125
140
  constructor(name: string, variants: string[], options?: {
126
141
  description?: string;
127
- is_primary_key?: boolean;
128
- is_nullable?: boolean;
142
+ isPrimaryKey?: boolean;
143
+ isNullable?: boolean;
129
144
  default?: string;
145
+ defaultAccess?: SyntropixDBAccessType;
130
146
  });
131
147
  }
132
148
  export declare class MoneyField extends Field {
133
149
  constructor(precision: number, scale: number, options?: {
134
150
  description?: string;
135
- is_primary_key?: boolean;
136
- is_nullable?: boolean;
151
+ isPrimaryKey?: boolean;
152
+ isNullable?: boolean;
137
153
  default?: number;
154
+ defaultAccess?: SyntropixDBAccessType;
138
155
  });
139
156
  }
140
157
  export declare class DecimalField extends Field {
141
158
  constructor(precision: number, scale: number, options?: {
142
159
  description?: string;
143
- is_primary_key?: boolean;
144
- is_nullable?: boolean;
160
+ isPrimaryKey?: boolean;
161
+ isNullable?: boolean;
145
162
  default?: number;
163
+ defaultAccess?: SyntropixDBAccessType;
146
164
  });
147
165
  }
148
166
  export declare class DoubleField extends Field {
149
167
  constructor(options?: {
150
168
  description?: string;
151
- is_primary_key?: boolean;
152
- is_nullable?: boolean;
169
+ isPrimaryKey?: boolean;
170
+ isNullable?: boolean;
153
171
  default?: number;
172
+ defaultAccess?: SyntropixDBAccessType;
154
173
  });
155
174
  }
@@ -1,32 +1,35 @@
1
1
  // Field definitions for ORM
2
2
  import { ForeignKeyAction } from './common';
3
- import { DataType } from './data-type';
3
+ import { ColumnType } from './data-type';
4
4
  export class Field {
5
5
  name = '';
6
6
  description = '';
7
- column_type;
8
- is_primary_key = false;
9
- is_nullable = false;
10
- auto_increment = false;
7
+ columnType;
8
+ isPrimaryKey = false;
9
+ isNullable = false;
10
+ autoIncrement = false;
11
11
  default;
12
+ defaultAccess;
12
13
  constructor(column_type, options = {}) {
13
- this.column_type = column_type;
14
+ this.columnType = column_type;
14
15
  this.name = options.name?.toLowerCase() || '';
15
16
  this.description = options.description || '';
16
- this.is_primary_key = options.is_primary_key || false;
17
- this.is_nullable = options.is_nullable || false;
18
- this.auto_increment = options.auto_increment || false;
17
+ this.isPrimaryKey = options.isPrimaryKey || false;
18
+ this.isNullable = options.isNullable || false;
19
+ this.autoIncrement = options.autoIncrement || false;
19
20
  this.default = options.default;
21
+ this.defaultAccess = options.defaultAccess;
20
22
  }
21
23
  into() {
22
24
  return {
23
25
  name: this.name,
24
- column_type: this.column_type,
26
+ columnType: this.columnType,
25
27
  description: this.description,
26
- is_primary_key: this.is_primary_key,
27
- is_nullable: this.is_nullable,
28
- auto_increment: this.auto_increment,
28
+ isPrimaryKey: this.isPrimaryKey,
29
+ isNullable: this.isNullable,
30
+ autoIncrement: this.autoIncrement,
29
31
  default: this.default,
32
+ defaultAccess: this.defaultAccess,
30
33
  };
31
34
  }
32
35
  }
@@ -35,86 +38,86 @@ export class ForeignKeyField extends Field {
35
38
  columnName;
36
39
  onDelete;
37
40
  onUpdate;
38
- constructor(column_type, tableName, columnName, options = {}) {
39
- super(column_type, options);
41
+ constructor(columnType, tableName, columnName, options = {}) {
42
+ super(columnType, options);
40
43
  this.tableName = tableName;
41
44
  this.columnName = columnName;
42
- this.onDelete = options.onDelete || ForeignKeyAction.CASCADE;
43
- this.onUpdate = options.onUpdate || ForeignKeyAction.CASCADE;
45
+ this.onDelete = options.onDelete || ForeignKeyAction.Cascade;
46
+ this.onUpdate = options.onUpdate || ForeignKeyAction.Cascade;
44
47
  }
45
48
  }
46
49
  export class StringField extends Field {
47
50
  constructor(maxLength, options = {}) {
48
- super(DataType.String(maxLength), options);
51
+ super(ColumnType.String(maxLength), options);
49
52
  }
50
53
  }
51
54
  export class TextField extends Field {
52
55
  constructor(options = {}) {
53
- super(DataType.Text, options);
56
+ super(ColumnType.Text, options);
54
57
  }
55
58
  }
56
59
  export class IntegerField extends Field {
57
60
  constructor(options = {}) {
58
- super(DataType.Integer, options);
61
+ super(ColumnType.Integer, options);
59
62
  }
60
63
  }
61
64
  export class BooleanField extends Field {
62
65
  constructor(options = {}) {
63
- super(DataType.Boolean, options);
66
+ super(ColumnType.Boolean, options);
64
67
  }
65
68
  }
66
69
  export class DateTimeField extends Field {
67
70
  constructor(options = {}) {
68
- super(DataType.DateTime, options);
71
+ super(ColumnType.DateTime, options);
69
72
  }
70
73
  }
71
74
  export class TimestampField extends Field {
72
75
  constructor(options = {}) {
73
- super(DataType.Timestamp, options);
76
+ super(ColumnType.Timestamp, options);
74
77
  }
75
78
  }
76
79
  export class DateField extends Field {
77
80
  constructor(options = {}) {
78
- super(DataType.Date, options);
81
+ super(ColumnType.Date, options);
79
82
  }
80
83
  }
81
84
  export class JsonField extends Field {
82
85
  constructor(options = {}) {
83
- super(DataType.Json, options);
86
+ super(ColumnType.Json, options);
84
87
  }
85
88
  }
86
89
  export class UuidField extends Field {
87
90
  constructor(options = {}) {
88
- super(DataType.Uuid, options);
91
+ super(ColumnType.Uuid, options);
89
92
  }
90
93
  }
91
94
  export class VectorField extends Field {
92
95
  constructor(dimensions, options = {}) {
93
- super(DataType.Vector(dimensions), options);
96
+ super(ColumnType.Vector(dimensions), options);
94
97
  }
95
98
  }
96
99
  export class ArrayField extends Field {
97
100
  constructor(dataType, options = {}) {
98
- super(DataType.Array(dataType), options);
101
+ super(ColumnType.Array(dataType), options);
99
102
  }
100
103
  }
101
104
  export class EnumField extends Field {
102
105
  constructor(name, variants, options = {}) {
103
- super(DataType.Enum(name, variants), options);
106
+ super(ColumnType.Enum(name, variants), options);
104
107
  }
105
108
  }
106
109
  export class MoneyField extends Field {
107
110
  constructor(precision, scale, options = {}) {
108
- super(DataType.Money(precision, scale), options);
111
+ super(ColumnType.Money(precision, scale), options);
109
112
  }
110
113
  }
111
114
  export class DecimalField extends Field {
112
115
  constructor(precision, scale, options = {}) {
113
- super(DataType.Decimal(precision, scale), options);
116
+ super(ColumnType.Decimal(precision, scale), options);
114
117
  }
115
118
  }
116
119
  export class DoubleField extends Field {
117
120
  constructor(options = {}) {
118
- super(DataType.Double, options);
121
+ super(ColumnType.Double, options);
119
122
  }
120
123
  }
@@ -1,6 +1,6 @@
1
1
  export declare enum SortType {
2
- DESCENDING = "DESCENDING",
3
- ASCENDING = "ASCENDING"
2
+ Descending = "Descending",
3
+ Ascending = "Ascending"
4
4
  }
5
5
  export interface SimilarityOptions {
6
6
  threshold: number;
@@ -35,49 +35,48 @@ export declare enum FilterOperation {
35
35
  NegativeInnerProduct = "NegativeInnerProduct",
36
36
  CosineDistance = "CosineDistance"
37
37
  }
38
- export interface SyntropixDBFilterItem {
38
+ export interface FilterItem {
39
39
  column: string;
40
40
  operator: FilterOperation;
41
- static_value?: any;
42
- column_value?: string;
43
- similarity_options?: SimilarityOptions;
41
+ staticValue?: any;
42
+ columnValue?: string;
43
+ simiarityOptions?: SimilarityOptions;
44
44
  }
45
- export type SyntropixDBFilterGroup = SyntropixDBFilterItem[];
46
- export type SyntropixDBFilter = SyntropixDBFilterGroup[];
47
- export type FilterCondition = SyntropixDBFilter;
48
- export type Filter = SyntropixDBFilter;
49
- export declare const AND: (...conditions: SyntropixDBFilterItem[]) => SyntropixDBFilterGroup;
50
- export declare const OR: (...conditions: SyntropixDBFilterGroup[]) => SyntropixDBFilter;
51
- export declare const EQ: (field: string, value: any) => SyntropixDBFilterItem;
52
- export declare const NE: (field: string, value: any) => SyntropixDBFilterItem;
53
- export declare const GT: (field: string, value: any) => SyntropixDBFilterItem;
54
- export declare const GTE: (field: string, value: any) => SyntropixDBFilterItem;
55
- export declare const LT: (field: string, value: any) => SyntropixDBFilterItem;
56
- export declare const LTE: (field: string, value: any) => SyntropixDBFilterItem;
57
- export declare const IN: (field: string, values: any[]) => SyntropixDBFilterItem;
58
- export declare const CONTAINS: (field: string, value: any) => SyntropixDBFilterItem;
59
- export declare const OVERLAP: (field: string, value: any) => SyntropixDBFilterItem;
60
- export declare const I_LIKE: (field: string, pattern: string) => SyntropixDBFilterItem;
61
- export declare const NOT_I_LIKE: (field: string, pattern: string) => SyntropixDBFilterItem;
62
- export declare const NOT_IN: (field: string, values: any[]) => SyntropixDBFilterItem;
63
- export declare const LIKE: (field: string, pattern: string) => SyntropixDBFilterItem;
64
- export declare const NOT_LIKE: (field: string, pattern: string) => SyntropixDBFilterItem;
65
- export declare const IS_NULL: (field: string) => SyntropixDBFilterItem;
66
- export declare const IS_NOT_NULL: (field: string) => SyntropixDBFilterItem;
67
- export declare const BETWEEN: (field: string, min: any, max: any) => SyntropixDBFilterItem;
68
- export declare const EQ_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
69
- export declare const NE_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
70
- export declare const GT_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
71
- export declare const GTE_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
72
- export declare const LT_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
73
- export declare const LTE_COL: (field: string, otherField: string) => SyntropixDBFilterItem;
74
- export declare const SIMILARITY: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
75
- export declare const SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
76
- export declare const WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
77
- export declare const WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
78
- export declare const STRICT_WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
79
- export declare const STRICT_WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
80
- export declare const EUCLIDEAN_DISTANCE: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
81
- export declare const NEGATIVE_INNER_PRODUCT: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
82
- export declare const COSINE_DISTANCE: (field: string, value: any, options: SimilarityOptions) => SyntropixDBFilterItem;
45
+ export type FilterGroup = FilterItem[];
46
+ export type Filter = FilterGroup[];
47
+ export declare const AND: (...conditions: FilterItem[]) => FilterGroup;
48
+ export declare const OR: (...conditions: FilterGroup[]) => Filter;
49
+ export declare const EQ: (field: string, value: any) => FilterItem;
50
+ export declare const NE: (field: string, value: any) => FilterItem;
51
+ export declare const GT: (field: string, value: any) => FilterItem;
52
+ export declare const GTE: (field: string, value: any) => FilterItem;
53
+ export declare const LT: (field: string, value: any) => FilterItem;
54
+ export declare const LTE: (field: string, value: any) => FilterItem;
55
+ export declare const IN: (field: string, values: any[]) => FilterItem;
56
+ export declare const CONTAINS: (field: string, value: any) => FilterItem;
57
+ export declare const OVERLAP: (field: string, value: any) => FilterItem;
58
+ export declare const I_LIKE: (field: string, pattern: string) => FilterItem;
59
+ export declare const NOT_I_LIKE: (field: string, pattern: string) => FilterItem;
60
+ export declare const NOT_IN: (field: string, values: any[]) => FilterItem;
61
+ export declare const LIKE: (field: string, pattern: string) => FilterItem;
62
+ export declare const NOT_LIKE: (field: string, pattern: string) => FilterItem;
63
+ export declare const IS_NULL: (field: string) => FilterItem;
64
+ export declare const IS_NOT_NULL: (field: string) => FilterItem;
65
+ export declare const BETWEEN: (field: string, min: any, max: any) => FilterItem;
66
+ export declare const EQ_COL: (field: string, otherField: string) => FilterItem;
67
+ export declare const NE_COL: (field: string, otherField: string) => FilterItem;
68
+ export declare const GT_COL: (field: string, otherField: string) => FilterItem;
69
+ export declare const GTE_COL: (field: string, otherField: string) => FilterItem;
70
+ export declare const LT_COL: (field: string, otherField: string) => FilterItem;
71
+ export declare const LTE_COL: (field: string, otherField: string) => FilterItem;
72
+ export declare const SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
73
+ export declare const SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
74
+ export declare const WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
75
+ export declare const WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
76
+ export declare const STRICT_WORD_SIMILARITY: (field: string, value: any, options: SimilarityOptions) => FilterItem;
77
+ export declare const STRICT_WORD_SIMILARITY_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
78
+ export declare const EUCLIDEAN_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
79
+ export declare const NEGATIVE_INNER_PRODUCT: (field: string, value: any, options: SimilarityOptions) => FilterItem;
80
+ export declare const COSINE_DISTANCE: (field: string, value: any, options: SimilarityOptions) => FilterItem;
83
81
  export declare const Value: (value: any) => any;
82
+ export declare function FilterWrapper(filter: Filter | FilterGroup | FilterItem | undefined): Filter | undefined;