Skip to content

Commit 505aa17

Browse files
feat: agenting.py type hints and OpenAPI specs #377
1 parent e6b3a3c commit 505aa17

File tree

5 files changed

+385
-108
lines changed

5 files changed

+385
-108
lines changed

src/keri/app/contacting.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ export class Challenges {
183183
* Mark challenge response as signed and accepted
184184
* @param source Prefix of the identifier that was challenged
185185
* @param said qb64 AID of exn message representing the signed response
186-
* @returns {Promise<Response>} A promise to the result
186+
* @returns {Promise<Operation<any>>} A promise to the result
187187
*/
188-
async responded(source: string, said: string): Promise<Response> {
188+
async responded(source: string, said: string): Promise<Operation<any>> {
189189
const path = `/challenges_verify/${source}`;
190190
const method = 'PUT';
191191
const data = {
192192
said: said,
193193
};
194194
const res = await this.client.fetch(path, method, data);
195-
return res;
195+
return await res.json() as Operation<any>;
196196
}
197197
}

src/keri/app/coring.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { Matter, MtrDex } from '../core/matter.ts';
55
import { components } from '../../types/keria-api-schema.ts';
66

77
type OOBI = components['schemas']['OOBI'];
8+
type KeyState = components['schemas']['KeyStateRecord'];
9+
type KeyEventRecord = components['schemas']['KeyEventRecord'];
10+
type AgentConfig = components['schemas']['AgentConfig'];
811

912
export function randomPasscode(): string {
1013
const raw = libsodium.randombytes_buf(16);
@@ -48,9 +51,9 @@ export class Oobis {
4851
* @async
4952
* @param {string} oobi The OOBI to be resolver
5053
* @param {string} [alias] Optional name or alias to link the OOBI resolution to a contact
51-
* @returns {Promise<any>} A promise to the long-running operation
54+
* @returns {Promise<Operation<any>>} A promise to the long-running operation
5255
*/
53-
async resolve(oobi: string, alias?: string): Promise<any> {
56+
async resolve(oobi: string, alias?: string): Promise<Operation<any>> {
5457
const path = `/oobis`;
5558
const data: any = {
5659
url: oobi,
@@ -85,10 +88,6 @@ export interface OperationsDeps {
8588
): Promise<Response>;
8689
}
8790

88-
export interface AgentConfig {
89-
iurls?: string[];
90-
}
91-
9291
/**
9392
* Operations
9493
* @remarks
@@ -208,9 +207,9 @@ export class KeyEvents {
208207
* Retrieve key events for an identifier
209208
* @async
210209
* @param {string} pre Identifier prefix
211-
* @returns {Promise<any>} A promise to the key events
210+
* @returns {Promise<KeyEventRecord[]>} A promise to the key events
212211
*/
213-
async get(pre: string): Promise<any> {
212+
async get(pre: string): Promise<KeyEventRecord[]> {
214213
const path = `/events?pre=${pre}`;
215214
const data = null;
216215
const method = 'GET';
@@ -236,9 +235,9 @@ export class KeyStates {
236235
* Retriene the key state for an identifier
237236
* @async
238237
* @param {string} pre Identifier prefix
239-
* @returns {Promise<any>} A promise to the key states
238+
* @returns {Promise<KeyState[]>} A promise to the key states
240239
*/
241-
async get(pre: string): Promise<any> {
240+
async get(pre: string): Promise<KeyState[]> {
242241
const path = `/states?pre=${pre}`;
243242
const data = null;
244243
const method = 'GET';
@@ -252,7 +251,7 @@ export class KeyStates {
252251
* @param {Array<string>} pres List of identifier prefixes
253252
* @returns {Promise<any>} A promise to the key states
254253
*/
255-
async list(pres: string[]): Promise<any> {
254+
async list(pres: string[]): Promise<KeyState[]> {
256255
const path = `/states?${pres.map((pre) => `pre=${pre}`).join('&')}`;
257256
const data = null;
258257
const method = 'GET';
@@ -266,9 +265,9 @@ export class KeyStates {
266265
* @param {string} pre Identifier prefix
267266
* @param {number} [sn] Optional sequence number
268267
* @param {any} [anchor] Optional anchor
269-
* @returns {Promise<any>} A promise to the long-running operation
268+
* @returns {Promise<Operation<any>>} A promise to the long-running operation
270269
*/
271-
async query(pre: string, sn?: string, anchor?: any): Promise<any> {
270+
async query(pre: string, sn?: string, anchor?: any): Promise<Operation<any>> {
272271
const path = `/queries`;
273272
const data: any = {
274273
pre: pre,

0 commit comments

Comments
 (0)