typeorm-hasura 0.0.14 → 0.0.16

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.
@@ -17,7 +17,7 @@ exports.AppDataSource = new typeorm_1.DataSource({
17
17
  synchronize: false,
18
18
  logging: false,
19
19
  entities: Object.values(entities),
20
- migrations: ['./test/migration/*.ts'],
20
+ migrations: ['./dev-playground/migration/*.ts'],
21
21
  subscribers: [],
22
22
  });
23
23
  //# sourceMappingURL=data-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../dev-playground/data-source.ts"],"names":[],"mappings":";;;AAAA,4BAAyB;AACzB,qCAAoC;AACpC,qCAAoC;AAEpC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;AAEjF,QAAA,aAAa,GAAG,IAAI,oBAAU,CAAC;IACxC,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC;IACrB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IACjC,UAAU,EAAE,CAAC,uBAAuB,CAAC;IACrC,WAAW,EAAE,EAAE;CAClB,CAAC,CAAA"}
1
+ {"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../dev-playground/data-source.ts"],"names":[],"mappings":";;;AAAA,4BAAyB;AACzB,qCAAoC;AACpC,qCAAoC;AAEpC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;AAEjF,QAAA,aAAa,GAAG,IAAI,oBAAU,CAAC;IACxC,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC;IACrB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IACjC,UAAU,EAAE,CAAC,iCAAiC,CAAC;IAC/C,WAAW,EAAE,EAAE;CAClB,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { BaseEntity } from "typeorm";
2
+ import { Org, UserView } from ".";
3
+ export declare class ProductView extends BaseEntity {
4
+ id: string;
5
+ name: string;
6
+ orgId: string;
7
+ org: Org;
8
+ userId: string;
9
+ user: UserView;
10
+ }
@@ -0,0 +1,71 @@
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.ProductView = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const src_1 = require("../../src");
15
+ const UserRole_1 = require("../UserRole");
16
+ const _1 = require(".");
17
+ let ProductView = class ProductView extends typeorm_1.BaseEntity {
18
+ };
19
+ __decorate([
20
+ (0, typeorm_1.ViewColumn)(),
21
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select'] } }),
22
+ __metadata("design:type", String)
23
+ ], ProductView.prototype, "id", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.ViewColumn)(),
26
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select', 'update'] } }),
27
+ __metadata("design:type", String)
28
+ ], ProductView.prototype, "name", void 0);
29
+ __decorate([
30
+ (0, typeorm_1.ViewColumn)(),
31
+ (0, typeorm_1.RelationId)((frame) => frame.org),
32
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select'] } }),
33
+ __metadata("design:type", String)
34
+ ], ProductView.prototype, "orgId", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.ManyToOne)(() => _1.Org),
37
+ (0, typeorm_1.JoinColumn)({ name: "orgId" }),
38
+ __metadata("design:type", _1.Org)
39
+ ], ProductView.prototype, "org", void 0);
40
+ __decorate([
41
+ (0, typeorm_1.ViewColumn)(),
42
+ (0, typeorm_1.RelationId)((frame) => frame.user),
43
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select'] } }),
44
+ __metadata("design:type", String)
45
+ ], ProductView.prototype, "userId", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.ManyToOne)(() => _1.UserView),
48
+ __metadata("design:type", _1.UserView)
49
+ ], ProductView.prototype, "user", void 0);
50
+ ProductView = __decorate([
51
+ (0, typeorm_1.ViewEntity)({
52
+ name: 'ProductView',
53
+ expression: (dataSource) => dataSource
54
+ .createQueryBuilder()
55
+ .select("Product.id", "id")
56
+ .addSelect("Product.name", "name")
57
+ .addSelect("Product.orgId", "orgId")
58
+ .addSelect("Product.userId", "userId")
59
+ .from(_1.Product, "Product")
60
+ }),
61
+ (0, src_1.HasuraEntity)({
62
+ customName: 'ProductView',
63
+ permissions: {
64
+ [UserRole_1.UserRole.user]: {
65
+ select: true,
66
+ }
67
+ }
68
+ })
69
+ ], ProductView);
70
+ exports.ProductView = ProductView;
71
+ //# sourceMappingURL=ProductView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductView.js","sourceRoot":"","sources":["../../../dev-playground/entity/ProductView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA4G;AAC5G,mCAAuD;AACvD,0CAAuC;AACvC,wBAA2C;AAqB3C,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,oBAAU;CAyB1C,CAAA;AAtBG;IAFC,IAAA,oBAAU,GAAE;IACZ,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;uCACnD;AAIZ;IAFC,IAAA,oBAAU,GAAE;IACZ,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;;yCAC3D;AAKd;IAHC,IAAA,oBAAU,GAAE;IACZ,IAAA,oBAAU,EAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;IAC7C,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;0CAChD;AAIf;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,MAAG,CAAC;IACpB,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8BACxB,MAAG;wCAAC;AAKV;IAHC,IAAA,oBAAU,GAAE;IACZ,IAAA,oBAAU,EAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;IAC9C,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;2CAC/C;AAGhB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,WAAQ,CAAC;8BACnB,WAAQ;yCAAC;AAxBP,WAAW;IAnBvB,IAAA,oBAAU,EAAC;QACR,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE,CACnC,UAAU;aACL,kBAAkB,EAAE;aACpB,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC;aAC1B,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;aACjC,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC;aACnC,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CAAC;aACrC,IAAI,CAAC,UAAO,EAAE,SAAS,CAAC;KACpC,CAAC;IACD,IAAA,kBAAY,EAAc;QACvB,UAAU,EAAE,aAAa;QACzB,WAAW,EAAE;YACT,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE;gBACb,MAAM,EAAE,IAAI;aACf;SACJ;KACJ,CAAC;GACW,WAAW,CAyBvB;AAzBY,kCAAW"}
@@ -0,0 +1,10 @@
1
+ import { BaseEntity } from "typeorm";
2
+ import { Org, ProductView } from ".";
3
+ export declare class UserView extends BaseEntity {
4
+ id: string;
5
+ name: string;
6
+ orgId: string;
7
+ testJsonB: object;
8
+ org: Org;
9
+ products: ProductView[];
10
+ }
@@ -0,0 +1,68 @@
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.UserView = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const src_1 = require("../../src");
15
+ const UserRole_1 = require("../UserRole");
16
+ const _1 = require(".");
17
+ let UserView = class UserView extends typeorm_1.BaseEntity {
18
+ };
19
+ __decorate([
20
+ (0, typeorm_1.ViewColumn)(),
21
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select'] } }),
22
+ __metadata("design:type", String)
23
+ ], UserView.prototype, "id", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.ViewColumn)(),
26
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select', 'update'] } }),
27
+ __metadata("design:type", String)
28
+ ], UserView.prototype, "name", void 0);
29
+ __decorate([
30
+ (0, typeorm_1.ViewColumn)(),
31
+ (0, typeorm_1.RelationId)((frame) => frame.org),
32
+ (0, src_1.HasuraColumn)({ permissions: { [UserRole_1.UserRole.user]: ['select'] } }),
33
+ __metadata("design:type", String)
34
+ ], UserView.prototype, "orgId", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.ViewColumn)(),
37
+ __metadata("design:type", Object)
38
+ ], UserView.prototype, "testJsonB", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.ManyToOne)(() => _1.Org),
41
+ __metadata("design:type", _1.Org)
42
+ ], UserView.prototype, "org", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.OneToMany)(() => _1.ProductView, (product) => product.user),
45
+ __metadata("design:type", Array)
46
+ ], UserView.prototype, "products", void 0);
47
+ UserView = __decorate([
48
+ (0, typeorm_1.ViewEntity)({
49
+ name: 'UserView',
50
+ expression: (dataSource) => dataSource
51
+ .createQueryBuilder()
52
+ .select("User.id", "id")
53
+ .addSelect("User.name", "name")
54
+ .addSelect("User.orgId", "orgId")
55
+ .addSelect("User.testJsonB", "testJsonB")
56
+ .from(_1.User, "User")
57
+ }),
58
+ (0, src_1.HasuraEntity)({
59
+ customName: 'UserView',
60
+ permissions: {
61
+ [UserRole_1.UserRole.user]: {
62
+ select: true,
63
+ },
64
+ },
65
+ })
66
+ ], UserView);
67
+ exports.UserView = UserView;
68
+ //# sourceMappingURL=UserView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserView.js","sourceRoot":"","sources":["../../../dev-playground/entity/UserView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA2G;AAC3G,mCAAuD;AACvD,0CAAuC;AACvC,wBAA2C;AAqB3C,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,oBAAU;CAsBvC,CAAA;AAnBC;IAFC,IAAA,oBAAU,GAAE;IACZ,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;oCACnD;AAIZ;IAFC,IAAA,oBAAU,GAAE;IACZ,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;;sCAC3D;AAKd;IAHC,IAAA,oBAAU,GAAE;IACZ,IAAA,oBAAU,EAAC,CAAC,KAAe,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;IAC1C,IAAA,kBAAY,EAAC,EAAE,WAAW,EAAE,EAAE,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;uCAChD;AAGf;IADC,IAAA,oBAAU,GAAE;;2CACK;AAGlB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,MAAG,CAAC;8BACf,MAAG;qCAAC;AAGV;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,cAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;;0CAC/B;AArBd,QAAQ;IAnBpB,IAAA,oBAAU,EAAC;QACV,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE,CACrC,UAAU;aACP,kBAAkB,EAAE;aACpB,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC;aACvB,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;aAC9B,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;aAChC,SAAS,CAAC,gBAAgB,EAAE,WAAW,CAAC;aACxC,IAAI,CAAC,OAAI,EAAE,MAAM,CAAC;KACxB,CAAC;IACD,IAAA,kBAAY,EAAW;QACtB,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE;YACX,CAAC,mBAAQ,CAAC,IAAI,CAAC,EAAE;gBACf,MAAM,EAAE,IAAI;aACb;SACF;KACF,CAAC;GACW,QAAQ,CAsBpB;AAtBY,4BAAQ"}
@@ -1,3 +1,5 @@
1
1
  export * from './Org';
