@venturialstd/organization 0.0.14 → 0.0.15
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/entities/organization-user.entity.d.ts.map +1 -1
- package/dist/entities/organization-user.entity.js +0 -2
- package/dist/entities/organization-user.entity.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/organization.module.d.ts.map +1 -1
- package/dist/organization.module.js +2 -6
- package/dist/organization.module.js.map +1 -1
- package/dist/services/organization-settings-encryption.service.d.ts +1 -1
- package/dist/services/organization-settings-encryption.service.d.ts.map +1 -1
- package/dist/services/organization-settings-encryption.service.js +20 -20
- package/dist/services/organization-settings-encryption.service.js.map +1 -1
- package/dist/services/organization-settings.service.d.ts +4 -4
- package/dist/services/organization-settings.service.d.ts.map +1 -1
- package/dist/services/organization-settings.service.js +4 -4
- package/dist/services/organization-settings.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-user.entity.d.ts","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,qBAEa,gBAAgB;IAE3B,EAAE,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"organization-user.entity.d.ts","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,qBAEa,gBAAgB;IAE3B,EAAE,EAAE,MAAM,CAAC;IAKX,cAAc,EAAE,MAAM,CAAC;IAIvB,YAAY,EAAE,YAAY,CAAC;IAK3B,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"}
|
|
@@ -38,7 +38,6 @@ __decorate([
|
|
|
38
38
|
(0, class_validator_1.IsString)(),
|
|
39
39
|
(0, class_validator_1.IsNotEmpty)(),
|
|
40
40
|
(0, typeorm_1.Column)({ type: 'uuid' }),
|
|
41
|
-
(0, typeorm_1.Index)(),
|
|
42
41
|
__metadata("design:type", String)
|
|
43
42
|
], OrganizationUser.prototype, "organizationId", void 0);
|
|
44
43
|
__decorate([
|
|
@@ -50,7 +49,6 @@ __decorate([
|
|
|
50
49
|
(0, class_validator_1.IsString)(),
|
|
51
50
|
(0, class_validator_1.IsNotEmpty)(),
|
|
52
51
|
(0, typeorm_1.Column)({ type: 'uuid' }),
|
|
53
|
-
(0, typeorm_1.Index)(),
|
|
54
52
|
__metadata("design:type", String)
|
|
55
53
|
], OrganizationUser.prototype, "userId", void 0);
|
|
56
54
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-user.entity.js","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8E;AAC9E,qCASiB;AAEjB,8EAG4C;AAC5C,+DAAqD;AAI9C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,EAAE,CAAS;
|
|
1
|
+
{"version":3,"file":"organization-user.entity.js","sourceRoot":"","sources":["../../src/entities/organization-user.entity.ts"],"names":[],"mapp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,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACzC,gBAAgB,CA2E5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
1
|
+
export * from './constants/organization.constant';
|
|
2
|
+
export * from './constants/organization.settings.constant';
|
|
3
|
+
export * from './constants/settings-type.constant';
|
|
4
|
+
export * from './decorators/organization.decorator';
|
|
5
|
+
export * from './decorators/roles.decorator';
|
|
6
|
+
export * from './dtos/CreateOrganization.dto';
|
|
7
|
+
export * from './entities/organization.entity';
|
|
8
|
+
export * from './entities/organization-settings.entity';
|
|
9
|
+
export * from './entities/organization-user.entity';
|
|
10
|
+
export * from './guards/organization.guard';
|
|
11
|
+
export * from './organization.module';
|
|
12
|
+
export * from './services/organization.service';
|
|
13
|
+
export * from './services/organization-settings.service';
|
|
14
|
+
export * from './services/organization-settings-encryption.service';
|
|
15
|
+
export * from './services/organization-user.service';
|
|
16
|
+
export * from './settings/organization.settings';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,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,
|
|
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,+BAA+B,CAAC;AAC9C,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,qDAAqD,CAAC;AACpE,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __exportStar(require("./guards/organization.guard"), exports);
|
|
|
27
27
|
__exportStar(require("./organization.module"), exports);
|
|
28
28
|
__exportStar(require("./services/organization.service"), exports);
|
|
29
29
|
__exportStar(require("./services/organization-settings.service"), exports);
|
|
30
|
-
__exportStar(require("./services/organization-user.service"), exports);
|
|
31
30
|
__exportStar(require("./services/organization-settings-encryption.service"), exports);
|
|
31
|
+
__exportStar(require("./services/organization-user.service"), exports);
|
|
32
32
|
__exportStar(require("./settings/organization.settings"), exports);
|
|
33
33
|
//# 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,qEAAmD;AACnD,sEAAoD;AACpD,+DAA6C;AAC7C,gEAA8C;AAC9C,iEAA+C;AAC/C,0EAAwD;AACxD,sEAAoD;AACpD,8DAA4C;AAC5C,wDAAsC;AACtC,kEAAgD;AAChD,2EAAyD;AACzD,uEAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,6EAA2D;AAC3D,qEAAmD;AACnD,sEAAoD;AACpD,+DAA6C;AAC7C,gEAA8C;AAC9C,iEAA+C;AAC/C,0EAAwD;AACxD,sEAAoD;AACpD,8DAA4C;AAC5C,wDAAsC;AACtC,kEAAgD;AAChD,2EAAyD;AACzD,sFAAoE;AACpE,uEAAqD;AACrD,mEAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":"AAYA,
|
|
1
|
+
{"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../src/organization.module.ts"],"names":[],"mappings":"AAYA,qBAkBa,kBAAkB;CAAG"}
|
|
@@ -15,8 +15,8 @@ const organization_settings_entity_1 = require("./entities/organization-settings
|
|
|
15
15
|
const organization_user_entity_1 = require("./entities/organization-user.entity");
|
|
16
16
|
const organization_service_1 = require("./services/organization.service");
|
|
17
17
|
const organization_settings_service_1 = require("./services/organization-settings.service");
|
|
18
|
-
const organization_user_service_1 = require("./services/organization-user.service");
|
|
19
18
|
const organization_settings_encryption_service_1 = require("./services/organization-settings-encryption.service");
|
|
19
|
+
const organization_user_service_1 = require("./services/organization-user.service");
|
|
20
20
|
let OrganizationModule = class OrganizationModule {
|
|
21
21
|
};
|
|
22
22
|
exports.OrganizationModule = OrganizationModule;
|
|
@@ -24,11 +24,7 @@ exports.OrganizationModule = OrganizationModule = __decorate([
|
|
|
24
24
|
(0, common_1.Module)({
|
|
25
25
|
imports: [
|
|
26
26
|
core_1.SharedModule.forRoot({}),
|
|
27
|
-
typeorm_1.TypeOrmModule.forFeature([
|
|
28
|
-
organization_entity_1.Organization,
|
|
29
|
-
organization_user_entity_1.OrganizationUser,
|
|
30
|
-
organization_settings_entity_1.OrganizationSettings,
|
|
31
|
-
]),
|
|
27
|
+
typeorm_1.TypeOrmModule.forFeature([organization_entity_1.Organization, organization_user_entity_1.OrganizationUser, organization_settings_entity_1.OrganizationSettings]),
|
|
32
28
|
],
|
|
33
29
|
providers: [
|
|
34
30
|
organization_service_1.OrganizationService,
|
|
@@ -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,0FAA+E;AAC/E,kFAAuE;AACvE,0EAAsE;AACtE,4FAAuF;AACvF,oFAA+E;
|
|
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,kHAA4G;AAC5G,oFAA+E;AAoBxE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAlB9B,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;YACT,0CAAmB;YACnB,mDAAuB;YACvB,2DAA2B;YAC3B,gFAAqC;SACtC;QACD,OAAO,EAAE;YACP,0CAAmB;YACnB,mDAAuB;YACvB,2DAA2B;YAC3B,gFAAqC;SACtC;KACF,CAAC;GACW,kBAAkB,CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-settings-encryption.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-settings-encryption.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"organization-settings-encryption.service.d.ts","sourceRoot":"","sources":["../../src/services/organization-settings-encryption.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,qBACa,qCAAqC;IAMpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IALnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAM;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAEV,MAAM,EAAE,SAAS;IAyB9C,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAkBlC,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IA2BtC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAQpC"}
|
|
@@ -44,9 +44,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.OrganizationSettingsEncryptionService = void 0;
|
|
46
46
|
const common_1 = require("@nestjs/common");
|
|
47
|
+
const core_1 = require("@venturialstd/core");
|
|
47
48
|
const crypto = __importStar(require("crypto"));
|
|
48
49
|
const settings_encryption_constants_1 = require("../constants/settings-encryption.constants");
|
|
49
|
-
const core_1 = require("@venturialstd/core");
|
|
50
50
|
let OrganizationSettingsEncryptionService = class OrganizationSettingsEncryptionService {
|
|
51
51
|
logger;
|
|
52
52
|
algorithm = settings_encryption_constants_1.ENCRYPTION_ALGORITHM.AES256;
|
|
@@ -59,14 +59,14 @@ let OrganizationSettingsEncryptionService = class OrganizationSettingsEncryption
|
|
|
59
59
|
const salt = process.env.SETTINGS_ENCRYPTION_SALT;
|
|
60
60
|
const MIN_KEY_LENGTH = 16;
|
|
61
61
|
if (!secret || !salt) {
|
|
62
|
-
this.logger.error(
|
|
63
|
-
throw new Error(
|
|
62
|
+
this.logger.error('ENCRYPTION KEY or SALT is not defined in environment variables');
|
|
63
|
+
throw new Error('ENCRYPTION KEY or SALT is required in environment variables');
|
|
64
64
|
}
|
|
65
65
|
if (Buffer.from(secret).length < MIN_KEY_LENGTH) {
|
|
66
|
-
this.logger.warn(
|
|
66
|
+
this.logger.warn('SETTINGS_ENCRYPTION_KEY is too short; consider using at least 16 characters');
|
|
67
67
|
}
|
|
68
68
|
if (Buffer.from(salt).length < MIN_KEY_LENGTH) {
|
|
69
|
-
this.logger.warn(
|
|
69
|
+
this.logger.warn('SETTINGS_ENCRYPTION_SALT is too short; consider using at least 16 characters');
|
|
70
70
|
}
|
|
71
71
|
this.encryptionKey = crypto.scryptSync(secret, salt, this.keyLength);
|
|
72
72
|
}
|
|
@@ -74,43 +74,43 @@ let OrganizationSettingsEncryptionService = class OrganizationSettingsEncryption
|
|
|
74
74
|
try {
|
|
75
75
|
const initVector = crypto.randomBytes(this.ivLength);
|
|
76
76
|
const cipher = crypto.createCipheriv(this.algorithm, this.encryptionKey, initVector);
|
|
77
|
-
let encrypted = cipher.update(plainText,
|
|
78
|
-
encrypted += cipher.final(
|
|
77
|
+
let encrypted = cipher.update(plainText, 'utf8', 'hex');
|
|
78
|
+
encrypted += cipher.final('hex');
|
|
79
79
|
const authTag = cipher.getAuthTag();
|
|
80
|
-
return `${initVector.toString(
|
|
80
|
+
return `${initVector.toString('hex')}:${encrypted}:${authTag.toString('hex')}`;
|
|
81
81
|
}
|
|
82
82
|
catch (error) {
|
|
83
|
-
this.logger.error(
|
|
83
|
+
this.logger.error('Encryption failed:', error);
|
|
84
84
|
throw error;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
decrypt(encryptedText) {
|
|
88
88
|
try {
|
|
89
|
-
const parts = encryptedText.split(
|
|
89
|
+
const parts = encryptedText.split(':');
|
|
90
90
|
if (parts.length !== 3) {
|
|
91
|
-
throw new Error(
|
|
91
|
+
throw new Error('Invalid encrypted text format');
|
|
92
92
|
}
|
|
93
93
|
const [ivHex, encryptedHex, authTagHex] = parts;
|
|
94
|
-
const iv = Buffer.from(ivHex,
|
|
95
|
-
const encrypted = Buffer.from(encryptedHex,
|
|
96
|
-
const authTag = Buffer.from(authTagHex,
|
|
94
|
+
const iv = Buffer.from(ivHex, 'hex');
|
|
95
|
+
const encrypted = Buffer.from(encryptedHex, 'hex');
|
|
96
|
+
const authTag = Buffer.from(authTagHex, 'hex');
|
|
97
97
|
const decipher = crypto.createDecipheriv(this.algorithm, this.encryptionKey, iv);
|
|
98
98
|
decipher.setAuthTag(authTag);
|
|
99
|
-
let decrypted = decipher.update(encrypted, undefined,
|
|
100
|
-
decrypted += decipher.final(
|
|
99
|
+
let decrypted = decipher.update(encrypted, undefined, 'utf8');
|
|
100
|
+
decrypted += decipher.final('utf8');
|
|
101
101
|
return decrypted;
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
|
-
this.logger.error(
|
|
104
|
+
this.logger.error('Descryption failed:', error);
|
|
105
105
|
throw error;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
isEncrypted(value) {
|
|
109
|
-
if (!value || typeof value !==
|
|
109
|
+
if (!value || typeof value !== 'string') {
|
|
110
110
|
return false;
|
|
111
111
|
}
|
|
112
|
-
const parts = value.split(
|
|
113
|
-
return
|
|
112
|
+
const parts = value.split(':');
|
|
113
|
+
return parts.length === 3 && parts.every((part) => /^[0-9a-f]+$/i.test(part));
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
exports.OrganizationSettingsEncryptionService = OrganizationSettingsEncryptionService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-settings-encryption.service.js","sourceRoot":"","sources":["../../src/services/organization-settings-encryption.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAiC;
|
|
1
|
+
{"version":3,"file":"organization-settings-encryption.service.js","sourceRoot":"","sources":["../../src/services/organization-settings-encryption.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAA+C;AAC/C,+CAAiC;AAEjC,8FAAkF;AAG3E,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAMnB;IALZ,SAAS,GAAG,oDAAoB,CAAC,MAAM,CAAC;IACxC,SAAS,GAAG,EAAE,CAAC;IACf,QAAQ,GAAG,EAAE,CAAC;IACd,aAAa,CAAS;IAEvC,YAA6B,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;QACnD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;QAClD,MAAM,cAAc,GAAG,EAAE,CAAC;QAE1B,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;YACpF,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,8EAA8E,CAC/E,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,MAAM,CA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,YAAY,EAAE,KAAK,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAE/C,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YACjF,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAE7B,IAAI,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAC9D,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEpC,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAc,CAAC,CAAC;YACzD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChF,CAAC;CACF,CAAA;AApFY,sFAAqC;gDAArC,qCAAqC;IADjD,IAAA,mBAAU,GAAE;qCAO0B,gBAAS;GANnC,qCAAqC,CAoFjD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TypeOrmCrudService } from
|
|
2
|
-
import { DeepPartial, Repository } from
|
|
3
|
-
import { OrganizationSettings } from
|
|
4
|
-
import { OrganizationSettingsEncryptionService } from
|
|
1
|
+
import { TypeOrmCrudService } from '@dataui/crud-typeorm';
|
|
2
|
+
import { DeepPartial, Repository } from 'typeorm';
|
|
3
|
+
import { OrganizationSettings } from '../entities/organization-settings.entity';
|
|
4
|
+
import { OrganizationSettingsEncryptionService } from './organization-settings-encryption.service';
|
|
5
5
|
export declare class OrganizationSettingsService extends TypeOrmCrudService<OrganizationSettings> {
|
|
6
6
|
private readonly organizationSettingsRepo;
|
|
7
7
|
private readonly settingsEncryptionService;
|
|
@@ -1 +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;
|
|
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;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AAOnG,qBACa,2BAA4B,SAAQ,kBAAkB,CAAC,oBAAoB,CAAC;IAGrF,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IACzC,OAAO,CAAC,QAAQ,CAAC,yBAAyB;gBADzB,wBAAwB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAC1D,yBAAyB,EAAE,qCAAqC;IAW7E,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAiCrE,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;IAsB5B,sBAAsB,CAC1B,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,WAAW,CAAC,oBAAoB,CAAC,GACrC,OAAO,CAAC,oBAAoB,CAAC;IAwC1B,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"}
|
|
@@ -17,8 +17,8 @@ const crud_typeorm_1 = require("@dataui/crud-typeorm");
|
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
19
19
|
const typeorm_2 = require("typeorm");
|
|
20
|
-
const organization_settings_entity_1 = require("../entities/organization-settings.entity");
|
|
21
20
|
const settings_type_constant_1 = require("../constants/settings-type.constant");
|
|
21
|
+
const organization_settings_entity_1 = require("../entities/organization-settings.entity");
|
|
22
22
|
const organization_settings_encryption_service_1 = require("./organization-settings-encryption.service");
|
|
23
23
|
let OrganizationSettingsService = class OrganizationSettingsService extends crud_typeorm_1.TypeOrmCrudService {
|
|
24
24
|
organizationSettingsRepo;
|
|
@@ -29,9 +29,9 @@ let OrganizationSettingsService = class OrganizationSettingsService extends crud
|
|
|
29
29
|
this.settingsEncryptionService = settingsEncryptionService;
|
|
30
30
|
}
|
|
31
31
|
async get(organizationId, key) {
|
|
32
|
-
const keyParts = key.split(
|
|
32
|
+
const keyParts = key.split(':');
|
|
33
33
|
if (keyParts.length !== 3) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error('Invalid key format. Expected format: module:section:key');
|
|
35
35
|
}
|
|
36
36
|
const [module, section, configKey] = keyParts;
|
|
37
37
|
const orgSetting = await this.organizationSettingsRepo.findOne({
|
|
@@ -67,7 +67,7 @@ let OrganizationSettingsService = class OrganizationSettingsService extends crud
|
|
|
67
67
|
}
|
|
68
68
|
const orgSettings = await this.organizationSettingsRepo.find({
|
|
69
69
|
where: whereClause,
|
|
70
|
-
order: { sortOrder:
|
|
70
|
+
order: { sortOrder: 'ASC' },
|
|
71
71
|
});
|
|
72
72
|
return orgSettings;
|
|
73
73
|
}
|
|
@@ -1 +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;AAChF,
|
|
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,gFAAoE;AACpE,2FAAgF;AAChF,yGAAmG;AAQ5F,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,iCAAwC;IAGpE;IACA;IAHnB,YAEmB,wBAA0D,EAC1D,yBAAgE;QAEjF,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAHf,6BAAwB,GAAxB,wBAAwB,CAAkC;QAC1D,8BAAyB,GAAzB,yBAAyB,CAAuC;IAGnF,CAAC;IAQD,KAAK,CAAC,GAAG,CAAC,cAAsB,EAAE,GAAW;QAC3C,MAAM,QAAQ,GAAG,GAAG,CA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