### Tasks
- [ ] Ability to copy a module instance to any page
- [ ] Ability to move a module instance to another page
Copy Module Instance
To copy a module instance to any page we will use the same endpoint as to create a module instance
Endpoint: /api/v1/moduleinstances/{sourceModuleInstanceId}/copy
Request Body:
{
"destinationContextId": "<PAGE_ID|MODUL_ID>",
"destinationContextType" : "<PAGE|MODULE>",
"name": "<Name>"
}
Response:
{
"responseMeta": {
"status": 200,
"success": true
},
"data": {
"moduleInstance": {
"id": "65f9165d720c6c752537eeb7",
"type": "JS_MODULE",
"sourceModuleId": "65f18785d333342605da2525",
"version": "0.0.13",
"name": "LoginUtil_1",
"contextType": "PAGE",
"contextId": "65f915ab720c6c752537ee81",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"inputs": {},
"jsonPathKeys": [],
"isValid": true,
"invalids": [],
"userPermissions": [
"manage:moduleInstances",
"delete:moduleInstances",
"read:moduleInstances",
"execute:moduleInstances"
]
},
"entities": {
"actions": [
{
"id": "65f9165d720c6c752537eeb8",
"name": "_$LoginUtil_1$_updateLoginModule",
"pageId": "65f915ab720c6c752537ee81",
"timeoutInMillisecond": 10000,
"confirmBeforeExecute": false,
"jsonPathKeys": [
" new Date() ",
" this.params.id "
],
"pluginId": "659541398543206d4fa4052f",
"isPublic": false,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"executeOnLoad": false
},
{
"id": "65f9165d720c6c752537eeb9",
"name": "_$LoginUtil_1$_findUserByEmail",
"pageId": "65f915ab720c6c752537ee81",
"timeoutInMillisecond": 10000,
"confirmBeforeExecute": false,
"jsonPathKeys": [
"this.params.email"
],
"pluginId": "659541398543206d4fa4052f",
"isPublic": false,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"executeOnLoad": false
}
],
"jsCollections": [
{
"id": "65f9165d720c6c752537eebc",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"name": "_$LoginUtil_1$_LoginUtil",
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"pluginId": "6595413b8543206d4fa40540",
"pluginType": "JS",
"actionIds": [],
"archivedActionIds": [],
"actions": [
{
"id": "65f9165d720c6c752537eebd",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "init",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.init",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "() => {\n const notFirstTime = appsmith.store.isFirstTime;\n if (!notFirstTime) {\n showModal('mdl_appInfo');\n } else {\n storeValue('notFirstTime', true);\n }\n}",
"selfReferencingDataPaths": [],
"jsArguments": []
},
"executeOnLoad": true,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"() => {\n const notFirstTime = appsmith.store.isFirstTime;\n if (!notFirstTime) {\n showModal('mdl_appInfo');\n } else {\n storeValue('notFirstTime', true);\n }\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.init",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
},
{
"id": "65f9165d720c6c752537eebe",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "clearStore",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.clearStore",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "() => {\n storeValue('notFirstTime', undefined);\n}",
"selfReferencingDataPaths": [],
"jsArguments": []
},
"executeOnLoad": false,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"() => {\n storeValue('notFirstTime', undefined);\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.clearStore",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
},
{
"id": "65f9165d720c6c752537eebf",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "signIn",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.signIn",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "async (email, password) => {\n const [user] = await _$LoginUtil_1$_findUserByEmail.run({\n email\n });\n console.log(user);\n if (user && password == \"123456\") {\n storeValue('token', \"token\").then(() => _$LoginUtil_1$_updateLoginModule.run({\n id: user.id\n })).then(() => navigateTo('View Applications'));\n } else {\n return showAlert('Invalid emaill/password combination', 'error');\n }\n}",
"selfReferencingDataPaths": [],
"jsArguments": [
{
"name": "email"
},
{
"name": "password"
}
]
},
"executeOnLoad": false,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"async (email, password) => {\n const [user] = await _$LoginUtil_1$_findUserByEmail.run({\n email\n });\n console.log(user);\n if (user && password == \"123456\") {\n storeValue('token', \"token\").then(() => _$LoginUtil_1$_updateLoginModule.run({\n id: user.id\n })).then(() => navigateTo('View Applications'));\n } else {\n return showAlert('Invalid emaill/password combination', 'error');\n }\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.signIn",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
}
],
"archivedActions": [],
"body": "export default {\n\tinit: () => { \n\t\tconst notFirstTime = appsmith.store.isFirstTime;\n\t\tif (!notFirstTime) {\n\t\t\tshowModal('mdl_appInfo')\n\t\t} else {\n\t\t\tstoreValue('notFirstTime', true);\n\t\t}\n\t},\n\tclearStore: () => {\n\t\t\tstoreValue('notFirstTime', undefined);\n },\n\tsignIn: async (email, password) => {\n\t\tconst [user] = await _$LoginUtil_1$_findUserByEmail.run({email});\n\t\tconsole.log(user);\n\t\tif (user && password == \"123456\") {\n\t\t\tstoreValue('token', \"token\")\n\t\t\t\t.then(() => _$LoginUtil_1$_updateLoginModule.run({\n\t\t\t\tid: user.id\n\t\t\t}))\n\t\t\t\t.then(() => navigateTo('View Applications'))\n\t\t} else {\n\t\t\treturn showAlert('Invalid emaill/password combination', 'error');\n\t\t}\n\t},\n}",
"variables": [],
"userPermissions": [
"read:actions",
"delete:actions",
"execute:actions",
"manage:actions"
],
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"isPublic": true,
"userExecutableName": "LoginUtil_1"
}
]
}
},
"errorDisplay": ""
}
Move Module Instance
Endpoint: POST /api/v1/moduleinstances/{sourceModuleInstanceId}/move
Request Body:
{
"destinationContextId": "<PAGE_ID|MODUL_ID>",
"destinationContextType" : "<PAGE|MODULE>",
"name": "<Name>"
}
Sample Response:
{
"responseMeta": {
"status": 200,
"success": true
},
"data": {
"moduleInstance": {
"id": "65f9165d720c6c752537eeb7",
"type": "JS_MODULE",
"sourceModuleId": "65f18785d333342605da2525",
"version": "0.0.13",
"name": "LoginUtil_1",
"contextType": "PAGE",
"contextId": "65f915ab720c6c752537ee81",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"inputs": {},
"jsonPathKeys": [],
"isValid": true,
"invalids": [],
"userPermissions": [
"manage:moduleInstances",
"delete:moduleInstances",
"read:moduleInstances",
"execute:moduleInstances"
]
},
"entities": {
"actions": [
{
"id": "65f9165d720c6c752537eeb8",
"name": "_$LoginUtil_1$_updateLoginModule",
"pageId": "65f915ab720c6c752537ee81",
"timeoutInMillisecond": 10000,
"confirmBeforeExecute": false,
"jsonPathKeys": [
" new Date() ",
" this.params.id "
],
"pluginId": "659541398543206d4fa4052f",
"isPublic": false,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"executeOnLoad": false
},
{
"id": "65f9165d720c6c752537eeb9",
"name": "_$LoginUtil_1$_findUserByEmail",
"pageId": "65f915ab720c6c752537ee81",
"timeoutInMillisecond": 10000,
"confirmBeforeExecute": false,
"jsonPathKeys": [
"this.params.email"
],
"pluginId": "659541398543206d4fa4052f",
"isPublic": false,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"executeOnLoad": false
}
],
"jsCollections": [
{
"id": "65f9165d720c6c752537eebc",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"name": "_$LoginUtil_1$_LoginUtil",
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"pluginId": "6595413b8543206d4fa40540",
"pluginType": "JS",
"actionIds": [],
"archivedActionIds": [],
"actions": [
{
"id": "65f9165d720c6c752537eebd",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "init",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.init",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "() => {\n const notFirstTime = appsmith.store.isFirstTime;\n if (!notFirstTime) {\n showModal('mdl_appInfo');\n } else {\n storeValue('notFirstTime', true);\n }\n}",
"selfReferencingDataPaths": [],
"jsArguments": []
},
"executeOnLoad": true,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"() => {\n const notFirstTime = appsmith.store.isFirstTime;\n if (!notFirstTime) {\n showModal('mdl_appInfo');\n } else {\n storeValue('notFirstTime', true);\n }\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.init",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
},
{
"id": "65f9165d720c6c752537eebe",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "clearStore",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.clearStore",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "() => {\n storeValue('notFirstTime', undefined);\n}",
"selfReferencingDataPaths": [],
"jsArguments": []
},
"executeOnLoad": false,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"() => {\n storeValue('notFirstTime', undefined);\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.clearStore",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
},
{
"id": "65f9165d720c6c752537eebf",
"applicationId": "65f9159b720c6c752537ee72",
"workspaceId": "65f14e8102e5a51303439249",
"pluginType": "JS",
"pluginId": "6595413b8543206d4fa40540",
"name": "signIn",
"fullyQualifiedName": "_$LoginUtil_1$_LoginUtil.signIn",
"datasource": {
"userPermissions": [],
"name": "UNUSED_DATASOURCE",
"pluginId": "6595413b8543206d4fa40540",
"workspaceId": "65f14e8102e5a51303439249",
"datasourceStorages": {},
"messages": [],
"isValid": true,
"new": true
},
"pageId": "65f915ab720c6c752537ee81",
"contextType": "PAGE",
"collectionId": "65f9165d720c6c752537eebc",
"actionConfiguration": {
"timeoutInMillisecond": 10000,
"paginationType": "NONE",
"encodeParamsToggle": true,
"body": "async (email, password) => {\n const [user] = await _$LoginUtil_1$_findUserByEmail.run({\n email\n });\n console.log(user);\n if (user && password == \"123456\") {\n storeValue('token', \"token\").then(() => _$LoginUtil_1$_updateLoginModule.run({\n id: user.id\n })).then(() => navigateTo('View Applications'));\n } else {\n return showAlert('Invalid emaill/password combination', 'error');\n }\n}",
"selfReferencingDataPaths": [],
"jsArguments": [
{
"name": "email"
},
{
"name": "password"
}
]
},
"executeOnLoad": false,
"dynamicBindingPathList": [
{
"key": "body"
}
],
"isValid": true,
"invalids": [],
"messages": [],
"jsonPathKeys": [
"async (email, password) => {\n const [user] = await _$LoginUtil_1$_findUserByEmail.run({\n email\n });\n console.log(user);\n if (user && password == \"123456\") {\n storeValue('token', \"token\").then(() => _$LoginUtil_1$_updateLoginModule.run({\n id: user.id\n })).then(() => navigateTo('View Applications'));\n } else {\n return showAlert('Invalid emaill/password combination', 'error');\n }\n}"
],
"confirmBeforeExecute": false,
"userPermissions": [],
"packageId": "65f14e8902e5a51303439250",
"isPublic": true,
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"validName": "_$LoginUtil_1$_LoginUtil.signIn",
"entityReferenceType": "JSACTION",
"selfReferencingDataPaths": []
}
],
"archivedActions": [],
"body": "export default {\n\tinit: () => { \n\t\tconst notFirstTime = appsmith.store.isFirstTime;\n\t\tif (!notFirstTime) {\n\t\t\tshowModal('mdl_appInfo')\n\t\t} else {\n\t\t\tstoreValue('notFirstTime', true);\n\t\t}\n\t},\n\tclearStore: () => {\n\t\t\tstoreValue('notFirstTime', undefined);\n },\n\tsignIn: async (email, password) => {\n\t\tconst [user] = await _$LoginUtil_1$_findUserByEmail.run({email});\n\t\tconsole.log(user);\n\t\tif (user && password == \"123456\") {\n\t\t\tstoreValue('token', \"token\")\n\t\t\t\t.then(() => _$LoginUtil_1$_updateLoginModule.run({\n\t\t\t\tid: user.id\n\t\t\t}))\n\t\t\t\t.then(() => navigateTo('View Applications'))\n\t\t} else {\n\t\t\treturn showAlert('Invalid emaill/password combination', 'error');\n\t\t}\n\t},\n}",
"variables": [],
"userPermissions": [
"read:actions",
"delete:actions",
"execute:actions",
"manage:actions"
],
"moduleInstanceId": "65f9165d720c6c752537eeb7",
"rootModuleInstanceId": "65f9165d720c6c752537eeb7",
"isPublic": true,
"userExecutableName": "LoginUtil_1"
}
]
}
},
"errorDisplay": ""
}
Copy Module Instance
To copy a module instance to any page we will use the same endpoint as to create a module instance
Endpoint:
/api/v1/moduleinstances/{sourceModuleInstanceId}/copyResponse:
Move Module Instance
Endpoint:
POST /api/v1/moduleinstances/{sourceModuleInstanceId}/moveRequest Body:
Sample Response: