@volcanicminds/typeorm 0.0.6 → 0.0.7

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/README.md CHANGED
@@ -43,7 +43,7 @@ import { Entity, Column, Index, PrimaryGeneratedColumn, CreateDateColumn, Update
43
43
 
44
44
  @Entity()
45
45
  class Player {
46
- @PrimaryGeneratedColumn()
46
+ @PrimaryGeneratedColumn('uuid')
47
47
  id: number
48
48
 
49
49
  @Index()
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import { User, ExtraColumns } from './lib/entities/user.e';
3
+ export { User, ExtraColumns };
package/dist/index.js CHANGED
@@ -32,9 +32,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.ExtraColumns = exports.User = void 0;
35
36
  require("reflect-metadata");
36
37
  const typeorm_1 = require("typeorm");
37
38
  const loaderEntities = __importStar(require("./lib/loader/entities"));
39
+ const user_e_1 = require("./lib/entities/user.e");
40
+ Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_e_1.User; } });
41
+ Object.defineProperty(exports, "ExtraColumns", { enumerable: true, get: function () { return user_e_1.ExtraColumns; } });
38
42
  function start(options) {
39
43
  return __awaiter(this, void 0, void 0, function* () {
40
44
  return new Promise((resolve, reject) => {
@@ -75,17 +79,13 @@ function start(options) {
75
79
  .then((ds) => __awaiter(this, void 0, void 0, function* () {
76
80
  const repository = {};
77
81
  Object.keys(repositories).map((r) => (repository[r] = ds.getRepository(repositories[r])));
78
- global.database = {
79
- model: classes,
80
- repository: repository
81
- };
82
+ global.entity = classes;
83
+ global.repository = repository;
82
84
  return resolve(ds);
83
85
  }))
84
86
  .catch((error) => reject(error));
85
87
  });
86
88
  });
87
89
  }
88
- module.exports = start;
89
- module.exports.server = start;
90
- module.exports.default = start;
90
+ module.exports = { start, User: user_e_1.User, ExtraColumns: user_e_1.ExtraColumns };
91
91
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,4BAAyB;AACzB,qCAAoC;AACpC,sEAAuD;AAEvD,SAAe,KAAK,CAAC,OAAO;;QAC1B,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,IAAI,MAAM,CAAC,qBAAqB,EAAE;gBAChC,OAAO,GAAG;oBACR,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,IAAI;oBACV,QAAQ,EAAE,QAAQ;oBAClB,QAAQ,EAAE,QAAQ;oBAClB,QAAQ,EAAE,QAAQ;oBAClB,WAAW,EAAE,IAAI;oBACjB,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,EAAE;iBACX,CAAA;aACF;YAED,IAAI,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE;gBACvD,MAAM,KAAK,CAAC,0CAA0C,CAAC,CAAA;aACxD;YAED,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;YAE5F,MAAM,QAAQ,GACZ,YAAY,KAAK,OAAO;gBACtB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,YAAY,KAAK,OAAO;oBAC1B,CAAC,CAAC,OAAO;oBACT,CAAC,CAAC,YAAY,KAAK,MAAM;wBACzB,CAAC,CAAC,MAAM;wBACR,CAAC,CAAC,YAAY,KAAK,MAAM;4BACzB,CAAC,CAAC,MAAM;4BACR,CAAC,CAAC,YAAY,KAAK,OAAO;gCAC1B,CAAC,CA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: number;
9
+ extra: ExtraColumns;
10
+ name: string;
11
+ email: string;
12
+ password: string;
13
+ allRoles: string[];
14
+ }
@@ -9,14 +9,37 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.User = void 0;
12
+ exports.User = exports.ExtraColumns = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
+ class ExtraColumns {
15
+ }
16
+ __decorate([
17
+ (0, typeorm_1.VersionColumn)(),
18
+ __metadata("design:type", Number)
19
+ ], ExtraColumns.prototype, "version", void 0);
20
+ __decorate([
21
+ (0, typeorm_1.CreateDateColumn)(),
22
+ __metadata("design:type", Date)
23
+ ], ExtraColumns.prototype, "createdAt", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.UpdateDateColumn)(),
26
+ __metadata("design:type", Date)
27
+ ], ExtraColumns.prototype, "updatedAt", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.DeleteDateColumn)(),
30
+ __metadata("design:type", Date)
31
+ ], ExtraColumns.prototype, "deletedAt", void 0);
32
+ exports.ExtraColumns = ExtraColumns;
14
33
  let User = class User {
15
34
  };
