diff --git a/README.md b/README.md index 77ca507a5e..8b3891e26b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Welcome to Twenty documentation! Twenty development stack is composed of 3 different layers - front: our frontend React app +- hasura: our graphql engine exposing our database and server - server: our backend that contain endpoint, crm logic, scripts, jobs... - storages: postgres @@ -29,7 +30,7 @@ cd infra/dev ``` ``` -docker-compose up --build --force-recreate +make build ``` Once this is completed you should have: @@ -46,23 +47,16 @@ If you are using VSCode, please use the `Dev Containers` extension to open the p If you are using Docker install, make sure to ssh in the docker container during development to execute commands. You can also use `Makefile` to help you -## Development +## Development workflow -### Tests +### Front tests -#### Unit tests: +Run tests: `make front-test` +Run coverage: `make front-coverage` +Run storybook: `make front-storybook` -``` -make front-test -# coverage -make front-coverage -``` +### Hasura development -#### Storybook: -``` -make front-storybook -``` - -## Developping on server - -Section TBD \ No newline at end of file +Open hasura console: `make hasura-console` +Do your changes in hasura console on http://localhost:9695 +Commit your changes in git diff --git a/hasura/config.yaml b/hasura/config.yaml new file mode 100644 index 0000000000..6d6bb5c2ac --- /dev/null +++ b/hasura/config.yaml @@ -0,0 +1,6 @@ +version: 3 +endpoint: http://localhost:8080 +metadata_directory: metadata +actions: + kind: synchronous + handler_webhook_baseurl: http://localhost:3000 \ No newline at end of file diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql new file mode 100644 index 0000000000..e69de29bb2 diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml new file mode 100644 index 0000000000..1edb4c2ffc --- /dev/null +++ b/hasura/metadata/actions.yaml @@ -0,0 +1,6 @@ +actions: [] +custom_types: + enums: [] + input_objects: [] + objects: [] + scalars: [] diff --git a/hasura/metadata/allow_list.yaml b/hasura/metadata/allow_list.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/allow_list.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/api_limits.yaml b/hasura/metadata/api_limits.yaml new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/hasura/metadata/api_limits.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/backend_configs.yaml b/hasura/metadata/backend_configs.yaml new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/hasura/metadata/backend_configs.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/cron_triggers.yaml b/hasura/metadata/cron_triggers.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/cron_triggers.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml new file mode 100644 index 0000000000..52ba870ebd --- /dev/null +++ b/hasura/metadata/databases/databases.yaml @@ -0,0 +1,9 @@ +- name: twenty + kind: postgres + configuration: + connection_info: + database_url: + from_env: HASURA_GRAPHQL_PG_DATABASE_URL + isolation_level: read-committed + use_prepared_statements: false + tables: "!include twenty/tables/tables.yaml" diff --git a/hasura/metadata/databases/twenty/tables/public_workspaces.yaml b/hasura/metadata/databases/twenty/tables/public_workspaces.yaml new file mode 100644 index 0000000000..9167a335a9 --- /dev/null +++ b/hasura/metadata/databases/twenty/tables/public_workspaces.yaml @@ -0,0 +1,3 @@ +table: + name: workspaces + schema: public diff --git a/hasura/metadata/databases/twenty/tables/tables.yaml b/hasura/metadata/databases/twenty/tables/tables.yaml new file mode 100644 index 0000000000..64aa5e7137 --- /dev/null +++ b/hasura/metadata/databases/twenty/tables/tables.yaml @@ -0,0 +1 @@ +- "!include public_workspaces.yaml" diff --git a/hasura/metadata/graphql_schema_introspection.yaml b/hasura/metadata/graphql_schema_introspection.yaml new file mode 100644 index 0000000000..61a4dcac29 --- /dev/null +++ b/hasura/metadata/graphql_schema_introspection.yaml @@ -0,0 +1 @@ +disabled_for_roles: [] diff --git a/hasura/metadata/inherited_roles.yaml b/hasura/metadata/inherited_roles.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/inherited_roles.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/metrics_config.yaml b/hasura/metadata/metrics_config.yaml new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/hasura/metadata/metrics_config.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/network.yaml b/hasura/metadata/network.yaml new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/hasura/metadata/network.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/opentelemetry.yaml b/hasura/metadata/opentelemetry.yaml new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/hasura/metadata/opentelemetry.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/query_collections.yaml b/hasura/metadata/query_collections.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/query_collections.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/remote_schemas.yaml b/hasura/metadata/remote_schemas.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/remote_schemas.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/rest_endpoints.yaml b/hasura/metadata/rest_endpoints.yaml new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/hasura/metadata/rest_endpoints.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/version.yaml b/hasura/metadata/version.yaml new file mode 100644 index 0000000000..0a70affa4b --- /dev/null +++ b/hasura/metadata/version.yaml @@ -0,0 +1 @@ +version: 3 diff --git a/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/down.sql b/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/down.sql new file mode 100644 index 0000000000..11d8bd7a7d --- /dev/null +++ b/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."workspaces"; diff --git a/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/up.sql b/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/up.sql new file mode 100644 index 0000000000..508cc4454d --- /dev/null +++ b/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."workspaces" ("id" serial NOT NULL, "name" Text NOT NULL, "display_name" text NOT NULL, PRIMARY KEY ("id") , UNIQUE ("id"), UNIQUE ("name")); diff --git a/infra/dev/Makefile b/infra/dev/Makefile index dc2a1ccace..5568250e02 100644 --- a/infra/dev/Makefile +++ b/infra/dev/Makefile @@ -1,17 +1,39 @@ +build: ## + @docker-compose up --build --force-recreate + up: ## @docker-compose up -d -logs: ## - @docker-compose logs twenty -f +down: ## + @docker-compose down -sh: ## - @docker-compose exec twenty sh +## Front + +front-logs: ## + @docker-compose logs twenty-front -f + +front-sh: ## + @docker-compose exec twenty-front sh front-test: ## - @docker-compose exec twenty sh -c "cd front && npm run test" + @docker-compose exec twenty-front sh -c "npm run test" front-coverage: ## - @docker-compose exec twenty sh -c "cd front && npm run coverage" + @docker-compose exec twenty-front sh -c "npm run coverage" front-storybook: ## - @docker-compose exec twenty sh -c "cd front && npm run storybook" + @docker-compose exec twenty-front sh -c "npm run storybook" + +## Hasura + +hasura-logs: ## + @docker-compose logs twenty-hasura -f + +hasura-sh: ## + @docker-compose exec twenty-hasura sh + +hasura-console: ## + @docker-compose exec twenty-hasura bash -c " \ + socat TCP-LISTEN:9695,fork,reuseaddr,bind=twenty-hasura TCP:127.0.0.1:9695 & \ + socat TCP-LISTEN:9693,fork,reuseaddr,bind=twenty-hasura TCP:127.0.0.1:9693 & \ + hasura console --log-level DEBUG --address "127.0.0.1" --no-browser || exit 1" \ No newline at end of file diff --git a/infra/dev/docker-compose.yml b/infra/dev/docker-compose.yml index 30201f859a..77aa1f409c 100644 --- a/infra/dev/docker-compose.yml +++ b/infra/dev/docker-compose.yml @@ -26,7 +26,7 @@ services: environment: HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/hasura HASURA_GRAPHQL_PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/twenty - HASURA_GRAPHQL_ENABLE_CONSOLE: "true" + HASURA_GRAPHQL_ENABLE_CONSOLE: "false" HASURA_GRAPHQL_DEV_MODE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log twenty-server: diff --git a/infra/dev/hasura/Dockerfile b/infra/dev/hasura/Dockerfile index e5c425416b..bc86e41b71 100644 --- a/infra/dev/hasura/Dockerfile +++ b/infra/dev/hasura/Dockerfile @@ -6,4 +6,6 @@ RUN apt-get install -y socat RUN apt-get install -y vim RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash +WORKDIR /hasura + CMD ["sh", "-c", "graphql-engine serve"] diff --git a/infra/prod/hasura/Dockerfile b/infra/prod/hasura/Dockerfile new file mode 100644 index 0000000000..f46285b415 --- /dev/null +++ b/infra/prod/hasura/Dockerfile @@ -0,0 +1,9 @@ +FROM hasura/graphql-engine:latest as api + +RUN apt-get update +RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash + +WORKDIR /app/hasura +COPY ./hasura . + +CMD ["sh", "-c", "graphql-engine serve"]