已合并
datashare配置共享新增可追加类型配置功能 #33014
datashare配置共享新增可追加类型配置功能 #33014
已合并
共 1 个文件变更+118-0
| @@ -1764,6 +1764,50 @@ declare namespace dataShare { | |||
| 1764 | * @since 23 static | 1764 | * @since 23 static |
| 1765 | */ | 1765 | */ |
| 1766 | allowList?: string[]; | 1766 | allowList?: string[]; |
| 1767 | + | ||
| 1768 | + /** | ||
| 1769 | + * Indicates whether the shared configuration is multi-value type. The default value is false, indicating that the | ||
| 1770 | + * shared configuration is not multi-value type. If the value is true, it indicates that the data being published is | ||
| 1771 | + * multi-value type, and the [value]{@link ProxyData#value} parameter will be ignored. | ||
| 1772 | + * Default value: false. | ||
| 1773 | + * | ||
| 1774 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 1775 | + * @stagemodelonly | ||
| 1776 | + * @since 26.0.0 dynamic&static | ||
| 1777 | + */ | ||
| 1778 | + isMultiValues?: boolean; | ||
| 1779 | + | ||
| 1780 | + /** | ||
| 1781 | + * Values of the multi-value type. The first parameter in the **Record** is the key specified by the user, which | ||
| 1782 | + * must be unique. The second parameter is the value corresponding to the key. A maximum of 10 values can be added | ||
| 1783 | + * to a single URI for an application. Each value can contain a maximum of 4096 bytes. At the same time, the total | ||
| 1784 | + * length of all values is limited by the [maxValueLength]{@link DataProxyConfig#maxValueLength} parameter value. | ||
| 1785 | + * This parameter is valid only when [isMultiValues]{@link ProxyData#isMultiValues} is set to true. | ||
| 1786 | + * | ||
| 1787 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 1788 | + * @stagemodelonly | ||
| 1789 | + * @since 26.0.0 dynamic&static | ||
| 1790 | + */ | ||
| 1791 | + values?: Record<int, ValueType>; | ||
| 1792 | + | ||
| 1793 | + /** | ||
| 1794 | + * List of applications that can add values to the shared configuration of multi-value type. The array can contain a | ||
| 1795 | + * maximum of 256 elements. Excess elements are invalid. | ||
| 1796 | + * Each element in the array is the | ||
| 1797 | + * [appIdentifier](docroot://quick-start/common-problem-of-application.md#what-is-appidentifier) of an application. | ||
| 1798 | + * The maximum length of an **appIdentifier** is 128 bytes. If the length exceeds 128 bytes, the **appIdentifier** | ||
| 1799 | + * does not take effect. If this parameter is not set when the shared configuration is published for the first time, | ||
| 1800 | + * the list is empty by default. If this parameter is not set when the shared configuration is updated, the | ||
| 1801 | + * list will not be updated. An empty list indicates that only the publisher can add values to the shared | ||
| 1802 | + * configuration. | ||
| 1803 | + * The array supports the special string "all" (case-sensitive), which indicates that all applications are allowed | ||
| 1804 | + * to add values to the shared configuration. | ||
| 1805 | + * | ||
| 1806 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 1807 | + * @stagemodelonly | ||
| 1808 | + * @since 26.0.0 dynamic&static | ||
| 1809 | + */ | ||
| 1810 | + trustProviders?: string[]; | ||
| 1767 | } | 1811 | } |
| 1768 | 1812 | ||
| 1769 | /** | 1813 | /** |
| @@ -1805,6 +1849,15 @@ declare namespace dataShare { | |||
| 1805 | * @since 23 static | 1849 | * @since 23 static |
| 1806 | */ | 1850 | */ |
| 1807 | value: ValueType; | 1851 | value: ValueType; |
| 1852 | + | ||
| 1853 | + /** | ||
| 1854 | + * Changed data of the multi-value type. If the changed data is not multi-value type, the **values** is undefined. | ||
| 1855 | + * | ||
| 1856 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 1857 | + * @stagemodelonly | ||
| 1858 | + * @since 26.0.0 dynamic&static | ||
| 1859 | + */ | ||
| 1860 | + values?: ValueType[]; | ||
| 1808 | } | 1861 | } |
| 1809 | 1862 | ||
| 1810 | /** | 1863 | /** |
| @@ -2213,6 +2266,71 @@ declare namespace dataShare { | |||
| 2213 | * @since 23 static | 2266 | * @since 23 static |
| 2214 | */ | 2267 | */ |
| 2215 | get(uris: string[], config: DataProxyConfig): Promise<DataProxyGetResult[]>; | 2268 | get(uris: string[], config: DataProxyConfig): Promise<DataProxyGetResult[]>; |
| 2269 | + | ||
| 2270 | + /** | ||
| 2271 | + * Puts a value into the published data. This operation can be performed only on multi-value type data. If the | ||
| 2272 | + * input **key** does not exist, a new value is added. If the input **key** already exists, the value corresponding | ||
| 2273 | + * to the key is updated. By default, a maximum of 10 values can be added to a single data record (that is, a URI) | ||
| 2274 | + * for a single application, and the maximum length of each value is 4096 bytes. In addition, the total length of | ||
| 2275 | + * all values in a single data record is limited by the value of the **maxValueLength** parameter that is specified | ||
| 2276 | + * during data publishing. Note that the **maxValueLength** parameter does not take effect in this API. This API | ||
| 2277 | + * uses a promise to return the result. | ||
| 2278 | + * | ||
| 2279 | + * @param { string } uri - Indicates the URI of the data to operate. | ||
| 2280 | + * @param { int } key - The key corresponding to the added value. It is unique for the same application. | ||
| 2281 | + * <br>The value range is all integers. | ||
| 2282 | + * @param { ValueType } value - The value to be put. | ||
| 2283 | + * @param { DataProxyConfig } config - Configuration of the data proxy operation. | ||
| 2284 | + * @returns { Promise<void> } Promise that returns no value. | ||
| 2285 | + * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is | ||
| 2286 | + * being restarted abnormally. | ||
| 2287 | + * @throws { BusinessError } 15700011 - The URI does not exist. | ||
| 2288 | + * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. | ||
| 2289 | + * @throws { BusinessError } 15700015 - No permission to access the data specified by the URI. | ||
| 2290 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 2291 | + * @stagemodelonly | ||
| 2292 | + * @since 26.0.0 dynamic&static | ||
| 2293 | + */ | ||
| 2294 | + putValue(uri: string, key: int, value: ValueType, config: DataProxyConfig): Promise<void>; | ||
| 2295 | + | ||
| 2296 | + /** | ||
| 2297 | + * Removes the value corresponding to the key. This operation can be performed only on multi-value type data. Only | ||
| 2298 | + * values added by this application can be removed. This API uses a promise to return the result. | ||
| 2299 | + * | ||
| 2300 | + * @param { string } uri - Indicates the URI of the data to operate. | ||
| 2301 | + * @param { int } key - The key corresponding to the added value. | ||
| 2302 | + * <br>The value range is all integers. | ||
| 2303 | + * @param { DataProxyConfig } config - Configuration of the data proxy operation. | ||
| 2304 | + * @returns { Promise<void> } Promise that returns no value. | ||
| 2305 | + * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is | ||
| 2306 | + * being restarted abnormally. | ||
| 2307 | + * @throws { BusinessError } 15700011 - The URI does not exist. | ||
| 2308 | + * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. | ||
| 2309 | + * @throws { BusinessError } 15700015 - No permission to access the data specified by the URI. | ||
| 2310 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 2311 | + * @stagemodelonly | ||
| 2312 | + * @since 26.0.0 dynamic&static | ||
| 2313 | + */ | ||
| 2314 | + removeValue(uri: string, key: int, config: DataProxyConfig): Promise<void>; | ||
| 2315 | + | ||
| 2316 | + /** | ||
| 2317 | + * Obtains all multi-value data under a specified URI. Only the publisher and the applications in the | ||
| 2318 | + * [allowList]{@link dataShare.ProxyData#allowList} can obtain the data. This API uses a promise to return the | ||
| 2319 | + * result. | ||
| 2320 | + * | ||
| 2321 | + * @param { string } uri - Indicates the URI of the data to operate. | ||
| 2322 | + * @param { DataProxyConfig } config - Configuration of the data proxy operation. | ||
| 2323 | + * @returns { Promise<ValueType[]> } Promise used to return an array of all values under the URI. | ||
| 2324 | + * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is | ||
| 2325 | + * being restarted abnormally. | ||
| 2326 | + * @throws { BusinessError } 15700011 - The URI does not exist. | ||
| 2327 | + * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. | ||
| 2328 | + * @throws { BusinessError } 15700015 - No permission to access the data specified by the URI. | ||
| 2329 | + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer | ||
| 2330 | + * @stagemodelonly | ||
| 2331 | + * @since 26.0.0 dynamic&static | ||
| 2332 | + */ | ||
| 2333 | + getValues(uri: string, config: DataProxyConfig): Promise<ValueType[]>; | ||
| 2216 | } | 2334 | } |
| 2217 | } | 2335 | } |
| 2218 | 2336 | ||