@solidxai/core 0.1.8-beta.10 → 0.1.8-beta.11
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 +197 -0
- package/dist/entities/setting.entity.d.ts +1 -0
- package/dist/entities/setting.entity.d.ts.map +1 -1
- package/dist/entities/setting.entity.js +5 -1
- package/dist/entities/setting.entity.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +12 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.d.ts +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.d.ts.map +1 -1
- package/dist/jobs/database/chatter-queue-publisher-database.service.js.map +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.d.ts +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/chatter-queue-subscriber-database.service.js.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.d.ts +1 -12
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.d.ts.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-publisher.service.js.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.d.ts +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.d.ts.map +1 -1
- package/dist/jobs/rabbitmq/chatter-queue-subscriber.service.js.map +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.d.ts +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.d.ts.map +1 -1
- package/dist/jobs/redis/chatter-queue-subscriber-redis.service.js.map +1 -1
- package/dist/services/encryption.service.d.ts +8 -0
- package/dist/services/encryption.service.d.ts.map +1 -0
- package/dist/services/encryption.service.js +75 -0
- package/dist/services/encryption.service.js.map +1 -0
- package/dist/services/setting.service.d.ts +1 -0
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +35 -7
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +12 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +4 -3
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/subscribers/audit.subscriber.d.ts +1 -1
- package/dist/subscribers/audit.subscriber.d.ts.map +1 -1
- package/dist/subscribers/audit.subscriber.js.map +1 -1
- package/package.json +1 -1
- package/src/entities/setting.entity.ts +3 -0
- package/src/index.ts +1 -0
- package/src/interfaces.ts +16 -0
- package/src/jobs/database/chatter-queue-publisher-database.service.ts +1 -1
- package/src/jobs/database/chatter-queue-subscriber-database.service.ts +1 -1
- package/src/jobs/rabbitmq/chatter-queue-publisher.service.ts +1 -15
- package/src/jobs/rabbitmq/chatter-queue-subscriber.service.ts +1 -1
- package/src/jobs/redis/chatter-queue-subscriber-redis.service.ts +1 -1
- package/src/services/encryption.service.ts +43 -0
- package/src/services/setting.service.ts +38 -9
- package/src/services/settings/default-settings-provider.service.ts +4 -3
- package/src/subscribers/audit.subscriber.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-publisher-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-publisher-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iGAAmF;AACnF,sFAAgF;AAChF,0EAAqE;AAGrE,sGAA2E;AAGpE,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,8CAAoC;IACnF,YACuB,gBAAkC,EAClC,qBAA4C;QAE/D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAH5B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGnE,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,wCAA2B;SACjC,CAAC;IACN,CAAC;CACJ,CAAA;AAbY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAGgC,qCAAgB;QACX,gDAAqB;GAH1D,6BAA6B,CAazC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport { DatabasePublisher } from 'src/services/queues/database-publisher.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { AuditQueuePayload } from '
|
|
1
|
+
{"version":3,"file":"chatter-queue-publisher-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-publisher-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iGAAmF;AACnF,sFAAgF;AAChF,0EAAqE;AAGrE,sGAA2E;AAGpE,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,8CAAoC;IACnF,YACuB,gBAAkC,EAClC,qBAA4C;QAE/D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAH5B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGnE,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,wCAA2B;SACjC,CAAC;IACN,CAAC;CACJ,CAAA;AAbY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAGgC,qCAAgB;QACX,gDAAqB;GAH1D,6BAA6B,CAazC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport { DatabasePublisher } from 'src/services/queues/database-publisher.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { AuditQueuePayload } from '../../interfaces';\nimport chatterQueueOptionsDatabase from './chatter-queue-options-database';\n\n@Injectable()\nexport class ChatterQueuePublisherDatabase extends DatabasePublisher<AuditQueuePayload> {\n constructor(\n protected readonly mqMessageService: MqMessageService,\n protected readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...chatterQueueOptionsDatabase\n };\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { MqMessageService } from '../../services/mq-message.service';
|
|
|
4
4
|
import { MqMessageQueueService } from '../../services/mq-message-queue.service';
|
|
5
5
|
import { QueuesModuleOptions } from "../../interfaces";
|
|
6
6
|
import { PollerService } from 'src/services/poller.service';
|
|
7
|
-
import { AuditQueuePayload } from '
|
|
7
|
+
import { AuditQueuePayload } from '../../interfaces';
|
|
8
8
|
import { ChatterMessageService } from 'src/services/chatter-message.service';
|
|
9
9
|
export declare class ChatterQueueSubscriberDatabase extends DatabaseSubscriber<AuditQueuePayload> {
|
|
10
10
|
readonly mqMessageService: MqMessageService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber-database.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-subscriber-database.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber-database.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-subscriber-database.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,qBACa,8BAA+B,SAAQ,kBAAkB,CAAC,iBAAiB,CAAC;IAIjF,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IACrD,QAAQ,CAAC,MAAM,EAAE,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAN1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmD;gBAGpE,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB,EAC5C,MAAM,EAAE,aAAa,EACb,qBAAqB,EAAE,qBAAqB;IAKjE,OAAO,IAAI,mBAAmB;IAMxB,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC;CAqB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-subscriber-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,mGAAqF;AAErF,0EAAqE;AACrE,sFAAgF;AAEhF,kEAA4D;AAE5D,oFAA6E;AAC7E,sGAA2E;AAGpE,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,gDAAqC;IAGrF,YACa,gBA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F,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAvCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACpC,8BAAa;QACU,+CAAqB;GAPxD,8BAA8B,CAuC1C","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { PollerService } from 'src/services/poller.service';\nimport { AuditQueuePayload } from '
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/chatter-queue-subscriber-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,mGAAqF;AAErF,0EAAqE;AACrE,sFAAgF;AAEhF,kEAA4D;AAE5D,oFAA6E;AAC7E,sGAA2E;AAGpE,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,gDAAqC;IAGrF,YACa,gBAAkC,EAClC,qBAA4C,EAC5C,MAAqB,EACb,qBAA4C;QAE7D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAL9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,WAAM,GAAN,MAAM,CAAe;QACb,0BAAqB,GAArB,qBAAqB,CAAuB;QANhD,kBAAa,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IASjF,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,wCAA2B;SACjC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAwC;QACpD,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpF,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;gBAChF,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CACrD,CAAC,CAAC,KAAK,EACP,CAAC,CAAC,SAAS,EACX,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAC/D,CAAC;gBACF,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;gBACjF,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAvCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACpC,8BAAa;QACU,+CAAqB;GAPxD,8BAA8B,CAuC1C","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { PollerService } from 'src/services/poller.service';\nimport { AuditQueuePayload } from '../../interfaces';\nimport { ChatterMessageService } from 'src/services/chatter-message.service';\nimport chatterQueueOptionsDatabase from './chatter-queue-options-database';\n\n@Injectable()\nexport class ChatterQueueSubscriberDatabase extends DatabaseSubscriber<AuditQueuePayload> {\n private readonly chatterLogger = new Logger(ChatterQueueSubscriberDatabase.name);\n\n constructor(\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n readonly poller: PollerService,\n private readonly chatterMessageService: ChatterMessageService,\n ) {\n super(mqMessageService, mqMessageQueueService, poller);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...chatterQueueOptionsDatabase\n };\n }\n\n async subscribe(message: QueueMessage<AuditQueuePayload>) {\n const p = message.payload;\n this.chatterLogger.debug(`Audit event ${p.eventType} ${p.modelName}#${p.entityId}`);\n\n switch (p.eventType) {\n case 'insert':\n await this.chatterMessageService.postAuditMessageOnInsert(p.after, p.modelName);\n break;\n case 'update':\n await this.chatterMessageService.postAuditMessageOnUpdate(\n p.after,\n p.modelName,\n p.before,\n (p.updatedColumnNames ?? []).map(n => ({ propertyName: n })),\n );\n break;\n case 'delete':\n await this.chatterMessageService.postAuditMessageOnDelete(p.modelName, p.before);\n break;\n }\n }\n}\n"]}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { RabbitMqPublisher } from 'src/services/queues/rabbitmq-publisher.service';
|
|
2
2
|
import { MqMessageQueueService } from '../../services/mq-message-queue.service';
|
|
3
3
|
import { MqMessageService } from '../../services/mq-message.service';
|
|
4
|
-
import { QueuesModuleOptions } from "../../interfaces";
|
|
5
|
-
export type AuditEventType = 'insert' | 'update' | 'delete';
|
|
6
|
-
export interface AuditQueuePayload {
|
|
7
|
-
eventType: AuditEventType;
|
|
8
|
-
modelName: string;
|
|
9
|
-
entityId: string | number | null;
|
|
10
|
-
occurredAt: string;
|
|
11
|
-
after?: any;
|
|
12
|
-
before?: any;
|
|
13
|
-
updatedColumnNames?: string[];
|
|
14
|
-
userId?: number | null;
|
|
15
|
-
}
|
|
4
|
+
import { AuditQueuePayload, QueuesModuleOptions } from "../../interfaces";
|
|
16
5
|
export declare class ChatterQueuePublisherRabbitmq extends RabbitMqPublisher<AuditQueuePayload> {
|
|
17
6
|
protected readonly mqMessageService: MqMessageService;
|
|
18
7
|
protected readonly mqMessageQueueService: MqMessageQueueService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-publisher.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-publisher.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"chatter-queue-publisher.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-publisher.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,qBACa,6BAA8B,SAAQ,iBAAiB,CAAC,iBAAiB,CAAC;IAE/E,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IACrD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;gBAD5C,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB;IAKnE,OAAO,IAAI,mBAAmB;CAKjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-publisher.service.js","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-publisher.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iGAAmF;AACnF,oFAA0D;AAC1D,sFAAgF;AAChF,0EAAqE;
|
|
1
|
+
{"version":3,"file":"chatter-queue-publisher.service.js","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-publisher.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iGAAmF;AACnF,oFAA0D;AAC1D,sFAAgF;AAChF,0EAAqE;AAI9D,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,8CAAoC;IACnF,YACuB,gBAAkC,EAClC,qBAA4C;QAE/D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAH5B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGnE,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,+BAAmB;SACzB,CAAA;IACL,CAAC;CACJ,CAAA;AAbY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,mBAAU,GAAE;qCAGgC,qCAAgB;QACX,gDAAqB;GAH1D,6BAA6B,CAazC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport { RabbitMqPublisher } from 'src/services/queues/rabbitmq-publisher.service';\nimport chatterQueueOptions from './chatter-queue-options';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { AuditQueuePayload, QueuesModuleOptions } from \"../../interfaces\";\n\n@Injectable()\nexport class ChatterQueuePublisherRabbitmq extends RabbitMqPublisher<AuditQueuePayload> {\n constructor(\n protected readonly mqMessageService: MqMessageService,\n protected readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...chatterQueueOptions\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { QueueMessage } from 'src/interfaces/mq';
|
|
|
3
3
|
import { MqMessageService } from '../../services/mq-message.service';
|
|
4
4
|
import { MqMessageQueueService } from '../../services/mq-message-queue.service';
|
|
5
5
|
import { QueuesModuleOptions } from "../../interfaces";
|
|
6
|
-
import { AuditQueuePayload } from '
|
|
6
|
+
import { AuditQueuePayload } from '../../interfaces';
|
|
7
7
|
import { ChatterMessageService } from 'src/services/chatter-message.service';
|
|
8
8
|
export declare class ChatterQueueSubscriberRabbitmq extends RabbitMqSubscriber<AuditQueuePayload> {
|
|
9
9
|
readonly mqMessageService: MqMessageService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-subscriber.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-subscriber.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,qBACa,8BAA+B,SAAQ,kBAAkB,CAAC,iBAAiB,CAAC;IAIjF,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAL1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmD;gBAGpE,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB,EACpC,qBAAqB,EAAE,qBAAqB;IAKjE,OAAO,IAAI,mBAAmB;IAMxB,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC;CAqB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber.service.js","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-subscriber.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,mGAAqF;AAErF,0EAAqE;AACrE,sFAAgF;AAEhF,oFAA0D;AAE1D,oFAA6E;AAGtE,IAAM,8BAA8B,sCAApC,MAAM,8BAA+B,SAAQ,gDAAqC;IAGrF,YACa,gBAAkC,EAClC,qBAA4C,EACpC,qBAA4C;QAE7D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAJtC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAAuB;QALhD,kBAAa,GAAG,IAAI,eAAM,CAAC,gCAA8B,CAAC,IAAI,CAAC,CAAC;IAQjF,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,+BAAmB;SACzB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAwC;QACpD,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpF,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;gBAChF,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CACrD,CAAC,CAAC,KAAK,EACP,CAAC,CAAC,SAAS,EACX,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAC/D,CAAC;gBACF,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;gBACjF,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAtCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACb,+CAAqB;GANxD,8BAA8B,CAsC1C","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport chatterQueueOptions from './chatter-queue-options';\nimport { AuditQueuePayload } from '
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber.service.js","sourceRoot":"","sources":["../../../src/jobs/rabbitmq/chatter-queue-subscriber.service.ts"],"names":[],"mappings":";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ACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;gBACjF,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAtCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACb,+CAAqB;GANxD,8BAA8B,CAsC1C","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport chatterQueueOptions from './chatter-queue-options';\nimport { AuditQueuePayload } from '../../interfaces';\nimport { ChatterMessageService } from 'src/services/chatter-message.service';\n\n@Injectable()\nexport class ChatterQueueSubscriberRabbitmq extends RabbitMqSubscriber<AuditQueuePayload> {\n private readonly chatterLogger = new Logger(ChatterQueueSubscriberRabbitmq.name);\n\n constructor(\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n private readonly chatterMessageService: ChatterMessageService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...chatterQueueOptions\n }\n }\n\n async subscribe(message: QueueMessage<AuditQueuePayload>) {\n const p = message.payload;\n this.chatterLogger.debug(`Audit event ${p.eventType} ${p.modelName}#${p.entityId}`);\n\n switch (p.eventType) {\n case 'insert':\n await this.chatterMessageService.postAuditMessageOnInsert(p.after, p.modelName);\n break;\n case 'update':\n await this.chatterMessageService.postAuditMessageOnUpdate(\n p.after,\n p.modelName,\n p.before,\n (p.updatedColumnNames ?? []).map(n => ({ propertyName: n })),\n );\n break;\n case 'delete':\n await this.chatterMessageService.postAuditMessageOnDelete(p.modelName, p.before);\n break;\n }\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { QueueMessage } from 'src/interfaces/mq';
|
|
|
3
3
|
import { MqMessageService } from '../../services/mq-message.service';
|
|
4
4
|
import { MqMessageQueueService } from '../../services/mq-message-queue.service';
|
|
5
5
|
import { QueuesModuleOptions } from "../../interfaces";
|
|
6
|
-
import { AuditQueuePayload } from '
|
|
6
|
+
import { AuditQueuePayload } from '../../interfaces';
|
|
7
7
|
import { ChatterMessageService } from '../../services/chatter-message.service';
|
|
8
8
|
export declare class ChatterQueueSubscriberRedis extends RedisSubscriber<any> {
|
|
9
9
|
readonly mqMessageService: MqMessageService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber-redis.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/redis/chatter-queue-subscriber-redis.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber-redis.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/redis/chatter-queue-subscriber-redis.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,qBACa,2BAA4B,SAAQ,eAAe,CAAC,GAAG,CAAC;IAI7D,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAL1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAgD;gBAGtE,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB,EACpC,qBAAqB,EAAE,qBAAqB;IAKjE,OAAO,IAAI,mBAAmB;IAMxB,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC;CAgB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatter-queue-subscriber-redis.service.js","sourceRoot":"","sources":["../../../src/jobs/redis/chatter-queue-subscriber-redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,6FAA+E;AAE/E,gGAA+D;AAC/D,0EAAqE;AACrE,sFAAgF;AAGhF,oFAA+E;AAGxE,IAAM,2BAA2B,mCAAjC,MAAM,2BAA4B,SAAQ,0CAAoB;IAGjE,YACa,gBAAkC,EAClC,qBAA4C,EACpC,qBAA4C;QAE7D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAJtC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAAuB;QALhD,uBAAkB,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;IAQnF,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,qCAAkB;SACxB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAwC;QACpD,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEzF,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,CAAC,CAAC;gBACjG,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACzK,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;gBAC5G,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAjCY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACb,+CAAqB;GANxD,2BAA2B,CAiCvC","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { RedisSubscriber } from 'src/services/queues/redis-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport chatterQueueConfig from './chatter-queue-options-redis';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { AuditQueuePayload } from '
|
|
1
|
+
{"version":3,"file":"chatter-queue-subscriber-redis.service.js","sourceRoot":"","sources":["../../../src/jobs/redis/chatter-queue-subscriber-redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,6FAA+E;AAE/E,gGAA+D;AAC/D,0EAAqE;AACrE,sFAAgF;AAGhF,oFAA+E;AAGxE,IAAM,2BAA2B,mCAAjC,MAAM,2BAA4B,SAAQ,0CAAoB;IAGjE,YACa,gBAAkC,EAClC,qBAA4C,EACpC,qBAA4C;QAE7D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAJtC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAAuB;QALhD,uBAAkB,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;IAQnF,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,qCAAkB;SACxB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAwC;QACpD,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEzF,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,CAAC,CAAC;gBACjG,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACzK,MAAM;YACV,KAAK,QAAQ;gBACT,MAAM,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;gBAC5G,MAAM;QACd,CAAC;IACL,CAAC;CACJ,CAAA;AAjCY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAKsB,qCAAgB;QACX,gDAAqB;QACb,+CAAqB;GANxD,2BAA2B,CAiCvC","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\n\nimport { RedisSubscriber } from 'src/services/queues/redis-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport chatterQueueConfig from './chatter-queue-options-redis';\nimport { MqMessageService } from '../../services/mq-message.service';\nimport { MqMessageQueueService } from '../../services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../../interfaces\";\nimport { AuditQueuePayload } from '../../interfaces';\nimport { ChatterMessageService } from '../../services/chatter-message.service';\n\n@Injectable()\nexport class ChatterQueueSubscriberRedis extends RedisSubscriber<any> {\n private readonly chatterQueueLogger = new Logger(ChatterQueueSubscriberRedis.name);\n\n constructor(\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n private readonly chatterMessageService: ChatterMessageService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...chatterQueueConfig\n }\n }\n\n async subscribe(message: QueueMessage<AuditQueuePayload>) {\n const p = message.payload;\n this.chatterQueueLogger.debug(`Audit event ${p.eventType} ${p.modelName}#${p.entityId}`);\n\n switch (p.eventType) {\n case 'insert':\n await this.chatterMessageService.postAuditMessageOnInsert(p.after, { name: p.modelName } as any);\n break;\n case 'update':\n await this.chatterMessageService.postAuditMessageOnUpdate(p.after, { name: p.modelName } as any, p.before, (p.updatedColumnNames || []).map(n => ({ propertyName: n })));\n break;\n case 'delete':\n await this.chatterMessageService.postAuditMessageOnDelete(p.before, { name: p.modelName } as any, p.before);\n break;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class EncryptionService {
|
|
2
|
+
private readonly key;
|
|
3
|
+
constructor(secret: string);
|
|
4
|
+
encrypt(plaintext: string): string;
|
|
5
|
+
decrypt(ciphertext: string): string;
|
|
6
|
+
isEncrypted(value: string): boolean;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=encryption.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.service.d.ts","sourceRoot":"","sources":["../../src/services/encryption.service.ts"],"names":[],"mappings":"AASA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,MAAM,EAAE,MAAM;IAK1B,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQlC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAcnC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGpC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EncryptionService = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const ALGORITHM = 'aes-256-gcm';
|
|
39
|
+
const IV_LENGTH = 12;
|
|
40
|
+
const AUTH_TAG_LENGTH = 16;
|
|
41
|
+
const KEY_LENGTH = 32;
|
|
42
|
+
const SCRYPT_SALT = 'solid-encryption-salt';
|
|
43
|
+
const ENC_PREFIX = 'enc:';
|
|
44
|
+
class EncryptionService {
|
|
45
|
+
constructor(secret) {
|
|
46
|
+
if (!secret)
|
|
47
|
+
throw new Error('EncryptionService: secret must not be empty');
|
|
48
|
+
this.key = crypto.scryptSync(secret, SCRYPT_SALT, KEY_LENGTH);
|
|
49
|
+
}
|
|
50
|
+
encrypt(plaintext) {
|
|
51
|
+
const iv = crypto.randomBytes(IV_LENGTH);
|
|
52
|
+
const cipher = crypto.createCipheriv(ALGORITHM, this.key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
53
|
+
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
|
|
54
|
+
const authTag = cipher.getAuthTag();
|
|
55
|
+
return `${ENC_PREFIX}${iv.toString('hex')}:${authTag.toString('hex')}:${encrypted.toString('hex')}`;
|
|
56
|
+
}
|
|
57
|
+
decrypt(ciphertext) {
|
|
58
|
+
if (!ciphertext.startsWith(ENC_PREFIX)) {
|
|
59
|
+
throw new Error('EncryptionService: value does not appear to be encrypted');
|
|
60
|
+
}
|
|
61
|
+
const payload = ciphertext.slice(ENC_PREFIX.length);
|
|
62
|
+
const [ivHex, authTagHex, encryptedHex] = payload.split(':');
|
|
63
|
+
const iv = Buffer.from(ivHex, 'hex');
|
|
64
|
+
const authTag = Buffer.from(authTagHex, 'hex');
|
|
65
|
+
const encryptedBuf = Buffer.from(encryptedHex, 'hex');
|
|
66
|
+
const decipher = crypto.createDecipheriv(ALGORITHM, this.key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
67
|
+
decipher.setAuthTag(authTag);
|
|
68
|
+
return decipher.update(encryptedBuf).toString('utf8') + decipher.final('utf8');
|
|
69
|
+
}
|
|
70
|
+
isEncrypted(value) {
|
|
71
|
+
return typeof value === 'string' && value.startsWith(ENC_PREFIX);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.EncryptionService = EncryptionService;
|
|
75
|
+
//# sourceMappingURL=encryption.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.service.js","sourceRoot":"","sources":["../../src/services/encryption.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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QAC9E,CAAC;QACD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,CAAC;QACtG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjF,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACnE,CAAC;CACF;AAjCD,8CAiCC","sourcesContent":["import * as crypto from 'crypto';\n\nconst ALGORITHM = 'aes-256-gcm';\nconst IV_LENGTH = 12;\nconst AUTH_TAG_LENGTH = 16;\nconst KEY_LENGTH = 32;\nconst SCRYPT_SALT = 'solid-encryption-salt';\nconst ENC_PREFIX = 'enc:';\n\nexport class EncryptionService {\n private readonly key: Buffer;\n\n constructor(secret: string) {\n if (!secret) throw new Error('EncryptionService: secret must not be empty');\n this.key = crypto.scryptSync(secret, SCRYPT_SALT, KEY_LENGTH) as Buffer;\n }\n\n encrypt(plaintext: string): string {\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, this.key, iv, { authTagLength: AUTH_TAG_LENGTH });\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);\n const authTag = cipher.getAuthTag();\n return `${ENC_PREFIX}${iv.toString('hex')}:${authTag.toString('hex')}:${encrypted.toString('hex')}`;\n }\n\n decrypt(ciphertext: string): string {\n if (!ciphertext.startsWith(ENC_PREFIX)) {\n throw new Error('EncryptionService: value does not appear to be encrypted');\n }\n const payload = ciphertext.slice(ENC_PREFIX.length);\n const [ivHex, authTagHex, encryptedHex] = payload.split(':');\n const iv = Buffer.from(ivHex, 'hex');\n const authTag = Buffer.from(authTagHex, 'hex');\n const encryptedBuf = Buffer.from(encryptedHex, 'hex');\n const decipher = crypto.createDecipheriv(ALGORITHM, this.key, iv, { authTagLength: AUTH_TAG_LENGTH });\n decipher.setAuthTag(authTag);\n return decipher.update(encryptedBuf).toString('utf8') + decipher.final('utf8');\n }\n\n isEncrypted(value: string): boolean {\n return typeof value === 'string' && value.startsWith(ENC_PREFIX);\n }\n}\n"]}
|
|
@@ -20,6 +20,7 @@ export declare class SettingService {
|
|
|
20
20
|
private readonly _logger;
|
|
21
21
|
private settings;
|
|
22
22
|
private settingsByKey;
|
|
23
|
+
private readonly encryptionService;
|
|
23
24
|
private readonly arrayKeysToSkip;
|
|
24
25
|
constructor(fileService: IFileService, pathBuilder: IStoragePathBuilder, solidRegistry: SolidRegistry, repo: SettingRepository, moduleMetadataRepo: ModuleMetadataRepository, requestContextService: RequestContextService, userRepository: Repository<User>);
|
|
25
26
|
private getSettingsFromDb;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting.service.d.ts","sourceRoot":"","sources":["../../src/services/setting.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,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AAY,EAAE,mBAAmB,GAAE,GAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAuBzF"}
|
|
@@ -61,6 +61,7 @@ const solid_registry_1 = require("../helpers/solid-registry");
|
|
|
61
61
|
const interfaces_1 = require("../interfaces");
|
|
62
62
|
const module_metadata_repository_1 = require("../repository/module-metadata.repository");
|
|
63
63
|
const common_2 = require("@nestjs/common");
|
|
64
|
+
const encryption_service_1 = require("./encryption.service");
|
|
64
65
|
let SettingService = SettingService_1 = class SettingService {
|
|
65
66
|
constructor(fileService, pathBuilder, solidRegistry, repo, moduleMetadataRepo, requestContextService, userRepository) {
|
|
66
67
|
this.fileService = fileService;
|
|
@@ -78,6 +79,10 @@ let SettingService = SettingService_1 = class SettingService {
|
|
|
78
79
|
'authenticationPasswordRegexErrorMessage',
|
|
79
80
|
'authenticationPasswordComplexityDescription',
|
|
80
81
|
]);
|
|
82
|
+
const encKey = process.env.APP_ENCRYPTION_KEY;
|
|
83
|
+
this.encryptionService = encKey ? new encryption_service_1.EncryptionService(encKey) : null;
|
|
84
|
+
if (!encKey)
|
|
85
|
+
this._logger.warn('APP_ENCRYPTION_KEY is not set — encrypted settings will not be decrypted');
|
|
81
86
|
}
|
|
82
87
|
async getSettingsFromDb() {
|
|
83
88
|
const settings = await this.repo.find({ relations: ['user'] });
|
|
@@ -131,7 +136,16 @@ let SettingService = SettingService_1 = class SettingService {
|
|
|
131
136
|
const settingFromDb = settingsFromDbByKey.get(setting.key);
|
|
132
137
|
const valueFromDb = settingFromDb?.value;
|
|
133
138
|
if (settingFromDb?.key && valueFromDb !== undefined && valueFromDb !== null) {
|
|
134
|
-
|
|
139
|
+
let rawValue = valueFromDb;
|
|
140
|
+
if (settingFromDb.encrypted && this.encryptionService) {
|
|
141
|
+
try {
|
|
142
|
+
rawValue = this.encryptionService.decrypt(rawValue);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
this._logger.warn(`Failed to decrypt setting "${setting.key}" — using raw value`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const parsedValue = typeof rawValue === 'string' ? this.parseSettingValue(rawValue, settingFromDb.key) : rawValue;
|
|
135
149
|
return { ...setting, value: parsedValue };
|
|
136
150
|
}
|
|
137
151
|
return setting;
|
|
@@ -150,31 +164,38 @@ let SettingService = SettingService_1 = class SettingService {
|
|
|
150
164
|
const existingSettingsFromDb = await this.getSettingsFromDb();
|
|
151
165
|
const existingSettingsFromDbByKey = new Map(existingSettingsFromDb.map(setting => [setting.key, setting]));
|
|
152
166
|
const settingsToMutate = [];
|
|
153
|
-
for (const { key, value, level, moduleName } of saEditableAndAbove) {
|
|
167
|
+
for (const { key, value, level, moduleName, encrypted } of saEditableAndAbove) {
|
|
154
168
|
const moduleMetadata = await this.moduleMetadataRepo.findOneBy({ name: moduleName });
|
|
155
169
|
if (!existingSettingsFromDbByKey.has(key)) {
|
|
156
170
|
const setting = new setting_entity_1.Setting();
|
|
157
171
|
setting.key = key;
|
|
158
172
|
setting.level = level;
|
|
173
|
+
setting.encrypted = !!encrypted;
|
|
159
174
|
if (moduleMetadata)
|
|
160
175
|
setting.moduleMetadata = moduleMetadata;
|
|
176
|
+
let rawValue;
|
|
161
177
|
if (typeof value === 'boolean') {
|
|
162
|
-
|
|
178
|
+
rawValue = value.toString();
|
|
163
179
|
}
|
|
164
180
|
else if (Array.isArray(value)) {
|
|
165
|
-
|
|
181
|
+
rawValue = value.join(',');
|
|
166
182
|
}
|
|
167
183
|
else if (value === null || value === undefined) {
|
|
168
|
-
|
|
184
|
+
rawValue = null;
|
|
169
185
|
}
|
|
170
186
|
else {
|
|
171
|
-
|
|
187
|
+
rawValue = String(value);
|
|
172
188
|
}
|
|
189
|
+
if (encrypted && this.encryptionService && rawValue !== null) {
|
|
190
|
+
rawValue = this.encryptionService.encrypt(rawValue);
|
|
191
|
+
}
|
|
192
|
+
setting.value = rawValue;
|
|
173
193
|
settingsToMutate.push(setting);
|
|
174
194
|
}
|
|
175
195
|
else {
|
|
176
196
|
const setting = existingSettingsFromDbByKey.get(key);
|
|
177
197
|
setting.level = level;
|
|
198
|
+
setting.encrypted = !!encrypted;
|
|
178
199
|
if (moduleMetadata)
|
|
179
200
|
setting.moduleMetadata = moduleMetadata;
|
|
180
201
|
settingsToMutate.push(setting);
|
|
@@ -251,12 +272,18 @@ let SettingService = SettingService_1 = class SettingService {
|
|
|
251
272
|
}
|
|
252
273
|
const key = settingDto.key;
|
|
253
274
|
const rawValue = settingDto.value;
|
|
254
|
-
|
|
275
|
+
let value = rawValue === null || rawValue === undefined ? null : String(rawValue);
|
|
255
276
|
const settingType = settingDto.type ?? 'system';
|
|
277
|
+
const definition = this.settingsByKey.get(key);
|
|
278
|
+
const shouldEncrypt = !!definition?.encrypted && this.encryptionService !== null && value !== null;
|
|
279
|
+
if (shouldEncrypt) {
|
|
280
|
+
value = this.encryptionService.encrypt(value);
|
|
281
|
+
}
|
|
256
282
|
const existingSetting = existingSettings.find(s => s.key === key);
|
|
257
283
|
if (existingSetting) {
|
|
258
284
|
existingSetting.value = value;
|
|
259
285
|
existingSetting.type = settingType;
|
|
286
|
+
existingSetting.encrypted = shouldEncrypt;
|
|
260
287
|
settingsToUpdate.push(existingSetting);
|
|
261
288
|
}
|
|
262
289
|
else {
|
|
@@ -264,6 +291,7 @@ let SettingService = SettingService_1 = class SettingService {
|
|
|
264
291
|
newSetting.key = key;
|
|
265
292
|
newSetting.value = value;
|
|
266
293
|
newSetting.type = settingType;
|
|
294
|
+
newSetting.encrypted = shouldEncrypt;
|
|
267
295
|
if (settingType === 'user' && user) {
|
|
268
296
|
newSetting.user = user;
|
|
269
297
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting.service.js","sourceRoot":"","sources":["../../src/services/setting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,6CAAmD;AACnD,qCAAqC;AACrC,wDAA0C;AAC1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AM,uBAAuB,UAAU,wBAAwB,UAAU,EAAE,EAAE,CAAC;IACrL,CAAC;CAEF,CAAA;AApWY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAcR,WAAA,IAAA,eAAM,EAAC,mBAAY,CAAC,CAAA;IACpB,WAAA,IAAA,eAAM,EAAC,gCAAyB,CAAC,CAAA;IAKjC,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qDAJC,8BAAa;QACtB,sCAAiB;QACH,qDAAwB;QACb,+CAAqB;QACJ,oBAAU;GAnB1D,cAAc,CAoW1B","sourcesContent":["import { BadRequestException, ForbiddenException, Inject, Injectable } from '@nestjs/common';\nimport { InjectRepository } from '@nestjs/typeorm';\nimport { Repository } from 'typeorm';\nimport * as fsPromises from 'fs/promises';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { CreateSettingDto } from 'src/dtos/create-setting.dto';\nimport { GetMcpUrlDto } from 'src/dtos/get-mcp-url.dto';\nimport { User } from 'src/entities/user.entity';\nimport { SettingRepository } from '../repository/setting.repository';\nimport { FILE_SERVICE, IFileService, FILE_STORAGE_PATH_BUILDER, IStoragePathBuilder } from './file';\nimport { Setting } from '../entities/setting.entity';\nimport { RequestContextService } from './request-context.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ISettingsProvider, NoInfer, SettingDefinition, SettingLevel } from '../interfaces';\nimport { ModuleMetadataRepository } from 'src/repository/module-metadata.repository';\nimport type { SolidCoreSetting } from './settings/default-settings-provider.service';\nimport { Logger } from '@nestjs/common';\n\n\n@Injectable()\nexport class SettingService {\n private readonly _logger = new Logger(SettingService.name);\n\n private settings: SettingDefinition[] = [];\n private settingsByKey = new Map<string, SettingDefinition>();\n\n private readonly arrayKeysToSkip = new Set([\n 'authenticationPasswordRegex',\n 'authenticationPasswordRegexErrorMessage',\n 'authenticationPasswordComplexityDescription',\n ]);\n\n constructor(\n @Inject(FILE_SERVICE) readonly fileService: IFileService,\n @Inject(FILE_STORAGE_PATH_BUILDER) readonly pathBuilder: IStoragePathBuilder,\n readonly solidRegistry: SolidRegistry,\n readonly repo: SettingRepository,\n readonly moduleMetadataRepo: ModuleMetadataRepository,\n private readonly requestContextService: RequestContextService,\n @InjectRepository(User) private readonly userRepository: Repository<User>,\n ) { }\n\n private async getSettingsFromDb(): Promise<Setting[]> {\n const settings = await this.repo.find({ relations: ['user'] });\n return settings;\n }\n\n private parseSettingValue(value: string, key: string): any {\n try {\n return JSON.parse(value);\n } catch {\n if (value === 'true' || value === 'false') {\n return value === 'true';\n }\n if (!isNaN(Number(value)) && value.trim() !== '') {\n return Number(value);\n }\n if (!this.arrayKeysToSkip.has(key) && value.includes(',')) {\n return value.split(',').map(item => item.trim());\n }\n return value;\n }\n }\n\n /**\n * Reads all registered providers and gathers settings from across the running platform.\n * This is the superset of all possible settings. \n * @returns \n */\n private getAllSettingsFromProviders(): SettingDefinition[] {\n // get all settings from registry \n const allSettingsProviders = this.solidRegistry.getSettingsProviders();\n const settings: SettingDefinition[] = [];\n const seenKeys = new Map<string, { setting: SettingDefinition; providerName?: string }>();\n for (const wrapper of allSettingsProviders) {\n const instance = wrapper.instance as ISettingsProvider;\n // if (!instance?.getSettings) continue;\n for (const setting of instance.getSettings()) {\n const existing = seenKeys.get(setting.key);\n if (existing) {\n throw new Error(\n `Duplicate setting key detected: ${setting.key}. ` +\n `First: ${JSON.stringify(existing.setting)} from provider: ${existing.providerName ?? \"unknown\"}. ` +\n `Second: ${JSON.stringify(setting)} from provider: ${wrapper.name ?? \"unknown\"}.`\n );\n }\n seenKeys.set(setting.key, { setting, providerName: wrapper.name });\n settings.push(setting);\n }\n }\n\n return settings\n }\n\n /**\n * public method that gets all settings in the system, this includes settings from solid-core and any consuming projects.\n * this means that the settings returned are the ones provided by ISettingsProvider, merged with values if any from the database. \n * \n * @returns \n */\n getAllSettings(): SettingDefinition[] {\n return this.settings;\n }\n\n async updateSettingsCache(): Promise<void> {\n this._logger.debug(`updating settings cache...`);\n const settingsFromDb = await this.getSettingsFromDb();\n const settingsFromProviders = this.getAllSettingsFromProviders();\n const settingsFromDbByKey = new Map(settingsFromDb.map(setting => [setting.key, setting]));\n\n this.settings = settingsFromProviders.map(setting => {\n const settingFromDb = settingsFromDbByKey.get(setting.key);\n const valueFromDb = settingFromDb?.value;\n if (settingFromDb?.key && valueFromDb !== undefined && valueFromDb !== null) {\n const parsedValue = typeof valueFromDb === 'string' ? this.parseSettingValue(valueFromDb, settingFromDb.key) : valueFromDb;\n return { ...setting, value: parsedValue };\n }\n return setting;\n });\n\n // Also keep a key vs SettingDefinition map...\n this.settingsByKey = new Map(this.settings.map(setting => [setting.key, setting]));\n }\n\n private isDisallowedSettingKey(key: string, settingLevelsToDisallow: SettingLevel[]): boolean {\n if (!key) {\n return false;\n }\n const setting = this.settingsByKey.get(key);\n // return setting ? [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly].includes(setting.level) : false;\n return setting ? settingLevelsToDisallow.includes(setting.level) : false;\n }\n\n /**\n * 1. \n * This method will seed (insert only) settings that are introduced in code but do not already exist in the database. \n * Also this method only deals with settings with level system-admin-editable & internal-user.\n */\n async seedSystemAdminEditableAndAboveSettings(): Promise<void> {\n // Seed only settings with level system-admin-editable & internal-user, \n // so basically settings which are either system-admin-editable and above.\n const saEditableAndAbove = this.getAllSettingsFromProviders().filter(i => [SettingLevel.SystemAdminEditable, SettingLevel.InternalUser].includes(i.level));\n\n // Get hold of the current values from the database.\n const existingSettingsFromDb: Setting[] = await this.getSettingsFromDb();\n\n // const existingKeysFromDb = new Set(existingSettingsFromDb.map(s => s.key));\n const existingSettingsFromDbByKey = new Map(existingSettingsFromDb.map(setting => [setting.key, setting]));\n const settingsToMutate: Setting[] = [];\n // const settingsToUpdate: Setting[] = [];\n\n for (const { key, value, level, moduleName } of saEditableAndAbove) {\n const moduleMetadata = await this.moduleMetadataRepo.findOneBy({ name: moduleName });\n if (!existingSettingsFromDbByKey.has(key)) {\n const setting = new Setting();\n setting.key = key;\n setting.level = level;\n if (moduleMetadata)\n setting.moduleMetadata = moduleMetadata;\n\n if (typeof value === 'boolean') {\n setting.value = value.toString();\n } else if (Array.isArray(value)) {\n setting.value = value.join(',');\n } else if (value === null || value === undefined) {\n setting.value = null;\n } else {\n setting.value = String(value);\n }\n\n settingsToMutate.push(setting);\n }\n else {\n const setting = existingSettingsFromDbByKey.get(key);\n setting.level = level;\n if (moduleMetadata)\n setting.moduleMetadata = moduleMetadata;\n settingsToMutate.push(setting);\n }\n }\n\n if (settingsToMutate.length > 0) {\n await this.repo.save(settingsToMutate);\n }\n // if (settingsToUpdate.length > 0) {\n // await this.repo.save(settingsToUpdate);\n // }\n }\n\n /**\n * 2. \n * Method used from the solid-core-ui to fetch available settings. \n * Here we are returning settings other than system-env.\n * \n * @returns \n */\n async getSystemAdminReadonlyAndAboveSettings(): Promise<Record<any, any>> {\n const finalSettings: Record<any, any> = {};\n const systemAdminReadonlyAndAboveSettings = this.settings.filter(i => i.level !== \"system-env\");\n for (const setting of systemAdminReadonlyAndAboveSettings) {\n finalSettings[setting.key] = setting.value;\n }\n return finalSettings;\n }\n\n /**\n * 3. \n * This method updates settings from the admin user interface. \n * Most likely settings with level system-admin-editable & internal-user are the ones that will get modified here. \n * \n * @param settings \n * @param uploadedFiles \n * @returns \n */\n async updateSettings(settings: CreateSettingDto[] = [], uploadedFiles: Array<Express.Multer.File> = []): Promise<Setting[]> {\n const activeUser = this.requestContextService.getActiveUser();\n const userId = activeUser?.sub;\n\n const restrictedKeys = new Set<string>();\n\n settings.forEach(setting => {\n if (this.isDisallowedSettingKey(setting.key, [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly])) {\n restrictedKeys.add(setting.key);\n }\n });\n uploadedFiles.forEach(file => {\n if (this.isDisallowedSettingKey(file.fieldname, [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly])) {\n restrictedKeys.add(file.fieldname);\n }\n });\n\n if (restrictedKeys.size > 0) {\n throw new BadRequestException(`${ERROR_MESSAGES.FORBIDDEN}: Settings ${Array.from(restrictedKeys).join(', ')} cannot be modified.`);\n }\n\n // const existingSettings = await this.repo.find();\n const existingSettings: Setting[] = await this.getSettingsFromDb();\n\n const settingsToUpdate: Setting[] = [];\n const settingsToCreate: Setting[] = [];\n\n let user: User | null = null;\n const hasUserSettings = settings.some(dto => dto.type === 'user');\n if (hasUserSettings && userId) {\n user = await this.userRepository.findOne({ where: { id: userId } });\n }\n\n // Handle uploaded files\n if (uploadedFiles?.length) {\n for (const file of uploadedFiles) {\n const settingKey = file.fieldname;\n const relativeFileName = `${file.filename}-${file.originalname}`;\n\n // Read file from local disk (where Multer stores uploads) and write to storage\n // The path builder constructs the provider-appropriate storage path\n const fileContent = await fsPromises.readFile(file.path);\n const storagePath = this.pathBuilder.build(relativeFileName);\n const fileUrl = await this.fileService.write(storagePath, fileContent, { contentType: file.mimetype });\n // Delete the temp file from local disk\n await fsPromises.unlink(file.path);\n\n const matchedDto = settings.find(dto => dto.key === settingKey);\n const settingType = matchedDto?.type ?? 'system';\n\n const existingSetting = existingSettings.find(s => s.key === settingKey);\n if (existingSetting) {\n existingSetting.value = fileUrl;\n existingSetting.type = settingType;\n settingsToUpdate.push(existingSetting);\n } else {\n const newSetting = new Setting();\n newSetting.key = settingKey;\n newSetting.value = fileUrl;\n newSetting.type = settingType;\n\n if (settingType === 'user' && user) {\n newSetting.user = user;\n }\n\n settingsToCreate.push(newSetting);\n }\n }\n }\n\n // Handle non-file settings\n for (const settingDto of settings) {\n if (uploadedFiles?.some(file => file.fieldname === settingDto.key)) {\n continue; // skip if already handled via file\n }\n\n const key = settingDto.key;\n // const value = settingDto.value ?? '';\n const rawValue = settingDto.value;\n const value = rawValue === null || rawValue === undefined ? null : String(rawValue);\n\n const settingType = settingDto.type ?? 'system';\n\n const existingSetting = existingSettings.find(s => s.key === key);\n if (existingSetting) {\n existingSetting.value = value;\n existingSetting.type = settingType;\n settingsToUpdate.push(existingSetting);\n } else {\n const newSetting = new Setting();\n newSetting.key = key;\n newSetting.value = value;\n newSetting.type = settingType;\n\n if (settingType === 'user' && user) {\n newSetting.user = user;\n }\n\n settingsToCreate.push(newSetting);\n }\n }\n\n if (settingsToUpdate.length > 0) {\n await this.repo.save(settingsToUpdate);\n }\n\n if (settingsToCreate.length > 0) {\n await this.repo.save(settingsToCreate);\n }\n await this.updateSettingsCache();\n\n return [...settingsToUpdate, ...settingsToCreate];\n }\n\n /**\n * 4. \n * @param settingKey \n * @returns \n */\n getConfigValue<T = never>(settingKey: NoInfer<T>) {\n const cachedSetting = this.settingsByKey.get(settingKey as string);\n if (cachedSetting) {\n return cachedSetting.value;\n }\n\n return null;\n\n // const cachedSetting = this.settings.find(setting => setting.key === settingKey);\n // if (cachedSetting) {\n // return cachedSetting.value;\n // }\n\n // // This is probably not needed at all, but leaving it here as a backup for scenarios like \n // // if getConfigValue<SolidCoreSetting>() is called before onApplicationBootstrap() runs or if the cache refresh fails. \n // const getAllSettings = this.getAllSettingsFromProviders();\n // const settingValue = getAllSettings.find(i => (i.key == settingKey))\n // return settingValue?.value;\n }\n\n async getMcpUrl(getMcpUrlDto: GetMcpUrlDto, solidRequestContext: any = {}): Promise<any> {\n\n const { showHeader, inListView } = getMcpUrlDto;\n\n const mcpEnabled = this.getConfigValue<SolidCoreSetting>('mcpEnabled');\n if (mcpEnabled === 'false' || mcpEnabled === false) {\n throw new ForbiddenException(ERROR_MESSAGES.FORBIDDEN);\n }\n\n if (solidRequestContext.activeUser) {\n const permissionNames = [\"SettingController.getMcpUrl\"];\n const matchingPermssions = solidRequestContext.activeUser.permissions.filter((p: any) => permissionNames.includes(p));\n const hasPermission = matchingPermssions.length > 0;\n if (!hasPermission) {\n throw new BadRequestException(ERROR_MESSAGES.FORBIDDEN);\n }\n }\n const apiKey = this.getConfigValue<SolidCoreSetting>('mcpApiKey');\n const userId = solidRequestContext.activeUser.sub;\n const mcpServerUrl = this.getConfigValue<SolidCoreSetting>('mcpServerUrl');\n return { mcpUrl: `${mcpServerUrl}/static/frontend.html?solidx-mcp-api-key=${apiKey}&solidx-user-id=${userId}&solidx-show-header=${showHeader}&solidx-in-list-view=${inListView}` };\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"setting.service.js","sourceRoot":"","sources":["../../src/services/setting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,6CAAmD;AACnD,qCAAqC;AACrC,wDAA0C;AAC1C,gEAA8D;AAG9D,yDAAgD;AAChD,yEAAqE;AACrE,iCAAoG;AACpG,+DAAqD;AACrD,uEAAkE;AAClE,8DAA2D;AAC3D,8CAA4F;AAC5F,yFAAqF;AAErF,2CAAwC;AACxC,6DAAyD;AAIlD,IAAM,cAAc,sBAApB,MAAM,cAAc;IAazB,YACwB,WAAkC,EACrB,WAAyC,EACnE,aAA4B,EAC5B,IAAuB,EACvB,kBAA4C,EACpC,qBAA4C,EACrC,cAAiD;QAN1C,gBAAW,GAAX,WAAW,CAAc;QACZ,gBAAW,GAAX,WAAW,CAAqB;QACnE,kBAAa,GAAb,aAAa,CAAe;QAC5B,SAAI,GAAJ,IAAI,CAAmB;QACvB,uBAAkB,GAAlB,kBAAkB,CAA0B;QACpC,0BAAqB,GAArB,qBAAqB,CAAuB;QACpB,mBAAc,GAAd,cAAc,CAAkB;QAnB1D,YAAO,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;QAEnD,aAAQ,GAAwB,EAAE,CAAC;QACnC,kBAAa,GAAG,IAAI,GAAG,EAA6B,CAAC;QAG5C,oBAAe,GAAG,IAAI,GAAG,CAAC;YACzC,6BAA6B;YAC7B,yCAAyC;YACzC,6CAA6C;SAC9C,CAAC,CAAC;QAWD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,sCA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,CAAC;YACtH,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;YACpD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAAM,IAAI,4BAAmB,CAAC,+BAAc,CAAC,SAAS,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAmB,WAAW,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC;QAClD,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAmB,cAAc,CAAC,CAAC;QAC3E,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,4CAA4C,MAAM,mBAAmB,MAAM,uBAAuB,UAAU,wBAAwB,UAAU,EAAE,EAAE,CAAC;IACrL,CAAC;CAEF,CAAA;AAhYY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAeR,WAAA,IAAA,eAAM,EAAC,mBAAY,CAAC,CAAA;IACpB,WAAA,IAAA,eAAM,EAAC,gCAAyB,CAAC,CAAA;IAKjC,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qDAJC,8BAAa;QACtB,sCAAiB;QACH,qDAAwB;QACb,+CAAqB;QACJ,oBAAU;GApB1D,cAAc,CAgY1B","sourcesContent":["import { BadRequestException, ForbiddenException, Inject, Injectable } from '@nestjs/common';\nimport { InjectRepository } from '@nestjs/typeorm';\nimport { Repository } from 'typeorm';\nimport * as fsPromises from 'fs/promises';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { CreateSettingDto } from 'src/dtos/create-setting.dto';\nimport { GetMcpUrlDto } from 'src/dtos/get-mcp-url.dto';\nimport { User } from 'src/entities/user.entity';\nimport { SettingRepository } from '../repository/setting.repository';\nimport { FILE_SERVICE, IFileService, FILE_STORAGE_PATH_BUILDER, IStoragePathBuilder } from './file';\nimport { Setting } from '../entities/setting.entity';\nimport { RequestContextService } from './request-context.service';\nimport { SolidRegistry } from 'src/helpers/solid-registry';\nimport { ISettingsProvider, NoInfer, SettingDefinition, SettingLevel } from '../interfaces';\nimport { ModuleMetadataRepository } from 'src/repository/module-metadata.repository';\nimport type { SolidCoreSetting } from './settings/default-settings-provider.service';\nimport { Logger } from '@nestjs/common';\nimport { EncryptionService } from './encryption.service';\n\n\n@Injectable()\nexport class SettingService {\n private readonly _logger = new Logger(SettingService.name);\n\n private settings: SettingDefinition[] = [];\n private settingsByKey = new Map<string, SettingDefinition>();\n private readonly encryptionService: EncryptionService | null;\n\n private readonly arrayKeysToSkip = new Set([\n 'authenticationPasswordRegex',\n 'authenticationPasswordRegexErrorMessage',\n 'authenticationPasswordComplexityDescription',\n ]);\n\n constructor(\n @Inject(FILE_SERVICE) readonly fileService: IFileService,\n @Inject(FILE_STORAGE_PATH_BUILDER) readonly pathBuilder: IStoragePathBuilder,\n readonly solidRegistry: SolidRegistry,\n readonly repo: SettingRepository,\n readonly moduleMetadataRepo: ModuleMetadataRepository,\n private readonly requestContextService: RequestContextService,\n @InjectRepository(User) private readonly userRepository: Repository<User>,\n ) {\n const encKey = process.env.APP_ENCRYPTION_KEY;\n this.encryptionService = encKey ? new EncryptionService(encKey) : null;\n if (!encKey) this._logger.warn('APP_ENCRYPTION_KEY is not set — encrypted settings will not be decrypted');\n }\n\n private async getSettingsFromDb(): Promise<Setting[]> {\n const settings = await this.repo.find({ relations: ['user'] });\n return settings;\n }\n\n private parseSettingValue(value: string, key: string): any {\n try {\n return JSON.parse(value);\n } catch {\n if (value === 'true' || value === 'false') {\n return value === 'true';\n }\n if (!isNaN(Number(value)) && value.trim() !== '') {\n return Number(value);\n }\n if (!this.arrayKeysToSkip.has(key) && value.includes(',')) {\n return value.split(',').map(item => item.trim());\n }\n return value;\n }\n }\n\n /**\n * Reads all registered providers and gathers settings from across the running platform.\n * This is the superset of all possible settings. \n * @returns \n */\n private getAllSettingsFromProviders(): SettingDefinition[] {\n // get all settings from registry \n const allSettingsProviders = this.solidRegistry.getSettingsProviders();\n const settings: SettingDefinition[] = [];\n const seenKeys = new Map<string, { setting: SettingDefinition; providerName?: string }>();\n for (const wrapper of allSettingsProviders) {\n const instance = wrapper.instance as ISettingsProvider;\n // if (!instance?.getSettings) continue;\n for (const setting of instance.getSettings()) {\n const existing = seenKeys.get(setting.key);\n if (existing) {\n throw new Error(\n `Duplicate setting key detected: ${setting.key}. ` +\n `First: ${JSON.stringify(existing.setting)} from provider: ${existing.providerName ?? \"unknown\"}. ` +\n `Second: ${JSON.stringify(setting)} from provider: ${wrapper.name ?? \"unknown\"}.`\n );\n }\n seenKeys.set(setting.key, { setting, providerName: wrapper.name });\n settings.push(setting);\n }\n }\n\n return settings\n }\n\n /**\n * public method that gets all settings in the system, this includes settings from solid-core and any consuming projects.\n * this means that the settings returned are the ones provided by ISettingsProvider, merged with values if any from the database. \n * \n * @returns \n */\n getAllSettings(): SettingDefinition[] {\n return this.settings;\n }\n\n async updateSettingsCache(): Promise<void> {\n this._logger.debug(`updating settings cache...`);\n const settingsFromDb = await this.getSettingsFromDb();\n const settingsFromProviders = this.getAllSettingsFromProviders();\n const settingsFromDbByKey = new Map(settingsFromDb.map(setting => [setting.key, setting]));\n\n this.settings = settingsFromProviders.map(setting => {\n const settingFromDb = settingsFromDbByKey.get(setting.key);\n const valueFromDb = settingFromDb?.value;\n if (settingFromDb?.key && valueFromDb !== undefined && valueFromDb !== null) {\n let rawValue = valueFromDb;\n if (settingFromDb.encrypted && this.encryptionService) {\n try {\n rawValue = this.encryptionService.decrypt(rawValue);\n } catch {\n this._logger.warn(`Failed to decrypt setting \"${setting.key}\" — using raw value`);\n }\n }\n const parsedValue = typeof rawValue === 'string' ? this.parseSettingValue(rawValue, settingFromDb.key) : rawValue;\n return { ...setting, value: parsedValue };\n }\n return setting;\n });\n\n // Also keep a key vs SettingDefinition map...\n this.settingsByKey = new Map(this.settings.map(setting => [setting.key, setting]));\n }\n\n private isDisallowedSettingKey(key: string, settingLevelsToDisallow: SettingLevel[]): boolean {\n if (!key) {\n return false;\n }\n const setting = this.settingsByKey.get(key);\n // return setting ? [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly].includes(setting.level) : false;\n return setting ? settingLevelsToDisallow.includes(setting.level) : false;\n }\n\n /**\n * 1. \n * This method will seed (insert only) settings that are introduced in code but do not already exist in the database. \n * Also this method only deals with settings with level system-admin-editable & internal-user.\n */\n async seedSystemAdminEditableAndAboveSettings(): Promise<void> {\n // Seed only settings with level system-admin-editable & internal-user, \n // so basically settings which are either system-admin-editable and above.\n const saEditableAndAbove = this.getAllSettingsFromProviders().filter(i => [SettingLevel.SystemAdminEditable, SettingLevel.InternalUser].includes(i.level));\n\n // Get hold of the current values from the database.\n const existingSettingsFromDb: Setting[] = await this.getSettingsFromDb();\n\n // const existingKeysFromDb = new Set(existingSettingsFromDb.map(s => s.key));\n const existingSettingsFromDbByKey = new Map(existingSettingsFromDb.map(setting => [setting.key, setting]));\n const settingsToMutate: Setting[] = [];\n // const settingsToUpdate: Setting[] = [];\n\n for (const { key, value, level, moduleName, encrypted } of saEditableAndAbove) {\n const moduleMetadata = await this.moduleMetadataRepo.findOneBy({ name: moduleName });\n if (!existingSettingsFromDbByKey.has(key)) {\n const setting = new Setting();\n setting.key = key;\n setting.level = level;\n setting.encrypted = !!encrypted;\n if (moduleMetadata)\n setting.moduleMetadata = moduleMetadata;\n\n let rawValue: string | null;\n if (typeof value === 'boolean') {\n rawValue = value.toString();\n } else if (Array.isArray(value)) {\n rawValue = value.join(',');\n } else if (value === null || value === undefined) {\n rawValue = null;\n } else {\n rawValue = String(value);\n }\n\n if (encrypted && this.encryptionService && rawValue !== null) {\n rawValue = this.encryptionService.encrypt(rawValue);\n }\n setting.value = rawValue;\n\n settingsToMutate.push(setting);\n }\n else {\n const setting = existingSettingsFromDbByKey.get(key);\n setting.level = level;\n setting.encrypted = !!encrypted;\n if (moduleMetadata)\n setting.moduleMetadata = moduleMetadata;\n settingsToMutate.push(setting);\n }\n }\n\n if (settingsToMutate.length > 0) {\n await this.repo.save(settingsToMutate);\n }\n // if (settingsToUpdate.length > 0) {\n // await this.repo.save(settingsToUpdate);\n // }\n }\n\n /**\n * 2. \n * Method used from the solid-core-ui to fetch available settings. \n * Here we are returning settings other than system-env.\n * \n * @returns \n */\n async getSystemAdminReadonlyAndAboveSettings(): Promise<Record<any, any>> {\n const finalSettings: Record<any, any> = {};\n const systemAdminReadonlyAndAboveSettings = this.settings.filter(i => i.level !== \"system-env\");\n for (const setting of systemAdminReadonlyAndAboveSettings) {\n finalSettings[setting.key] = setting.value;\n }\n return finalSettings;\n }\n\n /**\n * 3. \n * This method updates settings from the admin user interface. \n * Most likely settings with level system-admin-editable & internal-user are the ones that will get modified here. \n * \n * @param settings \n * @param uploadedFiles \n * @returns \n */\n async updateSettings(settings: CreateSettingDto[] = [], uploadedFiles: Array<Express.Multer.File> = []): Promise<Setting[]> {\n const activeUser = this.requestContextService.getActiveUser();\n const userId = activeUser?.sub;\n\n const restrictedKeys = new Set<string>();\n\n settings.forEach(setting => {\n if (this.isDisallowedSettingKey(setting.key, [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly])) {\n restrictedKeys.add(setting.key);\n }\n });\n uploadedFiles.forEach(file => {\n if (this.isDisallowedSettingKey(file.fieldname, [SettingLevel.SystemEnv, SettingLevel.SystemAdminReadonly])) {\n restrictedKeys.add(file.fieldname);\n }\n });\n\n if (restrictedKeys.size > 0) {\n throw new BadRequestException(`${ERROR_MESSAGES.FORBIDDEN}: Settings ${Array.from(restrictedKeys).join(', ')} cannot be modified.`);\n }\n\n // const existingSettings = await this.repo.find();\n const existingSettings: Setting[] = await this.getSettingsFromDb();\n\n const settingsToUpdate: Setting[] = [];\n const settingsToCreate: Setting[] = [];\n\n let user: User | null = null;\n const hasUserSettings = settings.some(dto => dto.type === 'user');\n if (hasUserSettings && userId) {\n user = await this.userRepository.findOne({ where: { id: userId } });\n }\n\n // Handle uploaded files\n if (uploadedFiles?.length) {\n for (const file of uploadedFiles) {\n const settingKey = file.fieldname;\n const relativeFileName = `${file.filename}-${file.originalname}`;\n\n // Read file from local disk (where Multer stores uploads) and write to storage\n // The path builder constructs the provider-appropriate storage path\n const fileContent = await fsPromises.readFile(file.path);\n const storagePath = this.pathBuilder.build(relativeFileName);\n const fileUrl = await this.fileService.write(storagePath, fileContent, { contentType: file.mimetype });\n // Delete the temp file from local disk\n await fsPromises.unlink(file.path);\n\n const matchedDto = settings.find(dto => dto.key === settingKey);\n const settingType = matchedDto?.type ?? 'system';\n\n const existingSetting = existingSettings.find(s => s.key === settingKey);\n if (existingSetting) {\n existingSetting.value = fileUrl;\n existingSetting.type = settingType;\n settingsToUpdate.push(existingSetting);\n } else {\n const newSetting = new Setting();\n newSetting.key = settingKey;\n newSetting.value = fileUrl;\n newSetting.type = settingType;\n\n if (settingType === 'user' && user) {\n newSetting.user = user;\n }\n\n settingsToCreate.push(newSetting);\n }\n }\n }\n\n // Handle non-file settings\n for (const settingDto of settings) {\n if (uploadedFiles?.some(file => file.fieldname === settingDto.key)) {\n continue; // skip if already handled via file\n }\n\n const key = settingDto.key;\n const rawValue = settingDto.value;\n let value = rawValue === null || rawValue === undefined ? null : String(rawValue);\n\n const settingType = settingDto.type ?? 'system';\n const definition = this.settingsByKey.get(key);\n const shouldEncrypt = !!definition?.encrypted && this.encryptionService !== null && value !== null;\n\n if (shouldEncrypt) {\n value = this.encryptionService.encrypt(value);\n }\n\n const existingSetting = existingSettings.find(s => s.key === key);\n if (existingSetting) {\n existingSetting.value = value;\n existingSetting.type = settingType;\n existingSetting.encrypted = shouldEncrypt;\n settingsToUpdate.push(existingSetting);\n } else {\n const newSetting = new Setting();\n newSetting.key = key;\n newSetting.value = value;\n newSetting.type = settingType;\n newSetting.encrypted = shouldEncrypt;\n\n if (settingType === 'user' && user) {\n newSetting.user = user;\n }\n\n settingsToCreate.push(newSetting);\n }\n }\n\n if (settingsToUpdate.length > 0) {\n await this.repo.save(settingsToUpdate);\n }\n\n if (settingsToCreate.length > 0) {\n await this.repo.save(settingsToCreate);\n }\n await this.updateSettingsCache();\n\n return [...settingsToUpdate, ...settingsToCreate];\n }\n\n /**\n * 4. \n * @param settingKey \n * @returns \n */\n getConfigValue<T = never>(settingKey: NoInfer<T>) {\n const cachedSetting = this.settingsByKey.get(settingKey as string);\n if (cachedSetting) {\n return cachedSetting.value;\n }\n\n return null;\n\n // const cachedSetting = this.settings.find(setting => setting.key === settingKey);\n // if (cachedSetting) {\n // return cachedSetting.value;\n // }\n\n // // This is probably not needed at all, but leaving it here as a backup for scenarios like \n // // if getConfigValue<SolidCoreSetting>() is called before onApplicationBootstrap() runs or if the cache refresh fails. \n // const getAllSettings = this.getAllSettingsFromProviders();\n // const settingValue = getAllSettings.find(i => (i.key == settingKey))\n // return settingValue?.value;\n }\n\n async getMcpUrl(getMcpUrlDto: GetMcpUrlDto, solidRequestContext: any = {}): Promise<any> {\n\n const { showHeader, inListView } = getMcpUrlDto;\n\n const mcpEnabled = this.getConfigValue<SolidCoreSetting>('mcpEnabled');\n if (mcpEnabled === 'false' || mcpEnabled === false) {\n throw new ForbiddenException(ERROR_MESSAGES.FORBIDDEN);\n }\n\n if (solidRequestContext.activeUser) {\n const permissionNames = [\"SettingController.getMcpUrl\"];\n const matchingPermssions = solidRequestContext.activeUser.permissions.filter((p: any) => permissionNames.includes(p));\n const hasPermission = matchingPermssions.length > 0;\n if (!hasPermission) {\n throw new BadRequestException(ERROR_MESSAGES.FORBIDDEN);\n }\n }\n const apiKey = this.getConfigValue<SolidCoreSetting>('mcpApiKey');\n const userId = solidRequestContext.activeUser.sub;\n const mcpServerUrl = this.getConfigValue<SolidCoreSetting>('mcpServerUrl');\n return { mcpUrl: `${mcpServerUrl}/static/frontend.html?solidx-mcp-api-key=${apiKey}&solidx-user-id=${userId}&solidx-show-header=${showHeader}&solidx-in-list-view=${inListView}` };\n }\n\n}\n"]}
|
|
@@ -126,6 +126,12 @@ declare const getSolidCoreSettings: (isProd: boolean) => [{
|
|
|
126
126
|
readonly key: "solidXGenAiCodeBuilderConfig";
|
|
127
127
|
readonly value: string;
|
|
128
128
|
readonly level: SettingLevel.SystemAdminEditable;
|
|
129
|
+
readonly encrypted: true;
|
|
130
|
+
}, {
|
|
131
|
+
readonly moduleName: "solid-core";
|
|
132
|
+
readonly key: "appEncryptionKey";
|
|
133
|
+
readonly value: string;
|
|
134
|
+
readonly level: SettingLevel.SystemEnv;
|
|
129
135
|
}, {
|
|
130
136
|
readonly moduleName: "solid-core";
|
|
131
137
|
readonly key: "mcpEnabled";
|
|
@@ -679,6 +685,12 @@ export declare class SolidCoreDefaultSettingsProvider implements ISettingsProvid
|
|
|
679
685
|
readonly key: "solidXGenAiCodeBuilderConfig";
|
|
680
686
|
readonly value: string;
|
|
681
687
|
readonly level: SettingLevel.SystemAdminEditable;
|
|
688
|
+
readonly encrypted: true;
|
|
689
|
+
}, {
|
|
690
|
+
readonly moduleName: "solid-core";
|
|
691
|
+
readonly key: "appEncryptionKey";
|
|
692
|
+
readonly value: string;
|
|
693
|
+
readonly level: SettingLevel.SystemEnv;
|
|
682
694
|
}, {
|
|
683
695
|
readonly moduleName: "solid-core";
|
|
684
696
|
readonly key: "mcpEnabled";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-settings-provider.service.d.ts","sourceRoot":"","sources":["../../../src/services/settings/default-settings-provider.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEpF,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,8BAA8B,wBAAwB,CAAC;AAGpE,QAAA,MAAM,oBAAoB,WAAY,OAAO
|
|
1
|
+
{"version":3,"file":"default-settings-provider.service.d.ts","sourceRoot":"","sources":["../../../src/services/settings/default-settings-provider.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIZ"}
|
|
@@ -41,12 +41,13 @@ const getSolidCoreSettings = (isProd) => [
|
|
|
41
41
|
{
|
|
42
42
|
moduleName: "solid-core", key: "solidXGenAiCodeBuilderConfig", value: JSON.stringify({
|
|
43
43
|
models: {
|
|
44
|
-
default: {
|
|
45
|
-
fast: {
|
|
44
|
+
default: { providerId: "", model: "", behavior: { streaming: false, custom: "" } },
|
|
45
|
+
fast: { providerId: "", model: "", behavior: { streaming: false, custom: "" } },
|
|
46
46
|
},
|
|
47
47
|
providers: {},
|
|
48
|
-
}), level: interfaces_1.SettingLevel.SystemAdminEditable
|
|
48
|
+
}), level: interfaces_1.SettingLevel.SystemAdminEditable, encrypted: true
|
|
49
49
|
},
|
|
50
|
+
{ moduleName: "solid-core", key: "appEncryptionKey", value: process.env.APP_ENCRYPTION_KEY, level: interfaces_1.SettingLevel.SystemEnv },
|
|
50
51
|
{ moduleName: "solid-core", key: "mcpEnabled", value: process.env.MCP_ENABLED || false, level: interfaces_1.SettingLevel.SystemAdminReadonly },
|
|
51
52
|
{ moduleName: "solid-core", key: "mcpServerUrl", value: process.env.MCP_SERVER_URL, level: interfaces_1.SettingLevel.SystemAdminReadonly },
|
|
52
53
|
{ moduleName: "solid-core", key: "mcpApiKey", value: process.env.MCP_API_KEY, level: interfaces_1.SettingLevel.SystemEnv },
|