From cdad239f0a0ab0a9065a9d4759f27932f9920ddd Mon Sep 17 00:00:00 2001 From: Reza Rahemtola Date: Tue, 5 Nov 2024 02:28:52 +0900 Subject: [PATCH] feat: Agents setup started --- .env.example | 1 + .prettierignore | 2 + package.json | 8 +- public/icons.svg | 26 ++ src/apis/agents/index.ts | 4 + src/apis/agents/schemas.gen.ts | 172 +++++++ src/apis/agents/services.gen.ts | 66 +++ src/apis/agents/types.gen.ts | 102 ++++ src/apis/subscriptions/index.ts | 2 +- src/apis/subscriptions/schemas.gen.ts | 614 ++++++++++++------------- src/apis/subscriptions/services.gen.ts | 170 ++----- src/apis/subscriptions/types.gen.ts | 141 +++--- src/config/env.ts | 5 +- src/layouts/MainLayout.vue | 5 + src/pages/Agents.vue | 27 ++ src/router/routes.ts | 4 + src/stores/subscription.ts | 13 +- 17 files changed, 852 insertions(+), 510 deletions(-) create mode 100644 .prettierignore create mode 100644 src/apis/agents/index.ts create mode 100644 src/apis/agents/schemas.gen.ts create mode 100644 src/apis/agents/services.gen.ts create mode 100644 src/apis/agents/types.gen.ts create mode 100644 src/pages/Agents.vue diff --git a/.env.example b/.env.example index c45c337..52a2b02 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ WALLET_CONNECT_PROJECT_ID= # APIs LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000 +LTAI_AGENTS_API_URL=http://localhost:8001 # RPCs SOLANA_RPC= diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f920b49 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +src/apis/agents +src/apis/subscriptions diff --git a/package.json b/package.json index 1ef3e8e..7ec5e87 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,13 @@ "scripts": { "lint": "eslint --fix --ext .js,.ts,.vue ./", "lint:check": "eslint --ext .js,.ts,.vue ./", - "format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore", - "format:check": "prettier --check \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore", + "format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\"", + "format:check": "prettier --check \"**/*.{js,ts,vue,scss,html,md,json}\"", "dev": "quasar dev", "build": "quasar build", - "generate-subscriptions-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/apis/subscriptions --client @hey-api/client-axios" + "generate-clients": "npm run generate-subscriptions-client; npm run generate-agents-client", + "generate-subscriptions-client": "openapi-ts --input http://localhost:8000/openapi.json --output ./src/apis/subscriptions --client @hey-api/client-axios", + "generate-agents-client": "openapi-ts --input http://localhost:8001/openapi.json --output ./src/apis/agents --client @hey-api/client-axios" }, "dependencies": { "@aleph-sdk/base": "^1.2.0", diff --git a/public/icons.svg b/public/icons.svg index 50e89a0..20d51bc 100644 --- a/public/icons.svg +++ b/public/icons.svg @@ -260,4 +260,30 @@ + + + + + + + + + + + + + + + + diff --git a/src/apis/agents/index.ts b/src/apis/agents/index.ts new file mode 100644 index 0000000..0a2b84b --- /dev/null +++ b/src/apis/agents/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts +export * from './schemas.gen'; +export * from './services.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/src/apis/agents/schemas.gen.ts b/src/apis/agents/schemas.gen.ts new file mode 100644 index 0000000..86fa42c --- /dev/null +++ b/src/apis/agents/schemas.gen.ts @@ -0,0 +1,172 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export const Body_update_agent__agent_id__putSchema = { + properties: { + secret: { + type: 'string', + title: 'Secret' + }, + code: { + type: 'string', + format: 'binary', + title: 'Code' + }, + packages: { + type: 'string', + format: 'binary', + title: 'Packages' + } + }, + type: 'object', + required: ['secret', 'code', 'packages'], + title: 'Body_update_agent__agent_id__put' +} as const; + +export const DeleteAgentBodySchema = { + properties: { + subscription_id: { + type: 'string', + title: 'Subscription Id' + }, + password: { + type: 'string', + title: 'Password' + } + }, + type: 'object', + required: ['subscription_id', 'password'], + title: 'DeleteAgentBody' +} as const; + +export const GetAgentResponseSchema = { + properties: { + id: { + type: 'string', + title: 'Id' + }, + vm_hash: { + type: 'string', + title: 'Vm Hash' + }, + last_update: { + type: 'integer', + title: 'Last Update' + } + }, + type: 'object', + required: ['id', 'last_update'], + title: 'GetAgentResponse' +} as const; + +export const GetAgentSecretResponseSchema = { + properties: { + secret: { + type: 'string', + title: 'Secret' + } + }, + type: 'object', + required: ['secret'], + title: 'GetAgentSecretResponse' +} as const; + +export const HTTPValidationErrorSchema = { + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' +} as const; + +export const SetupAgentBodySchema = { + properties: { + subscription_id: { + type: 'string', + title: 'Subscription Id' + }, + password: { + type: 'string', + title: 'Password' + }, + account: { + '$ref': '#/components/schemas/SubscriptionAccount' + } + }, + type: 'object', + required: ['subscription_id', 'password', 'account'], + title: 'SetupAgentBody' +} as const; + +export const SubscriptionAccountSchema = { + properties: { + address: { + type: 'string', + title: 'Address' + }, + chain: { + '$ref': '#/components/schemas/SubscriptionChain' + } + }, + type: 'object', + required: ['address', 'chain'], + title: 'SubscriptionAccount', + example: { + address: '0x0000000000000000000000000000000000000000', + chain: 'base' + } +} as const; + +export const SubscriptionChainSchema = { + type: 'string', + enum: ['base', 'solana'], + title: 'SubscriptionChain', + description: 'An enumeration.' +} as const; + +export const UpdateAgentResponseSchema = { + properties: { + vm_hash: { + type: 'string', + title: 'Vm Hash' + } + }, + type: 'object', + required: ['vm_hash'], + title: 'UpdateAgentResponse' +} as const; + +export const ValidationErrorSchema = { + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { + type: 'string', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } + }, + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' +} as const; \ No newline at end of file diff --git a/src/apis/agents/services.gen.ts b/src/apis/agents/services.gen.ts new file mode 100644 index 0000000..abf1fe7 --- /dev/null +++ b/src/apis/agents/services.gen.ts @@ -0,0 +1,66 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createClient, createConfig, type Options, formDataBodySerializer } from '@hey-api/client-axios'; +import type { SetupAgentPostData, SetupAgentPostError, SetupAgentPostResponse, DeleteAgentDeleteData, DeleteAgentDeleteError, DeleteAgentDeleteResponse, GetAgentPublicInfoAgentAgentIdGetData, GetAgentPublicInfoAgentAgentIdGetError, GetAgentPublicInfoAgentAgentIdGetResponse, UpdateAgentAgentIdPutData, UpdateAgentAgentIdPutError, UpdateAgentAgentIdPutResponse, GetAgentSecretAgentAgentIdSecretGetData, GetAgentSecretAgentAgentIdSecretGetError, GetAgentSecretAgentAgentIdSecretGetResponse } from './types.gen'; + +export const client = createClient(createConfig()); + +/** + * Setup + * Setup a new agent on subscription + */ +export const setupAgentPost = (options: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/agent' + }); +}; + +/** + * Delete + * Remove an agent on subscription end + */ +export const deleteAgentDelete = (options: Options) => { + return (options?.client ?? client).delete({ + ...options, + url: '/agent' + }); +}; + +/** + * Get Agent Public Info + * Get an agent public information + */ +export const getAgentPublicInfoAgentAgentIdGet = (options: Options) => { + return (options?.client ?? client).get({ + ...options, + url: '/agent/{agent_id}' + }); +}; + +/** + * Update + * Deploy an agent or update it + */ +export const updateAgentAgentIdPut = (options: Options) => { + return (options?.client ?? client).put({ + ...options, + ...formDataBodySerializer, + headers: { + 'Content-Type': null, + ...options?.headers + }, + url: '/agent/{agent_id}' + }); +}; + +/** + * Get Agent Secret + * Get an agent secret + */ +export const getAgentSecretAgentAgentIdSecretGet = (options: Options) => { + return (options?.client ?? client).get({ + ...options, + url: '/agent/{agent_id}/secret' + }); +}; \ No newline at end of file diff --git a/src/apis/agents/types.gen.ts b/src/apis/agents/types.gen.ts new file mode 100644 index 0000000..5614452 --- /dev/null +++ b/src/apis/agents/types.gen.ts @@ -0,0 +1,102 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Body_update_agent__agent_id__put = { + secret: string; + code: (Blob | File); + packages: (Blob | File); +}; + +export type DeleteAgentBody = { + subscription_id: string; + password: string; +}; + +export type GetAgentResponse = { + id: string; + vm_hash?: string; + last_update: number; +}; + +export type GetAgentSecretResponse = { + secret: string; +}; + +export type HTTPValidationError = { + detail?: Array; +}; + +export type SetupAgentBody = { + subscription_id: string; + password: string; + account: SubscriptionAccount; +}; + +export type SubscriptionAccount = { + address: string; + chain: SubscriptionChain; +}; + +/** + * An enumeration. + */ +export type SubscriptionChain = 'base' | 'solana'; + +export type UpdateAgentResponse = { + vm_hash: string; +}; + +export type ValidationError = { + loc: Array<(string | number)>; + msg: string; + type: string; +}; + +export type SetupAgentPostData = { + body: SetupAgentBody; +}; + +export type SetupAgentPostResponse = (unknown); + +export type SetupAgentPostError = (HTTPValidationError); + +export type DeleteAgentDeleteData = { + body: DeleteAgentBody; +}; + +export type DeleteAgentDeleteResponse = (unknown); + +export type DeleteAgentDeleteError = (HTTPValidationError); + +export type GetAgentPublicInfoAgentAgentIdGetData = { + path: { + agent_id: string; + }; +}; + +export type GetAgentPublicInfoAgentAgentIdGetResponse = (GetAgentResponse); + +export type GetAgentPublicInfoAgentAgentIdGetError = (HTTPValidationError); + +export type UpdateAgentAgentIdPutData = { + body: Body_update_agent__agent_id__put; + path: { + agent_id: string; + }; +}; + +export type UpdateAgentAgentIdPutResponse = (UpdateAgentResponse); + +export type UpdateAgentAgentIdPutError = (HTTPValidationError); + +export type GetAgentSecretAgentAgentIdSecretGetData = { + path: { + agent_id: string; + }; + query: { + signature: string; + }; +}; + +export type GetAgentSecretAgentAgentIdSecretGetResponse = (GetAgentSecretResponse); + +export type GetAgentSecretAgentAgentIdSecretGetError = (HTTPValidationError); \ No newline at end of file diff --git a/src/apis/subscriptions/index.ts b/src/apis/subscriptions/index.ts index 002afc3..0a2b84b 100644 --- a/src/apis/subscriptions/index.ts +++ b/src/apis/subscriptions/index.ts @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts export * from './schemas.gen'; export * from './services.gen'; -export * from './types.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/src/apis/subscriptions/schemas.gen.ts b/src/apis/subscriptions/schemas.gen.ts index a8b38c3..bd1b13b 100644 --- a/src/apis/subscriptions/schemas.gen.ts +++ b/src/apis/subscriptions/schemas.gen.ts @@ -1,381 +1,381 @@ // This file is auto-generated by @hey-api/openapi-ts export const BaseSubscriptionSchema = { - properties: { - id: { - type: 'string', - title: 'Id', - }, - type: { - $ref: '#/components/schemas/SubscriptionType', - }, - provider: { - $ref: '#/components/schemas/SubscriptionProvider', - }, - started_at: { - type: 'integer', - title: 'Started At', - }, - ended_at: { - type: 'integer', - title: 'Ended At', - }, - is_active: { - type: 'boolean', - title: 'Is Active', - }, - }, - type: 'object', - required: ['id', 'type', 'provider', 'started_at', 'is_active'], - title: 'BaseSubscription', + properties: { + id: { + type: 'string', + title: 'Id' + }, + type: { + '$ref': '#/components/schemas/SubscriptionType' + }, + provider: { + '$ref': '#/components/schemas/SubscriptionProvider' + }, + started_at: { + type: 'integer', + title: 'Started At' + }, + ended_at: { + type: 'integer', + title: 'Ended At' + }, + is_active: { + type: 'boolean', + title: 'Is Active' + } + }, + type: 'object', + required: ['id', 'type', 'provider', 'started_at', 'is_active'], + title: 'BaseSubscription' } as const; export const GetUserSubscriptionsResponseSchema = { - properties: { - subscriptions: { - items: { - $ref: '#/components/schemas/BaseSubscription', - }, - type: 'array', - title: 'Subscriptions', - }, - }, - type: 'object', - required: ['subscriptions'], - title: 'GetUserSubscriptionsResponse', + properties: { + subscriptions: { + items: { + '$ref': '#/components/schemas/BaseSubscription' + }, + type: 'array', + title: 'Subscriptions' + } + }, + type: 'object', + required: ['subscriptions'], + title: 'GetUserSubscriptionsResponse' } as const; export const HTTPValidationErrorSchema = { - properties: { - detail: { - items: { - $ref: '#/components/schemas/ValidationError', - }, - type: 'array', - title: 'Detail', - }, - }, - type: 'object', - title: 'HTTPValidationError', + properties: { + detail: { + items: { + '$ref': '#/components/schemas/ValidationError' + }, + type: 'array', + title: 'Detail' + } + }, + type: 'object', + title: 'HTTPValidationError' } as const; export const HoldDeleteSubscriptionBodySchema = { - properties: { - account: { - $ref: '#/components/schemas/SubscriptionAccount', - }, - signature: { - type: 'string', - title: 'Signature', - }, - type: { - $ref: '#/components/schemas/SubscriptionType', - }, - subscription_id: { - type: 'string', - title: 'Subscription Id', + properties: { + account: { + '$ref': '#/components/schemas/SubscriptionAccount' + }, + signature: { + type: 'string', + title: 'Signature' + }, + type: { + '$ref': '#/components/schemas/SubscriptionType' + }, + subscription_id: { + type: 'string', + title: 'Subscription Id' + } }, - }, - type: 'object', - required: ['account', 'signature', 'type', 'subscription_id'], - title: 'HoldDeleteSubscriptionBody', + type: 'object', + required: ['account', 'signature', 'type', 'subscription_id'], + title: 'HoldDeleteSubscriptionBody' } as const; export const HoldDeleteSubscriptionResponseSchema = { - properties: { - success: { - type: 'boolean', - title: 'Success', - }, - }, - type: 'object', - required: ['success'], - title: 'HoldDeleteSubscriptionResponse', + properties: { + success: { + type: 'boolean', + title: 'Success' + } + }, + type: 'object', + required: ['success'], + title: 'HoldDeleteSubscriptionResponse' } as const; export const HoldGetMessagesResponseSchema = { - properties: { - subscribe_message: { - type: 'string', - title: 'Subscribe Message', - }, - unsubscribe_message: { - type: 'string', - title: 'Unsubscribe Message', + properties: { + subscribe_message: { + type: 'string', + title: 'Subscribe Message' + }, + unsubscribe_message: { + type: 'string', + title: 'Unsubscribe Message' + } }, - }, - type: 'object', - required: ['subscribe_message', 'unsubscribe_message'], - title: 'HoldGetMessagesResponse', + type: 'object', + required: ['subscribe_message', 'unsubscribe_message'], + title: 'HoldGetMessagesResponse' } as const; export const HoldPostRefreshSubscriptionsResponseSchema = { - properties: { - cancelled_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Cancelled Subscriptions', - }, - }, - type: 'object', - required: ['cancelled_subscriptions'], - title: 'HoldPostRefreshSubscriptionsResponse', + properties: { + cancelled_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Cancelled Subscriptions' + } + }, + type: 'object', + required: ['cancelled_subscriptions'], + title: 'HoldPostRefreshSubscriptionsResponse' } as const; export const HoldPostSubscriptionBodySchema = { - properties: { - account: { - $ref: '#/components/schemas/SubscriptionAccount', - }, - signature: { - type: 'string', - title: 'Signature', - }, - type: { - $ref: '#/components/schemas/SubscriptionType', - }, - }, - type: 'object', - required: ['account', 'signature', 'type'], - title: 'HoldPostSubscriptionBody', + properties: { + account: { + '$ref': '#/components/schemas/SubscriptionAccount' + }, + signature: { + type: 'string', + title: 'Signature' + }, + type: { + '$ref': '#/components/schemas/SubscriptionType' + } + }, + type: 'object', + required: ['account', 'signature', 'type'], + title: 'HoldPostSubscriptionBody' } as const; export const HoldPostSubscriptionResponseSchema = { - properties: { - post_hash: { - type: 'string', - title: 'Post Hash', - }, - subscription_id: { - type: 'string', - title: 'Subscription Id', + properties: { + post_hash: { + type: 'string', + title: 'Post Hash' + }, + subscription_id: { + type: 'string', + title: 'Subscription Id' + } }, - }, - type: 'object', - required: ['post_hash', 'subscription_id'], - title: 'HoldPostSubscriptionResponse', + type: 'object', + required: ['post_hash', 'subscription_id'], + title: 'HoldPostSubscriptionResponse' } as const; export const SubsPostRefreshSubscriptionsResponseSchema = { - properties: { - created_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Created Subscriptions', - }, - cancelled_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Cancelled Subscriptions', - }, - }, - type: 'object', - required: ['created_subscriptions', 'cancelled_subscriptions'], - title: 'SubsPostRefreshSubscriptionsResponse', + properties: { + created_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Created Subscriptions' + }, + cancelled_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Cancelled Subscriptions' + } + }, + type: 'object', + required: ['created_subscriptions', 'cancelled_subscriptions'], + title: 'SubsPostRefreshSubscriptionsResponse' } as const; export const SubscriptionAccountSchema = { - properties: { - address: { - type: 'string', - title: 'Address', - }, - chain: { - $ref: '#/components/schemas/SubscriptionChain', - }, - }, - type: 'object', - required: ['address', 'chain'], - title: 'SubscriptionAccount', - example: { - address: '0x0000000000000000000000000000000000000000', - chain: 'base', - }, + properties: { + address: { + type: 'string', + title: 'Address' + }, + chain: { + '$ref': '#/components/schemas/SubscriptionChain' + } + }, + type: 'object', + required: ['address', 'chain'], + title: 'SubscriptionAccount', + example: { + address: '0x0000000000000000000000000000000000000000', + chain: 'base' + } } as const; export const SubscriptionChainSchema = { - type: 'string', - enum: ['base'], - title: 'SubscriptionChain', - description: 'An enumeration.', + type: 'string', + enum: ['base', 'solana'], + title: 'SubscriptionChain', + description: 'An enumeration.' } as const; export const SubscriptionProviderSchema = { - type: 'string', - enum: ['hold', 'subs', 'vouchers'], - title: 'SubscriptionProvider', - description: 'An enumeration.', + type: 'string', + enum: ['hold', 'subs', 'vouchers'], + title: 'SubscriptionProvider', + description: 'An enumeration.' } as const; export const SubscriptionTypeSchema = { - type: 'string', - enum: ['pro', 'advanced', 'agent'], - title: 'SubscriptionType', - description: 'An enumeration.', + type: 'string', + enum: ['pro', 'advanced', 'agent'], + title: 'SubscriptionType', + description: 'An enumeration.' } as const; export const ValidationErrorSchema = { - properties: { - loc: { - items: { - anyOf: [ - { + properties: { + loc: { + items: { + anyOf: [ + { + type: 'string' + }, + { + type: 'integer' + } + ] + }, + type: 'array', + title: 'Location' + }, + msg: { type: 'string', - }, - { - type: 'integer', - }, - ], - }, - type: 'array', - title: 'Location', - }, - msg: { - type: 'string', - title: 'Message', - }, - type: { - type: 'string', - title: 'Error Type', + title: 'Message' + }, + type: { + type: 'string', + title: 'Error Type' + } }, - }, - type: 'object', - required: ['loc', 'msg', 'type'], - title: 'ValidationError', + type: 'object', + required: ['loc', 'msg', 'type'], + title: 'ValidationError' } as const; export const VouchersCreatedSubscriptionSchema = { - properties: { - account: { - $ref: '#/components/schemas/SubscriptionAccount', - }, - type: { - $ref: '#/components/schemas/SubscriptionType', - }, - end_time: { - type: 'integer', - title: 'End Time', - }, - post_hash: { - type: 'string', - title: 'Post Hash', - }, - subscription_id: { - type: 'string', - title: 'Subscription Id', + properties: { + account: { + '$ref': '#/components/schemas/SubscriptionAccount' + }, + type: { + '$ref': '#/components/schemas/SubscriptionType' + }, + end_time: { + type: 'integer', + title: 'End Time' + }, + post_hash: { + type: 'string', + title: 'Post Hash' + }, + subscription_id: { + type: 'string', + title: 'Subscription Id' + } }, - }, - type: 'object', - required: ['account', 'type', 'end_time', 'post_hash', 'subscription_id'], - title: 'VouchersCreatedSubscription', + type: 'object', + required: ['account', 'type', 'end_time', 'post_hash', 'subscription_id'], + title: 'VouchersCreatedSubscription' } as const; export const VouchersDeleteSubscribeBodySchema = { - properties: { - subscription_ids: { - items: { - type: 'string', - }, - type: 'array', - title: 'Subscription Ids', - }, - }, - type: 'object', - required: ['subscription_ids'], - title: 'VouchersDeleteSubscribeBody', + properties: { + subscription_ids: { + items: { + type: 'string' + }, + type: 'array', + title: 'Subscription Ids' + } + }, + type: 'object', + required: ['subscription_ids'], + title: 'VouchersDeleteSubscribeBody' } as const; export const VouchersDeleteSubscriptionResponseSchema = { - properties: { - cancelled_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Cancelled Subscriptions', - }, - not_found_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Not Found Subscriptions', - }, - }, - type: 'object', - required: ['cancelled_subscriptions', 'not_found_subscriptions'], - title: 'VouchersDeleteSubscriptionResponse', + properties: { + cancelled_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Cancelled Subscriptions' + }, + not_found_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Not Found Subscriptions' + } + }, + type: 'object', + required: ['cancelled_subscriptions', 'not_found_subscriptions'], + title: 'VouchersDeleteSubscriptionResponse' } as const; export const VouchersPostRefreshSubscriptionsResponseSchema = { - properties: { - cancelled_subscriptions: { - items: { - type: 'string', - }, - type: 'array', - title: 'Cancelled Subscriptions', - }, - }, - type: 'object', - required: ['cancelled_subscriptions'], - title: 'VouchersPostRefreshSubscriptionsResponse', + properties: { + cancelled_subscriptions: { + items: { + type: 'string' + }, + type: 'array', + title: 'Cancelled Subscriptions' + } + }, + type: 'object', + required: ['cancelled_subscriptions'], + title: 'VouchersPostRefreshSubscriptionsResponse' } as const; export const VouchersPostSubscribeBodySchema = { - properties: { - subscriptions: { - items: { - $ref: '#/components/schemas/VouchersSubscription', - }, - type: 'array', - title: 'Subscriptions', - }, - password: { - type: 'string', - title: 'Password', + properties: { + subscriptions: { + items: { + '$ref': '#/components/schemas/VouchersSubscription' + }, + type: 'array', + title: 'Subscriptions' + }, + password: { + type: 'string', + title: 'Password' + } }, - }, - type: 'object', - required: ['subscriptions', 'password'], - title: 'VouchersPostSubscribeBody', + type: 'object', + required: ['subscriptions', 'password'], + title: 'VouchersPostSubscribeBody' } as const; export const VouchersPostSubscriptionResponseSchema = { - properties: { - created_subscriptions: { - items: { - $ref: '#/components/schemas/VouchersCreatedSubscription', - }, - type: 'array', - title: 'Created Subscriptions', - }, - }, - type: 'object', - required: ['created_subscriptions'], - title: 'VouchersPostSubscriptionResponse', + properties: { + created_subscriptions: { + items: { + '$ref': '#/components/schemas/VouchersCreatedSubscription' + }, + type: 'array', + title: 'Created Subscriptions' + } + }, + type: 'object', + required: ['created_subscriptions'], + title: 'VouchersPostSubscriptionResponse' } as const; export const VouchersSubscriptionSchema = { - properties: { - account: { - $ref: '#/components/schemas/SubscriptionAccount', - }, - type: { - $ref: '#/components/schemas/SubscriptionType', - }, - end_time: { - type: 'integer', - title: 'End Time', + properties: { + account: { + '$ref': '#/components/schemas/SubscriptionAccount' + }, + type: { + '$ref': '#/components/schemas/SubscriptionType' + }, + end_time: { + type: 'integer', + title: 'End Time' + } }, - }, - type: 'object', - required: ['account', 'type', 'end_time'], - title: 'VouchersSubscription', -} as const; + type: 'object', + required: ['account', 'type', 'end_time'], + title: 'VouchersSubscription' +} as const; \ No newline at end of file diff --git a/src/apis/subscriptions/services.gen.ts b/src/apis/subscriptions/services.gen.ts index d21359c..fcaa9db 100644 --- a/src/apis/subscriptions/services.gen.ts +++ b/src/apis/subscriptions/services.gen.ts @@ -1,180 +1,104 @@ // This file is auto-generated by @hey-api/openapi-ts import { createClient, createConfig, type Options } from '@hey-api/client-axios'; - -import type { - GetUserSubscriptionsSubscriptionsGetData, - GetUserSubscriptionsSubscriptionsGetError, - GetUserSubscriptionsSubscriptionsGetResponse, - SubscribeHoldSubscriptionPostData, - SubscribeHoldSubscriptionPostError, - SubscribeHoldSubscriptionPostResponse, - UnsubscribeHoldSubscriptionDeleteData, - UnsubscribeHoldSubscriptionDeleteError, - UnsubscribeHoldSubscriptionDeleteResponse, - RefreshActiveHoldSubscriptionsHoldRefreshPostError, - RefreshActiveHoldSubscriptionsHoldRefreshPostResponse, - HoldSubscriptionMessagesHoldMessageGetData, - HoldSubscriptionMessagesHoldMessageGetError, - HoldSubscriptionMessagesHoldMessageGetResponse, - RefreshSubsRefreshPostError, - RefreshSubsRefreshPostResponse, - SubscribeVouchersSubscriptionPostData, - SubscribeVouchersSubscriptionPostError, - SubscribeVouchersSubscriptionPostResponse, - CancelVouchersSubscriptionsVouchersSubscriptionDeleteData, - CancelVouchersSubscriptionsVouchersSubscriptionDeleteError, - CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse, - RefreshActiveVouchersSubscriptionsVouchersRefreshPostError, - RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse, -} from './types.gen'; +import type { GetUserSubscriptionsSubscriptionsGetData, GetUserSubscriptionsSubscriptionsGetError, GetUserSubscriptionsSubscriptionsGetResponse, SubscribeHoldSubscriptionPostData, SubscribeHoldSubscriptionPostError, SubscribeHoldSubscriptionPostResponse, UnsubscribeHoldSubscriptionDeleteData, UnsubscribeHoldSubscriptionDeleteError, UnsubscribeHoldSubscriptionDeleteResponse, RefreshActiveHoldSubscriptionsHoldRefreshPostError, RefreshActiveHoldSubscriptionsHoldRefreshPostResponse, HoldSubscriptionMessagesHoldMessageGetData, HoldSubscriptionMessagesHoldMessageGetError, HoldSubscriptionMessagesHoldMessageGetResponse, RefreshSubsRefreshPostError, RefreshSubsRefreshPostResponse, SubscribeVouchersSubscriptionPostData, SubscribeVouchersSubscriptionPostError, SubscribeVouchersSubscriptionPostResponse, CancelVouchersSubscriptionsVouchersSubscriptionDeleteData, CancelVouchersSubscriptionsVouchersSubscriptionDeleteError, CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse, RefreshActiveVouchersSubscriptionsVouchersRefreshPostError, RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse } from './types.gen'; export const client = createClient(createConfig()); /** * Get User Subscriptions */ -export const getUserSubscriptionsSubscriptionsGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - GetUserSubscriptionsSubscriptionsGetResponse, - GetUserSubscriptionsSubscriptionsGetError, - ThrowOnError - >({ - ...options, - url: '/subscriptions', - }); +export const getUserSubscriptionsSubscriptionsGet = (options: Options) => { + return (options?.client ?? client).get({ + ...options, + url: '/subscriptions' + }); }; /** * Subscribe * Subscribe to a plan */ -export const subscribeHoldSubscriptionPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - SubscribeHoldSubscriptionPostResponse, - SubscribeHoldSubscriptionPostError, - ThrowOnError - >({ - ...options, - url: '/hold/subscription', - }); +export const subscribeHoldSubscriptionPost = (options: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/hold/subscription' + }); }; /** * Unsubscribe * Unsubscribe of an existing subscription */ -export const unsubscribeHoldSubscriptionDelete = ( - options: Options, -) => { - return (options?.client ?? client).delete< - UnsubscribeHoldSubscriptionDeleteResponse, - UnsubscribeHoldSubscriptionDeleteError, - ThrowOnError - >({ - ...options, - url: '/hold/subscription', - }); +export const unsubscribeHoldSubscriptionDelete = (options: Options) => { + return (options?.client ?? client).delete({ + ...options, + url: '/hold/subscription' + }); }; /** * Refresh Active Hold Subscriptions * Delete existing active hold subscriptions if not enough tokens held in the wallet */ -export const refreshActiveHoldSubscriptionsHoldRefreshPost = ( - options?: Options, -) => { - return (options?.client ?? client).post< - RefreshActiveHoldSubscriptionsHoldRefreshPostResponse, - RefreshActiveHoldSubscriptionsHoldRefreshPostError, - ThrowOnError - >({ - ...options, - url: '/hold/refresh', - }); +export const refreshActiveHoldSubscriptionsHoldRefreshPost = (options?: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/hold/refresh' + }); }; /** * Hold Subscription Messages * Returns the messages to sign to authenticate other actions */ -export const holdSubscriptionMessagesHoldMessageGet = ( - options: Options, -) => { - return (options?.client ?? client).get< - HoldSubscriptionMessagesHoldMessageGetResponse, - HoldSubscriptionMessagesHoldMessageGetError, - ThrowOnError - >({ - ...options, - url: '/hold/message', - }); +export const holdSubscriptionMessagesHoldMessageGet = (options: Options) => { + return (options?.client ?? client).get({ + ...options, + url: '/hold/message' + }); }; /** * Refresh * Cancel existing unpaid subscriptions and creating newly paid ones */ -export const refreshSubsRefreshPost = ( - options?: Options, -) => { - return (options?.client ?? client).post({ - ...options, - url: '/subs/refresh', - }); +export const refreshSubsRefreshPost = (options?: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/subs/refresh' + }); }; /** * Subscribe * Create one or multiple vouchers subscriptions */ -export const subscribeVouchersSubscriptionPost = ( - options: Options, -) => { - return (options?.client ?? client).post< - SubscribeVouchersSubscriptionPostResponse, - SubscribeVouchersSubscriptionPostError, - ThrowOnError - >({ - ...options, - url: '/vouchers/subscription', - }); +export const subscribeVouchersSubscriptionPost = (options: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/vouchers/subscription' + }); }; /** * Cancel Vouchers Subscriptions * Stop some vouchers subscriptions */ -export const cancelVouchersSubscriptionsVouchersSubscriptionDelete = ( - options: Options, -) => { - return (options?.client ?? client).delete< - CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse, - CancelVouchersSubscriptionsVouchersSubscriptionDeleteError, - ThrowOnError - >({ - ...options, - url: '/vouchers/subscription', - }); +export const cancelVouchersSubscriptionsVouchersSubscriptionDelete = (options: Options) => { + return (options?.client ?? client).delete({ + ...options, + url: '/vouchers/subscription' + }); }; /** * Refresh Active Vouchers Subscriptions * Check existing vouchers subscriptions to stop if the end_date is passed */ -export const refreshActiveVouchersSubscriptionsVouchersRefreshPost = ( - options?: Options, -) => { - return (options?.client ?? client).post< - RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse, - RefreshActiveVouchersSubscriptionsVouchersRefreshPostError, - ThrowOnError - >({ - ...options, - url: '/vouchers/refresh', - }); -}; +export const refreshActiveVouchersSubscriptionsVouchersRefreshPost = (options?: Options) => { + return (options?.client ?? client).post({ + ...options, + url: '/vouchers/refresh' + }); +}; \ No newline at end of file diff --git a/src/apis/subscriptions/types.gen.ts b/src/apis/subscriptions/types.gen.ts index 1cf71ce..d6c50fd 100644 --- a/src/apis/subscriptions/types.gen.ts +++ b/src/apis/subscriptions/types.gen.ts @@ -1,67 +1,67 @@ // This file is auto-generated by @hey-api/openapi-ts export type BaseSubscription = { - id: string; - type: SubscriptionType; - provider: SubscriptionProvider; - started_at: number; - ended_at?: number; - is_active: boolean; + id: string; + type: SubscriptionType; + provider: SubscriptionProvider; + started_at: number; + ended_at?: number; + is_active: boolean; }; export type GetUserSubscriptionsResponse = { - subscriptions: Array; + subscriptions: Array; }; export type HTTPValidationError = { - detail?: Array; + detail?: Array; }; export type HoldDeleteSubscriptionBody = { - account: SubscriptionAccount; - signature: string; - type: SubscriptionType; - subscription_id: string; + account: SubscriptionAccount; + signature: string; + type: SubscriptionType; + subscription_id: string; }; export type HoldDeleteSubscriptionResponse = { - success: boolean; + success: boolean; }; export type HoldGetMessagesResponse = { - subscribe_message: string; - unsubscribe_message: string; + subscribe_message: string; + unsubscribe_message: string; }; export type HoldPostRefreshSubscriptionsResponse = { - cancelled_subscriptions: Array; + cancelled_subscriptions: Array<(string)>; }; export type HoldPostSubscriptionBody = { - account: SubscriptionAccount; - signature: string; - type: SubscriptionType; + account: SubscriptionAccount; + signature: string; + type: SubscriptionType; }; export type HoldPostSubscriptionResponse = { - post_hash: string; - subscription_id: string; + post_hash: string; + subscription_id: string; }; export type SubsPostRefreshSubscriptionsResponse = { - created_subscriptions: Array; - cancelled_subscriptions: Array; + created_subscriptions: Array<(string)>; + cancelled_subscriptions: Array<(string)>; }; export type SubscriptionAccount = { - address: string; - chain: SubscriptionChain; + address: string; + chain: SubscriptionChain; }; /** * An enumeration. */ -export type SubscriptionChain = 'base'; +export type SubscriptionChain = 'base' | 'solana'; /** * An enumeration. @@ -74,107 +74,108 @@ export type SubscriptionProvider = 'hold' | 'subs' | 'vouchers'; export type SubscriptionType = 'pro' | 'advanced' | 'agent'; export type ValidationError = { - loc: Array; - msg: string; - type: string; + loc: Array<(string | number)>; + msg: string; + type: string; }; export type VouchersCreatedSubscription = { - account: SubscriptionAccount; - type: SubscriptionType; - end_time: number; - post_hash: string; - subscription_id: string; + account: SubscriptionAccount; + type: SubscriptionType; + end_time: number; + post_hash: string; + subscription_id: string; }; export type VouchersDeleteSubscribeBody = { - subscription_ids: Array; + subscription_ids: Array<(string)>; }; export type VouchersDeleteSubscriptionResponse = { - cancelled_subscriptions: Array; - not_found_subscriptions: Array; + cancelled_subscriptions: Array<(string)>; + not_found_subscriptions: Array<(string)>; }; export type VouchersPostRefreshSubscriptionsResponse = { - cancelled_subscriptions: Array; + cancelled_subscriptions: Array<(string)>; }; export type VouchersPostSubscribeBody = { - subscriptions: Array; - password: string; + subscriptions: Array; + password: string; }; export type VouchersPostSubscriptionResponse = { - created_subscriptions: Array; + created_subscriptions: Array; }; export type VouchersSubscription = { - account: SubscriptionAccount; - type: SubscriptionType; - end_time: number; + account: SubscriptionAccount; + type: SubscriptionType; + end_time: number; }; export type GetUserSubscriptionsSubscriptionsGetData = { - query: { - address: string; - }; + query: { + address: string; + chain: SubscriptionChain; + }; }; -export type GetUserSubscriptionsSubscriptionsGetResponse = GetUserSubscriptionsResponse; +export type GetUserSubscriptionsSubscriptionsGetResponse = (GetUserSubscriptionsResponse); -export type GetUserSubscriptionsSubscriptionsGetError = HTTPValidationError; +export type GetUserSubscriptionsSubscriptionsGetError = (HTTPValidationError); export type SubscribeHoldSubscriptionPostData = { - body: HoldPostSubscriptionBody; + body: HoldPostSubscriptionBody; }; -export type SubscribeHoldSubscriptionPostResponse = HoldPostSubscriptionResponse; +export type SubscribeHoldSubscriptionPostResponse = (HoldPostSubscriptionResponse); -export type SubscribeHoldSubscriptionPostError = HTTPValidationError; +export type SubscribeHoldSubscriptionPostError = (HTTPValidationError); export type UnsubscribeHoldSubscriptionDeleteData = { - body: HoldDeleteSubscriptionBody; + body: HoldDeleteSubscriptionBody; }; -export type UnsubscribeHoldSubscriptionDeleteResponse = HoldDeleteSubscriptionResponse; +export type UnsubscribeHoldSubscriptionDeleteResponse = (HoldDeleteSubscriptionResponse); -export type UnsubscribeHoldSubscriptionDeleteError = HTTPValidationError; +export type UnsubscribeHoldSubscriptionDeleteError = (HTTPValidationError); -export type RefreshActiveHoldSubscriptionsHoldRefreshPostResponse = HoldPostRefreshSubscriptionsResponse; +export type RefreshActiveHoldSubscriptionsHoldRefreshPostResponse = (HoldPostRefreshSubscriptionsResponse); export type RefreshActiveHoldSubscriptionsHoldRefreshPostError = unknown; export type HoldSubscriptionMessagesHoldMessageGetData = { - query: { - subscription_type: SubscriptionType; - }; + query: { + subscription_type: SubscriptionType; + }; }; -export type HoldSubscriptionMessagesHoldMessageGetResponse = HoldGetMessagesResponse; +export type HoldSubscriptionMessagesHoldMessageGetResponse = (HoldGetMessagesResponse); -export type HoldSubscriptionMessagesHoldMessageGetError = HTTPValidationError; +export type HoldSubscriptionMessagesHoldMessageGetError = (HTTPValidationError); -export type RefreshSubsRefreshPostResponse = SubsPostRefreshSubscriptionsResponse; +export type RefreshSubsRefreshPostResponse = (SubsPostRefreshSubscriptionsResponse); export type RefreshSubsRefreshPostError = unknown; export type SubscribeVouchersSubscriptionPostData = { - body: VouchersPostSubscribeBody; + body: VouchersPostSubscribeBody; }; -export type SubscribeVouchersSubscriptionPostResponse = VouchersPostSubscriptionResponse; +export type SubscribeVouchersSubscriptionPostResponse = (VouchersPostSubscriptionResponse); -export type SubscribeVouchersSubscriptionPostError = HTTPValidationError; +export type SubscribeVouchersSubscriptionPostError = (HTTPValidationError); export type CancelVouchersSubscriptionsVouchersSubscriptionDeleteData = { - body: VouchersDeleteSubscribeBody; + body: VouchersDeleteSubscribeBody; }; -export type CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse = VouchersDeleteSubscriptionResponse; +export type CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse = (VouchersDeleteSubscriptionResponse); -export type CancelVouchersSubscriptionsVouchersSubscriptionDeleteError = HTTPValidationError; +export type CancelVouchersSubscriptionsVouchersSubscriptionDeleteError = (HTTPValidationError); -export type RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse = VouchersPostRefreshSubscriptionsResponse; +export type RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse = (VouchersPostRefreshSubscriptionsResponse); -export type RefreshActiveVouchersSubscriptionsVouchersRefreshPostError = unknown; +export type RefreshActiveVouchersSubscriptionsVouchersRefreshPostError = unknown; \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts index de4662e..1ecebbf 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -2,8 +2,9 @@ import { base, baseSepolia } from '@wagmi/vue/chains'; import { z } from 'zod'; const envSchema = z.object({ - ALEPH_API_URL: z.string().optional(), - LTAI_SUBSCRIPTIONS_API_URL: z.string(), + ALEPH_API_URL: z.string().url().optional(), + LTAI_SUBSCRIPTIONS_API_URL: z.string().url(), + LTAI_AGENTS_API_URL: z.string().url(), WALLET_CONNECT_PROJECT_ID: z.string(), SOLANA_RPC: z.string().url(), LTAI_BASE_ADDRESS: z.string().startsWith('0x').optional().default('0xF8B1b47AA748F5C7b5D0e80C726a843913EB573a'), diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 3e95168..ee5fba8 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -90,6 +90,11 @@ const accountStore = useAccountStore(); const generalStore = useGeneralStore(); const sidebarItems = [ + { + link: '/agents', + icon: 'svguse:icons.svg#agents', + title: 'Agents (private beta)', + }, { link: '/subscriptions', icon: 'svguse:icons.svg#subscription-star', diff --git a/src/pages/Agents.vue b/src/pages/Agents.vue new file mode 100644 index 0000000..83aaeb3 --- /dev/null +++ b/src/pages/Agents.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/router/routes.ts b/src/router/routes.ts index 477d84c..7c1241d 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -40,6 +40,10 @@ const routes = [ path: 'subscriptions/subscribe', component: () => import('pages/subscriptions/SubscriptionFlow.vue'), }, + { + path: 'agents', + component: () => import('pages/Agents.vue'), + }, { path: 'account', component: () => import('pages/AccountSettings.vue') }, ], }, diff --git a/src/stores/subscription.ts b/src/stores/subscription.ts index 397802d..0a54ba2 100644 --- a/src/stores/subscription.ts +++ b/src/stores/subscription.ts @@ -8,6 +8,7 @@ import { SubscriptionType, } from 'src/apis/subscriptions'; import { config } from 'src/config/wagmi'; +import { useAccountStore } from 'stores/account'; type SubscriptionState = { subscriptions: BaseSubscription[]; @@ -21,14 +22,18 @@ export const useSubscriptionStore = defineStore('subscriptions', { }), actions: { async load() { - const account = getAccount(config); - const address = account.address; + const { account } = useAccountStore(); - if (address === undefined) { + if (account === null) { return; } - const response = await getUserSubscriptionsSubscriptionsGet({ query: { address } }); + const response = await getUserSubscriptionsSubscriptionsGet({ + query: { + address: account.address, + chain: account.chain, + }, + }); this.subscriptions = response.data?.subscriptions ?? []; this.isLoaded = true;