From 850c6669e02ba6b87e4891c79bf145b757fcf191 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 28 Nov 2022 16:26:24 +0200 Subject: [PATCH 01/30] feat(docs): email usage tutorial --- .../version-v0.15/modules/email/usage.mdx | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 documentation/versioned_docs/version-v0.15/modules/email/usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx new file mode 100644 index 0000000..30f9b59 --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -0,0 +1,124 @@ +# Usage + +## Configuring the provider + +A major problem while playing with Conduit modules is the configuration problem. Many Conduit modules use third party providers +to operate and email module is not an exception. Providers such as Mandrill,Mailgun and Sendgrid are used from email module for +sending emails etc.
+ +In order to start using Email you need to configure it firstly! And this is simply done by sending a curl to the Conduit Server +based on the provider that you want to use. + +:::caution + +See how email [configuration](./config) works. + +::: + +## Start playing +Now the module is configured and everything is ready to proceed. + +## Sending an Email + +You are mama's lovely child, and you want to email her to tell her that everything is going well! +Are you going to use a typical email mechanism like Gmail or Outlook? The answer is no.
+Conduit can do it for you. Just find a PC in the middle of nowhere and type in a terminal: + +``` bash title="Request" +curl --location --request POST 'http://localhost:3030/email/send' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'masterkey: yourmasterkey' \ +--header 'Authorization: Bearer youradmintoken' +--data-raw '{ + "email": "receiver@example.com", + "sender": "sender@example.com", + "subject": "MAMA EVERYTHING IS OK", + "body": "Hello mama. I hope that this email finds you well. Everything is ok." +}' +``` + +## Templates +Conduit provides a template mechanism. You can either create a template locally and store it also to the external provider, +or you can use the templates that are created only in the external provider. + +### Create a template +Each stored template has two characteristics. +- **externalManaged** feature which is true if the template is stored also in the external provider. +- **externalId** , which is the template identification in the external provider. + +Before you send the request you need to know what **externalManaged** and **_id** variables are used for. + +If **externalManaged** is set to true then: +- If **_id** variable is not set, then the template is going to be stored in the external provider +and the **externalId** is the same as the external template id. + +- **Otherwise**, the template is created only in the conduit configured database and the **externalId** +is set to the given **_id**. + + +``` bash title="Request" +curl --location --request POST 'http://localhost:3030/email/templates' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer youradmintoken' \ +--header 'masterkey: yourmasterkey' \ +--data-raw '{ + "name": "template name", + "subject": "template email subject", + "body": "body template", + "sender": "sender@mail.com", + "externalManaged": "boolean value", +}' +``` + +:::note +** Template body could be also an html document.** +::: + +### Create template with variables + +Conduit supports also template creation with variables using handlebars. +Let's try to create a template which contains variables. + +A template body example could be this: + +``` +Mama , I am your lovely son {{ lovelySonName }} and i need your help! +``` + +``` bash title="Request" +curl --location --request POST 'http://localhost:3030/email/templates' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer youradmintoken' \ +--header 'masterkey: yourmasterkey' \ +--data-raw '{ + "name": "Mamas_help", + "subject": "MAMA HELP ME", + "body": "Mama , I am your lovely son {{ lovelySonName }} and I need your help!", + "sender": "mamasboy@mail.com", + "externalManaged": "false", +}' +``` + +### Sending email with template + +To send an email using template and variables you have to give values to these variables. + +```bash title="Request" +curl --location --request POST 'http://localhost:3030/email/send' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer youradmintoken ' \ +--header 'masterkey: yourmasterkey' \ +--data-raw '{ + "email": "tomama@mail.com", + "sender": "yourmail@mail.com", + "variables": { + "lovelySonName": "yourname" + }, + "templateName": "Mamas_help" + +}' +``` From 32f0d3ceef61438cd772812539295a9f1b4befb9 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 28 Nov 2022 16:28:40 +0200 Subject: [PATCH 02/30] fix(docs): email boolean values --- .../versioned_docs/version-v0.15/modules/email/usage.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index 30f9b59..ca41289 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -68,7 +68,7 @@ curl --location --request POST 'http://localhost:3030/email/templates' \ "subject": "template email subject", "body": "body template", "sender": "sender@mail.com", - "externalManaged": "boolean value", + "externalManaged": boolean, }' ``` @@ -98,7 +98,7 @@ curl --location --request POST 'http://localhost:3030/email/templates' \ "subject": "MAMA HELP ME", "body": "Mama , I am your lovely son {{ lovelySonName }} and I need your help!", "sender": "mamasboy@mail.com", - "externalManaged": "false", + "externalManaged": false, }' ``` From fcbc4b10b724ee77dc3ca598a4621f595ef98ad2 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 28 Nov 2022 16:29:19 +0200 Subject: [PATCH 03/30] fix(docs): delete irrelevant text --- .../versioned_docs/version-v0.15/modules/email/usage.mdx | 3 --- 1 file changed, 3 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index ca41289..3579bbe 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -15,9 +15,6 @@ See how email [configuration](./config) works. ::: -## Start playing -Now the module is configured and everything is ready to proceed. - ## Sending an Email You are mama's lovely child, and you want to email her to tell her that everything is going well! From 9e83aa3605484d47c1bb17536df90580d7445053 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 28 Nov 2022 16:30:47 +0200 Subject: [PATCH 04/30] fix(docs): delete irrelevant text --- .../versioned_docs/version-v0.15/modules/email/usage.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index 3579bbe..ff2cba8 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -6,8 +6,7 @@ A major problem while playing with Conduit modules is the configuration problem. to operate and email module is not an exception. Providers such as Mandrill,Mailgun and Sendgrid are used from email module for sending emails etc.
-In order to start using Email you need to configure it firstly! And this is simply done by sending a curl to the Conduit Server -based on the provider that you want to use. +In order to start using Email you need to configure it firstly! :::caution From 8a0bbde97335548127143a0c49591977d61c0e0f Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 28 Nov 2022 17:10:19 +0200 Subject: [PATCH 05/30] feat(docs): additional docs in email usage --- .../version-v0.15/modules/email/usage.mdx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index ff2cba8..d695a2f 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -118,3 +118,31 @@ curl --location --request POST 'http://localhost:3030/email/send' \ }' ``` +### Getting external templates +Option for getting all the templates which are registered in the external email provider is supported. +You can list the external templates through this curl: + +```bash title="Request" +curl --location --request GET 'http://localhost:3030/email/externalTemplates' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer youradmintoken ' \ +--header 'masterkey: yourmasterkey' \ +--data-raw '' +``` + +### Upload a template + +Email module provides an option for uploading local stored templates on the third party email provider.
+For instance, if mailgun provider is configured as an email provider then you can upload a template on mailgun. + +```bash title="Request" +curl --location --request POST 'http://localhost:3030/email/templates/upload' \ +--header 'Content-Type: application/json' \ +--header 'Accept: application/json' \ +--header 'Authorization: Bearer youradmintoken ' \ +--header 'masterkey: yourmasterkey' \ +--data-raw '{ + "_id": "templateId" +}' +``` \ No newline at end of file From f57b81a533ce672d628f3d0dcf51a4486570f85a Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 13:11:16 +0200 Subject: [PATCH 06/30] feat(docs): grpc sdk usage --- .../version-v0.15/modules/email/usage.mdx | 146 ++++-------------- 1 file changed, 32 insertions(+), 114 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index d695a2f..fee2245 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -1,44 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # Usage ## Configuring the provider -A major problem while playing with Conduit modules is the configuration problem. Many Conduit modules use third party providers -to operate and email module is not an exception. Providers such as Mandrill,Mailgun and Sendgrid are used from email module for -sending emails etc.
- In order to start using Email you need to configure it firstly! :::caution See how email [configuration](./config) works. - ::: +## Proper imports +In order to start using the email module you need to do the proper imports. + +```jsx title="Imports" +import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; +``` ## Sending an Email -You are mama's lovely child, and you want to email her to tell her that everything is going well! -Are you going to use a typical email mechanism like Gmail or Outlook? The answer is no.
-Conduit can do it for you. Just find a PC in the middle of nowhere and type in a terminal: - -``` bash title="Request" -curl --location --request POST 'http://localhost:3030/email/send' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'masterkey: yourmasterkey' \ ---header 'Authorization: Bearer youradmintoken' ---data-raw '{ - "email": "receiver@example.com", - "sender": "sender@example.com", - "subject": "MAMA EVERYTHING IS OK", - "body": "Hello mama. I hope that this email finds you well. Everything is ok." -}' + +```jsx title="Send an email" +await this.grpcSdk.sendEmail('template_name',{ + email : 'mail@example.com', + sender: 'sendermail@example.com', + variables: { + 'variable1' : 'variable_value', + } +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) ``` ## Templates Conduit provides a template mechanism. You can either create a template locally and store it also to the external provider, or you can use the templates that are created only in the external provider. -### Create a template +### Template registration Each stored template has two characteristics. - **externalManaged** feature which is true if the template is stored also in the external provider. - **externalId** , which is the template identification in the external provider. @@ -53,96 +53,14 @@ and the **externalId** is the same as the external template id. is set to the given **_id**. -``` bash title="Request" -curl --location --request POST 'http://localhost:3030/email/templates' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'Authorization: Bearer youradmintoken' \ ---header 'masterkey: yourmasterkey' \ ---data-raw '{ - "name": "template name", - "subject": "template email subject", - "body": "body template", - "sender": "sender@mail.com", - "externalManaged": boolean, -}' -``` - -:::note -** Template body could be also an html document.** -::: - -### Create template with variables - -Conduit supports also template creation with variables using handlebars. -Let's try to create a template which contains variables. - -A template body example could be this: - -``` -Mama , I am your lovely son {{ lovelySonName }} and i need your help! -``` - -``` bash title="Request" -curl --location --request POST 'http://localhost:3030/email/templates' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'Authorization: Bearer youradmintoken' \ ---header 'masterkey: yourmasterkey' \ ---data-raw '{ - "name": "Mamas_help", - "subject": "MAMA HELP ME", - "body": "Mama , I am your lovely son {{ lovelySonName }} and I need your help!", - "sender": "mamasboy@mail.com", - "externalManaged": false, -}' -``` - -### Sending email with template - -To send an email using template and variables you have to give values to these variables. - -```bash title="Request" -curl --location --request POST 'http://localhost:3030/email/send' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'Authorization: Bearer youradmintoken ' \ ---header 'masterkey: yourmasterkey' \ ---data-raw '{ - "email": "tomama@mail.com", - "sender": "yourmail@mail.com", - "variables": { - "lovelySonName": "yourname" - }, - "templateName": "Mamas_help" - -}' -``` -### Getting external templates -Option for getting all the templates which are registered in the external email provider is supported. -You can list the external templates through this curl: - -```bash title="Request" -curl --location --request GET 'http://localhost:3030/email/externalTemplates' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'Authorization: Bearer youradmintoken ' \ ---header 'masterkey: yourmasterkey' \ ---data-raw '' -``` - -### Upload a template - -Email module provides an option for uploading local stored templates on the third party email provider.
-For instance, if mailgun provider is configured as an email provider then you can upload a template on mailgun. - -```bash title="Request" -curl --location --request POST 'http://localhost:3030/email/templates/upload' \ ---header 'Content-Type: application/json' \ ---header 'Accept: application/json' \ ---header 'Authorization: Bearer youradmintoken ' \ ---header 'masterkey: yourmasterkey' \ ---data-raw '{ - "_id": "templateId" -}' +```jsx title="Template registration" +await this.grpcSdk.registerTemplate({ + name: 'template_name', + subject: 'subject', + body: '

Hello, {{user}}. I hope you are doing well.', + variables: ['user'] +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) ``` \ No newline at end of file From 454464ea55aaacd1cb454f09e88cb28bce37e7a2 Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 13:30:35 +0200 Subject: [PATCH 07/30] refactor(docs): email usage --- .../version-v0.15/modules/email/usage.mdx | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index fee2245..d257d20 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -1,23 +1,23 @@ -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Usage -## Configuring the provider +## Setting up -In order to start using Email you need to configure it firstly! +### Configuring the provider -:::caution +In order to start using Email you need to execute and configure it firstly! -See how email [configuration](./config) works. +:::caution +See how to [execute](./get-started#execution) the email module.
+See how to [configure](./configuration) it. ::: -## Proper imports -In order to start using the email module you need to do the proper imports. +After configuring , you need to have the appropriate imports. ```jsx title="Imports" import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; ``` + + ## Sending an Email @@ -35,23 +35,10 @@ await this.grpcSdk.sendEmail('template_name',{ ``` ## Templates -Conduit provides a template mechanism. You can either create a template locally and store it also to the external provider, -or you can use the templates that are created only in the external provider. +Conduit provides a template mechanism. Templates can be created with or without variables.
+To create a template with variables, do it by using [handlebars](https://handlebarsjs.com/guide/). ### Template registration -Each stored template has two characteristics. -- **externalManaged** feature which is true if the template is stored also in the external provider. -- **externalId** , which is the template identification in the external provider. - -Before you send the request you need to know what **externalManaged** and **_id** variables are used for. - -If **externalManaged** is set to true then: -- If **_id** variable is not set, then the template is going to be stored in the external provider -and the **externalId** is the same as the external template id. - -- **Otherwise**, the template is created only in the conduit configured database and the **externalId** -is set to the given **_id**. - ```jsx title="Template registration" await this.grpcSdk.registerTemplate({ From e40da317464edd39190afb73d54f12e33f2e2348 Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 13:53:06 +0200 Subject: [PATCH 08/30] fix(docs): email broken link --- .../versioned_docs/version-v0.15/modules/email/usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx index d257d20..67fbe46 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx @@ -8,7 +8,7 @@ In order to start using Email you need to execute and configure it firstly! :::caution See how to [execute](./get-started#execution) the email module.
-See how to [configure](./configuration) it. +See how to [configure](./config) it. ::: After configuring , you need to have the appropriate imports. From ece1a2627edccafc477a9bc45d64a85b7cbff083 Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 15:58:53 +0200 Subject: [PATCH 09/30] feat(docs): authentication and email sdk usage --- .../modules/authentication/sdk_usage.mdx | 69 +++++++++++++++++++ .../email/{usage.mdx => sdk_usage.mdx} | 20 +----- 2 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx rename documentation/versioned_docs/version-v0.15/modules/email/{usage.mdx => sdk_usage.mdx} (71%) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx new file mode 100644 index 0000000..e6ce88f --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -0,0 +1,69 @@ +# SDK Usage + + +## User Login +This sdk function produces login credentials for a user without them having to login. +It is required a user and a client have been created. +```jsx title="User login" +await this.grpcSdk.authentication.userLogin({ + userId: "someuserid", + clientId : "someclientid" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); + +``` + +## User Create +It is necessary to explain how a user is created using Conduit sdk. +Each sdk user has the option to decide whenever a user will be verified or not.
+In case that **verify** parameter is set to **true** then the user will be under a verification process in order to signup successfully. +The second step of the verification process depend on the configuration of the local strategy. The **send verification email** option should be selected. + +:::caution + +If the [email module is not up and configured](../email/config) or the [send verification email](./config#local-authentication) option is not selected then the process will fail .
+::: + +```jsx title="User login" +await this.grpcSdk.authentication.userCreate({ + email: "somemai@example.com", + password : "P@$$w0rd", + verify: true | false +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); + +``` + + +## User Delete + +No words needed to explain this sdk function usage. The only thing you need is the **userId** that you want to delete. + +```jsx title="User delete" +await this.grpcSdk.authentication.userDelete({ + userId: "someuserid" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); + +``` + +## Change Password + +No explanation needed either. Just type the new password and the email of the user, and you are ready. + +```jsx title="Change user's password " +await this.grpcSdk.authentication.changePass({ + email: "somemai@example.com", + password: "newP@$$w0rd" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); + +``` \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx similarity index 71% rename from documentation/versioned_docs/version-v0.15/modules/email/usage.mdx rename to documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index 67fbe46..eb99399 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -1,27 +1,11 @@ -# Usage - -## Setting up - -### Configuring the provider - -In order to start using Email you need to execute and configure it firstly! - -:::caution -See how to [execute](./get-started#execution) the email module.
-See how to [configure](./config) it. -::: - -After configuring , you need to have the appropriate imports. - -```jsx title="Imports" -import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; -``` +# SDK Usage ## Sending an Email ```jsx title="Send an email" +import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; await this.grpcSdk.sendEmail('template_name',{ email : 'mail@example.com', sender: 'sendermail@example.com', From 8f266ee213f879ca8142625b0a5ee2f4d32f1d0d Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 15:59:21 +0200 Subject: [PATCH 10/30] chore(docs): typo --- .../version-v0.15/modules/authentication/sdk_usage.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index e6ce88f..9dd0ff1 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -28,7 +28,7 @@ If the [email module is not up and configured](../email/config) or the [send ver ```jsx title="User login" await this.grpcSdk.authentication.userCreate({ - email: "somemai@example.com", + email: "somemail@example.com", password : "P@$$w0rd", verify: true | false }) @@ -59,7 +59,7 @@ No explanation needed either. Just type the new password and the email of the us ```jsx title="Change user's password " await this.grpcSdk.authentication.changePass({ - email: "somemai@example.com", + email: "somemail@example.com", password: "newP@$$w0rd" }) .catch(e => { From 5f2eb5b7d35fbc8a57a453c673f3d8fda80969df Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 16:51:43 +0200 Subject: [PATCH 11/30] feat(docs): sms,authentication --- .../modules/authentication/sdk_usage.mdx | 9 ++-- .../version-v0.15/modules/sms/sdk_usage.mdx | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index 9dd0ff1..ae11daa 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -17,12 +17,10 @@ await this.grpcSdk.authentication.userLogin({ ## User Create It is necessary to explain how a user is created using Conduit sdk. -Each sdk user has the option to decide whenever a user will be verified or not.
-In case that **verify** parameter is set to **true** then the user will be under a verification process in order to signup successfully. -The second step of the verification process depend on the configuration of the local strategy. The **send verification email** option should be selected. +As in dev using the sdk you have the option to decide whenever a user will be verified or not.
+You can enable also sign up verification by sending an email. :::caution - If the [email module is not up and configured](../email/config) or the [send verification email](./config#local-authentication) option is not selected then the process will fail .
::: @@ -30,12 +28,11 @@ If the [email module is not up and configured](../email/config) or the [send ver await this.grpcSdk.authentication.userCreate({ email: "somemail@example.com", password : "P@$$w0rd", - verify: true | false + verify: true, }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); - ``` diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx new file mode 100644 index 0000000..1622b05 --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -0,0 +1,48 @@ +# SDK Usage + + +## Send Sms +Underworld has to know about Conduit Platform. Just text him via sms. + +:::caution +Sms module has to be configured with the proper provider. +::: +```jsx title="Send sms" + this.grpcSdk.sms.sendSms({ + to: "+6666666666", + message: "Hello. Conduit rocks!" + }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }) +``` + +## Verify via Sms + +Conduit provides a verification logic by sending sms. You can verify everything in two steps.
+In the first step, a verification code will be sent to a user using the **sendVerificationCode** function. + +```jsx title="Send verification code" +const verificationSid = await this.grpcSdk.sms.sendVerificationCode({ + to: "+6666666666", +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +A verificationSid will be returned to you. Also, a code will be sent to the user. +To proceed to the next and final step you have to use these to make the verification. + + +```jsx title="Verify" +const verified = await this.grpcSdk.sms.verify({ + verificationSid : "someverificationsid", + code: "verificationcode" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +If verification process went well then the returned value will be true. \ No newline at end of file From f9edfbc6f17da67604fa115df1f54407fffe9f77 Mon Sep 17 00:00:00 2001 From: dimitris Date: Tue, 29 Nov 2022 16:52:09 +0200 Subject: [PATCH 12/30] chore(docs): typos --- .../versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index 1622b05..eb0cbef 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -19,7 +19,7 @@ Sms module has to be configured with the proper provider. ## Verify via Sms -Conduit provides a verification logic by sending sms. You can verify everything in two steps.
+Conduit provides a verification mechanism by sending sms. You can verify everything in two steps.
In the first step, a verification code will be sent to a user using the **sendVerificationCode** function. ```jsx title="Send verification code" From cac6e13349e39bd598f5b729b43d6cc03abca683 Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 30 Nov 2022 14:47:51 +0200 Subject: [PATCH 13/30] feat(docs,authentication,sms,push-notifications): docs updated --- .../modules/authentication/sdk_usage.mdx | 1 - .../modules/push-notifications/sdk_usage.mdx | 97 +++++++++++++++++++ .../version-v0.15/modules/sms/sdk_usage.mdx | 16 +-- 3 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index ae11daa..5483efd 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -12,7 +12,6 @@ await this.grpcSdk.authentication.userLogin({ .catch(e => { ConduitGrpcSdk.Logger.error(e); }); - ``` ## User Create diff --git a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx new file mode 100644 index 0000000..dcd77ce --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx @@ -0,0 +1,97 @@ +# SDK Usage + +Conduit sdk provides push notifications utils depending on the configured provider. For now,
+only Firebase and OneSignal providers are implemented. + +## Push Notification logic + +As it is mentioned before, push notifications are sent to applications which are related with users. +In fact, a user is related with a notification token , and a token is related with an application. +Notification token is a unique identifier generated for a user, thus for an application also. +For instance , Firebase messaging system provides tokens for sending push notifications.
+Conduit represents these tokens as objects which include three subfields. + +In detail: + +```jsx title="Notification Token Object" +{ + _id: ObjectId, + userId: ObjectId, //user's Id related with this token, + token: string, // actual token related with the application + platform: string, // application platform +} +``` + + +## Set Notification Token + +A reasonable question is "How a notification token is related with a user ?". Conduit has the answer for you. +You can "relate" a token with a user by using **setNotificationToken()** sdk function. + +```jsx title=" Set notification token" +await this.grpcSdk.pushNotifications.setNotificationToken({ + token: "applicationtoken", + platform: "WEB", // could be also ANDROID,IOS,MACOS,LINUX,CLI,IPADOS + userId: "someuserid", // user related with this token +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` + +## Get Notification Token + +Getting a user's notification token will be an easy process. Just call getNotificationTokens() function. +```jsx title=" Get notification tokens" +const tokens = await this.grpcSdk.pushNotifications.getNotificationTokens({ + userId: "someuserid", // user related with this token +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` +Response will include an array of Notification Token Object + +```jsx title="Response" +tokens: [{ + _id: ObjectId, + userId: ObjectId, //user's Id related with this token, + token: string, // actual token related with the application + platform: string, // application platform +}] +``` + +## Send Notification + +Congratulations! You are now ready to send push notifications. + +```jsx title="Send Notification" +const response= await this.grpcSdk.pushNotifications.sendNotification({ + sendTo: "diresuemos", + title: "Hello 666.I have a message for you.", + body: "Conduit will send you to heaven.Try it." +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` +Appropriate message will be returned to you if everything went well. +```jsx title="Response" +response: { + message: "Ok" +} +``` + +## Send Many Notifications + +There is a "plus" function for sending push notifications to many users concurrently. +```jsx title="Send Notifications" +await this.grpcSdk.pushNotifications.sendToManyDevices({ + sendTo: ["diresuemos","somueserid2","someuserid3"], + title: "Hello 666.I have a message for you.", + body: "Conduit will send you to heaven.Try it." +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index eb0cbef..5fbb14a 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -8,13 +8,13 @@ Underworld has to know about Conduit Platform. Just text him via sms. Sms module has to be configured with the proper provider. ::: ```jsx title="Send sms" - this.grpcSdk.sms.sendSms({ - to: "+6666666666", - message: "Hello. Conduit rocks!" - }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }) +this.grpcSdk.sms.sendSms({ + to: "+6666666666", + message: "Hello. Conduit rocks!" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); ``` ## Verify via Sms @@ -28,7 +28,7 @@ const verificationSid = await this.grpcSdk.sms.sendVerificationCode({ }) .catch(e => { ConduitGrpcSdk.Logger.error(e); -}) +}); ``` A verificationSid will be returned to you. Also, a code will be sent to the user. From fbdd63ce63b17ccf9bcc047d11e9dd1f7d2635ca Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 30 Nov 2022 15:29:29 +0200 Subject: [PATCH 14/30] feat(docs,chat): docs updated wth sdk usage --- .../version-v0.15/modules/chat/sdk_usage.mdx | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx new file mode 100644 index 0000000..672a4e3 --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx @@ -0,0 +1,75 @@ +# SDK Usage + +Chat sdk comes with three functionalities. Guess what ? You can create, delete rooms and send messages. +You might wonder "Why I can not update the room ?". And the answer is that is not implemented yet. +There are some questions that we need to answer before taking a decision to implement the update functionality. + +- Who is going to update the chat room? +- Does the user is authorized to do it? + +All these obstacles can be overcome by creating an authorization module. +Authorization module is in the pipeline and will be available soon. + + +## Create a room + +Let's begin by creating a room. All you need is: +- A participant array which include the participants user ids. +- A room name. + +```jsx title="Create a room" +const room = await this.grpcSdk.chat.createRoom({ + name: "roomname", + participants: ["userid1","userid2"], +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` + +In case of a successful chat room creation, the created room will be returned to you. + +```jsx title="Response" +room: { + Id: "roomid", + name: "roomname", + participants: ["userid1","userid2"] +} +``` + +## Delete a room + +Room id is only required for deleting it. + +```jsx title="Delete a room" +const deletedRoom = await this.grpcSdk.chat.deleteRoom({ + id: "roomid", + +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` +A room object will be returned to you if deletion takes place successfully. + +```jsx title="Response" +room: { + Id: "roomid", + name: "roomname", + participants: ["userid1","userid2"] +} +``` + + +## Send a message +Finally, sending a message to a room is also an easy operation. To send a message, you have to belong to the room and to be logged in as a user. + +```jsx title="Delete a room" +const message = await this.grpcSdk.chat.sendMessage({ + roomId: "roomid", + message: "Hello Conduit users!" +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}); +``` \ No newline at end of file From bd88b8fabf1e1d9f719c2546b4ac2e92f45bc223 Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 30 Nov 2022 15:56:13 +0200 Subject: [PATCH 15/30] chore(docs,chat,email,sms,push-notifications): typos syntax etc --- .../version-v0.15/modules/chat/sdk_usage.mdx | 7 ------- .../version-v0.15/modules/email/sdk_usage.mdx | 2 +- .../modules/push-notifications/sdk_usage.mdx | 13 +++++-------- .../version-v0.15/modules/sms/sdk_usage.mdx | 10 +++++----- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx index 672a4e3..05c4e07 100644 --- a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx @@ -2,13 +2,6 @@ Chat sdk comes with three functionalities. Guess what ? You can create, delete rooms and send messages. You might wonder "Why I can not update the room ?". And the answer is that is not implemented yet. -There are some questions that we need to answer before taking a decision to implement the update functionality. - -- Who is going to update the chat room? -- Does the user is authorized to do it? - -All these obstacles can be overcome by creating an authorization module. -Authorization module is in the pipeline and will be available soon. ## Create a room diff --git a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index eb99399..9c311ab 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -1,7 +1,7 @@ # SDK Usage -## Sending an Email +## Sending an email ```jsx title="Send an email" diff --git a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx index dcd77ce..5963dbe 100644 --- a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx @@ -1,10 +1,7 @@ # SDK Usage Conduit sdk provides push notifications utils depending on the configured provider. For now,
-only Firebase and OneSignal providers are implemented. - -## Push Notification logic - +only Firebase and OneSignal providers are implemented.
As it is mentioned before, push notifications are sent to applications which are related with users. In fact, a user is related with a notification token , and a token is related with an application. Notification token is a unique identifier generated for a user, thus for an application also. @@ -23,7 +20,7 @@ In detail: ``` -## Set Notification Token +## Set notification token A reasonable question is "How a notification token is related with a user ?". Conduit has the answer for you. You can "relate" a token with a user by using **setNotificationToken()** sdk function. @@ -39,7 +36,7 @@ await this.grpcSdk.pushNotifications.setNotificationToken({ }); ``` -## Get Notification Token +## Get notification token Getting a user's notification token will be an easy process. Just call getNotificationTokens() function. ```jsx title=" Get notification tokens" @@ -65,7 +62,7 @@ tokens: [{ Congratulations! You are now ready to send push notifications. -```jsx title="Send Notification" +```jsx title="Send notification" const response= await this.grpcSdk.pushNotifications.sendNotification({ sendTo: "diresuemos", title: "Hello 666.I have a message for you.", @@ -82,7 +79,7 @@ response: { } ``` -## Send Many Notifications +## Send many notifications There is a "plus" function for sending push notifications to many users concurrently. ```jsx title="Send Notifications" diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index 5fbb14a..9ddd8e0 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -1,12 +1,12 @@ # SDK Usage - - -## Send Sms -Underworld has to know about Conduit Platform. Just text him via sms. +Underworld has to know about Conduit Platform. Just use sms module to do it. :::caution Sms module has to be configured with the proper provider. ::: + +## Send Sms + ```jsx title="Send sms" this.grpcSdk.sms.sendSms({ to: "+6666666666", @@ -17,7 +17,7 @@ this.grpcSdk.sms.sendSms({ }); ``` -## Verify via Sms +## Verify via sms Conduit provides a verification mechanism by sending sms. You can verify everything in two steps.
In the first step, a verification code will be sent to a user using the **sendVerificationCode** function. From 62fc30ab1f192d3d421737c44167e0ad3637b605 Mon Sep 17 00:00:00 2001 From: dimitris Date: Wed, 30 Nov 2022 18:50:45 +0200 Subject: [PATCH 16/30] feat(docs,database): database sdk usage --- .../modules/database/sdk_usage.mdx | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx new file mode 100644 index 0000000..4469f8f --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -0,0 +1,146 @@ +# SDK Usage + +Since database is up, its sdk comes up with a bunch of operations that you could use. +To start playing with database you need to create a schema first. And **createSchemaFromAdapter()** +goes for it. + +## Schema creation + +Crete schema from adapter accepts a JSON schema as an argument, and it stores into the database. +Additional arguments are required such as: +- Schema name +- [Schema fields](./sdk_usage#schema-fields) +- [Schema model options](./sdk_usage#model-options) +- Owner module name // module that owns the module +- Collection name ( name of the collection) + +### Schema fields +Schema fields represent the whole schema. Each field may have: + +Name | Type | Description | +| ---- | ---- | ----------- | +| `type` | TYPE | Could be TYPE.(String,Number,Boolean etc.)| +| `required` | boolean | Indicates if a field is required. | +| `unique` | boolean | Indicates if a field is unique. | +| `select` | boolean | Indicates if a field could be retreived from a query. | +| `description` | string | Description of the field, | +| `default` | any | Default value of the field. | +| `enum` | enum values | When a field has enum values. | + +Suppose that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **description** **for_adults** and surely an **_id** field. +So a possible schema could be this. + +```jsx title="Movie schema" +enum MoviesGenreEnum { + THRILLER = "THRILLER", + COMEDY = "COMEDY", + ADVENTURE ="ADVENTURE", + SCIENCE_FICTION = "SCIFI" +}; + +const schema = { + _id: TYPE.ObjectId, + title: { + type: TYPE.String, + unique: true, + required: true, + }, + title: { + type: TYPE.String, + unique: true, + required: true, + }, + duration: { + type: TYPE.Number + }, + genre: { + type: TYPE.String, + enum: Object.values(MoviesGenreEnum), + required: true, + }, + description: { + type: TYPE.String, + required: false, + unique: false, + }, + forAdults: { + type: TYPE.Boolean, + required: true, + } + createdAt: TYPE.Date, + updatedAt: TYPE.Date, +} +``` +### Model Options + +There is another argument that createSchemaFromAdapter() needs and it called modelOptions. +Model options is an object and is stored in the database and keeps some information about our schema. + +Name | Type | Description | +| ---- | ---- | ----------- | +| `type` | TYPE | Could be TYPE.(String,Number,Boolean etc.)| +| `conduit.permissions` | object | Schema permissions | +| `conduit.persmissions.extendable` | boolean | Indicates if a schema could be extend after its creation. | +| `conduit.permissions.canCreate` | boolean | Indicates if a module can create documents of that schema. | +| `conduit.permissions.canModify` | boolean | Indicates if a module can modify documents of that schema. | +| `conduit.permissions.canModify` | boolean | Indicates if a module can delete of that schema. | + +A modelOptions object could be this: + +```jsx title="Model options object" +const modelOptions = { + timestamps: true, + conduit: { + permissions: { + extendable: true, + canCreate: false, + canModify: 'ExtensionOnly', + canDelete: false, + }, + }, +} as const; +``` + +## Schema creation + +Final step is to call the createSchemaFromAdapter() function. +```jsx title="Create schema from adapter" +await this.grpcSdk.database.createSchemaFromAdapter({ + name: "Movies", + fields: schema, + modelOptions: modelOptions, + collectionName: "", // could be 'Movies' also +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +## Getting schemas + +List schemas functionality is also available in grpc-sdk. Fetching registered schemas could be done +by calling **getSchemas()** function.
+In detail: + +```jsx title="Getting registereds schemas" +await this.grpcSdk.database.getSchemas({}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +In case of success, an array of schema documents will be returned to you. + +## Delete schema + +Deleting schemas could also be done by calling sdk's **deleteSchema()** function. All you need is schema's name. +Remember that conduit provides you the option of deleting also the created documents of the schema. + +```jsx title="Getting registereds schemas" +await this.grpcSdk.database.deleteSchema({ + name: "someschemaname", + deleteData: true // could be also false +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) \ No newline at end of file From c6d0087bd99dd09e9f8dd9f16fb1c64c9c4f48c0 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 11:07:21 +0200 Subject: [PATCH 17/30] chore(docs): grammar and syntax fixes --- .../modules/authentication/sdk_usage.mdx | 11 +++++----- .../modules/database/sdk_usage.mdx | 22 +++++++++---------- .../modules/push-notifications/sdk_usage.mdx | 18 +++++++-------- .../version-v0.15/modules/sms/sdk_usage.mdx | 7 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index 5483efd..ec3a91c 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -2,8 +2,9 @@ ## User Login -This sdk function produces login credentials for a user without them having to login. -It is required a user and a client have been created. +Without requiring the user to log in first, this SDK function generates login credentials for them. +A user and a client must both have been created. + ```jsx title="User login" await this.grpcSdk.authentication.userLogin({ userId: "someuserid", @@ -15,9 +16,9 @@ await this.grpcSdk.authentication.userLogin({ ``` ## User Create -It is necessary to explain how a user is created using Conduit sdk. -As in dev using the sdk you have the option to decide whenever a user will be verified or not.
-You can enable also sign up verification by sending an email. +It is necessary to explain how Conduit sdk is used to create a user. +As in dev, you can choose whether to verify a user when using the SDK.
+Sign up verification can also be enabled by sending an email. :::caution If the [email module is not up and configured](../email/config) or the [send verification email](./config#local-authentication) option is not selected then the process will fail .
diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 4469f8f..3f00281 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -1,12 +1,12 @@ # SDK Usage -Since database is up, its sdk comes up with a bunch of operations that you could use. +Since database is up, its sdk comes up with a bunch of operations you could use. To start playing with database you need to create a schema first. And **createSchemaFromAdapter()** goes for it. ## Schema creation -Crete schema from adapter accepts a JSON schema as an argument, and it stores into the database. +Create schema from adapter accepts a JSON schema as an argument, and it stores into the database. Additional arguments are required such as: - Schema name - [Schema fields](./sdk_usage#schema-fields) @@ -27,8 +27,8 @@ Name | Type | Description | | `default` | any | Default value of the field. | | `enum` | enum values | When a field has enum values. | -Suppose that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **description** **for_adults** and surely an **_id** field. -So a possible schema could be this. +Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **description** **for_adults** and surely an **_id** field. +So a possible schema could be this: ```jsx title="Movie schema" enum MoviesGenreEnum { @@ -73,8 +73,8 @@ const schema = { ``` ### Model Options -There is another argument that createSchemaFromAdapter() needs and it called modelOptions. -Model options is an object and is stored in the database and keeps some information about our schema. +There is another argument that createSchemaFromAdapter() needs, and it is called modelOptions. +Model options are objects that are stored in the database and contain some information about our schema. Name | Type | Description | | ---- | ---- | ----------- | @@ -103,7 +103,7 @@ const modelOptions = { ## Schema creation -Final step is to call the createSchemaFromAdapter() function. +The final step is to call the createSchemaFromAdapter() function. ```jsx title="Create schema from adapter" await this.grpcSdk.database.createSchemaFromAdapter({ name: "Movies", @@ -118,8 +118,8 @@ await this.grpcSdk.database.createSchemaFromAdapter({ ## Getting schemas -List schemas functionality is also available in grpc-sdk. Fetching registered schemas could be done -by calling **getSchemas()** function.
+The functionality of list schemas is also available in grpc-sdk.Fetching registered schemas could be done +by invoking the **getSchemas()** method In detail: ```jsx title="Getting registereds schemas" @@ -133,8 +133,8 @@ In case of success, an array of schema documents will be returned to you. ## Delete schema -Deleting schemas could also be done by calling sdk's **deleteSchema()** function. All you need is schema's name. -Remember that conduit provides you the option of deleting also the created documents of the schema. +Deleting schemas could also be done by calling the SDK's deleteSchema() function. All you need is Schema's name. +Remember that conduit allows you to delete the schema's created documents as well. ```jsx title="Getting registereds schemas" await this.grpcSdk.database.deleteSchema({ diff --git a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx index 5963dbe..3e3a710 100644 --- a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx @@ -1,12 +1,11 @@ # SDK Usage -Conduit sdk provides push notifications utils depending on the configured provider. For now,
-only Firebase and OneSignal providers are implemented.
-As it is mentioned before, push notifications are sent to applications which are related with users. -In fact, a user is related with a notification token , and a token is related with an application. -Notification token is a unique identifier generated for a user, thus for an application also. -For instance , Firebase messaging system provides tokens for sending push notifications.
-Conduit represents these tokens as objects which include three subfields. +Depending on the configured provider, Conduit SDK provides push notification utilities.For now, only Firebase and OneSignal providers are implemented.
+As it was mentioned before, push notifications are sent to applications that are related to users. +In fact, a user is related to a notification token, and a token is related to an application. +A notification token is a unique identifier generated for a user, and thus for an application as well. +For instance, the Firebase messaging system provides tokens for sending push notifications.
+Conduit represents these tokens as objects, which include three subfields. In detail: @@ -22,8 +21,9 @@ In detail: ## Set notification token -A reasonable question is "How a notification token is related with a user ?". Conduit has the answer for you. -You can "relate" a token with a user by using **setNotificationToken()** sdk function. +A reasonable question is "How is a notification token related to a user?" Conduit has the answer for you. +Using the **setNotificationToken()** SDK function, you can "relate" a token to a user. + ```jsx title=" Set notification token" await this.grpcSdk.pushNotifications.setNotificationToken({ diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index 9ddd8e0..e273298 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -19,8 +19,8 @@ this.grpcSdk.sms.sendSms({ ## Verify via sms -Conduit provides a verification mechanism by sending sms. You can verify everything in two steps.
-In the first step, a verification code will be sent to a user using the **sendVerificationCode** function. +Conduit provides a verification mechanism by sending SMS. You can verify everything in two steps.
+The **sendVerificationCode** function will be used to send a verification code to the user in the first step. ```jsx title="Send verification code" const verificationSid = await this.grpcSdk.sms.sendVerificationCode({ @@ -32,8 +32,7 @@ const verificationSid = await this.grpcSdk.sms.sendVerificationCode({ ``` A verificationSid will be returned to you. Also, a code will be sent to the user. -To proceed to the next and final step you have to use these to make the verification. - +To proceed to the next and final step you have to use these to make the verification ```jsx title="Verify" const verified = await this.grpcSdk.sms.verify({ From 93b81abab90a4dee6b8b90cd05fb6270ab453997 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 13:57:35 +0200 Subject: [PATCH 18/30] feat(docs): database sdk additions --- .../modules/database/sdk_usage.mdx | 148 +++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 3f00281..23e19a3 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -83,7 +83,7 @@ Name | Type | Description | | `conduit.persmissions.extendable` | boolean | Indicates if a schema could be extend after its creation. | | `conduit.permissions.canCreate` | boolean | Indicates if a module can create documents of that schema. | | `conduit.permissions.canModify` | boolean | Indicates if a module can modify documents of that schema. | -| `conduit.permissions.canModify` | boolean | Indicates if a module can delete of that schema. | +| `conduit.permissions.canDelete` | boolean | Indicates if a module can delete of that schema. | A modelOptions object could be this: @@ -143,4 +143,148 @@ await this.grpcSdk.database.deleteSchema({ }) .catch(e => { ConduitGrpcSdk.Logger.error(e); -}) \ No newline at end of file +}) +``` + + +## Schema extensions + +What about adding extra fields to system schemas? You can accomplish this by using **setSchemaExtension()**. +Existing schemas, such as User, EmailTemplate, Client, and so on, can be extended. +Extending the Conduit User schema is a great example of usage.
+Assume that the existing user schema does not account for your specific project's preferences. You can make changes to the existing schema. +You are free to include any field you want.
+Assume your goal is to add a field called **recoverEmail** which is used to recover an account if the initial email is misplaced or forgotten. + +```jsx title="Set schema extension" +await this.grpcSdk.database.setSchemaExtension({ + schemaName: "User", + extOwner: "database", + extFields: { + recoverEmail: { + type: "String", + required: "false", + } + } +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +Now the User schema includes this new field called **recoverEmail**. + +## Database Operations + +Conduit models provide several static helper functions for CRUD operations.
+Queries are structured Mongoose-like. To see Conduit's query language click [here](./operators). + +### findOne +Suppose that we want to find a record with a specific id. + +```jsx title="Set schema extension" +const user = await this.grpcSdk.database + .findOne("User",{ _id: "someuserid"}) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### findMany +For instance if we want to fetch all Users which have +enabled the 2FA using phone method ,then a query would be this: + +```jsx title="Finding many documents" +const users = await this.grpcSdk.database + .findMany("User", { $and: [ { hasTwoFa: true},{ twoFaMethod: 'phone'} ] }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### create + +```jsx title="Create a document" +await this.grpcSdk.database + .create("User",{ + email: "example@mail.com", + password: "P@ssw0rD!@", + isVerified: true // could also be false + }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### createMany + +```jsx title="Create many documents" +await this.grpcSdk.database.createMany("User", + [{ + email: "example@mail.com", + password: "P@ssw0rD!@", + isVerified: true // could also be false + }, + { + email: "example1@mail.com", + password: "P@ssw0rD!@12", + isVerified: true + }]) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + + +### updateMany +In case of updating many documents given some constraints then we can use updateMany() function.
+Consider that we want to disable two-factor authentication for all users whose ids are contained in some array. + +```jsx title="Update many documents " +const idArray = [userid1,userid2,userid3]; +await this.grpcSdk.database + .updaeteMany("User",{ _id :{ $in: idArray } },{ hasTwoFa: false}) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### deleteOne + +The only thing we need is the document ID we want to delete. + +```jsx title="Update many documents " +await this.grpcSdk.database + .deleteOne("User",{ _id : id }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### deleteMany + +Like updateMany we can use **deleteMany** to delete documents given some constraints. + +```jsx title="Delete many documents " +const idArray = [userid1,userid2,userid3]; +await this.grpcSdk.database + .deleteMany("User",{ _id :{ $in: idArray } }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` + +### countDocuments + +Sometimes we only need to count how many documents exist with specific features. +For example, if we want to count how many users have two-factor authentication enabled, +**countDocuments()** should be used.
+An alternative but more complicated way of doing it is to use **findMany()** and calculate the length of the returned array. + +```jsx title="Cunt documents" +await this.grpcSdk.database + .countDocuments("User",{ hasTwoFa: true }) + .catch(e => { + ConduitGrpcSdk.Logger.error(e); + }); +``` From d6e056f97c28077fbfd51a75b6eceea165b7bc40 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 14:00:43 +0200 Subject: [PATCH 19/30] chore(docs): database sdk type fixes --- .../version-v0.15/modules/database/sdk_usage.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 23e19a3..1dbf1d1 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -195,7 +195,7 @@ For instance if we want to fetch all Users which have enabled the 2FA using phone method ,then a query would be this: ```jsx title="Finding many documents" -const users = await this.grpcSdk.database +const users: User[] = await this.grpcSdk.database .findMany("User", { $and: [ { hasTwoFa: true},{ twoFaMethod: 'phone'} ] }) .catch(e => { ConduitGrpcSdk.Logger.error(e); @@ -281,8 +281,8 @@ For example, if we want to count how many users have two-factor authentication e **countDocuments()** should be used.
An alternative but more complicated way of doing it is to use **findMany()** and calculate the length of the returned array. -```jsx title="Cunt documents" -await this.grpcSdk.database +```jsx title="Count documents" +const count: number = await this.grpcSdk.database .countDocuments("User",{ hasTwoFa: true }) .catch(e => { ConduitGrpcSdk.Logger.error(e); From a5a929a2e85d2188f5ca3739db91d0850babb7a3 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 14:31:36 +0200 Subject: [PATCH 20/30] feat(docs): storage --- .../version-v0.15/modules/email/sdk_usage.mdx | 4 +- .../modules/storage/sdk_usage.mdx | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx diff --git a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index 9c311ab..806e63a 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -6,7 +6,7 @@ ```jsx title="Send an email" import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; -await this.grpcSdk.sendEmail('template_name',{ +await this.grpcSdk.email.sendEmail('template_name',{ email : 'mail@example.com', sender: 'sendermail@example.com', variables: { @@ -25,7 +25,7 @@ To create a template with variables, do it by using [handlebars](https://handleb ### Template registration ```jsx title="Template registration" -await this.grpcSdk.registerTemplate({ +await this.grpcSdk.email.registerTemplate({ name: 'template_name', subject: 'subject', body: '

Hello, {{user}}. I hope you are doing well.', diff --git a/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx new file mode 100644 index 0000000..2070340 --- /dev/null +++ b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx @@ -0,0 +1,39 @@ +# SDK Usage +Using Conduit, it is simple to interact with storage systems. Storage SDK provides you with the ability +of creating, updating, and getting files since the storage provider is configured. You can also fetch the +data from an already existing file. + +## Create + +```jsx title="Create a file" +await this.grpcSdk.storage.createFile(name,mimeType,data,folder,isPublic) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` +## Get a file + +```jsx title="Get a file" +const file = await this.grpcSdk.storage.getFile(fileId) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +## Get file's data + +```jsx title="Get a file's data" +const data = await this.grpcSdk.storage.getFileData(fileId) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` + +## Update a file + +```jsx title="Get a file's data" +await this.grpcSdk.storage.updateFile(name,mimeType,data,folder,isPublic) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` \ No newline at end of file From 5ffbcab21147f1d04c4f6fc7b9bb4188e7b96555 Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 15:16:31 +0200 Subject: [PATCH 21/30] fix(docs): email fixes --- .../version-v0.15/modules/email/sdk_usage.mdx | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index 806e63a..a7a0d7f 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -1,16 +1,37 @@ # SDK Usage +Using the email module SDK, you can send emails using templates. The only requirement is that the template should be registered in the database. +Conduit provides a template mechanism. Templates can be created with or without variables. +To create a template with variables, do it by using [handlebars](https://handlebarsjs.com/guide/). +## Templates +### Template registration +To create a template in to the database we need to set four fields. +- **Name**: The name of the template +- **Subject**: The subject of the email template +- **Body**: The body of the template. Could also be html document. +- **Variables**: An array of strings which contain the names of the template variables. +```jsx title="Template registration" +await this.grpcSdk.email.registerTemplate({ + name: 'template_name', + subject: 'subject', + body: '

Hello, {{user}}. I hope you are doing well.

', + variables: ['user'] +}) +.catch(e => { + ConduitGrpcSdk.Logger.error(e); +}) +``` -## Sending an email - - +## Sending an email with templates +Sending emails with templates requires you to configure each template variable with a specific value. +For instance if you want the **user** variable to be rendered to "Conduit" you have to specify it. ```jsx title="Send an email" import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; await this.grpcSdk.email.sendEmail('template_name',{ email : 'mail@example.com', sender: 'sendermail@example.com', variables: { - 'variable1' : 'variable_value', + user : 'Conduit', } }) .catch(e => { @@ -18,20 +39,9 @@ await this.grpcSdk.email.sendEmail('template_name',{ }) ``` -## Templates -Conduit provides a template mechanism. Templates can be created with or without variables.
-To create a template with variables, do it by using [handlebars](https://handlebarsjs.com/guide/). - -### Template registration +This email will be rendered into this: +``` +

Helo, Conduit, I hope you are doing well

+``` -```jsx title="Template registration" -await this.grpcSdk.email.registerTemplate({ - name: 'template_name', - subject: 'subject', - body: '

Hello, {{user}}. I hope you are doing well.', - variables: ['user'] -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) -``` \ No newline at end of file +As you can see above, the ***User*** variable is replaced by the value we gave. \ No newline at end of file From fa0f6c2e00a80174be5abc93a97af17980fa2faf Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 15:26:40 +0200 Subject: [PATCH 22/30] fix(docs): database fixes --- .../versioned_docs/version-v0.15/modules/database/sdk_usage.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 1dbf1d1..d591ef8 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -136,7 +136,7 @@ In case of success, an array of schema documents will be returned to you. Deleting schemas could also be done by calling the SDK's deleteSchema() function. All you need is Schema's name. Remember that conduit allows you to delete the schema's created documents as well. -```jsx title="Getting registereds schemas" +```jsx title="Getting registered schemas" await this.grpcSdk.database.deleteSchema({ name: "someschemaname", deleteData: true // could be also false From fe1bba734d71ef88259f903c3e4f6175e689eefa Mon Sep 17 00:00:00 2001 From: dimitris Date: Mon, 5 Dec 2022 15:58:36 +0200 Subject: [PATCH 23/30] fix(docs): database fixes --- .../modules/database/sdk_usage.mdx | 83 +++++++++++-------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index d591ef8..4ebd502 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -1,8 +1,9 @@ # SDK Usage -Since database is up, its sdk comes up with a bunch of operations you could use. -To start playing with database you need to create a schema first. And **createSchemaFromAdapter()** -goes for it. +Since the database is up, its SDK comes up with a bunch of operations you could use. +In order to explain the functionality of the database SDK, we're going to extend +the [movie tutorial](./tutorials/cinema_ticket_booking).
+To start operating on schemas, you need to create one first. Let's create a movie schema using the SDK. ## Schema creation @@ -27,7 +28,7 @@ Name | Type | Description | | `default` | any | Default value of the field. | | `enum` | enum values | When a field has enum values. | -Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **description** **for_adults** and surely an **_id** field. +Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **director** , **description** **for_adults** and surely an **_id** field. So a possible schema could be this: ```jsx title="Movie schema" @@ -40,14 +41,13 @@ enum MoviesGenreEnum { const schema = { _id: TYPE.ObjectId, - title: { + name: { type: TYPE.String, unique: true, required: true, }, - title: { + director: { type: TYPE.String, - unique: true, required: true, }, duration: { @@ -66,7 +66,8 @@ const schema = { forAdults: { type: TYPE.Boolean, required: true, - } + }, + releaseDate: TYPE.Date, createdAt: TYPE.Date, updatedAt: TYPE.Date, } @@ -138,7 +139,7 @@ Remember that conduit allows you to delete the schema's created documents as wel ```jsx title="Getting registered schemas" await this.grpcSdk.database.deleteSchema({ - name: "someschemaname", + name: "Movies", deleteData: true // could be also false }) .catch(e => { @@ -158,7 +159,7 @@ Assume your goal is to add a field called **recoverEmail** which is used to reco ```jsx title="Set schema extension" await this.grpcSdk.database.setSchemaExtension({ - schemaName: "User", + schemaName: "Movies", extOwner: "database", extFields: { recoverEmail: { @@ -184,19 +185,19 @@ Suppose that we want to find a record with a specific id. ```jsx title="Set schema extension" const user = await this.grpcSdk.database - .findOne("User",{ _id: "someuserid"}) + .findOne("Movies",{ _id: "somemovieid"}) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); ``` ### findMany -For instance if we want to fetch all Users which have -enabled the 2FA using phone method ,then a query would be this: +For instance if we want to fetch all Movies that have +duration greater than 1 hour. ```jsx title="Finding many documents" -const users: User[] = await this.grpcSdk.database - .findMany("User", { $and: [ { hasTwoFa: true},{ twoFaMethod: 'phone'} ] }) +const movies: any[] = await this.grpcSdk.database + .findMany("Movies", { duration: { $gt: 60 } }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); @@ -204,12 +205,19 @@ const users: User[] = await this.grpcSdk.database ### create +Create operation is very simple. Just invoke the **create()** function through database sdk and fill the +necessary fields for document creation. + ```jsx title="Create a document" await this.grpcSdk.database - .create("User",{ - email: "example@mail.com", - password: "P@ssw0rD!@", - isVerified: true // could also be false + .create("Movies",{ + title: "The hobbit.", + duration: 165, + genre: "SCIFI", + description: "Tolkien rocks", + forAdults: false, + director: "Peter Jackson", + releaseDate: "13/12/2012" }) .catch(e => { ConduitGrpcSdk.Logger.error(e); @@ -221,14 +229,22 @@ await this.grpcSdk.database ```jsx title="Create many documents" await this.grpcSdk.database.createMany("User", [{ - email: "example@mail.com", - password: "P@ssw0rD!@", - isVerified: true // could also be false + title: "The hobbit.", + duration: 165, + genre: "SCIFI", + description: "Tolkien rocks", + forAdults: false, + director: "Peter Jackson", + releaseDate: "13/12/2012" }, { - email: "example1@mail.com", - password: "P@ssw0rD!@12", - isVerified: true + title: "The Spiderman", + duration: 200, + genre: "SCIFI", + description: "Marvel rocks", + forAdults: false, + director: "Sam Raimi", + releaseDate: "29/04/2002" }]) .catch(e => { ConduitGrpcSdk.Logger.error(e); @@ -238,12 +254,13 @@ await this.grpcSdk.database.createMany("User", ### updateMany In case of updating many documents given some constraints then we can use updateMany() function.
-Consider that we want to disable two-factor authentication for all users whose ids are contained in some array. +Consider that we want to make some movies for adults only.
+Movies id's have to be an array. ```jsx title="Update many documents " -const idArray = [userid1,userid2,userid3]; +const idArray = [movieid2,movieid2,movieid3]; await this.grpcSdk.database - .updaeteMany("User",{ _id :{ $in: idArray } },{ hasTwoFa: false}) + .updaeteMany("Movies",{ _id :{ $in: idArray } },{ forAdults: true }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); @@ -255,7 +272,7 @@ The only thing we need is the document ID we want to delete. ```jsx title="Update many documents " await this.grpcSdk.database - .deleteOne("User",{ _id : id }) + .deleteOne("Movies",{ _id : id }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); @@ -266,9 +283,9 @@ await this.grpcSdk.database Like updateMany we can use **deleteMany** to delete documents given some constraints. ```jsx title="Delete many documents " -const idArray = [userid1,userid2,userid3]; +const idArray = [movieid2,movieid2,movieid3]; await this.grpcSdk.database - .deleteMany("User",{ _id :{ $in: idArray } }) + .deleteMany("Movies",{ _id :{ $in: idArray } }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); @@ -277,13 +294,13 @@ await this.grpcSdk.database ### countDocuments Sometimes we only need to count how many documents exist with specific features. -For example, if we want to count how many users have two-factor authentication enabled, +For example, if we want to count how many movies are suitable only for. **countDocuments()** should be used.
An alternative but more complicated way of doing it is to use **findMany()** and calculate the length of the returned array. ```jsx title="Count documents" const count: number = await this.grpcSdk.database - .countDocuments("User",{ hasTwoFa: true }) + .countDocuments("Movies",{ forAdults: true }) .catch(e => { ConduitGrpcSdk.Logger.error(e); }); From f523deeb33a7e7d8241bfefe9901b2129600a2a2 Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Fri, 16 Dec 2022 13:57:56 +0200 Subject: [PATCH 24/30] fix(docs): authentication sdk usage fixes --- .../modules/authentication/sdk_usage.mdx | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index ec3a91c..44a717e 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -1,66 +1,59 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage +## User Creation -## User Login -Without requiring the user to log in first, this SDK function generates login credentials for them. -A user and a client must both have been created. - -```jsx title="User login" -await this.grpcSdk.authentication.userLogin({ - userId: "someuserid", - clientId : "someclientid" -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); -``` - -## User Create -It is necessary to explain how Conduit sdk is used to create a user. -As in dev, you can choose whether to verify a user when using the SDK.
-Sign up verification can also be enabled by sending an email. +You may easily create users (utilizing the [Local Authentication](./strategies#local) strategy) through the SDK.
+The `verify` boolean field specifies whether the newly created user **should verify themselves**. :::caution -If the [email module is not up and configured](../email/config) or the [send verification email](./config#local-authentication) option is not selected then the process will fail .
+User authentication requires that the Email module is available and [configured](../email/config).
+The Authentication module's Local Authentication strategy should also enable email verification. ::: -```jsx title="User login" -await this.grpcSdk.authentication.userCreate({ +[//]: # (TODO: Update verify naming) + +```ts +await grpcSdk.authentication.userCreate({ email: "somemail@example.com", password : "P@$$w0rd", verify: true, -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); }); ``` +## User Login -## User Delete +You may retrieve an access/refresh token pair for your users through the SDK.
+Specifying a [security client](../router/security.mdx) id for your login request is required. -No words needed to explain this sdk function usage. The only thing you need is the **userId** that you want to delete. +[//]: # (TODO: Update this once security clients are optional in gRPC) -```jsx title="User delete" -await this.grpcSdk.authentication.userDelete({ - userId: "someuserid" -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); +```ts +await grpcSdk.authentication.userLogin({ + userId: "someuserid", + clientId: "someclientid" }); +``` + +## User Deletion +```ts +await grpcSdk.authentication.userDelete({ + userId: "someuserid" +}); ``` -## Change Password +## Changing Passwords -No explanation needed either. Just type the new password and the email of the user, and you are ready. +You may update the passwords for any users utilizing [Local Authentication](./strategies#local). -```jsx title="Change user's password " -await this.grpcSdk.authentication.changePass({ +```ts +await grpcSdk.authentication.changePass({ email: "somemail@example.com", password: "newP@$$w0rd" -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); }); - -``` \ No newline at end of file +``` From 191c38be1b984abbd5a75c4851c608482b75e103 Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Fri, 16 Dec 2022 14:55:24 +0200 Subject: [PATCH 25/30] fix(docs): chat sdk usage fixes --- .../version-v0.15/modules/chat/sdk_usage.mdx | 81 ++++++++----------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx index 05c4e07..280809b 100644 --- a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx @@ -1,68 +1,57 @@ -# SDK Usage - -Chat sdk comes with three functionalities. Guess what ? You can create, delete rooms and send messages. -You might wonder "Why I can not update the room ?". And the answer is that is not implemented yet. +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- +# SDK Usage -## Create a room +## Room Creation Let's begin by creating a room. All you need is: - A participant array which include the participants user ids. - A room name. -```jsx title="Create a room" -const room = await this.grpcSdk.chat.createRoom({ - name: "roomname", - participants: ["userid1","userid2"], -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); +```ts title="Request" +await grpcSdk.chat.createRoom({ + name: "roomName", + participants: ["userId1", "userId2"], }); ``` - -In case of a successful chat room creation, the created room will be returned to you. - -```jsx title="Response" -room: { - Id: "roomid", - name: "roomname", - participants: ["userid1","userid2"] +```ts title="Response" +{ + room: { + _id: "roomId", + name: "roomName", + participants: ["userId1", "userId2"] + } } ``` -## Delete a room +## Room Deletion -Room id is only required for deleting it. - -```jsx title="Delete a room" -const deletedRoom = await this.grpcSdk.chat.deleteRoom({ - id: "roomid", - -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); +```ts title="Request" +await grpcSdk.chat.deleteRoom({ + id: "roomId", }); ``` -A room object will be returned to you if deletion takes place successfully. - -```jsx title="Response" -room: { - Id: "roomid", - name: "roomname", - participants: ["userid1","userid2"] +```ts title="Response" +{ + room: { + _id: "roomId", + name: "roomName", + participants: ["userId1", "userId2"] + } } ``` +## Sending Messages -## Send a message -Finally, sending a message to a room is also an easy operation. To send a message, you have to belong to the room and to be logged in as a user. +Before sending a message to a group, make sure the user you're sending it as is already a member of the group. -```jsx title="Delete a room" -const message = await this.grpcSdk.chat.sendMessage({ - roomId: "roomid", +```ts title="Request" +await grpcSdk.chat.sendMessage({ + userId: "userId", + roomId: "roomId", message: "Hello Conduit users!" -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); }); -``` \ No newline at end of file +``` From a7589f2cd7287f86c9928d62c786f7339ed7f202 Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Fri, 16 Dec 2022 15:36:14 +0200 Subject: [PATCH 26/30] fix(docs): initial wip database sdk usage fixes --- .../modules/database/sdk_usage.mdx | 228 ++++++++---------- 1 file changed, 101 insertions(+), 127 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 4ebd502..7a1cb54 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -1,3 +1,8 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage Since the database is up, its SDK comes up with a bunch of operations you could use. @@ -5,7 +10,7 @@ In order to explain the functionality of the database SDK, we're going to extend the [movie tutorial](./tutorials/cinema_ticket_booking).
To start operating on schemas, you need to create one first. Let's create a movie schema using the SDK. -## Schema creation +## Schema Creation Create schema from adapter accepts a JSON schema as an argument, and it stores into the database. Additional arguments are required such as: @@ -21,12 +26,12 @@ Schema fields represent the whole schema. Each field may have: Name | Type | Description | | ---- | ---- | ----------- | | `type` | TYPE | Could be TYPE.(String,Number,Boolean etc.)| -| `required` | boolean | Indicates if a field is required. | -| `unique` | boolean | Indicates if a field is unique. | -| `select` | boolean | Indicates if a field could be retreived from a query. | +| `required` | boolean | Indicates whether a field is required. | +| `unique` | boolean | Indicates whether a field is unique. | +| `select` | boolean | Indicates whether a field could be retreived from a query. | | `description` | string | Description of the field, | | `default` | any | Default value of the field. | -| `enum` | enum values | When a field has enum values. | +| `enum` | enum values | When a field has enum values. | Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **director** , **description** **for_adults** and surely an **_id** field. So a possible schema could be this: @@ -102,75 +107,64 @@ const modelOptions = { } as const; ``` -## Schema creation +## Schema Creation -The final step is to call the createSchemaFromAdapter() function. -```jsx title="Create schema from adapter" -await this.grpcSdk.database.createSchemaFromAdapter({ +```ts title="Request" +await grpcSdk.database.createSchemaFromAdapter({ name: "Movies", fields: schema, modelOptions: modelOptions, collectionName: "", // could be 'Movies' also -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +}); ``` -## Getting schemas - -The functionality of list schemas is also available in grpc-sdk.Fetching registered schemas could be done -by invoking the **getSchemas()** method -In detail: +## Schema Retrieval -```jsx title="Getting registereds schemas" -await this.grpcSdk.database.getSchemas({}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.database.getSchemas({}); ``` -In case of success, an array of schema documents will be returned to you. - -## Delete schema +## Schema Deletion Deleting schemas could also be done by calling the SDK's deleteSchema() function. All you need is Schema's name. Remember that conduit allows you to delete the schema's created documents as well. -```jsx title="Getting registered schemas" -await this.grpcSdk.database.deleteSchema({ +```ts title="Request" +await grpcSdk.database.deleteSchema({ name: "Movies", deleteData: true // could be also false -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +}); ``` -## Schema extensions +## Extending Schemas + +Most Conduit modules need to register schemas and perform database queries for their data.
+These schemas are usually limited to the functionality that's required for their owner's internal operations. + +The Authentication module, for instance, registers a plain `User` schema, containing just enough descriptor fields for its authentication strategies.
+The `User` schema doesn't make any assumptions in regard to how user-facing apps would account for additional user-related information. -What about adding extra fields to system schemas? You can accomplish this by using **setSchemaExtension()**. -Existing schemas, such as User, EmailTemplate, Client, and so on, can be extended. -Extending the Conduit User schema is a great example of usage.
-Assume that the existing user schema does not account for your specific project's preferences. You can make changes to the existing schema. -You are free to include any field you want.
-Assume your goal is to add a field called **recoverEmail** which is used to recover an account if the initial email is misplaced or forgotten. +Suppose your use case requires that you keep track of a user's first and last names.
+Traditionally, you would register your own `UserInfo` schema, including these fields as well as a relation field to the `User` entry they reference.
+Instead, Conduit lets you extend the main `User` schema, appending the fields you deem necessary, +as long as they are not part of the schema's base fields or otherwise already provided through another modules' extension on the same schema. -```jsx title="Set schema extension" -await this.grpcSdk.database.setSchemaExtension({ +```ts title="Request" +await grpcSdk.database.setSchemaExtension({ schemaName: "Movies", - extOwner: "database", + extOwner: "yourModule", extFields: { - recoverEmail: { + firstName: { type: "String", - required: "false", - } - } -}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) + required: "true", + }, + lastName: { + type: "String", + required: "true", + }, + }, +}); ``` Now the User schema includes this new field called **recoverEmail**. @@ -180,58 +174,51 @@ Now the User schema includes this new field called **recoverEmail**. Conduit models provide several static helper functions for CRUD operations.
Queries are structured Mongoose-like. To see Conduit's query language click [here](./operators). -### findOne -Suppose that we want to find a record with a specific id. +### Document Retrieval + +Suppose we wish to find a record with a specific id. -```jsx title="Set schema extension" -const user = await this.grpcSdk.database - .findOne("Movies",{ _id: "somemovieid"}) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database + .findOne("Movies",{ _id: "someMovieId" }); ``` -### findMany -For instance if we want to fetch all Movies that have -duration greater than 1 hour. +### Multi-Document Retrieval -```jsx title="Finding many documents" -const movies: any[] = await this.grpcSdk.database - .findMany("Movies", { duration: { $gt: 60 } }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +Suppose we want to fetch all Movies that have a duration greater than 1 hour. + +```ts title="Request" +await grpcSdk.database + .findMany("Movies", { duration: { $gt: 60 } }); ``` -### create +### Document Creation Create operation is very simple. Just invoke the **create()** function through database sdk and fill the necessary fields for document creation. -```jsx title="Create a document" -await this.grpcSdk.database - .create("Movies",{ - title: "The hobbit.", - duration: 165, - genre: "SCIFI", - description: "Tolkien rocks", - forAdults: false, - director: "Peter Jackson", - releaseDate: "13/12/2012" - }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database + .create("Movies",{ + title: "The Hobbit", + duration: 165, + genre: "scifi", + description: "Tolkien rocks", + forAdults: false, + director: "Peter Jackson", + releaseDate: "13/12/2012" + }); ``` -### createMany +### Multi-Document Creation -```jsx title="Create many documents" -await this.grpcSdk.database.createMany("User", - [{ - title: "The hobbit.", +```ts title="Request" +await grpcSdk.database.createMany("User", + [ + { + title: "The Hobbit", duration: 165, - genre: "SCIFI", + genre: "scifi", description: "Tolkien rocks", forAdults: false, director: "Peter Jackson", @@ -240,68 +227,55 @@ await this.grpcSdk.database.createMany("User", { title: "The Spiderman", duration: 200, - genre: "SCIFI", + genre: "scifi", description: "Marvel rocks", forAdults: false, director: "Sam Raimi", releaseDate: "29/04/2002" - }]) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); + }, + ] +); ``` -### updateMany -In case of updating many documents given some constraints then we can use updateMany() function.
-Consider that we want to make some movies for adults only.
-Movies id's have to be an array. +### Multi-Document Updates -```jsx title="Update many documents " -const idArray = [movieid2,movieid2,movieid3]; -await this.grpcSdk.database - .updaeteMany("Movies",{ _id :{ $in: idArray } },{ forAdults: true }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +We can use `updateMany()`to update multiple documents given some optional constraints.
+Suppose we wish to discontinue some movies from an online streaming service. + +```ts title="Request" +const discontinuedMovies = [movieId2, movieId2,movieId3]; +await grpcSdk.database + .updaeteMany("Movies",{ _id: { $in: discontinuedMovies } }, { discontinued: true }); ``` -### deleteOne +### Document Deletion The only thing we need is the document ID we want to delete. -```jsx title="Update many documents " -await this.grpcSdk.database - .deleteOne("Movies",{ _id : id }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database + .deleteOne("Movies",{ _id : id }); ``` -### deleteMany +### Multi-Document Deletion -Like updateMany we can use **deleteMany** to delete documents given some constraints. +Like updateMany we can use `deleteMany` to delete documents given some constraints. -```jsx title="Delete many documents " -const idArray = [movieid2,movieid2,movieid3]; -await this.grpcSdk.database - .deleteMany("Movies",{ _id :{ $in: idArray } }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +const idArray = [movieid2, movieid2, movieid3]; +await grpcSdk.database + .deleteMany("Movies",{ _id :{ $in: idArray } }); ``` -### countDocuments +### Document Count Sometimes we only need to count how many documents exist with specific features. For example, if we want to count how many movies are suitable only for. **countDocuments()** should be used.
An alternative but more complicated way of doing it is to use **findMany()** and calculate the length of the returned array. -```jsx title="Count documents" -const count: number = await this.grpcSdk.database - .countDocuments("Movies",{ forAdults: true }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database + .countDocuments("Movies",{ forAdults: true }); ``` From 811dae80f4c3eb8b42186bb474316e4657fbcafc Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Fri, 16 Dec 2022 15:38:05 +0200 Subject: [PATCH 27/30] fix(docs): remaining sdk usage page sidebar metadata --- .../version-v0.15/modules/email/sdk_usage.mdx | 7 +++++++ .../version-v0.15/modules/push-notifications/sdk_usage.mdx | 5 +++++ .../versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx | 6 ++++++ .../version-v0.15/modules/storage/sdk_usage.mdx | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index a7a0d7f..5cb8422 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -1,7 +1,14 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage + Using the email module SDK, you can send emails using templates. The only requirement is that the template should be registered in the database. Conduit provides a template mechanism. Templates can be created with or without variables. To create a template with variables, do it by using [handlebars](https://handlebarsjs.com/guide/). + ## Templates ### Template registration diff --git a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx index 3e3a710..91c8e8e 100644 --- a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx @@ -1,3 +1,8 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage Depending on the configured provider, Conduit SDK provides push notification utilities.For now, only Firebase and OneSignal providers are implemented.
diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index e273298..26ca4f3 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -1,4 +1,10 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage + Underworld has to know about Conduit Platform. Just use sms module to do it. :::caution diff --git a/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx index 2070340..d84bf53 100644 --- a/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx @@ -1,4 +1,10 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 100 +--- + # SDK Usage + Using Conduit, it is simple to interact with storage systems. Storage SDK provides you with the ability of creating, updating, and getting files since the storage provider is configured. You can also fetch the data from an already existing file. From b2d71f2f66c1811c5274fcbfa173091215b9b73f Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Fri, 16 Dec 2022 15:53:42 +0200 Subject: [PATCH 28/30] fix(docs): chat sdk usage room response --- .../versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx index 280809b..e8a05b8 100644 --- a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx @@ -20,7 +20,7 @@ await grpcSdk.chat.createRoom({ ```ts title="Response" { room: { - _id: "roomId", + Id: "roomId", name: "roomName", participants: ["userId1", "userId2"] } @@ -37,7 +37,7 @@ await grpcSdk.chat.deleteRoom({ ```ts title="Response" { room: { - _id: "roomId", + Id: "roomId", name: "roomName", participants: ["userId1", "userId2"] } From a7bfc0a095f0cc7baf3598c4fa574d41b7d9fda0 Mon Sep 17 00:00:00 2001 From: dimitris Date: Thu, 22 Dec 2022 12:59:10 +0200 Subject: [PATCH 29/30] fix(docs): requested changes --- .../modules/authentication/sdk_usage.mdx | 42 ++++---- .../version-v0.15/modules/chat/sdk_usage.mdx | 36 +++---- .../modules/database/sdk_usage.mdx | 100 +++++------------- .../version-v0.15/modules/email/sdk_usage.mdx | 15 +-- .../modules/push-notifications/sdk_usage.mdx | 29 ++--- .../version-v0.15/modules/sms/sdk_usage.mdx | 32 +++--- .../modules/storage/sdk_usage.mdx | 41 +++---- 7 files changed, 115 insertions(+), 180 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index ec3a91c..6b26e2f 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -1,3 +1,8 @@ +--- +sidebar_label: 'SDK Usage' +sidebar_position: 5 +--- + # SDK Usage @@ -5,14 +10,18 @@ Without requiring the user to log in first, this SDK function generates login credentials for them. A user and a client must both have been created. -```jsx title="User login" -await this.grpcSdk.authentication.userLogin({ +```ts title="Request" +await grpcSdk.authentication.userLogin({ userId: "someuserid", clientId : "someclientid" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); +``` + +```ts title="Response" +{ + "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyNDJmMWJiMTBhMDk5MDE4Mjc3MzhmZSIsImlhdCI6MTY0ODU1NDUyNywiZXhwIjoxNzM0OTU0NTI3fQ.Fjqa7ORBBF2giwG7OgiWr2HMgHDL7R6ddFq2E730Djc", + "refreshToken": "BsKhe3ARhL/FfDfK1REphKkkqQaxRCj/LvvRHOg5wCXCBaUSOwafRHyFYIttaORY/NmHS7NAuT6+knBQegVOwQ==" +} ``` ## User Create @@ -24,15 +33,12 @@ Sign up verification can also be enabled by sending an email. If the [email module is not up and configured](../email/config) or the [send verification email](./config#local-authentication) option is not selected then the process will fail .
::: -```jsx title="User login" -await this.grpcSdk.authentication.userCreate({ +```ts title="Request" +await grpcSdk.authentication.userCreate({ email: "somemail@example.com", password : "P@$$w0rd", verify: true, }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` @@ -40,27 +46,19 @@ await this.grpcSdk.authentication.userCreate({ No words needed to explain this sdk function usage. The only thing you need is the **userId** that you want to delete. -```jsx title="User delete" -await this.grpcSdk.authentication.userDelete({ +```ts title="Request" +await grpcSdk.authentication.userDelete({ userId: "someuserid" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); - ``` ## Change Password No explanation needed either. Just type the new password and the email of the user, and you are ready. -```jsx title="Change user's password " -await this.grpcSdk.authentication.changePass({ +```ts title="Request" +await grpcSdk.authentication.changePass({ email: "somemail@example.com", password: "newP@$$w0rd" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); - ``` \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx index 05c4e07..5ec6477 100644 --- a/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/chat/sdk_usage.mdx @@ -10,20 +10,25 @@ Let's begin by creating a room. All you need is: - A participant array which include the participants user ids. - A room name. -```jsx title="Create a room" -const room = await this.grpcSdk.chat.createRoom({ +```ts title="Response" +await grpcSdk.chat.createRoom({ name: "roomname", participants: ["userid1","userid2"], }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); +``` + +```ts title="Response" +room: { + Id: "roomid", + name: "roomname", + participants: ["userid1","userid2"] +} ``` In case of a successful chat room creation, the created room will be returned to you. -```jsx title="Response" -room: { +```ts title="Response" +{ Id: "roomid", name: "roomname", participants: ["userid1","userid2"] @@ -34,18 +39,14 @@ room: { Room id is only required for deleting it. -```jsx title="Delete a room" -const deletedRoom = await this.grpcSdk.chat.deleteRoom({ +```jsx title="Request" +await grpcSdk.chat.deleteRoom({ id: "roomid", - }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` A room object will be returned to you if deletion takes place successfully. -```jsx title="Response" +```ts title="Response" room: { Id: "roomid", name: "roomname", @@ -57,12 +58,9 @@ room: { ## Send a message Finally, sending a message to a room is also an easy operation. To send a message, you have to belong to the room and to be logged in as a user. -```jsx title="Delete a room" -const message = await this.grpcSdk.chat.sendMessage({ +```ts title="Response" +await grpcSdk.chat.sendMessage({ roomId: "roomid", message: "Hello Conduit users!" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 4ebd502..29c1fe4 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -31,7 +31,7 @@ Name | Type | Description | Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **director** , **description** **for_adults** and surely an **_id** field. So a possible schema could be this: -```jsx title="Movie schema" +```ts title="Movie schema" enum MoviesGenreEnum { THRILLER = "THRILLER", COMEDY = "COMEDY", @@ -63,10 +63,6 @@ const schema = { required: false, unique: false, }, - forAdults: { - type: TYPE.Boolean, - required: true, - }, releaseDate: TYPE.Date, createdAt: TYPE.Date, updatedAt: TYPE.Date, @@ -88,7 +84,7 @@ Name | Type | Description | A modelOptions object could be this: -```jsx title="Model options object" +```ts title="Model options object" const modelOptions = { timestamps: true, conduit: { @@ -105,16 +101,13 @@ const modelOptions = { ## Schema creation The final step is to call the createSchemaFromAdapter() function. -```jsx title="Create schema from adapter" -await this.grpcSdk.database.createSchemaFromAdapter({ +```jsx title="Request" +await grpcSdk.database.createSchemaFromAdapter({ name: "Movies", fields: schema, modelOptions: modelOptions, collectionName: "", // could be 'Movies' also }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` ## Getting schemas @@ -123,11 +116,8 @@ The functionality of list schemas is also available in grpc-sdk.Fetching registe by invoking the **getSchemas()** method In detail: -```jsx title="Getting registereds schemas" -await this.grpcSdk.database.getSchemas({}) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.database.getSchemas({}) ``` In case of success, an array of schema documents will be returned to you. @@ -137,14 +127,11 @@ In case of success, an array of schema documents will be returned to you. Deleting schemas could also be done by calling the SDK's deleteSchema() function. All you need is Schema's name. Remember that conduit allows you to delete the schema's created documents as well. -```jsx title="Getting registered schemas" -await this.grpcSdk.database.deleteSchema({ +```ts title="Request" +await grpcSdk.database.deleteSchema({ name: "Movies", deleteData: true // could be also false }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` @@ -157,8 +144,8 @@ Assume that the existing user schema does not account for your specific project' You are free to include any field you want.
Assume your goal is to add a field called **recoverEmail** which is used to recover an account if the initial email is misplaced or forgotten. -```jsx title="Set schema extension" -await this.grpcSdk.database.setSchemaExtension({ +```jsx title="Request" +await grpcSdk.database.setSchemaExtension({ schemaName: "Movies", extOwner: "database", extFields: { @@ -168,9 +155,6 @@ await this.grpcSdk.database.setSchemaExtension({ } } }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` Now the User schema includes this new field called **recoverEmail**. @@ -183,24 +167,16 @@ Queries are structured Mongoose-like. To see Conduit's query language click [her ### findOne Suppose that we want to find a record with a specific id. -```jsx title="Set schema extension" -const user = await this.grpcSdk.database - .findOne("Movies",{ _id: "somemovieid"}) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database.findOne("Movies",{ _id: "somemovieid"}) ``` ### findMany For instance if we want to fetch all Movies that have duration greater than 1 hour. -```jsx title="Finding many documents" -const movies: any[] = await this.grpcSdk.database - .findMany("Movies", { duration: { $gt: 60 } }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +await grpcSdk.database.findMany("Movies", { duration: { $gt: 60 } }) ``` ### create @@ -208,32 +184,27 @@ const movies: any[] = await this.grpcSdk.database Create operation is very simple. Just invoke the **create()** function through database sdk and fill the necessary fields for document creation. -```jsx title="Create a document" -await this.grpcSdk.database +```ts title="Request" +await grpcSdk.database .create("Movies",{ title: "The hobbit.", duration: 165, genre: "SCIFI", description: "Tolkien rocks", - forAdults: false, director: "Peter Jackson", releaseDate: "13/12/2012" }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); ``` ### createMany -```jsx title="Create many documents" +```ts title="Request" await this.grpcSdk.database.createMany("User", [{ title: "The hobbit.", duration: 165, genre: "SCIFI", description: "Tolkien rocks", - forAdults: false, director: "Peter Jackson", releaseDate: "13/12/2012" }, @@ -242,53 +213,39 @@ await this.grpcSdk.database.createMany("User", duration: 200, genre: "SCIFI", description: "Marvel rocks", - forAdults: false, director: "Sam Raimi", releaseDate: "29/04/2002" }]) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); ``` ### updateMany In case of updating many documents given some constraints then we can use updateMany() function.
-Consider that we want to make some movies for adults only.
Movies id's have to be an array. -```jsx title="Update many documents " +```ts title="Request" const idArray = [movieid2,movieid2,movieid3]; -await this.grpcSdk.database - .updaeteMany("Movies",{ _id :{ $in: idArray } },{ forAdults: true }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +await grpcSdk.database + .updaeteMany("Movies",{ _id :{ $in: idArray } }) ``` ### deleteOne The only thing we need is the document ID we want to delete. -```jsx title="Update many documents " -await this.grpcSdk.database +```ts title="Request" +await grpcSdk.database .deleteOne("Movies",{ _id : id }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); ``` ### deleteMany Like updateMany we can use **deleteMany** to delete documents given some constraints. -```jsx title="Delete many documents " +```ts title="Request" const idArray = [movieid2,movieid2,movieid3]; -await this.grpcSdk.database +await grpcSdk.database .deleteMany("Movies",{ _id :{ $in: idArray } }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); ``` ### countDocuments @@ -298,10 +255,7 @@ For example, if we want to count how many movies are suitable only for. **countDocuments()** should be used.
An alternative but more complicated way of doing it is to use **findMany()** and calculate the length of the returned array. -```jsx title="Count documents" -const count: number = await this.grpcSdk.database - .countDocuments("Movies",{ forAdults: true }) - .catch(e => { - ConduitGrpcSdk.Logger.error(e); - }); +```ts title="Request" +grpcSdk.database + .countDocuments("Movies",{ genre: 'SCIFI' }) ``` diff --git a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx index a7a0d7f..7da49f2 100644 --- a/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/email/sdk_usage.mdx @@ -10,33 +10,26 @@ To create a template in to the database we need to set four fields. - **Subject**: The subject of the email template - **Body**: The body of the template. Could also be html document. - **Variables**: An array of strings which contain the names of the template variables. -```jsx title="Template registration" -await this.grpcSdk.email.registerTemplate({ +```ts title="Request" +await grpcSdk.email.registerTemplate({ name: 'template_name', subject: 'subject', body: '

Hello, {{user}}. I hope you are doing well.

', variables: ['user'] }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` ## Sending an email with templates Sending emails with templates requires you to configure each template variable with a specific value. For instance if you want the **user** variable to be rendered to "Conduit" you have to specify it. -```jsx title="Send an email" -import ConduitGrpcSdk from '@conduitplatform/grpc-sdk'; -await this.grpcSdk.email.sendEmail('template_name',{ +```ts title="Request" +await grpcSdk.email.sendEmail('template_name',{ email : 'mail@example.com', sender: 'sendermail@example.com', variables: { user : 'Conduit', } }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` This email will be rendered into this: diff --git a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx index 3e3a710..e0d4675 100644 --- a/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/push-notifications/sdk_usage.mdx @@ -25,27 +25,21 @@ A reasonable question is "How is a notification token related to a user?" Condui Using the **setNotificationToken()** SDK function, you can "relate" a token to a user. -```jsx title=" Set notification token" -await this.grpcSdk.pushNotifications.setNotificationToken({ +```ts title="Request" +await grpcSdk.pushNotifications.setNotificationToken({ token: "applicationtoken", platform: "WEB", // could be also ANDROID,IOS,MACOS,LINUX,CLI,IPADOS userId: "someuserid", // user related with this token }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` ## Get notification token Getting a user's notification token will be an easy process. Just call getNotificationTokens() function. -```jsx title=" Get notification tokens" -const tokens = await this.grpcSdk.pushNotifications.getNotificationTokens({ +```ts title="Request" +await grpcSdk.pushNotifications.getNotificationTokens({ userId: "someuserid", // user related with this token }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` Response will include an array of Notification Token Object @@ -62,15 +56,12 @@ tokens: [{ Congratulations! You are now ready to send push notifications. -```jsx title="Send notification" -const response= await this.grpcSdk.pushNotifications.sendNotification({ +```ts title="Request" +await grpcSdk.pushNotifications.sendNotification({ sendTo: "diresuemos", title: "Hello 666.I have a message for you.", body: "Conduit will send you to heaven.Try it." }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` Appropriate message will be returned to you if everything went well. ```jsx title="Response" @@ -82,13 +73,11 @@ response: { ## Send many notifications There is a "plus" function for sending push notifications to many users concurrently. -```jsx title="Send Notifications" -await this.grpcSdk.pushNotifications.sendToManyDevices({ +```ts title="Request" +await grpcSdk.pushNotifications.sendToManyDevices({ sendTo: ["diresuemos","somueserid2","someuserid3"], title: "Hello 666.I have a message for you.", body: "Conduit will send you to heaven.Try it." }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); + ``` \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx index e273298..8c5e6d9 100644 --- a/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/sms/sdk_usage.mdx @@ -7,14 +7,11 @@ Sms module has to be configured with the proper provider. ## Send Sms -```jsx title="Send sms" -this.grpcSdk.sms.sendSms({ +```ts title="Request" +await grpcSdk.sms.sendSms({ to: "+6666666666", message: "Hello. Conduit rocks!" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); ``` ## Verify via sms @@ -22,26 +19,31 @@ this.grpcSdk.sms.sendSms({ Conduit provides a verification mechanism by sending SMS. You can verify everything in two steps.
The **sendVerificationCode** function will be used to send a verification code to the user in the first step. -```jsx title="Send verification code" -const verificationSid = await this.grpcSdk.sms.sendVerificationCode({ +```ts title="Request" +await grpcSdk.sms.sendVerificationCode({ to: "+6666666666", }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}); +``` + +```ts title="Response" +{ + "verificationSid": string +} ``` A verificationSid will be returned to you. Also, a code will be sent to the user. To proceed to the next and final step you have to use these to make the verification -```jsx title="Verify" -const verified = await this.grpcSdk.sms.verify({ +```ts title="Request" +await grpcSdk.sms.verify({ verificationSid : "someverificationsid", code: "verificationcode" }) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) ``` +```ts title="Response" +{ + "verfied": boolean, +} +``` If verification process went well then the returned value will be true. \ No newline at end of file diff --git a/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx index 2070340..1ea836f 100644 --- a/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/storage/sdk_usage.mdx @@ -5,35 +5,36 @@ data from an already existing file. ## Create -```jsx title="Create a file" -await this.grpcSdk.storage.createFile(name,mimeType,data,folder,isPublic) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.storage.createFile(name,mimeType,data,folder,isPublic) +``` + +```ts title="Response" +{ + "id": "fileid", + "url": "fileurl", + "name": "fileName" +} ``` ## Get a file -```jsx title="Get a file" -const file = await this.grpcSdk.storage.getFile(fileId) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.storage.getFile(fileId) ``` ## Get file's data -```jsx title="Get a file's data" -const data = await this.grpcSdk.storage.getFileData(fileId) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.storage.getFileData(fileId) ``` +```ts title="Response" +{ + "data": "stringifiedFileData" +} +``` ## Update a file -```jsx title="Get a file's data" -await this.grpcSdk.storage.updateFile(name,mimeType,data,folder,isPublic) -.catch(e => { - ConduitGrpcSdk.Logger.error(e); -}) +```ts title="Request" +await grpcSdk.storage.updateFile(name,mimeType,data,folder,isPublic) ``` \ No newline at end of file From 73a3a6caf7aabbe7479ebfe2854c13b635dc0402 Mon Sep 17 00:00:00 2001 From: dimitris Date: Thu, 22 Dec 2022 13:04:13 +0200 Subject: [PATCH 30/30] fix(docs): requested changes --- .../modules/authentication/sdk_usage.mdx | 13 ++++++++++--- .../version-v0.15/modules/database/sdk_usage.mdx | 11 ++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx index 44a717e..0ebce49 100644 --- a/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/authentication/sdk_usage.mdx @@ -32,16 +32,23 @@ Specifying a [security client](../router/security.mdx) id for your login request [//]: # (TODO: Update this once security clients are optional in gRPC) -```ts +```ts title="Request" await grpcSdk.authentication.userLogin({ userId: "someuserid", clientId: "someclientid" }); ``` +```ts title="Response" +{ + "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyNDJmMWJiMTBhMDk5MDE4Mjc3MzhmZSIsImlhdCI6MTY0ODU1NDUyNywiZXhwIjoxNzM0OTU0NTI3fQ.Fjqa7ORBBF2giwG7OgiWr2HMgHDL7R6ddFq2E730Djc", + "refreshToken": "BsKhe3ARhL/FfDfK1REphKkkqQaxRCj/LvvRHOg5wCXCBaUSOwafRHyFYIttaORY/NmHS7NAuT6+knBQegVOwQ==" +} +``` + ## User Deletion -```ts +```ts title="Request" await grpcSdk.authentication.userDelete({ userId: "someuserid" }); @@ -51,7 +58,7 @@ await grpcSdk.authentication.userDelete({ You may update the passwords for any users utilizing [Local Authentication](./strategies#local). -```ts +```ts title="Request" await grpcSdk.authentication.changePass({ email: "somemail@example.com", password: "newP@$$w0rd" diff --git a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx index 7a1cb54..31c6e9c 100644 --- a/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx +++ b/documentation/versioned_docs/version-v0.15/modules/database/sdk_usage.mdx @@ -33,7 +33,7 @@ Name | Type | Description | | `default` | any | Default value of the field. | | `enum` | enum values | When a field has enum values. | -Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **director** , **description** **for_adults** and surely an **_id** field. +Assume that we want to create a movie schema. A movie may have **title** , **genre**, **duration**, **director** , **description** and surely an **_id** field. So a possible schema could be this: ```jsx title="Movie schema" @@ -68,10 +68,6 @@ const schema = { required: false, unique: false, }, - forAdults: { - type: TYPE.Boolean, - required: true, - }, releaseDate: TYPE.Date, createdAt: TYPE.Date, updatedAt: TYPE.Date, @@ -204,7 +200,6 @@ await grpcSdk.database duration: 165, genre: "scifi", description: "Tolkien rocks", - forAdults: false, director: "Peter Jackson", releaseDate: "13/12/2012" }); @@ -220,7 +215,6 @@ await grpcSdk.database.createMany("User", duration: 165, genre: "scifi", description: "Tolkien rocks", - forAdults: false, director: "Peter Jackson", releaseDate: "13/12/2012" }, @@ -229,7 +223,6 @@ await grpcSdk.database.createMany("User", duration: 200, genre: "scifi", description: "Marvel rocks", - forAdults: false, director: "Sam Raimi", releaseDate: "29/04/2002" }, @@ -277,5 +270,5 @@ An alternative but more complicated way of doing it is to use **findMany()** and ```ts title="Request" await grpcSdk.database - .countDocuments("Movies",{ forAdults: true }); + .countDocuments("Movies",{ genre: "SCIFI" }); ```