Skip to main content
Version: v5.0

IafUserConfig

Use the IafUserConfig API to create and manage user configs and user config versions in the Item service.

create#

Creates user configurations when you pass an array of UserConfig objects.

ParameterRequiredTypeDescription
configsYesundefined
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage
userconfigsYesArray<UserConfig>Pass an array of UserConfig objects with the properties and values you want to define your user configurations
Returns

Array<UserConfig> - An array of the created UserConfig objects

Examples
const userConfigObjs = [  {    _name: "Project A setup user config",    _shortName: "prjASetup",    _userType: "projectA_setup_userconfig"  },  {    _name: "Project B setupe user config",    _shortName: "prjBSetup",    _userType: "projectB_setup_userconfig"  }];
const userConfigs = await IafUserConfig.create(userConfigObjs);

createVersion#

Creates a UserConfig version.

ParameterRequiredTypeDescription
idYesStringThe UserConfig's id.
versionYesUserConfigVersionDefine and pass a UserConfigVersion object with the properties and values to define the version you want to create.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

UserConfigVersion - The created UserConfigVersion object

Examples
const userConfig = {  scripts: {  customForm: 'iaf_custom_form'  },  handlers: {    testEngine: {      title: 'Test Engine',      icon: 'ion-social-usd',      pageComponent: 'TestEngine'    }  },  pages: {    page0: {      handler: 'testEngine'    }  },  settings: {    detailPath: '/detail'  }};
const configVersion = await IafUserConfig.createVersion(userConfig._id, {_userData: userConfig});

delete#

Deletes a UserConfig class object.

ParameterRequiredTypeDescription
userConfigYesUserConfigPass an entire UserConfig object or a JSON object with a user config "_id" property and value.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

String - 204 response {ok:204}

Examples
const result = await IafUserConfig.delete(userConfig);

deleteVersion#

Deletes a UserConfigVersion when you pass its id.

ParameterRequiredTypeDescription
idYesStringThe UserConfig's id.
versionIdYesStringThe UserConfig's version id.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

String - 204 response {ok:204}

Examples
const res = await IafUserConfig.deleteVersion(userConfig._id, userConfig._versions[0]._id);

getById#

Gets a UserConfig when you pass its id.

ParameterRequiredTypeDescription
idYesStringPass the UserConfig's id as a string.
ctxNoCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

UserConfig - The UserConfig object

Examples
const userConfigs = await IafUserConfig.getById(id);

getByName#

Gets UserConfigs that match a name you pass name.

ParameterRequiredTypeDescription
nameYesStringPass the "_name" value of the UserConfig you want to get.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

Array<UserConfig> - An array of UserConfig objects that match the name you pass.

Examples
const userConfigs = await IafUserConfig.getByName("your_config_name");

getUserConfigs#

Gets all UserConfigs or the UserConfigs that match a query you pass.

ParameterRequiredTypeDescription
criteriaYesNamedUserItemCriteriaTo set your filter criteria, pass a NamedUserItemCriteria object with your simple query.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsYesItemSvcOptionsTo make the action transactional, pass a ItemSvcOptions object with a "transactional" property and set its value to true.
Returns

Array<UserConfig> - An array of the UserConfigs that match your criteria

Examples
const criteria = {   _usertype: "project_setup",   _name: "projectSetup" };
const userConfigs = await IafUserConfig.getUserConfigs(criteria);

getUserConfigsWithPagination#

Gets all UserConfigs or the UserConfigs that match a query you pass with pagination.

ParameterRequiredTypeDescription
criteriaYesNamedUserItemCriteriaTo set your filter criteria, pass a NamedUserItemCriteria object with your query.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsYesItemSvcOptionsTo make the action transactional, pass a ItemSvcOptions object with a "transactional" property and set its value to true.
Returns

Page<Array<UserConfig>> - A Page object with an array of the UserConfigs that match your criteria.

Examples
const criteria = {   _usertype: "project_setup",   _name: "projectSetup" };
const userConfigs = await IafUserConfig.getUserConfigsWithPagination(criteria);

getVersionById#

Gets a UserConfigVersion when you pass its id.

ParameterRequiredTypeDescription
idYesStringThe UserConfig's id.
versionIdYesStringThe UserConfig's version id.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

UserConfigVersion - The UserConfigVersion object

Examples
const userVersion = await IafUserConfig.getVersionById(userConfig._id, userConfig._versions[0]._id);

getVersions#

Gets a UserConfig's versions.

ParameterRequiredTypeDescription
idYesStringPass the UserConfig's id.
criteriaYesNamedUserItemVersionCriteriaDefine and pass a NamedUserItemVersionCriteria object with your simple query.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
optionsYesJSONPass a JSON object with your response options as parameters, such as "_pageSize" and "_offset" with the values you want.
Returns

Array<UserConfigVersion> - An array of UserConfigVersion objects that match your criteria

Examples
const criteria = {  _userAttributes.fileId: file._id};
const configVersions = await IafUserConfig.getVersions(userConfig._id, criteria);

isValid#

Checks if a UserConfig object that the user enters in the browser as a string is a valid JSON object.

ParameterRequiredTypeDescription
contentYesStringPass your UserConfig's content.
Returns

(String | Boolean) - If the UserConfig object that the user enters in the browser as a string is valid, the string returns. If the string object is not valid, a Boolean value of false returns.

update#

Creates an updated version of a UserConfig object. After you create the updated user config version object, to update the actual user configuration content, use the updateUserConfigVersion method.

ParameterRequiredTypeDescription
userConfigYesUserConfigPass the UserConfig object you want to update.
ctxYesctxContext, such as authorization token requirements, namespaces, or session storage.
Returns

UserConfig - An updated version of the UserConfig object

Examples
userConfig._userType = "project_setup_userconfig_updated";
const updatedUserconfig = await IafUserConfig.update(project, userConfig, ctx);

updateVersion#

Updates a specific UserConfigVersion. Use this method to update user config content.

ParameterRequiredTypeDescription
idYesStringPass the UserConfig's id.
versionYesUserConfigVersionPass a UserConfigVersion object with the properties and values you want to update.
ctxYesCtxContext, such as authorization token requirements, namespaces, or session storage.
Returns

UserConfigVersion - The updated UserConfigVersion object

Examples
const userConfig = {  scripts: {    customForm: 'iaf_custom_form'  },  handlers: {    testEngine: {      title: 'Test Engine',      icon: 'ion-social-usd',      pageComponent: 'TestEngine'    },  pages: {    page0: {      handler: 'testEngine'    }  },  settings: {    detailPath: '/detail'  }};
const updatedUserConfig = await IafUserConfig.updateVersion(userConfig._id, {_userData: userConfig});