@verana-labs/vs-agent-nestjs-client 1.6.0

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.
Files changed (69) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +222 -0
  3. package/build/app.module.d.ts +5 -0
  4. package/build/app.module.js +61 -0
  5. package/build/app.module.js.map +1 -0
  6. package/build/connections/connection.controller.d.ts +10 -0
  7. package/build/connections/connection.controller.js +65 -0
  8. package/build/connections/connection.controller.js.map +1 -0
  9. package/build/connections/connection.entity.d.ts +10 -0
  10. package/build/connections/connection.entity.js +49 -0
  11. package/build/connections/connection.entity.js.map +1 -0
  12. package/build/connections/connection.module.d.ts +5 -0
  13. package/build/connections/connection.module.js +44 -0
  14. package/build/connections/connection.module.js.map +1 -0
  15. package/build/connections/connection.repository.d.ts +27 -0
  16. package/build/connections/connection.repository.js +87 -0
  17. package/build/connections/connection.repository.js.map +1 -0
  18. package/build/connections/connection.service.d.ts +23 -0
  19. package/build/connections/connection.service.js +86 -0
  20. package/build/connections/connection.service.js.map +1 -0
  21. package/build/connections/index.d.ts +5 -0
  22. package/build/connections/index.js +22 -0
  23. package/build/connections/index.js.map +1 -0
  24. package/build/credentials/credential.entity.d.ts +13 -0
  25. package/build/credentials/credential.entity.js +59 -0
  26. package/build/credentials/credential.entity.js.map +1 -0
  27. package/build/credentials/credential.module.d.ts +5 -0
  28. package/build/credentials/credential.module.js +34 -0
  29. package/build/credentials/credential.module.js.map +1 -0
  30. package/build/credentials/credential.service.d.ts +100 -0
  31. package/build/credentials/credential.service.js +290 -0
  32. package/build/credentials/credential.service.js.map +1 -0
  33. package/build/credentials/index.d.ts +4 -0
  34. package/build/credentials/index.js +21 -0
  35. package/build/credentials/index.js.map +1 -0
  36. package/build/credentials/revocation-registry.entity.d.ts +9 -0
  37. package/build/credentials/revocation-registry.entity.js +48 -0
  38. package/build/credentials/revocation-registry.entity.js.map +1 -0
  39. package/build/index.d.ts +9 -0
  40. package/build/index.js +26 -0
  41. package/build/index.js.map +1 -0
  42. package/build/interfaces.d.ts +32 -0
  43. package/build/interfaces.js +3 -0
  44. package/build/interfaces.js.map +1 -0
  45. package/build/jms/index.d.ts +2 -0
  46. package/build/jms/index.js +19 -0
  47. package/build/jms/index.js.map +1 -0
  48. package/build/jms/stats-producer.service.d.ts +41 -0
  49. package/build/jms/stats-producer.service.js +145 -0
  50. package/build/jms/stats-producer.service.js.map +1 -0
  51. package/build/jms/stats.module.d.ts +5 -0
  52. package/build/jms/stats.module.js +34 -0
  53. package/build/jms/stats.module.js.map +1 -0
  54. package/build/messages/index.d.ts +3 -0
  55. package/build/messages/index.js +20 -0
  56. package/build/messages/index.js.map +1 -0
  57. package/build/messages/message.controller.d.ts +13 -0
  58. package/build/messages/message.controller.js +95 -0
  59. package/build/messages/message.controller.js.map +1 -0
  60. package/build/messages/message.module.d.ts +5 -0
  61. package/build/messages/message.module.js +41 -0
  62. package/build/messages/message.module.js.map +1 -0
  63. package/build/messages/message.service.d.ts +19 -0
  64. package/build/messages/message.service.js +103 -0
  65. package/build/messages/message.service.js.map +1 -0
  66. package/build/types.d.ts +65 -0
  67. package/build/types.js +11 -0
  68. package/build/types.js.map +1 -0
  69. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ `@verana-labs/vs-agent-nestjs-client`
