### Python Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/API%E9%85%8D%E7%BD%AE%E6%8C%87%E5%BC%95.html This Python code snippet shows how to use the `requests` library to make a GET request to the TAPD API, passing authentication credentials as a tuple. ```APIDOC import requests r = requests.get('https://api.tapd.cn/quickstart/testauth', auth=('api_user', 'api_password')) ret = r.text # Get the API response print(ret) # For Python 3 print ret # For Python 2 Example Response: {"status":1,"data":{"api_user":"api_user","api_password":"api.password","request_ip":"172.8.8.8"},"info":"success"} ``` -------------------------------- ### Install Open TAPD JS SDK Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Install the SDK using npm. This is the first step before using any of its functionalities. ```bash npm install @opentapd/tapd-open-js-sdk ``` -------------------------------- ### Authorization Header Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/%E6%8E%88%E6%9D%83%E5%87%AD%E8%AF%81/%E7%94%A8%E6%88%B7%E6%80%81.html Example of how to format the `Authorization` header using Base64 encoding of `client_id:client_secret`. ```HTTP Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== ``` -------------------------------- ### Get Stories Response Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/story/get_stories.html This snippet shows an example of the JSON response structure when retrieving stories. It includes details like custom plan fields and priority labels. ```APIDOC ## Get Stories Response ### Description This section details the structure of the response when retrieving stories. It includes a list of stories, each with various attributes, and a success message. ### Response Body - **stories** (array) - A list of story objects. - **custom_plan_field_6** (string) - Custom field value. - **custom_plan_field_7** (string) - Custom field value. - **custom_plan_field_8** (string) - Custom field value. - **custom_plan_field_9** (string) - Custom field value. - **custom_plan_field_10** (string) - Custom field value. - **priority_label** (string) - The label for the story's priority. - **info** (string) - A message indicating the status of the request, e.g., "success". ### Response Example ```json { "stories": [ { "custom_plan_field_6": "0", "custom_plan_field_7": "0", "custom_plan_field_8": "0", "custom_plan_field_9": "0", "custom_plan_field_10": "0", "priority_label": "" } ], "info": "success" } ``` ``` -------------------------------- ### HTTP Basic Authentication Header Construction Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/API%E9%85%8D%E7%BD%AE%E6%8C%87%E5%BC%95.html This example demonstrates how to construct the Authorization header for Basic Authentication. It shows the Base64 encoding of a sample api_user and api_password, and how to format it for the Authorization header. ```APIDOC 1. `api_user:api_password` encoded via `BASE64` becomes: `YXBpX3VzZXI6YXBpX3Bhc3N3b3Jk` 2. The Authorization header is then set to: `Authorization: Basic YXBpX3VzZXI6YXBpX3Bhc3N3b3Jk` ``` -------------------------------- ### Basic SDK Usage Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Initialize the SDK and set up event listeners or handlers. Use this to start interacting with TAPD services and UI components. ```javascript import SDK from "@opentapd/tapd-open-js-sdk"; const sdk = SDK(); sdk.events.on('event from ', function(data){ return 'world'; // return to tapd }) sdk.handler('handle name', { hello: 'world', // You param to you service }) sdk.navigator.openAppIndex('rul') sdk.ui.openDialog({url: 'tencent.com'}) ``` -------------------------------- ### Task Update Response Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/task/update_task.html This is an example of a successful response when updating a task. It includes the updated task details, such as ID, name, status, and custom fields. ```json { "status": 1, "data": { "Task": { "id": "1010158231500600385", "name": "检查数据库", "description": " ", "workspace_id": "10158231", "creator": "anyechen", "created": "2019-06-27 10:19:30", "modified": "2019-06-27 11:05:27", "status": "done", "owner": null, "cc": null, "begin": null, "due": null, "story_id": "0", "iteration_id": "0", "priority": "", "progress": "0", "completed": "2019-06-27 11:05:26", "effort_completed": "0", "exceed": "0", "remain": "0", "effort": "0", "label": "阻塞|延期", "cus_自定义字段的名称": "custom_field_value", "custom_field_one": null, "custom_field_two": null, "custom_field_three": null, "custom_field_four": null, "custom_field_five": null, "custom_field_six": null, "custom_field_seven": null, "custom_field_eight": null } }, "info": "success" } ``` -------------------------------- ### Add Tapd Wiki using curl Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/add_tapd_wiki.html Example of creating a wiki in a project using curl with Basic Auth. Ensure you replace 'api_user', 'api_password', and other parameters with your actual values. ```bash curl -u 'api_user:api_password' -d 'name=test111&description=xxxxxxx&workspace_id=10104801&creator=v_xuanfang' 'https://api.tapd.cn/tapd_wikis' ``` -------------------------------- ### Trigger Configuration Example Source: https://open.tapd.cn/document/plugin-doc/learning/yaml/modules/auto-task.html Defines a trigger named 'trigger_demo' that is activated by a specific event and can be associated with changes in stories or bugs. ```yaml trigger: events: - code: trigger_demo desc: 由xxx事件触发 icon: execute name: 触发器demo event_change: handler: trigger.change option: handler: trigger.option related: - story::* - bug::field_change ``` -------------------------------- ### PHP Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/API%E9%85%8D%E7%BD%AE%E6%8C%87%E5%BC%95.html This PHP code snippet demonstrates how to make a request to the TAPD API using cURL, setting the API username and password using `CURLOPT_USERPWD`. ```APIDOC Example Response: {"status":1,"data":{"api_user":"api_user","api_password":"api.password","request_ip":"172.8.8.8"},"info":"success"} ``` -------------------------------- ### Example PHP API Response Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/API%E9%85%8D%E7%BD%AE%E6%8C%87%E5%BC%95.html This is an example of a successful response from the TAPD API when called using PHP. ```json {"status":1,"data":{"api_user":"api_user","api_password":"api.password","request_ip":"172.8.8.8"},"info":"success"} ``` -------------------------------- ### Tapd Wiki Creation Response Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/add_tapd_wiki.html Example of a successful response when creating a wiki. This JSON object contains the details of the newly created wiki, including its ID and other properties. ```json { "status": 1, "data": { "Wiki": { "id": "1210104801000043897", "name": "test111", "workspace_id": "10104801", "description": "xxxxxxx", "markdown_description": "", "is_rich": "1", "parent_wiki_id": "0", "note": "", "view_count": "0", "created": "2020-08-26 10:15:28", "creator": "v_xuanfang", "modified": "2020-08-26 10:15:28", "modifier": "v_xuanfang" } }, "info": "success" } ``` -------------------------------- ### Get Project Wikis (Curl) Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/get_tapd_wikis.html Use this curl command to retrieve wikis for a specific project using Basic Auth. Ensure you replace 'api_user' and 'api_password' with your actual credentials and 'workspace_id' with the target project ID. ```bash curl -u 'api_user:api_password' 'https://api.tapd.cn/tapd_wikis?workspace_id=10104801' ``` -------------------------------- ### Data Example for Options Source: https://open.tapd.cn/document/plugin-doc/learning/yaml/modules/auto-task.html Defines a nested structure for select field options, including sub-fields and their respective options. This is used to configure dynamic choices in forms. ```yaml options = [ { 'label' : '字段A', 'key' : 'field_a', 'fieldType' : 'select', 'options' : [ { 'name' : '选项A', 'value' : 'option_a', 'data' : [ { "key": "field_a", "label": "子字段B", "fieldType": "select", "options": [ { "name": "子选项A", "value": "child_option_a" }, { "name": "子选项B", "value": "child_option_a" } ] } ] }, { 'name' : '选项B', 'value' : 'option_b' } ] } ] return options ``` -------------------------------- ### Standard Automated Event Format Example Source: https://open.tapd.cn/document/plugin-doc/learning/yaml/modules/auto-task.html Illustrates the expected JSON format for an automated event pushed to TAPD, including timestamp, user, new and old object states, and associated TAPD object IDs. ```json { "from": "open_app", "timestamp": 1625567088, "user": "dobbyzhang", "new": { "field":"fieldA", "fieldVal":1 }, "old": { "fieldVal":1 }, "tapd_object_id_list":[ "1020357843854927833" ] } ``` -------------------------------- ### Get Tapd Wikis Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/get_tapd_wikis.html Retrieves a paginated list of wikis for a given project. You can filter, sort, and specify the number of results per page. ```APIDOC ## GET /tapd_wikis ### Description Returns all wikis that match the query conditions (paginated display, default 30 items per page). ### Method GET ### Endpoint `https://api.tapd.cn/tapd_wikis` ### Parameters #### Query Parameters - **id** (integer) - Optional - The ID of the wiki. - **name** (string) - Optional - The title of the wiki. - **modifier** (string) - Optional - The modifier of the wiki. - **creator** (string) - Optional - The creator of the wiki. - **note** (string) - Optional - The note of the wiki. - **view_count** (string) - Optional - The view count of the wiki. - **created** (datetime) - Optional - The creation time. Supports time queries. - **modified** (datetime) - Optional - The last modification time. Supports time queries. - **workspace_id** (integer) - Required - The project ID. - **limit** (integer) - Optional - Sets the limit for the number of returned items. Defaults to 30. Maximum is 200. - **page** (integer) - Optional - Returns the Nth page of data within the current limit. Defaults to 1 (the first page). - **order** (string) - Optional - Sorting rule. Format: field name ASC or DESC, then URL-encoded. Example: `order=created%20desc` for sorting by creation time in descending order. - **fields** (string) - Optional - Sets the fields to retrieve. Multiple fields are separated by commas. ### Request Example ```bash curl -u 'api_user:api_password' 'https://api.tapd.cn/tapd_wikis?workspace_id=10104801' ``` ### Response #### Success Response (200) - **status** (integer) - Indicates the status of the response. - **data** (array) - An array of wiki objects. - **Wiki** (object) - Contains wiki details. - **id** (string) - The ID of the wiki. - **name** (string) - The title of the wiki. - **workspace_id** (string) - The project ID. - **description** (string) - Rich text description. - **markdown_description** (string) - Markdown description. - **is_rich** (string) - Indicates if rich text is used. - **parent_wiki_id** (string) - The parent wiki ID. - **note** (string) - The note for the wiki. - **view_count** (string) - The number of views. - **created** (string) - The creation timestamp. - **creator** (string) - The creator of the wiki. - **modified** (string) - The last modification timestamp. - **modifier** (string) - The last modifier of the wiki. - **info** (string) - Additional information about the response, e.g., "success". #### Response Example ```json { "status": 1, "data": [ { "Wiki": { "id": "1210104801000043827", "name": "test888", "workspace_id": "10104801", "description": "", "markdown_description": "", "is_rich": "0", "parent_wiki_id": "0", "note": "", "view_count": "0", "created": "2020-08-25 11:24:44", "creator": "dev", "modified": "2020-08-25 11:24:44", "modifier": "dev" } } ], "info": "success" } ``` ``` -------------------------------- ### Get User Information Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/%E6%8E%88%E6%9D%83%E5%87%AD%E8%AF%81/%E7%94%A8%E6%88%B7%E6%80%81.html Provides an interface to retrieve user information. This is typically called after obtaining a valid `access_token`. ```APIDOC ## Get User Information Provides an interface to retrieve user information. ``` -------------------------------- ### Bug Copy API Response Example Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/bug/copy_bug.html This snippet shows a typical JSON response when successfully copying a bug. It includes the workspace ID and a success message. ```json { "data": { "custom_field_88": "", "custom_field_89": "", "custom_field_90": "", "custom_field_91": "", "custom_field_92": "", "custom_field_93": "", "custom_field_94": "", "custom_field_95": "", "custom_field_96": "", "custom_field_97": "", "custom_field_98": "", "custom_field_99": "", "custom_field_100": "", "workspace_id": "755" }, "info": "success" } ``` -------------------------------- ### Get Stories Count using Python SDK Source: https://open.tapd.cn/document/plugin-doc/learning/api-and-security Instantiate the TAPD SDK and call the get_stories_count method to retrieve the number of stories for a specific workspace. ```Python from tapdplugin import sdk tapd = sdk.instance() tapd.get_stories_count({workspace_id:755}) ``` -------------------------------- ### Get Wiki Count using curl Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/get_tapd_wikis_count.html Use this curl command to retrieve the number of wikis for a given project ID. Basic Auth is used for authentication. ```bash curl -u 'api_user:api_password' 'https://api.tapd.cn/tapd_wikis/count?workspace_id=10104801' ``` -------------------------------- ### Get Entrance Data Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Retrieve configuration information about the current page's integration with TAPD, including application ID, entrance ID, and authorization code. ```javascript const entranceConfigs = await sdk.context.getEntranceData() // return {appId, entranceId, code} ``` -------------------------------- ### API Response Structure Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/get_tapd_wikis.html This is an example of the JSON response structure when successfully retrieving wikis. It includes status, data, and info fields. The 'data' field contains an array of wiki objects. ```json { "status": 1, "data": [ { "Wiki": { "id": "1210104801000043827", "name": "test888", "workspace_id": "10104801", "description": "", "markdown_description": "", "is_rich": "0", "parent_wiki_id": "0", "note": "", "view_count": "0", "created": "2020-08-25 11:24:44", "creator": "dev", "modified": "2020-08-25 11:24:44", "modifier": "dev" } }, { "Wiki": { "id": "1210104801000043825", "name": "test888", "workspace_id": "10104801", "description": "", "markdown_description": "", "is_rich": "0", "parent_wiki_id": "0", "note": "", "view_count": "1", "created": "2020-08-25 11:22:24", "creator": "dev", "modified": "2020-08-25 11:22:24", "modifier": "dev" } }, { "Wiki": { "id": "1210104801000043823", "name": "test888", "workspace_id": "10104801", "description": "", "markdown_description": "wfwwf4", "is_rich": "0", "parent_wiki_id": "0", "note": "", "view_count": "4", "created": "2020-08-25 11:22:20", "creator": "dev", "modified": "2020-08-25 15:39:05", "modifier": "dev" } } ], "info": "success" } ``` -------------------------------- ### Get Stories Count using Node.js SDK Source: https://open.tapd.cn/document/plugin-doc/learning/api-and-security Import the TAPD SDK and use the getStoriesCount method to fetch the number of stories for a given workspace, handling the promise with .then and .catch. ```javascript const { tapdSdk } = require('@tencent/tplugin-core'); tapdSdk.getStoriesCount({'workspace_id': 755}).then(data => { console.log(data) }).catch(e => { console.log(e) }) ``` -------------------------------- ### Example Webhook Event Data (Story Creation) Source: https://open.tapd.cn/document/api-doc/%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/%E5%BC%80%E5%8F%91%E5%BA%94%E7%94%A8/%E4%BD%BF%E7%94%A8Webhook-%E4%BA%91%E7%AB%AF.html This JSON object represents the data structure sent to your Webhook URL when a story is created. It includes event details, workspace information, and object IDs. ```json { "event": "story::create", "event_from": "web", "referer": "https://xxx/tapd_fe/xxx/story/list?useScene=storyList&groupType=&conf_id=xxx", "workspace_id": "xxx", "current_user": "xxx", "id": "1167870009001000028", "secret": "", "app_id": "3906", "rio_token": "", "devproxy_host": "http:/xxx.com", "queue_id": "130662", "event_id": "42079", "created": "2024-03-26 16:33:05" } ``` -------------------------------- ### Get Story Custom Fields Settings using curl Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/story/get_story_custom_fields_settings.html Use this curl command to authenticate with Basic Auth and retrieve the custom field settings for a story in a given project. Ensure you replace 'api_user' and 'api_password' with your actual credentials and '10104801' with the target workspace ID. ```bash curl -u 'api_user:api_password' 'https://api.tapd.cn/stories/custom_fields_settings?workspace_id=10104801' ``` -------------------------------- ### How to Access Webhook Configuration Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/webhook/webhook_document.html To set up webhooks, submit a request via 'Issue Feedback' (located under the user's avatar in the bottom left corner). You will need to provide the Project ID or Company ID, the specific events to monitor, the URL to receive the data, an optional verification password, and the desired data format. ```APIDOC ## How to Access Webhook Configuration To configure webhooks, navigate to `Issue Feedback` (bottom left avatar) and submit a request including: - `Project ID` or `Company ID` - `Events` to monitor (e.g., requirement creation, defect update, task deletion, release review creation, etc. Multiple selections are allowed). - `URL` for receiving data. - Optional `Verification Password` for request validation. - Optional `Data Format` (json or form, defaults to form). ``` -------------------------------- ### Get Story Custom Fields Settings Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/story/get_story_custom_fields_settings.html Retrieves the custom field configuration for stories in a given project. This is a GET request that requires the project ID as a query parameter. ```APIDOC ## GET /stories/custom_fields_settings ### Description Retrieves the custom field configuration for stories in a given project. This is a GET request that requires the project ID as a query parameter. ### Method GET ### Endpoint `https://api.tapd.cn/stories/custom_fields_settings` ### Parameters #### Query Parameters - **workspace_id** (integer) - Required - Project ID ### Request Example ```json { "example": "curl -u 'api_user:api_password' 'https://api.tapd.cn/stories/custom_fields_settings?workspace_id=10104801'" } ``` ### Response #### Success Response (200) - **status** (integer) - Indicates the success of the operation. - **data** (array) - An array of custom field configurations. - **CustomFieldConfig** (object) - Configuration details for a custom field. - **id** (string) - The ID of the custom field configuration. - **workspace_id** (string) - The ID of the project. - **app_id** (string) - The application ID. - **entry_type** (string) - The type of entry (e.g., 'story'). - **custom_field** (string) - The identifier for the custom field. - **type** (string) - The input type of the custom field. - **name** (string) - The display name of the custom field. - **options** (string) - The selectable options for the custom field. - **extra_config** (string) - Additional configuration information. - **enabled** (string) - Indicates if the custom field is enabled. - **creator** (string) - The user who created the custom field. - **created** (string) - The creation timestamp. - **modified** (string) - The last modified timestamp. - **freeze** (string) - Indicates if the field is frozen. - **sort** (string) - The sorting order for the custom field. - **memo** (string) - A memo or note for the custom field. - **open_extension_id** (string) - The extension ID for plugins. - **is_out** (integer) - Deprecated field. - **is_uninstall** (integer) - Indicates if the application is uninstalled. - **app_name** (string) - The name of the application. - **info** (string) - A message indicating the status of the request. #### Response Example ```json { "status": 1, "data": [ { "CustomFieldConfig": { "id": "1010104801216209053", "workspace_id": "10104801", "app_id": "1", "entry_type": "story", "custom_field": "custom_field_17", "type": "cascade_radio", "name": "联动字段测试", "options": "[\"{\"name\":\"a1\",\"children\":[{\"name\":\"a11\"},{\"name\":\"a12\",\"children\":[{\"name\":\"a123\"}]}]},{\"name\":\"a2\"},{\"name\":\"a3\"}]", "extra_config": null, "enabled": "1", "creator": "", "created": "0000-00-00 00:00:00", "modified": "0000-00-00 00:00:00", "freeze": "0", "sort": "0", "memo": null, "open_extension_id": "", "is_out": 0, "is_uninstall": 0, "app_name": "" } } ], "info": "success" } ``` ``` -------------------------------- ### SDK Navigator Methods Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Methods for navigating within the TAPD application and opening external objects. ```APIDOC ### # SDK-调用navigator ### `.openAppIndex(url: string)` Opens a new page within the TAPD application for an embedded SDK app. **Parameters:** - `url` (string) - The route of the embedded application. ### `.openObjectWindow(params: { entityType: string, entityId: string })` Opens the detail page of a TAPD business object (currently supports requirements, tasks, and defects). **Parameters:** - `params` (object) - `entityType` (string) - The type of the entity (e.g., 'story', 'task', 'bug'). - `entityId` (string) - The ID of the entity. ### `.syncUrl(options: {url: string, refresh: bolean})` Updates the current browser route, typically used to synchronize embedded application routes with browser routes. **Parameters:** - `options` (object) - `url` (string) - The target route. - `refresh` (boolean) - Whether to refresh the page after updating the route. ### `.updateTabCount({count: number, refresh: bolean})` Updates the numerical value displayed in a tab of an extension module. **Parameters:** - `count` (number) - The numerical value to update. - `refresh` (boolean) - Whether to refresh the route after updating (defaults to false). ### `.openObjectTab({tabName: string})` Switches to a specific tab within the detail page of an object (currently supports requirements, tasks, and defects). **Parameters:** - `tabName` (string) - The name of the tab to switch to. ``` -------------------------------- ### Get Workspace Member List Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Retrieve a list of members for a given TAPD workspace. You can specify the page size and page number for pagination. ```javascript sdk.request .getWorkspaceMemberList({ page_size: 100, workspace_id: '1', page: 1 }) .then((response) => { console.log(response) }) ``` -------------------------------- ### Get TAPD Workspace Member List Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Retrieves a list of members for a given TAPD workspace. Supports pagination with page_size and page parameters. ```javascript sdk.request .getWorkspaceMemberList({ page_size: 100, workspace_id: '1', page: 1 }) .then((response) => { console.log(response) }) ``` -------------------------------- ### on Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Listens for events emitted from TAPD. ```APIDOC ## on ### Description Listens for events emitted from TAPD. A callback function is executed when the event is triggered. The callback can return data to be sent back to TAPD. ### Method `on(event: string, cb: data => res, config: {once: bolean})` ### Parameters #### Path Parameters - None #### Query Parameters - **event** (string) - Required - The name of the event to listen for. - **cb** (data => res) - Required - The callback function to execute when the event is triggered. It receives data and can return a response. - **config** (object) - Optional - Configuration object. - **once** (boolean) - Optional - If true, the listener will be removed after the first trigger. #### Request Body - None ### Request Example ```javascript sdk.events.on('ConfirmYes', function() { return { id: 'target Objct ID' } }, { once: true }); ``` ### Response #### Success Response (200) - None explicitly defined, callback execution is the primary outcome. #### Response Example - None ``` -------------------------------- ### SDK UI Methods Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Methods for interacting with the TAPD UI, including alerts, confirmations, dialogs, and resizing. ```APIDOC ## SDK-调用TAPDUI ### `.alert(message: string)` Displays a simple alert message. **Parameters:** - `message` (string) - The message to display in the alert. ### `.confirm(message: string) => Promise` Displays a confirmation dialog with a message and returns a promise that resolves when the user confirms. **Parameters:** - `message` (string) - The message to display in the confirmation dialog. ### `.openDialog(params)` Opens a dialog window with specified parameters. **Parameters:** - `params` (object) - An object containing dialog configuration. - `title` (string) - The title of the dialog. - `url` (string) - The URL to load in the dialog. - `height` (number) - The height of the dialog. - `width` (number) - The width of the dialog. - `showBtn` (boolean) - Whether to show the confirmation button. - `btnYesText` (string) - The text for the confirmation button. - `btnNoText` (string) - The text for the cancel button. ### `.closeDialog()` Closes the currently open TAPD dialog. ### `.resizeDialog(width: number, height: number)` Adjusts the size of the dialog window. **Parameters:** - `width` (number) - The new width of the dialog. - `height` (number) - The new height of the dialog. ``` -------------------------------- ### SDK Context Methods Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Methods for retrieving context information and managing authorization codes. ```APIDOC ### # SDK-获取context ### `.getEntranceData() => Promise ` Retrieves configuration information for the current page embedded in TAPD. **Returns:** - `entranceConfigs` (object) - An object containing configuration details. - `appId` (string) - The application ID. - `code` (string) - The TAPD authorization code. - `entranceId` (string) - The mount point ID. ### `.refreshCode() => Promise ` Refreshes the TAPD authorization code, typically used when the code has expired. **Returns:** - `newCode` (string) - The new authorization code. ``` -------------------------------- ### Basic Condition Configuration Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/storage/condition.html Configure basic conditions using field, operator, and value. Multiple fields are implicitly ANDed. Use arrays for 'IN'/'NOT IN' operators. ```json "condition": { "field1": { "op": "=", "val": "tapd" }, "field2": { "op": "IN", "val": [138, 156] } } ``` -------------------------------- ### Add Tapd Wiki Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/add_tapd_wiki.html Creates a new Wiki entry in Tapd. You can provide a title, description (rich text or Markdown), creator, and the project ID. A parent Wiki ID can also be specified to create sub-wikis. ```APIDOC ## POST https://api.tapd.cn/tapd_wikis ### Description Creates a new Wiki entry in Tapd. You can provide a title, description (rich text or Markdown), creator, and the project ID. A parent Wiki ID can also be specified to create sub-wikis. ### Method POST ### Endpoint https://api.tapd.cn/tapd_wikis ### Parameters #### Request Body - **name** (string) - Required - Title of the Wiki. - **markdown_description** (string) - Optional - Description in Markdown format. - **description** (string) - Optional - Description in rich text format. - **creator** (string) - Required - The username of the creator. - **note** (string) - Optional - Additional notes for the Wiki. - **workspace_id** (integer) - Required - The ID of the project (workspace) where the Wiki will be created. - **parent_wiki_id** (string) - Optional - The ID of the parent Wiki to create this Wiki as a sub-wiki. ### Request Example ```json { "name": "test111", "description": "xxxxxxx", "workspace_id": 10104801, "creator": "v_xuanfang" } ``` ### Response #### Success Response (200) - **status** (integer) - Indicates the success of the operation (1 for success). - **data** (object) - Contains the details of the created Wiki. - **Wiki** (object) - Details of the created Wiki. - **id** (string) - The unique identifier of the created Wiki. - **name** (string) - The title of the Wiki. - **workspace_id** (string) - The ID of the project. - **description** (string) - The rich text description of the Wiki. - **markdown_description** (string) - The Markdown description of the Wiki. - **is_rich** (string) - Indicates if the description is in rich text format ('1' for rich text). - **parent_wiki_id** (string) - The ID of the parent Wiki. - **note** (string) - Additional notes. - **view_count** (string) - The number of views. - **created** (string) - The creation timestamp. - **creator** (string) - The username of the creator. - **modified** (string) - The last modification timestamp. - **modifier** (string) - The username of the last modifier. - **info** (string) - A message indicating the status (e.g., "success"). #### Response Example ```json { "status": 1, "data": { "Wiki": { "id": "1210104801000043897", "name": "test111", "workspace_id": "10104801", "description": "xxxxxxx", "markdown_description": "", "is_rich": "1", "parent_wiki_id": "0", "note": "", "view_count": "0", "created": "2020-08-26 10:15:28", "creator": "v_xuanfang", "modified": "2020-08-26 10:15:28", "modifier": "v_xuanfang" } }, "info": "success" } ``` ``` -------------------------------- ### on Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Listens for events emitted from TAPD. It allows specifying a callback function and an option to listen only once. ```APIDOC ## on ### Description Listens for events emitted from TAPD. It allows specifying a callback function and an option to listen only once. ### Method `on(event: string, cb: data => res, config: {once: bolean}) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **event** (string) - Required - The name of the event to listen for. * **cb** (function) - Required - The callback function to execute when the event is triggered. It receives data as a parameter and can return data to send back to TAPD. * **config** (object) - Optional - Configuration object. * **once** (boolean) - Optional - If true, the listener will be removed after the first trigger. ``` -------------------------------- ### Complex Nested Conditions Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/storage/condition.html Build complex filter logic by nesting 'OR' and 'AND' operations. This example demonstrates a mix of ORed conditions and a final ANDed condition. ```json "condition": { "OR": [ { "field1": "tapd" }, { "field2": [138, 156] }, { "field3": { "op": "LIKE", "val": "tapd%" }, "field4": { "op": ">", "val": "100" } } ], "field5": { "op": "!=", "val": 0 } } ``` -------------------------------- ### SDK Command Methods Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Methods for executing commands related to attachments and detail cards within TAPD business objects. ```APIDOC ### # SDK-调用command ### `.refreshAttachmentList()` Refreshes the attachment list on a TAPD business object detail page (requirements, tasks, defects). ### `.showObjDetailBottomCard()` Triggers the display of a mount point of type `app_for_obj_detail_bottom_card` on a TAPD business object detail page. ``` -------------------------------- ### Get Tapd Wikis Count Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/wiki/get_tapd_wikis_count.html Calculates and returns the number of wikis that match the specified query conditions. This endpoint supports filtering by various attributes and requires a project ID. ```APIDOC ## GET /tapd_wikis/count ### Description Calculates and returns the number of wikis that match the specified query conditions. Supports filtering by title, modifier, creator, note, view count, creation time, and modification time. ### Method GET ### Endpoint `https://api.tapd.cn/tapd_wikis/count` ### Parameters #### Query Parameters - **name** (string) - Optional - Title. Supports fuzzy matching. - **modifier** (string) - Optional - Modifier. - **creator** (string) - Optional - Creator. - **note** (string) - Optional - Note. - **view_count** (string) - Optional - View count. - **created** (datetime) - Optional - Creation time. Supports time range queries. - **modified** (datetime) - Optional - Last modification time. Supports time range queries. - **workspace_id** (integer) - Required - Project ID. ### Request Example ```bash curl -u 'api_user:api_password' 'https://api.tapd.cn/tapd_wikis/count?workspace_id=10104801' ``` ### Response #### Success Response (200) - **status** (integer) - Indicates the status of the operation. - **data** (object) - Contains the count of wikis. - **count** (integer) - The number of wikis matching the query. - **info** (string) - A message indicating the result of the operation. #### Response Example ```json { "status": 1, "data": { "count": 23 }, "info": "success" } ``` ``` -------------------------------- ### SDK-调用navigator Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Methods for navigating within the Tapd application and interacting with its navigation features. ```APIDOC ## .openAppIndex(url: string) ### Description Opens a new page within the Tapd SDK-embedded application. The URL provided is the route within the embedded application. ### Method `openAppIndex` ### Parameters - **url** (string) - Required - The route within the embedded application to open. ### Request Example ```javascript sdk.navigator.openAppIndex('/about') ``` ``` ```APIDOC ## .openObjectWindow(params: { entityType: string, entityId: string }) ### Description Opens the detail page of a Tapd business object. Currently supports requirements, tasks, and defects. ### Method `openObjectWindow` ### Parameters - **params** (object) - Required - An object containing the entity type and ID. - **entityType** (string) - Required - The type of the entity (e.g., 'story', 'task', 'defect'). - **entityId** (string) - Required - The ID of the entity. ### Request Example ```javascript sdk.navigator.openObjectWindow({entityType: 'story', entityId: '123'}) ``` ``` ```APIDOC ## .syncUrl(options: {url: string, refresh: bolean}) ### Description Updates the current browser's route, typically used to synchronize the embedded application's route with the browser's route. ### Method `syncUrl` ### Parameters - **options** (object) - Required - An object containing the URL and refresh flag. - **url** (string) - Required - The target route. - **refresh** (boolean) - Optional - Whether to refresh the page after updating the route. ### Request Example ```javascript sdk.navigator.syncUrl({url: 'exmaple.com', refresh: true}) ``` ``` ```APIDOC ## .updateTabCount({count: number, refresh: bolean}) ### Description Updates the numerical value displayed in a tab of an extension module. ### Method `updateTabCount` ### Parameters - **options** (object) - Required - An object containing the count and refresh flag. - **count** (number) - Required - The numerical value to update. - **refresh** (boolean) - Optional - Whether to refresh the route after updating (defaults to false). ### Request Example ```javascript sdk.navigator.updateTabCount({count: 100, refresh: false}) ``` ``` ```APIDOC ## .openObjectTab({tabName: string}) ### Description Switches to a specific tab within the detail page of a Tapd business object. Currently supports requirements, tasks, and defects detail pages. ### Method `openObjectTab` ### Parameters - **options** (object) - Required - An object containing the tab name. - **tabName** (string) - Required - The name of the tab to switch to. ### Request Example ```javascript sdk.navigator.openObjectTab({tabName: '变更历史'}) ``` ``` -------------------------------- ### Open New App Page Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Navigate to a new page within the SDK-embedded application by providing a URL. This is used for internal app navigation. ```javascript sdk.navigator.openAppIndex('/about') ``` -------------------------------- ### Show Confirmation Dialog Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Use the `confirm` method to display a confirmation dialog to the user. It returns a Promise that resolves when the user confirms. ```javascript sdk.ui.confirm('来个点赞3连?') .then(() => { alert('THX 😍') }) ``` -------------------------------- ### Get Related Member List for an Object Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk/index.html Fetch a list of members related to a specific object (bug, story, or task) within a workspace. Control inclusion of self and related story members. ```javascript sdk.request.getAllRelateMember({ workspace_id: '755', entity_type: 'bug', entity_id: '1000000755089798713', include_self: 1, include_relate_story_member: 0, include_sub_story_member: 0 }) .then((response) => { console.log(response) }) ``` -------------------------------- ### Convenient Usage Source: https://open.tapd.cn/document/api-doc/API%E6%96%87%E6%A1%A3/api_reference/storage/condition.html Provides a simplified way to configure common conditions like '=' and 'IN'. If the value is a constant, it constructs an '=' condition; if it's an array, it constructs an 'IN' condition. ```APIDOC ## Convenient Usage Provides a convenient configuration method for commonly used conditions `=` and `IN`. Key-value pairs are used in the condition object. If the value is a constant, an `=` condition is constructed. If the value is an array type, an `IN` condition is constructed. For example, the following condition is equivalent to `WHERE field1='tapd' AND field2 IN (138, 156)`. ```json { "condition": { "field1": "tapd", "field2": [138, 156] } } ``` ``` -------------------------------- ### Get Related Object Members Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Fetches members related to a specific object (story, bug, task) within a workspace. Allows inclusion of the user, related story members, and sub-story members. ```javascript sdk.request.getAllRelateMember({ workspace_id: '755', entity_type: 'bug', entity_id: '1000000755089798713', include_self: 1, include_relate_story_member: 0, include_sub_story_member: 0 }) .then((response) => { console.log(response) }) ``` -------------------------------- ### Workflow Condition Configuration Example Source: https://open.tapd.cn/document/plugin-doc/learning/yaml/modules/workflow.html Defines a custom condition object for workflow validation. This configuration specifies the condition's code, type, data handler, description, icon, name, and related objects. ```yaml conditions: - code: demo_condition2 type: progress data: handler: progress.data desc: 这是一个condition demo对象 icon: progress name: 插件condiiton Demo2 related: - story - bug - task ``` -------------------------------- ### SDK-获取context Source: https://open.tapd.cn/document/plugin-doc/learning/fe-jssdk Methods for retrieving context information about the current Tapd environment and user session. ```APIDOC ## .getEntranceData() => Promise ### Description Retrieves configuration information for the current page embedded in Tapd. ### Method `getEntranceData` ### Response #### Success Response (Promise) - Resolves with `entranceConfigs` object. - **appId** (string) - The application ID. - **code** (string) - The Tapd Token. - **entranceId** (string) - The mount point ID. ### Request Example ```javascript const entranceConfigs = await sdk.context.getEntranceData() // return {appId, entranceId, code} ``` ``` ```APIDOC ## .refreshCode() => Promise ### Description Refreshes the Tapd authorization code, typically used when the authorization code has expired. ### Method `refreshCode` ### Response #### Success Response (Promise) - Resolves with the new authorization code. ### Request Example ```javascript const newCode = await sdk.context.refreshCode() ``` ```