@darraghor/nest-backend-libs 2.26.0 → 2.27.0

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,3 @@
1
+ export declare class DisabledSuperPowersService {
2
+ resetDatabase(): Promise<void>;
3
+ }
@@ -0,0 +1,19 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable } from "@nestjs/common";
8
+ import { BadRequestError } from "passport-headerapikey";
9
+ let DisabledSuperPowersService = class DisabledSuperPowersService {
10
+ resetDatabase() {
11
+ throw new BadRequestError("Super powers are disabled");
12
+ }
13
+ };
14
+ DisabledSuperPowersService = __decorate([
15
+ Injectable()
16
+ // eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
17
+ ], DisabledSuperPowersService);
18
+ export { DisabledSuperPowersService };
19
+ //# sourceMappingURL=dosabled-super-powers.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dosabled-super-powers.service.js","sourceRoot":"","sources":["../../src/super-powers/dosabled-super-powers.service.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAI/C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACnC,aAAa;QACT,MAAM,IAAI,eAAe,CAAC,2BAA2B,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AAJY,0BAA0B;IAFtC,UAAU,EAAE;IACb,iFAAiF;GACpE,0BAA0B,CAItC;SAJY,0BAA0B"}
@@ -0,0 +1,6 @@
1
+ import { DisabledSuperPowersService } from "./dosabled-super-powers.service.js";
2
+ import { SuperPowersService } from "./super-powers.service.js";
3
+ export declare const SpServiceProvider: {
4
+ provide: typeof SuperPowersService;
5
+ useClass: typeof DisabledSuperPowersService | typeof SuperPowersService;
6
+ };
@@ -0,0 +1,12 @@
1
+ import { DisabledSuperPowersService } from "./dosabled-super-powers.service.js";
2
+ import { SuperPowersService } from "./super-powers.service.js";
3
+ // not going to use config service just for this
4
+ // should consider changing some of these to
5
+ // dynamic modules to enable testing
6
+ export const SpServiceProvider = {
7
+ provide: SuperPowersService,
8
+ useClass: process.env.ENABLE_SUPER_POWERS === "true"
9
+ ? SuperPowersService
10
+ : DisabledSuperPowersService,
11
+ };
12
+ //# sourceMappingURL=spService.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spService.provider.js","sourceRoot":"","sources":["../../src/super-powers/spService.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAE7D,gDAAgD;AAChD,4CAA4C;AAC5C,oCAAoC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,OAAO,EAAE,kBAAkB;IAC3B,QAAQ,EACJ,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,MAAM;QACtC,CAAC,CAAC,kBAAkB;QACpB,CAAC,CAAC,0BAA0B;CACvC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { SuperPowersService } from "./super-powers.service.js";
2
+ export declare class SuperPowersController {
3
+ private readonly spService;
4
+ constructor(spService: SuperPowersService);
5
+ findOne(): Promise<boolean>;
6
+ }
@@ -0,0 +1,41 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { UseGuards, Controller, Post } from "@nestjs/common";
11
+ import { ApiBearerAuth, ApiTags, ApiOkResponse } from "@nestjs/swagger";
12
+ import { ClaimsAuthorisationGuard } from "../authorization/guards/ClaimsAuthorisationGuard.js";
13
+ import { DefaultAuthGuard } from "../authorization/guards/DefaultAuthGuard.js";
14
+ import { MandatoryUserClaims } from "../authorization/guards/MandatoryUserClaims.decorator.js";
15
+ import { SuperPowersService } from "./super-powers.service.js";
16
+ let SuperPowersController = class SuperPowersController {
17
+ spService;
18
+ constructor(spService) {
19
+ this.spService = spService;
20
+ }
21
+ async findOne() {
22
+ return this.spService.resetDatabase();
23
+ }
24
+ };
25
+ __decorate([
26
+ Post("reset-database"),
27
+ ApiOkResponse(),
28
+ MandatoryUserClaims("modify:all"),
29
+ __metadata("design:type", Function),
30
+ __metadata("design:paramtypes", []),
31
+ __metadata("design:returntype", Promise)
32
+ ], SuperPowersController.prototype, "findOne", null);
33
+ SuperPowersController = __decorate([
34
+ UseGuards(DefaultAuthGuard, ClaimsAuthorisationGuard),
35
+ ApiBearerAuth(),
36
+ Controller("super-powers"),
37
+ ApiTags("Application Support"),
38
+ __metadata("design:paramtypes", [SuperPowersService])
39
+ ], SuperPowersController);
40
+ export { SuperPowersController };
41
+ //# sourceMappingURL=super-powers.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"super-powers.controller.js","sourceRoot":"","sources":["../../src/super-powers/super-powers.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAE,OAAO,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAC,wBAAwB,EAAC,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAC,gBAAgB,EAAC,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,0DAA0D,CAAC;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAMtD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACD;IAA7B,YAA6B,SAA6B;QAA7B,cAAS,GAAT,SAAS,CAAoB;IAAG,CAAC;IAKxD,AAAN,KAAK,CAAC,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;IAC1C,CAAC;CACJ,CAAA;AAHS;IAHL,IAAI,CAAC,gBAAgB,CAAC;IACtB,aAAa,EAAE;IACf,mBAAmB,CAAC,YAAY,CAAC;;;;oDAGjC;AARQ,qBAAqB;IAJjC,SAAS,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IACrD,aAAa,EAAE;IACf,UAAU,CAAC,cAAc,CAAC;IAC1B,OAAO,CAAC,qBAAqB,CAAC;qCAEa,kBAAkB;GADjD,qBAAqB,CASjC;SATY,qBAAqB"}
@@ -0,0 +1,2 @@
1
+ export declare class SuperPowersModule {
2
+ }
@@ -0,0 +1,21 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Module } from "@nestjs/common";
8
+ import { CoreModule } from "../root-app/core-app.module.js";
9
+ import { SpServiceProvider } from "./spService.provider.js";
10
+ import { SuperPowersController } from "./super-powers.controller.js";
11
+ let SuperPowersModule = class SuperPowersModule {
12
+ };
13
+ SuperPowersModule = __decorate([
14
+ Module({
15
+ imports: [CoreModule],
16
+ controllers: [SuperPowersController],
17
+ providers: [SpServiceProvider],
18
+ })
19
+ ], SuperPowersModule);
20
+ export { SuperPowersModule };
21
+ //# sourceMappingURL=super-powers.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"super-powers.module.js","sourceRoot":"","sources":["../../src/super-powers/super-powers.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAO5D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAL7B,MAAM,CAAC;QACJ,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACpC,SAAS,EAAE,CAAC,iBAAiB,CAAC;KACjC,CAAC;GACW,iBAAiB,CAAG;SAApB,iBAAiB"}
@@ -0,0 +1,16 @@
1
+ import { EntityManager } from "typeorm";
2
+ /**
3
+ * This service supports integration testing. It allows
4
+ * some of the database data to be cleaned up by the
5
+ * power user.
6
+ *
7
+ * If you create additional models that have foreign key
8
+ * relationships to the models in this service, you will
9
+ * need to clean up those models as well, before running this
10
+ * or these will fail.
11
+ */
12
+ export declare class SuperPowersService {
13
+ private readonly entityManager;
14
+ constructor(entityManager: EntityManager);
15
+ resetDatabase(): Promise<boolean>;
16
+ }
@@ -0,0 +1,46 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Injectable } from "@nestjs/common";
11
+ import { EntityManager } from "typeorm";
12
+ /**
13
+ * This service supports integration testing. It allows
14
+ * some of the database data to be cleaned up by the
15
+ * power user.
16
+ *
17
+ * If you create additional models that have foreign key
18
+ * relationships to the models in this service, you will
19
+ * need to clean up those models as well, before running this
20
+ * or these will fail.
21
+ */
22
+ let SuperPowersService = class SuperPowersService {
23
+ entityManager;
24
+ constructor(entityManager) {
25
+ this.entityManager = entityManager;
26
+ }
27
+ async resetDatabase() {
28
+ await this.entityManager.query(` -- orgs
29
+ TRUNCATE TABLE "membership_role", "organisation_membership","organisation_subscription_record","organisation" RESTART IDENTITY CASCADE;
30
+
31
+ -- users
32
+ TRUNCATE TABLE "user_api_key", "email", "user", RESTART IDENTITY CASCADE;
33
+
34
+ -- payments
35
+ TRUNCATE TABLE "payment_session_reference", "stripe_checkout_event" RESTART IDENTITY CASCADE;`);
36
+ return true;
37
+ }
38
+ };
39
+ SuperPowersService = __decorate([
40
+ Injectable()
41
+ // eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
42
+ ,
43
+ __metadata("design:paramtypes", [EntityManager])
44
+ ], SuperPowersService);
45
+ export { SuperPowersService };
46
+ //# sourceMappingURL=super-powers.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"super-powers.service.js","sourceRoot":"","sources":["../../src/super-powers/super-powers.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;GASG;AAGI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACE;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,aAAa;QACf,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAC1B;;;;;;;0GAO8F,CACjG,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAhBY,kBAAkB;IAF9B,UAAU,EAAE;IACb,iFAAiF;;qCAEjC,aAAa;GADhD,kBAAkB,CAgB9B;SAhBY,kBAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darraghor/nest-backend-libs",
3
- "version": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Some helpers for personal projects in nestjs",
6
6
  "homepage": "https://github.com/darraghoriordan/nest-backend-libs",