@solidxai/core 0.1.8-beta.7 → 0.1.8-beta.9

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.
@@ -84,6 +84,6 @@ __decorate([
84
84
  __metadata("design:type", String)
85
85
  ], AgentEvent.prototype, "modelUsed", void 0);
86
86
  exports.AgentEvent = AgentEvent = __decorate([
87
- (0, typeorm_1.Entity)({ name: 'ss_agent_events', synchronize: false })
87
+ (0, typeorm_1.Entity)({ name: 'ss_agent_events' })
88
88
  ], AgentEvent);
89
89
  //# sourceMappingURL=agent-event.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-event.entity.js","sourceRoot":"","sources":["../../src/entities/agent-event.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAgD;AAChD,mDAA0D;AAC1D,oEAA8D;AAGvD,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,4BAAY;;;;CAgD3C,CAAA;AAhDY,gCAAU;AAGrB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;6CACM;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAG,CAAC;;8CACO;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACR;AAInB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;6CACM;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,qBAAqB,CAAC,EAAE,CAAC;;6CAC1E;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;2CACzC;AAIhB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACV;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,qBAAqB,CAAC,EAAE,CAAC;;iDACnE;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;8CACtC;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACJ;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;8CACrC;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;wCAC3C;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACP;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACT;qBA/CP,UAAU;IADtB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;GAC3C,UAAU,CAgDtB","sourcesContent":["import { Column, Entity, Index } from 'typeorm';\nimport { CommonEntity } from 'src/entities/common.entity';\nimport { getColumnType } from 'src/helpers/typeorm-db-helper';\n\n@Entity({ name: 'ss_agent_events', synchronize: false })\nexport class AgentEvent extends CommonEntity {\n @Index()\n @Column({ })\n sessionId: string;\n\n @Column({ })\n turnNumber: number;\n\n @Column({ nullable: true })\n stepNumber: number;\n\n @Index()\n @Column({ })\n eventType: string;\n\n @Column({ type: \"simple-json\", nullable: true, ...getColumnType('simpleJsonLargeText') })\n eventData: any;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n content: string;\n\n @Index()\n @Column({ nullable: true })\n toolName: string;\n\n @Column({ type: \"simple-json\", nullable: true, ...getColumnType('simpleJsonLargeText') })\n toolArguments: string;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n toolOutput: string;\n\n @Column({ nullable: true })\n toolReturncode: number;\n\n @Column({ nullable: true, ...getColumnType('decimal') })\n durationMs: number;\n\n @Column({ nullable: true, ...getColumnType('decimal') })\n cost: number;\n\n @Column({ nullable: true })\n inputTokens: number;\n\n @Column({ nullable: true })\n outputTokens: number;\n\n @Column({ nullable: true })\n modelUsed: string;\n}\n"]}
