@nu-art/permissions
Advanced tools
Comparing version 0.20.8 to 0.20.9
import { BaseDB_ApiGenerator } from "@nu-art/db-api-generator/backend"; | ||
import { DB_PermissionAccessLevel, DB_PermissionApi, DB_PermissionDomain, DB_PermissionProject, Request_RegisterProject } from "../_imports"; | ||
import { DB_PermissionAccessLevel, DB_PermissionApi, DB_PermissionDomain, DB_PermissionProject } from "../_imports"; | ||
export declare class ProjectDB_Class extends BaseDB_ApiGenerator<DB_PermissionProject> { | ||
@@ -14,3 +14,3 @@ constructor(); | ||
constructor(); | ||
registerApis(projectDef: Request_RegisterProject): Promise<DB_PermissionApi[]>; | ||
registerApis(projectId: string, projectName: string, pathArray: string[]): Promise<DB_PermissionApi[]>; | ||
} | ||
@@ -17,0 +17,0 @@ export declare const ProjectPermissionsDB: ProjectDB_Class; |
@@ -180,3 +180,3 @@ "use strict"; | ||
} | ||
ApiDB_Class.prototype.registerApis = function (projectDef) { | ||
ApiDB_Class.prototype.registerApis = function (projectId, projectName, pathArray) { | ||
var _this = this; | ||
@@ -188,8 +188,8 @@ return this.runInTransaction(function (transaction) { return __awaiter(_this, void 0, void 0, function () { | ||
switch (_a.label) { | ||
case 0: return [4, exports.ApiPermissionsDB.query({ where: { projectId: projectDef.projectId } })]; | ||
case 0: return [4, exports.ApiPermissionsDB.query({ where: { projectId: projectId } })]; | ||
case 1: | ||
existingProjectApis = _a.sent(); | ||
apisToAdd = projectDef.pathArray | ||
apisToAdd = pathArray | ||
.filter(function (path) { return !existingProjectApis.find(function (api) { return api.path === path; }); }) | ||
.map(function (path) { return ({ path: path, projectId: projectDef.projectId }); }); | ||
.map(function (path) { return ({ path: path, projectId: projectId }); }); | ||
return [2, Promise.all(apisToAdd.map(function (api) { return _this.insertImpl(transaction, api); }))]; | ||
@@ -196,0 +196,0 @@ } |
import { Module } from "@nu-art/ts-common"; | ||
import { Request_RegisterProject } from "../.."; | ||
export declare class PermissionsRegisterProject_Class extends Module { | ||
registerProject(projectDetails: Request_RegisterProject): Promise<void>; | ||
declare type ProjectIdentityConfig = { | ||
projectId: string; | ||
projectName: string; | ||
}; | ||
export declare class PermissionsRegisterProject_Class extends Module<ProjectIdentityConfig> { | ||
registerProject(): Promise<void>; | ||
} | ||
export declare const PermissionsRegisterProject: PermissionsRegisterProject_Class; | ||
export {}; |
@@ -54,2 +54,3 @@ "use strict"; | ||
var managment_1 = require("./db-types/managment"); | ||
var backend_1 = require("@nu-art/thunderstorm/backend"); | ||
var PermissionsRegisterProject_Class = (function (_super) { | ||
@@ -60,10 +61,17 @@ __extends(PermissionsRegisterProject_Class, _super); | ||
} | ||
PermissionsRegisterProject_Class.prototype.registerProject = function (projectDetails) { | ||
PermissionsRegisterProject_Class.prototype.registerProject = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var routes, projectId, projectName, pathArray; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, managment_1.ProjectPermissionsDB.upsert({ _id: projectDetails.projectId, name: projectDetails.projectName })]; | ||
case 0: | ||
routes = backend_1.HttpServer.getRoutes(); | ||
projectId = this.config.projectId; | ||
projectName = this.config.projectName; | ||
pathArray = routes.map(function (httpRoute) { return httpRoute.path; }); | ||
pathArray = pathArray.filter(function (path) { return path !== '*'; }); | ||
return [4, managment_1.ProjectPermissionsDB.upsert({ _id: projectId, name: projectName })]; | ||
case 1: | ||
_a.sent(); | ||
return [4, managment_1.ApiPermissionsDB.registerApis(projectDetails)]; | ||
return [4, managment_1.ApiPermissionsDB.registerApis(projectId, projectName, pathArray)]; | ||
case 2: | ||
@@ -70,0 +78,0 @@ _a.sent(); |
{ | ||
"name": "@nu-art/permissions", | ||
"version": "0.20.8", | ||
"version": "0.20.9", | ||
"description": "Permissions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -12,8 +12,3 @@ import { ApiWithQuery, ApiWithBody } from "@nu-art/thunderstorm"; | ||
export declare type Permissions_ApiAssertUserAccess = ApiWithBody<"/v1/permissions/assert-user-access", Request_AssertApiForUser, Response_User>; | ||
export declare type Request_RegisterProject = { | ||
projectId: string; | ||
projectName: string; | ||
pathArray: string[]; | ||
}; | ||
export declare type Permissions_ApiRegisterProject = ApiWithBody<"/v1/permissions/register-project", Request_RegisterProject, void>; | ||
export declare type Permissions_ApiRegisterProject = ApiWithQuery<"/v1/permissions/register-project", void>; | ||
export declare type ApiBinder_GetCustomFields = ApiWithQuery<'/v1/permissions/assign/get-custom-fields', string[]>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
125592
79
1892
2