@syntropix/database 0.0.3 → 0.0.5
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.d.ts +1 -1
- package/dist/core/dataClient.js +2 -1
- package/dist/core/tableClient.d.ts +1 -1
- package/dist/core/tableClient.js +2 -1
- package/dist/types/basemodel.d.ts +1 -1
- package/dist/types/filter.d.ts +8 -0
- package/dist/types/filter.js +24 -0
- package/dist/types/requests.d.ts +2 -41
- package/package.json +5 -2
- package/.editorconfig +0 -8
- package/.env +0 -2
- package/.gitattributes +0 -4
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -8
- package/.vscode/settings.json +0 -1
- package/.yarnrc.yml +0 -1
- package/eslint.config.mjs +0 -23
- package/examples/advanced-usage.ts +0 -214
- package/examples/tsconfig.json +0 -13
- package/examples/usage.ts +0 -94
- package/jest.config.ts +0 -9
- package/src/core/client.ts +0 -41
- package/src/core/config.ts +0 -29
- package/src/core/dataClient.ts +0 -78
- package/src/core/syntropix.ts +0 -27
- package/src/core/tableClient.ts +0 -86
- package/src/index.ts +0 -10
- package/src/types/basemodel.ts +0 -558
- package/src/types/common.ts +0 -83
- package/src/types/data-type.ts +0 -23
- package/src/types/dto/base.ts +0 -4
- package/src/types/dto/table.ts +0 -21
- package/src/types/field.ts +0 -277
- package/src/types/filter.ts +0 -281
- package/src/types/requests.ts +0 -91
- package/test.json +0 -48
- package/tests/basic.test.ts +0 -141
- package/tests/tsconfig.json +0 -8
- package/tsconfig.json +0 -18
package/src/core/dataClient.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { DeleteData, Insert, Query, Update } from '../types/requests';
|
|
2
|
-
import { Client } from './client';
|
|
3
|
-
import { ClientConfig } from './config';
|
|
4
|
-
|
|
5
|
-
export class DataClient {
|
|
6
|
-
private client: Client;
|
|
7
|
-
|
|
8
|
-
constructor(config: ClientConfig = new ClientConfig()) {
|
|
9
|
-
this.client = new Client(config);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async insertData(data: Insert): Promise<any> {
|
|
13
|
-
const response = await this.client.post('/insert', data);
|
|
14
|
-
if (response.status === 'success') {
|
|
15
|
-
return response.data;
|
|
16
|
-
}
|
|
17
|
-
throw new Error(response.message);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async insertOne(data: Insert): Promise<any> {
|
|
21
|
-
const response = await this.client.post('/insert/one', data);
|
|
22
|
-
if (response.status === 'success') {
|
|
23
|
-
return response.data;
|
|
24
|
-
}
|
|
25
|
-
throw new Error(response.message);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async updateByPrimaryKey(pk: string, data: Update): Promise<any> {
|
|
29
|
-
const response = await this.client.post(`/update/${pk}`, data);
|
|
30
|
-
if (response.status === 'success') {
|
|
31
|
-
return response.data;
|
|
32
|
-
}
|
|
33
|
-
throw new Error(response.message);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async queryOne(data: Query, model?: any): Promise<any> {
|
|
37
|
-
const response = await this.client.post('/query', { One: data });
|
|
38
|
-
if (response.status === 'success') {
|
|
39
|
-
const responseData = response.data;
|
|
40
|
-
if (model !== undefined) {
|
|
41
|
-
return new model(responseData);
|
|
42
|
-
}
|
|
43
|
-
return responseData;
|
|
44
|
-
}
|
|
45
|
-
throw new Error(response.message);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async queryMany(data: Query, model?: any): Promise<any> {
|
|
49
|
-
const response = await this.client.post('/query', { Many: data });
|
|
50
|
-
if (response.status === 'success') {
|
|
51
|
-
const responseData = response.data;
|
|
52
|
-
if (model !== undefined) {
|
|
53
|
-
// In TypeScript, we would typically use a validation library or manual validation
|
|
54
|
-
// For now, we'll return the data as-is, but in a real implementation you might want to use
|
|
55
|
-
// a library like class-validator or zod for validation
|
|
56
|
-
return responseData.map((item: any) => new model(item));
|
|
57
|
-
}
|
|
58
|
-
return responseData;
|
|
59
|
-
}
|
|
60
|
-
throw new Error(response.message);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async updateData(data: Update): Promise<any> {
|
|
64
|
-
const response = await this.client.post('/update', data);
|
|
65
|
-
if (response.status === 'success') {
|
|
66
|
-
return response.data;
|
|
67
|
-
}
|
|
68
|
-
throw new Error(response.message);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async deleteData(data: DeleteData): Promise<any> {
|
|
72
|
-
const response = await this.client.post('/delete', data);
|
|
73
|
-
if (response.status === 'success') {
|
|
74
|
-
return response.data;
|
|
75
|
-
}
|
|
76
|
-
throw new Error(response.message);
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/core/syntropix.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ClientConfig } from './config';
|
|
2
|
-
import { DataClient } from './dataClient';
|
|
3
|
-
import { TableClient } from './tableClient';
|
|
4
|
-
|
|
5
|
-
export class SyntropixClient {
|
|
6
|
-
private config: ClientConfig;
|
|
7
|
-
private _tableClient?: TableClient;
|
|
8
|
-
private _dataClient?: DataClient;
|
|
9
|
-
|
|
10
|
-
constructor(config: ClientConfig) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get table(): TableClient {
|
|
15
|
-
if (!this._tableClient) {
|
|
16
|
-
this._tableClient = new TableClient(this.config);
|
|
17
|
-
}
|
|
18
|
-
return this._tableClient;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get data(): DataClient {
|
|
22
|
-
if (!this._dataClient) {
|
|
23
|
-
this._dataClient = new DataClient(this.config);
|
|
24
|
-
}
|
|
25
|
-
return this._dataClient;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/core/tableClient.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { TableCreateResponse } from '@/types/dto/table';
|
|
2
|
-
import { SyntropixDBTable } from '../types/common';
|
|
3
|
-
import {
|
|
4
|
-
TableAddColumn,
|
|
5
|
-
TableCreate,
|
|
6
|
-
TableDrop,
|
|
7
|
-
TableDropColumn,
|
|
8
|
-
TableGetSchema,
|
|
9
|
-
TableModifyColumn,
|
|
10
|
-
TableRename,
|
|
11
|
-
TableTruncate,
|
|
12
|
-
} from '../types/requests';
|
|
13
|
-
import { Client } from './client';
|
|
14
|
-
import { ClientConfig } from './config';
|
|
15
|
-
|
|
16
|
-
export class TableClient {
|
|
17
|
-
private client: Client;
|
|
18
|
-
|
|
19
|
-
constructor(config: ClientConfig = new ClientConfig()) {
|
|
20
|
-
this.client = new Client(config);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async createTable(data: TableCreate): Promise<TableCreateResponse> {
|
|
24
|
-
const response = await this.client.post('/table/create', data);
|
|
25
|
-
if (response.status === 'success') {
|
|
26
|
-
return response.data;
|
|
27
|
-
}
|
|
28
|
-
throw new Error(response.message);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async dropTable(data: TableDrop): Promise<any> {
|
|
32
|
-
const response = await this.client.post('/table/drop', data);
|
|
33
|
-
if (response.status === 'success') {
|
|
34
|
-
return response.data;
|
|
35
|
-
}
|
|
36
|
-
throw new Error(response.message);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async renameTable(data: TableRename): Promise<any> {
|
|
40
|
-
const response = await this.client.post('/table/rename', data);
|
|
41
|
-
if (response.status === 'success') {
|
|
42
|
-
return response.data;
|
|
43
|
-
}
|
|
44
|
-
throw new Error(response.message);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async truncateTable(data: TableTruncate): Promise<any> {
|
|
48
|
-
const response = await this.client.post('/table/truncate', data);
|
|
49
|
-
if (response.status === 'success') {
|
|
50
|
-
return response.data;
|
|
51
|
-
}
|
|
52
|
-
throw new Error(response.message);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async addColumn(data: TableAddColumn): Promise<any> {
|
|
56
|
-
const response = await this.client.post('/table/column/add', data);
|
|
57
|
-
if (response.status === 'success') {
|
|
58
|
-
return response.data;
|
|
59
|
-
}
|
|
60
|
-
throw new Error(response.message);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async dropColumn(data: TableDropColumn): Promise<any> {
|
|
64
|
-
const response = await this.client.post('/table/column/drop', data);
|
|
65
|
-
if (response.status === 'success') {
|
|
66
|
-
return response.data;
|
|
67
|
-
}
|
|
68
|
-
throw new Error(response.message);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async modifyColumn(data: TableModifyColumn): Promise<any> {
|
|
72
|
-
const response = await this.client.post('/table/column/modify', data);
|
|
73
|
-
if (response.status === 'success') {
|
|
74
|
-
return response.data;
|
|
75
|
-
}
|
|
76
|
-
throw new Error(response.message);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async getTableSchema(data: TableGetSchema): Promise<SyntropixDBTable> {
|
|
80
|
-
const response = await this.client.post('/table/schema', data);
|
|
81
|
-
if (response.status === 'success') {
|
|
82
|
-
return response.data as SyntropixDBTable;
|
|
83
|
-
}
|
|
84
|
-
throw new Error(response.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Main entry point for the SDK
|
|
2
|
-
export { Client } from './core/client';
|
|
3
|
-
export * from './core/config';
|
|
4
|
-
export { SyntropixClient } from './core/syntropix';
|
|
5
|
-
export { BaseModel, Column, ForeignKey } from './types/basemodel';
|
|
6
|
-
export * from './types/common';
|
|
7
|
-
export { DataType } from './types/data-type';
|
|
8
|
-
export * from './types/field';
|
|
9
|
-
export * from './types/filter';
|
|
10
|
-
export * from './types/requests';
|