diff --git a/api/openapitools.json b/api/openapitools.json deleted file mode 100644 index 15fef60..0000000 --- a/api/openapitools.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "spaces": 2, - "generator-cli": { - "version": "7.1.0" - } -} diff --git a/api/swagger.json b/api/swagger.json deleted file mode 100644 index 8a7fc24..0000000 --- a/api/swagger.json +++ /dev/null @@ -1,745 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "description": "This is a sample server celler server.", - "title": "Swagger Example API", - "contact": {}, - "version": "1.0" - }, - "paths": { - "/libraries": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Libraries" - ], - "summary": "获取资料库列表", - "parameters": [ - { - "type": "integer", - "description": "页码", - "name": "Page", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/pkg.ResponsePaginated" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - }, - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Libraries" - ], - "summary": "新建资料库", - "parameters": [ - { - "type": "string", - "description": "资料库名称", - "name": "Name", - "in": "query", - "required": true - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/model.Library" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - } - }, - "/library/{LibraryId}": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Libraries" - ], - "summary": "显示资料库", - "parameters": [ - { - "type": "integer", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - }, - "delete": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Libraries" - ], - "summary": "删除资料库", - "parameters": [ - { - "type": "integer", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - } - }, - "/library/{LibraryId}/document/{DocumentId}": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "显示文档", - "parameters": [ - { - "type": "string", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "文档 ID", - "name": "DocumentId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/model.Document" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - }, - "put": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "更新文档", - "parameters": [ - { - "type": "string", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "文档 ID", - "name": "DocumentId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "标题", - "name": "Title", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "内容", - "name": "Content", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/model.Document" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - }, - "delete": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "删除文档", - "parameters": [ - { - "type": "integer", - "description": "文档 ID", - "name": "DocumentId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/library/{LibraryId}/document/{DocumentId}/chunks": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "查看处理状态", - "parameters": [ - { - "type": "string", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "文档 ID", - "name": "DocumentId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.chunkStatusResponse" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - } - }, - "/library/{LibraryId}/documents": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "description": "获取当前账号的文档列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "获取文档列表", - "parameters": [ - { - "type": "integer", - "description": "页码", - "name": "Page", - "in": "query", - "required": true - }, - { - "type": "integer", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/pkg.ResponsePaginated" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - }, - "post": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "新建文档", - "parameters": [ - { - "type": "string", - "description": "标题", - "name": "LibraryId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "标题", - "name": "Title", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "描述", - "name": "Description", - "in": "formData" - }, - { - "type": "string", - "description": "文档内容", - "name": "Content", - "in": "formData" - } - ], - "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/model.Document" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - } - }, - "/library/{LibraryId}/query": { - "get": { - "security": [ - { - "BearerToken": [] - } - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Documents" - ], - "summary": "Server Sent Events 查询文档", - "parameters": [ - { - "type": "string", - "description": "资料库 ID", - "name": "LibraryId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "问题", - "name": "Question", - "in": "query", - "required": true - } - ], - "responses": { - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "403": { - "description": "Forbidden", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/pkg.ResponseError" - } - } - } - } - } - }, - "definitions": { - "controller.chunkStatusResponse": { - "type": "object", - "properties": { - "chunked": { - "type": "integer" - }, - "completed": { - "type": "boolean" - }, - "total": { - "type": "integer" - } - } - }, - "gorm.DeletedAt": { - "type": "object", - "properties": { - "time": { - "type": "string" - }, - "valid": { - "description": "Valid is true if Time is not NULL", - "type": "boolean" - } - } - }, - "model.Document": { - "type": "object", - "properties": { - "chunked": { - "type": "boolean" - }, - "content": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "deletedAt": { - "$ref": "#/definitions/gorm.DeletedAt" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "libraryId": { - "type": "integer" - }, - "title": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "userId": { - "type": "integer" - } - } - }, - "model.Library": { - "type": "object", - "properties": { - "createdAt": { - "type": "string" - }, - "deletedAt": { - "$ref": "#/definitions/gorm.DeletedAt" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "password": { - "type": "string" - }, - "updatedAt": { - "type": "string" - }, - "userId": { - "type": "integer" - } - } - }, - "pkg.ResponseError": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - } - }, - "pkg.ResponsePaginated": { - "type": "object", - "properties": { - "Data": {}, - "Limit": { - "type": "integer" - }, - "Page": { - "type": "integer" - }, - "Total": { - "type": "integer" - } - } - } - }, - "securityDefinitions": { - "BearerToken": { - "type": "apiKey", - "name": "Authorization", - "in": "header" - } - } -} \ No newline at end of file diff --git a/package.json b/package.json index 8cbdead..15f47a9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "event-source-polyfill": "^1.0.31", "google-protobuf": "^3.21.2", "grpc-web": "^1.5.0", + "keycloak-js": "^24.0.4", "mammoth": "^1.6.0", "md-editor-v3": "^4.8.3", "pdfjs-dist": "^4.0.269", diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index 58bac73..e23599a 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -5,60 +5,18 @@ diff --git a/src/openapi/.gitignore b/src/openapi/.gitignore deleted file mode 100644 index 149b576..0000000 --- a/src/openapi/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -wwwroot/*.js -node_modules -typings -dist diff --git a/src/openapi/.npmignore b/src/openapi/.npmignore deleted file mode 100644 index 999d88d..0000000 --- a/src/openapi/.npmignore +++ /dev/null @@ -1 +0,0 @@ -# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/src/openapi/.openapi-generator-ignore b/src/openapi/.openapi-generator-ignore deleted file mode 100644 index 7484ee5..0000000 --- a/src/openapi/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/src/openapi/.openapi-generator/FILES b/src/openapi/.openapi-generator/FILES deleted file mode 100644 index a80cd4f..0000000 --- a/src/openapi/.openapi-generator/FILES +++ /dev/null @@ -1,8 +0,0 @@ -.gitignore -.npmignore -api.ts -base.ts -common.ts -configuration.ts -git_push.sh -index.ts diff --git a/src/openapi/.openapi-generator/VERSION b/src/openapi/.openapi-generator/VERSION deleted file mode 100644 index 3769235..0000000 --- a/src/openapi/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.1.0 \ No newline at end of file diff --git a/src/openapi/api.ts b/src/openapi/api.ts deleted file mode 100644 index f3d2fcd..0000000 --- a/src/openapi/api.ts +++ /dev/null @@ -1,1208 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Swagger Example API - * This is a sample server celler server. - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; -// Some imports not used depending on template conditions -// @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; -import type { RequestArgs } from './base'; -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; - -/** - * - * @export - * @interface ControllerChunkStatusResponse - */ -export interface ControllerChunkStatusResponse { - /** - * - * @type {number} - * @memberof ControllerChunkStatusResponse - */ - 'chunked'?: number; - /** - * - * @type {boolean} - * @memberof ControllerChunkStatusResponse - */ - 'completed'?: boolean; - /** - * - * @type {number} - * @memberof ControllerChunkStatusResponse - */ - 'total'?: number; -} -/** - * - * @export - * @interface GormDeletedAt - */ -export interface GormDeletedAt { - /** - * - * @type {string} - * @memberof GormDeletedAt - */ - 'time'?: string; - /** - * Valid is true if Time is not NULL - * @type {boolean} - * @memberof GormDeletedAt - */ - 'valid'?: boolean; -} -/** - * - * @export - * @interface LibraryLibraryIdDocumentsPostRequest - */ -export interface LibraryLibraryIdDocumentsPostRequest { - /** - * 标题 - * @type {string} - * @memberof LibraryLibraryIdDocumentsPostRequest - */ - 'Title': string; - /** - * 描述 - * @type {string} - * @memberof LibraryLibraryIdDocumentsPostRequest - */ - 'Description'?: string; - /** - * 文档内容 - * @type {string} - * @memberof LibraryLibraryIdDocumentsPostRequest - */ - 'Content'?: string; -} -/** - * - * @export - * @interface ModelDocument - */ -export interface ModelDocument { - /** - * - * @type {boolean} - * @memberof ModelDocument - */ - 'chunked'?: boolean; - /** - * - * @type {string} - * @memberof ModelDocument - */ - 'content'?: string; - /** - * - * @type {string} - * @memberof ModelDocument - */ - 'createdAt'?: string; - /** - * - * @type {GormDeletedAt} - * @memberof ModelDocument - */ - 'deletedAt'?: GormDeletedAt; - /** - * - * @type {string} - * @memberof ModelDocument - */ - 'description'?: string; - /** - * - * @type {number} - * @memberof ModelDocument - */ - 'id'?: number; - /** - * - * @type {number} - * @memberof ModelDocument - */ - 'libraryId'?: number; - /** - * - * @type {string} - * @memberof ModelDocument - */ - 'title'?: string; - /** - * - * @type {string} - * @memberof ModelDocument - */ - 'updatedAt'?: string; - /** - * - * @type {number} - * @memberof ModelDocument - */ - 'userId'?: number; -} -/** - * - * @export - * @interface ModelLibrary - */ -export interface ModelLibrary { - /** - * - * @type {string} - * @memberof ModelLibrary - */ - 'createdAt'?: string; - /** - * - * @type {GormDeletedAt} - * @memberof ModelLibrary - */ - 'deletedAt'?: GormDeletedAt; - /** - * - * @type {number} - * @memberof ModelLibrary - */ - 'id'?: number; - /** - * - * @type {string} - * @memberof ModelLibrary - */ - 'name'?: string; - /** - * - * @type {string} - * @memberof ModelLibrary - */ - 'password'?: string; - /** - * - * @type {string} - * @memberof ModelLibrary - */ - 'updatedAt'?: string; - /** - * - * @type {number} - * @memberof ModelLibrary - */ - 'userId'?: number; -} -/** - * - * @export - * @interface PkgResponseError - */ -export interface PkgResponseError { - /** - * - * @type {string} - * @memberof PkgResponseError - */ - 'message'?: string; -} -/** - * - * @export - * @interface PkgResponsePaginated - */ -export interface PkgResponsePaginated { - /** - * - * @type {object} - * @memberof PkgResponsePaginated - */ - 'Data'?: object; - /** - * - * @type {number} - * @memberof PkgResponsePaginated - */ - 'Limit'?: number; - /** - * - * @type {number} - * @memberof PkgResponsePaginated - */ - 'Page'?: number; - /** - * - * @type {number} - * @memberof PkgResponsePaginated - */ - 'Total'?: number; -} - -/** - * DocumentsApi - axios parameter creator - * @export - */ -export const DocumentsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @summary 查看处理状态 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdChunksGet: async (libraryId: string, documentId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdChunksGet', 'libraryId', libraryId) - // verify required parameter 'documentId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdChunksGet', 'documentId', documentId) - const localVarPath = `/library/{LibraryId}/document/{DocumentId}/chunks` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))) - .replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 删除文档 - * @param {number} documentId 文档 ID - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdDelete: async (documentId: number, libraryId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'documentId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdDelete', 'documentId', documentId) - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdDelete', 'libraryId', libraryId) - const localVarPath = `/library/{LibraryId}/document/{DocumentId}` - .replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId))) - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 显示文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdGet: async (libraryId: string, documentId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdGet', 'libraryId', libraryId) - // verify required parameter 'documentId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdGet', 'documentId', documentId) - const localVarPath = `/library/{LibraryId}/document/{DocumentId}` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))) - .replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 更新文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {string} title 标题 - * @param {string} content 内容 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdPut: async (libraryId: string, documentId: string, title: string, content: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'libraryId', libraryId) - // verify required parameter 'documentId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'documentId', documentId) - // verify required parameter 'title' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'title', title) - // verify required parameter 'content' is not null or undefined - assertParamExists('libraryLibraryIdDocumentDocumentIdPut', 'content', content) - const localVarPath = `/library/{LibraryId}/document/{DocumentId}` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))) - .replace(`{${"DocumentId"}}`, encodeURIComponent(String(documentId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - if (title !== undefined) { - localVarQueryParameter['Title'] = title; - } - - if (content !== undefined) { - localVarQueryParameter['Content'] = content; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * 获取当前账号的文档列表 - * @summary 获取文档列表 - * @param {number} page 页码 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentsGet: async (page: number, libraryId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'page' is not null or undefined - assertParamExists('libraryLibraryIdDocumentsGet', 'page', page) - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentsGet', 'libraryId', libraryId) - const localVarPath = `/library/{LibraryId}/documents` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - if (page !== undefined) { - localVarQueryParameter['Page'] = page; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 新建文档 - * @param {string} libraryId 标题 - * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentsPost: async (libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDocumentsPost', 'libraryId', libraryId) - // verify required parameter 'libraryLibraryIdDocumentsPostRequest' is not null or undefined - assertParamExists('libraryLibraryIdDocumentsPost', 'libraryLibraryIdDocumentsPostRequest', libraryLibraryIdDocumentsPostRequest) - const localVarPath = `/library/{LibraryId}/documents` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(libraryLibraryIdDocumentsPostRequest, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary Server Sent Events 查询文档 - * @param {string} libraryId 资料库 ID - * @param {string} question 问题 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdQueryGet: async (libraryId: string, question: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdQueryGet', 'libraryId', libraryId) - // verify required parameter 'question' is not null or undefined - assertParamExists('libraryLibraryIdQueryGet', 'question', question) - const localVarPath = `/library/{LibraryId}/query` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - if (question !== undefined) { - localVarQueryParameter['Question'] = question; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * DocumentsApi - functional programming interface - * @export - */ -export const DocumentsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = DocumentsApiAxiosParamCreator(configuration) - return { - /** - * - * @summary 查看处理状态 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentDocumentIdChunksGet(libraryId: string, documentId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdChunksGet(libraryId, documentId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdChunksGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 删除文档 - * @param {number} documentId 文档 ID - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdDelete']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 显示文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentDocumentIdGet(libraryId: string, documentId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdGet(libraryId, documentId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 更新文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {string} title 标题 - * @param {string} content 内容 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, title: string, content: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, title, content, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentDocumentIdPut']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * 获取当前账号的文档列表 - * @summary 获取文档列表 - * @param {number} page 页码 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentsGet(page: number, libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsGet(page, libraryId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 新建文档 - * @param {string} libraryId 标题 - * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdDocumentsPost']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary Server Sent Events 查询文档 - * @param {string} libraryId 资料库 ID - * @param {string} question 问题 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdQueryGet(libraryId: string, question: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdQueryGet(libraryId, question, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['DocumentsApi.libraryLibraryIdQueryGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - } -}; - -/** - * DocumentsApi - factory interface - * @export - */ -export const DocumentsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = DocumentsApiFp(configuration) - return { - /** - * - * @summary 查看处理状态 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdChunksGet(libraryId: string, documentId: string, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentDocumentIdChunksGet(libraryId, documentId, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 删除文档 - * @param {number} documentId 文档 ID - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 显示文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdGet(libraryId: string, documentId: string, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentDocumentIdGet(libraryId, documentId, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 更新文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {string} title 标题 - * @param {string} content 内容 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, title: string, content: string, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, title, content, options).then((request) => request(axios, basePath)); - }, - /** - * 获取当前账号的文档列表 - * @summary 获取文档列表 - * @param {number} page 页码 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentsGet(page: number, libraryId: number, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentsGet(page, libraryId, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 新建文档 - * @param {string} libraryId 标题 - * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary Server Sent Events 查询文档 - * @param {string} libraryId 资料库 ID - * @param {string} question 问题 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdQueryGet(libraryId: string, question: string, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdQueryGet(libraryId, question, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * DocumentsApi - object-oriented interface - * @export - * @class DocumentsApi - * @extends {BaseAPI} - */ -export class DocumentsApi extends BaseAPI { - /** - * - * @summary 查看处理状态 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentDocumentIdChunksGet(libraryId: string, documentId: string, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdChunksGet(libraryId, documentId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 删除文档 - * @param {number} documentId 文档 ID - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentDocumentIdDelete(documentId: number, libraryId: number, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdDelete(documentId, libraryId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 显示文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentDocumentIdGet(libraryId: string, documentId: string, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdGet(libraryId, documentId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 更新文档 - * @param {string} libraryId 资料库 ID - * @param {string} documentId 文档 ID - * @param {string} title 标题 - * @param {string} content 内容 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentDocumentIdPut(libraryId: string, documentId: string, title: string, content: string, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentDocumentIdPut(libraryId, documentId, title, content, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * 获取当前账号的文档列表 - * @summary 获取文档列表 - * @param {number} page 页码 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentsGet(page: number, libraryId: number, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsGet(page, libraryId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 新建文档 - * @param {string} libraryId 标题 - * @param {LibraryLibraryIdDocumentsPostRequest} libraryLibraryIdDocumentsPostRequest - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdDocumentsPost(libraryId: string, libraryLibraryIdDocumentsPostRequest: LibraryLibraryIdDocumentsPostRequest, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdDocumentsPost(libraryId, libraryLibraryIdDocumentsPostRequest, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary Server Sent Events 查询文档 - * @param {string} libraryId 资料库 ID - * @param {string} question 问题 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DocumentsApi - */ - public libraryLibraryIdQueryGet(libraryId: string, question: string, options?: AxiosRequestConfig) { - return DocumentsApiFp(this.configuration).libraryLibraryIdQueryGet(libraryId, question, options).then((request) => request(this.axios, this.basePath)); - } -} - - - -/** - * LibrariesApi - axios parameter creator - * @export - */ -export const LibrariesApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @summary 获取资料库列表 - * @param {number} page 页码 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - librariesGet: async (page: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'page' is not null or undefined - assertParamExists('librariesGet', 'page', page) - const localVarPath = `/libraries`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - if (page !== undefined) { - localVarQueryParameter['Page'] = page; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 新建资料库 - * @param {string} name 资料库名称 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - librariesPost: async (name: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'name' is not null or undefined - assertParamExists('librariesPost', 'name', name) - const localVarPath = `/libraries`; - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - if (name !== undefined) { - localVarQueryParameter['Name'] = name; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 删除资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDelete: async (libraryId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdDelete', 'libraryId', libraryId) - const localVarPath = `/library/{LibraryId}` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * - * @summary 显示资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdGet: async (libraryId: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'libraryId' is not null or undefined - assertParamExists('libraryLibraryIdGet', 'libraryId', libraryId) - const localVarPath = `/library/{LibraryId}` - .replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId))); - // use dummy base URL string because the URL constructor only accepts absolute URLs. - const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication BearerToken required - await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * LibrariesApi - functional programming interface - * @export - */ -export const LibrariesApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = LibrariesApiAxiosParamCreator(configuration) - return { - /** - * - * @summary 获取资料库列表 - * @param {number} page 页码 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async librariesGet(page: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.librariesGet(page, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['LibrariesApi.librariesGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 新建资料库 - * @param {string} name 资料库名称 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async librariesPost(name: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.librariesPost(name, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['LibrariesApi.librariesPost']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 删除资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdDelete(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDelete(libraryId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdDelete']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - /** - * - * @summary 显示资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async libraryLibraryIdGet(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdGet(libraryId, options); - const index = configuration?.serverIndex ?? 0; - const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdGet']?.[index]?.url; - return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath); - }, - } -}; - -/** - * LibrariesApi - factory interface - * @export - */ -export const LibrariesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { - const localVarFp = LibrariesApiFp(configuration) - return { - /** - * - * @summary 获取资料库列表 - * @param {number} page 页码 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - librariesGet(page: number, options?: any): AxiosPromise { - return localVarFp.librariesGet(page, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 新建资料库 - * @param {string} name 资料库名称 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - librariesPost(name: string, options?: any): AxiosPromise { - return localVarFp.librariesPost(name, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 删除资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdDelete(libraryId: number, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdDelete(libraryId, options).then((request) => request(axios, basePath)); - }, - /** - * - * @summary 显示资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - libraryLibraryIdGet(libraryId: number, options?: any): AxiosPromise { - return localVarFp.libraryLibraryIdGet(libraryId, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * LibrariesApi - object-oriented interface - * @export - * @class LibrariesApi - * @extends {BaseAPI} - */ -export class LibrariesApi extends BaseAPI { - /** - * - * @summary 获取资料库列表 - * @param {number} page 页码 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof LibrariesApi - */ - public librariesGet(page: number, options?: AxiosRequestConfig) { - return LibrariesApiFp(this.configuration).librariesGet(page, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 新建资料库 - * @param {string} name 资料库名称 - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof LibrariesApi - */ - public librariesPost(name: string, options?: AxiosRequestConfig) { - return LibrariesApiFp(this.configuration).librariesPost(name, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 删除资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof LibrariesApi - */ - public libraryLibraryIdDelete(libraryId: number, options?: AxiosRequestConfig) { - return LibrariesApiFp(this.configuration).libraryLibraryIdDelete(libraryId, options).then((request) => request(this.axios, this.basePath)); - } - - /** - * - * @summary 显示资料库 - * @param {number} libraryId 资料库 ID - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof LibrariesApi - */ - public libraryLibraryIdGet(libraryId: number, options?: AxiosRequestConfig) { - return LibrariesApiFp(this.configuration).libraryLibraryIdGet(libraryId, options).then((request) => request(this.axios, this.basePath)); - } -} - - - diff --git a/src/openapi/base.ts b/src/openapi/base.ts deleted file mode 100644 index c23cc89..0000000 --- a/src/openapi/base.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Swagger Example API - * This is a sample server celler server. - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from './configuration'; -// Some imports not used depending on template conditions -// @ts-ignore -import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import globalAxios from 'axios'; - -export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); - -/** - * - * @export - */ -export const COLLECTION_FORMATS = { - csv: ",", - ssv: " ", - tsv: "\t", - pipes: "|", -}; - -/** - * - * @export - * @interface RequestArgs - */ -export interface RequestArgs { - url: string; - options: AxiosRequestConfig; -} - -/** - * - * @export - * @class BaseAPI - */ -export class BaseAPI { - protected configuration: Configuration | undefined; - - constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { - if (configuration) { - this.configuration = configuration; - this.basePath = configuration.basePath ?? basePath; - } - } -}; - -/** - * - * @export - * @class RequiredError - * @extends {Error} - */ -export class RequiredError extends Error { - constructor(public field: string, msg?: string) { - super(msg); - this.name = "RequiredError" - } -} - -interface ServerMap { - [key: string]: { - url: string, - description: string, - }[]; -} - -/** - * - * @export - */ -export const operationServerMap: ServerMap = { -} diff --git a/src/openapi/common.ts b/src/openapi/common.ts deleted file mode 100644 index e1f18c8..0000000 --- a/src/openapi/common.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Swagger Example API - * This is a sample server celler server. - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import type { Configuration } from "./configuration"; -import type { RequestArgs } from "./base"; -import type { AxiosInstance, AxiosResponse } from 'axios'; -import { RequiredError } from "./base"; - -/** - * - * @export - */ -export const DUMMY_BASE_URL = 'https://example.com' - -/** - * - * @throws {RequiredError} - * @export - */ -export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { - if (paramValue === null || paramValue === undefined) { - throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); - } -} - -/** - * - * @export - */ -export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { - if (configuration && configuration.apiKey) { - const localVarApiKeyValue = typeof configuration.apiKey === 'function' - ? await configuration.apiKey(keyParamName) - : await configuration.apiKey; - object[keyParamName] = localVarApiKeyValue; - } -} - -/** - * - * @export - */ -export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { - if (configuration && (configuration.username || configuration.password)) { - object["auth"] = { username: configuration.username, password: configuration.password }; - } -} - -/** - * - * @export - */ -export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const accessToken = typeof configuration.accessToken === 'function' - ? await configuration.accessToken() - : await configuration.accessToken; - object["Authorization"] = "Bearer " + accessToken; - } -} - -/** - * - * @export - */ -export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { - if (configuration && configuration.accessToken) { - const localVarAccessTokenValue = typeof configuration.accessToken === 'function' - ? await configuration.accessToken(name, scopes) - : await configuration.accessToken; - object["Authorization"] = "Bearer " + localVarAccessTokenValue; - } -} - -function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { - if (parameter == null) return; - if (typeof parameter === "object") { - if (Array.isArray(parameter)) { - (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); - } - else { - Object.keys(parameter).forEach(currentKey => - setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) - ); - } - } - else { - if (urlSearchParams.has(key)) { - urlSearchParams.append(key, parameter); - } - else { - urlSearchParams.set(key, parameter); - } - } -} - -/** - * - * @export - */ -export const setSearchParams = function (url: URL, ...objects: any[]) { - const searchParams = new URLSearchParams(url.search); - setFlattenedQueryParams(searchParams, objects); - url.search = searchParams.toString(); -} - -/** - * - * @export - */ -export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { - const nonString = typeof value !== 'string'; - const needsSerialization = nonString && configuration && configuration.isJsonMime - ? configuration.isJsonMime(requestOptions.headers['Content-Type']) - : nonString; - return needsSerialization - ? JSON.stringify(value !== undefined ? value : {}) - : (value || ""); -} - -/** - * - * @export - */ -export const toPathString = function (url: URL) { - return url.pathname + url.search + url.hash -} - -/** - * - * @export - */ -export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { - return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { - const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || axios.defaults.baseURL || basePath) + axiosArgs.url}; - return axios.request(axiosRequestArgs); - }; -} diff --git a/src/openapi/configuration.ts b/src/openapi/configuration.ts deleted file mode 100644 index 2a2332d..0000000 --- a/src/openapi/configuration.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Swagger Example API - * This is a sample server celler server. - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export interface ConfigurationParameters { - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - username?: string; - password?: string; - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - basePath?: string; - serverIndex?: number; - baseOptions?: any; - formDataCtor?: new () => any; -} - -export class Configuration { - /** - * parameter for apiKey security - * @param name security name - * @memberof Configuration - */ - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - username?: string; - /** - * parameter for basic security - * - * @type {string} - * @memberof Configuration - */ - password?: string; - /** - * parameter for oauth2 security - * @param name security name - * @param scopes oauth2 scope - * @memberof Configuration - */ - accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); - /** - * override base path - * - * @type {string} - * @memberof Configuration - */ - basePath?: string; - /** - * override server index - * - * @type {number} - * @memberof Configuration - */ - serverIndex?: number; - /** - * base options for axios calls - * - * @type {any} - * @memberof Configuration - */ - baseOptions?: any; - /** - * The FormData constructor that will be used to create multipart form data - * requests. You can inject this here so that execution environments that - * do not support the FormData class can still run the generated client. - * - * @type {new () => FormData} - */ - formDataCtor?: new () => any; - - constructor(param: ConfigurationParameters = {}) { - this.apiKey = param.apiKey; - this.username = param.username; - this.password = param.password; - this.accessToken = param.accessToken; - this.basePath = param.basePath; - this.serverIndex = param.serverIndex; - this.baseOptions = param.baseOptions; - this.formDataCtor = param.formDataCtor; - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * @param mime - MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public isJsonMime(mime: string): boolean { - const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); - return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); - } -} diff --git a/src/openapi/git_push.sh b/src/openapi/git_push.sh deleted file mode 100644 index f53a75d..0000000 --- a/src/openapi/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/src/openapi/index.ts b/src/openapi/index.ts deleted file mode 100644 index 457ac3a..0000000 --- a/src/openapi/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Swagger Example API - * This is a sample server celler server. - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export * from "./api"; -export * from "./configuration"; - diff --git a/src/plugins/api.ts b/src/plugins/api.ts deleted file mode 100644 index b345b83..0000000 --- a/src/plugins/api.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { DocumentsApi, Configuration, LibrariesApi } from "../openapi"; - -// import axios from "axios"; -// import router from "@/router"; -import {useUserStore} from "@/store/user"; -import { useConfigStore } from "@/store/config"; - - -const userStore = useUserStore() -const configStore = useConfigStore() - -const conf = new Configuration -conf.basePath = configStore.apiServer - -conf.apiKey = "Bearer " + userStore.jwt_token -const document = new DocumentsApi(conf); -const library = new LibrariesApi(conf); - - -export { - document, library, conf -} diff --git a/src/plugins/config.ts b/src/plugins/config.ts new file mode 100644 index 0000000..912c401 --- /dev/null +++ b/src/plugins/config.ts @@ -0,0 +1,14 @@ +let staticConfig = { + url: "https://auth.leaflow.cn/", + realm: "UserLand", + clientId: "Leaf Library", + + scope: "openid profile", + checkLoginIframe: false, + redirectUri: window.location.origin + "/auth/login", + + rpc_base_url: "http://127.0.0.1:18081" +} + + +export default staticConfig \ No newline at end of file diff --git a/src/plugins/keycloak.ts b/src/plugins/keycloak.ts new file mode 100644 index 0000000..0530ac0 --- /dev/null +++ b/src/plugins/keycloak.ts @@ -0,0 +1,41 @@ +import Keycloak, { KeycloakConfig, KeycloakInitOptions } from "keycloak-js"; +import config from "@/plugins/config" + + +const keycloakConfig: KeycloakConfig = { + url: config.url, + realm: config.realm, + clientId: config.clientId, +} + +const keycloakOptions: KeycloakInitOptions = { + scope: config.scope, + checkLoginIframe: config.checkLoginIframe, + redirectUri: config.redirectUri, + // onLoad: 'login-required', + +} + +// kc.updateToken + +// async function newKeycloak() { +// return new Keycloak(configStore.getKeyCloakConfig()); +// } + + +const kc = new Keycloak(keycloakConfig); + +kc.init(keycloakOptions).then((auth) => { + console.log(`User is ${auth ? 'authenticated' : 'not authenticated'}`); + + kc.onTokenExpired = () => { + kc.updateToken(5).then(auth => { + console.log(auth); + }) + } +}); + +// save kc to local storage +localStorage.setItem('keycloak', JSON.stringify(kc)); + +export default kc diff --git a/src/plugins/rpc.ts b/src/plugins/rpc.ts new file mode 100644 index 0000000..7e781c0 --- /dev/null +++ b/src/plugins/rpc.ts @@ -0,0 +1,24 @@ + +import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport"; +import keycloak from "@/plugins/keycloak" +import { DocumentServiceClient } from "@/proto/document/document.client"; +import { LibraryServiceClient } from "@/proto/library/library.client"; +import config from "@/plugins/config" + +let transport = new GrpcWebFetchTransport({ + baseUrl: config.rpc_base_url, + format: "text", + meta: { + "Authorization": "Bearer " + keycloak.idToken, + }, + timeout: 100 * 1000, +}); + + +let libraryServiceClient = new LibraryServiceClient(transport) +let documentClient = new DocumentServiceClient(transport) + +export { + libraryServiceClient, + documentClient +} \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index a549301..ee1a866 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,14 +1,15 @@ // Composables import { createRouter, createWebHistory } from "vue-router"; -import { useUserStore } from "@/store/user"; import { useConfigStore } from "@/store/config"; +import keycloak from "@/plugins/keycloak" +import { useLoginUrlStore } from "@/store/login_url"; const routes = [ { path: "/", name: "home", meta: { - auth: true, + auth: false, }, // route level code-splitting // this generates a separate chunk (Home-[hash].js) for this route @@ -23,6 +24,9 @@ const routes = [ { path: "/libraries", name: "libraries", + meta: { + auth: true, + }, component: () => import("@/views/libraries/List.vue"), }, { @@ -50,7 +54,7 @@ const routes = [ name: "library.documents.view", component: () => import("@/views/documents/View.vue"), }, - + ]; const router = createRouter({ @@ -59,12 +63,30 @@ const router = createRouter({ }); router.beforeEach((to, from) => { - // get route name console.log(from.name, from.fullPath) - const userStore = useUserStore(); const configStore = useConfigStore(); + const loginUrl = useLoginUrlStore(); + + if (to.name != "login") { + console.log("last visit:" + to.fullPath) + // 设置最后访问 url + loginUrl.setLastVisitUrl(to.fullPath); + } + + // // 如果来自登录的 url,则跳转到最后访问的 url + // if (from.name === "login") { + // const last_visit = loginUrl.getLastVisitUrl() + + // if (last_visit) { + // console.log("跳转:" + last_visit) + // // window.location.href = last_visit + // } + + // } + + // if (to.matched.length === 0) { // return router.push({ name: "errors.404" }); @@ -76,9 +98,8 @@ router.beforeEach((to, from) => { document.title = configStore.getAppName(); } - if (to.meta.auth == true) { - // validate login state - if (userStore.jwt_token == null) { + if (to.meta.auth) { + if (!keycloak.authenticated) { router.push({ name: "login" }); } } else { diff --git a/src/store/config.ts b/src/store/config.ts index bf7bb56..4df6bfd 100644 --- a/src/store/config.ts +++ b/src/store/config.ts @@ -5,23 +5,11 @@ export const useConfigStore = defineStore('app', { state: () => ({ appName: "资料库", description: "Leaf Library", - accountServer: "https://oauth.leaflow.cn", apiServer: "https://document-api.leaflow.cn/api", - // apiServer: "http://localhost:8080/api", }), actions: { getAppName(): string { return this.appName !== null ? this.appName : "Leaf Library" }, - getRefreshUrl(): string { - return this.accountServer + "/public/auth_request/refresh" - }, - getLoginUrl(): string { - let url = new URL(this.accountServer + "/public/auth_request") - url.searchParams.append("description", this.description) - // url.searchParams.append("callback_uri", window.location.href) - url.searchParams.append("attributes[app]", "todo") - return url.toString() - } }, -}) \ No newline at end of file +}) diff --git a/src/store/libraries.ts b/src/store/libraries.ts deleted file mode 100644 index c2e2101..0000000 --- a/src/store/libraries.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {defineStore} from 'pinia' -import axios from "axios"; -import {useConfigStore} from "./config"; - -export const useLibrariesStore = defineStore('libraries', { - state: () => ({ - libraries: [{ - ID: 0, - Name: "", - }], - }), -}) \ No newline at end of file diff --git a/src/store/login_url.ts b/src/store/login_url.ts new file mode 100644 index 0000000..707a93e --- /dev/null +++ b/src/store/login_url.ts @@ -0,0 +1,18 @@ +import {defineStore} from 'pinia' + +export const useLoginUrlStore = defineStore('login_url', { + persist: true, + state: () => ({ + last_visit_url: null as null | string + }), + + actions: { + setLastVisitUrl(url: string) { + this.last_visit_url = url + }, + getLastVisitUrl() { + return this.last_visit_url + } + } + +}) \ No newline at end of file diff --git a/src/store/user.ts b/src/store/user.ts deleted file mode 100644 index 0d84c63..0000000 --- a/src/store/user.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { defineStore } from "pinia"; -import axios from "axios"; -import { useConfigStore } from "./config"; - -const useUserStore = defineStore("user", { - persist: true, - state: () => ({ - refresh_token: null as null | string, - jwt_token: null as null | string, - expired_at: null as null | Date, - }), - getters: { - isLoggedIn(): boolean { - return this.jwt_token !== null; - }, - }, - actions: { - login(refresh_token: string, jwt_token: string) { - this.refresh_token = refresh_token; - this.jwt_token = jwt_token; - }, - setExpired(expires_in: number) { - // get date(current + seconds) - this.expired_at = new Date(Date.now() + expires_in * 1000); - }, - logout() { - console.log("logout"); - this.refresh_token = null; - this.jwt_token = null; - }, - refresh() { - let config = useConfigStore(); - - axios - .post(config.getRefreshUrl(), { - refresh_token: this.refresh_token, - }) - .then((r) => { - this.jwt_token = r.data.token; - this.setExpired(r.data.expires_in); - }) - .catch((e) => { - console.error(e); - this.logout(); - }); - }, - get_token() { - return this.jwt_token; - }, - }, -}); - -setInterval(() => { - // check expired - const currentDate = new Date(); - - const userStore = useUserStore(); - const expiredAt = new Date(userStore.expired_at || 0); - - // if has expired - if (userStore.expired_at !== null && expiredAt < currentDate) { - if (userStore.jwt_token !== null && userStore.refresh_token !== null) { - userStore.refresh(); - } - } -}, 1000); - -export { useUserStore }; diff --git a/src/views/auth/Login.vue b/src/views/auth/Login.vue index d9eccd7..e448318 100644 --- a/src/views/auth/Login.vue +++ b/src/views/auth/Login.vue @@ -1,123 +1,46 @@ diff --git a/src/views/documents/Create.vue b/src/views/documents/Create.vue deleted file mode 100644 index 957460f..0000000 --- a/src/views/documents/Create.vue +++ /dev/null @@ -1,213 +0,0 @@ - - - diff --git a/src/views/documents/Edit.vue b/src/views/documents/Edit.vue deleted file mode 100644 index 6123a64..0000000 --- a/src/views/documents/Edit.vue +++ /dev/null @@ -1,112 +0,0 @@ - - - diff --git a/src/views/documents/List.vue b/src/views/documents/List.vue deleted file mode 100644 index 8a44a63..0000000 --- a/src/views/documents/List.vue +++ /dev/null @@ -1,133 +0,0 @@ - - - diff --git a/src/views/documents/View.vue b/src/views/documents/View.vue deleted file mode 100644 index 6ce72c6..0000000 --- a/src/views/documents/View.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - diff --git a/src/views/libraries/List.vue b/src/views/libraries/List.vue index 609a39c..2209e3a 100644 --- a/src/views/libraries/List.vue +++ b/src/views/libraries/List.vue @@ -1,125 +1,30 @@ - diff --git a/tsconfig.json b/tsconfig.json index 1fc1d2a..969f0df 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "target": "esnext", "useDefineForClassFields": true, "allowSyntheticDefaultImports": true, - "allowImportingTsExtensions": true, "composite": true, "module": "esnext", "moduleResolution": "node", diff --git a/yarn.lock b/yarn.lock index da8b2c2..7524810 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1855,6 +1855,11 @@ isexe@^2.0.0: resolved "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== +js-sha256@^0.11.0: + version "0.11.0" + resolved "https://mirrors.cloud.tencent.com/npm/js-sha256/-/js-sha256-0.11.0.tgz#256a921d9292f7fe98905face82e367abaca9576" + integrity sha512-6xNlKayMZvds9h1Y1VWc0fQHQ82BxTXizWPEtEeGvmOUYpBRy4gbWroHLpzowe6xiQhHpelCQiE7HEdznyBL9Q== + js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz" @@ -1887,6 +1892,19 @@ jszip@^3.7.1: readable-stream "~2.3.6" setimmediate "^1.0.5" +jwt-decode@^4.0.0: + version "4.0.0" + resolved "https://mirrors.cloud.tencent.com/npm/jwt-decode/-/jwt-decode-4.0.0.tgz#2270352425fd413785b2faf11f6e755c5151bd4b" + integrity sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA== + +keycloak-js@^24.0.4: + version "24.0.4" + resolved "https://mirrors.cloud.tencent.com/npm/keycloak-js/-/keycloak-js-24.0.4.tgz#bfd78af853f0a45bb2f0b4dd24c135aef22cbab6" + integrity sha512-eLjG7CzGGgAXh78M76QUJy1R8+QDQvIJXJf6T3bq9VJZ6RXBGZXMsXvII66b83ueYDFa1gi2JojmA31Z23HO0g== + dependencies: + js-sha256 "^0.11.0" + jwt-decode "^4.0.0" + keyv@^4.5.3: version "4.5.4" resolved "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz"