@venturialstd/organization 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ export declare enum SETTINGS_TYPE {
2
+ TEXT = "text",
3
+ TEXTAREA = "textarea",
4
+ NUMBER = "number",
5
+ BOOLEAN = "boolean",
6
+ SELECT = "select",
7
+ MULTISELECT = "multiselect",
8
+ JSON = "json",
9
+ DATE = "date",
10
+ SECRET = "secret"
11
+ }
12
+ //# sourceMappingURL=settings-type.constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-type.constant.d.ts","sourceRoot":"","sources":["../../src/constants/settings-type.constant.ts"],"names":[],"mappings":"AAGA,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,IAAI,SAAS;IACb,MAAM,WAAW;CAClB"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SETTINGS_TYPE = void 0;
4
+ var SETTINGS_TYPE;
5
+ (function (SETTINGS_TYPE) {
6
+ SETTINGS_TYPE["TEXT"] = "text";
7
+ SETTINGS_TYPE["TEXTAREA"] = "textarea";
8
+ SETTINGS_TYPE["NUMBER"] = "number";
9
+ SETTINGS_TYPE["BOOLEAN"] = "boolean";
10
+ SETTINGS_TYPE["SELECT"] = "select";
11
+ SETTINGS_TYPE["MULTISELECT"] = "multiselect";
12
+ SETTINGS_TYPE["JSON"] = "json";
13
+ SETTINGS_TYPE["DATE"] = "date";
14
+ SETTINGS_TYPE["SECRET"] = "secret";
15
+ })(SETTINGS_TYPE || (exports.SETTINGS_TYPE = SETTINGS_TYPE = {}));
16
+ //# sourceMappingURL=settings-type.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-type.constant.js","sourceRoot":"","sources":["../../src/constants/settings-type.constant.ts"],"names":[],"mappings":";;;AAGA,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,sCAAqB,CAAA;IACrB,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;IAC3B,8BAAa,CAAA;IACb,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAVW,aAAa,6BAAb,aAAa,QAUxB"}
@@ -1 +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"}
1
+ {"version":3,"file":"organization.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/organization.decorator.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,mDAS1B,CAAC;AAWF,eAAO,MAAM,MAAM,mDAGjB,CAAC;AAWH,eAAO,MAAM,mBAAmB,mDAW9B,CAAC"}
@@ -4,7 +4,9 @@ exports.OrganizationContext = exports.UserId = exports.OrganizationId = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  exports.OrganizationId = (0, common_1.createParamDecorator)((data, ctx) => {
6
6
  const request = ctx.switchToHttp().getRequest();
7
- return request.organizationId || request.headers['x-organization-id'];
7
+ return (request.organizationId ||
8
+ request.params.organizationId ||
9
+ request.headers['x-organization-id']);
8
10
  });
