@darraghor/nest-backend-libs 1.1.3 → 1.4.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.
- package/dist/core-config/CoreConfigurationService.d.ts +1 -0
- package/dist/core-config/CoreConfigurationService.js +9 -0
- package/dist/core-config/CoreConfigurationService.js.map +1 -1
- package/dist/core-config/CoreConfigurationVariables.d.ts +1 -0
- package/dist/core-config/CoreConfigurationVariables.js +1 -0
- package/dist/core-config/CoreConfigurationVariables.js.map +1 -1
- package/dist/database/TypeOrmConfigurationProvider.js +5 -5
- package/dist/database/TypeOrmConfigurationProvider.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/LoggingInterceptor.js +8 -3
- package/dist/logger/LoggingInterceptor.js.map +1 -1
- package/dist/organisation/entities/organisation.entity.d.ts +1 -0
- package/dist/organisation/entities/organisation.entity.js +9 -0
- package/dist/organisation/entities/organisation.entity.js.map +1 -1
- package/dist/organisation/organisation.controller.d.ts +5 -6
- package/dist/organisation/organisation.controller.js +25 -32
- package/dist/organisation/organisation.controller.js.map +1 -1
- package/dist/organisation/organisation.service.d.ts +6 -6
- package/dist/organisation/organisation.service.js +22 -8
- package/dist/organisation/organisation.service.js.map +1 -1
- package/dist/person/PersonConfigurationService.d.ts +12 -0
- package/dist/person/PersonConfigurationService.js +83 -0
- package/dist/person/PersonConfigurationService.js.map +1 -0
- package/dist/person/PersonConfigurationVariables.d.ts +9 -0
- package/dist/person/PersonConfigurationVariables.js +12 -0
- package/dist/person/PersonConfigurationVariables.js.map +1 -0
- package/dist/person/entities/person.entity.d.ts +1 -0
- package/dist/person/entities/person.entity.js +12 -0
- package/dist/person/entities/person.entity.js.map +1 -1
- package/dist/person/person.controller.d.ts +2 -4
- package/dist/person/person.controller.js +13 -26
- package/dist/person/person.controller.js.map +1 -1
- package/dist/person/person.module.js +8 -1
- package/dist/person/person.module.js.map +1 -1
- package/dist/person/person.service.d.ts +7 -5
- package/dist/person/person.service.js +40 -25
- package/dist/person/person.service.js.map +1 -1
- package/dist/root-app/SwaggerGen.d.ts +3 -2
- package/dist/root-app/SwaggerGen.js +18 -17
- package/dist/root-app/SwaggerGen.js.map +1 -1
- package/dist/root-app/core-app.module.js +0 -2
- package/dist/root-app/core-app.module.js.map +1 -1
- package/package.json +1 -1
- package/dist/root-app/httpLogResponseContent.d.ts +0 -5
- package/dist/root-app/httpLogResponseContent.js +0 -43
- package/dist/root-app/httpLogResponseContent.js.map +0 -1
|
@@ -4,6 +4,7 @@ export declare class CoreConfigurationService extends ValidatedConfigurationServ
|
|
|
4
4
|
private configService;
|
|
5
5
|
constructor(configService: ConfigService);
|
|
6
6
|
get shouldGenerateSwagger(): boolean;
|
|
7
|
+
get shouldAutomaticallyInstallApiModels(): boolean;
|
|
7
8
|
get shouldUseNestCors(): boolean;
|
|
8
9
|
get webPort(): number;
|
|
9
10
|
get clientCorsUrl(): string;
|
|
@@ -24,6 +24,9 @@ let CoreConfigurationService = class CoreConfigurationService extends ValidatedC
|
|
|
24
24
|
return (this.configService.get("core.shouldGenerateSwagger") ===
|
|
25
25
|
"true");
|
|
26
26
|
}
|
|
27
|
+
get shouldAutomaticallyInstallApiModels() {
|
|
28
|
+
return (this.configService.get("core.shouldAutomaticallyInstallApiModels") === "true");
|
|
29
|
+
}
|
|
27
30
|
get shouldUseNestCors() {
|
|
28
31
|
return (this.configService.get("core.shouldUseNestCors") === "true");
|
|
29
32
|
}
|
|
@@ -46,6 +49,12 @@ __decorate([
|
|
|
46
49
|
__metadata("design:type", Boolean),
|
|
47
50
|
__metadata("design:paramtypes", [])
|
|
48
51
|
], CoreConfigurationService.prototype, "shouldGenerateSwagger", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
class_validator_1.IsDefined(),
|
|
54
|
+
class_validator_1.IsBoolean(),
|
|
55
|
+
__metadata("design:type", Boolean),
|
|
56
|
+
__metadata("design:paramtypes", [])
|
|
57
|
+
], CoreConfigurationService.prototype, "shouldAutomaticallyInstallApiModels", null);
|
|
49
58
|
__decorate([
|
|
50
59
|
class_validator_1.IsDefined(),
|
|
51
60
|
class_validator_1.IsBoolean(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreConfigurationService.js","sourceRoot":"","sources":["../../src/core-config/CoreConfigurationService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA6D;AAC7D,2CAA0C;AAC1C,2CAA6C;AAC7C,qDAAsE;AACtE,kGAA6F;AAG7F,IAAa,wBAAwB,GAArC,MAAa,wBAAyB,SAAQ,6DAA6B;IACvE,YAAoB,aAA4B;QAC5C,KAAK,EAAE,CAAC;QADQ,kBAAa,GAAb,aAAa,CAAe;IAEhD,CAAC;IAID,IAAI,qBAAqB;QACrB,OAAO,CACH,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,4BAA4B,CAAC;YAC5D,MAAM,CACT,CAAC;IACN,CAAC;IAID,IAAI,iBAAiB;QACjB,OAAO,CACH,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,wBAAwB,CAAC,KAAK,MAAM,CACtE,CAAC;IACN,CAAC;IAID,IAAI,OAAO;QACP,OAAO,MAAM,CAAC,QAAQ,CAClB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAE,EAC/C,EAAE,CACL,CAAC;IACN,CAAC;IAID,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,oBAAoB,CAAE,CAAC;IACjE,CAAC;IAID,IAAI,yBAAyB;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CACzB,gCAAgC,CAClC,CAAC;IACP,CAAC;IAID,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAE,CAAC;IAC3D,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"CoreConfigurationService.js","sourceRoot":"","sources":["../../src/core-config/Co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C,2BAAS,EAAE;IACX,uBAAK,EAAE;;;uDAMP;AAID;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;6DAGV;AAID;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;yEAKV;AAID;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;uDAGV;AA3DQ,wBAAwB;IADpC,mBAAU,EAAE;qCAE0B,sBAAa;GADvC,wBAAwB,CA4DpC;AA5DY,4DAAwB"}
|
|
@@ -6,5 +6,6 @@ declare const _default: (() => {
|
|
|
6
6
|
clientCorsUrl: string | undefined;
|
|
7
7
|
appEnvironmentSpecificUrl: string | undefined;
|
|
8
8
|
shouldUseNestCors: string | undefined;
|
|
9
|
+
shouldAutomaticallyInstallApiModels: string | undefined;
|
|
9
10
|
}) & import("@nestjs/config").ConfigFactoryKeyHost;
|
|
10
11
|
export default _default;
|
|
@@ -9,5 +9,6 @@ exports.default = config_1.registerAs("core", () => ({
|
|
|
9
9
|
clientCorsUrl: process.env.CLIENT_CORS_URL,
|
|
10
10
|
appEnvironmentSpecificUrl: process.env.APP_ENVIRONMENT_SPECIFIC_URL,
|
|
11
11
|
shouldUseNestCors: process.env.ENABLE_NEST_CORS,
|
|
12
|
+
shouldAutomaticallyInstallApiModels: process.env.AUTO_INSTALL_API_MODELS,
|
|
12
13
|
}));
|
|
13
14
|
//# sourceMappingURL=CoreConfigurationVariables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreConfigurationVariables.js","sourceRoot":"","sources":["../../src/core-config/CoreConfigurationVariables.ts"],"names":[],"mappings":";;AAAA,2CAA0C;AAE1C,kBAAe,mBAAU,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACnC,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC7B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC7B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;IAC1C,yBAAyB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B;IACnE,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"CoreConfigurationVariables.js","sourceRoot":"","sources":["../../src/core-config/CoreConfigurationVariables.ts"],"names":[],"mappings":";;AAAA,2CAA0C;AAE1C,kBAAe,mBAAU,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACnC,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC7B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC7B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;IAC1C,yBAAyB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B;IACnE,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IAC/C,mCAAmC,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB;CAC3E,CAAC,CAAC,CAAC"}
|
|
@@ -14,11 +14,11 @@ class TypeOrmConfigurationProvider {
|
|
|
14
14
|
static getTypeOrmConfig() {
|
|
15
15
|
console.log("DIRNAME", __dirname);
|
|
16
16
|
const nodeModuleCorePath = path_1.default.join(__dirname, process.env.CORE_MODULE_ENTITY_PATH || "", "**", "*.entity.{ts,js}");
|
|
17
|
-
console.log("Using core entity path", nodeModuleCorePath);
|
|
17
|
+
console.log("Using core entity path:", nodeModuleCorePath);
|
|
18
18
|
const appModulePath = path_1.default.join(__dirname, process.env.APP_MODULE_ENTITY_PATH || "", "**", "*.entity.{ts,js}");
|
|
19
|
-
console.log("Using application entity path", appModulePath);
|
|
20
|
-
const migrationsPath = path_1.default.join(__dirname, process.env.MIGRATIONS_PATH || "", "**", "
|
|
21
|
-
console.log("Using migration path", migrationsPath);
|
|
19
|
+
console.log("Using application entity path:", appModulePath);
|
|
20
|
+
const migrationsPath = path_1.default.join(__dirname, process.env.MIGRATIONS_PATH || "", "**", "migrations", "*.{ts,js}");
|
|
21
|
+
console.log("Using migration path:", migrationsPath);
|
|
22
22
|
if (process.env.DATABASE_URL) {
|
|
23
23
|
return {
|
|
24
24
|
type: "postgres",
|
|
@@ -49,7 +49,7 @@ class TypeOrmConfigurationProvider {
|
|
|
49
49
|
entities: [nodeModuleCorePath, appModulePath],
|
|
50
50
|
migrations: [migrationsPath],
|
|
51
51
|
cli: {
|
|
52
|
-
migrationsDir: "src/
|
|
52
|
+
migrationsDir: "src/migrations",
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeOrmConfigurationProvider.js","sourceRoot":"","sources":["../../src/database/TypeOrmConfigurationProvider.ts"],"names":[],"mappings":";;;;;;AAGA,gDAAwB;AAExB,MAAa,4BAA4B;IACrC;;;;OAIG;IACI,MAAM,CAAC,gBAAgB;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAClC,MAAM,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAChC,SAAS,EACT,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,EACzC,IAAI,EACJ,kBAAkB,CACrB,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"TypeOrmConfigurationProvider.js","sourceRoot":"","sources":["../../src/database/TypeOrmConfigurationProvider.ts"],"names":[],"mappings":";;;;;;AAGA,gDAAwB;AAExB,MAAa,4BAA4B;IACrC;;;;OAIG;IACI,MAAM,CAAC,gBAAgB;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAClC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AAO,CAAC,GAAG,CAAC,iBAAiB;YACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;YACvC,mBAAmB,EAAE,YAAY;YACjC,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC;YAC7C,UAAU,EAAE,CAAC,cAAc,CAAC;YAC5B,GAAG,EAAE;gBACD,aAAa,EAAE,gBAAgB;aAClC;SACJ,CAAC;IACN,CAAC;CACJ;AApED,oEAoEC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthzModule } from "./authz/authz.module";
|
|
2
2
|
import { JwtStrategy } from "./authz/authzstrategy";
|
|
3
3
|
import { DefaultAuthGuard } from "./authz/DefaultAuthGuard";
|
|
4
|
+
import { RequestWithUser } from "./authz/RequestWithUser";
|
|
4
5
|
import { ValidatedConfigurationService } from "./configuration/ValidatedConfigurationService";
|
|
5
6
|
import { CoreConfigurationService } from "./core-config/CoreConfigurationService";
|
|
6
7
|
import { DatabaseModule } from "./database/Database.module";
|
|
@@ -8,6 +9,9 @@ import { TypeOrmConfigurationProvider } from "./database/TypeOrmConfigurationPro
|
|
|
8
9
|
import { EmailClientModule } from "./email-client/email-client.module";
|
|
9
10
|
import { EmailClient } from "./email-client/email-client.service";
|
|
10
11
|
import CoreLoggerService from "./logger/CoreLoggerService";
|
|
12
|
+
import { OrganisationModule } from "./organisation/organisation.module";
|
|
13
|
+
import { Person } from "./person/entities/person.entity";
|
|
14
|
+
import { PersonModule } from "./person/person.module";
|
|
11
15
|
import { CoreModule } from "./root-app/core-app.module";
|
|
12
16
|
import { SwaggerGen } from "./root-app/SwaggerGen";
|
|
13
|
-
export { CoreLoggerService, CoreConfigurationService, EmailClientModule, CoreModule, SwaggerGen, DefaultAuthGuard, DatabaseModule, JwtStrategy, AuthzModule, TypeOrmConfigurationProvider, EmailClient, ValidatedConfigurationService, };
|
|
17
|
+
export { CoreLoggerService, CoreConfigurationService, EmailClientModule, CoreModule, SwaggerGen, DefaultAuthGuard, DatabaseModule, JwtStrategy, AuthzModule, Person, TypeOrmConfigurationProvider, EmailClient, ValidatedConfigurationService, RequestWithUser, PersonModule, OrganisationModule, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ValidatedConfigurationService = exports.EmailClient = exports.TypeOrmConfigurationProvider = exports.AuthzModule = exports.JwtStrategy = exports.DatabaseModule = exports.DefaultAuthGuard = exports.SwaggerGen = exports.CoreModule = exports.EmailClientModule = exports.CoreConfigurationService = exports.CoreLoggerService = void 0;
|
|
6
|
+
exports.OrganisationModule = exports.PersonModule = exports.ValidatedConfigurationService = exports.EmailClient = exports.TypeOrmConfigurationProvider = exports.Person = exports.AuthzModule = exports.JwtStrategy = exports.DatabaseModule = exports.DefaultAuthGuard = exports.SwaggerGen = exports.CoreModule = exports.EmailClientModule = exports.CoreConfigurationService = exports.CoreLoggerService = void 0;
|
|
7
7
|
const authz_module_1 = require("./authz/authz.module");
|
|
8
8
|
Object.defineProperty(exports, "AuthzModule", { enumerable: true, get: function () { return authz_module_1.AuthzModule; } });
|
|
9
9
|
const authzstrategy_1 = require("./authz/authzstrategy");
|
|
@@ -24,6 +24,12 @@ const email_client_service_1 = require("./email-client/email-client.service");
|
|
|
24
24
|
Object.defineProperty(exports, "EmailClient", { enumerable: true, get: function () { return email_client_service_1.EmailClient; } });
|
|
25
25
|
const CoreLoggerService_1 = __importDefault(require("./logger/CoreLoggerService"));
|
|
26
26
|
exports.CoreLoggerService = CoreLoggerService_1.default;
|
|
27
|
+
const organisation_module_1 = require("./organisation/organisation.module");
|
|
28
|
+
Object.defineProperty(exports, "OrganisationModule", { enumerable: true, get: function () { return organisation_module_1.OrganisationModule; } });
|
|
29
|
+
const person_entity_1 = require("./person/entities/person.entity");
|
|
30
|
+
Object.defineProperty(exports, "Person", { enumerable: true, get: function () { return person_entity_1.Person; } });
|
|
31
|
+
const person_module_1 = require("./person/person.module");
|
|
32
|
+
Object.defineProperty(exports, "PersonModule", { enumerable: true, get: function () { return person_module_1.PersonModule; } });
|
|
27
33
|
const core_app_module_1 = require("./root-app/core-app.module");
|
|
28
34
|
Object.defineProperty(exports, "CoreModule", { enumerable: true, get: function () { return core_app_module_1.CoreModule; } });
|
|
29
35
|
const SwaggerGen_1 = require("./root-app/SwaggerGen");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAiD;AA0B7C,4FA1BI,0BAAW,OA0BJ;AAzBf,yDAAkD;AAwB9C,4FAxBI,2BAAW,OAwBJ;AAvBf,+DAA0D;AAqBtD,iGArBI,mCAAgB,OAqBJ;AAnBpB,iGAA4F;AA0BxF,8GA1BI,6DAA6B,OA0BJ;AAzBjC,qFAAgF;AAc5E,yGAdI,mDAAwB,OAcJ;AAb5B,gEAA0D;AAkBtD,+FAlBI,gCAAc,OAkBJ;AAjBlB,0FAAqF;AAqBjF,6GArBI,2DAA4B,OAqBJ;AApBhC,4EAAqE;AAYjE,kGAZI,uCAAiB,OAYJ;AAXrB,8EAAgE;AAoB5D,4FApBI,kCAAW,OAoBJ;AAnBf,mFAA2D;AAQvD,4BARG,2BAAiB,CAQH;AAPrB,4EAAsE;AAsBlE,mGAtBI,wCAAkB,OAsBJ;AArBtB,mEAAuD;AAenD,uFAfI,sBAAM,OAeJ;AAdV,0DAAoD;AAmBhD,6FAnBI,4BAAY,OAmBJ;AAlBhB,gEAAsD;AAOlD,2FAPI,4BAAU,OAOJ;AANd,sDAAiD;AAO7C,2FAPI,uBAAU,OAOJ"}
|
|
@@ -23,9 +23,10 @@ let LoggingInterceptor = class LoggingInterceptor {
|
|
|
23
23
|
}
|
|
24
24
|
intercept(context, next) {
|
|
25
25
|
const request = context.switchToHttp().getRequest();
|
|
26
|
-
const
|
|
26
|
+
const response = context.switchToHttp().getResponse();
|
|
27
27
|
const { originalUrl, method, params, query, body } = request;
|
|
28
28
|
this.logger.log({
|
|
29
|
+
type: "REQUEST",
|
|
29
30
|
originalUrl,
|
|
30
31
|
method,
|
|
31
32
|
params,
|
|
@@ -33,8 +34,12 @@ let LoggingInterceptor = class LoggingInterceptor {
|
|
|
33
34
|
body,
|
|
34
35
|
});
|
|
35
36
|
return next.handle().pipe(rxjs_1.tap((data) => this.logger.log({
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
type: "RESPONSE",
|
|
38
|
+
originalUrl,
|
|
39
|
+
method,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
41
|
+
status: response?.status,
|
|
42
|
+
responseBody: data || undefined,
|
|
38
43
|
})));
|
|
39
44
|
}
|
|
40
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggingInterceptor.js","sourceRoot":"","sources":["../../src/logger/LoggingInterceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,2CAKwB;AACxB,+BAAyB;AACzB,4EAAoD;AAGpD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC3B,YAA6B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAC1D,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAEpD,MAAM,
|
|
1
|
+
{"version":3,"file":"LoggingInterceptor.js","sourceRoot":"","sources":["../../src/logger/LoggingInterceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,2CAKwB;AACxB,+BAAyB;AACzB,4EAAoD;AAGpD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC3B,YAA6B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAC1D,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAEpD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;QAEtD,MAAM,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC;QAE3D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACZ,IAAI,EAAE,SAAS;YACf,WAAW;YACX,MAAM;YACN,MAAM;YACN,KAAK;YACL,IAAI;SACP,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,UAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACZ,IAAI,EAAE,UAAU;YAChB,WAAW;YACX,MAAM;YACN,sEAAsE;YACtE,MAAM,EAAE,QAAQ,EAAE,MAAM;YACxB,YAAY,EAAE,IAAI,IAAI,SAAS;SAClC,CAAC,CACL,CACJ,CAAC;IACN,CAAC;CACJ,CAAA;AA/BY,kBAAkB;IAD9B,mBAAU,EAAE;qCAE4B,2BAAiB;GAD7C,kBAAkB,CA+B9B;AA/BY,gDAAkB"}
|
|
@@ -21,6 +21,15 @@ __decorate([
|
|
|
21
21
|
swagger_1.ApiProperty(),
|
|
22
22
|
__metadata("design:type", Number)
|
|
23
23
|
], Organisation.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
typeorm_1.Column("uuid", {
|
|
26
|
+
name: "uuid",
|
|
27
|
+
default: () => "uuid_generate_v4()",
|
|
28
|
+
}),
|
|
29
|
+
typeorm_1.Generated("uuid"),
|
|
30
|
+
swagger_1.ApiProperty(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Organisation.prototype, "uuid", void 0);
|
|
24
33
|
__decorate([
|
|
25
34
|
typeorm_1.ManyToMany(() => person_entity_1.Person, (orgMember) => orgMember.memberOfOrganisations, {
|
|
26
35
|
eager: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,yDAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"organisation.entity.js","sourceRoot":"","sources":["../../../src/organisation/entities/organisation.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,yDAA0C;AAC1C,qCAciB;AACjB,uEAA2D;AAG3D,IAAa,YAAY,GAAzB,MAAa,YAAY;CAgDxB,CAAA;AA7CG;IAFC,gCAAsB,EAAE;IACxB,qBAAW,EAAE;;wCACF;AAQZ;IANC,gBAAM,CAAC,MAAM,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB;KACtC,CAAC;IACD,mBAAS,CAAC,MAAM,CAAC;IACjB,qBAAW,EAAE;;0CACO;AAQrB;IANC,oBAAU,CAAC,GAAG,EAAE,CAAC,sBAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,qBAAqB,EAAE;QACtE,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,SAAS;KACtB,CAAC;IACD,2BAAO,EAAE;IACT,mBAAS,EAAE;;6CACO;AAQnB;IANC,mBAAS,CAAC,GAAG,EAAE,CAAC,sBAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAoB,EAAE;QAC9D,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,SAAS;KACtB,CAAC;IACD,eAAK,EAAE;IACP,oBAAU,EAAE;8BACL,sBAAM;2CAAC;AAIf;IAFC,oBAAU,CAAC,CAAC,YAA0B,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;IAC9D,qBAAW,EAAE;;6CACG;AAIjB;IAFC,gBAAM,EAAE;IACR,qBAAW,EAAE;;0CACA;AAId;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACA,IAAI;iDAAC;AAInB;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACD,IAAI;gDAAC;AAIlB;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACA,IAAI;iDAAC;AA/CV,YAAY;IADxB,gBAAM,EAAE;GACI,YAAY,CAgDxB;AAhDY,oCAAY"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { OrganisationService } from "./organisation.service";
|
|
2
|
-
import { CreateOrganisationDto } from "./dto/create-organisation.dto";
|
|
3
2
|
import { UpdateOrganisationDto } from "./dto/update-organisation.dto";
|
|
4
3
|
import { Organisation } from "./entities/organisation.entity";
|
|
4
|
+
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
5
5
|
export declare class OrganisationController {
|
|
6
6
|
private readonly organisationService;
|
|
7
7
|
constructor(organisationService: OrganisationService);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
remove(id: string): Promise<boolean>;
|
|
8
|
+
findOne(uuid: string, request: RequestWithUser): Promise<Organisation>;
|
|
9
|
+
findAllForUser(request: RequestWithUser): Promise<Organisation[]>;
|
|
10
|
+
update(uuid: string, updateOrganisationDto: UpdateOrganisationDto, request: RequestWithUser): Promise<import("typeorm").UpdateResult>;
|
|
11
|
+
remove(uuid: string, request: RequestWithUser): Promise<boolean>;
|
|
13
12
|
}
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.OrganisationController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const organisation_service_1 = require("./organisation.service");
|
|
18
|
-
const create_organisation_dto_1 = require("./dto/create-organisation.dto");
|
|
19
18
|
const update_organisation_dto_1 = require("./dto/update-organisation.dto");
|
|
20
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
21
20
|
const organisation_entity_1 = require("./entities/organisation.entity");
|
|
@@ -24,20 +23,18 @@ let OrganisationController = class OrganisationController {
|
|
|
24
23
|
constructor(organisationService) {
|
|
25
24
|
this.organisationService = organisationService;
|
|
26
25
|
}
|
|
27
|
-
async
|
|
28
|
-
return this.organisationService.
|
|
26
|
+
async findOne(uuid, request) {
|
|
27
|
+
return this.organisationService.findOne(uuid, request.user.id);
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
30
|
+
async findAllForUser(request) {
|
|
31
|
+
return this.organisationService.findAllForUser(request.user.id);
|
|
32
32
|
}
|
|
33
|
-
async
|
|
34
|
-
return this.organisationService.
|
|
33
|
+
async update(uuid, updateOrganisationDto, request) {
|
|
34
|
+
return this.organisationService.update(uuid, updateOrganisationDto, request.user.id);
|
|
35
35
|
}
|
|
36
|
-
async
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
async remove(id) {
|
|
40
|
-
const deleteResult = await this.organisationService.remove(+id);
|
|
36
|
+
async remove(uuid, request) {
|
|
37
|
+
const deleteResult = await this.organisationService.remove(uuid, request.user.id);
|
|
41
38
|
return (deleteResult !== undefined &&
|
|
42
39
|
deleteResult.affected !== undefined &&
|
|
43
40
|
deleteResult?.affected !== null &&
|
|
@@ -45,43 +42,39 @@ let OrganisationController = class OrganisationController {
|
|
|
45
42
|
}
|
|
46
43
|
};
|
|
47
44
|
__decorate([
|
|
48
|
-
common_1.
|
|
45
|
+
common_1.Get(":uuid"),
|
|
49
46
|
swagger_1.ApiOkResponse({ type: organisation_entity_1.Organisation }),
|
|
50
|
-
__param(0, common_1.
|
|
47
|
+
__param(0, common_1.Param("uuid")),
|
|
48
|
+
__param(1, common_1.Request()),
|
|
51
49
|
__metadata("design:type", Function),
|
|
52
|
-
__metadata("design:paramtypes", [
|
|
50
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
53
51
|
__metadata("design:returntype", Promise)
|
|
54
|
-
], OrganisationController.prototype, "
|
|
52
|
+
], OrganisationController.prototype, "findOne", null);
|
|
55
53
|
__decorate([
|
|
56
54
|
common_1.Get(),
|
|
57
55
|
swagger_1.ApiOkResponse({ type: organisation_entity_1.Organisation, isArray: true }),
|
|
56
|
+
__param(0, common_1.Request()),
|
|
58
57
|
__metadata("design:type", Function),
|
|
59
|
-
__metadata("design:paramtypes", []),
|
|
58
|
+
__metadata("design:paramtypes", [Object]),
|
|
60
59
|
__metadata("design:returntype", Promise)
|
|
61
|
-
], OrganisationController.prototype, "
|
|
62
|
-
__decorate([
|
|
63
|
-
common_1.Get(":id"),
|
|
64
|
-
swagger_1.ApiOkResponse({ type: organisation_entity_1.Organisation }),
|
|
65
|
-
__param(0, common_1.Param("id")),
|
|
66
|
-
__metadata("design:type", Function),
|
|
67
|
-
__metadata("design:paramtypes", [String]),
|
|
68
|
-
__metadata("design:returntype", Promise)
|
|
69
|
-
], OrganisationController.prototype, "findOne", null);
|
|
60
|
+
], OrganisationController.prototype, "findAllForUser", null);
|
|
70
61
|
__decorate([
|
|
71
|
-
common_1.Patch(":
|
|
62
|
+
common_1.Patch(":uuid"),
|
|
72
63
|
swagger_1.ApiOkResponse({ type: organisation_entity_1.Organisation }),
|
|
73
|
-
__param(0, common_1.Param("
|
|
64
|
+
__param(0, common_1.Param("uuid")),
|
|
74
65
|
__param(1, common_1.Body()),
|
|
66
|
+
__param(2, common_1.Request()),
|
|
75
67
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [String, update_organisation_dto_1.UpdateOrganisationDto]),
|
|
68
|
+
__metadata("design:paramtypes", [String, update_organisation_dto_1.UpdateOrganisationDto, Object]),
|
|
77
69
|
__metadata("design:returntype", Promise)
|
|
78
70
|
], OrganisationController.prototype, "update", null);
|
|
79
71
|
__decorate([
|
|
80
|
-
common_1.Delete("
|
|
72
|
+
common_1.Delete("uuid"),
|
|
81
73
|
swagger_1.ApiOkResponse({ type: organisation_entity_1.Organisation }),
|
|
82
|
-
__param(0, common_1.Param("
|
|
74
|
+
__param(0, common_1.Param("uuid")),
|
|
75
|
+
__param(1, common_1.Request()),
|
|
83
76
|
__metadata("design:type", Function),
|
|
84
|
-
__metadata("design:paramtypes", [String]),
|
|
77
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
85
78
|
__metadata("design:returntype", Promise)
|
|
86
79
|
], OrganisationController.prototype, "remove", null);
|
|
87
80
|
OrganisationController = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.controller.js","sourceRoot":"","sources":["../../src/organisation/organisation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,iEAA2D;AAC3D,2EAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"organisation.controller.js","sourceRoot":"","sources":["../../src/organisation/organisation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,iEAA2D;AAC3D,2EAAoE;AACpE,6CAAsE;AACtE,wEAA4D;AAC5D,+CAA2C;AAM3C,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAC/B,YAA6B,mBAAwC;QAAxC,wBAAmB,GAAnB,mBAAmB,CAAqB;IAAG,CAAC;IAIzE,KAAK,CAAC,OAAO,CACM,IAAY,EAChB,OAAwB;QAEnC,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,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A;IACb,WAAA,aAAI,EAAE,CAAA;IACN,WAAA,gBAAO,EAAE,CAAA;;6CADqB,+CAAqB;;oDAQvD;AAID;IAFC,eAAM,CAAC,MAAM,CAAC;IACd,uBAAa,CAAC,EAAC,IAAI,EAAE,kCAAY,EAAC,CAAC;IAE/B,WAAA,cAAK,CAAC,MAAM,CAAC,CAAA;IACb,WAAA,gBAAO,EAAE,CAAA;;;;oDAYb;AAnDQ,sBAAsB;IAJlC,kBAAS,CAAC,oBAAS,CAAC,KAAK,CAAC,CAAC;IAC3B,uBAAa,EAAE;IACf,mBAAU,CAAC,cAAc,CAAC;IAC1B,iBAAO,CAAC,eAAe,CAAC;qCAE6B,0CAAmB;GAD5D,sBAAsB,CAoDlC;AApDY,wDAAsB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Repository } from "typeorm";
|
|
1
|
+
import { DeleteResult, Repository, UpdateResult } from "typeorm";
|
|
2
2
|
import { CreateOrganisationDto } from "./dto/create-organisation.dto";
|
|
3
3
|
import { UpdateOrganisationDto } from "./dto/update-organisation.dto";
|
|
4
4
|
import { Organisation } from "./entities/organisation.entity";
|
|
5
5
|
export declare class OrganisationService {
|
|
6
6
|
private repository;
|
|
7
7
|
constructor(repository: Repository<Organisation>);
|
|
8
|
-
create(createOrganisationDto: CreateOrganisationDto): Promise<
|
|
9
|
-
|
|
10
|
-
findOne(
|
|
11
|
-
update(
|
|
12
|
-
remove(
|
|
8
|
+
create(createOrganisationDto: CreateOrganisationDto): Promise<Organisation>;
|
|
9
|
+
findAllForUser(currentUserId: number): Promise<Organisation[]>;
|
|
10
|
+
findOne(uuid: string, currentUserId: number): Promise<Organisation>;
|
|
11
|
+
update(uuid: string, updateOrganisationDto: UpdateOrganisationDto, currentUserId: number): Promise<UpdateResult>;
|
|
12
|
+
remove(uuid: string, currentUserId: number): Promise<DeleteResult>;
|
|
13
13
|
}
|
|
@@ -24,17 +24,31 @@ let OrganisationService = class OrganisationService {
|
|
|
24
24
|
async create(createOrganisationDto) {
|
|
25
25
|
return this.repository.save(createOrganisationDto);
|
|
26
26
|
}
|
|
27
|
-
async
|
|
28
|
-
return this.repository
|
|
27
|
+
async findAllForUser(currentUserId) {
|
|
28
|
+
return this.repository
|
|
29
|
+
.createQueryBuilder("orgs")
|
|
30
|
+
.innerJoinAndSelect("orgs.owner", "owner")
|
|
31
|
+
.where("owner.id = :currentUserId")
|
|
32
|
+
.setParameters({ currentUserId })
|
|
33
|
+
.getMany();
|
|
29
34
|
}
|
|
30
|
-
async findOne(
|
|
31
|
-
return this.repository
|
|
35
|
+
async findOne(uuid, currentUserId) {
|
|
36
|
+
return this.repository
|
|
37
|
+
.createQueryBuilder("orgs")
|
|
38
|
+
.innerJoinAndSelect("orgs.owner", "owner")
|
|
39
|
+
.where("owner.id = :currentUserId")
|
|
40
|
+
.andWhere("orgs.uuid = :uuid")
|
|
41
|
+
.setParameters({ currentUserId, uuid })
|
|
42
|
+
.getOneOrFail();
|
|
32
43
|
}
|
|
33
|
-
async update(
|
|
34
|
-
return this.repository.update(
|
|
44
|
+
async update(uuid, updateOrganisationDto, currentUserId) {
|
|
45
|
+
return this.repository.update({ uuid, ownerId: currentUserId }, updateOrganisationDto);
|
|
35
46
|
}
|
|
36
|
-
async remove(
|
|
37
|
-
return this.repository.delete(
|
|
47
|
+
async remove(uuid, currentUserId) {
|
|
48
|
+
return this.repository.delete({
|
|
49
|
+
uuid,
|
|
50
|
+
ownerId: currentUserId,
|
|
51
|
+
});
|
|
38
52
|
}
|
|
39
53
|
};
|
|
40
54
|
OrganisationService = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"organisation.service.js","sourceRoot":"","sources":["../../src/organisation/organisation.service.ts"],"names":[],"mappings":";;;;;;;;;;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A;AAhDY,mBAAmB;IAD/B,mBAAU,EAAE;IAGJ,WAAA,0BAAgB,CAAC,kCAAY,CAAC,CAAA;qCACX,oBAAU;GAHzB,mBAAmB,CAgD/B;AAhDY,kDAAmB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { ValidatedConfigurationService } from "../configuration/ValidatedConfigurationService";
|
|
3
|
+
export declare class PersonConfigurationService extends ValidatedConfigurationService {
|
|
4
|
+
private configService;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
get fakeSub(): string;
|
|
7
|
+
get fakeFamilyName(): string;
|
|
8
|
+
get fakeGivenNAme(): string;
|
|
9
|
+
get fakeName(): string;
|
|
10
|
+
get fakeEmail(): string;
|
|
11
|
+
get fakePicture(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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.PersonConfigurationService = void 0;
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
const ValidatedConfigurationService_1 = require("../configuration/ValidatedConfigurationService");
|
|
18
|
+
let PersonConfigurationService = class PersonConfigurationService extends ValidatedConfigurationService_1.ValidatedConfigurationService {
|
|
19
|
+
constructor(configService) {
|
|
20
|
+
super();
|
|
21
|
+
this.configService = configService;
|
|
22
|
+
}
|
|
23
|
+
get fakeSub() {
|
|
24
|
+
return this.configService.get("person.fakeSub");
|
|
25
|
+
}
|
|
26
|
+
get fakeFamilyName() {
|
|
27
|
+
return this.configService.get("person.fakeFamilyName");
|
|
28
|
+
}
|
|
29
|
+
get fakeGivenNAme() {
|
|
30
|
+
return this.configService.get("person.fakeGivenNAme");
|
|
31
|
+
}
|
|
32
|
+
get fakeName() {
|
|
33
|
+
return this.configService.get("person.fakeName");
|
|
34
|
+
}
|
|
35
|
+
get fakeEmail() {
|
|
36
|
+
return this.configService.get("person.fakeEmail");
|
|
37
|
+
}
|
|
38
|
+
get fakePicture() {
|
|
39
|
+
return this.configService.get("person.fakePicture");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
__decorate([
|
|
43
|
+
class_validator_1.IsDefined(),
|
|
44
|
+
class_validator_1.IsString(),
|
|
45
|
+
__metadata("design:type", String),
|
|
46
|
+
__metadata("design:paramtypes", [])
|
|
47
|
+
], PersonConfigurationService.prototype, "fakeSub", null);
|
|
48
|
+
__decorate([
|
|
49
|
+
class_validator_1.IsDefined(),
|
|
50
|
+
class_validator_1.IsString(),
|
|
51
|
+
__metadata("design:type", String),
|
|
52
|
+
__metadata("design:paramtypes", [])
|
|
53
|
+
], PersonConfigurationService.prototype, "fakeFamilyName", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
class_validator_1.IsDefined(),
|
|
56
|
+
class_validator_1.IsString(),
|
|
57
|
+
__metadata("design:type", String),
|
|
58
|
+
__metadata("design:paramtypes", [])
|
|
59
|
+
], PersonConfigurationService.prototype, "fakeGivenNAme", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
class_validator_1.IsDefined(),
|
|
62
|
+
class_validator_1.IsString(),
|
|
63
|
+
__metadata("design:type", String),
|
|
64
|
+
__metadata("design:paramtypes", [])
|
|
65
|
+
], PersonConfigurationService.prototype, "fakeName", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
class_validator_1.IsDefined(),
|
|
68
|
+
class_validator_1.IsString(),
|
|
69
|
+
__metadata("design:type", String),
|
|
70
|
+
__metadata("design:paramtypes", [])
|
|
71
|
+
], PersonConfigurationService.prototype, "fakeEmail", null);
|
|
72
|
+
__decorate([
|
|
73
|
+
class_validator_1.IsDefined(),
|
|
74
|
+
class_validator_1.IsString(),
|
|
75
|
+
__metadata("design:type", String),
|
|
76
|
+
__metadata("design:paramtypes", [])
|
|
77
|
+
], PersonConfigurationService.prototype, "fakePicture", null);
|
|
78
|
+
PersonConfigurationService = __decorate([
|
|
79
|
+
common_1.Injectable(),
|
|
80
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
81
|
+
], PersonConfigurationService);
|
|
82
|
+
exports.PersonConfigurationService = PersonConfigurationService;
|
|
83
|
+
//# sourceMappingURL=PersonConfigurationService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersonConfigurationService.js","sourceRoot":"","sources":["../../src/person/PersonConfigurationService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6DAA6D;AAC7D,2CAA0C;AAC1C,2CAA6C;AAC7C,qDAAoD;AACpD,kGAA6F;AAG7F,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,6DAA6B;IACzE,YAAoB,aAA4B;QAC5C,KAAK,EAAE,CAAC;QADQ,kBAAa,GAAb,aAAa,CAAe;IAEhD,CAAC;IAID,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,gBAAgB,CAAE,CAAC;IAC7D,CAAC;IAID,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,uBAAuB,CAAE,CAAC;IACpE,CAAC;IAGD,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,sBAAsB,CAAE,CAAC;IACnE,CAAC;IAGD,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,iBAAiB,CAAE,CAAC;IAC9D,CAAC;IAGD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,kBAAkB,CAAE,CAAC;IAC/D,CAAC;IAGD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,oBAAoB,CAAE,CAAC;IACjE,CAAC;CACJ,CAAA;AA7BG;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;yDAGV;AAID;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;gEAGV;AAGD;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;+DAGV;AAGD;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;0DAGV;AAGD;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;2DAGV;AAGD;IAFC,2BAAS,EAAE;IACX,0BAAQ,EAAE;;;6DAGV;AAnCQ,0BAA0B;IADtC,mBAAU,EAAE;qCAE0B,sBAAa;GADvC,0BAA0B,CAoCtC;AApCY,gEAA0B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: (() => {
|
|
2
|
+
fakeSub: string | undefined;
|
|
3
|
+
fakeFamilyName: string | undefined;
|
|
4
|
+
fakeGivenNAme: string | undefined;
|
|
5
|
+
fakeName: string | undefined;
|
|
6
|
+
fakeEmail: string | undefined;
|
|
7
|
+
fakePicture: string | undefined;
|
|
8
|
+
}) & import("@nestjs/config").ConfigFactoryKeyHost;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("@nestjs/config");
|
|
4
|
+
exports.default = config_1.registerAs("person", () => ({
|
|
5
|
+
fakeSub: process.env.AUTH0_M2M_FAKE_SUB,
|
|
6
|
+
fakeFamilyName: process.env.AUTH0_M2M_FAKE_FAMILY_NAME,
|
|
7
|
+
fakeGivenNAme: process.env.AUTH0_M2M_FAKE_GIVEN_NAME,
|
|
8
|
+
fakeName: process.env.AUTH0_M2M_FAKE_NAME,
|
|
9
|
+
fakeEmail: process.env.AUTH0_M2M_FAKE_EMAIL,
|
|
10
|
+
fakePicture: process.env.AUTH0_M2M_FAKE_PICTURE,
|
|
11
|
+
}));
|
|
12
|
+
//# sourceMappingURL=PersonConfigurationVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersonConfigurationVariables.js","sourceRoot":"","sources":["../../src/person/PersonConfigurationVariables.ts"],"names":[],"mappings":";;AAAA,2CAA0C;AAE1C,kBAAe,mBAAU,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;IACvC,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B;IACtD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;IACpD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IACzC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;IAC3C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;CAClD,CAAC,CAAC,CAAC"}
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Person = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
15
|
const typeorm_1 = require("typeorm");
|
|
15
16
|
const organisation_entity_1 = require("../../organisation/entities/organisation.entity");
|
|
16
17
|
let Person = class Person {
|
|
@@ -25,6 +26,15 @@ __decorate([
|
|
|
25
26
|
typeorm_1.Column(),
|
|
26
27
|
__metadata("design:type", String)
|
|
27
28
|
], Person.prototype, "email", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
typeorm_1.Column("uuid", {
|
|
31
|
+
name: "uuid",
|
|
32
|
+
default: () => "uuid_generate_v4()",
|
|
33
|
+
}),
|
|
34
|
+
typeorm_1.Generated("uuid"),
|
|
35
|
+
swagger_1.ApiProperty(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], Person.prototype, "uuid", void 0);
|
|
28
38
|
__decorate([
|
|
29
39
|
swagger_1.ApiProperty(),
|
|
30
40
|
typeorm_1.Column({ default: false }),
|
|
@@ -67,6 +77,7 @@ __decorate([
|
|
|
67
77
|
__metadata("design:type", String)
|
|
68
78
|
], Person.prototype, "username", void 0);
|
|
69
79
|
__decorate([
|
|
80
|
+
class_transformer_1.Exclude(),
|
|
70
81
|
typeorm_1.ManyToMany(() => organisation_entity_1.Organisation, (org) => org.members, {
|
|
71
82
|
cascade: true,
|
|
72
83
|
onDelete: "CASCADE",
|
|
@@ -74,6 +85,7 @@ __decorate([
|
|
|
74
85
|
__metadata("design:type", Array)
|
|
75
86
|
], Person.prototype, "memberOfOrganisations", void 0);
|
|
76
87
|
__decorate([
|
|
88
|
+
class_transformer_1.Exclude(),
|
|
77
89
|
typeorm_1.OneToMany(() => organisation_entity_1.Organisation, (org) => org.owner, {
|
|
78
90
|
cascade: true,
|
|
79
91
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.entity.js","sourceRoot":"","sources":["../../../src/person/entities/person.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"person.entity.js","sourceRoot":"","sources":["../../../src/person/entities/person.entity.ts"],"names":[],"m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;QAClD,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,SAAS;KACtB,CAAC;;qDACqC;AAMvC;IAJC,2BAAO,EAAE;IACT,mBAAS,CAAC,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE;QAC/C,OAAO,EAAE,IAAI;KAChB,CAAC;;oDACoC;AAItC;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACA,IAAI;2CAAC;AAInB;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACD,IAAI;0CAAC;AAIlB;IAFC,0BAAgB,EAAE;IAClB,qBAAW,EAAE;8BACA,IAAI;2CAAC;AAzEV,MAAM;IADlB,gBAAM,EAAE;GACI,MAAM,CA0ElB;AA1EY,wBAAM"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { PersonService } from "./person.service";
|
|
2
|
-
import { CreatePersonDto } from "./dto/create-person.dto";
|
|
3
2
|
import { UpdatePersonDto } from "./dto/update-person.dto";
|
|
4
3
|
import { Person } from "./entities/person.entity";
|
|
5
4
|
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
6
5
|
export declare class PersonController {
|
|
7
6
|
private readonly personService;
|
|
8
7
|
constructor(personService: PersonService);
|
|
9
|
-
create(createPersonDto: CreatePersonDto): Promise<Person>;
|
|
10
8
|
findSelf(request: RequestWithUser): Promise<Person>;
|
|
11
|
-
update(
|
|
12
|
-
remove(
|
|
9
|
+
update(uuid: string, updatePersonDto: UpdatePersonDto, request: RequestWithUser): Promise<import("typeorm").UpdateResult>;
|
|
10
|
+
remove(uuid: string, request: RequestWithUser): Promise<boolean>;
|
|
13
11
|
}
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.PersonController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const person_service_1 = require("./person.service");
|
|
18
|
-
const create_person_dto_1 = require("./dto/create-person.dto");
|
|
19
18
|
const update_person_dto_1 = require("./dto/update-person.dto");
|
|
20
19
|
const swagger_1 = require("@nestjs/swagger");
|
|
21
20
|
const person_entity_1 = require("./entities/person.entity");
|
|
@@ -24,31 +23,17 @@ let PersonController = class PersonController {
|
|
|
24
23
|
constructor(personService) {
|
|
25
24
|
this.personService = personService;
|
|
26
25
|
}
|
|
27
|
-
async create(createPersonDto) {
|
|
28
|
-
return this.personService.create(createPersonDto);
|
|
29
|
-
}
|
|
30
26
|
async findSelf(request) {
|
|
31
27
|
return this.personService.findOne(request.user.id);
|
|
32
28
|
}
|
|
33
|
-
async update(
|
|
34
|
-
return this.personService.update(
|
|
29
|
+
async update(uuid, updatePersonDto, request) {
|
|
30
|
+
return this.personService.update(uuid, updatePersonDto, request.user.uuid);
|
|
35
31
|
}
|
|
36
|
-
async remove(
|
|
37
|
-
const deleteResult = await this.personService.remove(
|
|
38
|
-
return
|
|
39
|
-
deleteResult.affected !== undefined &&
|
|
40
|
-
deleteResult?.affected !== null &&
|
|
41
|
-
deleteResult?.affected > 0);
|
|
32
|
+
async remove(uuid, request) {
|
|
33
|
+
const deleteResult = await this.personService.remove(uuid, request.user.uuid);
|
|
34
|
+
return deleteResult !== undefined;
|
|
42
35
|
}
|
|
43
36
|
};
|
|
44
|
-
__decorate([
|
|
45
|
-
common_1.Post(),
|
|
46
|
-
swagger_1.ApiOkResponse({ type: person_entity_1.Person }),
|
|
47
|
-
__param(0, common_1.Body()),
|
|
48
|
-
__metadata("design:type", Function),
|
|
49
|
-
__metadata("design:paramtypes", [create_person_dto_1.CreatePersonDto]),
|
|
50
|
-
__metadata("design:returntype", Promise)
|
|
51
|
-
], PersonController.prototype, "create", null);
|
|
52
37
|
__decorate([
|
|
53
38
|
common_1.Get(),
|
|
54
39
|
swagger_1.ApiOkResponse({ type: person_entity_1.Person }),
|
|
@@ -58,20 +43,22 @@ __decorate([
|
|
|
58
43
|
__metadata("design:returntype", Promise)
|
|
59
44
|
], PersonController.prototype, "findSelf", null);
|
|
60
45
|
__decorate([
|
|
61
|
-
common_1.Patch(":
|
|
46
|
+
common_1.Patch(":uuid"),
|
|
62
47
|
swagger_1.ApiOkResponse({ type: person_entity_1.Person }),
|
|
63
|
-
__param(0, common_1.Param("
|
|
48
|
+
__param(0, common_1.Param("uuid")),
|
|
64
49
|
__param(1, common_1.Body()),
|
|
50
|
+
__param(2, common_1.Request()),
|
|
65
51
|
__metadata("design:type", Function),
|
|
66
|
-
__metadata("design:paramtypes", [String, update_person_dto_1.UpdatePersonDto]),
|
|
52
|
+
__metadata("design:paramtypes", [String, update_person_dto_1.UpdatePersonDto, Object]),
|
|
67
53
|
__metadata("design:returntype", Promise)
|
|
68
54
|
], PersonController.prototype, "update", null);
|
|
69
55
|
__decorate([
|
|
70
|
-
common_1.Delete(":
|
|
56
|
+
common_1.Delete(":uuid"),
|
|
71
57
|
swagger_1.ApiOkResponse({ type: person_entity_1.Person }),
|
|
72
|
-
__param(0, common_1.Param("
|
|
58
|
+
__param(0, common_1.Param("uuid")),
|
|
59
|
+
__param(1, common_1.Request()),
|
|
73
60
|
__metadata("design:type", Function),
|
|
74
|
-
__metadata("design:paramtypes", [String]),
|
|
61
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
75
62
|
__metadata("design:returntype", Promise)
|
|
76
63
|
], PersonController.prototype, "remove", null);
|
|
77
64
|
PersonController = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.controller.js","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"person.controller.js","sourceRoot":"","sources":["../../src/person/person.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,qDAA+C;AAC/C,+DAAwD;AACxD,6CAAsE;AACtE,4DAAgD;AAChD,+CAA2C;AAM3C,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IACzB,YAA6B,a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AAQ,CAAC;IACpB,iBAAO,CAAC,SAAS,CAAC;qCAE6B,8BAAa;GADhD,gBAAgB,CAmC5B;AAnCY,4CAAgB"}
|
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.PersonModule = void 0;
|
|
10
13
|
const common_1 = require("@nestjs/common");
|
|
@@ -14,17 +17,21 @@ const person_entity_1 = require("./entities/person.entity");
|
|
|
14
17
|
const logger_module_1 = require("../logger/logger.module");
|
|
15
18
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
16
19
|
const authz_client_module_1 = require("../authzclient/authz-client.module");
|
|
20
|
+
const PersonConfigurationService_1 = require("./PersonConfigurationService");
|
|
21
|
+
const config_1 = require("@nestjs/config");
|
|
22
|
+
const PersonConfigurationVariables_1 = __importDefault(require("./PersonConfigurationVariables"));
|
|
17
23
|
let PersonModule = class PersonModule {
|
|
18
24
|
};
|
|
19
25
|
PersonModule = __decorate([
|
|
20
26
|
common_1.Module({
|
|
21
27
|
imports: [
|
|
28
|
+
config_1.ConfigModule.forFeature(PersonConfigurationVariables_1.default),
|
|
22
29
|
logger_module_1.LoggerModule,
|
|
23
30
|
typeorm_1.TypeOrmModule.forFeature([person_entity_1.Person]),
|
|
24
31
|
authz_client_module_1.AuthzClientModule,
|
|
25
32
|
],
|
|
26
33
|
controllers: [person_controller_1.PersonController],
|
|
27
|
-
providers: [person_service_1.PersonService],
|
|
34
|
+
providers: [person_service_1.PersonService, PersonConfigurationService_1.PersonConfigurationService],
|
|
28
35
|
exports: [person_service_1.PersonService],
|
|
29
36
|
})
|
|
30
37
|
], PersonModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.module.js","sourceRoot":"","sources":["../../src/person/person.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"person.module.js","sourceRoot":"","sources":["../../src/person/person.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsC;AACtC,qDAA+C;AAC/C,2DAAqD;AACrD,4DAAgD;AAChD,2DAAqD;AACrD,6CAA8C;AAC9C,4EAAqE;AACrE,6EAAwE;AACxE,2CAA4C;AAC5C,kGAA6D;AAY7D,IAAa,YAAY,GAAzB,MAAa,YAAY;CAAG,CAAA;AAAf,YAAY;IAXxB,eAAM,CAAC;QACJ,OAAO,EAAE;YACL,qBAAY,CAAC,UAAU,CAAC,sCAAe,CAAC;YACxC,4BAAY;YACZ,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAM,CAAC,CAAC;YAClC,uCAAiB;SACpB;QACD,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,EAAE,uDAA0B,CAAC;QACtD,OAAO,EAAE,CAAC,8BAAa,CAAC;KAC3B,CAAC;GACW,YAAY,CAAG;AAAf,oCAAY"}
|
|
@@ -3,20 +3,22 @@ import { AccessToken } from "../authz/AccessToken";
|
|
|
3
3
|
import { AuthZClientService } from "../authzclient/authz.service";
|
|
4
4
|
import { UserProfile } from "../authzclient/UserProfile.dto";
|
|
5
5
|
import CoreLoggerService from "../logger/CoreLoggerService";
|
|
6
|
-
import { CreatePersonDto } from "./dto/create-person.dto";
|
|
7
6
|
import { UpdatePersonDto } from "./dto/update-person.dto";
|
|
8
7
|
import { Person } from "./entities/person.entity";
|
|
8
|
+
import { PersonConfigurationService } from "./PersonConfigurationService";
|
|
9
9
|
export declare class PersonService {
|
|
10
10
|
private repository;
|
|
11
11
|
private logger;
|
|
12
12
|
private authzClient;
|
|
13
|
-
|
|
13
|
+
private personConfig;
|
|
14
|
+
constructor(repository: Repository<Person>, logger: CoreLoggerService, authzClient: AuthZClientService, personConfig: PersonConfigurationService);
|
|
14
15
|
getAuth0User(payload: AccessToken, rawAccessToken: string): Promise<UserProfile | undefined>;
|
|
15
16
|
validateUser(payload: AccessToken, rawAccessToken: string): Promise<Person | undefined>;
|
|
16
|
-
create(createPersonDto: CreatePersonDto): Promise<CreatePersonDto & Person>;
|
|
17
17
|
findAll(): Promise<Person[]>;
|
|
18
18
|
findOneByAuth0Id(auth0Id: string): Promise<Person | undefined>;
|
|
19
19
|
findOne(id: number): Promise<Person>;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
findOneByUuid(uuid: string): Promise<Person>;
|
|
21
|
+
update(uuid: string, updatePersonDto: UpdatePersonDto, currentUserUuid: string): Promise<import("typeorm").UpdateResult>;
|
|
22
|
+
remove(uuid: string, currentUserUuid: string): Promise<Person>;
|
|
23
|
+
private isOwnerGuard;
|
|
22
24
|
}
|
|
@@ -24,26 +24,29 @@ const UserProfile_dto_1 = require("../authzclient/UserProfile.dto");
|
|
|
24
24
|
const CoreLoggerService_1 = __importDefault(require("../logger/CoreLoggerService"));
|
|
25
25
|
const organisation_entity_1 = require("../organisation/entities/organisation.entity");
|
|
26
26
|
const person_entity_1 = require("./entities/person.entity");
|
|
27
|
+
const PersonConfigurationService_1 = require("./PersonConfigurationService");
|
|
27
28
|
let PersonService = class PersonService {
|
|
28
|
-
constructor(repository, logger, authzClient) {
|
|
29
|
+
constructor(repository, logger, authzClient, personConfig) {
|
|
29
30
|
this.repository = repository;
|
|
30
31
|
this.logger = logger;
|
|
31
32
|
this.authzClient = authzClient;
|
|
33
|
+
this.personConfig = personConfig;
|
|
32
34
|
}
|
|
33
35
|
async getAuth0User(payload, rawAccessToken) {
|
|
34
36
|
// fake the user for our m2m token user used in testing
|
|
35
37
|
// m2m users don't get profiles
|
|
36
|
-
if (payload.sub ===
|
|
38
|
+
if (payload.sub === this.personConfig.fakeSub) {
|
|
37
39
|
const integrationTestM2MFakeUser = new UserProfile_dto_1.UserProfile();
|
|
38
40
|
integrationTestM2MFakeUser.email_verified = true;
|
|
39
|
-
integrationTestM2MFakeUser.family_name =
|
|
41
|
+
integrationTestM2MFakeUser.family_name =
|
|
42
|
+
this.personConfig.fakeFamilyName;
|
|
40
43
|
integrationTestM2MFakeUser.gender = undefined;
|
|
41
44
|
integrationTestM2MFakeUser.sub = payload.sub;
|
|
42
|
-
integrationTestM2MFakeUser.given_name =
|
|
43
|
-
|
|
44
|
-
integrationTestM2MFakeUser.
|
|
45
|
-
integrationTestM2MFakeUser.
|
|
46
|
-
|
|
45
|
+
integrationTestM2MFakeUser.given_name =
|
|
46
|
+
this.personConfig.fakeGivenNAme;
|
|
47
|
+
integrationTestM2MFakeUser.name = this.personConfig.fakeName;
|
|
48
|
+
integrationTestM2MFakeUser.email = this.personConfig.fakeEmail;
|
|
49
|
+
integrationTestM2MFakeUser.picture = this.personConfig.fakePicture;
|
|
47
50
|
return integrationTestM2MFakeUser;
|
|
48
51
|
}
|
|
49
52
|
return await this.authzClient.getUser(rawAccessToken);
|
|
@@ -81,31 +84,42 @@ let PersonService = class PersonService {
|
|
|
81
84
|
// save person
|
|
82
85
|
return this.repository.save(person);
|
|
83
86
|
}
|
|
84
|
-
async create(createPersonDto) {
|
|
85
|
-
return this.repository.save(createPersonDto);
|
|
86
|
-
}
|
|
87
87
|
async findAll() {
|
|
88
88
|
return this.repository.find();
|
|
89
89
|
}
|
|
90
90
|
async findOneByAuth0Id(auth0Id) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
this.logger.error("Couldn't find a user to notify", error);
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
91
|
+
return this.repository.findOneOrFail({
|
|
92
|
+
auth0UserId: auth0Id,
|
|
93
|
+
});
|
|
100
94
|
}
|
|
101
95
|
async findOne(id) {
|
|
102
96
|
return this.repository.findOneOrFail(id);
|
|
103
97
|
}
|
|
104
|
-
async
|
|
105
|
-
return this.repository.
|
|
98
|
+
async findOneByUuid(uuid) {
|
|
99
|
+
return this.repository.findOneOrFail({ uuid }, { relations: ["ownerOfOrganisations"] });
|
|
106
100
|
}
|
|
107
|
-
async
|
|
108
|
-
|
|
101
|
+
async update(uuid, updatePersonDto, currentUserUuid) {
|
|
102
|
+
this.isOwnerGuard(uuid, currentUserUuid, "update");
|
|
103
|
+
return this.repository.update({ uuid }, updatePersonDto);
|
|
104
|
+
}
|
|
105
|
+
async remove(uuid, currentUserUuid) {
|
|
106
|
+
this.isOwnerGuard(uuid, currentUserUuid, "delete");
|
|
107
|
+
const user = await this.repository.findOneOrFail({
|
|
108
|
+
uuid,
|
|
109
|
+
}, {});
|
|
110
|
+
if (user.ownerOfOrganisations.length > 0) {
|
|
111
|
+
throw new Error("Can't remove the owner of an organisation");
|
|
112
|
+
}
|
|
113
|
+
return this.repository.remove(user);
|
|
114
|
+
}
|
|
115
|
+
isOwnerGuard(uuid, currentUserUuid, attemptedAction) {
|
|
116
|
+
if (uuid !== currentUserUuid) {
|
|
117
|
+
this.logger.warn(`Attempted to ${attemptedAction} another user`, {
|
|
118
|
+
currentUserUuid,
|
|
119
|
+
uuid,
|
|
120
|
+
});
|
|
121
|
+
throw new common_1.NotFoundException();
|
|
122
|
+
}
|
|
109
123
|
}
|
|
110
124
|
};
|
|
111
125
|
PersonService = __decorate([
|
|
@@ -113,7 +127,8 @@ PersonService = __decorate([
|
|
|
113
127
|
__param(0, typeorm_1.InjectRepository(person_entity_1.Person)),
|
|
114
128
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
115
129
|
CoreLoggerService_1.default,
|
|
116
|
-
authz_service_1.AuthZClientService
|
|
130
|
+
authz_service_1.AuthZClientService,
|
|
131
|
+
PersonConfigurationService_1.PersonConfigurationService])
|
|
117
132
|
], PersonService);
|
|
118
133
|
exports.PersonService = PersonService;
|
|
119
134
|
//# sourceMappingURL=person.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person.service.js","sourceRoot":"","sources":["../../src/person/person.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"person.service.js","sourceRoot":"","sources":["../../src/person/person.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA6D;AAC7D,6CAAiD;AACjD,qCAAmC;AAEnC,gEAAgE;AAChE,oEAA2D;AAC3D,oFAA4D;AAC5D,sFAA0E;AAE1E,4DAAgD;AAChD,6EAAwE;AAGxE,IAAa,aAAa,GAA1B,MAAa,aAAa;IACtB,YAEY,UAA8B,EAC9B,MAAyB,EACzB,WAA+B,EAC/B,YAAwC;QAHxC,eAAU,GAAV,UAAU,CAAoB;QAC9B,WAAM,GAAN,MAAM,CAAmB;QACzB,gBAAW,GAAX,WAAW,CAAoB;QAC/B,iBAAY,GAAZ,YAAY,CAA4B;IACjD,CAAC;IAEJ,KAAK,CAAC,YAAY,CACd,OAAoB,EACpB,cAAsB;QAEtB,uDAAuD;QACvD,+BAA+B;QAC/B,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAC3C,MAAM,0BAA0B,GAAG,IAAI,6BAAW,EAAE,CAAC;YACrD,0BAA0B,CAAC,cAAc,GAAG,IAAI,CAAC;YACjD,0BAA0B,CAAC,WAAW;gBAClC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;YACrC,0BAA0B,CAAC,MAAM,GAAG,SAAS,CAAC;YAC9C,0BAA0B,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAC7C,0BAA0B,CAAC,UAAU;gBACjC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC;YACpC,0BAA0B,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;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AAQ,CAAC,CAAC;QAEnD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAC5C;YACI,IAAI;SACP,EACD,EAAE,CACL,CAAC;QACF,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;SAChE;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAEO,YAAY,CAChB,IAAY,EACZ,eAAuB,EACvB,eAAuB;QAEvB,IAAI,IAAI,KAAK,eAAe,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,eAAe,eAAe,EAAE;gBAC7D,eAAe;gBACf,IAAI;aACP,CAAC,CAAC;YACH,MAAM,IAAI,0BAAiB,EAAE,CAAC;SACjC;IACL,CAAC;CACJ,CAAA;AAlIY,aAAa;IADzB,mBAAU,EAAE;IAGJ,WAAA,0BAAgB,CAAC,sBAAM,CAAC,CAAA;qCACL,oBAAU;QACd,2BAAiB;QACZ,kCAAkB;QACjB,uDAA0B;GAN3C,aAAa,CAkIzB;AAlIY,sCAAa"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { INestApplication } from "@nestjs/common";
|
|
2
2
|
import CoreLoggerService from "../logger/CoreLoggerService";
|
|
3
|
+
import { CoreConfigurationService } from "..";
|
|
3
4
|
export declare class SwaggerGen {
|
|
4
5
|
private logger;
|
|
5
|
-
|
|
6
|
+
private config;
|
|
7
|
+
constructor(logger: CoreLoggerService, config: CoreConfigurationService);
|
|
6
8
|
generate(app: INestApplication, pathToSave: string): void;
|
|
7
|
-
static runOnThisEnvironment(generateSwagger?: string): boolean;
|
|
8
9
|
}
|
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
|
-
var SwaggerGen_1;
|
|
15
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
15
|
exports.SwaggerGen = void 0;
|
|
17
16
|
const common_1 = require("@nestjs/common");
|
|
@@ -19,15 +18,17 @@ const swagger_1 = require("@nestjs/swagger");
|
|
|
19
18
|
const fs_1 = __importDefault(require("fs"));
|
|
20
19
|
const child_process_1 = require("child_process");
|
|
21
20
|
const CoreLoggerService_1 = __importDefault(require("../logger/CoreLoggerService"));
|
|
21
|
+
const __1 = require("..");
|
|
22
22
|
/* istanbul ignore next */
|
|
23
|
-
let SwaggerGen =
|
|
23
|
+
let SwaggerGen =
|
|
24
24
|
// eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
|
|
25
25
|
class SwaggerGen {
|
|
26
|
-
constructor(logger) {
|
|
26
|
+
constructor(logger, config) {
|
|
27
27
|
this.logger = logger;
|
|
28
|
+
this.config = config;
|
|
28
29
|
}
|
|
29
30
|
generate(app, pathToSave) {
|
|
30
|
-
if (!
|
|
31
|
+
if (!this.config.shouldGenerateSwagger) {
|
|
31
32
|
this.logger.log("Skipping swagger model generation for this environment");
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
@@ -39,25 +40,25 @@ class SwaggerGen {
|
|
|
39
40
|
const document = swagger_1.SwaggerModule.createDocument(app, config);
|
|
40
41
|
swagger_1.SwaggerModule.setup("swagger", app, document);
|
|
41
42
|
// tslint:disable-next-line: non-literal-fs-path
|
|
42
|
-
fs_1.default.writeFileSync(pathToSave, JSON.stringify(document));
|
|
43
|
+
fs_1.default.writeFileSync(pathToSave, JSON.stringify(document, undefined, 2));
|
|
43
44
|
this.logger.log(`Wrote swagger api doc to ${pathToSave}`);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return generateSwagger?.toLowerCase() === "true";
|
|
45
|
+
if (this.config.shouldAutomaticallyInstallApiModels) {
|
|
46
|
+
const modelGenerator = child_process_1.spawn("./generate.sh", {
|
|
47
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
48
|
+
shell: true,
|
|
49
|
+
});
|
|
50
|
+
modelGenerator.on("exit", () => {
|
|
51
|
+
this.logger.log("Regenerated shared api models");
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
SwaggerGen =
|
|
56
|
+
SwaggerGen = __decorate([
|
|
57
57
|
common_1.Injectable()
|
|
58
58
|
// eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
|
|
59
59
|
,
|
|
60
|
-
__metadata("design:paramtypes", [CoreLoggerService_1.default
|
|
60
|
+
__metadata("design:paramtypes", [CoreLoggerService_1.default,
|
|
61
|
+
__1.CoreConfigurationService])
|
|
61
62
|
], SwaggerGen);
|
|
62
63
|
exports.SwaggerGen = SwaggerGen;
|
|
63
64
|
//# sourceMappingURL=SwaggerGen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwaggerGen.js","sourceRoot":"","sources":["../../src/root-app/SwaggerGen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SwaggerGen.js","sourceRoot":"","sources":["../../src/root-app/SwaggerGen.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,6CAA+D;AAC/D,4CAAoB;AAEpB,iDAAoC;AACpC,oFAA4D;AAC5D,0BAA4C;AAE5C,0BAA0B;AAG1B,IAAa,UAAU;AADvB,iFAAiF;AACjF,MAAa,UAAU;IACnB,YACY,MAAyB,EACzB,MAAgC;QADhC,WAAM,GAAN,MAAM,CAAmB;QACzB,WAAM,GAAN,MAAM,CAA0B;IACzC,CAAC;IACG,QAAQ,CAAC,GAAqB,EAAE,UAAkB;QACrD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,wDAAwD,CAC3D,CAAC;YACF,OAAO;SACV;QACD,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;aAC/B,aAAa,EAAE;aACf,QAAQ,CAAC,cAAc,CAAC;aACxB,cAAc,CAAC,2BAA2B,CAAC;aAC3C,KAAK,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC3D,uBAAa,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAE9C,gDAAgD;QAChD,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,UAAU,EAAE,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,MAAM,CAAC,mCAAmC,EAAE;YACjD,MAAM,cAAc,GAAG,qBAAK,CAAC,eAAe,EAAE;gBAC1C,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC;gBACtC,KAAK,EAAE,IAAI;aACd,CAAC,CAAC;YAEH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;gBAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAA;AAlCY,UAAU;IAFtB,mBAAU,EAAE;IACb,iFAAiF;;qCAGzD,2BAAiB;QACjB,4BAAwB;GAHnC,UAAU,CAkCtB;AAlCY,gCAAU"}
|
|
@@ -23,7 +23,6 @@ const core_1 = require("@nestjs/core");
|
|
|
23
23
|
const CoreLoggerService_1 = __importDefault(require("../logger/CoreLoggerService"));
|
|
24
24
|
const CoreConfigurationService_1 = require("../core-config/CoreConfigurationService");
|
|
25
25
|
const LoggingInterceptor_1 = require("../logger/LoggingInterceptor");
|
|
26
|
-
const httpLogResponseContent_1 = require("./httpLogResponseContent");
|
|
27
26
|
const CoreConfig_module_1 = require("../core-config/CoreConfig.module");
|
|
28
27
|
const config_1 = require("@nestjs/config");
|
|
29
28
|
const organisation_module_1 = require("../organisation/organisation.module");
|
|
@@ -45,7 +44,6 @@ let CoreModule = class CoreModule {
|
|
|
45
44
|
forbidNonWhitelisted: true,
|
|
46
45
|
}));
|
|
47
46
|
app.useGlobalInterceptors(new common_1.ClassSerializerInterceptor(app.get(core_1.Reflector)), new LoggingInterceptor_1.LoggingInterceptor(loggerService));
|
|
48
|
-
app.useGlobalInterceptors(new httpLogResponseContent_1.HttpLogResponse());
|
|
49
47
|
loggerService.log(`will listen on port ${configService.webPort} (DEV: http://localhost:${configService.webPort} )`);
|
|
50
48
|
await callback(app);
|
|
51
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-app.module.js","sourceRoot":"","sources":["../../src/root-app/core-app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAsD;AACtD,+DAA+D;AAC/D,4DAA4D;AAC5D,4BAA0B;AAC1B,2CAMwB;AACxB,2DAAqD;AACrD,qDAA+C;AAC/C,+CAAyC;AACzC,6CAAwC;AACxC,uCAAoD;AACpD,oFAA4D;AAC5D,sFAAiF;AACjF,qEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"core-app.module.js","sourceRoot":"","sources":["../../src/root-app/core-app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAsD;AACtD,+DAA+D;AAC/D,4DAA4D;AAC5D,4BAA0B;AAC1B,2CAMwB;AACxB,2DAAqD;AACrD,qDAA+C;AAC/C,+CAAyC;AACzC,6CAAwC;AACxC,uCAAoD;AACpD,oFAA4D;AAC5D,sFAAiF;AACjF,qEAAgE;AAChE,wEAAkE;AAClE,2CAA4C;AAC5C,6EAAuE;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AA;AA5CY,UAAU;IAXtB,eAAM,CAAC;QACJ,OAAO,EAAE;YACL,qBAAY,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC;YACnC,4BAAY;YACZ,oCAAgB;YAChB,wCAAkB;SACrB;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,EAAE,uBAAU,CAAC;QACnC,OAAO,EAAE,CAAC,uBAAU,CAAC;KACxB,CAAC;GACW,UAAU,CA4CtB;AA5CY,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,43 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.HttpLogResponse = void 0;
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const operators_1 = require("rxjs/operators");
|
|
13
|
-
let HttpLogResponse = class HttpLogResponse {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.logger = new common_1.Logger("HTTP");
|
|
16
|
-
}
|
|
17
|
-
intercept(context, next) {
|
|
18
|
-
const request = context.switchToHttp().getRequest();
|
|
19
|
-
const response = context.switchToHttp().getResponse();
|
|
20
|
-
const { originalUrl, method, params, query, body } = request;
|
|
21
|
-
this.logger.log({
|
|
22
|
-
type: "REQUEST",
|
|
23
|
-
originalUrl,
|
|
24
|
-
method,
|
|
25
|
-
params: params || undefined,
|
|
26
|
-
query: query || undefined,
|
|
27
|
-
body: body || undefined,
|
|
28
|
-
});
|
|
29
|
-
return next.handle().pipe(operators_1.tap((data) => this.logger.log({
|
|
30
|
-
type: "RESPONSE",
|
|
31
|
-
originalUrl,
|
|
32
|
-
method,
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
34
|
-
status: response?.status,
|
|
35
|
-
responseBody: data || undefined,
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
HttpLogResponse = __decorate([
|
|
40
|
-
common_1.Injectable()
|
|
41
|
-
], HttpLogResponse);
|
|
42
|
-
exports.HttpLogResponse = HttpLogResponse;
|
|
43
|
-
//# sourceMappingURL=httpLogResponseContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpLogResponseContent.js","sourceRoot":"","sources":["../../src/root-app/httpLogResponseContent.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4DAA4D;AAC5D,2CAMwB;AACxB,8CAAmC;AAInC,IAAa,eAAe,GAA5B,MAAa,eAAe;IAA5B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,CAAC;IA+BxC,CAAC;IA7BG,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAClD,MAAM,OAAO,GAAY,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAE7D,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;QAEtD,MAAM,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC;QAE3D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACZ,IAAI,EAAE,SAAS;YACf,WAAW;YACX,MAAM;YACN,MAAM,EAAE,MAAM,IAAI,SAAS;YAC3B,KAAK,EAAE,KAAK,IAAI,SAAS;YACzB,IAAI,EAAE,IAAI,IAAI,SAAS;SAC1B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,eAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACZ,IAAI,EAAE,UAAU;YAChB,WAAW;YACX,MAAM;YACN,sEAAsE;YACtE,MAAM,EAAE,QAAQ,EAAE,MAAM;YACxB,YAAY,EAAE,IAAI,IAAI,SAAS;SAClC,CAAC,CACL,CACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAhCY,eAAe;IAD3B,mBAAU,EAAE;GACA,eAAe,CAgC3B;AAhCY,0CAAe"}
|