@credo-ts/question-answer 0.4.1-alpha.157

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 (60) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +65 -0
  3. package/build/QuestionAnswerApi.d.ts +53 -0
  4. package/build/QuestionAnswerApi.js +106 -0
  5. package/build/QuestionAnswerApi.js.map +1 -0
  6. package/build/QuestionAnswerEvents.d.ts +13 -0
  7. package/build/QuestionAnswerEvents.js +8 -0
  8. package/build/QuestionAnswerEvents.js.map +1 -0
  9. package/build/QuestionAnswerModule.d.ts +9 -0
  10. package/build/QuestionAnswerModule.js +29 -0
  11. package/build/QuestionAnswerModule.js.map +1 -0
  12. package/build/QuestionAnswerRole.d.ts +4 -0
  13. package/build/QuestionAnswerRole.js +9 -0
  14. package/build/QuestionAnswerRole.js.map +1 -0
  15. package/build/handlers/AnswerMessageHandler.d.ts +9 -0
  16. package/build/handlers/AnswerMessageHandler.js +15 -0
  17. package/build/handlers/AnswerMessageHandler.js.map +1 -0
  18. package/build/handlers/QuestionMessageHandler.d.ts +9 -0
  19. package/build/handlers/QuestionMessageHandler.js +15 -0
  20. package/build/handlers/QuestionMessageHandler.js.map +1 -0
  21. package/build/handlers/index.d.ts +2 -0
  22. package/build/handlers/index.js +19 -0
  23. package/build/handlers/index.js.map +1 -0
  24. package/build/index.d.ts +8 -0
  25. package/build/index.js +25 -0
  26. package/build/index.js.map +1 -0
  27. package/build/messages/AnswerMessage.d.ts +15 -0
  28. package/build/messages/AnswerMessage.js +42 -0
  29. package/build/messages/AnswerMessage.js.map +1 -0
  30. package/build/messages/QuestionMessage.d.ts +23 -0
  31. package/build/messages/QuestionMessage.js +70 -0
  32. package/build/messages/QuestionMessage.js.map +1 -0
  33. package/build/messages/index.d.ts +2 -0
  34. package/build/messages/index.js +19 -0
  35. package/build/messages/index.js.map +1 -0
  36. package/build/models/QuestionAnswerState.d.ts +11 -0
  37. package/build/models/QuestionAnswerState.js +16 -0
  38. package/build/models/QuestionAnswerState.js.map +1 -0
  39. package/build/models/ValidResponse.d.ts +4 -0
  40. package/build/models/ValidResponse.js +12 -0
  41. package/build/models/ValidResponse.js.map +1 -0
  42. package/build/models/index.d.ts +2 -0
  43. package/build/models/index.js +19 -0
  44. package/build/models/index.js.map +1 -0
  45. package/build/repository/QuestionAnswerRecord.d.ts +48 -0
  46. package/build/repository/QuestionAnswerRecord.js +44 -0
  47. package/build/repository/QuestionAnswerRecord.js.map +1 -0
  48. package/build/repository/QuestionAnswerRepository.d.ts +5 -0
  49. package/build/repository/QuestionAnswerRepository.js +29 -0
  50. package/build/repository/QuestionAnswerRepository.js.map +1 -0
  51. package/build/repository/index.d.ts +2 -0
  52. package/build/repository/index.js +19 -0
  53. package/build/repository/index.js.map +1 -0
  54. package/build/services/QuestionAnswerService.d.ts +107 -0
  55. package/build/services/QuestionAnswerService.js +234 -0
  56. package/build/services/QuestionAnswerService.js.map +1 -0
  57. package/build/services/index.d.ts +1 -0
  58. package/build/services/index.js +18 -0
  59. package/build/services/index.js.map +1 -0
  60. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
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 2020-present Hyperledger Contributors.
190
+ Copyright 2021 Queen’s Printer for Ontario. Mostafa Youssef (https://github.com/MosCD3), Amit Padmani (https://github.com/nbAmit), Prasad Katkar (https://github.com/NB-PrasadKatkar), Mike Richardson (https://github.com/NB-MikeRichardson)
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ <p align="center">
2
+ <br />
3
+ <img
4
+ alt="Credo Logo"
5
+ src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png"
6
+ height="250px"
7
+ />
8
+ </p>
9
+ <h1 align="center"><b>Credo Question Answer Module</b></h1>
10
+ <p align="center">
11
+ <a
12
+ href="https://raw.githubusercontent.com/openwallet-foundation/credo-ts/main/LICENSE"
13
+ ><img
14
+ alt="License"
15
+ src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
16
+ /></a>
17
+ <a href="https://www.typescriptlang.org/"
18
+ ><img
19
+ alt="typescript"
20
+ src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"
21
+ /></a>
22
+ <a href="https://www.npmjs.com/package/@credo-ts/question-answer"
23
+ ><img
24
+ alt="@credo-ts/question-answer version"
25
+ src="https://img.shields.io/npm/v/@credo-ts/question-answer"
26
+ /></a>
27
+
28
+ </p>
29
+ <br />
30
+
31
+ Question Answer module for [Credo](https://github.com/openwallet-foundation/credo-ts.git). Implements [Aries RFC 0113](https://github.com/hyperledger/aries-rfcs/blob/1795d5c2d36f664f88f5e8045042ace8e573808c/features/0113-question-answer/README.md).
32
+
33
+ ### Quick start
34
+
35
+ In order for this module to work, we have to inject it into the agent to access agent functionality. See the example for more information.
36
+
37
+ ### Example of usage
38
+
39
+ ```ts
40
+ import { QuestionAnswerModule } from '@credo-ts/question-answer'
41
+
42
+ const agent = new Agent({
43
+ config: {
44
+ /* config */
45
+ },
46
+ dependencies: agentDependencies,
47
+ modules: {
48
+ questionAnswer: new QuestionAnswerModule(),
49
+ /* other custom modules */
50
+ },
51
+ })
52
+
53
+ await agent.initialize()
54
+
55
+ // To send a question to a given connection
56
+ await agent.modules.questionAnswer.sendQuestion(connectionId, {
57
+ question: 'Do you want to play?',
58
+ validResponses: [{ text: 'Yes' }, { text: 'No' }],
59
+ })
60
+
61
+ // Questions and Answers are received as QuestionAnswerStateChangedEvent
62
+
63
+ // To send an answer related to a given question answer record
64
+ await agent.modules.questionAnswer.sendAnswer(questionAnswerRecordId, 'Yes')
65
+ ```
@@ -0,0 +1,53 @@
1
+ import type { QuestionAnswerRecord } from './repository';
2
+ import type { Query } from '@credo-ts/core';
3
+ import { AgentContext, ConnectionService, MessageSender } from '@credo-ts/core';
4
+ import { ValidResponse } from './models';
5
+ import { QuestionAnswerService } from './services';
6
+ export declare class QuestionAnswerApi {
7
+ private questionAnswerService;
8
+ private messageSender;
9
+ private connectionService;
10
+ private agentContext;
11
+ constructor(questionAnswerService: QuestionAnswerService, messageSender: MessageSender, connectionService: ConnectionService, agentContext: AgentContext);
12
+ /**
13
+ * Create a question message with possible valid responses, then send message to the
14
+ * holder
15
+ *
16
+ * @param connectionId connection to send the question message to
17
+ * @param config config for creating question message
18
+ * @returns QuestionAnswer record
19
+ */
20
+ sendQuestion(connectionId: string, config: {
21
+ question: string;
22
+ validResponses: ValidResponse[];
23
+ detail?: string;
24
+ }): Promise<QuestionAnswerRecord>;
25
+ /**
26
+ * Create an answer message as the holder and send it in response to a question message
27
+ *
28
+ * @param questionRecordId the id of the questionAnswer record
29
+ * @param response response included in the answer message
30
+ * @returns QuestionAnswer record
31
+ */
32
+ sendAnswer(questionRecordId: string, response: string): Promise<QuestionAnswerRecord>;
33
+ /**
34
+ * Get all QuestionAnswer records
35
+ *
36
+ * @returns list containing all QuestionAnswer records
37
+ */
38
+ getAll(): Promise<QuestionAnswerRecord[]>;
39
+ /**
40
+ * Get all QuestionAnswer records by specified query params
41
+ *
42
+ * @returns list containing all QuestionAnswer records matching specified query params
43
+ */
44
+ findAllByQuery(query: Query<QuestionAnswerRecord>): Promise<QuestionAnswerRecord[]>;
45
+ /**
46
+ * Retrieve a question answer record by id
47
+ *
48
+ * @param questionAnswerId The questionAnswer record id
49
+ * @return The question answer record or null if not found
50
+ *
51
+ */
52
+ findById(questionAnswerId: string): Promise<QuestionAnswerRecord | null>;
53
+ }
@@ -0,0 +1,106 @@
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.QuestionAnswerApi = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const handlers_1 = require("./handlers");
15
+ const models_1 = require("./models");
16
+ const services_1 = require("./services");
17
+ let QuestionAnswerApi = class QuestionAnswerApi {
18
+ constructor(questionAnswerService, messageSender, connectionService, agentContext) {
19
+ this.questionAnswerService = questionAnswerService;
20
+ this.messageSender = messageSender;
21
+ this.connectionService = connectionService;
22
+ this.agentContext = agentContext;
23
+ this.agentContext.dependencyManager.registerMessageHandlers([
24
+ new handlers_1.QuestionMessageHandler(this.questionAnswerService),
25
+ new handlers_1.AnswerMessageHandler(this.questionAnswerService),
26
+ ]);
27
+ }
28
+ /**
29
+ * Create a question message with possible valid responses, then send message to the
30
+ * holder
31
+ *
32
+ * @param connectionId connection to send the question message to
33
+ * @param config config for creating question message
34
+ * @returns QuestionAnswer record
35
+ */
36
+ async sendQuestion(connectionId, config) {
37
+ const connection = await this.connectionService.getById(this.agentContext, connectionId);
38
+ connection.assertReady();
39
+ const { questionMessage, questionAnswerRecord } = await this.questionAnswerService.createQuestion(this.agentContext, connectionId, {
40
+ question: config.question,
41
+ validResponses: config.validResponses.map((item) => new models_1.ValidResponse(item)),
42
+ detail: config === null || config === void 0 ? void 0 : config.detail,
43
+ });
44
+ const outboundMessageContext = await (0, core_1.getOutboundMessageContext)(this.agentContext, {
45
+ message: questionMessage,
46
+ associatedRecord: questionAnswerRecord,
47
+ connectionRecord: connection,
48
+ });
49
+ await this.messageSender.sendMessage(outboundMessageContext);
50
+ return questionAnswerRecord;
51
+ }
52
+ /**
53
+ * Create an answer message as the holder and send it in response to a question message
54
+ *
55
+ * @param questionRecordId the id of the questionAnswer record
56
+ * @param response response included in the answer message
57
+ * @returns QuestionAnswer record
58
+ */
59
+ async sendAnswer(questionRecordId, response) {
60
+ const questionRecord = await this.questionAnswerService.getById(this.agentContext, questionRecordId);
61
+ const { answerMessage, questionAnswerRecord } = await this.questionAnswerService.createAnswer(this.agentContext, questionRecord, response);
62
+ const connection = await this.connectionService.getById(this.agentContext, questionRecord.connectionId);
63
+ const outboundMessageContext = await (0, core_1.getOutboundMessageContext)(this.agentContext, {
64
+ message: answerMessage,
65
+ associatedRecord: questionAnswerRecord,
66
+ connectionRecord: connection,
67
+ });
68
+ await this.messageSender.sendMessage(outboundMessageContext);
69
+ return questionAnswerRecord;
70
+ }
71
+ /**
72
+ * Get all QuestionAnswer records
73
+ *
74
+ * @returns list containing all QuestionAnswer records
75
+ */
76
+ getAll() {
77
+ return this.questionAnswerService.getAll(this.agentContext);
78
+ }
79
+ /**
80
+ * Get all QuestionAnswer records by specified query params
81
+ *
82
+ * @returns list containing all QuestionAnswer records matching specified query params
83
+ */
84
+ findAllByQuery(query) {
85
+ return this.questionAnswerService.findAllByQuery(this.agentContext, query);
86
+ }
87
+ /**
88
+ * Retrieve a question answer record by id
89
+ *
90
+ * @param questionAnswerId The questionAnswer record id
91
+ * @return The question answer record or null if not found
92
+ *
93
+ */
94
+ findById(questionAnswerId) {
95
+ return this.questionAnswerService.findById(this.agentContext, questionAnswerId);
96
+ }
97
+ };
98
+ QuestionAnswerApi = __decorate([
99
+ (0, core_1.injectable)(),
100
+ __metadata("design:paramtypes", [services_1.QuestionAnswerService,
101
+ core_1.MessageSender,
102
+ core_1.ConnectionService,
103
+ core_1.AgentContext])
104
+ ], QuestionAnswerApi);
105
+ exports.QuestionAnswerApi = QuestionAnswerApi;
106
+ //# sourceMappingURL=QuestionAnswerApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuestionAnswerApi.js","sourceRoot":"","sources":["../src/QuestionAnswerApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAG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AAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;IACjF,CAAC;CACF,CAAA;AAvHY,iBAAiB;IAD7B,IAAA,iBAAU,GAAE;qCAQc,gCAAqB;QAC7B,oBAAa;QACT,wBAAiB;QACtB,mBAAY;GAVjB,iBAAiB,CAuH7B;AAvHY,8CAAiB"}
@@ -0,0 +1,13 @@
1
+ import type { QuestionAnswerState } from './models';
2
+ import type { QuestionAnswerRecord } from './repository';
3
+ import type { BaseEvent } from '@credo-ts/core';
4
+ export declare enum QuestionAnswerEventTypes {
5
+ QuestionAnswerStateChanged = "QuestionAnswerStateChanged"
6
+ }
7
+ export interface QuestionAnswerStateChangedEvent extends BaseEvent {
8
+ type: typeof QuestionAnswerEventTypes.QuestionAnswerStateChanged;
9
+ payload: {
10
+ previousState: QuestionAnswerState | null;
11
+ questionAnswerRecord: QuestionAnswerRecord;
12
+ };
13
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionAnswerEventTypes = void 0;
4
+ var QuestionAnswerEventTypes;
5
+ (function (QuestionAnswerEventTypes) {
6
+ QuestionAnswerEventTypes["QuestionAnswerStateChanged"] = "QuestionAnswerStateChanged";
7
+ })(QuestionAnswerEventTypes = exports.QuestionAnswerEventTypes || (exports.QuestionAnswerEventTypes = {}));
8
+ //# sourceMappingURL=QuestionAnswerEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuestionAnswerEvents.js","sourceRoot":"","sources":["../src/QuestionAnswerEvents.ts"],"names":[],"mappings":";;;AAIA,IAAY,wBAEX;AAFD,WAAY,wBAAwB;IAClC,qFAAyD,CAAA;AAC3D,CAAC,EAFW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAEnC"}
@@ -0,0 +1,9 @@
1
+ import type { DependencyManager, FeatureRegistry, Module } from '@credo-ts/core';
2
+ import { QuestionAnswerApi } from './QuestionAnswerApi';
3
+ export declare class QuestionAnswerModule implements Module {
4
+ readonly api: typeof QuestionAnswerApi;
5
+ /**
6
+ * Registers the dependencies of the question answer module on the dependency manager.
7
+ */
8
+ register(dependencyManager: DependencyManager, featureRegistry: FeatureRegistry): void;
9
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionAnswerModule = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const QuestionAnswerApi_1 = require("./QuestionAnswerApi");
6
+ const QuestionAnswerRole_1 = require("./QuestionAnswerRole");
7
+ const repository_1 = require("./repository");
8
+ const services_1 = require("./services");
9
+ class QuestionAnswerModule {
10
+ constructor() {
11
+ this.api = QuestionAnswerApi_1.QuestionAnswerApi;
12
+ }
13
+ /**
14
+ * Registers the dependencies of the question answer module on the dependency manager.
15
+ */
16
+ register(dependencyManager, featureRegistry) {
17
+ // Services
18
+ dependencyManager.registerSingleton(services_1.QuestionAnswerService);
19
+ // Repositories
20
+ dependencyManager.registerSingleton(repository_1.QuestionAnswerRepository);
21
+ // Feature Registry
22
+ featureRegistry.register(new core_1.Protocol({
23
+ id: 'https://didcomm.org/questionanswer/1.0',
24
+ roles: [QuestionAnswerRole_1.QuestionAnswerRole.Questioner, QuestionAnswerRole_1.QuestionAnswerRole.Responder],
25
+ }));
26
+ }
27
+ }
28
+ exports.QuestionAnswerModule = QuestionAnswerModule;
29
+ //# sourceMappingURL=QuestionAnswerModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuestionAnswerModule.js","sourceRoot":"","sources":["../src/QuestionAnswerModule.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AAEzC,2DAAuD;AACvD,6DAAyD;AACzD,6CAAuD;AACvD,yCAAkD;AAElD,MAAa,oBAAoB;IAAjC;QACkB,QAAG,GAAG,qCAAiB,CAAA;IAoBzC,CAAC;IAlBC;;OAEG;IACI,QAAQ,CAAC,iBAAoC,EAAE,eAAgC;QACpF,WAAW;QACX,iBAAiB,CAAC,iBAAiB,CAAC,gCAAqB,CAAC,CAAA;QAE1D,eAAe;QACf,iBAAiB,CAAC,iBAAiB,CAAC,qCAAwB,CAAC,CAAA;QAE7D,mBAAmB;QACnB,eAAe,CAAC,QAAQ,CACtB,IAAI,eAAQ,CAAC;YACX,EAAE,EAAE,wCAAwC;YAC5C,KAAK,EAAE,CAAC,uCAAkB,CAAC,UAAU,EAAE,uCAAkB,CAAC,SAAS,CAAC;SACrE,CAAC,CACH,CAAA;IACH,CAAC;CACF;AArBD,oDAqBC"}
@@ -0,0 +1,4 @@
1
+ export declare enum QuestionAnswerRole {
2
+ Questioner = "questioner",
3
+ Responder = "responder"
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionAnswerRole = void 0;
4
+ var QuestionAnswerRole;
5
+ (function (QuestionAnswerRole) {
6
+ QuestionAnswerRole["Questioner"] = "questioner";
7
+ QuestionAnswerRole["Responder"] = "responder";
8
+ })(QuestionAnswerRole = exports.QuestionAnswerRole || (exports.QuestionAnswerRole = {}));
9
+ //# sourceMappingURL=QuestionAnswerRole.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuestionAnswerRole.js","sourceRoot":"","sources":["../src/QuestionAnswerRole.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,6CAAuB,CAAA;AACzB,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B"}
@@ -0,0 +1,9 @@
1
+ import type { QuestionAnswerService } from '../services';
2
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
3
+ import { AnswerMessage } from '../messages';
4
+ export declare class AnswerMessageHandler implements MessageHandler {
5
+ private questionAnswerService;
6
+ supportedMessages: (typeof AnswerMessage)[];
7
+ constructor(questionAnswerService: QuestionAnswerService);
8
+ handle(messageContext: MessageHandlerInboundMessage<AnswerMessageHandler>): Promise<void>;
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnswerMessageHandler = void 0;
4
+ const messages_1 = require("../messages");
5
+ class AnswerMessageHandler {
6
+ constructor(questionAnswerService) {
7
+ this.supportedMessages = [messages_1.AnswerMessage];
8
+ this.questionAnswerService = questionAnswerService;
9
+ }
10
+ async handle(messageContext) {
11
+ await this.questionAnswerService.receiveAnswer(messageContext);
12
+ }
13
+ }
14
+ exports.AnswerMessageHandler = AnswerMessageHandler;
15
+ //# sourceMappingURL=AnswerMessageHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnswerMessageHandler.js","sourceRoot":"","sources":["../../src/handlers/AnswerMessageHandler.ts"],"names":[],"mappings":";;;AAGA,0CAA2C;AAE3C,MAAa,oBAAoB;IAI/B,YAAmB,qBAA4C;QAFxD,sBAAiB,GAAG,CAAC,wBAAa,CAAC,CAAA;QAGxC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAA;IACpD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,cAAkE;QACpF,MAAM,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;IAChE,CAAC;CACF;AAXD,oDAWC"}
@@ -0,0 +1,9 @@
1
+ import type { QuestionAnswerService } from '../services';
2
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
3
+ import { QuestionMessage } from '../messages';
4
+ export declare class QuestionMessageHandler implements MessageHandler {
5
+ private questionAnswerService;
6
+ supportedMessages: (typeof QuestionMessage)[];
7
+ constructor(questionAnswerService: QuestionAnswerService);
8
+ handle(messageContext: MessageHandlerInboundMessage<QuestionMessageHandler>): Promise<void>;
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionMessageHandler = void 0;
4
+ const messages_1 = require("../messages");
5
+ class QuestionMessageHandler {
6
+ constructor(questionAnswerService) {
7
+ this.supportedMessages = [messages_1.QuestionMessage];
8
+ this.questionAnswerService = questionAnswerService;
9
+ }
10
+ async handle(messageContext) {
11
+ await this.questionAnswerService.processReceiveQuestion(messageContext);
12
+ }
13
+ }
14
+ exports.QuestionMessageHandler = QuestionMessageHandler;
15
+ //# sourceMappingURL=QuestionMessageHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuestionMessageHandler.js","sourceRoot":"","sources":["../../src/handlers/QuestionMessageHandler.ts"],"names":[],"mappings":";;;AAGA,0CAA6C;AAE7C,MAAa,sBAAsB;IAIjC,YAAmB,qBAA4C;QAFxD,sBAAiB,GAAG,CAAC,0BAAe,CAAC,CAAA;QAG1C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAA;IACpD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,cAAoE;QACtF,MAAM,IAAI,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAA;IACzE,CAAC;CACF;AAXD,wDAWC"}
@@ -0,0 +1,2 @@
1
+ export * from './QuestionMessageHandler';
2
+ export * from './AnswerMessageHandler';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./QuestionMessageHandler"), exports);
18
+ __exportStar(require("./AnswerMessageHandler"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,yDAAsC"}
@@ -0,0 +1,8 @@
1
+ export * from './messages';
2
+ export * from './models';
3
+ export * from './services';
4
+ export * from './repository';
5
+ export * from './QuestionAnswerEvents';
6
+ export * from './QuestionAnswerApi';
7
+ export * from './QuestionAnswerRole';
8
+ export * from './QuestionAnswerModule';