9
11
  exports.UserId = (0, common_1.createParamDecorator)((data, ctx) => {
10
12
  const request = ctx.switchToHttp().getRequest();
@@ -13,7 +15,9 @@ exports.UserId = (0, common_1.createParamDecorator)((data, ctx) => {
13
15
  exports.OrganizationContext = (0, common_1.createParamDecorator)((data, ctx) => {
14
16
  const request = ctx.switchToHttp().getRequest();
15
17
  return {
16
- organizationId: request.organizationId || request.headers['x-organization-id'],
18
+ organizationId: request.organizationId ||
19
+ request.params.organizationId ||
20
+ request.headers['x-organization-id'],
17
21
  userId: request.user?.id || request.userId,
18
22
  role: request.organizationRole,
19
23
  user: request.user,
@@ -1 +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"}
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,CACL,OAAO,CAAC,cAAc;QACtB,OAAO,CAAC,MAAM,CAAC,cAAc;QAC7B,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CACrC,CAAC;AACJ,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,EACZ,OAAO,CAAC,cAAc;YACtB,OAAO,CAAC,MAAM,CAAC,cAAc;YAC7B,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACtC,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,19 @@
1
+ import { SETTINGS_TYPE } from '../constants/settings-type.constant';
2
+ import { Organization } from './organization.entity';
3
+ export declare class OrganizationSettings {
4
+ id: string;
5
+ organizationId: string;
6
+ organization: Organization;
7
+ label: string;
8
+ description: string;
9
+ module: string;
10
+ section: string;
11
+ key: string;
12
+ value: string;
13
+ type: SETTINGS_TYPE;
14
+ options: object | null | string;
15
+ sortOrder: number;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }
19
+ //# sourceMappingURL=organization-settings.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.entity.d.ts","sourceRoot":"","sources":["../../src/entities/organization-settings.entity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAarD,qBAEa,oBAAoB;IAG/B,EAAE,EAAE,MAAM,CAAC;IAIX,cAAc,EAAE,MAAM,CAAC;IAIvB,YAAY,EAAE,YAAY,CAAC;IAI3B,KAAK,EAAE,MAAM,CAAC;IAId,WAAW,EAAE,MAAM,CAAC;IAIpB,MAAM,EAAE,MAAM,CAAC;IAIf,OAAO,EAAE,MAAM,CAAC;IAIhB,GAAG,EAAE,MAAM,CAAC;IAIZ,KAAK,EAAE,MAAM,CAAC;IAQd,IAAI,EAAE,aAAa,CAAC;IAMpB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IAGhC,SAAS,EAAE,MAAM,CAAC;IASlB,SAAS,EAAE,IAAI,CAAC;IAShB,SAAS,EAAE,IAAI,CAAC;CACjB"}
@@ -0,0 +1,124 @@
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.OrganizationSettings = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const typeorm_1 = require("typeorm");
16
+ const settings_type_constant_1 = require("../constants/settings-type.constant");
17
+ const organization_entity_1 = require("./organization.entity");
18
+ let OrganizationSettings = class OrganizationSettings {
19
+ id;
20
+ organizationId;
21
+ organization;
22
+ label;
23
+ description;
24
+ module;
25
+ section;
26
+ key;
27
+ value;
28
+ type;
29
+ options;
30
+ sortOrder;
31
+ createdAt;
32
+ updatedAt;
33
+ };
34
+ exports.OrganizationSettings = OrganizationSettings;
35
+ __decorate([
36
+ (0, class_transformer_1.Exclude)(),
37
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
38
+ __metadata("design:type", String)
39
+ ], OrganizationSettings.prototype, "id", void 0);
40
+ __decorate([
41
+ (0, class_validator_1.IsNotEmpty)(),
42
+ (0, typeorm_1.Column)({ type: 'uuid' }),
43
+ __metadata("design:type", String)
44
+ ], OrganizationSettings.prototype, "organizationId", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.ManyToOne)(() => organization_entity_1.Organization, { onDelete: 'CASCADE' }),
47
+ (0, typeorm_1.JoinColumn)({ name: 'organizationId' }),
48
+ __metadata("design:type", organization_entity_1.Organization)
49
+ ], OrganizationSettings.prototype, "organization", void 0);
50
+ __decorate([
51
+ (0, class_validator_1.IsNotEmpty)(),
52
+ (0, typeorm_1.Column)(),
53
+ __metadata("design:type", String)
54
+ ], OrganizationSettings.prototype, "label", void 0);
55
+ __decorate([
56
+ (0, class_validator_1.IsOptional)(),
57
+ (0, typeorm_1.Column)({ nullable: true }),
58
+ __metadata("design:type", String)
59
+ ], OrganizationSettings.prototype, "description", void 0);
60
+ __decorate([
61
+ (0, class_validator_1.IsNotEmpty)(),
62
+ (0, typeorm_1.Column)(),
63
+ __metadata("design:type", String)
64
+ ], OrganizationSettings.prototype, "module", void 0);
65
+ __decorate([
66
+ (0, class_validator_1.IsNotEmpty)(),
67
+ (0, typeorm_1.Column)(),
68
+ __metadata("design:type", String)
69
+ ], OrganizationSettings.prototype, "section", void 0);
70
+ __decorate([
71
+ (0, class_validator_1.IsNotEmpty)(),
72
+ (0, typeorm_1.Column)(),
73
+ __metadata("design:type", String)
74
+ ], OrganizationSettings.prototype, "key", void 0);
75
+ __decorate([
76
+ (0, class_validator_1.IsNotEmpty)(),
77
+ (0, typeorm_1.Column)(),
78
+ __metadata("design:type", String)
79
+ ], OrganizationSettings.prototype, "value", void 0);
80
+ __decorate([
81
+ (0, class_validator_1.IsNotEmpty)(),
82
+ (0, typeorm_1.Column)({
83
+ type: 'enum',
84
+ enum: settings_type_constant_1.SETTINGS_TYPE,
85
+ default: settings_type_constant_1.SETTINGS_TYPE.TEXT,
86
+ }),
87
+ __metadata("design:type", String)
88
+ ], OrganizationSettings.prototype, "type", void 0);
89
+ __decorate([
90
+ (0, class_validator_1.IsOptional)(),
91
+ (0, typeorm_1.Column)('jsonb', {
92
+ nullable: true,
93
+ }),
94
+ __metadata("design:type", Object)
95
+ ], OrganizationSettings.prototype, "options", void 0);
96
+ __decorate([
97
+ (0, typeorm_1.Column)({ default: 0 }),
98
+ __metadata("design:type", Number)
99
+ ], OrganizationSettings.prototype, "sortOrder", void 0);
100
+ __decorate([
101
+ (0, class_transformer_1.Exclude)(),
102
+ (0, typeorm_1.CreateDateColumn)({
103
+ name: 'createdAt',
104
+ nullable: false,
105
+ type: 'timestamptz',
106
+ default: () => 'CURRENT_TIMESTAMP',
107
+ }),
108
+ __metadata("design:type", Date)
109
+ ], OrganizationSettings.prototype, "createdAt", void 0);
110
+ __decorate([
111
+ (0, class_transformer_1.Exclude)(),
112
+ (0, typeorm_1.UpdateDateColumn)({
113
+ name: 'updatedAt',
114
+ nullable: false,
115
+ type: 'timestamptz',
116
+ default: () => 'CURRENT_TIMESTAMP',
117
+ }),
118
+ __metadata("design:type", Date)
119
+ ], OrganizationSettings.prototype, "updatedAt", void 0);
120
+ exports.OrganizationSettings = OrganizationSettings = __decorate([
121
+ (0, typeorm_1.Entity)('organization_settings'),
122
+ (0, typeorm_1.Index)(['organizationId', 'module', 'section', 'key'], { unique: true })
123
+ ], OrganizationSettings);
124
+ //# sourceMappingURL=organization-settings.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.entity.js","sourceRoot":"","sources":["../../src/entities/organization-settings.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA4C;AAC5C,qDAAyD;AACzD,qCASiB;AAEjB,gFAAoE;AACpE,+DAAqD;AAe9C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG/B,EAAE,CAAS;IAIX,cAAc,CAAS;IAIvB,YAAY,CAAe;IAI3B,KAAK,CAAS;IAId,WAAW,CAAS;IAIpB,MAAM,CAAS;IAIf,OAAO,CAAS;IAIhB,GAAG,CAAS;IAIZ,KAAK,CAAS;IAQd,IAAI,CAAgB;IAMpB,OAAO,CAAyB;IAGhC,SAAS,CAAS;IASlB,SAAS,CAAO;IAShB,SAAS,CAAO;CACjB,CAAA;AAvEY,oDAAoB;AAG/B;IAFC,IAAA,2BAAO,GAAE;IACT,IAAA,gCAAsB,EAAC,MAAM,CAAC;;gDACpB;AAIX;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DACF;AAIvB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kCAAY,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtD,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;8BACzB,kCAAY;0DAAC;AAI3B;IAFC,IAAA,4BAAU,G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,EAAC,CAAC,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GAC3D,oBAAoB,CAuEhC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  export * from './constants/organization.constant';
2
2
  export * from './constants/organization.settings.constant';
3
+ export * from './constants/settings-type.constant';
3
4
  export * from './decorators/organization.decorator';
4
5
  export * from './decorators/roles.decorator';
5
6
  export * from './entities/organization.entity';
7
+ export * from './entities/organization-settings.entity';
6
8
  export * from './entities/organization-user.entity';
7
9
  export * from './guards/organization.guard';
8
10
  export * from './organization.module';
9
11
  export * from './services/organization.service';
12
+ export * from './services/organization-settings.service';
10
13
  export * from './services/organization-user.service';
11
14
  export * from './settings/organization.settings';
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -16,13 +16,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants/organization.constant"), exports);
18
18
  __exportStar(require("./constants/organization.settings.constant"), exports);
19
+ __exportStar(require("./constants/settings-type.constant"), exports);
19
20
  __exportStar(require("./decorators/organization.decorator"), exports);
20
21
  __exportStar(require("./decorators/roles.decorator"), exports);
21
22
  __exportStar(require("./entities/organization.entity"), exports);
23
+ __exportStar(require("./entities/organization-settings.entity"), exports);
22
24
  __exportStar(require("./entities/organization-user.entity"), exports);
23
25
  __exportStar(require("./guards/organization.guard"), exports);
24
26
  __exportStar(require("./organization.module"), exports);
25
27
  __exportStar(require("./services/organization.service"), exports);
28
+ __exportStar(require("./services/organization-settings.service"), exports);
26
29
  __exportStar(require("./services/organization-user.service"), exports);
27
30
  __exportStar(require("./settings/organization.settings"), exports);
28
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,6EAA2D;AAC3D,qEAAmD;AACnD,sEAAoD;AACpD,+DAA6C;AAC7C,iEAA+C;AAC/C,0EAAwD;AACxD,sEAAoD;AACpD,8DAA4C;AAC5C,wDAAsC;AACtC,kEAAgD;AAChD,2EAAyD;AACzD,uEAAqD;AACrD,mEAAiD"}
@@ -1 +1 @@
1
- {"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":"AASA,qBAMa,kBAAkB;CAAG"}
1
+ {"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":"AAWA,qBASa,kBAAkB;CAAG"}
@@ -11,18 +11,23 @@ const common_1 = require("@nestjs/common");
11
11
  const typeorm_1 = require("@nestjs/typeorm");
12
12
  const core_1 = require("@venturialstd/core");
13
13
  const organization_entity_1 = require("./entities/organization.entity");
14
+ const organization_settings_entity_1 = require("./entities/organization-settings.entity");
14
15
  const organization_user_entity_1 = require("./entities/organization-user.entity");
15
16
  const organization_service_1 = require("./services/organization.service");
17
+ const organization_settings_service_1 = require("./services/organization-settings.service");
16
18
  const organization_user_service_1 = require("./services/organization-user.service");
17
19
  let OrganizationModule = class OrganizationModule {
18
20
  };
19
21
  exports.OrganizationModule = OrganizationModule;
20
22
  exports.OrganizationModule = OrganizationModule = __decorate([
21
23
  (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
+ imports: [
25
+ core_1.SharedModule.forRoot({}),
26
+ typeorm_1.TypeOrmModule.forFeature([organization_entity_1.Organization, organization_user_entity_1.OrganizationUser, organization_settings_entity_1.OrganizationSettings]),
27
+ ],
28
+ providers: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService, organization_settings_service_1.OrganizationSettingsService],
24
29
  controllers: [],
25
- exports: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService],
30
+ exports: [organization_service_1.OrganizationService, organization_user_service_1.OrganizationUserService, organization_settings_service_1.OrganizationSettingsService],
26
31
  })
27
32
  ], OrganizationModule);
28
33
  //# sourceMappingURL=organization.module.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6CAAkD;AAElD,wEAA8D;AAC9D,0FAA+E;AAC/E,kFAAuE;AACvE,0EAAsE;AACtE,4FAAuF;AACvF,oFAA+E;AAWxE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAT9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,mBAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,uBAAa,CAAC,UAAU,CAAC,CAAC,kCAAY,EAAE,2CAAgB,EAAE,mDAAoB,CAAC,CAAC;SACjF;QACD,SAAS,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,EAAE,2DAA2B,CAAC;QACtF,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,CAAC,0CAAmB,EAAE,mDAAuB,EAAE,2DAA2B,CAAC;KACrF,CAAC;GACW,kBAAkB,CAAG"}
@@ -0,0 +1,15 @@
1
+ import { TypeOrmCrudService } from '@dataui/crud-typeorm';
2
+ import { DeepPartial, Repository } from 'typeorm';
3
+ import { OrganizationSettings } from '../entities/organization-settings.entity';
4
+ export declare class OrganizationSettingsService extends TypeOrmCrudService<OrganizationSettings> {
5
+ private readonly organizationSettingsRepo;
6
+ constructor(organizationSettingsRepo: Repository<OrganizationSettings>);
7
+ get(organizationId: string, key: string): Promise<string | undefined>;
8
+ getManySettings(organizationId: string, keys: string[]): Promise<Record<string, string>>;
9
+ getAllForOrganization(organizationId: string, module?: string): Promise<OrganizationSettings[]>;
10
+ setOrganizationSetting(organizationId: string, dto: DeepPartial<OrganizationSettings>): Promise<OrganizationSettings>;
11
+ deleteOrganizationSetting(organizationId: string, module: string, section: string, key: string): Promise<void>;
12
+ resetModuleSettings(organizationId: string, module: string): Promise<void>;
13
+ bulkUpdateSettings(organizationId: string, settings: DeepPartial<OrganizationSettings>[]): Promise<OrganizationSettings[]>;
14
+ }
15
+ //# sourceMappingURL=organization-settings.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-settings.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAOhF,qBACa,2BAA4B,SAAQ,kBAAkB,CAAC,oBAAoB,CAAC;IAGrF,OAAO,CAAC,QAAQ,CAAC,wBAAwB;gBAAxB,wBAAwB,EAAE,UAAU,CAAC,oBAAoB,CAAC;IAWvE,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA0BrE,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAiBxF,qBAAqB,CACzB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAoB5B,sBAAsB,CAC1B,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,WAAW,CAAC,oBAAoB,CAAC,GACrC,OAAO,CAAC,oBAAoB,CAAC;IAiC1B,yBAAyB,CAC7B,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC;IAcV,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E,kBAAkB,CACtB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,WAAW,CAAC,oBAAoB,CAAC,EAAE,GAC5C,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAUnC"}
@@ -0,0 +1,114 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.OrganizationSettingsService = void 0;
16
+ const crud_typeorm_1 = require("@dataui/crud-typeorm");
17
+ const common_1 = require("@nestjs/common");
18
+ const typeorm_1 = require("@nestjs/typeorm");
19
+ const typeorm_2 = require("typeorm");
20
+ const organization_settings_entity_1 = require("../entities/organization-settings.entity");
21
+ let OrganizationSettingsService = class OrganizationSettingsService extends crud_typeorm_1.TypeOrmCrudService {
22
+ organizationSettingsRepo;
23
+ constructor(organizationSettingsRepo) {
24
+ super(organizationSettingsRepo);
25
+ this.organizationSettingsRepo = organizationSettingsRepo;
26
+ }
27
+ async get(organizationId, key) {
28
+ const keyParts = key.split(':');
29
+ if (keyParts.length !== 3) {
30
+ throw new Error('Invalid key format. Expected format: module:section:key');
31
+ }
32
+ const [module, section, configKey] = keyParts;
33
+ const orgSetting = await this.organizationSettingsRepo.findOne({
34
+ where: {
35
+ organizationId,
36
+ module,
37
+ section,
38
+ key: configKey,
39
+ },
40
+ });
41
+ return orgSetting?.value;
42
+ }
43
+ async getManySettings(organizationId, keys) {
44
+ const results = {};
45
+ for (const key of keys) {
46
+ const value = await this.get(organizationId, key);
47
+ if (value !== undefined) {
48
+ results[key] = value;
49
+ }
50
+ }
51
+ return results;
52
+ }
53
+ async getAllForOrganization(organizationId, module) {
54
+ const whereClause = { organizationId };
55
+ if (module) {
56
+ whereClause.module = module;
57
+ }
58
+ const orgSettings = await this.organizationSettingsRepo.find({
59
+ where: whereClause,
60
+ order: { sortOrder: 'ASC' },
61
+ });
62
+ return orgSettings;
63
+ }
64
+ async setOrganizationSetting(organizationId, dto) {
65
+ const existingSetting = await this.organizationSettingsRepo.findOne({
66
+ where: {
67
+ organizationId,
68
+ module: dto.module,
69
+ section: dto.section,
70
+ key: dto.key,
71
+ },
72
+ });
73
+ if (existingSetting) {
74
+ return this.organizationSettingsRepo.save({
75
+ ...existingSetting,
76
+ ...dto,
77
+ organizationId,
78
+ });
79
+ }
80
+ return this.organizationSettingsRepo.save({
81
+ ...dto,
82
+ organizationId,
83
+ });
84
+ }
85
+ async deleteOrganizationSetting(organizationId, module, section, key) {
86
+ await this.organizationSettingsRepo.delete({
87
+ organizationId,
88
+ module,
89
+ section,
90
+ key,
91
+ });
92
+ }
93
+ async resetModuleSettings(organizationId, module) {
94
+ await this.organizationSettingsRepo.delete({
95
+ organizationId,
96
+ module,
97
+ });
98
+ }
99
+ async bulkUpdateSettings(organizationId, settings) {
100
+ const results = [];
101
+ for (const setting of settings) {
102
+ const result = await this.setOrganizationSetting(organizationId, setting);
103
+ results.push(result);
104
+ }
105
+ return results;
106
+ }
107
+ };
108
+ exports.OrganizationSettingsService = OrganizationSettingsService;
109
+ exports.OrganizationSettingsService = OrganizationSettingsService = __decorate([
110
+ (0, common_1.Injectable)(),
111
+ __param(0, (0, typeorm_1.InjectRepository)(organization_settings_entity_1.OrganizationSettings)),
112
+ __metadata("design:paramtypes", [typeorm_2.Repository])
113
+ ], OrganizationSettingsService);
114
+ //# sourceMappingURL=organization-settings.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.service.js","sourceRoot":"","sources":["../../src/services/organization-settings.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA0D;AAC1D,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAkD;AAElD,2FAAgF;AAQzE,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,iCAAwC;IAGpE;IAFnB,YAEmB,wBAA0D;QAE3E,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAFf,6BAAwB,GAAxB,wBAAwB,CAAkC;IAG7E,CAAC;IAQD,KAAK,CAAC,GAAG,CAAC,cAAsB,EAAE,GAAW;QAC3C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,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AU;GAH5C,2BAA2B,CAgKvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venturialstd/organization",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Organization Management Module for Venturial",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",