1/* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit FormKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import formBindingData from './@ohos.app.form.formBindingData'; 23import formInfo from './@ohos.app.form.formInfo'; 24import Want from './@ohos.app.ability.Want'; 25 26/** 27 * Interface of formProvider. 28 * 29 * @namespace formProvider 30 * @syscap SystemCapability.Ability.Form 31 * @since 9 32 */ 33/** 34 * Interface of formProvider. 35 * 36 * @namespace formProvider 37 * @syscap SystemCapability.Ability.Form 38 * @atomicservice 39 * @since 11 40 */ 41declare namespace formProvider { 42 /** 43 * Set next update time for a specified form. 44 * 45 * @param { string } formId - Indicates the form ID. 46 * @param { number } minute - Indicates duration minute before next update. 47 * @param { AsyncCallback<void> } callback - The callback of setFormNextRefreshTime. 48 * @throws { BusinessError } 401 - Parameter error. Possible causes: 49 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 50 * @throws { BusinessError } 16500050 - An IPC connection error happened. 51 * @throws { BusinessError } 16500060 - A service connection error happened, please try again later. 52 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 53 * @throws { BusinessError } 16501000 - An internal functional error occurred. 54 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 55 * @throws { BusinessError } 16501002 - The number of forms exceeds upper bound. 56 * @throws { BusinessError } 16501003 - The form can not be operated by the current application. 57 * @syscap SystemCapability.Ability.Form 58 * @since 9 59 */ 60 /** 61 * Set next update time for a specified form. 62 * 63 * @param { string } formId - Indicates the form ID. 64 * @param { number } minute - Indicates duration minute before next update. 65 * @param { AsyncCallback<void> } callback - The callback of setFormNextRefreshTime. 66 * @throws { BusinessError } 401 - Parameter error. Possible causes: 67 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 68 * @throws { BusinessError } 16500050 - IPC connection error. 69 * @throws { BusinessError } 16500060 - Service connection error. 70 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 71 * @throws { BusinessError } 16501000 - An internal functional error occurred. 72 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 73 * @throws { BusinessError } 16501002 - The number of forms exceeds the maximum allowed. 74 * @throws { BusinessError } 16501003 - The form cannot be operated by the current application. 75 * @syscap SystemCapability.Ability.Form 76 * @atomicservice 77 * @since 11 78 */ 79 function setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void; 80 81 /** 82 * Set next update time for a specified form. 83 * 84 * @param { string } formId - Indicates the form ID. 85 * @param { number } minute - Indicates duration minute before next update. 86 * @returns { Promise<void> } The promise returned by the function. 87 * @throws { BusinessError } 401 - Parameter error. Possible causes: 88 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 89 * @throws { BusinessError } 16500050 - An IPC connection error happened. 90 * @throws { BusinessError } 16500060 - A service connection error happened, please try again later. 91 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 92 * @throws { BusinessError } 16501000 - An internal functional error occurred. 93 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 94 * @throws { BusinessError } 16501002 - The number of forms exceeds upper bound. 95 * @throws { BusinessError } 16501003 - The form can not be operated by the current application. 96 * @syscap SystemCapability.Ability.Form 97 * @since 9 98 */ 99 /** 100 * Set next update time for a specified form. 101 * 102 * @param { string } formId - Indicates the form ID. 103 * @param { number } minute - Indicates duration minute before next update. 104 * @returns { Promise<void> } The promise returned by the function. 105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 106 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 107 * @throws { BusinessError } 16500050 - IPC connection error. 108 * @throws { BusinessError } 16500060 - Service connection error. 109 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 110 * @throws { BusinessError } 16501000 - An internal functional error occurred. 111 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 112 * @throws { BusinessError } 16501002 - The number of forms exceeds the maximum allowed. 113 * @throws { BusinessError } 16501003 - The form cannot be operated by the current application. 114 * @syscap SystemCapability.Ability.Form 115 * @atomicservice 116 * @since 11 117 */ 118 function setFormNextRefreshTime(formId: string, minute: number): Promise<void>; 119 120 /** 121 * Update a specified form. 122 * Client to communication with FormManagerService. 123 * 124 * @param { string } formId - Indicates the form ID. 125 * @param { formBindingData.FormBindingData } formBindingData - Indicates the form data. 126 * @param { AsyncCallback<void> } callback - The callback of updateForm. 127 * @throws { BusinessError } 401 - Parameter error. Possible causes: 128 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 129 * @throws { BusinessError } 16500050 - An IPC connection error happened. 130 * @throws { BusinessError } 16500060 - A service connection error happened, please try again later. 131 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 132 * @throws { BusinessError } 16501000 - An internal functional error occurred. 133 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 134 * @throws { BusinessError } 16501003 - The form can not be operated by the current application. 135 * @syscap SystemCapability.Ability.Form 136 * @since 9 137 */ 138 /** 139 * Update a specified form. 140 * Client to communication with FormManagerService. 141 * 142 * @param { string } formId - Indicates the form ID. 143 * @param { formBindingData.FormBindingData } formBindingData - Indicates the form data. 144 * @param { AsyncCallback<void> } callback - The callback of updateForm. 145 * @throws { BusinessError } 401 - Parameter error. Possible causes: 146 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 147 * @throws { BusinessError } 16500050 - IPC connection error. 148 * @throws { BusinessError } 16500060 - Service connection error. 149 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 150 * @throws { BusinessError } 16501000 - An internal functional error occurred. 151 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 152 * @throws { BusinessError } 16501003 - The form cannot be operated by the current application. 153 * @syscap SystemCapability.Ability.Form 154 * @atomicservice 155 * @since 11 156 */ 157 function updateForm( 158 formId: string, 159 formBindingData: formBindingData.FormBindingData, 160 callback: AsyncCallback<void> 161 ): void; 162 163 /** 164 * Update a specified form. 165 * Client to communication with FormManagerService. 166 * 167 * @param { string } formId - Indicates the form ID. 168 * @param { formBindingData.FormBindingData } formBindingData - Indicates the form data. 169 * @returns { Promise<void> } The promise returned by the function. 170 * @throws { BusinessError } 401 - Parameter error. Possible causes: 171 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 172 * @throws { BusinessError } 16500050 - An IPC connection error happened. 173 * @throws { BusinessError } 16500060 - A service connection error happened, please try again later. 174 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 175 * @throws { BusinessError } 16501000 - An internal functional error occurred. 176 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 177 * @throws { BusinessError } 16501003 - The form can not be operated by the current application. 178 * @syscap SystemCapability.Ability.Form 179 * @since 9 180 */ 181 /** 182 * Update a specified form. 183 * Client to communication with FormManagerService. 184 * 185 * @param { string } formId - Indicates the form ID. 186 * @param { formBindingData.FormBindingData } formBindingData - Indicates the form data. 187 * @returns { Promise<void> } The promise returned by the function. 188 * @throws { BusinessError } 401 - Parameter error. Possible causes: 189 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 190 * @throws { BusinessError } 16500050 - IPC connection error. 191 * @throws { BusinessError } 16500060 - Service connection error. 192 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 193 * @throws { BusinessError } 16501000 - An internal functional error occurred. 194 * @throws { BusinessError } 16501001 - The ID of the form to be operated does not exist. 195 * @throws { BusinessError } 16501003 - The form cannot be operated by the current application. 196 * @syscap SystemCapability.Ability.Form 197 * @atomicservice 198 * @since 11 199 */ 200 function updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void>; 201 202 /** 203 * Get info of all forms belonging to current bundle. 204 * Client to communication with FormManagerService. 205 * 206 * @param { formInfo.FormInfoFilter } filter - Indicates the requirements the forms that the formInfos belong to have to meet. 207 * @param { AsyncCallback<Array<formInfo.FormInfo>> } callback - The callback is used to return the formInfo. 208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 209 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 210 * @throws { BusinessError } 16500050 - An IPC connection error happened. 211 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 212 * @throws { BusinessError } 16501000 - An internal functional error occurred. 213 * @syscap SystemCapability.Ability.Form 214 * @since 9 215 */ 216 /** 217 * Get info of all forms belonging to current bundle. 218 * Client to communication with FormManagerService. 219 * 220 * @param { formInfo.FormInfoFilter } filter - Indicates the requirements the forms that the formInfos belong to have to meet. 221 * @param { AsyncCallback<Array<formInfo.FormInfo>> } callback - The callback is used to return the formInfo. 222 * @throws { BusinessError } 401 - Parameter error. Possible causes: 223 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 224 * @throws { BusinessError } 16500050 - IPC connection error. 225 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 226 * @throws { BusinessError } 16501000 - An internal functional error occurred. 227 * @syscap SystemCapability.Ability.Form 228 * @atomicservice 229 * @since 11 230 */ 231 function getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 232 233 /** 234 * Get infos of all forms belonging to current bundle. 235 * Client to communication with FormManagerService. 236 * 237 * @param { AsyncCallback<Array<formInfo.FormInfo>> } callback - The callback is used to return the formInfo. 238 * @throws { BusinessError } 401 - Parameter error. Possible causes: 239 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 240 * @throws { BusinessError } 16500050 - An IPC connection error happened. 241 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 242 * @throws { BusinessError } 16501000 - An internal functional error occurred. 243 * @syscap SystemCapability.Ability.Form 244 * @since 9 245 */ 246 /** 247 * Get infos of all forms belonging to current bundle. 248 * Client to communication with FormManagerService. 249 * 250 * @param { AsyncCallback<Array<formInfo.FormInfo>> } callback - The callback is used to return the formInfo. 251 * @throws { BusinessError } 401 - Parameter error. Possible causes: 252 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 253 * @throws { BusinessError } 16500050 - IPC connection error. 254 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 255 * @throws { BusinessError } 16501000 - An internal functional error occurred. 256 * @syscap SystemCapability.Ability.Form 257 * @atomicservice 258 * @since 11 259 */ 260 function getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; 261 262 /** 263 * Get infos of all forms belonging to current bundle. 264 * Client to communication with FormManagerService. 265 * 266 * @param { formInfo.FormInfoFilter } [filter] - Indicates the requirements the forms that the formInfos belong to have to meet. 267 * @returns { Promise<Array<formInfo.FormInfo>> } Returns the formInfo. 268 * @throws { BusinessError } 401 - Parameter error. Possible causes: 269 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 270 * @throws { BusinessError } 16500050 - An IPC connection error happened. 271 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 272 * @throws { BusinessError } 16501000 - An internal functional error occurred. 273 * @syscap SystemCapability.Ability.Form 274 * @since 9 275 */ 276 /** 277 * Get infos of all forms belonging to current bundle. 278 * Client to communication with FormManagerService. 279 * 280 * @param { formInfo.FormInfoFilter } [filter] - Indicates the requirements the forms that the formInfos belong to have to meet. 281 * @returns { Promise<Array<formInfo.FormInfo>> } Returns the formInfo. 282 * @throws { BusinessError } 401 - Parameter error. Possible causes: 283 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 284 * @throws { BusinessError } 16500050 - IPC connection error. 285 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 286 * @throws { BusinessError } 16501000 - An internal functional error occurred. 287 * @syscap SystemCapability.Ability.Form 288 * @atomicservice 289 * @since 11 290 */ 291 function getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>>; 292 293 /** 294 * Request to publish a form to the form host. 295 * 296 * @param { Want } want - The want of the form to publish. 297 * @param { formBindingData.FormBindingData } formBindingData - Indicates the form data. 298 * @param { AsyncCallback<string> } callback - The callback is used to return the form id. 299 * @throws { BusinessError } 202 - The application is not a system application. 300 * @throws { BusinessError } 401 - Parameter error. Possible causes: 301 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 302 * @throws { BusinessError } 16500050 - IPC connection error. 303 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 304 * @throws { BusinessError } 16501000 - An internal functional error occurred. 305 * @syscap SystemCapability.Ability.Form 306 * @systemapi 307 * @since 9 308 */ 309 function requestPublishForm( 310 want: Want, 311 formBindingData: formBindingData.FormBindingData, 312 callback: AsyncCallback<string> 313 ): void; 314 315 /** 316 * Request to publish a form to the form host. 317 * 318 * @param { Want } want - The want of the form to publish. 319 * @param { AsyncCallback<string> } callback - The callback is used to return the form id. 320 * @throws { BusinessError } 202 - The application is not a system application. 321 * @throws { BusinessError } 401 - Parameter error. Possible causes: 322 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 323 * @throws { BusinessError } 16500050 - IPC connection error. 324 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 325 * @throws { BusinessError } 16501000 - An internal functional error occurred. 326 * @syscap SystemCapability.Ability.Form 327 * @systemapi 328 * @since 9 329 */ 330 function requestPublishForm(want: Want, callback: AsyncCallback<string>): void; 331 332 /** 333 * Request to publish a form to the form host. 334 * 335 * @param { Want } want - The want of the form to publish. 336 * @param { formBindingData.FormBindingData } [formBindingData] - Indicates the form data. 337 * @returns { Promise<string> } Returns the form id. 338 * @throws { BusinessError } 202 - The application is not a system application. 339 * @throws { BusinessError } 401 - Parameter error. Possible causes: 340 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 341 * @throws { BusinessError } 16500050 - IPC connection error. 342 * @throws { BusinessError } 16500100 - Failed to obtain the configuration information. 343 * @throws { BusinessError } 16501000 - An internal functional error occurred. 344 * @syscap SystemCapability.Ability.Form 345 * @systemapi 346 * @since 9 347 */ 348 function requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string>; 349 350 /** 351 * Check if the request of publishing a form is supported by the host 352 * 353 * @param { AsyncCallback<boolean> } callback - The callback is used to return true if the request is supported. 354 * @throws { BusinessError } 202 - The application is not a system application. 355 * @throws { BusinessError } 401 - Parameter error. Possible causes: 356 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 357 * @throws { BusinessError } 16500050 - IPC connection error. 358 * @throws { BusinessError } 16501000 - An internal functional error occurred. 359 * @syscap SystemCapability.Ability.Form 360 * @systemapi 361 * @since 9 362 */ 363 function isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void; 364 365 /** 366 * Check if the request of publishing a form is supported by the host 367 * 368 * @returns { Promise<boolean> } Returns true if the request is supported. 369 * @throws { BusinessError } 202 - The application is not a system application. 370 * @throws { BusinessError } 16500050 - IPC connection error. 371 * @throws { BusinessError } 16501000 - An internal functional error occurred. 372 * @syscap SystemCapability.Ability.Form 373 * @systemapi 374 * @since 9 375 */ 376 function isRequestPublishFormSupported(): Promise<boolean>; 377} 378export default formProvider; 379