### Quick Start with Seeyon Client Source: https://github.com/demomacro/seeyon-client/blob/main/README.md A basic example demonstrating how to initialize the SeeyonClient, obtain an authentication token, and initiate a workflow using the CAP4 API. It shows essential steps for getting started with the library. ```typescript import { SeeyonClient } from "seeyon-client"; // 初始化客户端 const client = new SeeyonClient({ username: "your-username", password: "your-password", baseURL: "http://127.0.0.1/seeyon", // 默认值 timeout: 30000, }); // 获取认证 Token const auth = await client.refreshToken(); console.log("Token:", auth.id); // 或者直接获取当前 token(如果不存在或过期会自动获取) const token = await client.getToken(); console.log("Token:", token); // 发起工作流 const result = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "your-template-code", draft: "0", // 0: 新建-发送;1: 新建-保存待发 subject: "测试申请", }, }); console.log("工作流发起成功:", result); ``` -------------------------------- ### Quick Start: Initialize and Use Seeyon Client in TypeScript Source: https://github.com/demomacro/seeyon-client/blob/main/packages/seeyon-client/README.md Demonstrates how to initialize the SeeyonClient with credentials and baseURL, obtain an authentication token, and initiate a workflow. It highlights essential first steps for using the client. ```typescript import { SeeyonClient } from "seeyon-client"; // 初始化客户端 const client = new SeeyonClient({ username: "your-username", password: "your-password", baseURL: "http://127.0.0.1/seeyon", // 默认值 }); // 获取认证 Token const auth = await client.auth.getToken(); console.log("认证成功,Token:", auth.id); // 发起工作流 const workflowResult = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "your-template-code", draft: "0", // 0: 新建-发送;1: 新建-保存待发 subject: "测试申请流程", }, }); console.log("工作流发起成功,流程ID:", workflowResult.data.processId); ``` -------------------------------- ### Install Seeyon Client with npm, yarn, or pnpm Source: https://github.com/demomacro/seeyon-client/blob/main/packages/seeyon-client/README.md Provides commands to install the seeyon-client package using different package managers. This is the initial step to integrate the library into your project. ```bash npm install seeyon-client # 或者 yarn add seeyon-client # 或者 pnpm add seeyon-client ``` -------------------------------- ### Start Seeyon Workflow Process Source: https://context7.com/demomacro/seeyon-client/llms.txt Provides an example of initiating a new workflow process in Seeyon CAP4. It shows how to pass form data, attachment IDs, related document information, and attachment metadata. Includes handling of the process response, detailing IDs, subject, and workitems, as well as error messages. ```typescript // Start a workflow with form data const processResult = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "PURCHASE_REQUEST_001", draft: "0", // 0: create and send; 1: create as draft subject: "Purchase Request - Office Supplies", attachments: [432641077895385013, 355134930180197101], // Title attachment IDs relateDoc: "col|123456,789012;doc|321654,987654", data: { formmain_0177: { "申请人": "张三", "申请部门": "技术部", "申请金额": "5000", "申请原因": "购买办公用品", "上传附件1": "3091996204880318295" // CAP4 attachment field }, formson_0185: [ // Sub-table data (array of records) { "物品名称": "笔记本电脑", "数量": "2", "单价": "4500", "金额": "9000", "备注": "联想ThinkPad" }, { "物品名称": "鼠标", "数量": "5", "单价": "50", "金额": "250" } ], thirdAttachments: [ // CAP4 attachment metadata { subReference: "3091996204880318295", fileUrl: "432641077895385013", sort: 1 } ], changedFields: { // Fields to trigger calculation formmain_0177: ["申请金额", "申请部门"], formson_0185: ["数量", "单价"] } }, useNewDataStructure: false, doTrigger: true } }); // Process response console.log("Process ID:", processResult.data.processId); console.log("Summary ID:", processResult.data.summaryId); console.log("Affair ID:", processResult.data.affairId); console.log("Subject:", processResult.data.subject); // Iterate workitems processResult.data.workitems.forEach(item => { console.log(`Node: ${item.nodeName}, User: ${item.userName} (${item.userLoginName})`); console.log(`Workitem ID: ${item.id}, Node ID: ${item.nodeId}`); }); // Error handling if (processResult.data.errorMsg) { console.error("Process start error:", processResult.data.errorMsg); } ``` -------------------------------- ### Install Seeyon Client Source: https://github.com/demomacro/seeyon-client/blob/main/README.md Instructions for installing the seeyon-client library using npm, pnpm, or yarn package managers. This is the initial step to integrate the client into your project. ```bash npm install seeyon-client # 或者 pnpm add seeyon-client # 或者 yarn add seeyon-client ``` -------------------------------- ### Seeyon Client Project Structure Source: https://github.com/demomacro/seeyon-client/blob/main/README.md An overview of the file and directory structure for the seeyon-client project. It details the organization of source code, build configurations, example playgrounds, documentation, and testing setup. ```text seeyon-client/ ├── packages/seeyon-client/ # 源代码 │ ├── src/ │ │ ├── types.ts # TypeScript 类型定义 │ │ ├── client.ts # 主客户端类 │ │ ├── resources/ # 资源类 │ │ │ ├── cap4.ts # CAP4 表单和工作流 │ │ │ └── index.ts # 资源导出 │ │ └── index.ts # 主入口点 │ ├── build.config.ts # 构建配置 │ └── package.json ├── playground/ # 示例环境 │ ├── client.ts # 客户端示例 │ ├── config.ts # 配置管理 │ ├── package.json # 依赖声明 │ └── tsconfig.json # TypeScript 配置 ├── docs/ # 文档 │ └── seeyoncloud/ # Seeyon 官方文档 ├── basis.config.ts # 基础配置 ├── renovate.json # 依赖更新配置 ├── vitest.config.ts # 测试配置 └── package.json ``` -------------------------------- ### Start Workflow Process API Source: https://context7.com/demomacro/seeyon-client/llms.txt Initiates a new workflow instance within the Seeyon CAP4 system, allowing for the submission of form data and attachments. ```APIDOC ## Start Workflow Process Initiate a new workflow instance with form data and attachments. ### Description This endpoint allows you to start a new workflow process in Seeyon CAP4. You can provide form data, specify attachments, and configure process initiation options. ### Method `client.cap4.startProcess(options)` ### Parameters #### `options` Object - **appName** (string) - Required - The name of the application or module (e.g., '协同工作流'). - **data** (object) - Required - The data object for the process initiation. - **templateCode** (string) - Required - The code of the workflow template. - **draft** (string) - Optional - '0' for create and send, '1' for create as draft. Defaults to '0'. - **subject** (string) - Required - The subject of the workflow process. - **attachments** (array) - Optional - An array of attachment IDs. - **relateDoc** (string) - Optional - Related document information in a specific format (e.g., 'col|123,456;doc|789'). - **data** (object) - Required - The main form data and related data. - **formmain_[id]** (object) - Main form fields. - **formson_[id]** (array) - Sub-table data (array of records). - **thirdAttachments** (array) - CAP4 attachment metadata. - **subReference** (string) - Attachment reference. - **fileUrl** (string) - Attachment ID or URL. - **sort** (number) - Order of the attachment. - **changedFields** (object) - Fields that trigger calculations. - **useNewDataStructure** (boolean) - Optional - Whether to use the new data structure. Defaults to `false`. - **doTrigger** (boolean) - Optional - Whether to trigger process calculations. Defaults to `true`. ### Request Example ```typescript const processResult = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "PURCHASE_REQUEST_001", draft: "0", // 0: create and send; 1: create as draft subject: "Purchase Request - Office Supplies", attachments: [432641077895385013, 355134930180197101], // Title attachment IDs relateDoc: "col|123456,789012;doc|321654,987654", data: { formmain_0177: { "申请人": "张三", "申请部门": "技术部", "申请金额": "5000", "申请原因": "购买办公用品", "上传附件1": "3091996204880318295" // CAP4 attachment field }, formson_0185: [ // Sub-table data (array of records) { "物品名称": "笔记本电脑", "数量": "2", "单价": "4500", "金额": "9000", "备注": "联想ThinkPad" }, { "物品名称": "鼠标", "数量": "5", "单价": "50", "金额": "250" } ], thirdAttachments: [ // CAP4 attachment metadata { subReference: "3091996204880318295", fileUrl: "432641077895385013", sort: 1 } ], changedFields: { // Fields to trigger calculation formmain_0177: ["申请金额", "申请部门"], formson_0185: ["数量", "单价"] } }, useNewDataStructure: false, doTrigger: true } }); ``` ### Response #### Success Response (200) - **data** (object) - The result of the process initiation. - **processId** (string) - The ID of the initiated process. - **summaryId** (string) - The ID of the process summary. - **affairId** (string) - The ID of the affair. - **subject** (string) - The subject of the process. - **workitems** (array) - An array of work item details. - **id** (string) - Work item ID. - **nodeId** (string) - Node ID. - **nodeName** (string) - Node name. - **userLoginName** (string) - User login name. - **userName** (string) - User name. - **errorMsg** (string) - Error message if the process failed. #### Response Example ```json { "data": { "processId": "1234567890", "summaryId": "0987654321", "affairId": "1122334455", "subject": "Purchase Request - Office Supplies", "workitems": [ { "id": "wi_1", "nodeId": "node_a", "nodeName": "Reviewer", "userLoginName": "lisi", "userName": "李四" } ], "errorMsg": null } } ``` #### Error Handling Example ```typescript if (processResult.data.errorMsg) { console.error("Process start error:", processResult.data.errorMsg); } ``` ``` -------------------------------- ### Building the Seeyon Client Project Source: https://github.com/demomacro/seeyon-client/blob/main/README.md Commands for managing project dependencies and building the seeyon-client package. Includes installing dependencies, building the project, and running in development mode with file watching. ```bash # 安装依赖 pnpm install # 构建 cd packages/seeyon-client pnpm build # 开发模式(监听文件变化) pnpm dev ``` -------------------------------- ### Leveraging TypeScript Types for Seeyon Client Development Source: https://context7.com/demomacro/seeyon-client/llms.txt Illustrates how to utilize TypeScript's type definitions provided by the 'seeyon-client' library for type-safe development. This includes defining configurations, process start parameters, batch operation data, and export data, ensuring code correctness and improving developer experience. ```typescript import { SeeyonClient, SeeyonConfig, ProcessStartParams, ProcessStartResponse, BatchOperationParams, BatchOperationResponse, ExportDataParams, ExportDataResponse, FormCaptureParams, FormDataItem, MasterTable, SubTable, ApiResponse } from "seeyon-client"; const config: SeeyonConfig = { username: "rest_user", password: "rest_pass", baseURL: "http://localhost/seeyon", loginName: "admin", timeout: 60000 }; const client = new SeeyonClient(config); const processParams: ProcessStartParams = { appName: "协同工作流", data: { templateCode: "TEMPLATE_001", draft: "0", subject: "Type-safe Request", data: { formmain_001: { field1: "value1" } } } }; const processResponse: ApiResponse = await client.cap4.startProcess(processParams); const masterTable: MasterTable = { name: "formmain_001", record: { id: 1, fields: [ { name: "field1", value: "value1", showValue: "Display 1" } ] } }; const subTable: SubTable = { name: "formson_001", records: [ { id: 1, fields: [ { name: "subfield1", value: "subvalue1", showValue: "Sub Display 1" } ] } ] }; const formDataItem: FormDataItem = { masterTable, subTables: [subTable] }; const batchParams: BatchOperationParams = { formCode: "FORM_001", loginName: "admin", rightId: "view.auth", dataList: [formDataItem] }; const batchResponse: ApiResponse = await client.cap4.batchAdd(batchParams); const exportParams: ExportDataParams = { templateCode: "FORM_001", rightId: "view.auth", beginDateTime: "2023-01-01 00:00:00", endDateTime: "2023-12-31 23:59:59", page: 1, pageSize: 50 }; const exportResponse: ApiResponse = await client.cap4.exportData(exportParams); exportResponse.data.definition.fields.forEach(field => { console.log(`${field.display}: ${field.fieldType}`); }); ``` -------------------------------- ### Seeyon API Response Data Example (JSON) Source: https://github.com/demomacro/seeyon-client/blob/main/docs/seeyoncloud/CAP4.md This JSON structure illustrates a typical successful response from a Seeyon API, containing a status code, message, and detailed data including work items, process information, and business data. ```json { "code": 0, "data": { "workitems": [ { "nodeName": "节点姓名", "userLoginName": "loginName", "id": "6063271658185834554", "userName": "用户姓名", "nodeId": "15940211100644", "userId": "5647565013925644425" } ], "app_bussiness_data": "{\"affairId\":\"-7826004588359563757\",\"summaryId\":\"2076716881761815485\"}", "processId": "5724125432261003059", "subject": "aaa1", "errorMsg": "" }, "message": "" } ``` -------------------------------- ### Seeyon Batch Add Form Request Parameters Example (JSON) Source: https://github.com/demomacro/seeyon-client/blob/main/docs/seeyoncloud/CAP4.md This JSON payload demonstrates the parameters required for the Seeyon batch add form API. It specifies form code, login name, right ID, and a list of data entries, each containing master and sub-table information. ```json { "formCode": "aaa1", "loginName": "zhai", "rightId": "56195256829429332.-470190193844795028", "doTrigger": true, "dataList": [ { "masterTable": { "name": "formmain_0019", "record": { "id": 123456789101, "fields": [ { "name": "field0001", "value": "", "showValue": "create" }, { "name": "field0002", "value": "", "showValue": "one" } ] }, "changedFields": ["field0001", "field0002"] }, "subTables": [ { "name": "formson_0021", "records": [ { "id": 123456789101, "fields": [ { "name": "field0005", "value": "", "showValue": "cap" } ] } ], "changedFields": ["field0005"] } ] } ] } ``` -------------------------------- ### Seeyon API Request Parameters Example (JSON) Source: https://github.com/demomacro/seeyon-client/blob/main/docs/seeyoncloud/CAP4.md This JSON structure represents a sample request payload for a Seeyon API operation, likely for creating or updating a form entry. It includes application name, data details, template code, attachments, and subject. ```json { "appName": "collaboration", "data": { "data": { "formmain_0177": { "文本1": "测试文本1-111", "上传附件1": "3091996204880318295", "图片下拉1": "-2767075386175501632" }, "formson_0185": [ { "图片下拉2": "-2767075386175501632", "上传附件2": "-6092561120937621142" } ], "thirdAttachments": [ { "subReference": "3091996204880318295", "fileUrl": "432641077895385013", "sort": 1 }, { "subReference": "-6092561120937621142", "fileUrl": "355134930180197101", "sort": 1 } ], "changedFields": { "formmain_0177": ["选人1", "文本1"], "formson_0185": ["选人2"] } }, "templateCode": "ABC1111", "draft": "0", "attachments": [123456, 123457], "relateDoc": "col|123,456;doc|321,654", "subject": "", "useNewDataStructure": false, "doTrigger": true } } ``` -------------------------------- ### Seeyon Batch Add Form Response Data Example (JSON) Source: https://github.com/demomacro/seeyon-client/blob/main/docs/seeyoncloud/CAP4.md This JSON output shows the result of a Seeyon batch add form operation. It indicates the success code, counts of successful and failed entries, and lists of IDs for successful operations. ```json { "code": 0, "data": { "successIdList": [4035394180072293997], "failedData": {}, "successCount": 1, "failedCount": 0 }, "message": "" } ``` -------------------------------- ### CAP4 Resource Operations Source: https://github.com/demomacro/seeyon-client/blob/main/README.md This section details the operations available for CAP4 resources, including starting processes, updating cache data, batch operations, and data export. ```APIDOC ## POST /api/cap4/process/start ### Description Starts a new process with the provided parameters. ### Method POST ### Endpoint /api/cap4/process/start ### Parameters #### Request Body - **params** (ProcessStartParams) - Required - Parameters for starting a process. ### Request Example ```json { "processKey": "exampleProcessKey", "businessData": {} } ``` ### Response #### Success Response (200) - **data** (ProcessStartResponse) - Details of the started process. #### Response Example ```json { "success": true, "data": { "processId": "exampleProcessId" } } ``` ## PUT /api/cap4/cache/formdata ### Description Updates the cached form data. ### Method PUT ### Endpoint /api/cap4/cache/formdata ### Parameters #### Request Body - **params** (UpdateCacheFormDataParams) - Required - Parameters for updating cache form data. ### Request Example ```json { "formId": "exampleFormId", "formData": {} } ``` ### Response #### Success Response (200) - **data** (void) - Indicates successful update. #### Response Example ```json { "success": true } ``` ## POST /api/cap4/batch/add ### Description Performs a batch addition of resources. ### Method POST ### Endpoint /api/cap4/batch/add ### Parameters #### Request Body - **params** (BatchOperationParams) - Required - Parameters for batch addition. ### Request Example ```json { "resources": [] } ``` ### Response #### Success Response (200) - **data** (BatchOperationResponse) - Response containing the results of the batch operation. #### Response Example ```json { "success": true, "data": { "successfulCount": 10, "failedCount": 0 } } ``` ## PUT /api/cap4/batch/update ### Description Performs a batch update of resources. ### Method PUT ### Endpoint /api/cap4/batch/update ### Parameters #### Request Body - **params** (BatchOperationParams) - Required - Parameters for batch update. ### Request Example ```json { "resources": [] } ``` ### Response #### Success Response (200) - **data** (BatchOperationResponse) - Response containing the results of the batch operation. #### Response Example ```json { "success": true, "data": { "successfulCount": 10, "failedCount": 0 } } ``` ## DELETE /api/cap4/batch/delete ### Description Performs a batch deletion of resources. ### Method DELETE ### Endpoint /api/cap4/batch/delete ### Parameters #### Request Body - **params** (BatchDeleteParams) - Required - Parameters for batch deletion. ### Request Example ```json { "ids": [] } ``` ### Response #### Success Response (200) - **data** (BatchOperationResponse) - Response containing the results of the batch operation. #### Response Example ```json { "success": true, "data": { "successfulCount": 10, "failedCount": 0 } } ``` ## POST /api/cap4/data/export ### Description Exports data based on the provided parameters. ### Method POST ### Endpoint /api/cap4/data/export ### Parameters #### Request Body - **params** (ExportDataParams) - Required - Parameters for data export. ### Request Example ```json { "filters": {}, "format": "csv" } ``` ### Response #### Success Response (200) - **data** (ExportDataResponse) - Response containing the exported data. #### Response Example ```json { "success": true, "data": { "fileUrl": "http://example.com/export.csv" } } ``` ## POST /api/cap4/form/capture ### Description Captures form data. ### Method POST ### Endpoint /api/cap4/form/capture ### Parameters #### Request Body - **params** (FormCaptureParams) - Required - Parameters for form capture. ### Request Example ```json { "formId": "exampleFormId", "captureData": {} } ``` ### Response #### Success Response (200) - **data** (FormCaptureResponse) - Response containing the captured form data. #### Response Example ```json { "success": true, "data": { "captureId": "exampleCaptureId" } } ``` ``` -------------------------------- ### Custom HTTP Requests for Seeyon REST Endpoints Source: https://context7.com/demomacro/seeyon-client/llms.txt Demonstrates how to make custom GET, POST, PUT, and DELETE requests to Seeyon REST endpoints using the client library. Allows for specifying request methods, bodies, and headers for flexibility beyond predefined helper methods. ```typescript const customGetResult = await client.request("/rest/orgMember/123", { method: "GET" }); const customPostResult = await client.request("/rest/custom-endpoint", { method: "POST", body: { param1: "value1", param2: "value2" }, headers: { "X-Custom-Header": "custom-value" } }); const customPutResult = await client.request("/rest/resource/456", { method: "PUT", body: { updatedField: "newValue" } }); const customDeleteResult = await client.request("/rest/resource/789", { method: "DELETE" }); ``` -------------------------------- ### Batch Operations for Seeyon Forms Source: https://github.com/demomacro/seeyon-client/blob/main/README.md Example demonstrating how to perform batch addition of form data using the `batchAdd` method from the `client.cap4` resource. It specifies the form code, login name, right ID, and a list of data records for the main table. ```typescript // 批量添加表单数据 const batchResult = await client.cap4.batchAdd({ formCode: "your-form-code", loginName: "your-login-name", rightId: "your-right-id", dataList: [ { masterTable: { name: "form_main_001", record: { id: 1, fields: [ { name: "field1", value: "value1", showValue: "显示值1" }, { name: "field2", value: "value2", showValue: "显示值2" }, ], }, }, }, ], }); ``` -------------------------------- ### Comprehensive Error Handling for Seeyon API Operations Source: https://context7.com/demomacro/seeyon-client/llms.txt Provides examples of error handling for Seeyon API operations, including business logic errors, network issues, authentication failures, and timeouts. It covers both individual requests and batch operations, offering guidance on identifying and reacting to different error types. ```typescript import { SeeyonClient } from "seeyon-client"; const client = new SeeyonClient({ username: "rest_account", password: "rest_password" }); try { const result = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "INVALID_CODE", draft: "0", subject: "Test" } }); if (result.code !== 0) { console.error(`Business error: ${result.message} (Code: ${result.code})`); } else if (result.data.errorMsg) { console.error(`Process error: ${result.data.errorMsg}`); } else { console.log("Success:", result.data.processId); } } catch (error) { if (error.message.includes("401")) { console.error("Authentication failed - check credentials or token"); } else if (error.message.includes("404")) { console.error("Endpoint not found - check baseURL and API version"); } else if (error.message.includes("timeout")) { console.error("Request timeout - check network or increase timeout setting"); } else { console.error("Request failed:", error.message); } } try { const batchResult = await client.cap4.batchAdd({ formCode: "TEST_FORM", loginName: "admin", rightId: "test.test", dataList: [] }); console.log(`Success: ${batchResult.data.successCount}, Failed: ${batchResult.data.failedCount}`); if (batchResult.data.failedCount > 0) { Object.entries(batchResult.data.failedData).forEach(([recordId, errorMsg]) => { console.error(`Record ${recordId} failed: ${errorMsg}`); }); } } catch (error) { console.error("Batch operation failed:", error); } ``` -------------------------------- ### CAP4 API - Workflow and Form Operations Source: https://github.com/demomacro/seeyon-client/blob/main/README.md Provides methods for interacting with Seeyon CAP4 features, including starting workflows, performing batch operations, exporting data, and capturing form screenshots. ```APIDOC ## CAP4 API - Workflow and Form Operations ### Description This section details the methods available under `client.cap4` for managing CAP4 workflows and forms. This includes starting new processes, handling data in batches, exporting data, and capturing form images. ### Method `client.cap4` object containing various methods. ### Endpoint N/A (Client-side library, interacts with Seeyon REST API) ### Parameters #### `startProcess(options)` - **options** (object) - Required - Options for starting a workflow. - **appName** (string) - Required - The name of the application or workflow. - **data** (object) - Required - Workflow data. - **templateCode** (string) - Required - The code of the workflow template. - **draft** (string) - Required - Draft status ('0' for new, '1' for draft). - **subject** (string) - Required - The subject of the workflow. #### `batchAdd(options)` - **options** (object) - Required - Options for batch adding form data. - **formCode** (string) - Required - The code of the form. - **loginName** (string) - Required - Login name for the operation. - **rightId** (string) - Required - The ID for permissions. - **dataList** (Array) - Required - List of data records to add. - **masterTable** (object) - Required - Master table data. - **name** (string) - Required - Name of the master table. - **record** (object) - Required - Record data. - **id** (number) - Required - Record ID. - **fields** (Array) - Required - List of fields. - **name** (string) - Required - Field name. - **value** (any) - Required - Field value. - **showValue** (string) - Optional - Display value of the field. #### `exportData(options)` - **options** (object) - Required - Options for exporting data. - **templateCode** (string) - Required - The code of the template. - **rightId** (string) - Required - The ID for permissions. - **beginDateTime** (string) - Required - Start date and time (YYYY-MM-DD HH:mm:ss). - **endDateTime** (string) - Required - End date and time (YYYY-MM-DD HH:mm:ss). - **page** (number) - Optional - Page number for pagination (default: 1). - **pageSize** (number) - Optional - Number of records per page (default: 100). #### `formCapture(options)` - **options** (object) - Required - Options for capturing a form screenshot. - **rightId** (string) - Required - The ID for permissions. - **moduleId** (string) - Required - The module ID. - **moduleType** (number) - Required - Type of module (e.g., 42 for CAP form, 1 for workflow form). - **renderType** (string) - Required - The rendering type ('base64' or 'pdf'). - **requestParams** (object) - Required - Parameters for the request. - **serverName** (string) - Required - Server name. - **serverPort** (string) - Required - Server port. - **scheme** (string) - Required - Protocol (http or https). - **contextPath** (string) - Required - Context path of the Seeyon application. ### Request Example #### Start Workflow ```typescript const result = await client.cap4.startProcess({ appName: "协同工作流", data: { templateCode: "your-template-code", draft: "0", subject: "测试申请", }, }); console.log("Workflow started:", result); ``` #### Batch Add Data ```typescript const batchResult = await client.cap4.batchAdd({ formCode: "your-form-code", loginName: "your-login-name", rightId: "your-right-id", dataList: [ { masterTable: { name: "form_main_001", record: { id: 1, fields: [ { name: "field1", value: "value1", showValue: "显示值1" }, { name: "field2", value: "value2", showValue: "显示值2" }, ], }, }, }, ], }); ``` #### Export Data ```typescript const exportResult = await client.cap4.exportData({ templateCode: "your-template-code", rightId: "your-right-id", beginDateTime: "2024-01-01 00:00:00", endDateTime: "2024-12-31 23:59:59", page: 1, pageSize: 100, }); ``` #### Form Capture ```typescript const capture = await client.cap4.formCapture({ rightId: "your-right-id", moduleId: "your-module-id", moduleType: 1, renderType: "base64", requestParams: { serverName: "your-server", serverPort: "8080", scheme: "http", contextPath: "/seeyon", }, }); ``` ### Response #### Success Response (startProcess) - **result** (object) - Details of the started workflow. #### Success Response (batchAdd) - **success** (boolean) - Indicates if the batch operation was successful. - **message** (string) - A message describing the result. #### Success Response (exportData) - **data** (Array) - List of exported data records. - **total** (number) - Total number of records available. #### Success Response (formCapture) - **content** (string) - The captured form data (base64 or PDF content). #### Response Example ```json { "result": { /* workflow details */ }, "success": true, "message": "Operation completed successfully.", "data": [ /* exported data */ ], "total": 100, "content": "data:image/png;base64,iVBORw0KGgo..." } ``` ``` -------------------------------- ### Initialize Seeyon Client Instance Source: https://context7.com/demomacro/seeyon-client/llms.txt Demonstrates how to create and configure a SeeyonClient instance. Covers basic initialization with credentials and advanced configuration including user identity simulation, custom headers, and timeouts. Includes methods for retrieving and refreshing authentication tokens. ```typescript import { SeeyonClient } from "seeyon-client"; // Basic initialization const client = new SeeyonClient({ username: "rest_account", password: "rest_password", baseURL: "http://127.0.0.1/seeyon", timeout: 30000, retry: 3 }); // With user identity simulation and custom headers const clientWithIdentity = new SeeyonClient({ username: "rest_account", password: "rest_password", baseURL: "https://seeyon.company.com/seeyon", loginName: "zhangsan", // Simulate login as this user memberId: "1234567890", // User ID memberCode: "EMP001", // Employee code userAgentFrom: "mobile", // Terminal type: pc, mobile, wechat, etc. headers: { "X-Custom-Header": "value" } }); // Get authentication token (auto-acquired if needed) const token = await client.getToken(); console.log("Token:", token); // Manually refresh token (automatically done when expired) const authResponse = await client.refreshToken(); console.log("New Token:", authResponse.id); console.log("Bound User:", authResponse.bindingUser); ``` -------------------------------- ### Seeyon Client Initialization Source: https://context7.com/demomacro/seeyon-client/llms.txt Demonstrates how to create and configure a Seeyon client instance with various options, including authentication, base URL, and custom headers. ```APIDOC ## Initialize Seeyon Client Create and configure a Seeyon client instance with authentication credentials. ### Description This section details the process of initializing the SeeyonClient, including basic setup and advanced configurations like user identity simulation and custom headers. ### Method `new SeeyonClient(options)` ### Parameters #### Constructor Options - **username** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. - **baseURL** (string) - Required - The base URL of the Seeyon REST API. - **timeout** (number) - Optional - The request timeout in milliseconds. Defaults to 30000. - **retry** (number) - Optional - The number of times to retry failed requests. Defaults to 3. - **loginName** (string) - Optional - The login name for simulating user identity. - **memberId** (string) - Optional - The user ID for simulating user identity. - **memberCode** (string) - Optional - The employee code for simulating user identity. - **userAgentFrom** (string) - Optional - The terminal type (e.g., 'pc', 'mobile'). - **headers** (object) - Optional - Custom headers to include in requests. ### Request Example ```typescript import { SeeyonClient } from "seeyon-client"; // Basic initialization const client = new SeeyonClient({ username: "rest_account", password: "rest_password", baseURL: "http://127.0.0.1/seeyon", timeout: 30000, retry: 3 }); // With user identity simulation and custom headers const clientWithIdentity = new SeeyonClient({ username: "rest_account", password: "rest_password", baseURL: "https://seeyon.company.com/seeyon", loginName: "zhangsan", // Simulate login as this user memberId: "1234567890", // User ID memberCode: "EMP001", // Employee code userAgentFrom: "mobile", // Terminal type: pc, mobile, wechat, etc. headers: { "X-Custom-Header": "value" } }); ``` ### Related Functions #### `getToken()` Gets the authentication token. #### `refreshToken()` Manually refreshes the authentication token. ### Response Example ```typescript // Get authentication token (auto-acquired if needed) const token = await client.getToken(); console.log("Token:", token); // Manually refresh token (automatically done when expired) const authResponse = await client.refreshToken(); console.log("New Token:", authResponse.id); console.log("Bound User:", authResponse.bindingUser); ``` ``` -------------------------------- ### Configure Seeyon Client with Simple and Advanced Options Source: https://github.com/demomacro/seeyon-client/blob/main/packages/seeyon-client/README.md Illustrates two ways to initialize the `SeeyonClient`: a simple configuration using only username and password, and an advanced configuration with custom baseURL, timeout, retry count, and headers. ```typescript import { SeeyonClient } from "seeyon-client"; // 简单配置(使用默认设置) const client = new SeeyonClient({ username: "admin", password: "password123", }); // 高级配置(自定义设置) const client = new SeeyonClient({ username: "admin", password: "password123", baseURL: "https://your-seeyon-server.com/seeyon", timeout: 60000, retry: 5, headers: { "X-Custom-Header": "custom-value", }, loginName: "模拟用户", memberId: "user001", }); ``` -------------------------------- ### Custom HTTP Request Source: https://context7.com/demomacro/seeyon-client/llms.txt Allows making custom HTTP requests (GET, POST, PUT, DELETE) to Seeyon REST endpoints when specific helper methods are not available. You can specify the method, endpoint, request body, and headers. ```APIDOC ## Custom HTTP Request ### Description Make custom requests to Seeyon REST endpoints not covered by helper methods. ### Method Supports GET, POST, PUT, DELETE. ### Endpoint Specify the full endpoint path (e.g., `/rest/orgMember/123`). ### Parameters #### Request Body (for POST/PUT) - **body** (object) - Optional - The request payload. - **headers** (object) - Optional - Custom headers for the request. ### Request Example ```typescript // GET request const customGetResult = await client.request("/rest/orgMember/123", { method: "GET" }); // POST request with custom body const customPostResult = await client.request("/rest/custom-endpoint", { method: "POST", body: { param1: "value1", param2: "value2" }, headers: { "X-Custom-Header": "custom-value" } }); // PUT request const customPutResult = await client.request("/rest/resource/456", { method: "PUT", body: { updatedField: "newValue" } }); // DELETE request const customDeleteResult = await client.request("/rest/resource/789", { method: "DELETE" }); ``` ### Response #### Success Response (200) The response depends on the specific endpoint called. #### Response Example (Varies based on the endpoint) ``` -------------------------------- ### SeeyonClient Initialization and Authentication Source: https://github.com/demomacro/seeyon-client/blob/main/README.md Demonstrates how to initialize the SeeyonClient with configuration and obtain authentication tokens. ```APIDOC ## SeeyonClient Initialization and Authentication ### Description Initialize the SeeyonClient with your Seeyon credentials and server details. This section covers obtaining and refreshing authentication tokens. ### Method Constructor and async methods. ### Endpoint N/A (Client-side library) ### Parameters #### Client Constructor Parameters - **config** (SeeyonConfig) - Required - Configuration object for the client. - **username** (string) - Required - REST API username. - **password** (string) - Required - REST API password. - **baseURL** (string) - Optional - Base URL for Seeyon REST API (default: `http://127.0.0.1/seeyon`). - **timeout** (number) - Optional - Request timeout in milliseconds (default: 30000). - **retry** (number) - Optional - Number of retry attempts (default: 3). - **headers** (Record) - Optional - Additional request headers. - **loginName** (string) - Optional - Username for simulated login. - **memberId** (string) - Optional - User ID. - **memberCode** (string) - Optional - User Code. - **userAgentFrom** (string) - Optional - User agent source. #### Methods - **getToken()** - Returns the current authentication token or `undefined` if not available. - **refreshToken()** - Fetches a new authentication token from the API. ### Request Example ```typescript import { SeeyonClient } from "seeyon-client"; const client = new SeeyonClient({ username: "your-username", password: "your-password", baseURL: "http://127.0.0.1/seeyon", timeout: 30000 }); // Get current token (will auto-refresh if needed) const token = await client.getToken(); console.log("Token:", token); // Force refresh token const auth = await client.refreshToken(); console.log("New Token:", auth.id); ``` ### Response #### Success Response (Token) - **token** (string) - The authentication token. #### Success Response (refreshToken) - **id** (string) - The new authentication token. #### Response Example ```json { "id": "your-auth-token" } ``` ```