From bc7710b36dbaba85c284087f4ea8be2bc97c71b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Pailharey?= <rpailharey@grandlyon.com>
Date: Wed, 13 Apr 2022 13:41:20 +0200
Subject: [PATCH] feat(registry): add doc for cozy registry

---
 .../functionalities/cozy-registry.md          | 37 +++++++++++++++++++
 mkdocs.yml                                    |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 docs/pilote/Pilote - Usager/functionalities/cozy-registry.md

diff --git a/docs/pilote/Pilote - Usager/functionalities/cozy-registry.md b/docs/pilote/Pilote - Usager/functionalities/cozy-registry.md
new file mode 100644
index 0000000..a766411
--- /dev/null
+++ b/docs/pilote/Pilote - Usager/functionalities/cozy-registry.md	
@@ -0,0 +1,37 @@
+## Description
+
+Pilote Usager is linked to a registry to allow a TS to find and connect to a user Pilote app.
+A service is run every day to send instance information to the registry.
+
+### Service Flow summarized
+
+```plantuml
+  "Pilote Usager" -> "Cozy Registry": POST firstName, lastName, cozyURL, smsTriggerId
+  "Pilote TS" -> "Cozy Registry": GET firstname, lastName
+  "Pilote TS" <-- "Cozy Registry": cozyURL, smsTriggerId
+  "Pilote TS" -> "Pilote Usager": trigger sharecode sending by SMS
+  "Pilote Usager" --> "Pilote Usager": sharecode
+  "Pilote TS" <- "Pilote Usager": read sharecode
+  "Pilote TS" -> "Pilote Usager": connect to user Cozy
+```
+
+## Launch the service locally
+- Switch to Node 16 (using nvm or n)
+- install local remote doctypes (details [here](https://doc.self-data.alpha.grandlyon.com/ecolyo/project_architecture/remote_doctypes/#local-remote-doctype)), add a folder named org.mps.registry.dev, inside it add a file named request with the following content :
+```
+POST https://cozy-registry.poc.self-data.alpha.grandlyon.com/api/pilote
+Authorization: Bearer {{secret_token}}
+Content-Type: application/json
+
+{{data}}
+```
+- in the database, if it doesn't exist, create a table named secrets/io-cozy-remote-secrets and add a document with the following content :
+```json
+{
+  "_id": "org.mps.registry.dev",
+  "token": "pilotecozytoken"
+}
+```
+- launch `docker-compose up` in a first terminal
+- launch `yarn build` in a second terminal
+- launch `yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/cozyRegistry/pilote.js` to execute the service
diff --git a/mkdocs.yml b/mkdocs.yml
index cadaea7..dff24b7 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -115,6 +115,7 @@ nav:
               - Contact: pilote/Pilote - Usager/functionalities/contact.md
               - Document: pilote/Pilote - Usager/functionalities/document.md
               - Settings: pilote/Pilote - Usager/functionalities/setting.md
+              - Cozy Registry: pilote/Pilote - Usager/functionalities/cozy-registry.md
           - Getting Started:
               - Setup your environment: ecolyo/getting_started/setup_your_environment.md
               - Launch local application: pilote/Pilote - Usager/getting_started/launch_local_application.md
-- 
GitLab