@syntropix/database 0.0.2 → 0.0.3
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/.env +1 -1
- package/.vscode/settings.json +1 -8
- package/dist/core/dataClient.js +0 -5
- package/dist/core/tableClient.d.ts +2 -1
- package/dist/types/basemodel.d.ts +2 -1
- package/dist/types/dto/base.d.ts +4 -0
- package/dist/types/dto/base.js +1 -0
- package/dist/types/dto/table.d.ts +22 -0
- package/dist/types/dto/table.js +1 -0
- package/eslint.config.mjs +23 -23
- package/examples/tsconfig.json +13 -0
- package/examples/usage.ts +73 -52
- package/jest.config.ts +9 -10
- package/package.json +4 -4
- package/src/core/dataClient.ts +1 -6
- package/src/core/tableClient.ts +3 -2
- package/src/types/basemodel.ts +3 -2
- package/src/types/common.ts +83 -83
- package/src/types/dto/base.ts +4 -0
- package/src/types/dto/table.ts +21 -0
- package/src/types/filter.ts +28 -1
- package/src/types/requests.ts +2 -52
- package/tests/basic.test.ts +52 -34
- package/tests/tsconfig.json +8 -0
- package/tsconfig.json +18 -21
- package/examples/advanced-usage.d.ts +0 -42
- package/examples/advanced-usage.d.ts.map +0 -1
- package/examples/advanced-usage.js +0 -257
- package/examples/advanced-usage.js.map +0 -1
- package/examples/usage.d.ts +0 -11
- package/examples/usage.d.ts.map +0 -1
- package/examples/usage.js +0 -91
- package/examples/usage.js.map +0 -1
- package/tsconfig.base.json +0 -17
- package/tsconfig.test.json +0 -13
package/src/types/filter.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// Filter types for database queries
|
|
2
|
-
|
|
3
2
|
export enum SortType {
|
|
4
3
|
DESCENDING = 'DESCENDING',
|
|
5
4
|
ASCENDING = 'ASCENDING',
|
|
@@ -20,9 +19,13 @@ export enum FilterOperation {
|
|
|
20
19
|
NEQ = 'NEQ',
|
|
21
20
|
Between = 'Between',
|
|
22
21
|
In = 'In',
|
|
22
|
+
Contains = 'Contains',
|
|
23
|
+
Overlap = 'Overlap',
|
|
23
24
|
NotIn = 'NotIn',
|
|
24
25
|
Like = 'Like',
|
|
25
26
|
NotLike = 'NotLike',
|
|
27
|
+
ILike = 'ILike',
|
|
28
|
+
NotILike = 'NotILike',
|
|
26
29
|
IsNull = 'IsNull',
|
|
27
30
|
IsNotNull = 'IsNotNull',
|
|
28
31
|
Similarity = 'Similarity',
|
|
@@ -99,6 +102,30 @@ export const IN = (field: string, values: any[]): SyntropixDBFilterItem => ({
|
|
|
99
102
|
static_value: values,
|
|
100
103
|
});
|
|
101
104
|
|
|
105
|
+
export const CONTAINS = (field: string, value: any): SyntropixDBFilterItem => ({
|
|
106
|
+
column: field,
|
|
107
|
+
operator: FilterOperation.Contains,
|
|
108
|
+
static_value: value,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const OVERLAP = (field: string, value: any): SyntropixDBFilterItem => ({
|
|
112
|
+
column: field,
|
|
113
|
+
operator: FilterOperation.Overlap,
|
|
114
|
+
static_value: value,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const I_LIKE = (field: string, pattern: string): SyntropixDBFilterItem => ({
|
|
118
|
+
column: field,
|
|
119
|
+
operator: FilterOperation.ILike,
|
|
120
|
+
static_value: pattern,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export const NOT_I_LIKE = (field: string, pattern: string): SyntropixDBFilterItem => ({
|
|
124
|
+
column: field,
|
|
125
|
+
operator: FilterOperation.NotILike,
|
|
126
|
+
static_value: pattern,
|
|
127
|
+
});
|
|
128
|
+
|
|
102
129
|
export const NOT_IN = (field: string, values: any[]): SyntropixDBFilterItem => ({
|
|
103
130
|
column: field,
|
|
104
131
|
operator: FilterOperation.NotIn,
|
package/src/types/requests.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Request types for database operations
|
|
2
2
|
import { Aggregate, Column, ForeignKey, GroupBy, Index, Join, Sort } from './common';
|
|
3
|
-
import { Filter
|
|
3
|
+
import { Filter } from './filter';
|
|
4
4
|
|
|
5
5
|
// Table operations
|
|
6
6
|
export interface TableCreate {
|
|
@@ -76,7 +76,7 @@ export interface DeleteData {
|
|
|
76
76
|
|
|
77
77
|
export interface QueryPayload {
|
|
78
78
|
filter?: Filter;
|
|
79
|
-
sort?: Sort;
|
|
79
|
+
sort?: Sort[];
|
|
80
80
|
aggregate?: Aggregate[];
|
|
81
81
|
join?: Join[];
|
|
82
82
|
limit?: number;
|
|
@@ -89,53 +89,3 @@ export interface Query {
|
|
|
89
89
|
table_name: string;
|
|
90
90
|
query: QueryPayload;
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
// Rust-compatible type definitions
|
|
94
|
-
export interface SyntropixDBSortItem {
|
|
95
|
-
column: string;
|
|
96
|
-
direction: SortType;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export type SyntropixDBSort = SyntropixDBSortItem[];
|
|
100
|
-
|
|
101
|
-
export interface SyntropixDBJoin {
|
|
102
|
-
table: string;
|
|
103
|
-
on: string;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface SyntropixDBAggregate {
|
|
107
|
-
function: string;
|
|
108
|
-
column: string;
|
|
109
|
-
alias: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type SyntropixDBGroupBy = string[];
|
|
113
|
-
|
|
114
|
-
export type SyntropixDBDistinct = string[];
|
|
115
|
-
|
|
116
|
-
export interface SyntropixDBQuery {
|
|
117
|
-
filter: SyntropixDBFilter;
|
|
118
|
-
sort?: SyntropixDBSort;
|
|
119
|
-
limit?: number;
|
|
120
|
-
offset?: number;
|
|
121
|
-
select?: string[];
|
|
122
|
-
join?: SyntropixDBJoin[];
|
|
123
|
-
aggregate?: SyntropixDBAggregate[];
|
|
124
|
-
group_by?: SyntropixDBGroupBy;
|
|
125
|
-
distinct?: SyntropixDBDistinct;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface SyntropixDBInsert {
|
|
129
|
-
columns: string[];
|
|
130
|
-
values: any[][];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface SyntropixDBUpdate {
|
|
134
|
-
filter: SyntropixDBFilter;
|
|
135
|
-
columns: string[];
|
|
136
|
-
values: any[];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface SyntropixDBDelete {
|
|
140
|
-
filter: SyntropixDBFilter;
|
|
141
|
-
}
|
package/tests/basic.test.ts
CHANGED
|
@@ -1,57 +1,73 @@
|
|
|
1
|
-
// Jest tests for BaseModel ORM
|
|
2
1
|
import { BaseModel, Column } from '@/types/basemodel';
|
|
3
2
|
import { AND, EQ, OR } from '@/types/filter';
|
|
3
|
+
|
|
4
4
|
import 'dotenv/config';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const getRandomString = () => {
|
|
7
|
+
return Math.random().toString(36).substring(2, 15);
|
|
8
|
+
};
|
|
9
|
+
|
|
7
10
|
class User extends BaseModel {
|
|
8
|
-
static tableName =
|
|
11
|
+
static tableName = `test_users_${getRandomString()}`;
|
|
12
|
+
|
|
13
|
+
@Column({ type: 'Integer', primary: true, auto_increment: true })
|
|
14
|
+
declare id: number;
|
|
15
|
+
|
|
16
|
+
@Column()
|
|
17
|
+
declare email: string;
|
|
18
|
+
|
|
19
|
+
@Column({ name: 'full_name' })
|
|
20
|
+
declare fullName: string;
|
|
9
21
|
|
|
10
|
-
@Column({ type: '
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@Column({ type: '
|
|
14
|
-
|
|
22
|
+
@Column({ type: 'Json', nullable: true })
|
|
23
|
+
declare profile: any;
|
|
24
|
+
|
|
25
|
+
@Column({ type: 'Boolean', name: 'is_active' })
|
|
26
|
+
declare isActive: boolean;
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
describe('BaseModel ORM', () => {
|
|
18
30
|
beforeAll(async () => {
|
|
19
|
-
// Create table before running tests
|
|
20
31
|
await User.createTable();
|
|
21
32
|
});
|
|
22
33
|
|
|
23
34
|
describe('User CRUD Operations', () => {
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
let userId: number;
|
|
36
|
+
let userEmail: string;
|
|
37
|
+
let userFullName: string;
|
|
38
|
+
|
|
39
|
+
test('should create a user', async () => {
|
|
40
|
+
const randomValue = getRandomString();
|
|
41
|
+
userEmail = `user${randomValue}@example.com`;
|
|
42
|
+
userFullName = `User ${randomValue}`;
|
|
43
|
+
const userCreateResp = await User.create({
|
|
44
|
+
email: userEmail,
|
|
45
|
+
fullName: userFullName,
|
|
31
46
|
isActive: true,
|
|
32
47
|
});
|
|
33
48
|
|
|
34
|
-
expect(
|
|
35
|
-
expect(
|
|
36
|
-
|
|
37
|
-
expect(createdUser.isActive).toBe(true);
|
|
49
|
+
expect(userCreateResp).toBeDefined();
|
|
50
|
+
expect(userCreateResp.pk).toBeDefined();
|
|
51
|
+
userId = userCreateResp.pk;
|
|
38
52
|
});
|
|
39
53
|
|
|
40
|
-
test('should retrieve
|
|
41
|
-
const user = await User.get(OR(AND(EQ('
|
|
42
|
-
|
|
54
|
+
test('should retrieve the created user by id', async () => {
|
|
55
|
+
const user = await User.get(OR(AND(EQ('id', userId))));
|
|
43
56
|
expect(user).toBeDefined();
|
|
44
|
-
expect(user.email).toBe(
|
|
45
|
-
expect(user.fullName).toBe(
|
|
57
|
+
expect(user.email).toBe(userEmail);
|
|
58
|
+
expect(user.fullName).toBe(userFullName);
|
|
59
|
+
expect(user.isActive).toBe(true);
|
|
60
|
+
expect(user.profile).toBeNull();
|
|
46
61
|
});
|
|
47
62
|
|
|
48
63
|
test('should update a user', async () => {
|
|
49
|
-
const user = await User.get(OR(AND(EQ('
|
|
50
|
-
|
|
64
|
+
const user = await User.get(OR(AND(EQ('id', userId))));
|
|
65
|
+
userFullName = `User ${getRandomString()}`;
|
|
66
|
+
user.fullName = userFullName;
|
|
51
67
|
await user.save();
|
|
52
68
|
|
|
53
|
-
const updatedUser = await User.get(OR(AND(EQ('
|
|
54
|
-
expect(updatedUser.fullName).toBe(
|
|
69
|
+
const updatedUser = await User.get(OR(AND(EQ('id', userId))));
|
|
70
|
+
expect(updatedUser.fullName).toBe(userFullName);
|
|
55
71
|
});
|
|
56
72
|
|
|
57
73
|
test('should filter users by active status', async () => {
|
|
@@ -78,11 +94,11 @@ describe('BaseModel ORM', () => {
|
|
|
78
94
|
});
|
|
79
95
|
|
|
80
96
|
test('should delete a user', async () => {
|
|
81
|
-
const user = await User.get(OR(AND(EQ('
|
|
97
|
+
const user = await User.get(OR(AND(EQ('id', userId))));
|
|
82
98
|
await user.remove();
|
|
83
99
|
|
|
84
100
|
// Verify user is deleted (this might throw or return null depending on implementation)
|
|
85
|
-
await expect(User.get(OR(AND(EQ('
|
|
101
|
+
await expect(User.get(OR(AND(EQ('id', userId))))).rejects.toThrow();
|
|
86
102
|
});
|
|
87
103
|
});
|
|
88
104
|
|
|
@@ -90,13 +106,11 @@ describe('BaseModel ORM', () => {
|
|
|
90
106
|
test('should bulk create multiple users', async () => {
|
|
91
107
|
const users = await User.bulkCreate([
|
|
92
108
|
{
|
|
93
|
-
id: 2,
|
|
94
109
|
email: 'user2@example.com',
|
|
95
110
|
fullName: 'User 2',
|
|
96
111
|
isActive: true,
|
|
97
112
|
},
|
|
98
113
|
{
|
|
99
|
-
id: 3,
|
|
100
114
|
email: 'user3@example.com',
|
|
101
115
|
fullName: 'User 3',
|
|
102
116
|
isActive: false,
|
|
@@ -104,7 +118,7 @@ describe('BaseModel ORM', () => {
|
|
|
104
118
|
]);
|
|
105
119
|
|
|
106
120
|
expect(users).toBeDefined();
|
|
107
|
-
expect(
|
|
121
|
+
expect(users).toBe(2);
|
|
108
122
|
});
|
|
109
123
|
|
|
110
124
|
test('should retrieve bulk created users', async () => {
|
|
@@ -120,4 +134,8 @@ describe('BaseModel ORM', () => {
|
|
|
120
134
|
expect(user3.isActive).toBe(false);
|
|
121
135
|
});
|
|
122
136
|
});
|
|
137
|
+
|
|
138
|
+
afterAll(async () => {
|
|
139
|
+
await User.dropTable();
|
|
140
|
+
});
|
|
123
141
|
});
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"paths": {
|
|
12
|
+
"@/*": ["src/*"]
|
|
13
|
+
},
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
"declaration": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { BaseModel } from '../src/types/basemodel';
|
|
3
|
-
export declare class CompanyGroup extends BaseModel {
|
|
4
|
-
static tableName: string;
|
|
5
|
-
static description: string;
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class CompanyGroupMember extends BaseModel {
|
|
11
|
-
static tableName: string;
|
|
12
|
-
static description: string;
|
|
13
|
-
id: number;
|
|
14
|
-
groupId: number;
|
|
15
|
-
memberId: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class CompanyMember extends BaseModel {
|
|
18
|
-
static tableName: string;
|
|
19
|
-
static description: string;
|
|
20
|
-
id: number;
|
|
21
|
-
userId: string;
|
|
22
|
-
firstName: string;
|
|
23
|
-
lastName: string;
|
|
24
|
-
middleName: string | null;
|
|
25
|
-
email: string;
|
|
26
|
-
avatar: string | null;
|
|
27
|
-
bio: string;
|
|
28
|
-
role: 'admin' | 'user';
|
|
29
|
-
personalKey: string;
|
|
30
|
-
}
|
|
31
|
-
export declare class CompanyApiKey extends BaseModel {
|
|
32
|
-
static tableName: string;
|
|
33
|
-
static description: string;
|
|
34
|
-
id: number;
|
|
35
|
-
name: string;
|
|
36
|
-
description: string | null;
|
|
37
|
-
key: string;
|
|
38
|
-
createdAt: Date | string;
|
|
39
|
-
isPersonal: boolean;
|
|
40
|
-
createdBy: number;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=advanced-usage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-usage.d.ts","sourceRoot":"","sources":["advanced-usage.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAsB,MAAM,wBAAwB,CAAC;AAGvE,qBAAa,YAAa,SAAQ,SAAS;IACzC,MAAM,CAAC,SAAS,SAA8B;IAC9C,MAAM,CAAC,WAAW,SAAoB;IAQtC,EAAE,EAAG,MAAM,CAAC;IAGZ,IAAI,EAAG,MAAM,CAAC;IAGd,WAAW,EAAG,MAAM,CAAC;CACtB;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,MAAM,CAAC,SAAS,SAAqC;IACrD,MAAM,CAAC,WAAW,SAA2B;IAQ7C,EAAE,EAAG,MAAM,CAAC;IAGZ,OAAO,EAAG,MAAM,CAAC;IAGjB,QAAQ,EAAG,MAAM,CAAC;CACnB;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,CAAC,SAAS,SAA+B;IAC/C,MAAM,CAAC,WAAW,SAAqB;IAQvC,EAAE,EAAG,MAAM,CAAC;IAQZ,MAAM,EAAG,MAAM,CAAC;IAQhB,SAAS,EAAG,MAAM,CAAC;IAOnB,QAAQ,EAAG,MAAM,CAAC;IAOlB,UAAU,EAAG,MAAM,GAAG,IAAI,CAAC;IAO3B,KAAK,EAAG,MAAM,CAAC;IAOf,MAAM,EAAG,MAAM,GAAG,IAAI,CAAC;IAEvB,GAAG,EAAG,MAAM,CAAC;IAOb,IAAI,EAAG,OAAO,GAAG,MAAM,CAAC;IAOxB,WAAW,EAAG,MAAM,CAAC;CACtB;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,CAAC,SAAS,SAAgC;IAChD,MAAM,CAAC,WAAW,SAAsB;IAQxC,EAAE,EAAG,MAAM,CAAC;IAOZ,IAAI,EAAG,MAAM,CAAC;IAOd,WAAW,EAAG,MAAM,GAAG,IAAI,CAAC;IAO5B,GAAG,EAAG,MAAM,CAAC;IAOb,SAAS,EAAG,IAAI,GAAG,MAAM,CAAC;IAQ1B,UAAU,EAAG,OAAO,CAAC;IAGrB,SAAS,EAAG,MAAM,CAAC;CACpB"}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CompanyApiKey = exports.CompanyMember = exports.CompanyGroupMember = exports.CompanyGroup = void 0;
|
|
13
|
-
require("dotenv/config");
|
|
14
|
-
const config_1 = require("../src/core/config");
|
|
15
|
-
const syntropix_1 = require("../src/core/syntropix");
|
|
16
|
-
const basemodel_1 = require("../src/types/basemodel");
|
|
17
|
-
const filter_1 = require("../src/types/filter");
|
|
18
|
-
class CompanyGroup extends basemodel_1.BaseModel {
|
|
19
|
-
}
|
|
20
|
-
exports.CompanyGroup = CompanyGroup;
|
|
21
|
-
CompanyGroup.tableName = 'syntropix_company_groups';
|
|
22
|
-
CompanyGroup.description = 'Company groups';
|
|
23
|
-
__decorate([
|
|
24
|
-
(0, basemodel_1.Column)({
|
|
25
|
-
type: 'Integer',
|
|
26
|
-
primary: true,
|
|
27
|
-
auto_increment: true,
|
|
28
|
-
description: 'Group ID',
|
|
29
|
-
}),
|
|
30
|
-
__metadata("design:type", Number)
|
|
31
|
-
], CompanyGroup.prototype, "id", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, basemodel_1.Column)({ type: { String: 256 }, description: 'Group Name' }),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], CompanyGroup.prototype, "name", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, basemodel_1.Column)({ type: 'Text', description: 'Group Description' }),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], CompanyGroup.prototype, "description", void 0);
|
|
40
|
-
class CompanyGroupMember extends basemodel_1.BaseModel {
|
|
41
|
-
}
|
|
42
|
-
exports.CompanyGroupMember = CompanyGroupMember;
|
|
43
|
-
CompanyGroupMember.tableName = 'syntropix_company_group_members';
|
|
44
|
-
CompanyGroupMember.description = 'Company group members';
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, basemodel_1.Column)({
|
|
47
|
-
type: 'Integer',
|
|
48
|
-
primary: true,
|
|
49
|
-
auto_increment: true,
|
|
50
|
-
description: 'Member ID',
|
|
51
|
-
}),
|
|
52
|
-
__metadata("design:type", Number)
|
|
53
|
-
], CompanyGroupMember.prototype, "id", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_groups', 'id', { description: 'Group ID' }),
|
|
56
|
-
__metadata("design:type", Number)
|
|
57
|
-
], CompanyGroupMember.prototype, "groupId", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_members', 'id', { description: 'Member ID' }),
|
|
60
|
-
__metadata("design:type", Number)
|
|
61
|
-
], CompanyGroupMember.prototype, "memberId", void 0);
|
|
62
|
-
class CompanyMember extends basemodel_1.BaseModel {
|
|
63
|
-
}
|
|
64
|
-
exports.CompanyMember = CompanyMember;
|
|
65
|
-
CompanyMember.tableName = 'syntropix_company_members';
|
|
66
|
-
CompanyMember.description = 'Company members';
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, basemodel_1.Column)({
|
|
69
|
-
type: 'Integer',
|
|
70
|
-
primary: true,
|
|
71
|
-
auto_increment: true,
|
|
72
|
-
description: 'Member ID',
|
|
73
|
-
}),
|
|
74
|
-
__metadata("design:type", Number)
|
|
75
|
-
], CompanyMember.prototype, "id", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, basemodel_1.Column)({
|
|
78
|
-
type: { String: 256 },
|
|
79
|
-
description: 'User id in mongodb',
|
|
80
|
-
nullable: false,
|
|
81
|
-
name: 'user_id',
|
|
82
|
-
}),
|
|
83
|
-
__metadata("design:type", String)
|
|
84
|
-
], CompanyMember.prototype, "userId", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
(0, basemodel_1.Column)({
|
|
87
|
-
type: { String: 256 },
|
|
88
|
-
description: 'First Name',
|
|
89
|
-
nullable: false,
|
|
90
|
-
name: 'first_name',
|
|
91
|
-
}),
|
|
92
|
-
__metadata("design:type", String)
|
|
93
|
-
], CompanyMember.prototype, "firstName", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, basemodel_1.Column)({
|
|
96
|
-
type: { String: 256 },
|
|
97
|
-
description: 'Last Name',
|
|
98
|
-
nullable: false,
|
|
99
|
-
name: 'last_name',
|
|
100
|
-
}),
|
|
101
|
-
__metadata("design:type", String)
|
|
102
|
-
], CompanyMember.prototype, "lastName", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
(0, basemodel_1.Column)({
|
|
105
|
-
type: { String: 256 },
|
|
106
|
-
description: 'Middle Name',
|
|
107
|
-
nullable: true,
|
|
108
|
-
name: 'middle_name',
|
|
109
|
-
}),
|
|
110
|
-
__metadata("design:type", Object)
|
|
111
|
-
], CompanyMember.prototype, "middleName", void 0);
|
|
112
|
-
__decorate([
|
|
113
|
-
(0, basemodel_1.Column)({
|
|
114
|
-
type: { String: 256 },
|
|
115
|
-
description: 'Email',
|
|
116
|
-
nullable: false,
|
|
117
|
-
name: 'email',
|
|
118
|
-
}),
|
|
119
|
-
__metadata("design:type", String)
|
|
120
|
-
], CompanyMember.prototype, "email", void 0);
|
|
121
|
-
__decorate([
|
|
122
|
-
(0, basemodel_1.Column)({
|
|
123
|
-
type: { String: 256 },
|
|
124
|
-
description: 'Avatar',
|
|
125
|
-
nullable: true,
|
|
126
|
-
name: 'avatar',
|
|
127
|
-
}),
|
|
128
|
-
__metadata("design:type", Object)
|
|
129
|
-
], CompanyMember.prototype, "avatar", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, basemodel_1.Column)({ type: 'Text', description: 'Bio', nullable: true, name: 'bio' }),
|
|
132
|
-
__metadata("design:type", String)
|
|
133
|
-
], CompanyMember.prototype, "bio", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, basemodel_1.Column)({
|
|
136
|
-
type: { String: 32 },
|
|
137
|
-
description: 'Role',
|
|
138
|
-
nullable: false,
|
|
139
|
-
name: 'role',
|
|
140
|
-
}),
|
|
141
|
-
__metadata("design:type", String)
|
|
142
|
-
], CompanyMember.prototype, "role", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
(0, basemodel_1.Column)({
|
|
145
|
-
type: { String: 256 },
|
|
146
|
-
description: 'Personal Key',
|
|
147
|
-
nullable: false,
|
|
148
|
-
name: 'personal_key',
|
|
149
|
-
}),
|
|
150
|
-
__metadata("design:type", String)
|
|
151
|
-
], CompanyMember.prototype, "personalKey", void 0);
|
|
152
|
-
class CompanyApiKey extends basemodel_1.BaseModel {
|
|
153
|
-
}
|
|
154
|
-
exports.CompanyApiKey = CompanyApiKey;
|
|
155
|
-
CompanyApiKey.tableName = 'syntropix_company_api_keys';
|
|
156
|
-
CompanyApiKey.description = 'Company API keys';
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, basemodel_1.Column)({
|
|
159
|
-
type: 'Integer',
|
|
160
|
-
primary: true,
|
|
161
|
-
auto_increment: true,
|
|
162
|
-
description: 'API Key ID',
|
|
163
|
-
}),
|
|
164
|
-
__metadata("design:type", Number)
|
|
165
|
-
], CompanyApiKey.prototype, "id", void 0);
|
|
166
|
-
__decorate([
|
|
167
|
-
(0, basemodel_1.Column)({
|
|
168
|
-
type: { String: 256 },
|
|
169
|
-
description: 'Name',
|
|
170
|
-
nullable: false,
|
|
171
|
-
name: 'name',
|
|
172
|
-
}),
|
|
173
|
-
__metadata("design:type", String)
|
|
174
|
-
], CompanyApiKey.prototype, "name", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
(0, basemodel_1.Column)({
|
|
177
|
-
type: 'Text',
|
|
178
|
-
description: 'Description',
|
|
179
|
-
nullable: true,
|
|
180
|
-
name: 'description',
|
|
181
|
-
}),
|
|
182
|
-
__metadata("design:type", Object)
|
|
183
|
-
], CompanyApiKey.prototype, "description", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
(0, basemodel_1.Column)({
|
|
186
|
-
type: { String: 256 },
|
|
187
|
-
description: 'Key',
|
|
188
|
-
nullable: false,
|
|
189
|
-
name: 'key',
|
|
190
|
-
}),
|
|
191
|
-
__metadata("design:type", String)
|
|
192
|
-
], CompanyApiKey.prototype, "key", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
(0, basemodel_1.Column)({
|
|
195
|
-
type: 'DateTime',
|
|
196
|
-
description: 'Created At',
|
|
197
|
-
nullable: false,
|
|
198
|
-
name: 'created_at',
|
|
199
|
-
}),
|
|
200
|
-
__metadata("design:type", Object)
|
|
201
|
-
], CompanyApiKey.prototype, "createdAt", void 0);
|
|
202
|
-
__decorate([
|
|
203
|
-
(0, basemodel_1.Column)({
|
|
204
|
-
type: 'Boolean',
|
|
205
|
-
description: 'Is Personal',
|
|
206
|
-
nullable: false,
|
|
207
|
-
name: 'is_personal',
|
|
208
|
-
}),
|
|
209
|
-
__metadata("design:type", Boolean)
|
|
210
|
-
], CompanyApiKey.prototype, "isPersonal", void 0);
|
|
211
|
-
__decorate([
|
|
212
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_members', 'id', { description: 'Created By', name: 'created_by' }),
|
|
213
|
-
__metadata("design:type", Number)
|
|
214
|
-
], CompanyApiKey.prototype, "createdBy", void 0);
|
|
215
|
-
// Example usage
|
|
216
|
-
async function examples() {
|
|
217
|
-
const _client = new syntropix_1.SyntropixClient(new config_1.ClientConfig());
|
|
218
|
-
console.log(CompanyApiKey.getDescription());
|
|
219
|
-
const member = await CompanyMember.filter({
|
|
220
|
-
filter: (0, filter_1.OR)((0, filter_1.AND)((0, filter_1.GTE)('id', 0))),
|
|
221
|
-
});
|
|
222
|
-
console.log(member);
|
|
223
|
-
// await CompanyMember.dropTable(_client);
|
|
224
|
-
// await CompanyApiKey.dropTable(_client);
|
|
225
|
-
// await CompanyMember.createTable(_client);
|
|
226
|
-
// await CompanyGroup.createTable(_client);
|
|
227
|
-
// await CompanyApiKey.createTable(_client);
|
|
228
|
-
// await CompanyGroupMember.createTable(_client);
|
|
229
|
-
// await CompanyMember.create(
|
|
230
|
-
// {
|
|
231
|
-
// userId: "1234567890",
|
|
232
|
-
// firstName: "John",
|
|
233
|
-
// lastName: "Doe",
|
|
234
|
-
// middleName: "Doe",
|
|
235
|
-
// email: "john.doe@example.com",
|
|
236
|
-
// avatar: "https://example.com/avatar.png",
|
|
237
|
-
// bio: "",
|
|
238
|
-
// role: "admin",
|
|
239
|
-
// personalKey: "1234567890",
|
|
240
|
-
// },
|
|
241
|
-
// _client
|
|
242
|
-
// );
|
|
243
|
-
// await CompanyApiKey.create(
|
|
244
|
-
// {
|
|
245
|
-
// name: "Admin API Key for John Doe",
|
|
246
|
-
// description: "Admin API Key for John Doe",
|
|
247
|
-
// key: "1234567890",
|
|
248
|
-
// createdAt: new Date(),
|
|
249
|
-
// createdBy: 1,
|
|
250
|
-
// isPersonal: true,
|
|
251
|
-
// },
|
|
252
|
-
// _client
|
|
253
|
-
// );
|
|
254
|
-
}
|
|
255
|
-
// Run examples
|
|
256
|
-
examples().catch(console.error);
|
|
257
|
-
//# sourceMappingURL=advanced-usage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-usage.js","sourceRoot":"","sources":["advanced-usage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAuB;AACvB,+CAAkD;AAClD,qDAAwD;AACxD,sDAAuE;AACvE,gDAAmD;AAEnD,MAAa,YAAa,SAAQ,qBAAS;;AAA3C,oCAiBC;AAhBQ,sBAAS,GAAG,0BAA0B,CAAC;AACvC,wBAAW,GAAG,gBAAgB,CAAC;AAQtC;IANC,IAAA,kBAAM,EAAC;QACN,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,UAAU;KACxB,CAAC;;wCACU;AAGZ;IADC,IAAA,kBAAM,EAAC,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;0CAC/C;AAGd;IADC,IAAA,kBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,m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MAAM,EAAE,IAAA,WAAE,EAAC,IAAA,YAAG,EAAC,IAAA,YAAG,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC9B,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,0CAA0C;IAC1C,0CAA0C;IAC1C,4CAA4C;IAC5C,2CAA2C;IAC3C,4CAA4C;IAC5C,iDAAiD;IAEjD,8BAA8B;IAC9B,MAAM;IACN,4BAA4B;IAC5B,yBAAyB;IACzB,uBAAuB;IACvB,yBAAyB;IACzB,qCAAqC;IACrC,gDAAgD;IAChD,eAAe;IACf,qBAAqB;IACrB,iCAAiC;IACjC,OAAO;IACP,YAAY;IACZ,KAAK;IAEL,8BAA8B;IAC9B,MAAM;IACN,0CAA0C;IAC1C,iDAAiD;IACjD,yBAAyB;IACzB,6BAA6B;IAC7B,oBAAoB;IACpB,wBAAwB;IACxB,OAAO;IACP,YAAY;IACZ,KAAK;AACP,CAAC;AAED,eAAe;AACf,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/examples/usage.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { BaseModel } from '../src/types/basemodel';
|
|
3
|
-
export declare class User extends BaseModel {
|
|
4
|
-
static tableName: string;
|
|
5
|
-
id: number;
|
|
6
|
-
email: string;
|
|
7
|
-
fullName: string;
|
|
8
|
-
profile?: any;
|
|
9
|
-
isActive: boolean;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=usage.d.ts.map
|
package/examples/usage.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["usage.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAU,MAAM,wBAAwB,CAAC;AAI3D,qBAAa,IAAK,SAAQ,SAAS;IACjC,MAAM,CAAC,SAAS,SAAW;IAEuC,EAAE,EAAG,MAAM,CAAC;IACpE,KAAK,EAAG,MAAM,CAAC;IACM,QAAQ,EAAG,MAAM,CAAC;IACP,OAAO,CAAC,EAAE,GAAG,CAAC;IACR,QAAQ,EAAG,OAAO,CAAC;CACpE"}
|