2
2
  export * from './Product';
3
3
  export * from './User';
4
+ export * from './UserView';
5
+ export * from './ProductView';
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Org"), exports);
18
18
  __exportStar(require("./Product"), exports);
19
19
  __exportStar(require("./User"), exports);
20
+ __exportStar(require("./UserView"), exports);
21
+ __exportStar(require("./ProductView"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev-playground/entity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B;AAC1B,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev-playground/entity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B;AAC1B,yCAAuB;AAEvB,6CAA0B;AAC1B,gDAA6B"}
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.next1679166386871 = void 0;
13
- const schema = process.env.DB_SCHEMA || "${schema}";
13
+ const schema = process.env.DB_SCHEMA || "public";
14
14
  if (schema.includes('"') || schema.includes("'") || schema.includes("\\")) {
15
15
  throw new Error("Invalid schema name");
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"1679166386871-next.js","sourceRoot":"","sources":["../../../dev-playground/migration/1679166386871-next.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,WAAW,CAAC;AAEpD,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;IACvE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;CAC1C;AAED,MAAa,iBAAiB;IAA9B;QACI,SAAI,GAAG,mBAAmB,CAAA;IAmB9B,CAAC;IAjBS,EAAE,CAAC,WAAwB;;YAC7B,MAAM,WAAW,CAAC,KAAK,CAAC,iBAAiB,MAAM,qJAAqJ,CAAC,CAAC;YACtM,MAAM,WAAW,CAAC,KAAK,CAAC,iBAAiB,MAAM,uKAAuK,CAAC,CAAC;YACxN,MAAM,WAAW,CAAC,KAAK,CAAC,iBAAiB,MAAM,sIAAsI,CAAC,CAAC;YACvL,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,8FAA8F,MAAM,uDAAuD,CAAC,CAAC;YAC3M,MAAM,WAAW,CAAC,KAAK,CAAC,g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AAM,uKAAuK,CAAC,CAAC;YACxN,MAAM,WAAW,CAAC,KAAK,CAAC,iBAAiB,MAAM,sIAAsI,CAAC,CAAC;YACvL,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,8FAA8F,MAAM,uDAAuD,CAAC,CAAC;YAC3M,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,iGAAiG,MAAM,uDAAuD,CAAC,CAAC;YAC9M,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,kGAAkG,MAAM,wDAAwD,CAAC,CAAC;QACpN,CAAC;KAAA;IAEK,IAAI,CAAC,WAAwB;;YAC/B,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,8DAA8D,CAAC,CAAC;YAC9G,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,8DAA8D,CAAC,CAAC;YAC9G,MAAM,WAAW,CAAC,KAAK,CAAC,gBAAgB,MAAM,2DAA2D,CAAC,CAAC;YAC3G,MAAM,WAAW,CAAC,KAAK,CAAC,eAAe,MAAM,SAAS,CAAC,CAAC;YACxD,MAAM,WAAW,CAAC,KAAK,CAAC,eAAe,MAAM,aAAa,CAAC,CAAC;YAC5D,MAAM,WAAW,CAAC,KAAK,CAAC,eAAe,MAAM,UAAU,CAAC,CAAC;QAC7D,CAAC;KAAA;CACJ;AApBD,8CAoBC"}
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+ export declare class Next1687868108675 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,35 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Next1687868108675 = void 0;
13
+ class Next1687868108675 {
14
+ constructor() {
15
+ this.name = 'Next1687868108675';
16
+ }
17
+ up(queryRunner) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ yield queryRunner.query(`CREATE VIEW "UserView" AS SELECT "User"."id" AS "id", "User"."name" AS "name", "User"."orgId" AS "orgId", "User"."testJsonB" AS "testJsonB" FROM "public"."User" "User"`);
20
+ yield queryRunner.query(`INSERT INTO "typeorm_metadata"("database", "schema", "table", "type", "name", "value") VALUES (DEFAULT, $1, DEFAULT, $2, $3, $4)`, ["public", "VIEW", "UserView", "SELECT \"User\".\"id\" AS \"id\", \"User\".\"name\" AS \"name\", \"User\".\"orgId\" AS \"orgId\", \"User\".\"testJsonB\" AS \"testJsonB\" FROM \"public\".\"User\" \"User\""]);
21
+ yield queryRunner.query(`CREATE VIEW "ProductView" AS SELECT "Product"."id" AS "id", "Product"."name" AS "name", "Product"."orgId" AS "orgId", "Product"."userId" AS "userId" FROM "public"."Product" "Product"`);
22
+ yield queryRunner.query(`INSERT INTO "typeorm_metadata"("database", "schema", "table", "type", "name", "value") VALUES (DEFAULT, $1, DEFAULT, $2, $3, $4)`, ["public", "VIEW", "ProductView", "SELECT \"Product\".\"id\" AS \"id\", \"Product\".\"name\" AS \"name\", \"Product\".\"orgId\" AS \"orgId\", \"Product\".\"userId\" AS \"userId\" FROM \"public\".\"Product\" \"Product\""]);
23
+ });
24
+ }
25
+ down(queryRunner) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ yield queryRunner.query(`DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "schema" = $3`, ["VIEW", "ProductView", "public"]);
28
+ yield queryRunner.query(`DROP VIEW "ProductView"`);
29
+ yield queryRunner.query(`DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "schema" = $3`, ["VIEW", "UserView", "public"]);
30
+ yield queryRunner.query(`DROP VIEW "UserView"`);
31
+ });
32
+ }
33
+ }
34
+ exports.Next1687868108675 = Next1687868108675;
35
+ //# sourceMappingURL=1687868108675-next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1687868108675-next.js","sourceRoot":"","sources":["../../../dev-playground/migration/1687868108675-next.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAa,iBAAiB;IAA9B;QACI,SAAI,GAAG,mBAAmB,CAAA;IAgB9B,CAAC;IAdgB,EAAE,CAAC,WAAwB;;YACpC,MAAM,WAAW,CAAC,KAAK,CAAC,yKAAyK,CAAC,CAAC;YACnM,MAAM,WAAW,CAAC,KAAK,CAAC,kIAAkI,EAAE,CAAC,QAAQ,EAAC,MAAM,EAAC,UAAU,EAAC,6KAA6K,CAAC,CAAC,CAAC;YACxW,MAAM,WAAW,CAAC,KAAK,CAAC,wLAAwL,CAAC,CAAC;YAClN,MAAM,WAAW,CAAC,KAAK,CAAC,kIAAkI,EAAE,CAAC,QAAQ,EAAC,MAAM,EAAC,aAAa,EAAC,yLAAyL,CAAC,CAAC,CAAC;QAC3X,CAAC;KAAA;IAEY,IAAI,CAAC,WAAwB;;YACtC,MAAM,WAAW,CAAC,KAAK,CAAC,oFAAoF,EAAE,CAAC,MAAM,EAAC,aAAa,EAAC,QAAQ,CAAC,CAAC,CAAC;YAC/I,MAAM,WAAW,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACnD,MAAM,WAAW,CAAC,KAAK,CAAC,oFAAoF,EAAE,CAAC,MAAM,EAAC,UAAU,EAAC,QAAQ,CAAC,CAAC,CAAC;YAC5I,MAAM,WAAW,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACpD,CAAC;KAAA;CAEJ;AAjBD,8CAiBC"}
@@ -18,13 +18,10 @@ function generatePermissions(dataSourceOptions, table, { entityOptions, columnMe
18
18
  if (select) {
19
19
  if (select === true)
20
20
  select = {};
21
+ const limit = select.limit || dataSourceOptions.defaultSelectPermissionLimit;
21
22
  result.select_permissions.push({
22
23
  role: key,
23
- permission: {
24
- columns: columnNames(columnMetadata, key, "select"),
25
- filter: (0, whereClause_1.convertWhereClause)(table, where, select.where),
26
- limit: select.limit || dataSourceOptions.defaultSelectPermissionLimit,
27
- }
24
+ permission: Object.assign({ columns: columnNames(columnMetadata, key, "select"), filter: (0, whereClause_1.convertWhereClause)(table, where, select.where) }, (limit ? { limit } : {}))
28
25
  });
29
26
  }
30
27
  if (update) {
@@ -32,12 +29,7 @@ function generatePermissions(dataSourceOptions, table, { entityOptions, columnMe
32
29
  update = {};
33
30
  result.update_permissions.push({
34
31
  role: key,
35
- permission: {
36
- columns: columnNames(columnMetadata, key, "update"),
37
- filter: (0, whereClause_1.convertWhereClause)(table, where, update.where),
38
- check: (0, whereClause_1.convertWhereClause)(table, update.check),
39
- set: update.set
40
- }
32
+ permission: Object.assign(Object.assign({ columns: columnNames(columnMetadata, key, "update"), filter: (0, whereClause_1.convertWhereClause)(table, where, update.where) }, (update.check ? { check: (0, whereClause_1.convertWhereClause)(table, update.check) } : {})), (update.set ? { set: update.set } : {}))
41
33
  });
42
34
  }
43
35
  if (insert) {
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/mappers/permissions.ts"],"names":[],"mappings":";;;AAGA,+CAAkD;AAMlD,SAAgB,mBAAmB,CAC/B,iBAAoC,EACpC,KAA6B,EAC7B,EAAE,aAAa,EAAE,cAAc,EAA0C;IAGzE,MAAM,MAAM,GAAqB;QAC7B,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;KACzB,CAAA;IACD,IAAI,CAAC,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;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AApED,kDAoEC;AAED,SAAS,WAAW,CAAC,GAAqB,EAAE,QAAgB,EAAE,MAAsB;IAChF,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;;QACvB,IAAI,UAAU,GAAG,MAAA,MAAA,MAAM,CAAC,OAAO,0CAAE,WAAW,0CAAG,QAAQ,CAAC,CAAA;QACxD,IAAI,OAAO,UAAU,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS;YAAE,OAAO,KAAK,CAAC;QAC5E,IAAI,OAAO,UAAU,IAAI,QAAQ;YAC7B,UAAU,GAAG,CAAC,UAAU,CAAC,CAAA;QAC7B,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;AAC/B,CAAC"}
@@ -1,9 +1,7 @@
1
1
  import * as TypeORM from "typeorm";
2
2
  import type * as Hasura from "hasura-metadata-types";
3
3
  type RelationshipKind = 'object_relationships' | 'array_relationships';
4
- export declare function generateRelationship(relation: TypeORM.EntityMetadata['relations'][number]): {
5
- kind: RelationshipKind;
6
- relationship: Hasura.LocalTableObjectRelationship | Hasura.SameTableObjectRelationship;
7
- };
4
+ type Relationship = Hasura.LocalTableObjectRelationship | Hasura.SameTableObjectRelationship | Hasura.ManualObjectRelationship;
5
+ export declare function generateRelationship(relation: TypeORM.EntityMetadata['relations'][number]): Relationship;
8
6
  export declare function generateRelationships(relations: TypeORM.EntityMetadata['relations']): Pick<Hasura.MetadataTable, RelationshipKind>;
9
7
  export {};
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateRelationships = exports.generateRelationship = void 0;
4
4
  function generateRelationship(relation) {
5
- const kind = relation.relationType.endsWith('-to-one') ? 'object_relationships' : 'array_relationships';
6
- const owningRelation = relation.isOwning ? relation : relation.inverseRelation;
5
+ const owningRelation = relation.isOwning ?
6
+ relation : relation.inverseRelation;
7
7
  if (!owningRelation || relation.isManyToMany)
8
8
  throw new Error('Does not support many-to-many relations yet, so we will skip this specific relation. ' +
9
9
  'Also its possible that you have missed to set inverse side of the relation.');
@@ -12,21 +12,42 @@ function generateRelationship(relation) {
12
12
  // const schema = owningRelation.entityMetadata.schema;
13
13
  // @ts-ignore is that okay?
14
14
  const schema = owningRelation.target.dataSource.options.schema || 'public';
15
- const relationship = relation.isOwning ? {
16
- name: relation.propertyName,
17
- using: {
18
- foreign_key_constraint_on: columns.length === 1 ? columns[0] : columns
19
- }
20
- } : {
21
- name: relation.propertyName,
22
- using: {
23
- foreign_key_constraint_on: Object.assign(Object.assign({}, ((columns === null || columns === void 0 ? void 0 : columns.length) === 1 ? { column: columns[0] } : { columns })), { table: {
24
- name: owningRelation.entityMetadata.tableName,
25
- schema,
26
- } })
27
- }
28
- };
29
- return { kind, relationship };
15
+ const tableType = owningRelation.entityMetadata.tableType;
16
+ if (tableType === "regular" && relation.isOwning)
17
+ return {
18
+ name: relation.propertyName,
19
+ using: {
20
+ foreign_key_constraint_on: columns.length === 1 ? columns[0] : columns
21
+ }
22
+ };
23
+ else if (tableType === "regular" && !relation.isOwning)
24
+ return {
25
+ name: relation.propertyName,
26
+ using: {
27
+ foreign_key_constraint_on: Object.assign(Object.assign({}, ((columns === null || columns === void 0 ? void 0 : columns.length) === 1 ? { column: columns[0] } : { columns })), { table: {
28
+ name: owningRelation.entityMetadata.tableName,
29
+ schema,
30
+ } })
31
+ }
32
+ };
33
+ else if (tableType === "view")
34
+ return {
35
+ name: relation.propertyName,
36
+ using: {
37
+ manual_configuration: {
38
+ column_mapping: Object.fromEntries(relation.joinColumns
39
+ .filter(column => column.referencedColumn)
40
+ .map(column => [column.propertyName, column.referencedColumn.propertyName])),
41
+ insertion_order: null,
42
+ remote_table: {
43
+ name: relation.inverseEntityMetadata.tableName,
44
+ schema
45
+ }
46
+ }
47
+ }
48
+ };
49
+ else
50
+ throw new Error("Relation tableType is not available");
30
51
  }
31
52
  exports.generateRelationship = generateRelationship;
32
53
  function generateRelationships(relations) {
@@ -38,7 +59,9 @@ function generateRelationships(relations) {
38
59
  relations.sort((a, b) => a.propertyName.localeCompare(b.propertyName));
39
60
  for (const relation of relations) {
40
61
  try {
41
- const { kind, relationship } = generateRelationship(relation);
62
+ const kind = relation.relationType.endsWith('-to-one') ?
63
+ 'object_relationships' : 'array_relationships';
64
+ const relationship = generateRelationship(relation);
42
65
  // @ts-ignore dont want to play with types for now
43
66
  result[kind].push(relationship);
44
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../../src/mappers/relationships.ts"],"names":[],"mappings":";;;AAKA,SAAgB,oBAAoB,CAAC,QAAqD;IAItF,MAAM,IAAI,GAAG,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAExG,MAAM,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;IAE/E,IAAI,CAAC,cAAc,IAAI,QAAQ,CAAC,YAAY;QACxC,MAAM,IAAI,KAAK,CAAC,uFAAuF;YACnG,6EAA6E,CAAC,CAAC;IAEvF,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAE9E,uBAAuB;IACvB,uDAAuD;IACvD,2BAA2B;IAC3B,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;IAE3E,MAAM,YAAY,GACd,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChB,IAAI,EAAE,QAAQ,CAAC,YAAY;QAC3B,KA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AC,QAAQ,CAAC,CAAC;YACpD,kDAAkD;YAClD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACnC;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAvBD,sDAuBC"}
@@ -15,7 +15,7 @@ function generateSource(dataSourceOptions) {
15
15
  // sort to be consistent with hasura
16
16
  .sort((a, b) => a.name.localeCompare(b.name))
17
17
  // we only want to generate tables for regular tables cuz we doesn't support another types
18
- .filter(table => table.tableType === 'regular')
18
+ .filter(table => table.tableType === 'regular' || table.tableType === "view")
19
19
  .map(table => (0, table_1.generateTable)(dataSourceOptions, table)),
20
20
  customization,
21
21
  configuration: {
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/mappers/source.ts"],"names":[],"mappings":";;;AAEA,6CAA6C;AAC7C,+CAA+C;AAC/C,mCAAwC;AAExC,SAAgB,cAAc,CAAC,iBAAoC;IAC/D,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC;IAEjF,uBAAuB;IACvB,wDAAwD;IAExD,OAAO;QACH,IAAI;QACJ,IAAI,EAAE,IAAA,0BAAa,EAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;QAC5C,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,eAAe,CAAC;YACnC,oCAAoC;aACnC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7C,0FAA0F;aACzF,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC;aAC9C,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAA,qB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nC;YACD,mBAAmB,EAAE,wBAAwB;SAChD;KACJ,CAAA;AACL,CAAC;AAzBD,wCAyBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typeorm-hasura",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "hasura",
@@ -44,7 +44,7 @@
44
44
  "axios": "^1.3.5",
45
45
  "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
46
46
  "graphql-tag": "^2.0.0",
47
- "hasura-metadata-types": "^2.24.1",
47
+ "hasura-metadata-types": "^2.26.0",
48
48
  "lodash.snakecase": "^4.1.1"
49
49
  },
50
50
  "peerDependencies": {
@@ -65,6 +65,6 @@
65
65
  "rimraf": "^3.0.2",
66
66
  "ts-jest": "^29.0.5",
67
67
  "ts-node": "^10.9.1",
68
- "typeorm": "^0.3.12"
68
+ "typeorm": "^0.3.16"
69
69
  }
70
70
  }
package/readme.md CHANGED
@@ -1,8 +1,4 @@
1
- # typeorm-hasura
2
-
3
- [![npm version](https://badge.fury.io/js/typeorm-hasura.svg)](https://badge.fury.io/js/typeorm-hasura)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
1
+ # typeorm-hasura [![npm version](https://badge.fury.io/js/typeorm-hasura.svg)](https://badge.fury.io/js/typeorm-hasura) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
2
 
7
3
  `typeorm-hasura` is a JavaScript library that generates Hasura metadata from TypeORM entities.
8
4
  This library is designed to automate the process of creating Hasura metadata,