This commit consolidates scripts and categories under a unified 'Executable' concept. This simplifies the architecture and improves code readability. - Introduce subfolders within `src/domain` to segregate domain elements. - Update class and interface names by removing the 'I' prefix in alignment with new coding standards. - Replace 'Node' with 'Executable' to clarify usage; reserve 'Node' exclusively for the UI's tree component.
8.2 KiB
8.2 KiB
Collection files
privacy.sexy is a data-driven application that reads YAML files.
This document details the structure and syntax of the YAML files located in application/collections, which form the backbone of the application's data model.
Related documentation:
- 📖
collection.yaml.d.tsoutlines code types. - 📖 Script Guidelines provide guidance on script creation including best-practices.
Objects
Collection
- Defines categories, scripts, and OS-specific details in a tree structure.
- Allows defining common functions for code reuse.
Collection syntax
os:string(required)- Operating system for the collection.
- 📖 See
OperatingSystem.tsfor possible values.
actions: [Category, ... ](required)- Renders each parent category as cards in the user interface.
- ❗ A Collection must consist of at least one category.
functions: [Function, ... ]- Optional for code reuse.
scripting:ScriptingDefinition(required)- Sets the scripting language for all inline code used within the collection.
Executables
An Executable is a logical entity that can
- execute once compiled,
- include a
docsproperty for documentation.
It's either Category or a Script.
Category
Represents a logical group of scripts and subcategories.
Category syntax
category:string(required)- Name of the category.
- ❗ Must be unique throughout the collection.
children: [Category|Script, ... ](required)- ❗ Category must consist of at least one subcategory or script.
- Children can be combination of scripts and subcategories.
docs:string|[string, ... ]- Markdown-formatted documentation related to the category.
Script
Represents an individual tweak.
Types (like functions):
- Inline script:
- Direct code.
- ❗ Requires
codeand optionalrevertCode.
- Caller script:
- Calls other functions.
- ❗ Requires
call, but notcodeorrevertCode.
📖 For detailed guidelines, see Script Guidelines.
Script syntax
name:string(required)- Script name.
- ❗ Must be unique throughout the Collection.
code:string(conditionally required)- Code to execute when the user selects the script.
- 💡 If defined, it's best practice to also define
revertCode. - ❗ Cannot co-exist with
call, define eithercodewith optionalrevertCodeorcall.
revertCode:string- Reverts changes made by
code. - ❗ Cannot co-exist with
call, definerevertCodewithcodeorcall.
- Reverts changes made by
call:FunctionCall|[FunctionCall, ... ](conditionally required)- A shared function or sequence of functions to call (called in order).
- ❗ Cannot co-exist with
codeorrevertCode, definecodewith optionalrevertCodeorcall.
docs:string|[string, ... ]- Markdown-formatted documentation related to the script.
recommend:"standard"|"strict"|undefined(default:undefined)- Sets recommendation level.
- Application will not recommend the script if
undefined.
📖 For detailed guidelines, see Script Guidelines.
FunctionCall
Specifies a function call. It may require providing argument values to its parameters.
FunctionCall syntax
function:string(required)- Name of the function to call.
- ❗ Function with same name must defined in
functionsproperty of Collection.
parameters:[parameterName: parameterValue, ... ]- Key-value pairs representing function parameters and their corresponding argument values.
- 📖 See parameter substitution for an example usage.
- 💡 You can use expressions (templating) when providing argument values for parameters.
Function
- Enables reusable code in scripts.
- Functions are templates compiled by privacy.sexy and uses special expression expressions.
- A function can be of two different types (like scripts):
- Inline function: a function with an inline code.
- ❗ Requires
codeand optionallyrevertCode, but notcall.
- ❗ Requires
- Caller function: a function that calls other functions.
- ❗ Requires
call, but notcodeorrevertCode.
- ❗ Requires
- Inline function: a function with an inline code.
- 📖 Read about function expressions in Templating with example usages.
Function syntax
name:string(required)- Name of the function that scripts will use.
- ❗ Function names must be unique.
- ❗ Function names must follow camelCase and start with verbs (e.g.,
uninstallStoreApp).
parameters:[FunctionParameter, ... ](conditionally required)- Lists parameters used.
- ❗ Required to be able use in
FunctionCallor expressions (templating).
code:string(conditionally required)- Code to execute when the user selects the script.
- 💡 You can use expressions (templating) in its value.
- 💡 If defined, it's best practice to also define
revertCode. - ❗ Cannot co-exist with
call, define eithercodewith optionalrevertCodeorcall.
revertCode:string- Reverts changes made by
code. - 💡 You can use expressions (templating) in its value.
- ❗ Cannot co-exist with
call, definerevertCodewithcodeorcall.
- Reverts changes made by
call:FunctionCall|[FunctionCall, ... ](conditionally required)- A shared function or sequence of functions to call (called in order).
- 💡 You can use expressions (templating) in argument values provided for parameters.
- ❗ Cannot co-exist with
codeorrevertCode, definecodewith optionalrevertCodeorcall.
FunctionParameter
- Defines a single parameter that may require an argument value optionally or mandatory.
- A
FunctionCallprovides argument values by a caller.
FunctionParameter syntax
name:string(required)- Name of the parameter that the function has.
- ❗ Required for expressions (templating).
- ❗ Must be unique and consists of alphanumeric characters.
optional:boolean(default:false)- Indicates the caller must provide and argument value for the parameter.
- 💡 If set to
falsei.e. an argument value is not optional then it expects a non-empty value for the variable.- E.g., in a
withexpression.
- E.g., in a
- 💡 Set it to
trueif you will use its argument value conditionally;- Or else set it to
falsefor verbosity or do not define it as default value isfalseanyway.
- Or else set it to
ScriptingDefinition
Sets global scripting properties for a Collection.
ScriptingDefinition syntax
language:string(required)- 📖 See
ScriptingLanguage.tsenumeration for allowed values.
- 📖 See
startCode:string(required)- Prepends the given code to the generated script file.
- 💡 You can use global variables such as
$homepage,$version,$datevia parameter substitution code syntax such asWelcome to {{ $homepage }}!.
endCode:string(required)- Appends to the given code to the generated script file.
- 💡 You can use global variables such as
$homepage,$version,$datevia parameter substitution code syntax such asWelcome to {{ $homepage }}!.