@venturialstd/organization 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +678 -0
- package/dist/constants/organization.constant.d.ts +12 -0
- package/dist/constants/organization.constant.d.ts.map +1 -0
- package/dist/constants/organization.constant.js +17 -0
- package/dist/constants/organization.constant.js.map +1 -0
- package/dist/constants/organization.settings.constant.d.ts +11 -0
- package/dist/constants/organization.settings.constant.d.ts.map +1 -0
- package/dist/constants/organization.settings.constant.js +14 -0
- package/dist/constants/organization.settings.constant.js.map +1 -0
- package/dist/decorators/organization.decorator.d.ts +4 -0
- package/dist/decorators/organization.decorator.d.ts.map +1 -0
- package/dist/decorators/organization.decorator.js +22 -0
- package/dist/decorators/organization.decorator.js.map +1 -0
- package/dist/decorators/roles.decorator.d.ts +3 -0
- package/dist/decorators/roles.decorator.d.ts.map +1 -0
- package/dist/decorators/roles.decorator.js +7 -0
- package/dist/decorators/roles.decorator.js.map +1 -0
- package/dist/entities/organization-user.entity.d.ts +16 -0
- package/dist/entities/organization-user.entity.d.ts.map +1 -0
- package/dist/entities/organization-user.entity.js +120 -0
- package/dist/entities/organization-user.entity.js.map +1 -0
- package/dist/entities/organization.entity.d.ts +13 -0
- package/dist/entities/organization.entity.d.ts.map +1 -0
- package/dist/entities/organization.entity.js +94 -0
- package/dist/entities/organization.entity.js.map +1 -0
- package/dist/guards/organization.guard.d.ts +16 -0
- package/dist/guards/organization.guard.d.ts.map +1 -0
- package/dist/guards/organization.guard.js +90 -0
- package/dist/guards/organization.guard.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/organization.module.d.ts +3 -0
- package/dist/organization.module.d.ts.map +1 -0
- package/dist/organization.module.js +28 -0
- package/dist/organization.module.js.map +1 -0
- package/dist/services/organization-user.service.d.ts +30 -0
- package/dist/services/organization-user.service.d.ts.map +1 -0
- package/dist/services/organization-user.service.js +246 -0
- package/dist/services/organization-user.service.js.map +1 -0
- package/dist/services/organization.service.d.ts +18 -0
- package/dist/services/organization.service.d.ts.map +1 -0
- package/dist/services/organization.service.js +117 -0
- package/dist/services/organization.service.js.map +1 -0
- package/dist/settings/organization.settings.d.ts +3 -0
- package/dist/settings/organization.settings.d.ts.map +1 -0
- package/dist/settings/organization.settings.js +79 -0
- package/dist/settings/organization.settings.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ORGANIZATION_SETTING_KEYS: {
|
|
2
|
+
readonly GENERAL_MAX_ORGANIZATIONS: "organization.general.max_organizations";
|
|
3
|
+
readonly GENERAL_MAX_MEMBERS: "organization.general.max_members";
|
|
4
|
+
readonly FEATURES_CUSTOM_DOMAIN: "organization.features.custom_domain";
|
|
5
|
+
readonly FEATURES_API_ACCESS: "organization.features.api_access";
|
|
6
|
+
readonly FEATURES_SSO: "organization.features.sso";
|
|
7
|
+
readonly LIMITS_STORAGE: "organization.limits.storage_gb";
|
|
8
|
+
readonly LIMITS_BANDWIDTH: "organization.limits.bandwidth_gb";
|
|
9
|
+
readonly LIMITS_PROJECTS: "organization.limits.projects";
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=organization.settings.constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.settings.constant.d.ts","sourceRoot":"","sources":["../../src/constants/organization.settings.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB;;;;;;;;;CAS5B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ORGANIZATION_SETTING_KEYS = void 0;
|
|
4
|
+
exports.ORGANIZATION_SETTING_KEYS = {
|
|
5
|
+
GENERAL_MAX_ORGANIZATIONS: 'organization.general.max_organizations',
|
|
6
|
+
GENERAL_MAX_MEMBERS: 'organization.general.max_members',
|
|
7
|
+
FEATURES_CUSTOM_DOMAIN: 'organization.features.custom_domain',
|
|
8
|
+
FEATURES_API_ACCESS: 'organization.features.api_access',
|
|
9
|
+
FEATURES_SSO: 'organization.features.sso',
|
|
10
|
+
LIMITS_STORAGE: 'organization.limits.storage_gb',
|
|
11
|
+
LIMITS_BANDWIDTH: 'organization.limits.bandwidth_gb',
|
|
12
|
+
LIMITS_PROJECTS: 'organization.limits.projects',
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=organization.settings.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.settings.constant.js","sourceRoot":"","sources":["../../src/constants/organization.settings.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,yBAAyB,GAAG;IACvC,yBAAyB,EAAE,wCAAwC;IACnE,mBAAmB,EAAE,kCAAkC;IACvD,sBAAsB,EAAE,qCAAqC;IAC7D,mBAAmB,EAAE,kCAAkC;IACvD,YAAY,EAAE,2BAA2B;IACzC,cAAc,EAAE,gCAAgC;IAChD,gBAAgB,EAAE,kCAAkC;IACpD,eAAe,EAAE,8BAA8B;CACvC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const OrganizationId: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
2
|
+
export declare const UserId: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
3
|
+
export declare const OrganizationContext: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
4
|
+
//# sourceMappingURL=organization.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/organization.decorator.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,mDAK1B,CAAC;AAWF,eAAO,MAAM,MAAM,mDAGjB,CAAC;AAWH,eAAO,MAAM,mBAAmB,mDAQ9B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrganizationContext = exports.UserId = exports.OrganizationId = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.OrganizationId = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
|
7
|
+
return request.organizationId || request.headers['x-organization-id'];
|
|
8
|
+
});
|
|
9
|
+
exports.UserId = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
10
|
+
const request = ctx.switchToHttp().getRequest();
|
|
11
|
+
return request.user?.id || request.userId;
|
|
12
|
+
});
|
|
13
|
+
exports.OrganizationContext = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
14
|
+
const request = ctx.switchToHttp().getRequest();
|
|
15
|
+
return {
|
|
16
|
+
organizationId: request.organizationId || request.headers['x-organization-id'],
|
|
17
|
+
userId: request.user?.id || request.userId,
|
|
18
|
+
role: request.organizationRole,
|
|
19
|
+
user: request.user,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=organization.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.decorator.js","sourceRoot":"","sources":["../../src/decorators/organization.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAW3D,QAAA,cAAc,GAAG,IAAA,6BAAoB,EAChD,CAAC,IAAa,EAAE,GAAqB,EAAU,EAAE;IAC/C,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC,CACF,CAAC;AAWW,QAAA,MAAM,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAa,EAAE,GAAqB,EAAU,EAAE;IAC1F,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC;AAC5C,CAAC,CAAC,CAAC;AAWU,QAAA,mBAAmB,GAAG,IAAA,6BAAoB,EAAC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IAC/F,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC9E,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,OAAO,CAAC,MAAM;QAC1C,IAAI,EAAE,OAAO,CAAC,gBAAgB;QAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/roles.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAa5E,eAAO,MAAM,KAAK,GAAI,GAAG,OAAO,sBAAsB,EAAE,qDAAgC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Roles = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const Roles = (...roles) => (0, common_1.SetMetadata)('roles', roles);
|
|
6
|
+
exports.Roles = Roles;
|
|
7
|
+
//# sourceMappingURL=roles.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.decorator.js","sourceRoot":"","sources":["../../src/decorators/roles.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAetC,MAAM,KAAK,GAAG,CAAC,GAAG,KAA+B,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAA5E,QAAA,KAAK,SAAuE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ORGANIZATION_USER_ROLE, ORGANIZATION_USER_STATUS } from '../constants/organization.constant';
|
|
2
|
+
export declare class OrganizationUser {
|
|
3
|
+
id: string;
|
|
4
|
+
organizationId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
role: ORGANIZATION_USER_ROLE;
|
|
7
|
+
status: ORGANIZATION_USER_STATUS;
|
|
8
|
+
isPrimary: boolean;
|
|
9
|
+
invitedBy: string;
|
|
10
|
+
invitedAt: Date;
|
|
11
|
+
joinedAt: Date;
|
|
12
|
+
permissions: Record<string, unknown>;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=organization-user.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-user.entity.d.ts","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAE5C,qBAEa,gBAAgB;IAE3B,EAAE,EAAE,MAAM,CAAC;IAMX,cAAc,EAAE,MAAM,CAAC;IAMvB,MAAM,EAAE,MAAM,CAAC;IASf,IAAI,EAAE,sBAAsB,CAAC;IAS7B,MAAM,EAAE,wBAAwB,CAAC;IAIjC,SAAS,EAAE,OAAO,CAAC;IAKnB,SAAS,EAAE,MAAM,CAAC;IAKlB,SAAS,EAAE,IAAI,CAAC;IAKhB,QAAQ,EAAE,IAAI,CAAC;IAKf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAQrC,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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.OrganizationUser = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const organization_constant_1 = require("../constants/organization.constant");
|
|
16
|
+
let OrganizationUser = class OrganizationUser {
|
|
17
|
+
id;
|
|
18
|
+
organizationId;
|
|
19
|
+
userId;
|
|
20
|
+
role;
|
|
21
|
+
status;
|
|
22
|
+
isPrimary;
|
|
23
|
+
invitedBy;
|
|
24
|
+
invitedAt;
|
|
25
|
+
joinedAt;
|
|
26
|
+
permissions;
|
|
27
|
+
createdAt;
|
|
28
|
+
updatedAt;
|
|
29
|
+
};
|
|
30
|
+
exports.OrganizationUser = OrganizationUser;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], OrganizationUser.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
38
|
+
(0, typeorm_1.Column)(),
|
|
39
|
+
(0, typeorm_1.Index)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], OrganizationUser.prototype, "organizationId", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsString)(),
|
|
44
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
45
|
+
(0, typeorm_1.Column)(),
|
|
46
|
+
(0, typeorm_1.Index)(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], OrganizationUser.prototype, "userId", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, class_validator_1.IsString)(),
|
|
51
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
52
|
+
(0, typeorm_1.Column)({
|
|
53
|
+
type: 'enum',
|
|
54
|
+
enum: organization_constant_1.ORGANIZATION_USER_ROLE,
|
|
55
|
+
default: organization_constant_1.ORGANIZATION_USER_ROLE.MEMBER,
|
|
56
|
+
}),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], OrganizationUser.prototype, "role", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, class_validator_1.IsString)(),
|
|
61
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
62
|
+
(0, typeorm_1.Column)({
|
|
63
|
+
type: 'enum',
|
|
64
|
+
enum: organization_constant_1.ORGANIZATION_USER_STATUS,
|
|
65
|
+
default: organization_constant_1.ORGANIZATION_USER_STATUS.ACTIVE,
|
|
66
|
+
}),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], OrganizationUser.prototype, "status", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, class_validator_1.IsBoolean)(),
|
|
71
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
72
|
+
__metadata("design:type", Boolean)
|
|
73
|
+
], OrganizationUser.prototype, "isPrimary", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, class_validator_1.IsString)(),
|
|
76
|
+
(0, class_validator_1.IsOptional)(),
|
|
77
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
78
|
+
__metadata("design:type", String)
|
|
79
|
+
], OrganizationUser.prototype, "invitedBy", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, class_validator_1.IsString)(),
|
|
82
|
+
(0, class_validator_1.IsOptional)(),
|
|
83
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
84
|
+
__metadata("design:type", Date)
|
|
85
|
+
], OrganizationUser.prototype, "invitedAt", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, class_validator_1.IsString)(),
|
|
88
|
+
(0, class_validator_1.IsOptional)(),
|
|
89
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
|
|
90
|
+
__metadata("design:type", Date)
|
|
91
|
+
], OrganizationUser.prototype, "joinedAt", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, class_validator_1.IsString)(),
|
|
94
|
+
(0, class_validator_1.IsOptional)(),
|
|
95
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
96
|
+
__metadata("design:type", Object)
|
|
97
|
+
], OrganizationUser.prototype, "permissions", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typeorm_1.CreateDateColumn)({
|
|
100
|
+
name: 'createdAt',
|
|
101
|
+
nullable: false,
|
|
102
|
+
type: 'timestamptz',
|
|
103
|
+
default: () => 'CURRENT_TIMESTAMP',
|
|
104
|
+
}),
|
|
105
|
+
__metadata("design:type", Date)
|
|
106
|
+
], OrganizationUser.prototype, "createdAt", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, typeorm_1.UpdateDateColumn)({
|
|
109
|
+
name: 'updatedAt',
|
|
110
|
+
nullable: false,
|
|
111
|
+
type: 'timestamptz',
|
|
112
|
+
default: () => 'CURRENT_TIMESTAMP',
|
|
113
|
+
}),
|
|
114
|
+
__metadata("design:type", Date)
|
|
115
|
+
], OrganizationUser.prototype, "updatedAt", void 0);
|
|
116
|
+
exports.OrganizationUser = OrganizationUser = __decorate([
|
|
117
|
+
(0, typeorm_1.Entity)('organization_user'),
|
|
118
|
+
(0, typeorm_1.Index)(['organizationId', 'userId'], { unique: true })
|
|
119
|
+
], OrganizationUser);
|
|
120
|
+
//# sourceMappingURL=organization-user.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-user.entity.js","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8E;AAC9E,qCAOiB;AAEjB,8EAG4C;AAIrC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,EAAE,CAAS;IAMX,cAAc,CAAS;IAMvB,MAAM,CAAS;IASf,IAAI,CAAyB;IAS7B,MAAM,CAA2B;IAIjC,SAAS,CAAU;IAKnB,SAAS,CAAS;IAKlB,SAAS,CAAO;IAKhB,QAAQ,CAAO;IAKf,WAAW,CAA0B;IAQrC,SAAS,CAAO;IAQhB,SAAS,CAAO;CACjB,CAAA;AAzEY,4CAAgB;AAE3B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACpB;AAMX;IAJC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,GAAE;;wDACe;AAMvB;IAJC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,GAAE;;gDACO;AASf;IAPC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,8CAAsB;QAC5B,OAAO,EAAE,8CAAsB,CAAC,MAAM;KACvC,CAAC;;8CAC2B;AAS7B;IAPC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC;QACN,IAAI,EAA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AA,eAAK,EAAC,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACzC,gBAAgB,CAyE5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class Organization {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
slug: string;
|
|
5
|
+
domain: string;
|
|
6
|
+
description: string;
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
settings: Record<string, unknown>;
|
|
9
|
+
ownerId: string;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=organization.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.entity.d.ts","sourceRoot":"","sources":["../../src/entities/organization.entity.ts"],"names":[],"mappings":"AASA,qBACa,YAAY;IAEvB,EAAE,EAAE,MAAM,CAAC;IAKX,IAAI,EAAE,MAAM,CAAC;IAKb,IAAI,EAAE,MAAM,CAAC;IAKb,MAAM,EAAE,MAAM,CAAC;IAKf,WAAW,EAAE,MAAM,CAAC;IAIpB,QAAQ,EAAE,OAAO,CAAC;IAKlB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAKlC,OAAO,EAAE,MAAM,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;IAQhB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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.Organization = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let Organization = class Organization {
|
|
16
|
+
id;
|
|
17
|
+
name;
|
|
18
|
+
slug;
|
|
19
|
+
domain;
|
|
20
|
+
description;
|
|
21
|
+
isActive;
|
|
22
|
+
settings;
|
|
23
|
+
ownerId;
|
|
24
|
+
createdAt;
|
|
25
|
+
updatedAt;
|
|
26
|
+
};
|
|
27
|
+
exports.Organization = Organization;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], Organization.prototype, "id", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
35
|
+
(0, typeorm_1.Column)({ unique: true }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], Organization.prototype, "name", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_validator_1.IsString)(),
|
|
40
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
41
|
+
(0, typeorm_1.Column)({ unique: true }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], Organization.prototype, "slug", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, class_validator_1.IsString)(),
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], Organization.prototype, "domain", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, class_validator_1.IsString)(),
|
|
52
|
+
(0, class_validator_1.IsOptional)(),
|
|
53
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], Organization.prototype, "description", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, class_validator_1.IsBoolean)(),
|
|
58
|
+
(0, typeorm_1.Column)({ default: true }),
|
|
59
|
+
__metadata("design:type", Boolean)
|
|
60
|
+
], Organization.prototype, "isActive", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, class_validator_1.IsString)(),
|
|
63
|
+
(0, class_validator_1.IsOptional)(),
|
|
64
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], Organization.prototype, "settings", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, class_validator_1.IsString)(),
|
|
69
|
+
(0, class_validator_1.IsOptional)(),
|
|
70
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], Organization.prototype, "ownerId", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.CreateDateColumn)({
|
|
75
|
+
name: 'createdAt',
|
|
76
|
+
nullable: false,
|
|
77
|
+
type: 'timestamptz',
|
|
78
|
+
default: () => 'CURRENT_TIMESTAMP',
|
|
79
|
+
}),
|
|
80
|
+
__metadata("design:type", Date)
|
|
81
|
+
], Organization.prototype, "createdAt", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.UpdateDateColumn)({
|
|
84
|
+
name: 'updatedAt',
|
|
85
|
+
nullable: false,
|
|
86
|
+
type: 'timestamptz',
|
|
87
|
+
default: () => 'CURRENT_TIMESTAMP',
|
|
88
|
+
}),
|
|
89
|
+
__metadata("design:type", Date)
|
|
90
|
+
], Organization.prototype, "updatedAt", void 0);
|
|
91
|
+
exports.Organization = Organization = __decorate([
|
|
92
|
+
(0, typeorm_1.Entity)('organization')
|
|
93
|
+
], Organization);
|
|
94
|
+
//# sourceMappingURL=organization.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.entity.js","sourceRoot":"","sources":["../../src/entities/organization.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8E;AAC9E,qCAMiB;AAGV,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB,EAAE,CAAS;IAKX,IAAI,CAAS;IAKb,IAAI,CAAS;IAKb,MAAM,CAAS;IAKf,WAAW,CAAS;IAIpB,QAAQ,CAAU;IAKlB,QAAQ,CAA0B;IAKlC,OAAO,CAAS;IAQhB,SAAS,CAAO;IAQhB,SAAS,CAAO;CACjB,CAAA;AArDY,oCAAY;AAEvB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;wCACpB;AAKX;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;0CACZ;AAKb;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;0CACZ;AAKb;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACZ;AAKf;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACP;AAIpB;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;8CACR;AAKlB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACR;AAKlC;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAQhB;IANC,IAAA,0BAAgB,EAAC;QAChB,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB;KACnC,CAAC;8BACS,IAAI;+CAAC;AAQhB;IANC,IAAA,0BAAgB,EAAC;QAChB,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB;KACnC,CAAC;8BACS,IAAI;+CAAC;uBApDL,YAAY;IADxB,IAAA,gBAAM,EAAC,cAAc,CAAC;GACV,YAAY,CAqDxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { OrganizationUserService } from '../services/organization-user.service';
|
|
4
|
+
export declare class OrganizationGuard implements CanActivate {
|
|
5
|
+
private readonly organizationUserService;
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
constructor(organizationUserService: OrganizationUserService, reflector: Reflector);
|
|
8
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare class OrganizationRoleGuard implements CanActivate {
|
|
11
|
+
private readonly organizationUserService;
|
|
12
|
+
private readonly reflector;
|
|
13
|
+
constructor(organizationUserService: OrganizationUserService, reflector: Reflector);
|
|
14
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=organization.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.guard.d.ts","sourceRoot":"","sources":["../../src/guards/organization.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAahF,qBACa,iBAAkB,YAAW,WAAW;IAEjD,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,uBAAuB,EAAE,uBAAuB,EAChD,SAAS,EAAE,SAAS;IAGjC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAmC/D;AAaD,qBACa,qBAAsB,YAAW,WAAW;IAErD,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,uBAAuB,EAAE,uBAAuB,EAChD,SAAS,EAAE,SAAS;IAGjC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAkC/D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.OrganizationRoleGuard = exports.OrganizationGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const organization_user_service_1 = require("../services/organization-user.service");
|
|
16
|
+
let OrganizationGuard = class OrganizationGuard {
|
|
17
|
+
organizationUserService;
|
|
18
|
+
reflector;
|
|
19
|
+
constructor(organizationUserService, reflector) {
|
|
20
|
+
this.organizationUserService = organizationUserService;
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
}
|
|
23
|
+
async canActivate(context) {
|
|
24
|
+
const request = context.switchToHttp().getRequest();
|
|
25
|
+
const organizationId = request.organizationId ||
|
|
26
|
+
request.headers['x-organization-id'] ||
|
|
27
|
+
request.params.organizationId ||
|
|
28
|
+
request.query.organizationId;
|
|
29
|
+
if (!organizationId) {
|
|
30
|
+
throw new common_1.UnauthorizedException('Organization ID is required');
|
|
31
|
+
}
|
|
32
|
+
const userId = request.user?.id || request.userId;
|
|
33
|
+
if (!userId) {
|
|
34
|
+
throw new common_1.UnauthorizedException('User authentication is required');
|
|
35
|
+
}
|
|
36
|
+
const hasAccess = await this.organizationUserService.hasAccess(organizationId, userId);
|
|
37
|
+
if (!hasAccess) {
|
|
38
|
+
throw new common_1.ForbiddenException('You do not have access to this organization');
|
|
39
|
+
}
|
|
40
|
+
const role = await this.organizationUserService.getUserRole(organizationId, userId);
|
|
41
|
+
request.organizationId = organizationId;
|
|
42
|
+
request.organizationRole = role;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.OrganizationGuard = OrganizationGuard;
|
|
47
|
+
exports.OrganizationGuard = OrganizationGuard = __decorate([
|
|
48
|
+
(0, common_1.Injectable)(),
|
|
49
|
+
__metadata("design:paramtypes", [organization_user_service_1.OrganizationUserService,
|
|
50
|
+
core_1.Reflector])
|
|
51
|
+
], OrganizationGuard);
|
|
52
|
+
let OrganizationRoleGuard = class OrganizationRoleGuard {
|
|
53
|
+
organizationUserService;
|
|
54
|
+
reflector;
|
|
55
|
+
constructor(organizationUserService, reflector) {
|
|
56
|
+
this.organizationUserService = organizationUserService;
|
|
57
|
+
this.reflector = reflector;
|
|
58
|
+
}
|
|
59
|
+
async canActivate(context) {
|
|
60
|
+
const requiredRoles = this.reflector.getAllAndOverride('roles', [
|
|
61
|
+
context.getHandler(),
|
|
62
|
+
context.getClass(),
|
|
63
|
+
]);
|
|
64
|
+
if (!requiredRoles || requiredRoles.length === 0) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const request = context.switchToHttp().getRequest();
|
|
68
|
+
const organizationId = request.organizationId;
|
|
69
|
+
const userId = request.user?.id || request.userId;
|
|
70
|
+
if (!organizationId || !userId) {
|
|
71
|
+
throw new common_1.UnauthorizedException('Organization and user context required');
|
|
72
|
+
}
|
|
73
|
+
const userRole = await this.organizationUserService.getUserRole(organizationId, userId);
|
|
74
|
+
if (!userRole) {
|
|
75
|
+
throw new common_1.ForbiddenException('User is not a member of this organization');
|
|
76
|
+
}
|
|
77
|
+
const hasRole = requiredRoles.includes(userRole);
|
|
78
|
+
if (!hasRole) {
|
|
79
|
+
throw new common_1.ForbiddenException(`This action requires one of the following roles: ${requiredRoles.join(', ')}`);
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.OrganizationRoleGuard = OrganizationRoleGuard;
|
|
85
|
+
exports.OrganizationRoleGuard = OrganizationRoleGuard = __decorate([
|
|
86
|
+
(0, common_1.Injectable)(),
|
|
87
|
+
__metadata("design:paramtypes", [organization_user_service_1.OrganizationUserService,
|
|
88
|
+
core_1.Reflector])
|
|
89
|
+
], OrganizationRoleGuard);
|
|
90
|
+
//# sourceMappingURL=organization.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.guard.js","sourceRoot":"","sources":["../../src/guards/organization.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAMwB;AACxB,uCAAyC;AAGzC,qFAAgF;AAczE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAET;IACA;IAFnB,YACmB,uBAAgD,EAChD,SAAoB;QADpB,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAGpD,MAAM,cAAc,GAClB,OAAO,CAAC,cAAc;YACtB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACpC,OAAO,CAAC,MAAM,CAAC,cAAc;YAC7B,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;QAE/B,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,8BAAqB,CAAC,6BAA6B,CAAC,CAAC;QACjE,CAAC;QAGD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC;QAElD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,8BAAqB,CAAC,iCAAiC,CAAC,CAAC;QACrE,CAAC;QAGD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAEvF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,2BAAkB,CAAC,6CAA6C,CAAC,CAAC;QAC9E,CAAC;QAGD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;Q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E,CAAC;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEjD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,2BAAkB,CAC1B,oDAAoD,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/E,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAxCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGiC,mDAAuB;QACrC,gBAAS;GAH5B,qBAAqB,CAwCjC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './constants/organization.constant';
|
|
2
|
+
export * from './constants/organization.settings.constant';
|
|
3
|
+
export * from './decorators/organization.decorator';
|
|
4
|
+
export * from './decorators/roles.decorator';
|
|
5
|
+
export * from './entities/organization.entity';
|
|
6
|
+
export * from './entities/organization-user.entity';
|
|
7
|
+
export * from './guards/organization.guard';
|
|
8
|
+
export * from './organization.module';
|
|
9
|
+
export * from './services/organization.service';
|
|
10
|
+
export * from './services/organization-user.service';
|
|
11
|
+
export * from './settings/organization.settings';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants/organization.constant"), exports);
|
|
18
|
+
__exportStar(require("./constants/organization.settings.constant"), exports);
|
|
19
|
+
__exportStar(require("./decorators/organization.decorator"), exports);
|
|
20
|
+
__exportStar(require("./decorators/roles.decorator"), exports);
|
|
21
|
+
__exportStar(require("./entities/organization.entity"), exports);
|
|
22
|
+
__exportStar(require("./entities/organization-user.entity"), exports);
|
|
23
|
+
__exportStar(require("./guards/organization.guard"), exports);
|
|
24
|
+
__exportStar(require("./organization.module"), exports);
|
|
25
|
+
__exportStar(require("./services/organization.service"), exports);
|
|
26
|
+
__exportStar(require("./services/organization-user.service"), exports);
|
|
27
|
+
__exportStar(require("./settings/organization.settings"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,6EAA2D;AAC3D,sEAAoD;AACpD,+DAA6C;AAC7C,iEAA+C;AAC/C,sEAAoD;AACpD,8DAA4C;AAC5C,wDAAsC;AACtC,kEAAgD;AAChD,uEAAqD;AACrD,mEAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":"AASA,qBAMa,kBAAkB;CAAG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.OrganizationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const core_1 = require("@venturialstd/core");
|
|
13
|
+
const organization_entity_1 = require("./entities/organization.entity");
|
|
14
|
+
const organization_user_entity_1 = require("./entities/organization-user.entity");
|
|
15
|
+
const organization_service_1 = require("./services/organization.service");
|
|
16
|
+
const organization_user_service_1 = require("./services/organization-user.service");
|
|
17
|
+
let OrganizationModule = class OrganizationModule {
|
|
18
|
+
};
|
|
19
|
+
exports.OrganizationModule = OrganizationModule;
|
|
20
|
+
exports.OrganizationModule = OrganizationModule = __decorate([
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [core_1.SharedModule.forRoot({}), typeorm_1.TypeOrmModule.forFeature([organization_entity_1.Organization, organization_user_entity_1.OrganizationUser])],
|
|
23
|
+
providers: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService],
|
|
24
|
+
controllers: [],
|
|
25
|
+
exports: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService],
|
|
26
|
+
})
|
|
27
|
+
], OrganizationModule);
|
|
28
|
+
//# sourceMappingURL=organization.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6CAAkD;AAElD,wEAA8D;AAC9D,kFAAuE;AACvE,0EAAsE;AACtE,oFAA+E;AAQxE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAN9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,mBAAY,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAY,EAAE,2CAAgB,CAAC,CAAC,CAAC;QAC/F,SAAS,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,CAAC;QACzD,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,CAAC;KACxD,CAAC;GACW,kBAAkB,CAAG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TypeOrmCrudService } from '@dataui/crud-typeorm';
|
|
2
|
+
import { AppLogger } from '@venturialstd/core';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { ORGANIZATION_USER_ROLE } from '../constants/organization.constant';
|
|
5
|
+
import { Organization } from '../entities/organization.entity';
|
|
6
|
+
import { OrganizationUser } from '../entities/organization-user.entity';
|
|
7
|
+
export declare class OrganizationUserService extends TypeOrmCrudService<OrganizationUser> {
|
|
8
|
+
readonly repo: Repository<OrganizationUser>;
|
|
9
|
+
private readonly organizationRepo;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
constructor(repo: Repository<OrganizationUser>, organizationRepo: Repository<Organization>, logger: AppLogger);
|
|
12
|
+
addUserToOrganization(organizationId: string, userId: string, role?: ORGANIZATION_USER_ROLE, invitedBy?: string): Promise<OrganizationUser>;
|
|
13
|
+
inviteUserToOrganization(organizationId: string, userId: string, role: ORGANIZATION_USER_ROLE, invitedBy: string): Promise<OrganizationUser>;
|
|
14
|
+
acceptInvitation(organizationId: string, userId: string): Promise<OrganizationUser>;
|
|
15
|
+
removeUserFromOrganization(organizationId: string, userId: string): Promise<void>;
|
|
16
|
+
updateUserRole(organizationId: string, userId: string, newRole: ORGANIZATION_USER_ROLE): Promise<OrganizationUser>;
|
|
17
|
+
getUserOrganizations(userId: string): Promise<OrganizationUser[]>;
|
|
18
|
+
getOrganizationUsers(organizationId: string): Promise<OrganizationUser[]>;
|
|
19
|
+
getActiveOrganizationUsers(organizationId: string): Promise<OrganizationUser[]>;
|
|
20
|
+
hasAccess(organizationId: string, userId: string): Promise<boolean>;
|
|
21
|
+
hasRole(organizationId: string, userId: string, role: ORGANIZATION_USER_ROLE): Promise<boolean>;
|
|
22
|
+
isAdminOrOwner(organizationId: string, userId: string): Promise<boolean>;
|
|
23
|
+
getUserRole(organizationId: string, userId: string): Promise<ORGANIZATION_USER_ROLE | null>;
|
|
24
|
+
setPrimaryOwner(organizationId: string, userId: string): Promise<OrganizationUser>;
|
|
25
|
+
transferOwnership(organizationId: string, fromUserId: string, toUserId: string): Promise<void>;
|
|
26
|
+
getUserInvitations(userId: string): Promise<OrganizationUser[]>;
|
|
27
|
+
suspendUser(organizationId: string, userId: string): Promise<OrganizationUser>;
|
|
28
|
+
reactivateUser(organizationId: string, userId: string): Promise<OrganizationUser>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=organization-user.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-user.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-user.service.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