16
35
  __decorate([
17
- (0, typeorm_1.PrimaryGeneratedColumn)(),
36
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
18
37
  __metadata("design:type", Number)
19
38
  ], User.prototype, "id", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)(() => ExtraColumns),
41
+ __metadata("design:type", ExtraColumns)
42
+ ], User.prototype, "extra", void 0);
20
43
  __decorate([
21
44
  (0, typeorm_1.Index)(),
22
45
  (0, typeorm_1.Column)(),
@@ -32,19 +55,12 @@ __decorate([
32
55
  __metadata("design:type", String)
33
56
  ], User.prototype, "password", void 0);
34
57
  __decorate([
35
- (0, typeorm_1.Column)({ type: 'varchar', array: true, nullable: true }),
58
+ (0, typeorm_1.Column)({ type: 'simple-array', nullable: true }),
36
59
  __metadata("design:type", Array)
37
- ], User.prototype, "roles", void 0);
38
- __decorate([
39
- (0, typeorm_1.CreateDateColumn)(),
40
- __metadata("design:type", Date)
41
- ], User.prototype, "createdAt", void 0);
42
- __decorate([
43
- (0, typeorm_1.UpdateDateColumn)(),
44
- __metadata("design:type", Date)
45
- ], User.prototype, "updatedAt", void 0);
60
+ ], User.prototype, "allRoles", void 0);
46
61
  User = __decorate([
47
- (0, typeorm_1.Entity)()
62
+ (0, typeorm_1.Entity)(),
63
+ (0, typeorm_1.TableInheritance)({ column: { type: 'varchar', name: 'type', default: 'user' } })
48
64
  ], User);
49
65
  exports.User = User;
50
66
  //# sourceMappingURL=user.e.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.e.js","sourceRoot":"","sources":["../../../lib/entities/user.e.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA2G;AAGpG,IAAM,IAAI,GAAV,MAAM,IAAI;CAuBhB,CAAA;AAtBC;IAAC,IAAA,gCAAsB,GAAE;;gCACf;AAEV;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;kCACG;AAEZ;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;mCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;sCACO;AAEhB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mCAC1C;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;uCAAA;AAtBJ,IAAI;IADhB,IAAA,gBAAM,GAAE;GACI,IAAI,CAuBhB;AAvBY,oBAAI"}
