import { GraphqlClient } from './../common/GraphqlClient'; import { ManagementTokenProvider } from './ManagementTokenProvider'; import { ManagementClientOptions } from './types'; import { CommonMessage, UdfDataType, UdfTargetType, UserDefinedField, UserDefinedData } from '../../types/graphql.v2'; /** * @name UdfManagementClient * @description Udf is short for User Defined Field. Approw data entities (such as users, roles, groups, organizations, etc.) can add custom fields. You can configure fields that appow does not come with by default. For example, if you need to create a school-related application, you can add a custom field. \`school\` field. * At the same time, you can ask the user to supplement the information of this field after the user registration is completed. For detailed documentation, please see https://docs.approw.co/extensibility/user/extend-register-fields.html. * * This module can be used to manage custom field metadata. * * @example * * Please use the module in the following ways: * \`\`\`javascript * import { ManagementClient } from "appow-js-sdk" * const managementClient = new ManagementClient({ * userPoolId: "YOUR_USERPOOL_ID", * secret: "YOUR_USERPOOL_SECRET", * }) * managementClient.udf.list // Get a list of custom field metadata * managementClient.udf.set // Set custom fields * managementClient.udf.remove // Delete custom fields * \`\`\` * * @class UdfManagementClient Manage custom field metadata */ export declare class UdfManagementClient { options: ManagementClientOptions; graphqlClient: GraphqlClient; tokenProvider: ManagementTokenProvider; constructor(options: ManagementClientOptions, graphqlClient: GraphqlClient, tokenProvider: ManagementTokenProvider); /** * @name set * @name_zh Set custom field metadata * @description Set the custom field metadata, if the field does not exist, it will be created automatically. * * @param {UdfTargetType} targetType Custom field target type, USER means user and ROLE means role. * @param {string} key field key * @param {UdfDataType} dataType Data types, currently supports a total of five data types. STRING is a character string, NUMBER is a number, DATETIME is a date, BOOLEAN is a boolean value, and OBJECT is an object. * @param {string} label The field Label is generally a Human Readable string. * * @example * * import { ManagementClient, UdfTargetType, UdfDataType } from "appow-js-sdk" * const udf = await managementClient.udf.set( * UdfTargetType.User, * 'school', * UdfDataType.String, * 'school' * ); * * @example * * // If the custom field age does not exist, it will be created for the first time * * import { ManagementClient, UdfTargetType, UdfDataType } from "appow-js-sdk" * const udf = await managementClient.udf.set( * UdfTargetType.User, * 'age', * UdfDataType.Number, * 'age' * ); * * // If the age field has been created before, the configuration of the field will be modified * * const udf = await managementClient.udf.set( * UdfTargetType.User, * 'age', * UdfDataType.Number, * 'new description' * ); * * @returns {Promise} * @memberof UdfManagementClient */ set(targetType: UdfTargetType, key: string, dataType: UdfDataType, label: string): Promise; /** * @name remove * @name_zh Delete custom field * @description Delete custom field * * @param {UdfTargetType} targetType Custom field target type, USER means user and ROLE means role. * @param {string} key field key * * @example * * await managementClient.udf.remove(UdfTargetType.User, 'school'); * * @returns {Promise} * @memberof UdfManagementClient */ remove(targetType: UdfTargetType, key: string): Promise; /** * @name list * @name_zh Get custom field definition * @description Query the custom field defined by the user pool * * @param {UdfTargetType} targetType Custom field target type, USER means user and ROLE means role. * @example * * const list = await managementClient.udf.list(UdfTargetType.User); * * @returns {Promise} * @memberof UdfManagementClient */ list(targetType: UdfTargetType): Promise; /** * @name listUdv * @name_zh Get a list of custom field data for an entity * @description Get a list of custom field data for an entity * * * @param {UdfTargetType} targetType Custom field target type, USER means user and ROLE means role. * @param {string} targetId Custom field target id, such as user ID * @example * * udfManagementClient.listUdv('USER', 'userId') * * @returns {Promise>} * @memberof UdfManagementClient */ listUdv(targetType: UdfTargetType, targetId: string): Promise>; /** * @name setUdvBatch * @name_zh Add custom data in bulk * @description Add custom data in bulk * * @param {UdfTargetType} targetType Custom field target type, USER means user and ROLE means role. * @param {string} targetId Custom field target id, such as user ID * @param {Object[]} [udvList] * @param {boolean} [udvList.key] The key of the custom field * @param {string} [udvList.value] Custom field value * * @example * * udfManagementClient.setUdv('USER', 'userId', [{key: 'school', 'value': 'Tsinghua University'}]) * * @returns {Promise>} * @memberof UdfManagementClient */ setUdvBatch(targetType: UdfTargetType, targetId: string, udvList: { key: string; value: any; }[]): Promise>; }