diff --git a/backend/files/misc/ide/macros/README.md b/backend/files/misc/ide/macros/README.md deleted file mode 100644 index dc6b1e02a2..0000000000 --- a/backend/files/misc/ide/macros/README.md +++ /dev/null @@ -1,6 +0,0 @@ - -# Macros for Hyper IDE - -This folder contains all Hyperlambda macros for Hyper IDE. A macro is a Hyperlambda snippet that -typically creates code, endpoints, and/or folders for you. You can parametrise a macro dynamically, -changing how it behaves, resulting in changing its generated code. diff --git a/backend/files/misc/ide/macros/document-endpoints.hl b/backend/files/misc/ide/macros/document-endpoints.hl deleted file mode 100644 index a20c734687..0000000000 --- a/backend/files/misc/ide/macros/document-endpoints.hl +++ /dev/null @@ -1,210 +0,0 @@ - -// Macro for Hyper IDE that creates documentation for a module's endpoints. -.name:Documents all endpoints in module -.description:"Macro for Hyper IDE that creates Markdown documentation for a module's endpoints, and stores the documentation in an ENDPOINTS.md file at root of the module's folder." -.arguments - . - name:module - type:string - description:"Name of module to create a 'download file endpoint' for" - mandatory:bool:true - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - // Making sure that module does not already have a 'ENDPOINTS.md' file. - strings.concat - get-value:x:@.module-path - .:ENDPOINTS.md - if - io.file.exists:x:@strings.concat - .lambda - - // File already exists. - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' already has an 'ENDPOINTS.md' file and hence we cannot create another" - throw:x:- - public:bool:true - status:int:404 - - // Figuring out base URL to endpoints belonging to module. - .base-url - set-value:x:@.base-url - strings.concat - .:magic - get-value:x:@.module-path - - // Retrieving all endpoints and filtering out those not belonging to specified module. - endpoints.list - .endpoints - for-each:x:@endpoints.list/* - if - strings.starts-with:x:@.dp/#/*/path - get-value:x:@.base-url - .lambda - add:x:@.endpoints - get-nodes:x:@.dp/# - - // Now we have all endpoints belonging to module, and we can start creating documentation. - .documentation:"# Endpoints\r\n\r\nThis documentation was automatically generated by Magic by reading meta data from your endpoints, and automatically generating documentation for individual endpoints.\r\n" - for-each:x:@.endpoints/* - .description: - if - and - exists:x:@.dp/#/*/description - not - eq - get-value:x:@.dp/#/*/description - . - .lambda - set-value:x:@.description - strings.replace:x:@.dp/#/*/description - .:[ - .:\[ - set-value:x:@.description - strings.replace:x:@.description - .:] - .:\] - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:"\r\n" - .:"## " - get-value:x:@.dp/#/*/verb - .:" - " - get-value:x:@.dp/#/*/path - .:"\r\n\r\n" - get-value:x:@.description - .:"\r\n\r\n* __Type__ - " - get-value:x:@.dp/#/*/type - .:"\r\n* __Produces__ - " - get-value:x:@.dp/#/*/produces - if - exists:x:@.dp/#/*/consumes - .lambda - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:"\r\n* __Consumes__ - " - get-value:x:@.dp/#/*/consumes - if - exists:x:@.dp/#/*/auth - .lambda - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:"\r\n* __Authorisation__ -" - for-each:x:@.dp/#/*/auth/* - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:" `" - get-value:x:@.dp/# - .:` - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -" - if - exists:x:@.dp/#/*/input/* - .lambda - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -### Input -" - for-each:x:@.dp/#/*/input/* - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -" - .:* __ - get-value:x:@.dp/#/*/name - .:__ - ` - get-value:x:@.dp/#/*/type - .:` - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -" - if - exists:x:@.dp/#/*/output/* - .lambda - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -### Output -" - for-each:x:@.dp/#/*/output/* - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -" - .:* __ - get-value:x:@.dp/#/*/name - .:__ - if - and - exists:x:@.dp/#/*/type - not - eq - get-value:x:@.dp/#/*/type - . - .lambda - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:" - `" - get-value:x:@.dp/#/*/type - .:` - set-value:x:@.documentation - strings.concat - get-value:x:@.documentation - .:@" -" - - // Saving file as ENDPOINTS.md now that we have its entire content. - io.file.save:x:@strings.concat - get-value:x:@.documentation - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - strings.concat - .:folders-changed| - get-value:x:@strings.concat/@strings.concat diff --git a/backend/files/misc/ide/macros/download-file-endpoint.hl b/backend/files/misc/ide/macros/download-file-endpoint.hl deleted file mode 100644 index e673f9d4ab..0000000000 --- a/backend/files/misc/ide/macros/download-file-endpoint.hl +++ /dev/null @@ -1,126 +0,0 @@ - -// Macro for Hyper IDE that creates an upload image endpoint. -.name:Creates a download file endpoint -.description:"Macro for Hyper IDE that creates a 'download file' HTTP GET endpoint for you where the file is specified as an [file] query parameter. This macro goes hand in hand with the upload file macro, and becomes its 'get' equivalent." -.arguments - . - name:module - type:string - description:"Name of module to create a 'download file endpoint' for" - mandatory:bool:true - . - name:auth - type:string - description:Comma separated list of roles users must belong to in order to invoke endpoint. If empty, there are no authorisation requirements - mandatory:bool:false - . - name:name - type:string - description:Name of your endpoint that becomes the last parts of its URL - mandatory:bool:true - default:download-file - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - validators.mandatory:x:@.arguments/*/name - validators.regex:x:@.arguments/*/name - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - // Making sure that module does not already have a 'xxx.get.hl' file. - strings.concat - get-value:x:@.module-path - get-value:x:@.arguments/*/name - .:.get.hl - if - io.file.exists:x:@strings.concat - .lambda - - // File already exists. - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' already has a '" - get-value:x:@.arguments/*/name - .:".get.hl' file and hence we cannot create another" - throw:x:- - public:bool:true - status:int:404 - - // Copying main 'download-image.get.hl' template file from '/misc/idea/templates' folder. - io.file.copy:/misc/ide/templates/download-file.get.hl - get-value:x:@strings.concat - - /* - * Opening 'xxx.get.hl' file such that we can correctly decorate it - * according to arguments specified by caller. - */ - strings.concat - get-value:x:@.module-path - get-value:x:@.arguments/*/name - .:.get.hl - io.file.load:x:@strings.concat - hyper2lambda:x:@io.file.load - comments:true - - // Substituting parameters. - if - or - eq - get-value:x:@.arguments/*/auth - . - eq - get-value:x:@.arguments/*/auth - .: - not - exists:x:@.arguments/*/auth - .lambda - - // No [auth] specified. - remove-nodes:x:@hyper2lambda/**/=[[auth]] - else - - // Auth specified. - set-value:x:@hyper2lambda/**/=[[auth]] - get-value:x:@.arguments/*/auth - set-value:x:@hyper2lambda/**/=[[module]] - get-value:x:@.arguments/*/module - - // Then transforming file to Hyperlambda and saving it again. - lambda2hyper:x:@hyper2lambda/* - comments:true - io.file.save:x:@strings.concat - get-value:x:@lambda2hyper - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - strings.concat - .:folders-changed| - get-value:x:@.module-path diff --git a/backend/files/misc/ide/macros/download-image-endpoint.hl b/backend/files/misc/ide/macros/download-image-endpoint.hl deleted file mode 100644 index 958c36075e..0000000000 --- a/backend/files/misc/ide/macros/download-image-endpoint.hl +++ /dev/null @@ -1,126 +0,0 @@ - -// Macro for Hyper IDE that creates an upload image endpoint. -.name:Creates a download image endpoint -.description:"Macro for Hyper IDE that creates a 'download image' HTTP GET endpoint for you where the image is specified as an [image] query parameter. This macro goes hand in hand with the upload image macro, and becomes its 'get' equivalent." -.arguments - . - name:module - type:string - description:"Name of module to create a 'download image endpoint' for" - mandatory:bool:true - . - name:auth - type:string - description:Comma separated list of roles users must belong to in order to invoke endpoint. If empty, there are no authorisation requirements - mandatory:bool:false - . - name:name - type:string - description:Name of your endpoint that becomes the last parts of its URL - mandatory:bool:true - default:download-image - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - validators.mandatory:x:@.arguments/*/name - validators.regex:x:@.arguments/*/name - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - // Making sure that module does not already have a 'xxx.get.hl' file. - strings.concat - get-value:x:@.module-path - get-value:x:@.arguments/*/name - .:.get.hl - if - io.file.exists:x:@strings.concat - .lambda - - // File already exists. - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' already has a '" - get-value:x:@.arguments/*/name - .:".get.hl' file and hence we cannot create another" - throw:x:- - public:bool:true - status:int:404 - - // Copying main 'download-image.get.hl' template file from '/misc/idea/templates' folder. - io.file.copy:/misc/ide/templates/download-image.get.hl - get-value:x:@strings.concat - - /* - * Opening 'xxx.get.hl' file such that we can correctly decorate it - * according to arguments specified by caller. - */ - strings.concat - get-value:x:@.module-path - get-value:x:@.arguments/*/name - .:.get.hl - io.file.load:x:@strings.concat - hyper2lambda:x:@io.file.load - comments:true - - // Substituting parameters. - if - or - eq - get-value:x:@.arguments/*/auth - . - eq - get-value:x:@.arguments/*/auth - .: - not - exists:x:@.arguments/*/auth - .lambda - - // No [auth] specified. - remove-nodes:x:@hyper2lambda/**/=[[auth]] - else - - // Auth specified. - set-value:x:@hyper2lambda/**/=[[auth]] - get-value:x:@.arguments/*/auth - set-value:x:@hyper2lambda/**/=[[module]] - get-value:x:@.arguments/*/module - - // Then transforming file to Hyperlambda and saving it again. - lambda2hyper:x:@hyper2lambda/* - comments:true - io.file.save:x:@strings.concat - get-value:x:@lambda2hyper - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - strings.concat - .:folders-changed| - get-value:x:@strings.concat/@strings.concat diff --git a/backend/files/misc/ide/macros/ensure-database.hl b/backend/files/misc/ide/macros/ensure-database.hl deleted file mode 100644 index 8fb0a50832..0000000000 --- a/backend/files/misc/ide/macros/ensure-database.hl +++ /dev/null @@ -1,146 +0,0 @@ - -// Macro for Hyper IDE that creates a 'magic.startup' folder for you within your module that automatically creates your database if it does not exist from before. -.name:"Ensures your module's database exists" -.description:"Macro for Hyper IDE that creates a 'magic.startup' folder for you within your module's main folder that automatically creates your database if it does not exist from before. Notice, this macro requires that you supply at least one of a MySQL database create script or an MS SQL database create script, or preferably both if you can." -.arguments - . - name:module - type:string - description:"Name of module to create a 'magic.startup' folder for" - mandatory:bool:true - . - name:database - type:string - description:"The name of your application's database. Typically the same as your module's name" - mandatory:bool:true - . - name:mssql - type:multi_string - description:Microsoft SQL server create database SQL script. At least one of the MySQL, PostgreSQL or MS SQL create scripts needs to be supplied. - mandatory:bool:false - . - name:mysql - type:multi_string - description:MySQL create database SQL script. At least one of the MySQL, PostgreSQL or MS SQL create scripts needs to be supplied. - mandatory:bool:false - . - name:pgsql - type:multi_string - description:PostgreSQL create database SQL script. At least one of the MySQL, PostgreSQL or MS SQL create scripts needs to be supplied. - mandatory:bool:false - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - // Making sure that at least one of [mysql] or [mssql] arguments was given. - if - and - not - exists:x:@.arguments/*/mysql - not - exists:x:@.arguments/*/mssql - .lambda - - // Neither MS SQL nor MySQL was given, and hence there are no reasons to create 'magic.startup' folder. - throw:"You have to supply either [mysql] or [mssql] arguments, or both. There are no reasons to create a 'magic.startup' folder without at least one of these" - public:bool:true - status:int:404 - - // Copying main 'magic.startup' template folder from misc folder. - strings.concat - get-value:x:@.module-path - .:/magic.startup/ - io.folder.copy:/misc/ide/template-folders/magic.startup/ - get-value:x:@strings.concat - - /* - * Opening 'create-database.hl' file such that we can correctly decorate it - * according to arguments specified by caller. - * - * First loading file and transforming to lambda. - */ - strings.concat - get-value:x:@.module-path - .:/magic.startup/create-database.hl - io.file.load:x:@strings.concat - hyper2lambda:x:@io.file.load - comments:true - - // Adding module's name into file. - unwrap:x:+/*/* - add:x:@hyper2lambda/*/signal - . - module:x:@.arguments/*/module - database:x:@.arguments/*/module - - // Then transforming file to Hyperlambda and saving it again. - lambda2hyper:x:@hyper2lambda/* - comments:true - io.file.save:x:@strings.concat - get-value:x:@lambda2hyper - - /* - * Checking if caller supplied a [mssql] argument, and if so, creating the - * create MSSQL database file. - */ - if - exists:x:@.arguments/*/mssql - .lambda - - // Creating our 'module.mssql.sql' file. - strings.concat - get-value:x:@.module-path - .:/magic.startup/ - get-value:x:@.arguments/*/module - .:.mssql.sql - io.file.save:x:@strings.concat - get-value:x:@.arguments/*/mssql - - /* - * Checking if caller supplied a [mysql] argument, and if so, creating the - * create MYSQL database file. - */ - if - exists:x:@.arguments/*/mysql - .lambda - - // Creating our 'module.mysql.sql' file. - strings.concat - get-value:x:@.module-path - .:/magic.startup/ - get-value:x:@.arguments/*/module - .:.mysql.sql - io.file.save:x:@strings.concat - get-value:x:@.arguments/*/mysql - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - .:folders-changed diff --git a/backend/files/misc/ide/macros/ensure-etc-folder.hl b/backend/files/misc/ide/macros/ensure-etc-folder.hl deleted file mode 100644 index 5b0ba1be76..0000000000 --- a/backend/files/misc/ide/macros/ensure-etc-folder.hl +++ /dev/null @@ -1,88 +0,0 @@ - -// Macro for Hyper IDE that ensures that as module is installed, a folder inside of the '/etc/' folder will be created where the module can store its configuration files, images, and other types of dynamic files related to the module. -.name:Ensures your modules has an /etc/ dynamic files folder -.description:"Macro for Hyper IDE that ensures that as module is installed, a folder inside of the '/etc/' folder will be created where the module can store its configuration files, images, and other types of dynamic files related to the module. Notice, the image macros will by default store files inside of this folder, so if you execute the image upload/download macros, you should also probably execute this macro." -.arguments - . - name:module - type:string - description:"Name of module to create an '/etc/' folder for" - mandatory:bool:true - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - /* - * Making sure that module has a 'magic.startup' folder, and creating one - * if no such folder exists. - */ - strings.concat - get-value:x:@.module-path - .:/magic.startup/ - if - not - io.folder.exists:x:@strings.concat - .lambda - - // Creating the module's 'magic.startup' folder. - io.folder.create:x:@strings.concat - - /* - * Lambda object that will be persisted as 'ensure-etc-folder.hl' file inside of - * module's 'magic.startup' folder. - */ - set-value:x:./*/.file/*/.folder - strings.concat - .:/etc/ - .:x:@.arguments/*/module - .:/ - .file - .folder - if - not - io.folder.exists:x:@.folder - .lambda - io.folder.create:x:@.folder - - /* - * Transforming lambda to Hyperlambda and persisting - * as '/modules/xxx/magic.startup/ensure-etc-folder.hl' file. - */ - strings.concat - get-value:x:@.module-path - .:magic.startup/ - .:ensure-etc-folder.hl - io.file.save:x:@strings.concat - lambda2hyper:x:@.file/* - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - .:folders-changed diff --git a/backend/files/misc/ide/macros/upload-file-endpoint.hl b/backend/files/misc/ide/macros/upload-file-endpoint.hl deleted file mode 100644 index e075bdabcc..0000000000 --- a/backend/files/misc/ide/macros/upload-file-endpoint.hl +++ /dev/null @@ -1,122 +0,0 @@ - -// Macro for Hyper IDE that creates an upload file endpoint. -.name:Creates an upload file endpoint -.description:"Macro for Hyper IDE that creates an 'upload file' HTTP PUT endpoint for you that assumes the file is sent as multipart/form-data. This macros will by default persist the files uploaded in the '/etc/MODULE_NAME/' folder, so you might want to run the 'ensure etc folder' macro too." -.arguments - . - name:module - type:string - description:"Name of module to create an 'upload file endpoint' for" - mandatory:bool:true - . - name:auth - type:string - description:Comma separated list of roles users must belong to in order to invoke endpoint - mandatory:bool:true - . - name:name - type:string - description:Name of your endpoint that becomes the last parts of its URL - mandatory:bool:true - default:upload-file - -// Lambda object executed as macro is actually executed. -.lambda - - // Sanity checking invocation. - validators.mandatory:x:@.arguments/*/module - validators.regex:x:@.arguments/*/module - regex:^[a-zA-Z0-9_-]+$ - validators.mandatory:x:@.arguments/*/name - validators.regex:x:@.arguments/*/name - regex:^[a-zA-Z0-9_-]+$ - - // Figuring out module's complete path. - .module-path - set-value:x:@.module-path - strings.concat - .:/modules/ - get-value:x:@.arguments/*/module - .:/ - - // Making sure that module exists. - if - not - io.folder.exists:x:@.module-path - .lambda - - // No such module - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' does not exist" - throw:x:- - public:bool:true - status:int:404 - - // Making sure that module does not already have an 'xxx.put.hl' file. - strings.concat - get-value:x:@.module-path - get-value:x:@.arguments/*/name - .:.put.hl - if - io.file.exists:x:@strings.concat - .lambda - - // File already exists. - strings.concat - .:"The module called '" - get-value:x:@.arguments/*/module - .:"' already has a '" - get-value:x:@.arguments/*/name - .:".put.hl' file and hence we cannot create another" - throw:x:- - public:bool:true - status:int:404 - - // Copying main 'upload-file.put.hl' template file from 'misc/idea/templates' folder. - io.file.copy:/misc/ide/templates/upload-file.put.hl - get-value:x:@strings.concat - - /* - * Opening 'xxx.put.hl' file such that we can correctly decorate it - * according to arguments specified by caller. - */ - io.file.load:x:@strings.concat - hyper2lambda:x:@io.file.load - comments:true - - // Substituting parameters. - if - or - eq - get-value:x:@.arguments/*/auth - . - eq - get-value:x:@.arguments/*/auth - .: - not - exists:x:@.arguments/*/auth - .lambda - - // No [auth] specified. - remove-nodes:x:@hyper2lambda/**/=[[auth]] - else - - // Auth specified. - set-value:x:@hyper2lambda/**/=[[auth]] - get-value:x:@.arguments/*/auth - set-value:x:@hyper2lambda/**/=[[module]] - get-value:x:@.arguments/*/module - - // Then transforming file to Hyperlambda and saving it again. - lambda2hyper:x:@hyper2lambda/* - comments:true - io.file.save:x:@strings.concat - get-value:x:@lambda2hyper - - // Making sure we inform caller that he needs to refresh his folders. - set-value:x:@.lambda - strings.concat - .:folders-changed| - get-value:x:@strings.concat/@strings.concat diff --git a/backend/files/system/ide/execute-macro.post.hl b/backend/files/system/ide/execute-macro.post.hl deleted file mode 100644 index 4e753dea8a..0000000000 --- a/backend/files/system/ide/execute-macro.post.hl +++ /dev/null @@ -1,32 +0,0 @@ - -// Executes the specified [macro] file passing in the specified [args]. -.arguments - macro:string - args:* -.description:Executes the specified [macro] file passing in the specified [args] -.type:internal - -// Making sure user is authorised to access endpoint. -auth.ticket.verify:root - -// Sanity checking invocation. -validators.mandatory:x:@.arguments/*/macro - -// Loading macro Hyperlambda file and transforming to lambda. -io.file.load:x:@.arguments/*/macro -hyper2lambda:x:@io.file.load - -// Decorating macro's [.lambda] object. -add:x:+/*/* - get-nodes:x:@.arguments/*/args/* -insert-before:x:@hyper2lambda/*/.lambda/0 - . - .arguments - -// Executing macro. -eval:x:@hyper2lambda/*/.lambda - -// Returning success to caller. -unwrap:x:+/* -return - result:x:@hyper2lambda/*/.lambda diff --git a/backend/files/system/ide/macro.get.hl b/backend/files/system/ide/macro.get.hl deleted file mode 100644 index 13f0bf8b9a..0000000000 --- a/backend/files/system/ide/macro.get.hl +++ /dev/null @@ -1,25 +0,0 @@ - -// Returns macro definition to caller. -.arguments - macro:string -.description:Returns macro definition to caller -.type:internal - -// Making sure user is authorised to access endpoint. -auth.ticket.verify:root - -// Sanity checking invocation. -validators.mandatory:x:@.arguments/*/macro - -// Loading macro Hyperlambda file and transforming to lambda. -io.file.load:x:@.arguments/*/macro -hyper2lambda:x:@io.file.load -add:x:../*/return/*/arguments - get-nodes:x:@hyper2lambda/*/.arguments/* - -// Returning result to caller. -unwrap:x:+/* -return - name:x:@hyper2lambda/*/.name - description:x:@hyper2lambda/*/.description - arguments diff --git a/frontend/src/app/_general/components/shortkeys/shortkeys.component.ts b/frontend/src/app/_general/components/shortkeys/shortkeys.component.ts index 1c74188099..f29df454b2 100644 --- a/frontend/src/app/_general/components/shortkeys/shortkeys.component.ts +++ b/frontend/src/app/_general/components/shortkeys/shortkeys.component.ts @@ -158,10 +158,6 @@ const fullkeys: Keys[] = [ name: 'Delete Folder', key: 'Alt + X' }, - { - name: 'Execute macro', - key: 'Alt + O' - }, { name: 'New file', key: 'Alt + A' diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.html b/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.html deleted file mode 100644 index 3f61d0e4a2..0000000000 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.html +++ /dev/null @@ -1,69 +0,0 @@ -