1
+ {"version":3,"file":"user.e.js","sourceRoot":"","sources":["../../../lib/entities/user.e.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAUgB;AAEhB,MAAa,YAAY;CAYxB;AAXC;IAAC,IAAA,uBAAa,GAAE;;6CACD;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAXjB,oCAYC;AAIM,IAAM,IAAI,GAAV,MAAM,IAAI;CAoBhB,CAAA;AAnBC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;gCACrB;AAEV;IAAC,IAAA,gBAAM,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;8BACpB,YAAY;mCAAA;AAEnB;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;kCACG;AAEZ;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;mCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;sCACO;AAEhB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCAC/B;AAnBP,IAAI;IAFhB,IAAA,gBAAM,GAAE;IACR,IAAA,0BAAgB,EAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;GACpE,IAAI,CAoBhB;AApBY,oBAAI"}
@@ -0,0 +1,5 @@
1
+ export declare function load(): {
2
+ classes: any;
3
+ repositories: any;
4
+ entities: any[];
5
+ };
package/esm/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ import { User, ExtraColumns } from './lib/entities/user.e';
3
+ export { User, ExtraColumns };
package/esm/index.js ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ExtraColumns = exports.User = void 0;
27
+ require("reflect-metadata");
28
+ const typeorm_1 = require("typeorm");
29
+ const loaderEntities = __importStar(require("./lib/loader/entities"));
30
+ const user_e_1 = require("./lib/entities/user.e");
31
+ Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_e_1.User; } });
32
+ Object.defineProperty(exports, "ExtraColumns", { enumerable: true, get: function () { return user_e_1.ExtraColumns; } });
33
+ async function start(options) {
34
+ return new Promise((resolve, reject) => {
35
+ if (global.npmDebugServerStarted) {
36
+ options = {
37
+ type: 'postgres',
38
+ host: '127.0.0.1',
39
+ port: 5432,
40
+ username: 'vminds',
41
+ password: 'vminds',
42
+ database: 'vminds',
43
+ synchronize: true,
44
+ logging: true,
45
+ logger: ''
46
+ };
47
+ }
48
+ if (options == null || Object.keys(options).length == 0) {
49
+ throw Error('Volcanic Database: options not specified');
50
+ }
51
+ const { LOG_DB_LEVEL = process.env.LOG_LEVEL || 'trace', LOG_COLORIZE = true } = process.env;
52
+ const logLevel = LOG_DB_LEVEL === 'trace'
53
+ ? 'all'
54
+ : LOG_DB_LEVEL === 'debug'
55
+ ? 'query'
56
+ : LOG_DB_LEVEL === 'info'
57
+ ? 'info'
58
+ : LOG_DB_LEVEL === 'warn'
59
+ ? 'warn'
60
+ : LOG_DB_LEVEL === 'error'
61
+ ? 'error'
62
+ : false;
63
+ const { classes, repositories, entities } = loaderEntities.load();
64
+ options.entities = [...(options.entities || []), ...(entities || [])];
65
+ options.logger = LOG_COLORIZE ? 'advanced-console' : 'simple-console';
66
+ options.logging = logLevel;
67
+ new typeorm_1.DataSource(options)
68
+ .initialize()
69
+ .then(async (ds) => {
70
+ const repository = {};
71
+ Object.keys(repositories).map((r) => (repository[r] = ds.getRepository(repositories[r])));
72
+ global.entity = classes;
73
+ global.repository = repository;
74
+ return resolve(ds);
75
+ })
76
+ .catch((error) => reject(error));
77
+ });
78
+ }
79
+ module.exports = { start, User: user_e_1.User, ExtraColumns: user_e_1.ExtraColumns };
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,4BAAyB;AACzB,qCAAoC;AACpC,sEAAuD;AACvD,kDAA0D;AA+DjD,qFA/DA,aAAI,OA+DA;AAAE,6FA/DA,qBAAY,OA+DA;AA7D3B,KAAK,UAAU,KAAK,CAAC,OAAO;IAC1B,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAChC,OAAO,GAAG;gBACR,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,QAAQ;gBAClB,QAAQ,EAAE,QAAQ;gBAClB,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,EAAE;aACX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,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAEzF,MAAM,CAAC,MAAM,GAAG,OAAO,CAAA;YACvB,MAAM,CAAC,UAAU,GAAG,UAAU,CAAA;YAC9B,OAAO,OAAO,CAAC,EAAE,CAAC,CAAA;QACpB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC;AAGD,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,IAAI,EAAJ,aAAI,EAAE,YAAY,EAAZ,qBAAY,EAAE,CAAA"}
@@ -0,0 +1,14 @@
1
+ export declare class ExtraColumns {
2
+ version: number;
3
+ createdAt: Date;
4
+ updatedAt: Date;
5
+ deletedAt: Date;
6
+ }
7
+ export declare class User {
8
+ id: number;
9
+ extra: ExtraColumns;
10
+ name: string;
11
+ email: string;
12
+ password: string;
13
+ allRoles: string[];
14
+ }
@@ -0,0 +1,66 @@
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.User = exports.ExtraColumns = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ class ExtraColumns {
15
+ }
16
+ __decorate([
17
+ (0, typeorm_1.VersionColumn)(),
18
+ __metadata("design:type", Number)
19
+ ], ExtraColumns.prototype, "version", void 0);
20
+ __decorate([
21
+ (0, typeorm_1.CreateDateColumn)(),
22
+ __metadata("design:type", Date)
23
+ ], ExtraColumns.prototype, "createdAt", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.UpdateDateColumn)(),
26
+ __metadata("design:type", Date)
27
+ ], ExtraColumns.prototype, "updatedAt", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.DeleteDateColumn)(),
30
+ __metadata("design:type", Date)
31
+ ], ExtraColumns.prototype, "deletedAt", void 0);
32
+ exports.ExtraColumns = ExtraColumns;
33
+ let User = class User {
34
+ };
35
+ __decorate([
36
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
37
+ __metadata("design:type", Number)
38
+ ], User.prototype, "id", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)(() => ExtraColumns),
41
+ __metadata("design:type", ExtraColumns)
42
+ ], User.prototype, "extra", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Index)(),
45
+ (0, typeorm_1.Column)(),
46
+ __metadata("design:type", String)
47
+ ], User.prototype, "name", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.Index)(),
50
+ (0, typeorm_1.Column)(),
51
+ __metadata("design:type", String)
52
+ ], User.prototype, "email", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.Column)(),
55
+ __metadata("design:type", String)
56
+ ], User.prototype, "password", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)({ type: 'simple-array', nullable: true }),
59
+ __metadata("design:type", Array)
60
+ ], User.prototype, "allRoles", void 0);
61
+ User = __decorate([
62
+ (0, typeorm_1.Entity)(),
63
+ (0, typeorm_1.TableInheritance)({ column: { type: 'varchar', name: 'type', default: 'user' } })
64
+ ], User);
65
+ exports.User = User;
66
+ //# sourceMappingURL=user.e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.e.js","sourceRoot":"","sources":["../../../lib/entities/user.e.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAUgB;AAEhB,MAAa,YAAY;CAYxB;AAXC;IAAC,IAAA,uBAAa,GAAE;;6CACD;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAEf;IAAC,IAAA,0BAAgB,GAAE;8BACR,IAAI;+CAAA;AAXjB,oCAYC;AAIM,IAAM,IAAI,GAAV,MAAM,IAAI;CAoBhB,CAAA;AAnBC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;gCACrB;AAEV;IAAC,IAAA,gBAAM,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC;8BACpB,YAAY;mCAAA;AAEnB;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;kCACG;AAEZ;IAAC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,GAAE;;mCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;sCACO;AAEhB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCAC/B;AAnBP,IAAI;IAFhB,IAAA,gBAAM,GAAE;IACR,IAAA,0BAAgB,EAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;GACpE,IAAI,CAoBhB;AApBY,oBAAI"}
@@ -0,0 +1,5 @@
1
+ export declare function load(): {
2
+ classes: any;
3
+ repositories: any;
4
+ entities: any[];
5
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.load = void 0;
4
+ const glob = require('glob');
5
+ const pluralize = require('pluralize');
6
+ function load() {
7
+ const classes = {};
8
+ const repositories = {};
9
+ const entities = [];
10
+ const patterns = [`${__dirname}/../entities/*.e.{ts,js}`, `${process.cwd()}/src/entities/*.e.{ts,js}`];
11
+ patterns.forEach((pattern) => {
12
+ glob.sync(pattern, { nodir: true, nosort: true, stat: false }).forEach((f) => {
13
+ const entityClass = require(f);
14
+ const entityNames = Object.keys(entityClass);
15
+ entityNames.map((name) => {
16
+ classes[name] = entityClass[name];
17
+ repositories[pluralize(name.toLowerCase())] = entityClass[name];
18
+ entities.push(entityClass[name]);
19
+ });
20
+ });
21
+ });
22
+ return { classes, repositories, entities };
23
+ }
24
+ exports.load = load;
25
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../lib/loader/entities.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AAEtC,SAAgB,IAAI;IAClB,MAAM,OAAO,GAAQ,EAAE,CAAA;IACvB,MAAM,YAAY,GAAQ,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAU,EAAE,CAAA;IAE1B,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,0BAA0B,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAA;IACtG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;YACnF,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;YAC9B,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YAE5C,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACvB,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;gBACjC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;gBAC/D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;YAClC,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA;AAC5C,CAAC;AApBD,oBAoBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcanicminds/typeorm",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "license": "MIT",
5
5
  "description": "TypeORM for the volcanic (minds) backend",
6
6
  "keywords": [
@@ -11,16 +11,24 @@
11
11
  "typescript",
12
12
  "javascript"
13
13
  ],
14
- "main": "dist/index",
15
- "typings": "dist/index",
14
+ "main": "dist/index.js",
15
+ "module": "esm/index.js",
16
+ "files": [
17
+ "dist",
18
+ "esm",
19
+ "src"
20
+ ],
16
21
  "engines": {
17
22
  "node": ">=16"
18
23
  },
19
24
  "scripts": {
20
- "compile": "rm -rf ./dist && tsc",
21
- "dev": "ts-node ./start.ts",
25
+ "upgrade-deps": "npm-upgrade",
26
+ "clean": "rm -rf dist esm",
27
+ "prebuild": "npm run clean",
22
28
  "test": "jest test --config ./jest.config.js",
23
- "upgrade-deps": "npm-upgrade"
29
+ "build:esm": "tsc --target es2018 --outDir esm",
30
+ "build:cjs": "tsc --target es2015 --module commonjs --outDir dist",
31
+ "build": "npm run build:esm && npm run build:cjs"
24
32
  },
25
33
  "dependencies": {
26
34
  "pluralize": "^8.0.0",
@@ -30,7 +38,6 @@
30
38
  "devDependencies": {
31
39
  "@types/node": "^18.11.9",
32
40
  "jest": "^29.3.1",
33
- "nodemon": "^2.0.20",
34
41
  "npm-upgrade": "^3.1.0",
35
42
  "ts-node": "^10.9.1",
36
43
  "typescript": "^4.9.3"
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v18.12.0
package/.prettierignore DELETED
@@ -1,5 +0,0 @@
1
- node_modules
2
-
3
- # Ignore artifacts:
4
- build
5
- coverage
package/.prettierrc DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "semi": false,
3
- "singleQuote": true,
4
- "useTabs": false,
5
- "bracketSpacing": true,
6
- "trailingComma": "none",
7
- "tabWidth": 2,
8
- "printWidth": 120
9
- }
package/DOCKER.md DELETED
@@ -1,26 +0,0 @@
1
- # hot to test
2
-
3
- ```ruby
4
- docker pull postgres:latest
5
-
6
- # without data mount
7
- docker run -itd -e POSTGRES_USER=vminds -e POSTGRES_PASSWORD=vminds -p 5432:5432 --name postgresql postgres
8
-
9
- # with data mount
10
- docker run -itd -e POSTGRES_USER=vminds -e POSTGRES_PASSWORD=vminds -p 5432:5432 -v /data:/var/lib/postgresql/data --name postgresql postgres
11
-
12
-
13
- ```
14
-
15
- # pgAdmin
16
-
17
- ```ruby
18
-
19
- docker pull dpage/pgadmin4:latest
20
-
21
- docker run --name pgadmin-vminds -p 5051:80 -e "PGADMIN_DEFAULT_EMAIL=developers@volcanicminds.com" -e "PGADMIN_DEFAULT_PASSWORD=vminds" -d dpage/pgadmin4
22
-
23
- # pgAdmin4: connect pgsql using correct IP read from inspect (retrieve your ID by docker ps)
24
- docker inspect 6f14e1fa0702 | grep IPAddress
25
-
26
- ```
package/NPM.md DELETED
@@ -1,24 +0,0 @@
1
- # NPM
2
-
3
- [more info](https://zellwk.com/blog/publish-to-npm/)
4
-
5
- ## how to publish
6
-
7
- ```ruby
8
- npm install npm@latest -g
9
- npm login
10
- npm init --scope=volcanicminds
11
- npm publish --access public
12
- ```
13
-
14
- ## local linking
15
-
16
- ```ruby
17
- yarn link
18
- yarn link "@volcanicminds/typeorm"
19
- ```
20
-
21
- ```ruby
22
- yarn unlink
23
- yarn unlink "@volcanicminds/typeorm"
24
- ```
package/TODO.md DELETED
@@ -1,7 +0,0 @@
1
- # TODO
2
-
3
- - loading entities
4
- - expose entities to global
5
- - expose repo (controller) to global
6
- - pass options by config file or structure
7
- - test if is possibile to avoid add package pg here (let choose on the top project)
package/dist/start.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- global.npmDebugServerStarted = true;
12
- require('./index')().then((AppDataSource) => __awaiter(void 0, void 0, void 0, function* () {
13
- const c1 = new global.database.model.User();
14
- c1.breed = 'nread2';
15
- c1.age = 'young';
16
- c1.name = 'fuffy';
17
- yield global.database.repository.users.save(c1);
18
- }));
19
- //# sourceMappingURL=start.js.map
package/dist/start.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../start.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;AAEZ,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAA;AACnC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAO,aAAa,EAAE,EAAE;IAChD,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IAC3C,EAAE,CAAC,KAAK,GAAG,QAAQ,CAAA;IACnB,EAAE,CAAC,GAAG,GAAG,OAAO,CAAA;IAChB,EAAE,CAAC,IAAI,GAAG,OAAO,CAAA;IACjB,MAAM,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACjD,CAAC,CAAA,CAAC,CAAA"}
package/index.ts DELETED
@@ -1,72 +0,0 @@
1
- 'use strict'
2
-
3
- import 'reflect-metadata'
4
- import { DataSource } from 'typeorm'
5
- import * as loaderEntities from './lib/loader/entities'
6
-
7
- async function start(options) {
8
- return new Promise<DataSource>((resolve, reject) => {
9
- if (global.npmDebugServerStarted) {
10
- options = {
11
- type: 'postgres',
12
- host: '127.0.0.1',
13
- port: 5432,
14
- username: 'vminds',
15
- password: 'vminds',
16
- database: 'vminds',
17
- synchronize: true,
18
- logging: true, // query, error, schema, warn, info, all
19
- logger: '' // advanced-console, simple-console
20
- }
21
- }
22
-
23
- if (options == null || Object.keys(options).length == 0) {
24
- throw Error('Volcanic Database: options not specified')
25
- }
26
-
27
- const { LOG_DB_LEVEL = process.env.LOG_LEVEL || 'trace', LOG_COLORIZE = true } = process.env
28
-
29
- const logLevel: string | boolean =
30
- LOG_DB_LEVEL === 'trace'
31
- ? 'all'
32
- : LOG_DB_LEVEL === 'debug'
33
- ? 'query'
34
- : LOG_DB_LEVEL === 'info'
35
- ? 'info'
36
- : LOG_DB_LEVEL === 'warn'
37
- ? 'warn'
38
- : LOG_DB_LEVEL === 'error'
39
- ? 'error'
40
- : false
41
-
42
- const { classes, repositories, entities } = loaderEntities.load()
43
- options.entities = [...(options.entities || []), ...(entities || [])]
44
- options.logger = LOG_COLORIZE ? 'advanced-console' : 'simple-console'
45
- options.logging = logLevel
46
- // options.entities = [
47
- // ...(options.entities || []),
48
- // `${__dirname}/../entities/*.e.{ts,js}`,
49
- // `${process.cwd()}/src/entities/*.e.{ts,js}`
50
- // ]
51
-
52
- new DataSource(options)
53
- .initialize()
54
- .then(async (ds) => {
55
- // load uselful stuff
56
- const repository = {}
57
- Object.keys(repositories).map((r) => (repository[r] = ds.getRepository(repositories[r])))
58
-
59
- global.database = {
60
- model: classes,
61
- repository: repository
62
- }
63
-
64
- return resolve(ds)
65
- })
66
- .catch((error) => reject(error))
67
- })
68
- }
69
-
70
- module.exports = start
71
- module.exports.server = start
72
- module.exports.default = start
package/jest.config.js DELETED
@@ -1,188 +0,0 @@
1
- // For a detailed explanation regarding each configuration property, visit:
2
- // https://jestjs.io/docs/en/configuration.html
3
-
4
- module.exports = {
5
- // All imported modules in your tests should be mocked automatically
6
- // automock: false,
7
-
8
- // Stop running tests after `n` failures
9
- // bail: 0,
10
-
11
- // The directory where Jest should store its cached dependency information
12
- // cacheDirectory: "C:\\Users\\davide\\AppData\\Local\\Temp\\jest",
13
-
14
- // Automatically clear mock calls and instances between every test
15
- // clearMocks: false,
16
-
17
- // Indicates whether the coverage information should be collected while executing the test
18
- collectCoverage: true,
19
-
20
- // An array of glob patterns indicating a set of files for which coverage information should be collected
21
- // collectCoverageFrom: undefined,
22
-
23
- // The directory where Jest should output its coverage files
24
- // coverageDirectory: undefined,
25
-
26
- // An array of regexp pattern strings used to skip coverage collection
27
- // coveragePathIgnorePatterns: [
28
- // "\\\\node_modules\\\\"
29
- // ],
30
-
31
- // Indicates which provider should be used to instrument code for coverage
32
- coverageProvider: "v8",
33
-
34
- // A list of reporter names that Jest uses when writing coverage reports
35
- // coverageReporters: [
36
- // "json",
37
- // "text",
38
- // "lcov",
39
- // "clover"
40
- // ],
41
-
42
- // An object that configures minimum threshold enforcement for coverage results
43
- // coverageThreshold: undefined,
44
-
45
- // A path to a custom dependency extractor
46
- // dependencyExtractor: undefined,
47
-
48
- // Make calling deprecated APIs throw helpful error messages
49
- // errorOnDeprecated: false,
50
-
51
- // Force coverage collection from ignored files using an array of glob patterns
52
- // forceCoverageMatch: [],
53
-
54
- // A path to a module which exports an async function that is triggered once before all test suites
55
- // globalSetup: undefined,
56
-
57
- // A path to a module which exports an async function that is triggered once after all test suites
58
- // globalTeardown: undefined,
59
-
60
- // A set of global variables that need to be available in all test environments
61
- // globals: {},
62
-
63
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
64
- // maxWorkers: "50%",
65
-
66
- // An array of directory names to be searched recursively up from the requiring module's location
67
- // moduleDirectories: [
68
- // "node_modules"
69
- // ],
70
-
71
- // An array of file extensions your modules use
72
- // moduleFileExtensions: [
73
- // "js",
74
- // "json",
75
- // "jsx",
76
- // "ts",
77
- // "tsx",
78
- // "node"
79
- // ],
80
-
81
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
82
- // moduleNameMapper: {},
83
-
84
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
85
- // modulePathIgnorePatterns: [],
86
-
87
- // Activates notifications for test results
88
- // notify: false,
89
-
90
- // An enum that specifies notification mode. Requires { notify: true }
91
- // notifyMode: "failure-change",
92
-
93
- // A preset that is used as a base for Jest's configuration
94
- // preset: undefined,
95
-
96
- // Run tests from one or more projects
97
- // projects: undefined,
98
-
99
- // Use this configuration option to add custom reporters to Jest
100
- // reporters: undefined,
101
-
102
- // Automatically reset mock state between every test
103
- // resetMocks: false,
104
-
105
- // Reset the module registry before running each individual test
106
- // resetModules: false,
107
-
108
- // A path to a custom resolver
109
- // resolver: undefined,
110
-
111
- // Automatically restore mock state between every test
112
- // restoreMocks: false,
113
-
114
- // The root directory that Jest should scan for tests and modules within
115
- // rootDir: undefined,
116
-
117
- // A list of paths to directories that Jest should use to search for files in
118
- // roots: [
119
- // "<rootDir>"
120
- // ],
121
-
122
- // Allows you to use a custom runner instead of Jest's default test runner
123
- // runner: "jest-runner",
124
-
125
- // The paths to modules that run some code to configure or set up the testing environment before each test
126
- // setupFiles: [],
127
-
128
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
129
- // setupFilesAfterEnv: [],
130
-
131
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
132
- // snapshotSerializers: [],
133
-
134
- // The test environment that will be used for testing
135
- testEnvironment: "node",
136
-
137
- // Options that will be passed to the testEnvironment
138
- // testEnvironmentOptions: {},
139
-
140
- // Adds a location field to test results
141
- // testLocationInResults: false,
142
-
143
- // The glob patterns Jest uses to detect test files
144
- // testMatch: [
145
- // "**/__tests__/**/*.[jt]s?(x)",
146
- // "**/?(*.)+(spec|test).[tj]s?(x)"
147
- // ],
148
-
149
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
150
- // testPathIgnorePatterns: [
151
- // "\\\\node_modules\\\\"
152
- // ],
153
-
154
- // The regexp pattern or array of patterns that Jest uses to detect test files
155
- // testRegex: [],
156
-
157
- // This option allows the use of a custom results processor
158
- // testResultsProcessor: undefined,
159
-
160
- // This option allows use of a custom test runner
161
- // testRunner: "jasmine2",
162
-
163
- // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
164
- // testURL: "http://localhost",
165
-
166
- // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
167
- // timers: "real",
168
-
169
- // A map from regular expressions to paths to transformers
170
- // transform: undefined,
171
-
172
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
173
- // transformIgnorePatterns: [
174
- // "\\\\node_modules\\\\"
175
- // ],
176
-
177
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
178
- // unmockedModulePathPatterns: undefined,
179
-
180
- // Indicates whether each individual test should be reported during the run
181
- // verbose: undefined,
182
-
183
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
184
- // watchPathIgnorePatterns: [],
185
-
186
- // Whether to use watchman for file crawling
187
- // watchman: true,
188
- };
@@ -1,27 +0,0 @@
1
- import { Entity, Column, Index, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'
2
-
3
- @Entity()
4
- export class User {
5
- @PrimaryGeneratedColumn()
6
- id: number
7
-
8
- @Index()
9
- @Column()
10
- name: string
11
-
12
- @Index()
13
- @Column()
14
- email: string
15
-
16
- @Column()
17
- password: string
18
-
19
- @Column({ type: 'varchar', array: true, nullable: true })
20
- roles: string[]
21
-
22
- @CreateDateColumn()
23
- createdAt: Date
24
-
25
- @UpdateDateColumn()
26
- updatedAt: Date
27
- }
@@ -1,24 +0,0 @@
1
- const glob = require('glob')
2
- const pluralize = require('pluralize')
3
-
4
- export function load() {
5
- const classes: any = {}
6
- const repositories: any = {}
7
- const entities: any[] = []
8
-
9
- const patterns = [`${__dirname}/../entities/*.e.{ts,js}`, `${process.cwd()}/src/entities/*.e.{ts,js}`]
10
- patterns.forEach((pattern) => {
11
- glob.sync(pattern, { nodir: true, nosort: true, stat: false }).forEach((f: string) => {
12
- const entityClass = require(f)
13
- const entityNames = Object.keys(entityClass)
14
-
15
- entityNames.map((name) => {
16
- classes[name] = entityClass[name]
17
- repositories[pluralize(name.toLowerCase())] = entityClass[name]
18
- entities.push(entityClass[name])
19
- })
20
- })
21
- })
22
-
23
- return { classes, repositories, entities }
24
- }
package/start.ts DELETED
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- global.npmDebugServerStarted = true // internal debug purpose
4
- require('./index')().then(async (AppDataSource) => {
5
- const c1 = new global.database.model.User()
6
- c1.breed = 'nread2'
7
- c1.age = 'young'
8
- c1.name = 'fuffy'
9
- await global.database.repository.users.save(c1)
10
- })
@@ -1,5 +0,0 @@
1
- describe('sum module', () => {
2
- test('adds 1 + 2 to equal 3', () => {
3
- expect(1 + 2).toBe(3)
4
- })
5
- })
package/tsconfig.json DELETED
@@ -1,39 +0,0 @@
1
- // https://typestrong.org/ts-node/docs/configuration/
2
- {
3
- "extends": "ts-node/node16/tsconfig.json",
4
- "ts-node": {
5
- "files": true,
6
- "compilerOptions": {
7
- "module": "commonjs"
8
- }
9
- },
10
- "compilerOptions": {
11
- "module": "commonjs",
12
- "declaration": false,
13
- "noImplicitAny": false,
14
- "noUnusedLocals": false,
15
- "removeComments": true,
16
- "noLib": false,
17
- "emitDecoratorMetadata": true,
18
- "experimentalDecorators": true,
19
- "useUnknownInCatchVariables": false,
20
- "strictPropertyInitialization": false,
21
- "target": "es6",
22
- "sourceMap": true,
23
- "allowJs": true,
24
- "outDir": "dist",
25
- "lib": ["es7"],
26
- "paths": {
27
- "@types": ["./types"]
28
- }
29
- // "types": ["node"],
30
- // "typeRoots": ["./node_modules/@types", "./types", "./lib/types"],
31
- // "rootDirs": ["lib", "config", "types"],
32
- // "baseUrl": ".",
33
- // "paths": {
34
- // "*": ["*", "components/*"]
35
- // }
36
- },
37
- "include": ["*.ts", "*.d.ts", "lib/**/*", "config/**/*", "hooks/**/*", "types/**/*"],
38
- "exclude": ["node_modules", "test/**/*"]
39
- }