diff --git a/docs/explanations/architecture.rst b/docs/explanations/architecture.rst index 9dd2b08329..f0da71f27a 100644 --- a/docs/explanations/architecture.rst +++ b/docs/explanations/architecture.rst @@ -36,53 +36,53 @@ The starting point of the program is `Main.hs `_, which is in charge of :ref:`cli`. +Main then calls `CLI.hs `_, which is in charge of :ref:`cli`. App --- -`App.hs `_ is then in charge of composing the different modules. +`App.hs `_ is then in charge of composing the different modules. Auth ---- -`Auth.hs `_ is in charge of :ref:`authn`. +`Auth.hs `_ is in charge of :ref:`authn`. Api Request ----------- -`ApiRequest.hs `_ is in charge of parsing the URL query string (following PostgREST syntax), the request headers, and the request body. +`ApiRequest.hs `_ is in charge of parsing the URL query string (following PostgREST syntax), the request headers, and the request body. A request might be rejected at this level if it's invalid. For example when providing an unknown media type to PostgREST or using an unknown HTTP method. Plan ---- -Using the Schema Cache, `Plan.hs `_ generates an internal AST, filling out-of-band SQL details (like an ``ON CONFLICT (pk)`` clause) required to complete the user request. +Using the Schema Cache, `Plan.hs `_ generates an internal AST, filling out-of-band SQL details (like an ``ON CONFLICT (pk)`` clause) required to complete the user request. A request might be rejected at this level if it's invalid. For example when doing resource embedding on a nonexistent resource. Query ----- -`Query.hs `_ generates the SQL queries (parametrized and prepared) required to satisfy the user request. +`Query.hs `_ generates the SQL queries (parametrized and prepared) required to satisfy the user request. Only at this stage a connection from the pool might be used. Schema Cache ------------ -`SchemaCache.hs `_ is in charge of :ref:`schema_cache`. +`SchemaCache.hs `_ is in charge of :ref:`schema_cache`. Config ------ -`Config.hs `_ is in charge of :ref:`configuration`. +`Config.hs `_ is in charge of :ref:`configuration`. Admin ----- -`Admin.hs `_ is in charge of the :ref:`admin_server`. +`Admin.hs `_ is in charge of the :ref:`admin_server`. HTTP ---- @@ -92,4 +92,4 @@ The HTTP server is provided by `Warp `_. Listener -------- -`Listener.hs `_ is in charge of the :ref:`listener`. +`Listener.hs `_ is in charge of the :ref:`listener`. diff --git a/nix/hsie/README.md b/nix/hsie/README.md index f20b18dec1..fe0d73b33d 100644 --- a/nix/hsie/README.md +++ b/nix/hsie/README.md @@ -5,10 +5,10 @@ project. It's available in PostgREST's `nix-shell` by default. ## Dumping imports -Given source code in the directories `src` and `main`, for example, you can run: +Given source code in the directories `src/library` and `src/executable`, for example, you can run: ``` -hsie dump-imports src main +hsie dump-imports src/library src/executable ``` This dumps all imports of the modules in the given directory to a CSV file, @@ -18,7 +18,7 @@ To dump to a JSON file (e.g., to further process with `jq`), add the `--json` flag: ``` -hsie dump-imports --json src main +hsie dump-imports --json src/library src/executable ``` ## Graphing imports @@ -27,7 +27,7 @@ The tool can generate `graphviz` graphs of module and symbol imports by printing a file to `stdout` that can directly be rendered with `dot`: ``` -hsie graph-modules src main | dot -Tpng -o modules.png +hsie graph-modules src/library src/executable | dot -Tpng -o modules.png ``` The command `graph-modules` prints a graph of which modules insert which other @@ -39,7 +39,7 @@ To check whether modules are imported under consistent aliases in your project, run: ``` -hsie check-aliases main src +hsie check-aliases src/library src/executable ``` This will exit with a non-zero exit code if any inconsistent aliases are found. @@ -48,13 +48,13 @@ The following command checks whether any modules are imported as wildcards, i.e. not qualified and without specifying symbols. ``` -hsie check-wildcards main src +hsie check-wildcards src/library src/executable ``` To whitelist certain modules to be imported as wildcards, use `--ok`: ``` -hsie check-wildcards main src --ok Protolude --ok Test.Module +hsie check-wildcards src/library src/executable --ok Protolude --ok Test.Module ``` ## Current limitations diff --git a/nix/tools/devTools.nix b/nix/tools/devTools.nix index 61a3e62525..66850c7aef 100644 --- a/nix/tools/devTools.nix +++ b/nix/tools/devTools.nix @@ -132,7 +132,7 @@ let args = [ "ARG_OPTIONAL_SINGLE([outfile], [o], [Output filename], [postgrest-module-graph.png])" ]; } '' - ${hsie} graph-modules main src | ${graphviz}/bin/dot -Tpng -o "$_arg_outfile" + ${hsie} graph-modules src/library src/executable | ${graphviz}/bin/dot -Tpng -o "$_arg_outfile" ''; hsieGraphSymbols = diff --git a/nix/tools/style.nix b/nix/tools/style.nix index 20c237ebe8..d63440632f 100644 --- a/nix/tools/style.nix +++ b/nix/tools/style.nix @@ -88,7 +88,7 @@ let ${ruff}/bin/ruff check . echo "Checking consistency of import aliases in Haskell code..." - ${hsie} check-aliases main src + ${hsie} check-aliases src/library src/executable echo "Linting Haskell files..." ${fd}/bin/fd '\.l?hs$' \ diff --git a/postgrest.cabal b/postgrest.cabal index a3b30d730a..c0697a41ff 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -42,7 +42,7 @@ library default-extensions: OverloadedStrings NoImplicitPrelude NumericUnderscores - hs-source-dirs: src + hs-source-dirs: src/library exposed-modules: PostgREST.Admin PostgREST.App PostgREST.AppState @@ -194,7 +194,7 @@ executable postgrest default-language: Haskell2010 default-extensions: OverloadedStrings NoImplicitPrelude - hs-source-dirs: main + hs-source-dirs: src/executable main-is: Main.hs build-depends: base >= 4.9 && < 4.22 , containers >= 0.5.7 && < 0.8 diff --git a/main/Main.hs b/src/executable/Main.hs similarity index 100% rename from main/Main.hs rename to src/executable/Main.hs diff --git a/src/PostgREST/Admin.hs b/src/library/PostgREST/Admin.hs similarity index 100% rename from src/PostgREST/Admin.hs rename to src/library/PostgREST/Admin.hs diff --git a/src/PostgREST/ApiRequest.hs b/src/library/PostgREST/ApiRequest.hs similarity index 100% rename from src/PostgREST/ApiRequest.hs rename to src/library/PostgREST/ApiRequest.hs diff --git a/src/PostgREST/ApiRequest/Payload.hs b/src/library/PostgREST/ApiRequest/Payload.hs similarity index 100% rename from src/PostgREST/ApiRequest/Payload.hs rename to src/library/PostgREST/ApiRequest/Payload.hs diff --git a/src/PostgREST/ApiRequest/Preferences.hs b/src/library/PostgREST/ApiRequest/Preferences.hs similarity index 100% rename from src/PostgREST/ApiRequest/Preferences.hs rename to src/library/PostgREST/ApiRequest/Preferences.hs diff --git a/src/PostgREST/ApiRequest/QueryParams.hs b/src/library/PostgREST/ApiRequest/QueryParams.hs similarity index 100% rename from src/PostgREST/ApiRequest/QueryParams.hs rename to src/library/PostgREST/ApiRequest/QueryParams.hs diff --git a/src/PostgREST/ApiRequest/Types.hs b/src/library/PostgREST/ApiRequest/Types.hs similarity index 100% rename from src/PostgREST/ApiRequest/Types.hs rename to src/library/PostgREST/ApiRequest/Types.hs diff --git a/src/PostgREST/App.hs b/src/library/PostgREST/App.hs similarity index 100% rename from src/PostgREST/App.hs rename to src/library/PostgREST/App.hs diff --git a/src/PostgREST/AppState.hs b/src/library/PostgREST/AppState.hs similarity index 100% rename from src/PostgREST/AppState.hs rename to src/library/PostgREST/AppState.hs diff --git a/src/PostgREST/Auth.hs b/src/library/PostgREST/Auth.hs similarity index 100% rename from src/PostgREST/Auth.hs rename to src/library/PostgREST/Auth.hs diff --git a/src/PostgREST/Auth/Jwt.hs b/src/library/PostgREST/Auth/Jwt.hs similarity index 100% rename from src/PostgREST/Auth/Jwt.hs rename to src/library/PostgREST/Auth/Jwt.hs diff --git a/src/PostgREST/Auth/JwtCache.hs b/src/library/PostgREST/Auth/JwtCache.hs similarity index 100% rename from src/PostgREST/Auth/JwtCache.hs rename to src/library/PostgREST/Auth/JwtCache.hs diff --git a/src/PostgREST/Auth/Types.hs b/src/library/PostgREST/Auth/Types.hs similarity index 100% rename from src/PostgREST/Auth/Types.hs rename to src/library/PostgREST/Auth/Types.hs diff --git a/src/PostgREST/CLI.hs b/src/library/PostgREST/CLI.hs similarity index 100% rename from src/PostgREST/CLI.hs rename to src/library/PostgREST/CLI.hs diff --git a/src/PostgREST/Cache/Sieve.hs b/src/library/PostgREST/Cache/Sieve.hs similarity index 100% rename from src/PostgREST/Cache/Sieve.hs rename to src/library/PostgREST/Cache/Sieve.hs diff --git a/src/PostgREST/Client.hs b/src/library/PostgREST/Client.hs similarity index 100% rename from src/PostgREST/Client.hs rename to src/library/PostgREST/Client.hs diff --git a/src/PostgREST/Config.hs b/src/library/PostgREST/Config.hs similarity index 100% rename from src/PostgREST/Config.hs rename to src/library/PostgREST/Config.hs diff --git a/src/PostgREST/Config/Database.hs b/src/library/PostgREST/Config/Database.hs similarity index 100% rename from src/PostgREST/Config/Database.hs rename to src/library/PostgREST/Config/Database.hs diff --git a/src/PostgREST/Config/JSPath.hs b/src/library/PostgREST/Config/JSPath.hs similarity index 100% rename from src/PostgREST/Config/JSPath.hs rename to src/library/PostgREST/Config/JSPath.hs diff --git a/src/PostgREST/Config/PgVersion.hs b/src/library/PostgREST/Config/PgVersion.hs similarity index 100% rename from src/PostgREST/Config/PgVersion.hs rename to src/library/PostgREST/Config/PgVersion.hs diff --git a/src/PostgREST/Config/Proxy.hs b/src/library/PostgREST/Config/Proxy.hs similarity index 100% rename from src/PostgREST/Config/Proxy.hs rename to src/library/PostgREST/Config/Proxy.hs diff --git a/src/PostgREST/Cors.hs b/src/library/PostgREST/Cors.hs similarity index 100% rename from src/PostgREST/Cors.hs rename to src/library/PostgREST/Cors.hs diff --git a/src/PostgREST/Debounce.hs b/src/library/PostgREST/Debounce.hs similarity index 100% rename from src/PostgREST/Debounce.hs rename to src/library/PostgREST/Debounce.hs diff --git a/src/PostgREST/Error.hs b/src/library/PostgREST/Error.hs similarity index 100% rename from src/PostgREST/Error.hs rename to src/library/PostgREST/Error.hs diff --git a/src/PostgREST/Error/Types.hs b/src/library/PostgREST/Error/Types.hs similarity index 100% rename from src/PostgREST/Error/Types.hs rename to src/library/PostgREST/Error/Types.hs diff --git a/src/PostgREST/Listener.hs b/src/library/PostgREST/Listener.hs similarity index 100% rename from src/PostgREST/Listener.hs rename to src/library/PostgREST/Listener.hs diff --git a/src/PostgREST/Logger.hs b/src/library/PostgREST/Logger.hs similarity index 100% rename from src/PostgREST/Logger.hs rename to src/library/PostgREST/Logger.hs diff --git a/src/PostgREST/Logger/Apache.hs b/src/library/PostgREST/Logger/Apache.hs similarity index 100% rename from src/PostgREST/Logger/Apache.hs rename to src/library/PostgREST/Logger/Apache.hs diff --git a/src/PostgREST/MainTx.hs b/src/library/PostgREST/MainTx.hs similarity index 100% rename from src/PostgREST/MainTx.hs rename to src/library/PostgREST/MainTx.hs diff --git a/src/PostgREST/MediaType.hs b/src/library/PostgREST/MediaType.hs similarity index 100% rename from src/PostgREST/MediaType.hs rename to src/library/PostgREST/MediaType.hs diff --git a/src/PostgREST/Metrics.hs b/src/library/PostgREST/Metrics.hs similarity index 100% rename from src/PostgREST/Metrics.hs rename to src/library/PostgREST/Metrics.hs diff --git a/src/PostgREST/Network.hs b/src/library/PostgREST/Network.hs similarity index 100% rename from src/PostgREST/Network.hs rename to src/library/PostgREST/Network.hs diff --git a/src/PostgREST/Observation.hs b/src/library/PostgREST/Observation.hs similarity index 100% rename from src/PostgREST/Observation.hs rename to src/library/PostgREST/Observation.hs diff --git a/src/PostgREST/Plan.hs b/src/library/PostgREST/Plan.hs similarity index 100% rename from src/PostgREST/Plan.hs rename to src/library/PostgREST/Plan.hs diff --git a/src/PostgREST/Plan/CallPlan.hs b/src/library/PostgREST/Plan/CallPlan.hs similarity index 100% rename from src/PostgREST/Plan/CallPlan.hs rename to src/library/PostgREST/Plan/CallPlan.hs diff --git a/src/PostgREST/Plan/MutatePlan.hs b/src/library/PostgREST/Plan/MutatePlan.hs similarity index 100% rename from src/PostgREST/Plan/MutatePlan.hs rename to src/library/PostgREST/Plan/MutatePlan.hs diff --git a/src/PostgREST/Plan/Negotiate.hs b/src/library/PostgREST/Plan/Negotiate.hs similarity index 100% rename from src/PostgREST/Plan/Negotiate.hs rename to src/library/PostgREST/Plan/Negotiate.hs diff --git a/src/PostgREST/Plan/ReadPlan.hs b/src/library/PostgREST/Plan/ReadPlan.hs similarity index 100% rename from src/PostgREST/Plan/ReadPlan.hs rename to src/library/PostgREST/Plan/ReadPlan.hs diff --git a/src/PostgREST/Plan/Types.hs b/src/library/PostgREST/Plan/Types.hs similarity index 100% rename from src/PostgREST/Plan/Types.hs rename to src/library/PostgREST/Plan/Types.hs diff --git a/src/PostgREST/Query.hs b/src/library/PostgREST/Query.hs similarity index 100% rename from src/PostgREST/Query.hs rename to src/library/PostgREST/Query.hs diff --git a/src/PostgREST/Query/PreQuery.hs b/src/library/PostgREST/Query/PreQuery.hs similarity index 100% rename from src/PostgREST/Query/PreQuery.hs rename to src/library/PostgREST/Query/PreQuery.hs diff --git a/src/PostgREST/Query/QueryBuilder.hs b/src/library/PostgREST/Query/QueryBuilder.hs similarity index 100% rename from src/PostgREST/Query/QueryBuilder.hs rename to src/library/PostgREST/Query/QueryBuilder.hs diff --git a/src/PostgREST/Query/SqlFragment.hs b/src/library/PostgREST/Query/SqlFragment.hs similarity index 100% rename from src/PostgREST/Query/SqlFragment.hs rename to src/library/PostgREST/Query/SqlFragment.hs diff --git a/src/PostgREST/Query/Statements.hs b/src/library/PostgREST/Query/Statements.hs similarity index 100% rename from src/PostgREST/Query/Statements.hs rename to src/library/PostgREST/Query/Statements.hs diff --git a/src/PostgREST/RangeQuery.hs b/src/library/PostgREST/RangeQuery.hs similarity index 100% rename from src/PostgREST/RangeQuery.hs rename to src/library/PostgREST/RangeQuery.hs diff --git a/src/PostgREST/Response.hs b/src/library/PostgREST/Response.hs similarity index 100% rename from src/PostgREST/Response.hs rename to src/library/PostgREST/Response.hs diff --git a/src/PostgREST/Response/GucHeader.hs b/src/library/PostgREST/Response/GucHeader.hs similarity index 100% rename from src/PostgREST/Response/GucHeader.hs rename to src/library/PostgREST/Response/GucHeader.hs diff --git a/src/PostgREST/Response/OpenAPI.hs b/src/library/PostgREST/Response/OpenAPI.hs similarity index 100% rename from src/PostgREST/Response/OpenAPI.hs rename to src/library/PostgREST/Response/OpenAPI.hs diff --git a/src/PostgREST/Response/Performance.hs b/src/library/PostgREST/Response/Performance.hs similarity index 100% rename from src/PostgREST/Response/Performance.hs rename to src/library/PostgREST/Response/Performance.hs diff --git a/src/PostgREST/SchemaCache.hs b/src/library/PostgREST/SchemaCache.hs similarity index 100% rename from src/PostgREST/SchemaCache.hs rename to src/library/PostgREST/SchemaCache.hs diff --git a/src/PostgREST/SchemaCache/Identifiers.hs b/src/library/PostgREST/SchemaCache/Identifiers.hs similarity index 100% rename from src/PostgREST/SchemaCache/Identifiers.hs rename to src/library/PostgREST/SchemaCache/Identifiers.hs diff --git a/src/PostgREST/SchemaCache/Relationship.hs b/src/library/PostgREST/SchemaCache/Relationship.hs similarity index 100% rename from src/PostgREST/SchemaCache/Relationship.hs rename to src/library/PostgREST/SchemaCache/Relationship.hs diff --git a/src/PostgREST/SchemaCache/Representations.hs b/src/library/PostgREST/SchemaCache/Representations.hs similarity index 100% rename from src/PostgREST/SchemaCache/Representations.hs rename to src/library/PostgREST/SchemaCache/Representations.hs diff --git a/src/PostgREST/SchemaCache/Routine.hs b/src/library/PostgREST/SchemaCache/Routine.hs similarity index 100% rename from src/PostgREST/SchemaCache/Routine.hs rename to src/library/PostgREST/SchemaCache/Routine.hs diff --git a/src/PostgREST/SchemaCache/Table.hs b/src/library/PostgREST/SchemaCache/Table.hs similarity index 100% rename from src/PostgREST/SchemaCache/Table.hs rename to src/library/PostgREST/SchemaCache/Table.hs diff --git a/src/PostgREST/TimeIt.hs b/src/library/PostgREST/TimeIt.hs similarity index 100% rename from src/PostgREST/TimeIt.hs rename to src/library/PostgREST/TimeIt.hs diff --git a/src/PostgREST/Unix.hs b/src/library/PostgREST/Unix.hs similarity index 100% rename from src/PostgREST/Unix.hs rename to src/library/PostgREST/Unix.hs diff --git a/src/PostgREST/Version.hs b/src/library/PostgREST/Version.hs similarity index 100% rename from src/PostgREST/Version.hs rename to src/library/PostgREST/Version.hs