tspace-mysql 1.6.2 → 1.6.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.
@@ -0,0 +1,192 @@
1
+ import { Model } from '../../src/lib';
2
+ export declare class User extends Model {
3
+ constructor();
4
+ }
5
+ export declare class Post extends Model {
6
+ constructor();
7
+ }
8
+ export declare class PostUser extends Model {
9
+ constructor();
10
+ }
11
+ export declare const userSchemaObject: {
12
+ type: string;
13
+ properties: {
14
+ id: {
15
+ type: string;
16
+ };
17
+ uuid: {
18
+ anyOf: {
19
+ type: string;
20
+ }[];
21
+ };
22
+ email: {
23
+ type: string;
24
+ };
25
+ name: {
26
+ anyOf: {
27
+ type: string;
28
+ }[];
29
+ };
30
+ username: {
31
+ anyOf: {
32
+ type: string;
33
+ }[];
34
+ };
35
+ password: {
36
+ type: string;
37
+ };
38
+ createdAt: {
39
+ anyOf: {
40
+ type: string;
41
+ }[];
42
+ };
43
+ updatedAt: {
44
+ anyOf: {
45
+ type: string;
46
+ }[];
47
+ };
48
+ deletedAt: {
49
+ anyOf: {
50
+ type: string;
51
+ }[];
52
+ };
53
+ };
54
+ };
55
+ export declare const userSchemaArray: {
56
+ type: string;
57
+ items: {
58
+ type: string;
59
+ properties: {
60
+ id: {
61
+ type: string;
62
+ };
63
+ uuid: {
64
+ anyOf: {
65
+ type: string;
66
+ }[];
67
+ };
68
+ email: {
69
+ type: string;
70
+ };
71
+ name: {
72
+ anyOf: {
73
+ type: string;
74
+ }[];
75
+ };
76
+ username: {
77
+ anyOf: {
78
+ type: string;
79
+ }[];
80
+ };
81
+ password: {
82
+ type: string;
83
+ };
84
+ createdAt: {
85
+ anyOf: {
86
+ type: string;
87
+ }[];
88
+ };
89
+ updatedAt: {
90
+ anyOf: {
91
+ type: string;
92
+ }[];
93
+ };
94
+ deletedAt: {
95
+ anyOf: {
96
+ type: string;
97
+ }[];
98
+ };
99
+ };
100
+ };
101
+ };
102
+ export declare const postSchemaObject: {
103
+ type: string;
104
+ properties: {
105
+ id: {
106
+ type: string;
107
+ };
108
+ uuid: {
109
+ anyOf: {
110
+ type: string;
111
+ }[];
112
+ };
113
+ userId: {
114
+ type: string;
115
+ };
116
+ title: {
117
+ type: string;
118
+ };
119
+ subtitle: {
120
+ anyOf: {
121
+ type: string;
122
+ }[];
123
+ };
124
+ description: {
125
+ anyOf: {
126
+ type: string;
127
+ }[];
128
+ };
129
+ createdAt: {
130
+ anyOf: {
131
+ type: string;
132
+ }[];
133
+ };
134
+ updatedAt: {
135
+ anyOf: {
136
+ type: string;
137
+ }[];
138
+ };
139
+ deletedAt: {
140
+ anyOf: {
141
+ type: string;
142
+ }[];
143
+ };
144
+ };
145
+ };
146
+ export declare const postSchemaArray: {
147
+ type: string;
148
+ items: {
149
+ type: string;
150
+ properties: {
151
+ id: {
152
+ type: string;
153
+ };
154
+ uuid: {
155
+ anyOf: {
156
+ type: string;
157
+ }[];
158
+ };
159
+ userId: {
160
+ type: string;
161
+ };
162
+ title: {
163
+ type: string;
164
+ };
165
+ subtitle: {
166
+ anyOf: {
167
+ type: string;
168
+ }[];
169
+ };
170
+ description: {
171
+ anyOf: {
172
+ type: string;
173
+ }[];
174
+ };
175
+ createdAt: {
176
+ anyOf: {
177
+ type: string;
178
+ }[];
179
+ };
180
+ updatedAt: {
181
+ anyOf: {
182
+ type: string;
183
+ }[];
184
+ };
185
+ deletedAt: {
186
+ anyOf: {
187
+ type: string;
188
+ }[];
189
+ };
190
+ };
191
+ };
192
+ };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postSchemaArray = exports.postSchemaObject = exports.userSchemaArray = exports.userSchemaObject = exports.PostUser = exports.Post = exports.User = void 0;
4
+ const lib_1 = require("../../src/lib");
5
+ class User extends lib_1.Model {
6
+ constructor() {
7
+ super();
8
+ this.useCamelCase();
9
+ this.useUUID();
10
+ this.useTimestamp();
11
+ this.useSoftDelete();
12
+ this.hasMany({ model: Post, name: 'posts' });
13
+ this.hasOne({ model: Post, name: 'post' });
14
+ this.useSchema({
15
+ id: new lib_1.Blueprint().int().primary().autoIncrement(),
16
+ uuid: new lib_1.Blueprint().varchar(50).null(),
17
+ email: new lib_1.Blueprint().varchar(50).null(),
18
+ name: new lib_1.Blueprint().varchar(255).null(),
19
+ username: new lib_1.Blueprint().varchar(255).null(),
20
+ password: new lib_1.Blueprint().varchar(255).null(),
21
+ createdAt: new lib_1.Blueprint().timestamp().null(),
22
+ updatedAt: new lib_1.Blueprint().timestamp().null(),
23
+ deletedAt: new lib_1.Blueprint().timestamp().null(),
24
+ });
25
+ }
26
+ }
27
+ exports.User = User;
28
+ class Post extends lib_1.Model {
29
+ constructor() {
30
+ super();
31
+ this.useUUID();
32
+ this.useTimestamp();
33
+ this.useSoftDelete();
34
+ this.useCamelCase();
35
+ this.belongsTo({ name: 'user', model: User });
36
+ this.belongsToMany({ name: 'subscribers', model: User, modelPivot: PostUser });
37
+ this.useSchema({
38
+ id: new lib_1.Blueprint().int().notNull().primary().autoIncrement(),
39
+ uuid: new lib_1.Blueprint().varchar(50).null(),
40
+ userId: new lib_1.Blueprint().int().notNull(),
41
+ title: new lib_1.Blueprint().varchar(100).notNull(),
42
+ subtitle: new lib_1.Blueprint().varchar(100).null(),
43
+ description: new lib_1.Blueprint().varchar(255).null(),
44
+ createdAt: new lib_1.Blueprint().timestamp().null(),
45
+ updatedAt: new lib_1.Blueprint().timestamp().null(),
46
+ deletedAt: new lib_1.Blueprint().timestamp().null()
47
+ });
48
+ }
49
+ }
50
+ exports.Post = Post;
51
+ class PostUser extends lib_1.Model {
52
+ constructor() {
53
+ super();
54
+ this.useUUID();
55
+ this.useTimestamp();
56
+ this.useSoftDelete();
57
+ this.useCamelCase();
58
+ this.useTableSingular();
59
+ this.useSchema({
60
+ id: new lib_1.Blueprint().int().notNull().primary().autoIncrement(),
61
+ uuid: new lib_1.Blueprint().varchar(50).null(),
62
+ userId: new lib_1.Blueprint().int().notNull(),
63
+ postId: new lib_1.Blueprint().int().notNull(),
64
+ createdAt: new lib_1.Blueprint().timestamp().null(),
65
+ updatedAt: new lib_1.Blueprint().timestamp().null(),
66
+ deletedAt: new lib_1.Blueprint().timestamp().null()
67
+ });
68
+ }
69
+ }
70
+ exports.PostUser = PostUser;
71
+ exports.userSchemaObject = {
72
+ type: 'object',
73
+ properties: {
74
+ id: { type: 'integer' },
75
+ uuid: { anyOf: [{ type: 'string' }, { type: 'null' }] },
76
+ email: { type: 'string' },
77
+ name: { anyOf: [{ type: 'string' }, { type: 'null' }] },
78
+ username: { anyOf: [{ type: 'string' }, { type: 'null' }] },
79
+ password: { type: 'string' },
80
+ createdAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
81
+ updatedAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
82
+ deletedAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
83
+ }
84
+ };
85
+ exports.userSchemaArray = {
86
+ type: 'array',
87
+ items: Object.assign({}, exports.userSchemaObject)
88
+ };
89
+ exports.postSchemaObject = {
90
+ type: 'object',
91
+ properties: {
92
+ id: { type: 'integer' },
93
+ uuid: { anyOf: [{ type: 'string' }, { type: 'null' }] },
94
+ userId: { type: 'integer' },
95
+ title: { type: 'string' },
96
+ subtitle: { anyOf: [{ type: 'string' }, { type: 'null' }] },
97
+ description: { anyOf: [{ type: 'string' }, { type: 'null' }] },
98
+ createdAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
99
+ updatedAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
100
+ deletedAt: { anyOf: [{ type: 'string' }, { type: 'date' }, { type: 'null' }] },
101
+ }
102
+ };
103
+ exports.postSchemaArray = {
104
+ type: 'array',
105
+ items: Object.assign({}, exports.postSchemaObject)
106
+ };
107
+ //# sourceMappingURL=schema-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-spec.js","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AK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;QAC3D,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;QAC9D,SAAS,EAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAG,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;QAChF,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAG,MAAM,EAAE,EAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;QAChF,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAG,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;KAChF;CACJ,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,IAAI,EAAE,OAAO;IACb,KAAK,oBACE,wBAAgB,CACtB;CACJ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tspace-mysql",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "mysql query builder object relational mapping (ORM)",
5
5
  "main": "build/lib/index.js",
6
6
  "types": "build/lib/index.d.ts",
@@ -52,7 +52,7 @@
52
52
  "build": "tsc",
53
53
  "prepare": "npm run build",
54
54
  "test:build": "mocha './build/tests/**/*.test.js' --reporter spec --no-timeouts --recursive --exit",
55
- "test": "ts-mocha './src/tests/**/*.test.ts' --reporter spec --no-timeouts --recursive --exit"
55
+ "test": "cross-env NODE_ENV=test ts-mocha './src/tests/**/*.test.ts' --reporter spec --no-timeouts --recursive --exit"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/chai": "^4.3.11",
@@ -63,6 +63,7 @@
63
63
  "@types/pluralize": "^0.0.29",
64
64
  "chai": "4.3.10",
65
65
  "chai-json-schema": "^1.5.1",
66
+ "cross-env": "^7.0.3",
66
67
  "mocha": "^10.2.0",
67
68
  "mochawesome": "^7.1.3",
68
69
  "ts-mocha": "^10.0.0",