1
+ {"version":3,"file":"agent-event.entity.js","sourceRoot":"","sources":["../../src/entities/agent-event.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAgD;AAChD,mDAA0D;AAC1D,oEAA8D;AAGvD,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,4BAAY;;;;CAgD3C,CAAA;AAhDY,gCAAU;AAGrB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;6CACM;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAG,CAAC;;8CACO;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACR;AAInB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;6CACM;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,qBAAqB,CAAC,EAAE,CAAC;;6CAC1E;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;2CACzC;AAIhB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACV;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,qBAAqB,CAAC,EAAE,CAAC;;iDACnE;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;8CACtC;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACJ;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;8CACrC;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;wCAC3C;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACP;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACT;qBA/CP,UAAU;IADtB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;GACvB,UAAU,CAgDtB","sourcesContent":["import { Column, Entity, Index } from 'typeorm';\nimport { CommonEntity } from 'src/entities/common.entity';\nimport { getColumnType } from 'src/helpers/typeorm-db-helper';\n\n@Entity({ name: 'ss_agent_events' })\nexport class AgentEvent extends CommonEntity {\n @Index()\n @Column({ })\n sessionId: string;\n\n @Column({ })\n turnNumber: number;\n\n @Column({ nullable: true })\n stepNumber: number;\n\n @Index()\n @Column({ })\n eventType: string;\n\n @Column({ type: \"simple-json\", nullable: true, ...getColumnType('simpleJsonLargeText') })\n eventData: any;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n content: string;\n\n @Index()\n @Column({ nullable: true })\n toolName: string;\n\n @Column({ type: \"simple-json\", nullable: true, ...getColumnType('simpleJsonLargeText') })\n toolArguments: string;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n toolOutput: string;\n\n @Column({ nullable: true })\n toolReturncode: number;\n\n @Column({ nullable: true, ...getColumnType('decimal') })\n durationMs: number;\n\n @Column({ nullable: true, ...getColumnType('decimal') })\n cost: number;\n\n @Column({ nullable: true })\n inputTokens: number;\n\n @Column({ nullable: true })\n outputTokens: number;\n\n @Column({ nullable: true })\n modelUsed: string;\n}\n"]}
@@ -64,6 +64,6 @@ __decorate([
64
64
  __metadata("design:type", String)
65
65
  ], AgentSession.prototype, "summary", void 0);
66
66
  exports.AgentSession = AgentSession = __decorate([
67
- (0, typeorm_1.Entity)({ name: 'ss_agent_sessions', synchronize: false })
67
+ (0, typeorm_1.Entity)({ name: 'ss_agent_sessions' })
68
68
  ], AgentSession);
69
69
  //# sourceMappingURL=agent-session.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session.entity.js","sourceRoot":"","sources":["../../src/entities/agent-session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAgD;AAChD,mDAA0D;AAC1D,oEAA8D;AAGvD,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAAY;;;;CAiC7C,CAAA;AAjCY,oCAAY;AAGvB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAG,CAAC;;+CACM;AAIlB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACZ;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;iDACrC;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAG,CAAC;;+CACM;AAIlB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;4CACG;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;+CAClC;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACJ;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;sDACE;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACG;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;6CACzC;uBAhCL,YAAY;IADxB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;GAC7C,YAAY,CAiCxB","sourcesContent":["import { Column, Entity, Index } from 'typeorm';\nimport { CommonEntity } from 'src/entities/common.entity';\nimport { getColumnType } from 'src/helpers/typeorm-db-helper';\n\n@Entity({ name: 'ss_agent_sessions', synchronize: false })\nexport class AgentSession extends CommonEntity {\n @Index({ unique: true })\n @Column({ })\n sessionId: string;\n\n @Index()\n @Column({ nullable: true })\n userId: number;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n projectRoot: string;\n\n @Column({ })\n modelName: string;\n\n @Index()\n @Column({ })\n status: string;\n\n @Column({ default: 0, ...getColumnType('decimal') })\n totalCost: number;\n\n @Column({ default: 0 })\n totalSteps: number;\n\n @Column({ default: 0 })\n totalInputTokens: number;\n\n @Column({ default: 0 })\n totalOutputTokens: number;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n summary: string;\n}\n"]}
1
+ {"version":3,"file":"agent-session.entity.js","sourceRoot":"","sources":["../../src/entities/agent-session.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCAAgD;AAChD,mDAA0D;AAC1D,oEAA8D;AAGvD,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAAY;;;;CAiC7C,CAAA;AAjCY,oCAAY;AAGvB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAG,CAAC;;+CACM;AAIlB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACZ;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;iDACrC;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAG,CAAC;;+CACM;AAIlB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAG,CAAC;;4CACG;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,IAAA,iCAAa,EAAC,SAAS,CAAC,EAAE,CAAC;;+CAClC;AAGlB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACJ;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;sDACE;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACG;AAG1B;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,CAAC;;6CACzC;uBAhCL,YAAY;IADxB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;GACzB,YAAY,CAiCxB","sourcesContent":["import { Column, Entity, Index } from 'typeorm';\nimport { CommonEntity } from 'src/entities/common.entity';\nimport { getColumnType } from 'src/helpers/typeorm-db-helper';\n\n@Entity({ name: 'ss_agent_sessions' })\nexport class AgentSession extends CommonEntity {\n @Index({ unique: true })\n @Column({ })\n sessionId: string;\n\n @Index()\n @Column({ nullable: true })\n userId: number;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n projectRoot: string;\n\n @Column({ })\n modelName: string;\n\n @Index()\n @Column({ })\n status: string;\n\n @Column({ default: 0, ...getColumnType('decimal') })\n totalCost: number;\n\n @Column({ default: 0 })\n totalSteps: number;\n\n @Column({ default: 0 })\n totalInputTokens: number;\n\n @Column({ default: 0 })\n totalOutputTokens: number;\n\n @Column({ nullable: true, ...getColumnType('longText') })\n summary: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sms-template.entity.d.ts","sourceRoot":"","sources":["../../src/entities/sms-template.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,qBACa,WAAY,SAAQ,YAAY;IAGzC,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,MAAM,CAAC;IAEpB,IAAI,EAAE,MAAM,CAAC;IAEb,qBAAqB,EAAE,MAAM,CAAC;IAE9B,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,EAAE,OAAO,CAAQ;IAEvB,IAAI,EAAE,MAAM,CAAC;CAChB"}
1
+ {"version":3,"file":"sms-template.entity.d.ts","sourceRoot":"","sources":["../../src/entities/sms-template.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,qBACa,WAAY,SAAQ,YAAY;IAGzC,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,MAAM,CAAC;IAEpB,IAAI,EAAE,MAAM,CAAC;IAEb,qBAAqB,EAAE,MAAM,CAAC;IAE9B,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,EAAE,OAAO,CAAQ;IAEvB,IAAI,EAAE,MAAM,CAAC;CAChB"}
@@ -13,6 +13,7 @@ exports.SmsTemplate = void 0;
13
13
  const openapi = require("@nestjs/swagger");
14
14
  const common_entity_1 = require("./common.entity");
15
15
  const typeorm_1 = require("typeorm");
16
+ const typeorm_db_helper_1 = require("../helpers/typeorm-db-helper");
16
17
  let SmsTemplate = class SmsTemplate extends common_entity_1.CommonEntity {
17
18
  constructor() {
18
19
  super(...arguments);
@@ -33,7 +34,7 @@ __decorate([
33
34
  __metadata("design:type", String)
34
35
  ], SmsTemplate.prototype, "displayName", void 0);
35
36
  __decorate([
36
- (0, typeorm_1.Column)({ name: "body", type: "varchar", nullable: true }),
37
+ (0, typeorm_1.Column)({ name: "body", ...(0, typeorm_db_helper_1.getColumnType)('longText'), nullable: true }),
37
38
  __metadata("design:type", String)
38
39
  ], SmsTemplate.prototype, "body", void 0);
39
40
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"sms-template.entity.js","sourceRoot":"","sources":["../../src/entities/sms-template.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA0D;AAC1D,qCAAgD;AAGzC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,4BAAY;IAAtC;;QAaH,WAAM,GAAY,IAAI,CAAC;KAG1B;;8UAHqB,IAAI;;CAGzB,CAAA;AAhBY,kCAAW;AAGpB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC;;yCAC5B;AAEb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;gDAC9B;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC7C;AAEb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACd;AAE9B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC5B;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2CACnC;AAEvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC7C;sBAfJ,WAAW;IADvB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,WAAW,CAgBvB","sourcesContent":["import { CommonEntity } from 'src/entities/common.entity';\nimport { Column, Entity, Index } from 'typeorm';\n\n@Entity(\"ss_sms_template\")\nexport class SmsTemplate extends CommonEntity {\n @Index({ unique: true })\n @Column({ name: \"name\", type: \"varchar\"})\n name: string;\n @Column({ name: \"display_name\", type: \"varchar\" })\n displayName: string;\n @Column({ name: \"body\", type: \"varchar\", nullable: true })\n body: string;\n @Column({ type: \"varchar\", nullable: true })\n smsProviderTemplateId: string;\n @Column({ name: \"description\", nullable: true })\n description: string;\n @Column({ name: \"active\", nullable: true, default: true })\n active: boolean = true;\n @Column({ name: \"type\", type: \"varchar\", nullable: true })\n type: string;\n}"]}
1
+ {"version":3,"file":"sms-template.entity.js","sourceRoot":"","sources":["../../src/entities/sms-template.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA0D;AAC1D,qCAAgD;AAChD,oEAA8D;AAGvD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,4BAAY;IAAtC;;QAaH,WAAM,GAAY,IAAI,CAAC;KAG1B;;8UAHqB,IAAI;;CAGzB,CAAA;AAhBY,kCAAW;AAGpB;IAFC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvB,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;yCAC7B;AAEb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;gDAC9B;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAA,iCAAa,EAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC1D;AAEb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACd;AAE9B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC5B;AAEpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2CACnC;AAEvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC7C;sBAfJ,WAAW;IADvB,IAAA,gBAAM,EAAC,iBAAiB,CAAC;GACb,WAAW,CAgBvB","sourcesContent":["import { CommonEntity } from 'src/entities/common.entity';\nimport { Column, Entity, Index } from 'typeorm';\nimport { getColumnType } from 'src/helpers/typeorm-db-helper';\n\n@Entity(\"ss_sms_template\")\nexport class SmsTemplate extends CommonEntity {\n @Index({ unique: true })\n @Column({ name: \"name\", type: \"varchar\" })\n name: string;\n @Column({ name: \"display_name\", type: \"varchar\" })\n displayName: string;\n @Column({ name: \"body\", ...getColumnType('longText'), nullable: true })\n body: string;\n @Column({ type: \"varchar\", nullable: true })\n smsProviderTemplateId: string;\n @Column({ name: \"description\", nullable: true })\n description: string;\n @Column({ name: \"active\", nullable: true, default: true })\n active: boolean = true;\n @Column({ name: \"type\", type: \"varchar\", nullable: true })\n type: string;\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAyB7H,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IAEpC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAEtC,0BAA0B,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC/D;AAcD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACpC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAgGf;AAgBD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,CAwCf"}
1
+ {"version":3,"file":"bootstrap.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAyB7H,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IAEpC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAEtC,0BAA0B,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC/D;AAcD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACpC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CA+Gf;AAgBD,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,CAwCf"}
@@ -48,6 +48,17 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
48
48
  const server = app.getHttpAdapter().getInstance();
49
49
  server.get('/', (_req, res) => res.status(200).send('SOLID OK'));
50
50
  app.use((0, helmet_1.default)((0, security_helper_1.buildDefaultSecurityHeaderOptions)()));
51
+ const isSwaggerPath = (path) => path === '/docs' ||
52
+ path === '/docs/' ||
53
+ path.startsWith('/docs/') ||
54
+ path === '/docs-json' ||
55
+ path === '/docs-yaml';
56
+ app.use((req, res, next) => {
57
+ if (isSwaggerPath(req.path)) {
58
+ res.removeHeader('Content-Security-Policy');
59
+ }
60
+ next();
61
+ });
51
62
  app.use((_req, res, next) => {
52
63
  res.setHeader('Permissions-Policy', (0, security_helper_1.buildPermissionsPolicyHeader)(permissionsPolicyOverrides));
53
64
  next();
@@ -72,7 +83,7 @@ async function bootstrapSolidApp(appModuleFactory, options = {}) {
72
83
  transformOptions: { enableImplicitConversion: true },
73
84
  }));
74
85
  if (swagger !== false) {
75
- const { title = 'Solid Starters', description = 'Solid Starters API', version = '1.0' } = swagger;
86
+ const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;
76
87
  const swaggerConfig = new swagger_1.DocumentBuilder()
77
88
  .setTitle(title)
78
89
  .setDescription(description)
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAgEA,8CAmGC;AAgBD,8CA0CC;AA7ND,2CAAgD;AAChD,uCAA2C;AAC3C,6CAAiE;AAEjE,oDAA4B;AAC5B,4CAAoB;AACpB,2BAAgC;AAChC,+BAA+B;AAC/B,+CAA4D;AAC5D,mDAAgD;AAChD,yFAAoF;AACpF,+CAAwD;AACxD,uDAA6H;AAC7H,6DAAuD;AAIvD,SAAS,6BAA6B;IACpC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACnD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAGH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YAClI,OAAO;QACT,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AA+BM,KAAK,UAAU,iBAAiB,CACrC,gBAAoC,EACpC,UAAiC,EAAE;IAEnC,6BAA6B,EAAE,CAAC;IAEhC,MAA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I,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAGvC,MAAM,GAAG,GAAG,MAAM,+BAAc,CAAC,oBAAoB,CAAC,SAAS,EAAE;QAC/D,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;KACjF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,+BAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { ValidationPipe } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {} } = options;\n\n const appModule = await appModuleFactory();\n const app = await NestFactory.create(appModule);\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions()));\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n // Winston logger\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = 'Solid Starters', description = 'Solid Starters API', version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(new WrapResponseInterceptor());\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n await app.listen(port);\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
1
+ {"version":3,"file":"bootstrap.helper.js","sourceRoot":"","sources":["../../src/helpers/bootstrap.helper.ts"],"names":[],"mappings":";;;;;AAgEA,8CAkHC;AAgBD,8CA0CC;AA5OD,2CAAgD;AAChD,uCAA2C;AAC3C,6CAAiE;AAEjE,oDAA4B;AAC5B,4CAAoB;AACpB,2BAAgC;AAChC,+BAA+B;AAC/B,+CAA4D;AAC5D,mDAAgD;AAChD,yFAAoF;AACpF,+CAAwD;AACxD,uDAA6H;AAC7H,6DAAuD;AAIv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AAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnF,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAGvC,MAAM,GAAG,GAAG,MAAM,+BAAc,CAAC,oBAAoB,CAAC,SAAS,EAAE;QAC/D,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;KACjF,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,+BAAc,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { ValidationPipe } from '@nestjs/common';\nimport { NestFactory } from '@nestjs/core';\nimport { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';\nimport { NextFunction, Request, Response } from 'express';\nimport helmet from 'helmet';\nimport qs from 'qs';\nimport { existsSync } from 'fs';\nimport { resolve } from 'path';\nimport { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';\nimport { CommandFactory } from 'nest-commander';\nimport { WrapResponseInterceptor } from '../interceptors/wrap-response.interceptor';\nimport { buildDefaultCorsOptions } from './cors.helper';\nimport { buildDefaultSecurityHeaderOptions, buildPermissionsPolicyHeader, PermissionsPolicyConfig } from './security.helper';\nimport { parseBooleanEnv } from './environment.helper';\n\n// ---- Shared process handlers ----\n\nfunction registerGlobalProcessHandlers() {\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n });\n\n process.on('uncaughtException', (err) => {\n console.error('Uncaught Exception thrown:', err);\n });\n\n // Suppress pg deprecation warning caused by TypeORM's internal query scheduling\n process.on('warning', (warning) => {\n if (warning.name === 'DeprecationWarning' && (warning.message.includes('client.query()') || warning.message.includes('punycode'))) {\n return;\n }\n console.warn(warning);\n });\n}\n\n// ---- HTTP server bootstrap ----\n\nexport interface SolidSwaggerOptions {\n title?: string;\n description?: string;\n version?: string;\n}\n\nexport interface SolidBootstrapOptions {\n /** Global API prefix. Defaults to 'api'. Set to '' to disable. */\n globalPrefix?: string;\n /** Swagger configuration. Set to false to disable Swagger entirely. */\n swagger?: SolidSwaggerOptions | false;\n /** Permissions-Policy header overrides (merged with defaults). */\n permissionsPolicyOverrides?: Partial<PermissionsPolicyConfig>;\n}\n\n/**\n * Bootstraps a SolidX NestJS HTTP application with sensible defaults:\n * security headers, CORS, Winston logger, ValidationPipe,\n * WrapResponseInterceptor, qs deep query parsing, Swagger, and the\n * pg BIGINT type parser.\n *\n * @example\n * // main.ts\n * bootstrapSolidApp(() => AppModule.forRoot(), {\n * swagger: { title: 'My API', description: 'My API description' },\n * });\n */\nexport async function bootstrapSolidApp(\n appModuleFactory: () => Promise<any>,\n options: SolidBootstrapOptions = {},\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n const { globalPrefix = 'api', swagger = {}, permissionsPolicyOverrides = {} } = options;\n\n const appModule = await appModuleFactory();\n const app = await NestFactory.create(appModule);\n\n const apiEnabled = parseBooleanEnv('API_ENABLED', true);\n\n if (!apiEnabled) {\n await app.init();\n app\n .get(WINSTON_MODULE_NEST_PROVIDER)\n .log('API server disabled via API_ENABLED=false. Skipping HTTP listen.', 'Bootstrap');\n return;\n }\n\n // Health check at root path\n const server = app.getHttpAdapter().getInstance();\n server.get('/', (_req, res) => res.status(200).send('SOLID OK'));\n\n // Security headers\n app.use(helmet(buildDefaultSecurityHeaderOptions()));\n\n // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.\n const isSwaggerPath = (path: string) =>\n path === '/docs' ||\n path === '/docs/' ||\n path.startsWith('/docs/') ||\n path === '/docs-json' ||\n path === '/docs-yaml';\n\n app.use((req: Request, res: Response, next: NextFunction) => {\n if (isSwaggerPath(req.path)) {\n res.removeHeader('Content-Security-Policy');\n }\n next();\n });\n\n // Permissions-Policy header\n app.use((_req: Request, res: Response, next: NextFunction) => {\n res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));\n next();\n });\n\n // Winston logger\n app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n\n const port = process.env.PORT || 3000;\n\n if (globalPrefix) {\n app.setGlobalPrefix(globalPrefix);\n }\n\n // qs-based deep query parsing (dot notation, nested objects, arrays)\n app.use((req: Request, _res: Response, next: NextFunction) => {\n if (req.query) {\n req.query = qs.parse(req.url.split('?')[1], {\n allowDots: true,\n depth: 20,\n arrayLimit: 100,\n });\n }\n next();\n });\n\n // Global ValidationPipe\n app.useGlobalPipes(\n new ValidationPipe({\n transform: true,\n transformOptions: { enableImplicitConversion: true },\n }),\n );\n\n // Swagger\n if (swagger !== false) {\n const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;\n const swaggerConfig = new DocumentBuilder()\n .setTitle(title)\n .setDescription(description)\n .setVersion(version)\n .setExternalDoc('Postman Collection', '/docs-json')\n .addBearerAuth(\n {\n description: 'Please enter token in following format: Bearer <JWT>',\n name: 'Authorization',\n bearerFormat: 'Bearer',\n scheme: 'Bearer',\n type: 'http',\n in: 'Header',\n },\n 'jwt',\n )\n .build();\n const document = SwaggerModule.createDocument(app, swaggerConfig);\n SwaggerModule.setup('/docs', app, document);\n }\n\n // Global interceptor\n app.useGlobalInterceptors(new WrapResponseInterceptor());\n\n // CORS\n app.enableCors(buildDefaultCorsOptions());\n\n // Fix pg returning BIGINT columns as strings\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const types = require('pg').types;\n types.setTypeParser(types.builtins.INT8, (val: string) => parseInt(val));\n\n await app.listen(port);\n}\n\n// ---- CLI bootstrap ----\n\n/**\n * Bootstraps a SolidX NestJS CLI application using nest-commander.\n * Handles verbose flag stripping, project root validation, and clean process exit.\n *\n * @example\n * // main-cli.ts\n * #!/usr/bin/env node\n * import { bootstrapSolidCli } from '@solidxai/core';\n * import { AppModule } from './app.module';\n *\n * bootstrapSolidCli(() => AppModule.forRoot());\n */\nexport async function bootstrapSolidCli(\n appModuleFactory: () => Promise<any>,\n): Promise<void> {\n registerGlobalProcessHandlers();\n\n process.on('exit', (code) => {\n if (code !== 0) {\n console.error(`Exiting with error status code: ${code}`);\n }\n });\n\n // Validate that cwd is a valid Solid API project\n const packageJsonPath = resolve(process.cwd(), 'package.json');\n if (!existsSync(packageJsonPath)) {\n console.error('Does not seem to be a valid solid-api project.');\n console.error('Exit reason: missing package.json in the current directory.');\n process.exit(1);\n }\n\n // Strip --verbose / -v before nest-commander processes argv\n const showLogs = process.argv.includes('--verbose') || process.argv.includes('-v');\n for (const flag of ['--verbose', '-v']) {\n const idx = process.argv.indexOf(flag);\n if (idx !== -1) process.argv.splice(idx, 1);\n }\n\n const appModule = await appModuleFactory();\n process.env.SOLID_CLI_RUNNING = 'true';\n\n // @ts-ignore\n const app = await CommandFactory.createWithoutRunning(appModule, {\n logger: showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : false,\n });\n\n try {\n await CommandFactory.runApplication(app);\n } catch (e) {\n console.error('CLI exited abruptly due to an error:', e);\n process.exit(1);\n }\n\n process.exit(0);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionDynamicFieldCrudManager.d.ts","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAsB,yBAAyB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAElH,MAAM,WAAW,4BAA4B;IACzC,wBAAwB,EAAE,MAAM,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,4BAA4B,EAAE,yBAAyB,CAAC;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;CAC7C;AAED,qBAAa,gCAAiC,YAAW,gBAAgB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,4BAA4B;IAG5D,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAoCpD,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAUhB,sBAAsB;IAWpC,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG;IAKjC,OAAO,CAAC,yBAAyB;YAWnB,qBAAqB;IAkBnC,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,yBAAyB;CAGpC"}
1
+ {"version":3,"file":"SelectionDynamicFieldCrudManager.d.ts","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAsB,yBAAyB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAElH,MAAM,WAAW,4BAA4B;IACzC,wBAAwB,EAAE,MAAM,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,4BAA4B,EAAE,yBAAyB,CAAC;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;CAC7C;AAED,qBAAa,gCAAiC,YAAW,gBAAgB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,4BAA4B;IAG5D,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAoCpD,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAUhB,sBAAsB;IAWpC,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG;IAKjC,OAAO,CAAC,yBAAyB;YAWnB,qBAAqB;IAkBnC,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,yBAAyB;CAGpC"}
@@ -98,14 +98,23 @@ class SelectionDynamicFieldCrudManager {
98
98
  }
99
99
  }
100
100
  providerInstance(selectionDynamicProvider) {
101
- const provider = this.options.discoveryService
102
- .getProviders()
103
- .filter((provider) => provider.name === selectionDynamicProvider)
104
- .pop();
105
- if (!provider) {
101
+ const providers = this.options.discoveryService.getProviders();
102
+ const byToken = providers.find((p) => p.name === selectionDynamicProvider);
103
+ if (byToken) {
104
+ return byToken.instance;
105
+ }
106
+ const byName = providers.find((p) => {
107
+ try {
108
+ return typeof p.instance?.name === 'function' && p.instance.name() === selectionDynamicProvider;
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ });
114
+ if (!byName) {
106
115
  throw new Error(`Provider for ${selectionDynamicProvider} not found`);
107
116
  }
108
- return provider.instance;
117
+ return byName.instance;
109
118
  }
110
119
  isApplyRequiredValidation() {
111
120
  return this.options.required;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionDynamicFieldCrudManager.js","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts"],"names":[],"mappings":";;;AACA,qDAAuE;AACvE,oFAAwE;AAaxE,MAAa,gCAAgC;IAEzC,YAA6B,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAClE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAQ;QACnB,MAAM,UAAU,GAAQ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC;QAClD,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAE1D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBACtB,OAAO;oBACH;wBACI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;wBAC7B,KAAK,EAAE,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,wBAAwB;qBAClE;iBACJ,CAAC;YACN,CAAC;YAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;YAEjC,IAAI,IAAI,CAAC,yBAAyB,EAAE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1D,OAAO;oBACH;wBACI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;wBAC7B,KAAK,EAAE,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,cAAc;qBACxD;iBACJ,CAAC;YACN,CAAC;YAGD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM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C,OAAO,CAAC,QAAQ,CAAC;IACjC,CAAC;CACJ;AAhID,4EAgIC","sourcesContent":["import { DiscoveryService } from \"@nestjs/core\";\nimport { isEmpty, isInt, isNotEmpty, isString } from \"class-validator\";\nimport { SelectionValueType } from \"src/dtos/create-field-metadata.dto\";\nimport { FieldCrudManager, ISelectionProvider, ISelectionProviderContext, ValidationError } from \"src/interfaces\";\n\nexport interface SelectionDynamicFieldOptions {\n selectionDynamicProvider: string;\n selectionValueType: SelectionValueType;\n required: boolean | undefined | null;\n selectionDynamicProviderCtxt: ISelectionProviderContext;\n fieldName: string;\n discoveryService: DiscoveryService;\n isMultiSelect: boolean | undefined | null;\n}\n\nexport class SelectionDynamicFieldCrudManager implements FieldCrudManager {\n\n constructor(private readonly options: SelectionDynamicFieldOptions) {\n }\n\n async validate(dto: any): Promise<ValidationError[]> {\n const fieldValue: any = dto[this.options.fieldName];\n // return this.applyValidations(fieldValue);\n const isMultiSelect = this.options?.isMultiSelect;\n if (isMultiSelect && fieldValue) {\n const arrayCheck = this.parseAndValidateArray(fieldValue);\n\n if (!arrayCheck.isValid) {\n return [\n {\n field: this.options.fieldName,\n error: `Field: ${this.options.fieldName} must be a valid array`,\n },\n ];\n }\n\n const values = arrayCheck.values;\n\n if (this.isApplyRequiredValidation() && values.length === 0) {\n return [\n {\n field: this.options.fieldName,\n error: `Field: ${this.options.fieldName} is required`,\n },\n ];\n }\n\n // Apply validations to each value\n const allErrors = await Promise.all(values.map((val) => this.applyValidations(val)));\n return allErrors.flat();\n } else {\n // For non-multi-select, apply validations to the single field value\n return this.applyValidations(fieldValue);\n }\n }\n\n private parseAndValidateArray(fieldValue: any): { isValid: boolean; values: any[] } {\n if (Array.isArray(fieldValue)) {\n return { isValid: true, values: fieldValue };\n }\n\n try {\n const parsed = typeof fieldValue === 'string' ? JSON.parse(fieldValue) : null;\n if (Array.isArray(parsed)) {\n return { isValid: true, values: parsed };\n }\n } catch {\n // fall through\n }\n\n return { isValid: false, values: [] };\n }\n\n\n private async applyValidations(fieldValue: any): Promise<ValidationError[]> {\n const errors: ValidationError[] = [];\n this.isApplyRequiredValidation() && isEmpty(fieldValue) ? errors.push({ field: this.options.fieldName, error: `Field: ${this.options.fieldName} is required` }) : \"no errors\";\n if (isNotEmpty(fieldValue)) {\n const formatErrors = await this.applyFormatValidations(fieldValue);\n errors.push(...formatErrors);\n }\n return errors;\n }\n\n private async applyFormatValidations(fieldValue: any): Promise<ValidationError[]> {\n const errors: ValidationError[] = [];\n !this.isValidSelectionValueType(fieldValue, this.options.selectionValueType) ? errors.push({ field: this.options.fieldName, error: 'Field value type is invalid' }) : \"no errors\";\n const ctxt = this.options.selectionDynamicProviderCtxt;\n if (ctxt.validateOnSave !== false) {\n const _isValidSelectionValue = await this.isValidSelectionValue(fieldValue, this.options.selectionDynamicProvider, ctxt);\n !_isValidSelectionValue ? errors.push({ field: this.options.fieldName, error: 'Field value is invalid' }) : \"no errors\";\n }\n return errors;\n }\n\n transformForCreate(dto: any): any {\n return dto;\n }\n\n // Validation to be applied\n private isValidSelectionValueType(fieldValue: any, selectionValueType: SelectionValueType): boolean {\n switch (selectionValueType) {\n case SelectionValueType.string:\n return isString(fieldValue);\n case SelectionValueType.int:\n return isInt(fieldValue);\n default:\n throw new Error(`Validation for selection value type ${selectionValueType} is not implemented`);\n }\n }\n\n private async isValidSelectionValue(fieldValue: any, selectionDynamicProvider: string, ctxt: ISelectionProviderContext): Promise<boolean> {\n const providerInstance = this.providerInstance<any>(selectionDynamicProvider);\n try {\n // Use the value method first\n const valueOption = await providerInstance.value(fieldValue, ctxt);\n if (valueOption && valueOption.value === fieldValue) {\n return true;\n }\n return false;\n }\n catch (error) {\n // Use the values method as a fallback, if the value method is not implemented\n const values = await providerInstance.values('', ctxt);\n const isValid = values.some(v => v.value === fieldValue);\n return isValid;\n }\n }\n\n private providerInstance<T extends ISelectionProviderContext>(selectionDynamicProvider: string): ISelectionProvider<T> {\n const provider = this.options.discoveryService\n .getProviders()\n .filter((provider) => provider.name === selectionDynamicProvider)\n .pop();\n if (!provider) {\n throw new Error(`Provider for ${selectionDynamicProvider} not found`);\n }\n return provider.instance as ISelectionProvider<T>;\n }\n\n private isApplyRequiredValidation(): boolean {\n return this.options.required;\n }\n}"]}
1
+ {"version":3,"file":"SelectionDynamicFieldCrudManager.js","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/SelectionDynamicFieldCrudManager.ts"],"names":[],"mappings":";;;AACA,qDAAuE;AACvE,oFAAwE;AAaxE,MAAa,gCAAgC;IAEzC,YAA6B,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAClE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAQ;QACnB,MAAM,UAAU,GAAQ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC;QAClD,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAE1D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBACtB,OAAO;oBACH;wBACI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;wBAC7B,KAAK,EAAE,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,wBAAwB;qBAClE;iBACJ,CAAC;YACN,CAAC;YAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;YAEjC,IAAI,IAAI,CAAC,yBAAyB,EAAE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1D,OAAO;oBACH;wBACI,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;wBAC7B,KAAK,EAAE,UAAU,IAAI,CAAC,OAAO,CAAC,SAAS,cAAc;qBACxD;iBACJ,CAAC;YACN,CAAC;YAGD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GA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BACD,OAAO,OAAO,CAAC,CAAC,QAAQ,EAAE,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,wBAAwB,CAAC;YACpG,CAAC;YAAC,MAAM,CAAC;gBACL,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,gBAAgB,wBAAwB,YAAY,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,MAAM,CAAC,QAAiC,CAAC;IACpD,CAAC;IAEO,yBAAyB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACjC,CAAC;CACJ;AA3ID,4EA2IC","sourcesContent":["import { DiscoveryService } from \"@nestjs/core\";\nimport { isEmpty, isInt, isNotEmpty, isString } from \"class-validator\";\nimport { SelectionValueType } from \"src/dtos/create-field-metadata.dto\";\nimport { FieldCrudManager, ISelectionProvider, ISelectionProviderContext, ValidationError } from \"src/interfaces\";\n\nexport interface SelectionDynamicFieldOptions {\n selectionDynamicProvider: string;\n selectionValueType: SelectionValueType;\n required: boolean | undefined | null;\n selectionDynamicProviderCtxt: ISelectionProviderContext;\n fieldName: string;\n discoveryService: DiscoveryService;\n isMultiSelect: boolean | undefined | null;\n}\n\nexport class SelectionDynamicFieldCrudManager implements FieldCrudManager {\n\n constructor(private readonly options: SelectionDynamicFieldOptions) {\n }\n\n async validate(dto: any): Promise<ValidationError[]> {\n const fieldValue: any = dto[this.options.fieldName];\n // return this.applyValidations(fieldValue);\n const isMultiSelect = this.options?.isMultiSelect;\n if (isMultiSelect && fieldValue) {\n const arrayCheck = this.parseAndValidateArray(fieldValue);\n\n if (!arrayCheck.isValid) {\n return [\n {\n field: this.options.fieldName,\n error: `Field: ${this.options.fieldName} must be a valid array`,\n },\n ];\n }\n\n const values = arrayCheck.values;\n\n if (this.isApplyRequiredValidation() && values.length === 0) {\n return [\n {\n field: this.options.fieldName,\n error: `Field: ${this.options.fieldName} is required`,\n },\n ];\n }\n\n // Apply validations to each value\n const allErrors = await Promise.all(values.map((val) => this.applyValidations(val)));\n return allErrors.flat();\n } else {\n // For non-multi-select, apply validations to the single field value\n return this.applyValidations(fieldValue);\n }\n }\n\n private parseAndValidateArray(fieldValue: any): { isValid: boolean; values: any[] } {\n if (Array.isArray(fieldValue)) {\n return { isValid: true, values: fieldValue };\n }\n\n try {\n const parsed = typeof fieldValue === 'string' ? JSON.parse(fieldValue) : null;\n if (Array.isArray(parsed)) {\n return { isValid: true, values: parsed };\n }\n } catch {\n // fall through\n }\n\n return { isValid: false, values: [] };\n }\n\n\n private async applyValidations(fieldValue: any): Promise<ValidationError[]> {\n const errors: ValidationError[] = [];\n this.isApplyRequiredValidation() && isEmpty(fieldValue) ? errors.push({ field: this.options.fieldName, error: `Field: ${this.options.fieldName} is required` }) : \"no errors\";\n if (isNotEmpty(fieldValue)) {\n const formatErrors = await this.applyFormatValidations(fieldValue);\n errors.push(...formatErrors);\n }\n return errors;\n }\n\n private async applyFormatValidations(fieldValue: any): Promise<ValidationError[]> {\n const errors: ValidationError[] = [];\n !this.isValidSelectionValueType(fieldValue, this.options.selectionValueType) ? errors.push({ field: this.options.fieldName, error: 'Field value type is invalid' }) : \"no errors\";\n const ctxt = this.options.selectionDynamicProviderCtxt;\n if (ctxt.validateOnSave !== false) {\n const _isValidSelectionValue = await this.isValidSelectionValue(fieldValue, this.options.selectionDynamicProvider, ctxt);\n !_isValidSelectionValue ? errors.push({ field: this.options.fieldName, error: 'Field value is invalid' }) : \"no errors\";\n }\n return errors;\n }\n\n transformForCreate(dto: any): any {\n return dto;\n }\n\n // Validation to be applied\n private isValidSelectionValueType(fieldValue: any, selectionValueType: SelectionValueType): boolean {\n switch (selectionValueType) {\n case SelectionValueType.string:\n return isString(fieldValue);\n case SelectionValueType.int:\n return isInt(fieldValue);\n default:\n throw new Error(`Validation for selection value type ${selectionValueType} is not implemented`);\n }\n }\n\n private async isValidSelectionValue(fieldValue: any, selectionDynamicProvider: string, ctxt: ISelectionProviderContext): Promise<boolean> {\n const providerInstance = this.providerInstance<any>(selectionDynamicProvider);\n try {\n // Use the value method first\n const valueOption = await providerInstance.value(fieldValue, ctxt);\n if (valueOption && valueOption.value === fieldValue) {\n return true;\n }\n return false;\n }\n catch (error) {\n // Use the values method as a fallback, if the value method is not implemented\n const values = await providerInstance.values('', ctxt);\n const isValid = values.some(v => v.value === fieldValue);\n return isValid;\n }\n }\n\n private providerInstance<T extends ISelectionProviderContext>(selectionDynamicProvider: string): ISelectionProvider<T> {\n const providers = this.options.discoveryService.getProviders();\n\n const byToken = providers.find((p) => p.name === selectionDynamicProvider);\n if (byToken) {\n return byToken.instance as ISelectionProvider<T>;\n }\n\n const byName = providers.find((p) => {\n try {\n return typeof p.instance?.name === 'function' && p.instance.name() === selectionDynamicProvider;\n } catch {\n return false;\n }\n });\n\n if (!byName) {\n throw new Error(`Provider for ${selectionDynamicProvider} not found`);\n }\n return byName.instance as ISelectionProvider<T>;\n }\n\n private isApplyRequiredValidation(): boolean {\n return this.options.required;\n }\n}"]}
@@ -5490,7 +5490,7 @@
5490
5490
  "private": false,
5491
5491
  "encrypt": false,
5492
5492
  "isSystem": true,
5493
- "selectionStaticValues": ["active", "completed", "failed", "cancelled"],
5493
+ "selectionStaticValues": ["active:Active", "completed:Completed", "failed:Failed", "cancelled:Cancelled"],
5494
5494
  "selectionValueType": "string"
5495
5495
  },
5496
5496
  {
@@ -5627,15 +5627,15 @@
5627
5627
  "encrypt": false,
5628
5628
  "isSystem": true,
5629
5629
  "selectionStaticValues": [
5630
- "user_message",
5631
- "assistant_message",
5632
- "tool_use",
5633
- "tool_result",
5634
- "system_prompt",
5635
- "thinking",
5636
- "error",
5637
- "session_start",
5638
- "session_end"
5630
+ "user_message:User Message",
5631
+ "assistant_message:Assistant Message",
5632
+ "tool_use:Tool Use",
5633
+ "tool_result:Tool Result",
5634
+ "system_prompt:System Prompt",
5635
+ "thinking:Thinking",
5636
+ "error:Error",
5637
+ "session_start:Session Start",
5638
+ "session_end:Session End"
5639
5639
  ],
5640
5640
  "selectionValueType": "string"
5641
5641
  },
@@ -13601,9 +13601,9 @@
13601
13601
  "pagination": true,
13602
13602
  "pageSizeOptions": [10, 25, 50],
13603
13603
  "enableGlobalSearch": true,
13604
- "create": false,
13604
+ "create": true,
13605
13605
  "edit": true,
13606
- "delete": false
13606
+ "delete": true
13607
13607
  },
13608
13608
  "children": [
13609
13609
  { "type": "field", "attrs": { "name": "sessionId", "isSearchable": true } },
@@ -13659,9 +13659,7 @@
13659
13659
  { "type": "field", "attrs": { "name": "totalSteps" } },
13660
13660
  { "type": "field", "attrs": { "name": "totalCost" } },
13661
13661
  { "type": "field", "attrs": { "name": "totalInputTokens" } },
13662
- { "type": "field", "attrs": { "name": "totalOutputTokens" } },
13663
- { "type": "field", "attrs": { "name": "createdAt" } },
13664
- { "type": "field", "attrs": { "name": "updatedAt" } }
13662
+ { "type": "field", "attrs": { "name": "totalOutputTokens" } }
13665
13663
  ]
13666
13664
  }
13667
13665
  ]
@@ -13697,9 +13695,9 @@
13697
13695
  "pagination": true,
13698
13696
  "pageSizeOptions": [10, 25, 50],
13699
13697
  "enableGlobalSearch": true,
13700
- "create": false,
13701
- "edit": false,
13702
- "delete": false
13698
+ "create": true,
13699
+ "edit": true,
13700
+ "delete": true
13703
13701
  },
13704
13702
  "children": [
13705
13703
  { "type": "field", "attrs": { "name": "id" } },
@@ -13760,8 +13758,7 @@
13760
13758
  { "type": "field", "attrs": { "name": "cost" } },
13761
13759
  { "type": "field", "attrs": { "name": "inputTokens" } },
13762
13760
  { "type": "field", "attrs": { "name": "outputTokens" } },
13763
- { "type": "field", "attrs": { "name": "toolReturncode" } },
13764
- { "type": "field", "attrs": { "name": "createdAt" } }
13761
+ { "type": "field", "attrs": { "name": "toolReturncode" } }
13765
13762
  ]
13766
13763
  }
13767
13764
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"user.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AAK,KAAA,EAAE,mBAAmB,GAAE,GAAQ;IAgBnE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BhE,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCpE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrE,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CnE,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,GAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAWvE,uBAAuB,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,cAAc;IAM9D,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI;IAgBrD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5C,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,qBAAqB,EAAE,MAAM,CAAC;KAC/B,CAAC;CAWH"}
@@ -82,8 +82,9 @@ let UserService = class UserService extends crud_service_1.CRUDService {
82
82
  if (!user) {
83
83
  throw new Error(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
84
84
  }
85
- const roles = updateDto.roles ? updateDto.roles : [];
86
- await this.addRolesToUser(user.username, roles);
85
+ if (updateDto.roles != null) {
86
+ await this.addRolesToUser(user.username, updateDto.roles);
87
+ }
87
88
  await this.update(id, updateDto, files, true);
88
89
  }
89
90
  async addRoleToUser(username, roleName) {
@@ -1 +1 @@
1
- {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqF;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E,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;YAC1C,qBAAqB,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE;SAC5D,CAAC;IACJ,CAAC;CAGF,CAAA;AA9QY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAIrB,WAAA,IAAA,0BAAgB,EAAC,kBAAI,EAAE,SAAS,CAAC,CAAA;qCALT,gCAAc;QAEf,uBAAa;QAEtB,gCAAc;QAEM,oBAAU;QAGZ,iDAAsB;QACnC,gBAAS;GAZpB,WAAW,CA8QvB","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager, Repository } from 'typeorm';\nimport type { SolidCoreSetting } from \"src/services/settings/default-settings-provider.service\";\n\n\nimport { OauthUserDto } from '../dtos/oauth-user-dto';\nimport { RoleMetadata } from '../entities/role-metadata.entity';\nimport { User } from '../entities/user.entity';\nimport { ActiveUserData } from '../interfaces/active-user-data.interface';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { UserRepository } from 'src/repository/user.repository';\nimport { RoleMetadataRepository } from 'src/repository/role-metadata.repository';\nimport { HashingService } from './hashing.service';\n\n@Injectable()\nexport class UserService extends CRUDService<User> {\n constructor(\n readonly hashingService: HashingService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(User, 'default')\n readonly repo: UserRepository,\n @InjectRepository(User, 'default')\n readonly nonSecurityRuleAwareRepo: Repository<User>,\n // @InjectRepository(RoleMetadata)\n // private readonly roleRepository: Repository<RoleMetadata>,\n private readonly roleRepository: RoleMetadataRepository,\n readonly moduleRef: ModuleRef,\n\n ) {\n super(entityManager, repo, 'user', 'solid-core', moduleRef);\n }\n\n override async delete(id: number, solidRequestContext: any = {}) {\n // Prevent user from deleting themselves\n if (solidRequestContext?.activeUser?.sub === id) {\n throw new BadRequestException(ERROR_MESSAGES.DELETE_SELF_NOT_ALLOWED);\n }\n\n // ✅ Proceed with the default deletion logic\n return super.delete(id, solidRequestContext);\n }\n\n override async deleteMany(ids: number[], solidRequestContext: any = {}): Promise<any> {\n if (!ids || ids.length === 0) {\n throw new Error(ERROR_MESSAGES.DELETE_IDS_REQUIRED);\n }\n\n // ❌ If the active user is trying to delete themselves\n if (solidRequestContext?.activeUser?.sub && ids.includes(solidRequestContext.activeUser.id)) {\n throw new BadRequestException(ERROR_MESSAGES.DELETE_SELF_NOT_ALLOWED);\n }\n\n return super.deleteMany(ids, solidRequestContext);\n }\n\n async findOneByEmail(email: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n email: email\n },\n relations: {}\n });\n // if (!entity) {\n // throw new NotFoundException(`user with email #${email} not found`);\n // }\n // return entity;\n }\n\n async findOneByAccessCode(accessCode: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n accessCode: accessCode\n },\n relations: {}\n });\n }\n\n async findOneByUsername(username: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n username: username\n },\n relations: {}\n });\n // if (!entity) {\n // throw new NotFoundException(`user with username ${username} not found`);\n // }\n // return entity;\n }\n\n async updateUser(id: any, updateDto, files, solidRequestContext: any = {}) {\n const user = await this.repo.findOne({\n where: { id: id },\n relations: {\n roles: true\n }\n });\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND);\n }\n const roles = updateDto.roles ? updateDto.roles : [];\n await this.addRolesToUser(user.username, roles);\n await this.update(id, updateDto, files, true);\n }\n\n async addRoleToUser(username: string, roleName: string): Promise<User> {\n // Find the role, find the user and populate the many 2 many table.\n const user = await this.repo.findOne({\n where: { username: username },\n relations: {\n roles: true\n }\n });\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n const role = await this.roleRepository.findOne({ where: { name: roleName } });\n if (!role) {\n throw new Error(ERROR_MESSAGES.ROLE_NOT_FOUND(roleName));\n }\n\n if (user.roles && user.roles.length > 0) {\n user.roles.push(role);\n }\n else {\n user.roles = [role];\n }\n\n return await this.repo.save(user);\n }\n\n async addRolesToUser(username: string, roleNames: string[]): Promise<User> {\n const user = await this.nonSecurityRuleAwareRepo.findOne({\n where: { username: username },\n relations: { roles: true }\n });\n\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n\n const roles = await this.roleRepository.find({\n where: roleNames.map(roleName => ({ name: roleName }))\n });\n\n if (roles.length !== roleNames.length) {\n const foundRoleNames = roles.map(role => role.name);\n const missingRoles = roleNames.filter(roleName => !foundRoleNames.includes(roleName));\n throw new Error(ERROR_MESSAGES.ROLES_NOT_FOUND(missingRoles));\n }\n\n const currentRoles = user.roles.map(role => role.name);\n\n const rolesToAdd = roles.filter(role => !currentRoles.includes(role.name));\n\n const rolesToRemove = user.roles.filter(role => !roleNames.includes(role.name));\n\n if (rolesToAdd.length > 0) {\n user.roles.push(...rolesToAdd);\n }\n\n if (rolesToRemove.length > 0) {\n user.roles = user.roles.filter(role => !rolesToRemove.includes(role));\n }\n\n return await this.nonSecurityRuleAwareRepo.save(user);\n }\n\n\n async removeRoleFromUser(username: string, roleName: string): Promise<User> {\n\n // load the role with the respective permissions.\n const user = await this.repo.findOne({\n where: {\n username: username\n },\n relations: {\n roles: true\n }\n });\n\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n\n // modify the permissions array.\n user.roles = user.roles.filter(role => role.name !== roleName);\n\n return await this.repo.save(user);\n }\n\n // PROVIDER SPECIFIC CODE\n async resolveUserOnOauthGoogle(oauthUserDto: OauthUserDto): Promise<User> {\n const user = await this.repo.findOne({\n where: {\n email: oauthUserDto.email,\n },\n relations: {\n roles: true\n }\n });\n\n // if we are unable to find a user then we need to create one. \n if (!user) {\n const user = new User();\n user.username = oauthUserDto.email;\n user.email = oauthUserDto.email;\n user.fullName = oauthUserDto.name;\n user.lastLoginProvider = oauthUserDto.provider;\n user.accessCode = oauthUserDto.accessCode;\n user.googleAccessToken = oauthUserDto.accessToken;\n user.googleId = oauthUserDto.providerId;\n user.googleProfilePicture = oauthUserDto.picture;\n\n const savedUser = await this.repo.save(user);\n\n // Initialize the user roles\n await this.initializeRolesForNewUser([this.settingService.getConfigValue<SolidCoreSetting>('defaultRole')], savedUser);\n }\n // else we update the user and store the generated code & access token. \n else {\n const entity = await this.repo.preload({\n id: user.id,\n lastLoginProvider: oauthUserDto.provider,\n accessCode: oauthUserDto.accessCode,\n googleAccessToken: oauthUserDto.accessToken,\n googleId: oauthUserDto.providerId,\n googleProfilePicture: oauthUserDto.picture,\n });\n\n await this.repo.save(entity);\n }\n\n return user;\n }\n\n async findUsersByRole(roleName: string, relations: any = {}): Promise<User[]> {\n return await this.repo.find({\n where: {\n roles: {\n name: roleName\n }\n },\n relations: relations\n });\n }\n\n async checkIfPermissionExists(query: any, activeUser: ActiveUserData) {\n\n const matchingPermssions = activeUser.permissions.filter((p) => query.permissionNames.includes(p));\n return matchingPermssions\n }\n\n async initializeRolesForNewUser(roles: string[], user: User) {\n if (!user.id) {\n throw new BadRequestException(ERROR_MESSAGES.USER_MISSING_ID);\n }\n let userRoles = [];\n // Default Internal user role assigned \n userRoles.push(\"Internal User\");\n if (roles) {\n userRoles = [...userRoles, ...roles];\n }\n userRoles = Array.from(new Set([...userRoles]));\n if (userRoles.length > 0) {\n await this.addRolesToUser(user.username, userRoles);\n }\n }\n\n async hashPassword(password: string): Promise<{\n password: string;\n passwordScheme: string;\n passwordSchemeVersion: number;\n }> {\n const hashedPassword = await this.hashingService.hash(password);\n\n return {\n password: hashedPassword,\n passwordScheme: this.hashingService.name(),\n passwordSchemeVersion: this.hashingService.currentVersion(),\n };\n }\n\n\n}\n\n"]}
1
+ {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[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,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;YAC1C,qBAAqB,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE;SAC5D,CAAC;IACJ,CAAC;CAGF,CAAA;AA/QY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,6BAAmB,GAAE,CAAA;IAIrB,WAAA,IAAA,0BAAgB,EAAC,kBAAI,EAAE,SAAS,CAAC,CAAA;qCALT,gCAAc;QAEf,uBAAa;QAEtB,gCAAc;QAEM,oBAAU;QAGZ,iDAAsB;QACnC,gBAAS;GAZpB,WAAW,CA+QvB","sourcesContent":["import { BadRequestException, forwardRef, Inject, Injectable } from '@nestjs/common';\nimport { ModuleRef } from \"@nestjs/core\";\nimport { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';\nimport { CRUDService } from 'src/services/crud.service';\nimport { EntityManager, Repository } from 'typeorm';\nimport type { SolidCoreSetting } from \"src/services/settings/default-settings-provider.service\";\n\n\nimport { OauthUserDto } from '../dtos/oauth-user-dto';\nimport { RoleMetadata } from '../entities/role-metadata.entity';\nimport { User } from '../entities/user.entity';\nimport { ActiveUserData } from '../interfaces/active-user-data.interface';\nimport { ERROR_MESSAGES } from 'src/constants/error-messages';\nimport { UserRepository } from 'src/repository/user.repository';\nimport { RoleMetadataRepository } from 'src/repository/role-metadata.repository';\nimport { HashingService } from './hashing.service';\n\n@Injectable()\nexport class UserService extends CRUDService<User> {\n constructor(\n readonly hashingService: HashingService,\n @InjectEntityManager()\n readonly entityManager: EntityManager,\n // @InjectRepository(User, 'default')\n readonly repo: UserRepository,\n @InjectRepository(User, 'default')\n readonly nonSecurityRuleAwareRepo: Repository<User>,\n // @InjectRepository(RoleMetadata)\n // private readonly roleRepository: Repository<RoleMetadata>,\n private readonly roleRepository: RoleMetadataRepository,\n readonly moduleRef: ModuleRef,\n\n ) {\n super(entityManager, repo, 'user', 'solid-core', moduleRef);\n }\n\n override async delete(id: number, solidRequestContext: any = {}) {\n // Prevent user from deleting themselves\n if (solidRequestContext?.activeUser?.sub === id) {\n throw new BadRequestException(ERROR_MESSAGES.DELETE_SELF_NOT_ALLOWED);\n }\n\n // ✅ Proceed with the default deletion logic\n return super.delete(id, solidRequestContext);\n }\n\n override async deleteMany(ids: number[], solidRequestContext: any = {}): Promise<any> {\n if (!ids || ids.length === 0) {\n throw new Error(ERROR_MESSAGES.DELETE_IDS_REQUIRED);\n }\n\n // ❌ If the active user is trying to delete themselves\n if (solidRequestContext?.activeUser?.sub && ids.includes(solidRequestContext.activeUser.id)) {\n throw new BadRequestException(ERROR_MESSAGES.DELETE_SELF_NOT_ALLOWED);\n }\n\n return super.deleteMany(ids, solidRequestContext);\n }\n\n async findOneByEmail(email: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n email: email\n },\n relations: {}\n });\n // if (!entity) {\n // throw new NotFoundException(`user with email #${email} not found`);\n // }\n // return entity;\n }\n\n async findOneByAccessCode(accessCode: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n accessCode: accessCode\n },\n relations: {}\n });\n }\n\n async findOneByUsername(username: string): Promise<User> {\n return await this.repo.findOne({\n where: {\n username: username\n },\n relations: {}\n });\n // if (!entity) {\n // throw new NotFoundException(`user with username ${username} not found`);\n // }\n // return entity;\n }\n\n async updateUser(id: any, updateDto, files, solidRequestContext: any = {}) {\n const user = await this.repo.findOne({\n where: { id: id },\n relations: {\n roles: true\n }\n });\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND);\n }\n if (updateDto.roles != null) {\n await this.addRolesToUser(user.username, updateDto.roles);\n }\n await this.update(id, updateDto, files, true);\n }\n\n async addRoleToUser(username: string, roleName: string): Promise<User> {\n // Find the role, find the user and populate the many 2 many table.\n const user = await this.repo.findOne({\n where: { username: username },\n relations: {\n roles: true\n }\n });\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n const role = await this.roleRepository.findOne({ where: { name: roleName } });\n if (!role) {\n throw new Error(ERROR_MESSAGES.ROLE_NOT_FOUND(roleName));\n }\n\n if (user.roles && user.roles.length > 0) {\n user.roles.push(role);\n }\n else {\n user.roles = [role];\n }\n\n return await this.repo.save(user);\n }\n\n async addRolesToUser(username: string, roleNames: string[]): Promise<User> {\n const user = await this.nonSecurityRuleAwareRepo.findOne({\n where: { username: username },\n relations: { roles: true }\n });\n\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n\n const roles = await this.roleRepository.find({\n where: roleNames.map(roleName => ({ name: roleName }))\n });\n\n if (roles.length !== roleNames.length) {\n const foundRoleNames = roles.map(role => role.name);\n const missingRoles = roleNames.filter(roleName => !foundRoleNames.includes(roleName));\n throw new Error(ERROR_MESSAGES.ROLES_NOT_FOUND(missingRoles));\n }\n\n const currentRoles = user.roles.map(role => role.name);\n\n const rolesToAdd = roles.filter(role => !currentRoles.includes(role.name));\n\n const rolesToRemove = user.roles.filter(role => !roleNames.includes(role.name));\n\n if (rolesToAdd.length > 0) {\n user.roles.push(...rolesToAdd);\n }\n\n if (rolesToRemove.length > 0) {\n user.roles = user.roles.filter(role => !rolesToRemove.includes(role));\n }\n\n return await this.nonSecurityRuleAwareRepo.save(user);\n }\n\n\n async removeRoleFromUser(username: string, roleName: string): Promise<User> {\n\n // load the role with the respective permissions.\n const user = await this.repo.findOne({\n where: {\n username: username\n },\n relations: {\n roles: true\n }\n });\n\n if (!user) {\n throw new Error(ERROR_MESSAGES.USER_NOT_FOUND_BY_USERNAME(username));\n }\n\n // modify the permissions array.\n user.roles = user.roles.filter(role => role.name !== roleName);\n\n return await this.repo.save(user);\n }\n\n // PROVIDER SPECIFIC CODE\n async resolveUserOnOauthGoogle(oauthUserDto: OauthUserDto): Promise<User> {\n const user = await this.repo.findOne({\n where: {\n email: oauthUserDto.email,\n },\n relations: {\n roles: true\n }\n });\n\n // if we are unable to find a user then we need to create one. \n if (!user) {\n const user = new User();\n user.username = oauthUserDto.email;\n user.email = oauthUserDto.email;\n user.fullName = oauthUserDto.name;\n user.lastLoginProvider = oauthUserDto.provider;\n user.accessCode = oauthUserDto.accessCode;\n user.googleAccessToken = oauthUserDto.accessToken;\n user.googleId = oauthUserDto.providerId;\n user.googleProfilePicture = oauthUserDto.picture;\n\n const savedUser = await this.repo.save(user);\n\n // Initialize the user roles\n await this.initializeRolesForNewUser([this.settingService.getConfigValue<SolidCoreSetting>('defaultRole')], savedUser);\n }\n // else we update the user and store the generated code & access token. \n else {\n const entity = await this.repo.preload({\n id: user.id,\n lastLoginProvider: oauthUserDto.provider,\n accessCode: oauthUserDto.accessCode,\n googleAccessToken: oauthUserDto.accessToken,\n googleId: oauthUserDto.providerId,\n googleProfilePicture: oauthUserDto.picture,\n });\n\n await this.repo.save(entity);\n }\n\n return user;\n }\n\n async findUsersByRole(roleName: string, relations: any = {}): Promise<User[]> {\n return await this.repo.find({\n where: {\n roles: {\n name: roleName\n }\n },\n relations: relations\n });\n }\n\n async checkIfPermissionExists(query: any, activeUser: ActiveUserData) {\n\n const matchingPermssions = activeUser.permissions.filter((p) => query.permissionNames.includes(p));\n return matchingPermssions\n }\n\n async initializeRolesForNewUser(roles: string[], user: User) {\n if (!user.id) {\n throw new BadRequestException(ERROR_MESSAGES.USER_MISSING_ID);\n }\n let userRoles = [];\n // Default Internal user role assigned \n userRoles.push(\"Internal User\");\n if (roles) {\n userRoles = [...userRoles, ...roles];\n }\n userRoles = Array.from(new Set([...userRoles]));\n if (userRoles.length > 0) {\n await this.addRolesToUser(user.username, userRoles);\n }\n }\n\n async hashPassword(password: string): Promise<{\n password: string;\n passwordScheme: string;\n passwordSchemeVersion: number;\n }> {\n const hashedPassword = await this.hashingService.hash(password);\n\n return {\n password: hashedPassword,\n passwordScheme: this.hashingService.name(),\n passwordSchemeVersion: this.hashingService.currentVersion(),\n };\n }\n\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidxai/core",
3
- "version": "0.1.8-beta.7",
3
+ "version": "0.1.8-beta.9",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,7 +2,7 @@ import { Column, Entity, Index } from 'typeorm';
2
2
  import { CommonEntity } from 'src/entities/common.entity';
3
3
  import { getColumnType } from 'src/helpers/typeorm-db-helper';
4
4
 
5
- @Entity({ name: 'ss_agent_events', synchronize: false })
5
+ @Entity({ name: 'ss_agent_events' })
6
6
  export class AgentEvent extends CommonEntity {
7
7
  @Index()
8
8
  @Column({ })
@@ -2,7 +2,7 @@ import { Column, Entity, Index } from 'typeorm';
2
2
  import { CommonEntity } from 'src/entities/common.entity';
3
3
  import { getColumnType } from 'src/helpers/typeorm-db-helper';
4
4
 
5
- @Entity({ name: 'ss_agent_sessions', synchronize: false })
5
+ @Entity({ name: 'ss_agent_sessions' })
6
6
  export class AgentSession extends CommonEntity {
7
7
  @Index({ unique: true })
8
8
  @Column({ })
@@ -1,14 +1,15 @@
1
1
  import { CommonEntity } from 'src/entities/common.entity';
2
2
  import { Column, Entity, Index } from 'typeorm';
3
+ import { getColumnType } from 'src/helpers/typeorm-db-helper';
3
4
 
4
5
  @Entity("ss_sms_template")
5
6
  export class SmsTemplate extends CommonEntity {
6
7
  @Index({ unique: true })
7
- @Column({ name: "name", type: "varchar"})
8
+ @Column({ name: "name", type: "varchar" })
8
9
  name: string;
9
10
  @Column({ name: "display_name", type: "varchar" })
10
11
  displayName: string;
11
- @Column({ name: "body", type: "varchar", nullable: true })
12
+ @Column({ name: "body", ...getColumnType('longText'), nullable: true })
12
13
  body: string;
13
14
  @Column({ type: "varchar", nullable: true })
14
15
  smsProviderTemplateId: string;
@@ -90,6 +90,21 @@ export async function bootstrapSolidApp(
90
90
  // Security headers
91
91
  app.use(helmet(buildDefaultSecurityHeaderOptions()));
92
92
 
93
+ // Nest's Swagger UI HTML injects inline styles; keep CSP strict elsewhere.
94
+ const isSwaggerPath = (path: string) =>
95
+ path === '/docs' ||
96
+ path === '/docs/' ||
97
+ path.startsWith('/docs/') ||
98
+ path === '/docs-json' ||
99
+ path === '/docs-yaml';
100
+
101
+ app.use((req: Request, res: Response, next: NextFunction) => {
102
+ if (isSwaggerPath(req.path)) {
103
+ res.removeHeader('Content-Security-Policy');
104
+ }
105
+ next();
106
+ });
107
+
93
108
  // Permissions-Policy header
94
109
  app.use((_req: Request, res: Response, next: NextFunction) => {
95
110
  res.setHeader('Permissions-Policy', buildPermissionsPolicyHeader(permissionsPolicyOverrides));
@@ -127,7 +142,7 @@ export async function bootstrapSolidApp(
127
142
 
128
143
  // Swagger
129
144
  if (swagger !== false) {
130
- const { title = 'Solid Starters', description = 'Solid Starters API', version = '1.0' } = swagger;
145
+ const { title = process.env.SOLID_APP_NAME, description = process.env.SOLID_APP_DESCRIPTION, version = '1.0' } = swagger;
131
146
  const swaggerConfig = new DocumentBuilder()
132
147
  .setTitle(title)
133
148
  .setDescription(description)
@@ -128,14 +128,25 @@ export class SelectionDynamicFieldCrudManager implements FieldCrudManager {
128
128
  }
129
129
 
130
130
  private providerInstance<T extends ISelectionProviderContext>(selectionDynamicProvider: string): ISelectionProvider<T> {
131
- const provider = this.options.discoveryService
132
- .getProviders()
133
- .filter((provider) => provider.name === selectionDynamicProvider)
134
- .pop();
135
- if (!provider) {
131
+ const providers = this.options.discoveryService.getProviders();
132
+
133
+ const byToken = providers.find((p) => p.name === selectionDynamicProvider);
134
+ if (byToken) {
135
+ return byToken.instance as ISelectionProvider<T>;
136
+ }
137
+
138
+ const byName = providers.find((p) => {
139
+ try {
140
+ return typeof p.instance?.name === 'function' && p.instance.name() === selectionDynamicProvider;
141
+ } catch {
142
+ return false;
143
+ }
144
+ });
145
+
146
+ if (!byName) {
136
147
  throw new Error(`Provider for ${selectionDynamicProvider} not found`);
137
148
  }
138
- return provider.instance as ISelectionProvider<T>;
149
+ return byName.instance as ISelectionProvider<T>;
139
150
  }
140
151
 
141
152
  private isApplyRequiredValidation(): boolean {
@@ -5490,7 +5490,7 @@
5490
5490
  "private": false,
5491
5491
  "encrypt": false,
5492
5492
  "isSystem": true,
5493
- "selectionStaticValues": ["active", "completed", "failed", "cancelled"],
5493
+ "selectionStaticValues": ["active:Active", "completed:Completed", "failed:Failed", "cancelled:Cancelled"],
5494
5494
  "selectionValueType": "string"
5495
5495
  },
5496
5496
  {
@@ -5627,15 +5627,15 @@
5627
5627
  "encrypt": false,
5628
5628
  "isSystem": true,
5629
5629
  "selectionStaticValues": [
5630
- "user_message",
5631
- "assistant_message",
5632
- "tool_use",
5633
- "tool_result",
5634
- "system_prompt",
5635
- "thinking",
5636
- "error",
5637
- "session_start",
5638
- "session_end"
5630
+ "user_message:User Message",
5631
+ "assistant_message:Assistant Message",
5632
+ "tool_use:Tool Use",
5633
+ "tool_result:Tool Result",
5634
+ "system_prompt:System Prompt",
5635
+ "thinking:Thinking",
5636
+ "error:Error",
5637
+ "session_start:Session Start",
5638
+ "session_end:Session End"
5639
5639
  ],
5640
5640
  "selectionValueType": "string"
5641
5641
  },
@@ -13601,9 +13601,9 @@
13601
13601
  "pagination": true,
13602
13602
  "pageSizeOptions": [10, 25, 50],
13603
13603
  "enableGlobalSearch": true,
13604
- "create": false,
13604
+ "create": true,
13605
13605
  "edit": true,
13606
- "delete": false
13606
+ "delete": true
13607
13607
  },
13608
13608
  "children": [
13609
13609
  { "type": "field", "attrs": { "name": "sessionId", "isSearchable": true } },
@@ -13659,9 +13659,7 @@
13659
13659
  { "type": "field", "attrs": { "name": "totalSteps" } },
13660
13660
  { "type": "field", "attrs": { "name": "totalCost" } },
13661
13661
  { "type": "field", "attrs": { "name": "totalInputTokens" } },
13662
- { "type": "field", "attrs": { "name": "totalOutputTokens" } },
13663
- { "type": "field", "attrs": { "name": "createdAt" } },
13664
- { "type": "field", "attrs": { "name": "updatedAt" } }
13662
+ { "type": "field", "attrs": { "name": "totalOutputTokens" } }
13665
13663
  ]
13666
13664
  }
13667
13665
  ]
@@ -13697,9 +13695,9 @@
13697
13695
  "pagination": true,
13698
13696
  "pageSizeOptions": [10, 25, 50],
13699
13697
  "enableGlobalSearch": true,
13700
- "create": false,
13701
- "edit": false,
13702
- "delete": false
13698
+ "create": true,
13699
+ "edit": true,
13700
+ "delete": true
13703
13701
  },
13704
13702
  "children": [
13705
13703
  { "type": "field", "attrs": { "name": "id" } },
@@ -13760,8 +13758,7 @@
13760
13758
  { "type": "field", "attrs": { "name": "cost" } },
13761
13759
  { "type": "field", "attrs": { "name": "inputTokens" } },
13762
13760
  { "type": "field", "attrs": { "name": "outputTokens" } },
13763
- { "type": "field", "attrs": { "name": "toolReturncode" } },
13764
- { "type": "field", "attrs": { "name": "createdAt" } }
13761
+ { "type": "field", "attrs": { "name": "toolReturncode" } }
13765
13762
  ]
13766
13763
  }
13767
13764
  ]
@@ -102,8 +102,9 @@ export class UserService extends CRUDService<User> {
102
102
  if (!user) {
103
103
  throw new Error(ERROR_MESSAGES.USER_NOT_FOUND);
104
104
  }
105
- const roles = updateDto.roles ? updateDto.roles : [];
106
- await this.addRolesToUser(user.username, roles);
105
+ if (updateDto.roles != null) {
106
+ await this.addRolesToUser(user.username, updateDto.roles);
107
+ }
107
108
  await this.update(id, updateDto, files, true);
108
109
  }
109
110