UNPKG

flowus-api-sdk

Version:

Official TypeScript/JavaScript SDK for FlowUs API - Create, manage, and interact with FlowUs pages, databases, and blocks

611 lines (610 loc) 26.4 kB
"use strict"; /* tslint:disable */ /* eslint-disable */ /** * FlowUs API * FlowUs Developer API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultApi = void 0; const runtime = __importStar(require("../runtime")); const index_1 = require("../models/index"); /** * */ class DefaultApi extends runtime.BaseAPI { /** * 向指定块追加一个或多个子块 * 追加子块 */ async appendBlockChildrenRaw(requestParameters, initOverrides) { if (requestParameters['blockId'] == null) { throw new runtime.RequiredError('blockId', 'Required parameter "blockId" was null or undefined when calling appendBlockChildren().'); } if (requestParameters['appendBlockChildrenRequest'] == null) { throw new runtime.RequiredError('appendBlockChildrenRequest', 'Required parameter "appendBlockChildrenRequest" was null or undefined when calling appendBlockChildren().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/blocks/{block_id}/children`; urlPath = urlPath.replace(`{${"block_id"}}`, encodeURIComponent(String(requestParameters['blockId']))); const response = await this.request({ path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: (0, index_1.AppendBlockChildrenRequestToJSON)(requestParameters['appendBlockChildrenRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.AppendBlockChildrenResponseFromJSON)(jsonValue)); } /** * 向指定块追加一个或多个子块 * 追加子块 */ async appendBlockChildren(requestParameters, initOverrides) { const response = await this.appendBlockChildrenRaw(requestParameters, initOverrides); return await response.value(); } /** * 在现有页面下创建一个新的数据库 * 创建数据库 */ async createDatabaseRaw(requestParameters, initOverrides) { if (requestParameters['createDatabaseRequest'] == null) { throw new runtime.RequiredError('createDatabaseRequest', 'Required parameter "createDatabaseRequest" was null or undefined when calling createDatabase().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/databases`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, index_1.CreateDatabaseRequestToJSON)(requestParameters['createDatabaseRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.DatabaseFromJSON)(jsonValue)); } /** * 在现有页面下创建一个新的数据库 * 创建数据库 */ async createDatabase(requestParameters, initOverrides) { const response = await this.createDatabaseRaw(requestParameters, initOverrides); return await response.value(); } /** * 在页面或数据库中创建新页面 * 创建页面 */ async createPageRaw(requestParameters, initOverrides) { if (requestParameters['createPageRequest'] == null) { throw new runtime.RequiredError('createPageRequest', 'Required parameter "createPageRequest" was null or undefined when calling createPage().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/pages`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, index_1.CreatePageRequestToJSON)(requestParameters['createPageRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.CreatePageResponseFromJSON)(jsonValue)); } /** * 在页面或数据库中创建新页面 * 创建页面 */ async createPage(requestParameters, initOverrides) { const response = await this.createPageRaw(requestParameters, initOverrides); return await response.value(); } /** * 删除指定块及其所有子块 * 删除块 */ async deleteBlockRaw(requestParameters, initOverrides) { if (requestParameters['blockId'] == null) { throw new runtime.RequiredError('blockId', 'Required parameter "blockId" was null or undefined when calling deleteBlock().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/blocks/{block_id}`; urlPath = urlPath.replace(`{${"block_id"}}`, encodeURIComponent(String(requestParameters['blockId']))); const response = await this.request({ path: urlPath, method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.DeleteBlockResponseFromJSON)(jsonValue)); } /** * 删除指定块及其所有子块 * 删除块 */ async deleteBlock(requestParameters, initOverrides) { const response = await this.deleteBlockRaw(requestParameters, initOverrides); return await response.value(); } /** * 根据ID获取块对象 * 获取块 */ async getBlockRaw(requestParameters, initOverrides) { if (requestParameters['blockId'] == null) { throw new runtime.RequiredError('blockId', 'Required parameter "blockId" was null or undefined when calling getBlock().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/blocks/{block_id}`; urlPath = urlPath.replace(`{${"block_id"}}`, encodeURIComponent(String(requestParameters['blockId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BlockFromJSON)(jsonValue)); } /** * 根据ID获取块对象 * 获取块 */ async getBlock(requestParameters, initOverrides) { const response = await this.getBlockRaw(requestParameters, initOverrides); return await response.value(); } /** * 获取指定块的子块列表 * 获取子块 */ async getBlockChildrenRaw(requestParameters, initOverrides) { if (requestParameters['blockId'] == null) { throw new runtime.RequiredError('blockId', 'Required parameter "blockId" was null or undefined when calling getBlockChildren().'); } const queryParameters = {}; if (requestParameters['startCursor'] != null) { queryParameters['start_cursor'] = requestParameters['startCursor']; } if (requestParameters['pageSize'] != null) { queryParameters['page_size'] = requestParameters['pageSize']; } const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/blocks/{block_id}/children`; urlPath = urlPath.replace(`{${"block_id"}}`, encodeURIComponent(String(requestParameters['blockId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.GetBlockChildrenResponseFromJSON)(jsonValue)); } /** * 获取指定块的子块列表 * 获取子块 */ async getBlockChildren(requestParameters, initOverrides) { const response = await this.getBlockChildrenRaw(requestParameters, initOverrides); return await response.value(); } /** * 根据ID获取数据库对象 * 获取数据库 */ async getDatabaseRaw(requestParameters, initOverrides) { if (requestParameters['databaseId'] == null) { throw new runtime.RequiredError('databaseId', 'Required parameter "databaseId" was null or undefined when calling getDatabase().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/databases/{database_id}`; urlPath = urlPath.replace(`{${"database_id"}}`, encodeURIComponent(String(requestParameters['databaseId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.DatabaseFromJSON)(jsonValue)); } /** * 根据ID获取数据库对象 * 获取数据库 */ async getDatabase(requestParameters, initOverrides) { const response = await this.getDatabaseRaw(requestParameters, initOverrides); return await response.value(); } /** * 获取当前机器人的创建者用户信息 * 获取机器人创建者信息 */ async getMeRaw(initOverrides) { const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/users/me`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.UserMeFromJSON)(jsonValue)); } /** * 获取当前机器人的创建者用户信息 * 获取机器人创建者信息 */ async getMe(initOverrides) { const response = await this.getMeRaw(initOverrides); return await response.value(); } /** * 根据ID获取页面对象 * 获取页面 */ async getPageRaw(requestParameters, initOverrides) { if (requestParameters['pageId'] == null) { throw new runtime.RequiredError('pageId', 'Required parameter "pageId" was null or undefined when calling getPage().'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/pages/{page_id}`; urlPath = urlPath.replace(`{${"page_id"}}`, encodeURIComponent(String(requestParameters['pageId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.PageFromJSON)(jsonValue)); } /** * 根据ID获取页面对象 * 获取页面 */ async getPage(requestParameters, initOverrides) { const response = await this.getPageRaw(requestParameters, initOverrides); return await response.value(); } /** * 获取数据库中的页面列表,支持分页 * 查询数据库 */ async queryDatabaseRaw(requestParameters, initOverrides) { if (requestParameters['databaseId'] == null) { throw new runtime.RequiredError('databaseId', 'Required parameter "databaseId" was null or undefined when calling queryDatabase().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/databases/{database_id}/query`; urlPath = urlPath.replace(`{${"database_id"}}`, encodeURIComponent(String(requestParameters['databaseId']))); const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, index_1.QueryDatabaseRequestToJSON)(requestParameters['queryDatabaseRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.QueryDatabaseResponseFromJSON)(jsonValue)); } /** * 获取数据库中的页面列表,支持分页 * 查询数据库 */ async queryDatabase(requestParameters, initOverrides) { const response = await this.queryDatabaseRaw(requestParameters, initOverrides); return await response.value(); } /** * 通过向量搜索在空间中查找相关页面和内容 * 搜索页面 */ async searchPagesRaw(requestParameters, initOverrides) { if (requestParameters['searchRequest'] == null) { throw new runtime.RequiredError('searchRequest', 'Required parameter "searchRequest" was null or undefined when calling searchPages().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/pages/search`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, index_1.SearchRequestToJSON)(requestParameters['searchRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.SearchResultFromJSON)(jsonValue)); } /** * 通过向量搜索在空间中查找相关页面和内容 * 搜索页面 */ async searchPages(requestParameters, initOverrides) { const response = await this.searchPagesRaw(requestParameters, initOverrides); return await response.value(); } /** * 更新指定块的内容或属性 * 更新块 */ async updateBlockRaw(requestParameters, initOverrides) { if (requestParameters['blockId'] == null) { throw new runtime.RequiredError('blockId', 'Required parameter "blockId" was null or undefined when calling updateBlock().'); } if (requestParameters['updateBlockRequest'] == null) { throw new runtime.RequiredError('updateBlockRequest', 'Required parameter "updateBlockRequest" was null or undefined when calling updateBlock().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/blocks/{block_id}`; urlPath = urlPath.replace(`{${"block_id"}}`, encodeURIComponent(String(requestParameters['blockId']))); const response = await this.request({ path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: (0, index_1.UpdateBlockRequestToJSON)(requestParameters['updateBlockRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BlockFromJSON)(jsonValue)); } /** * 更新指定块的内容或属性 * 更新块 */ async updateBlock(requestParameters, initOverrides) { const response = await this.updateBlockRaw(requestParameters, initOverrides); return await response.value(); } /** * 更新数据库的属性 * 更新数据库 */ async updateDatabaseRaw(requestParameters, initOverrides) { if (requestParameters['databaseId'] == null) { throw new runtime.RequiredError('databaseId', 'Required parameter "databaseId" was null or undefined when calling updateDatabase().'); } if (requestParameters['updateDatabaseRequest'] == null) { throw new runtime.RequiredError('updateDatabaseRequest', 'Required parameter "updateDatabaseRequest" was null or undefined when calling updateDatabase().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/databases/{database_id}`; urlPath = urlPath.replace(`{${"database_id"}}`, encodeURIComponent(String(requestParameters['databaseId']))); const response = await this.request({ path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: (0, index_1.UpdateDatabaseRequestToJSON)(requestParameters['updateDatabaseRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.DatabaseFromJSON)(jsonValue)); } /** * 更新数据库的属性 * 更新数据库 */ async updateDatabase(requestParameters, initOverrides) { const response = await this.updateDatabaseRaw(requestParameters, initOverrides); return await response.value(); } /** * 更新页面的属性 * 更新页面属性 */ async updatePageRaw(requestParameters, initOverrides) { if (requestParameters['pageId'] == null) { throw new runtime.RequiredError('pageId', 'Required parameter "pageId" was null or undefined when calling updatePage().'); } if (requestParameters['updatePageRequest'] == null) { throw new runtime.RequiredError('updatePageRequest', 'Required parameter "updatePageRequest" was null or undefined when calling updatePage().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/pages/{page_id}`; urlPath = urlPath.replace(`{${"page_id"}}`, encodeURIComponent(String(requestParameters['pageId']))); const response = await this.request({ path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: (0, index_1.UpdatePageRequestToJSON)(requestParameters['updatePageRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.PageFromJSON)(jsonValue)); } /** * 更新页面的属性 * 更新页面属性 */ async updatePage(requestParameters, initOverrides) { const response = await this.updatePageRaw(requestParameters, initOverrides); return await response.value(); } /** * 在机器人授权的页面范围内搜索相关内容 * 搜索页面 */ async v1SearchRaw(requestParameters, initOverrides) { if (requestParameters['v1SearchRequest'] == null) { throw new runtime.RequiredError('v1SearchRequest', 'Required parameter "v1SearchRequest" was null or undefined when calling v1Search().'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/v1/search`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, index_1.V1SearchRequestToJSON)(requestParameters['v1SearchRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.V1SearchResponseFromJSON)(jsonValue)); } /** * 在机器人授权的页面范围内搜索相关内容 * 搜索页面 */ async v1Search(requestParameters, initOverrides) { const response = await this.v1SearchRaw(requestParameters, initOverrides); return await response.value(); } } exports.DefaultApi = DefaultApi;