@@ -6,12 +6,17 @@ import {
66 IEcosystem ,
77 IEcosystemDashboard ,
88 IEcosystemInvitation ,
9- IEcosystemInvitations ,
109 IEcosystemMemberInvitations
1110} from 'apps/ecosystem/interfaces/ecosystem.interfaces' ;
1211import { CreateEcosystemDto } from 'apps/ecosystem/dtos/create-ecosystem-dto' ;
1312// eslint-disable-next-line camelcase
1413import { ecosystem_orgs , user } from '@prisma/client' ;
14+ import { IUserRequest } from '@credebl/user-request/user-request.interface' ;
15+ import { CreateIntentDto } from 'apps/ecosystem/dtos/create-intent.dto' ;
16+ import { UpdateIntentDto } from 'apps/ecosystem/dtos/update-intent.dto' ;
17+ import { CreateIntentTemplateDto , UpdateIntentTemplateDto } from '../utilities/dtos/intent-template.dto' ;
18+ import { GetAllIntentTemplatesDto } from '../utilities/dtos/get-all-intent-templates.dto' ;
19+ import { IIntentTemplateList } from '@credebl/common/interfaces/intents-template.interface' ;
1520
1621@Injectable ( )
1722export class EcosystemService {
@@ -20,26 +25,6 @@ export class EcosystemService {
2025 private readonly natsClient : NATSClient
2126 ) { }
2227
23- /**
24- *
25- * @param createEcosystemInvitationDto
26- * @returns Ecosystem creation success
27- */
28- async inviteUserToCreateEcosystem ( email : string , platformAdminId : string ) : Promise < IEcosystemInvitations > {
29- return this . natsClient . sendNatsMessage ( this . serviceProxy , 'invite-user-for-ecosystem-creation' , {
30- email,
31- platformAdminId
32- } ) ;
33- }
34- /**
35- *
36- * @param userId
37- * @returns Get invitations
38- */
39- async getInvitationsByUserId ( userId : string ) : Promise < IEcosystemInvitations [ ] > {
40- return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-ecosystem-invitations-by-user' , { userId } ) ;
41- }
42-
4328 /**
4429 *
4530 * @param createEcosystemDto
@@ -123,4 +108,102 @@ export class EcosystemService {
123108 ecosystemId
124109 } ) ;
125110 }
111+
112+ // Intent Template CRUD operations
113+ async createIntentTemplate ( createIntentTemplateDto : CreateIntentTemplateDto , user : IUserRequest ) : Promise < object > {
114+ const payload = { ...createIntentTemplateDto , user : { id : user . userId } } ;
115+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'create-intent-template' , payload ) ;
116+ }
117+
118+ async getIntentTemplateById ( id : string ) : Promise < object > {
119+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-intent-template-by-id' , id ) ;
120+ }
121+
122+ async getIntentTemplatesByIntentId ( intentId : string ) : Promise < object [ ] > {
123+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-intent-templates-by-intent-id' , { intentId } ) ;
124+ }
125+
126+ async updateIntentTemplate (
127+ id : string ,
128+ updateIntentTemplateDto : UpdateIntentTemplateDto ,
129+ user : IUserRequest
130+ ) : Promise < object > {
131+ const payload = { id, ...updateIntentTemplateDto , user : { id : user . userId } } ;
132+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'update-intent-template' , payload ) ;
133+ }
134+
135+ async deleteIntentTemplate ( id : string ) : Promise < object > {
136+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'delete-intent-template' , { id } ) ;
137+ }
138+
139+ async getIntentTemplatesByOrgId ( orgId : string ) : Promise < object [ ] > {
140+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-intent-templates-by-org-id' , { orgId } ) ;
141+ }
142+ // Intent CRUD operations
143+
144+ /**
145+ * Create a new intent
146+ * @param createIntentDto Intent details
147+ * @param user Logged-in user
148+ * @returns Created intent
149+ */
150+ async createIntent ( createIntentDto : CreateIntentDto ) : Promise < object > {
151+ const payload = { createIntentDto } ;
152+
153+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'create-intent' , payload ) ;
154+ }
155+
156+ /**
157+ * Get all intents
158+ * @returns List of intents
159+ */
160+ async getIntents ( ecosystemId : string , intentId ?: string ) : Promise < object [ ] > {
161+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-intents' , { ecosystemId, intentId } ) ;
162+ }
163+
164+ async getVerificationTemplates ( orgId : string ) : Promise < object [ ] > {
165+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-verification-templates-by-org-id' , { orgId } ) ;
166+ }
167+
168+ async getIntentTemplateByIntentAndOrg ( intentName : string , verifierOrgId : string ) : Promise < object | null > {
169+ const payload = { intentName, verifierOrgId } ;
170+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-intent-template-by-intent-and-org' , payload ) ;
171+ }
172+
173+ async getAllIntentTemplatesByQuery (
174+ intentTemplateSearchCriteria : GetAllIntentTemplatesDto
175+ ) : Promise < IIntentTemplateList > {
176+ const payload = {
177+ intentTemplateSearchCriteria
178+ } ;
179+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'get-all-intent-templates-by-query' , payload ) ;
180+ }
181+
182+ /**
183+ * Update an intent
184+ * @param id Intent ID
185+ * @param updateIntentDto Updated intent details
186+ * @param user Logged-in user
187+ * @returns Updated intent
188+ */
189+ async updateIntent ( updateIntentDto : UpdateIntentDto ) : Promise < object > {
190+ const payload = {
191+ updateIntentDto
192+ } ;
193+
194+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'update-intent' , payload ) ;
195+ }
196+
197+ /**
198+ * Delete an intent
199+ * @param id Intent ID
200+ * @returns Deleted intent
201+ */
202+ async deleteIntent ( ecosystemId : string , intentId : string , user : IUserRequest ) : Promise < object > {
203+ return this . natsClient . sendNatsMessage ( this . serviceProxy , 'delete-intent' , {
204+ ecosystemId,
205+ intentId,
206+ user : { id : user . userId }
207+ } ) ;
208+ }
126209}
0 commit comments