{{data.name}}

- -
- -

{{data.description}}

- -
- - - - {{idx.name}} - | - - - - - - - {{idx.name}} - | - - - - -
- -
- -
- - - - - - - -
\ No newline at end of file diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.scss b/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.scss deleted file mode 100644 index 903483dd1b..0000000000 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.scss +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Thomas Hansen - For license inquiries you can contact thomas@ainiro.io. - */ - -.description { - color: rgb(128, 128, 128); - font-size: 1rem; - margin-top: 0.5rem; - margin-bottom: 2rem; - font-style: italic; -} - -.half-width { - width: calc(50% - 1rem); - float: left; - margin-right: 1rem; -} - -.fill-width { - width: calc(100% - 1rem); -} - -::ng-deep .custom-fields { - .mat-form-field-flex { - align-items: flex-start; - } -} diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.ts b/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.ts deleted file mode 100644 index 313a2bcf80..0000000000 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/execute-macro-dialog/execute-macro-dialog.component.ts +++ /dev/null @@ -1,60 +0,0 @@ - -/* - * Copyright (c) 2023 Thomas Hansen - For license inquiries you can contact thomas@ainiro.io. - */ - -// Angular and system imports. -import { Component, Inject } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { GeneralService } from 'src/app/_general/services/general.service'; -import { MacroDefinition } from '../../models/macro-definition.model'; - -/** - * Modal dialog allowing you to parametrise and execute a macro. - */ -@Component({ - selector: 'app-execute-macro-dialog', - templateUrl: './execute-macro-dialog.component.html', - styleUrls: ['./execute-macro-dialog.component.scss'] -}) -export class ExecuteMacroDialogComponent { - - /** - * Creates an instance of your component. - */ - constructor( - private generalService: GeneralService, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: MacroDefinition) { - - for (const idx of this.data.arguments) { - if (!idx.value && idx.default) { - idx.value = idx.default; - } - } - } - - differentMacro() { - - delete this.data.name; - this.dialogRef.close(this.data); - } - - execute() { - - if (!this.canExecute()) { - this.generalService.showFeedback('Please provide the necessary details.', 'errorMessage'); - return; - } - this.dialogRef.close(this.data); - } - - /* - * Private helper methods. - */ - - private canExecute() { - - return this.data.arguments.filter(x => x.mandatory && !x.value).length === 0; - } -} diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-editor/ide-editor.component.ts b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-editor/ide-editor.component.ts index adcec710bd..187e43d41d 100644 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-editor/ide-editor.component.ts +++ b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-editor/ide-editor.component.ts @@ -10,7 +10,6 @@ import { ConfirmationDialogComponent } from 'src/app/_general/components/confirm import { LoadSnippetDialogComponent } from 'src/app/_general/components/load-snippet-dialog/load-snippet-dialog.component'; import { ShortkeysComponent } from 'src/app/_general/components/shortkeys/shortkeys.component'; import { GeneralService } from 'src/app/_general/services/general.service'; -import { ExecuteMacroDialogComponent } from '../execute-macro-dialog/execute-macro-dialog.component'; import { PreviewFileDialogComponent } from '../preview-file-dialog/preview-file-dialog.component'; import { RenameFileDialogComponent, FileObjectName } from '../rename-file-dialog/rename-file-dialog.component'; import { RenameFolderDialogComponent } from '../rename-folder-dialog/rename-folder-dialog.component'; @@ -400,106 +399,6 @@ export class IdeEditorComponent implements OnInit, OnDestroy, OnChanges { } } - private selectMacro() { - - const dialogRef = this.dialog.open(SelectMacroDialogComponent, { - width: '550px', - data: { - name: '', - }, - }); - dialogRef.afterClosed().subscribe((result: Macro) => { - if (result) { - this.executeMacro(result.name); - } - }); - } - - private executeMacro(file: string) { - - this.generalService.showLoading(); - this.fileService.getMacroDefinition(file).subscribe({ - next: (result: MacroDefinition) => { - - this.generalService.hideLoading(); - - /* - * Filling out default values for anything we can intelligently figure - * out according to selected folder. - */ - const splits = this.activeFolder.split('/'); - if (splits.length === 4 && splits[1] === 'modules') { - const moduleArgs = result.arguments.filter(x => x.name === 'module' || x.name === 'database'); - if (moduleArgs.length > 0) { - for (const idx of moduleArgs) { - idx.value = splits[2]; - } - } - } - const authArgs = result.arguments.filter(x => x.name === 'auth'); - if (authArgs.length > 0) { - for (const idx of authArgs) { - idx.value = 'root'; - } - } - const dialogRef = this.dialog.open(ExecuteMacroDialogComponent, { - width: '500px', - data: result, - }); - dialogRef.afterClosed().subscribe((result: MacroDefinition) => { - if (result && result.name) { - const payload = {}; - for (const idx of result.arguments.filter(x => x.value)) { - payload[idx.name] = idx.value; - } - - this.generalService.showLoading(); - this.fileService.executeMacro(file, payload).subscribe({ - next: (exeResult: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback('Macro successfully executed', 'successMessage'); - if (exeResult.result === 'folders-changed') { - - this.dialog.open(ConfirmationDialogComponent, { - width: '500px', - data: { - title: `Refresh folders`, - description_extra: 'Macro execution changed your file system, do you want to refresh your files and folders?', - action_btn: 'Refresh', - action_btn_color: 'primary', - bold_description: true - } - }).afterClosed().subscribe((result: string) => { - if (result === 'confirm') { - this.getFilesFromServer.emit(); - } - }) - } else if (exeResult.result.startsWith('folders-changed|')) { - var fileObject = exeResult.result.split('|')[1]; - this.updateFileObject.emit(fileObject); - - } - }, - error: (error: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage'); - } - }); - } else if (result) { - this.selectMacro(); - } - }); - }, - error: (error: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage'); - } - }); - } - private watchForActions() { this.codemirrorActionSubscription = this.codemirrorActionsService.action.subscribe((action: string) => { @@ -534,10 +433,6 @@ export class IdeEditorComponent implements OnInit, OnDestroy, OnChanges { this.insertSnippet(); break; - case 'macro': - this.selectMacro(); - break; - case 'newFile': this.createNewFileObject('file'); break; diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.html b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.html index 9d74f11ad4..44a3519936 100644 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.html +++ b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.html @@ -69,15 +69,6 @@ drive_folder_upload - - diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.ts b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.ts index a8972b1b0e..9fa24fd917 100644 --- a/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.ts +++ b/frontend/src/app/_protected/pages/create/hyper-ide/components/ide-tree/ide-tree.component.ts @@ -9,7 +9,6 @@ import { MatDialog } from '@angular/material/dialog'; import { MatTreeFlattener, MatTreeFlatDataSource } from '@angular/material/tree'; import { ConfirmationDialogComponent } from 'src/app/_general/components/confirmation-dialog/confirmation-dialog.component'; import { GeneralService } from 'src/app/_general/services/general.service'; -import { ExecuteMacroDialogComponent } from '../execute-macro-dialog/execute-macro-dialog.component'; import { IncompatibleFileDialogComponent } from '../incompatible-file-dialog/incompatible-file-dialog.component'; import { NewFileFolderDialogComponent } from '../new-file-folder-dialog/new-file-folder-dialog.component'; import { Macro, SelectMacroDialogComponent } from '../select-macro-dialog/select-macro-dialog.component'; @@ -218,23 +217,6 @@ export class IdeTreeComponent implements OnInit { }); } - /** - * Invoked when user wants to execute a macro. - */ - selectMacro() { - const dialogRef = this.dialog.open(SelectMacroDialogComponent, { - width: '550px', - data: { - name: '', - }, - }); - dialogRef.afterClosed().subscribe((result: Macro) => { - if (result) { - this.executeMacro(result.name); - } - }); - } - /** * Invoked when user wants to open a file for editing. */ @@ -946,91 +928,6 @@ export class IdeTreeComponent implements OnInit { return null; } - private executeMacro(file: string) { - - this.generalService.showLoading(); - this.fileService.getMacroDefinition(file).subscribe({ - next: (result: MacroDefinition) => { - - this.generalService.hideLoading(); - - /* - * Filling out default values for anything we can intelligently figure - * out according to selected folder. - */ - const splits = this.activeFolder.split('/'); - if (splits.length === 4 && splits[1] === 'modules') { - const moduleArgs = result.arguments.filter(x => x.name === 'module' || x.name === 'database'); - if (moduleArgs.length > 0) { - for (const idx of moduleArgs) { - idx.value = splits[2]; - } - } - } - const authArgs = result.arguments.filter(x => x.name === 'auth'); - if (authArgs.length > 0) { - for (const idx of authArgs) { - idx.value = 'root'; - } - } - const dialogRef = this.dialog.open(ExecuteMacroDialogComponent, { - width: '500px', - data: result, - }); - dialogRef.afterClosed().subscribe((result: MacroDefinition) => { - - if (result && result.name) { - const payload = {}; - for (const idx of result.arguments.filter(x => x.value)) { - payload[idx.name] = idx.value; - } - - this.generalService.showLoading(); - this.fileService.executeMacro(file, payload).subscribe({ - next: (exeResult: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback('Macro successfully executed', 'successMessage'); - if (exeResult.result === 'folders-changed') { - - this.dialog.open(ConfirmationDialogComponent, { - width: '500px', - data: { - title: `Refresh folders`, - description_extra: 'Macro execution changed your file system, do you want to refresh your files and folders?', - action_btn: 'Refresh', - action_btn_color: 'primary', - bold_description: true - } - }).afterClosed().subscribe((result: string) => { - if (result === 'confirm') { - this.getFilesFromServer().then(); - } - }) - } else if (exeResult.result.startsWith('folders-changed|')) { - var fileObject = exeResult.result.split('|')[1]; - this.updateFileObject(fileObject); - } - }, - error: (error: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage'); - } - }); - } else if (result) { - this.selectMacro(); - } - }); - }, - error: (error: any) => { - - this.generalService.hideLoading(); - this.generalService.showFeedback(error?.error?.message ?? error, 'errorMessage'); - } - }); - } - private nameValidation(name: string) { if (!name || name.length === 0) { diff --git a/frontend/src/app/_protected/pages/create/hyper-ide/module/ide.module.ts b/frontend/src/app/_protected/pages/create/hyper-ide/module/ide.module.ts index 6a96e98d9e..6a9dd84e10 100644 --- a/frontend/src/app/_protected/pages/create/hyper-ide/module/ide.module.ts +++ b/frontend/src/app/_protected/pages/create/hyper-ide/module/ide.module.ts @@ -12,7 +12,6 @@ import { IdeEditorComponent } from '../components/ide-editor/ide-editor.componen import { IdeSearchboxComponent } from '../components/ide-searchbox/ide-searchbox.component'; import { IdeTreeComponent } from '../components/ide-tree/ide-tree.component'; import { IdeRoutingModule } from './ide.routing.module'; -import { ExecuteMacroDialogComponent } from '../components/execute-macro-dialog/execute-macro-dialog.component'; import { IncompatibleFileDialogComponent } from '../components/incompatible-file-dialog/incompatible-file-dialog.component'; import { NewFileFolderDialogComponent } from '../components/new-file-folder-dialog/new-file-folder-dialog.component'; import { RenameFileDialogComponent } from '../components/rename-file-dialog/rename-file-dialog.component'; @@ -28,7 +27,6 @@ import { ExecuteResult } from '../components/execute-result/execute-result-dialo IdeTreeComponent, IdeEditorComponent, IdeSearchboxComponent, - ExecuteMacroDialogComponent, ExecuteResult, IncompatibleFileDialogComponent, NewFileFolderDialogComponent,