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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| configs | Yes | undefined | |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage |
| userconfigs | Yes | Array<UserConfig> | Pass an array of UserConfig objects with the properties and values you want to define your user configurations |
Array<UserConfig> - An array of the created UserConfig objects
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The UserConfig's id. |
| version | Yes | UserConfigVersion | Define and pass a UserConfigVersion object with the properties and values to define the version you want to create. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
UserConfigVersion - The created UserConfigVersion object
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userConfig | Yes | UserConfig | Pass an entire UserConfig object or a JSON object with a user config "_id" property and value. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
String - 204 response {ok:204}
const result = await IafUserConfig.delete(userConfig);deleteVersion#
Deletes a UserConfigVersion when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The UserConfig's id. |
| versionId | Yes | String | The UserConfig's version id. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
String - 204 response {ok:204}
const res = await IafUserConfig.deleteVersion(userConfig._id, userConfig._versions[0]._id);getById#
Gets a UserConfig when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserConfig's id as a string. |
| ctx | No | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
UserConfig - The UserConfig object
const userConfigs = await IafUserConfig.getById(id);getByName#
Gets UserConfigs that match a name you pass name.
| Parameter | Required | Type | Description |
|---|---|---|---|
| name | Yes | String | Pass the "_name" value of the UserConfig you want to get. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
Array<UserConfig> - An array of UserConfig objects that match the name you pass.
const userConfigs = await IafUserConfig.getByName("your_config_name");getUserConfigs#
Gets all UserConfigs or the UserConfigs that match a query you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | NamedUserItemCriteria | To set your filter criteria, pass a NamedUserItemCriteria object with your simple query. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | Yes | ItemSvcOptions | To make the action transactional, pass a ItemSvcOptions object with a "transactional" property and set its value to true. |
Array<UserConfig> - An array of the UserConfigs that match your criteria
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | Yes | NamedUserItemCriteria | To set your filter criteria, pass a NamedUserItemCriteria object with your query. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | Yes | ItemSvcOptions | To make the action transactional, pass a ItemSvcOptions object with a "transactional" property and set its value to true. |
Page<Array<UserConfig>> - A Page object with an array of the UserConfigs that match your criteria.
const criteria = { _usertype: "project_setup", _name: "projectSetup" };
const userConfigs = await IafUserConfig.getUserConfigsWithPagination(criteria);getVersionById#
Gets a UserConfigVersion when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | The UserConfig's id. |
| versionId | Yes | String | The UserConfig's version id. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
UserConfigVersion - The UserConfigVersion object
const userVersion = await IafUserConfig.getVersionById(userConfig._id, userConfig._versions[0]._id);getVersions#
Gets a UserConfig's versions.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserConfig's id. |
| criteria | Yes | NamedUserItemVersionCriteria | Define and pass a NamedUserItemVersionCriteria object with your simple query. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
| options | Yes | JSON | Pass a JSON object with your response options as parameters, such as "_pageSize" and "_offset" with the values you want. |
Array<UserConfigVersion> - An array of UserConfigVersion objects that match your criteria
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| content | Yes | String | Pass your UserConfig's content. |
(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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| userConfig | Yes | UserConfig | Pass the UserConfig object you want to update. |
| ctx | Yes | ctx | Context, such as authorization token requirements, namespaces, or session storage. |
UserConfig - An updated version of the UserConfig object
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the UserConfig's id. |
| version | Yes | UserConfigVersion | Pass a UserConfigVersion object with the properties and values you want to update. |
| ctx | Yes | Ctx | Context, such as authorization token requirements, namespaces, or session storage. |
UserConfigVersion - The updated UserConfigVersion object
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});