2
+ # Nestjs-client for VS Agent
3
+ The `nestjs-client` library simplifies the integration of VS Agent components in your NestJS applications. It provides several modules that follow a plug-and-play architecture, allowing you to incorporate them based on your needs. Certain modules, such as credential management, recommend using the message handling module for seamless operation.
4
+
5
+ ## Available Modules
6
+ 1. Message Handling:
7
+ - Manages the events related to message states, including when a message is sent, delivered, or received.
8
+ - Use this module if you're integrating messaging functionality into your application.
9
+ 2. Credential Management:
10
+ - Handles the lifecycle of credentials, including offering, accepting, rejecting, and revoking credentials.
11
+ - This module is typically used when you need to manage digital credentials for your application.
12
+ 3. Connection Management:
13
+ - Manages events related to connection state changes.
14
+
15
+ ## How to work
16
+ ```mermaid
17
+ classDiagram
18
+ class VsAgent {
19
+ + Handles DIDComm communication
20
+ + Manages agent wallet and credentials
21
+ + Exposes API for client interactions
22
+ }
23
+
24
+ class NestJSClient {
25
+ + Plug-and-play integration
26
+ + Selectable modules for various services
27
+ + Modules:
28
+ -- MessageEventOptions: Configures message event handling
29
+ -- ConnectionEventOptions: Configures connection event handling
30
+ -- CredentialOptions: Configures credential management
31
+ -- StatsOptions: Configures stats management
32
+ }
33
+
34
+ class Client {
35
+ + Directly manages requests to SA
36
+ + Facilitates reception of requests from modules
37
+ + Provides an abstraction for service communication
38
+ + Interfaces:
39
+ -- messages
40
+ -- credentialTypes
41
+ -- revocationRegistries
42
+ -- invitations
43
+ }
44
+
45
+ class ModelLibrary {
46
+ + Defines required data models
47
+ + Ensures type safety across services
48
+ }
49
+
50
+ %% Relations
51
+ NestJSClient --> VsAgent : Uses
52
+ Client --> VsAgent : Sends requests
53
+ Client --> VsAgent : Receives requests
54
+ Client --> ModelLibrary : Uses models
55
+ ModelLibrary --> VsAgent : Provides data models
56
+ NestJSClient --> ModelLibrary : Uses models
57
+
58
+ %% Style
59
+ style NestJSClient stroke:#333,stroke-width:4px
60
+ ```
61
+
62
+ ## Configuration
63
+ ### Dynamic Module Setup
64
+ The `nestjs-client` allows dynamic configuration through various module options defined in `types.ts`. You can configure individual modules or the `EventsModule` for handling multiple events at once
65
+ ### Key Configuration Options
66
+ - `eventHandler`: Specifies the event handler class to handle incoming events. It must implement the `EventHandler` interface.
67
+ - `imports`: An array of additional modules to import, such as service modules or other shared functionality.
68
+ - `url`: VS Agent Admin API URL
69
+ - `version`: Specifies the version of VS Agent API to use.
70
+ - `statOptions`: Configuration options for the **JMS (Jakarta Message Service) broker**, including host, port, queue name, authentication, and reconnection settings. The default broker used is **Apache Artemis**.
71
+
72
+ ### `statOptions` Parameters
73
+ The `statOptions` object includes the following properties for configuring the message broker:
74
+
75
+ | Parameter | Type | Description |
76
+ |---------------|---------|-------------|
77
+ | `host` | `string` | The hostname or IP address of the JMS broker. |
78
+ | `port` | `number` | The port used to connect to the JMS broker. |
79
+ | `queue` | `string` | The name of the message queue to use. |
80
+ | `username` | `string` | The username for authenticating with the broker (if required). |
81
+ | `password` | `string` | The password for authentication (if required). |
82
+ | `reconnectLimit` | `number` | The maximum number of reconnection attempts in case of a connection failure. |
83
+ | `threads` | `number` | The number of worker threads for processing messages. |
84
+ | `delay` | `number` | The delay (in milliseconds) before retrying a failed connection or message processing. |
85
+
86
+ #### `MessageEventOptions`
87
+ Configures message event handling. The following properties are available:
88
+ - `eventHandler` (optional).
89
+ - `imports` (optional).
90
+ - `url` (mandatory).
91
+ - `version` (optional).
92
+ #### `ConnectionEventOptions`
93
+ Configures connection event handling. The following properties are available:
94
+ - `eventHandler` (optional).
95
+ - `imports` (optional).
96
+
97
+ #### `CredentialOptions`
98
+ Configures credential management. The following properties are available:
99
+ - `imports` (optional).
100
+ - `url` (mandatory).
101
+ - `version` (optional).
102
+
103
+ #### `StatsOptions`
104
+ Configures stats management. The following properties are available:
105
+ - `imports` (optional).
106
+ - `statOptions` (optional).
107
+
108
+ ##### Example of Using the `StatEventModule`
109
+
110
+ This example demonstrates how to configure and use the `StatEventModule` to send and process statistics using a JMS broker:
111
+
112
+ - **AppModule**
113
+ ```typescript
114
+ import { Module } from '@nestjs/common';
115
+ import { StatEventModule } from '@verana-labs/vs-agent-nestjs-client';
116
+
117
+ EventsModule.register({
118
+ modules: {
119
+ ...
120
+ stats: true,
121
+ },
122
+ options: {
123
+ statOptions: {
124
+ host: 'jms-broker.example.com',
125
+ port: 61616,
126
+ queue: 'stats-queue', // The queue must be unique
127
+ username: 'admin',
128
+ password: 'password123',
129
+ reconnectLimit: 5,
130
+ threads: 10,
131
+ delay: 1000,
132
+ },
133
+ eventHandler: CoreService,
134
+ url: 'http://localhost',
135
+ imports: [],
136
+ },
137
+ })
138
+ ```
139
+
140
+ - **STAT_KPI**
141
+ ```typescript
142
+ export enum STAT_KPI {
143
+ USER_CONNECTED,
144
+ }
145
+ ```
146
+
147
+ - **StatProducerService**
148
+ After configuring the `StatEventModule`, you can inject the `StatProducerService` into your services to send statistics to the configured JMS broker:
149
+
150
+ ```typescript
151
+ import { STAT_KPI } from './common'
152
+ import { StatEnum, StatProducerService } from '@verana-labs/vs-agent-nestjs-client'
153
+
154
+ export class CoreService implements EventHandler, OnModuleInit {
155
+ constructor(
156
+ @InjectRepository(SessionEntity)
157
+ private readonly statProducer: StatProducerService,
158
+ ) {}
159
+
160
+ await this.statProducer.spool(STAT_KPI.USER_CONNECTED, 'uuid', [new StatEnum(0, 'string')])
161
+ }
162
+ ```
163
+
164
+
165
+ #### `ModulesConfig`
166
+ This interface defines the configuration for enabling or disabling modules:
167
+ - `messages` (optional): Whether to enable the message handling module. Defaults to false.
168
+ - `connections` (optional): Whether to enable the connection management module. Defaults to false.
169
+ - `credentials` (optional): Whether to enable the credential management module. Defaults to false.
170
+ - `stats` (optional): Whether to enable the stats management module. Defaults to false.
171
+
172
+ #### `EventsModuleOptions`
173
+ This configuration interface is used to configure multiple modules at once via the EventsModule:
174
+ - `modules`: Specifies which modules to enable (messages, connections, and credentials).
175
+ - `options`: Contains common configuration options that apply to each module, such as eventHandler, imports, url, and version.
176
+
177
+
178
+
179
+
180
+ ### Example of Using Independent Modules
181
+ This example demonstrates how to use each module separately:
182
+ ```typescript
183
+ @Module({
184
+ imports: [
185
+ MessageEventModule.forRoot({
186
+ messageHandler: CustomMessageHandler, // Class with input method
187
+ imports: [],
188
+ url: 'http://vsa-url.com',
189
+ version: ApiVersion.V1,
190
+ }),
191
+ CredentialManagementModule.forRoot({
192
+ // Configuration options
193
+ }),
194
+ ],
195
+ })
196
+ export class AppModule {}
197
+ ```
198
+
199
+ ### Example of Using the Recommended `EventsModule`
200
+ The recommended approach is to use the `EventsModule` to register multiple modules at once for easier configuration:
201
+ ```typescript
202
+ @Module({
203
+ imports: [
204
+ EventsModule.register({
205
+ modules: {
206
+ messages: true,
207
+ credentials: true,
208
+ },
209
+ options: {
210
+ eventHandler: CoreService,
211
+ imports: [],
212
+ url: process.env.VS_AGENT_ADMIN_URL,
213
+ version: ApiVersion.V1,
214
+ },
215
+ }),
216
+ ],
217
+ })
218
+ export class AppModule {}
219
+ ```
220
+ In this example, the `EventsModule` is used to register multiple modules simultaneously, which ensures better integration and streamlined configuration for common use cases.
221
+
222
+ For more information on dynamic modules and their configuration in NestJS, refer to the official [documentation](https://docs.nestjs.com/fundamentals/dynamic-modules)
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { EventsModuleOptions } from './types';
3
+ export declare class EventsModule {
4
+ static register(options: EventsModuleOptions): DynamicModule;
5
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var EventsModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EventsModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const connections_1 = require("./connections");
13
+ const credentials_1 = require("./credentials");
14
+ const jms_1 = require("./jms");
15
+ const messages_1 = require("./messages");
16
+ let EventsModule = EventsModule_1 = class EventsModule {
17
+ static register(options) {
18
+ var _a, _b, _c, _d;
19
+ const imports = [];
20
+ const { modules, options: moduleOptions } = options;
21
+ if (modules.messages) {
22
+ imports.push(messages_1.MessageEventModule.forRoot({
23
+ eventHandler: moduleOptions.eventHandler,
24
+ imports: (_a = moduleOptions.imports) !== null && _a !== void 0 ? _a : [],
25
+ url: moduleOptions.url,
26
+ version: moduleOptions.version,
27
+ }));
28
+ }
29
+ if (modules.connections) {
30
+ imports.push(connections_1.ConnectionsEventModule.forRoot({
31
+ eventHandler: moduleOptions.eventHandler,
32
+ imports: (_b = moduleOptions.imports) !== null && _b !== void 0 ? _b : [],
33
+ useMessages: modules.messages,
34
+ }));
35
+ }
36
+ if (modules.credentials) {
37
+ imports.push(credentials_1.CredentialModule.forRoot({
38
+ imports: (_c = moduleOptions.imports) !== null && _c !== void 0 ? _c : [],
39
+ url: moduleOptions.url,
40
+ version: moduleOptions.version,
41
+ }));
42
+ }
43
+ if (modules.stats) {
44
+ imports.push(jms_1.StatEventModule.forRoot({
45
+ imports: (_d = moduleOptions.imports) !== null && _d !== void 0 ? _d : [],
46
+ statOptions: moduleOptions.statOptions,
47
+ }));
48
+ }
49
+ return {
50
+ module: EventsModule_1,
51
+ imports,
52
+ exports: imports,
53
+ };
54
+ }
55
+ };
56
+ exports.EventsModule = EventsModule;
57
+ exports.EventsModule = EventsModule = EventsModule_1 = __decorate([
58
+ (0, common_1.Global)(),
59
+ (0, common_1.Module)({})
60
+ ], EventsModule);
61
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA8D;AAE9D,+CAAsD;AACtD,+CAAgD;AAChD,+BAAuC;AACvC,yCAA+C;AAKxC,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,OAA4B;;QAC1C,MAAM,OAAO,GAAG,EAAE,CAAA;QAClB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;QAEnD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,CA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{ ConnectionStateUpdated } from '@verana-labs/vs-agent-model';
2
+ import { ConnectionsEventService } from './connection.service';
3
+ export declare class ConnectionsEventController {
4
+ private readonly service;
5
+ private readonly logger;
6
+ constructor(service: ConnectionsEventService);
7
+ update(body: ConnectionStateUpdated): Promise<{
8
+ message: string;
9
+ }>;
10
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var ConnectionsEventController_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ConnectionsEventController = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ const vs_agent_client_1 = require("@verana-labs/vs-agent-client");
20
+ const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
21
+ const connection_service_1 = require("./connection.service");
22
+ let ConnectionsEventController = ConnectionsEventController_1 = class ConnectionsEventController {
23
+ constructor(service) {
24
+ this.service = service;
25
+ this.logger = new common_1.Logger(ConnectionsEventController_1.name);
26
+ }
27
+ async update(body) {
28
+ try {
29
+ this.logger.log(`connectionStateUpdated event: ${JSON.stringify(body)}`);
30
+ await this.service.update(body);
31
+ return { message: 'Connection state updated successfully' };
32
+ }
33
+ catch (error) {
34
+ vs_agent_client_1.HttpUtils.handleException(this.logger, error, 'Failed to update connection state');
35
+ }
36
+ }
37
+ };
38
+ exports.ConnectionsEventController = ConnectionsEventController;
39
+ __decorate([
40
+ (0, common_1.Post)(`/${vs_agent_model_1.EventType.ConnectionState}`),
41
+ (0, swagger_1.ApiOperation)({
42
+ summary: 'Handle the ConnectionState event',
43
+ description: 'Processes the ConnectionState event and updates the connection state.',
44
+ }),
45
+ (0, swagger_1.ApiResponse)({
46
+ status: common_1.HttpStatus.OK,
47
+ description: 'Connection state updated successfully.',
48
+ schema: {
49
+ example: { message: 'Connection state updated successfully' },
50
+ },
51
+ }),
52
+ (0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.BAD_REQUEST, description: 'Invalid input data.' }),
53
+ (0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR, description: 'Internal server error.' }),
54
+ __param(0, (0, common_1.Body)()),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [vs_agent_model_1.ConnectionStateUpdated]),
57
+ __metadata("design:returntype", Promise)
58
+ ], ConnectionsEventController.prototype, "update", null);
59
+ exports.ConnectionsEventController = ConnectionsEventController = ConnectionsEventController_1 = __decorate([
60
+ (0, swagger_1.ApiTags)('Connections Event'),
61
+ (0, common_1.Controller)(),
62
+ __param(0, (0, common_1.Inject)(connection_service_1.ConnectionsEventService)),
63
+ __metadata("design:paramtypes", [connection_service_1.ConnectionsEventService])
64
+ ], ConnectionsEventController);
65
+ //# sourceMappingURL=connection.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.controller.js","sourceRoot":"","sources":["../../src/connections/connection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAoE;AACpE,kEAAwD;AACxD,gEAA+E;AAE/E,6DAA8D;AAIvD,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAGrC,YAA6C,OAAiD;QAAhC,YAAO,GAAP,OAA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AU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,4CAAuB,CAAC,CAAA;qCAA2B,4CAAuB;GAHnF,0BAA0B,CA8BtC"}
@@ -0,0 +1,10 @@
1
+ import { ExtendedDidExchangeState } from '@verana-labs/vs-agent-model';
2
+ import { UserProfile } from '../types';
3
+ export declare class ConnectionEntity {
4
+ id?: string;
5
+ status?: ExtendedDidExchangeState;
6
+ userProfile?: UserProfile;
7
+ createdTs?: Date;
8
+ updatedTs?: Date;
9
+ metadata?: Record<string, any>;
10
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ConnectionEntity = void 0;
13
+ const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
14
+ const typeorm_1 = require("typeorm");
15
+ let ConnectionEntity = class ConnectionEntity {
16
+ };
17
+ exports.ConnectionEntity = ConnectionEntity;
18
+ __decorate([
19
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
20
+ __metadata("design:type", String)
21
+ ], ConnectionEntity.prototype, "id", void 0);
22
+ __decorate([
23
+ (0, typeorm_1.Column)({
24
+ type: 'enum',
25
+ enum: vs_agent_model_1.ExtendedDidExchangeState,
26
+ default: vs_agent_model_1.ExtendedDidExchangeState.Start,
27
+ }),
28
+ __metadata("design:type", String)
29
+ ], ConnectionEntity.prototype, "status", void 0);
30
+ __decorate([
31
+ (0, typeorm_1.Column)('jsonb', { nullable: true }),
32
+ __metadata("design:type", Object)
33
+ ], ConnectionEntity.prototype, "userProfile", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.CreateDateColumn)(),
36
+ __metadata("design:type", Date)
37
+ ], ConnectionEntity.prototype, "createdTs", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.UpdateDateColumn)(),
40
+ __metadata("design:type", Date)
41
+ ], ConnectionEntity.prototype, "updatedTs", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)('jsonb', { nullable: true }),
44
+ __metadata("design:type", Object)
45
+ ], ConnectionEntity.prototype, "metadata", void 0);
46
+ exports.ConnectionEntity = ConnectionEntity = __decorate([
47
+ (0, typeorm_1.Entity)('connections')
48
+ ], ConnectionEntity);
49
+ //# sourceMappingURL=connection.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.entity.js","sourceRoot":"","sources":["../../src/connections/connection.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAAsE;AACtE,qCAAoG;AAK7F,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAsB5B,CAAA;AAtBY,4CAAgB;AAE3B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACpB;AAOX;IALC,IAAA,gBAAM,EAAC;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,yCAAwB;QAC9B,OAAO,EAAE,yCAAwB,CAAC,KAAK;KACxC,CAAC;;gDAC+B;AAGjC;IADC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACX;AAGzB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;mDAAA;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;mDAAA;AAGhB;IADC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;2BArBnB,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,gBAAgB,CAsB5B"}
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { ConnectionEventOptions } from '../types';
3
+ export declare class ConnectionsEventModule {
4
+ static forRoot(options: ConnectionEventOptions): DynamicModule;
5
+ }