Skip to content

Commit

Permalink
Merge pull request #1859 from bakaphp/development
Browse files Browse the repository at this point in the history
Version 1.1
  • Loading branch information
kaioken authored Aug 26, 2024
2 parents 7c06cd1 + d57cda7 commit dd451eb
Show file tree
Hide file tree
Showing 47 changed files with 1,198 additions and 179 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,33 @@ Todo:

## Initial Setup

1. Use the ``docker compose up --build -d`` to bring up the containers.Make sure to have Docker Desktop active and have no other containers running that may cause conflict with this project's containers(There may be conflicts port wise if more than one container uses the same ports).
1. Use the ``docker compose up --build -d`` to bring up the containers. Make sure to have Docker Desktop active and have no other containers running that may cause conflict with this project's containers(There may be conflicts port wise if more than one container uses the same ports).

2. Check the status of containers using the command ```docker-compose ps```. Make sure they are running and services are healthy.

3. Get inside the php container using ```docker exec -it php bash```.
3. Get inside the database container using ```docker exec -it mysqlLaravel /bin/bash```. Then, create 4 databases: `inventory`, `social`, `crm`, `workflow`.

4. Create 4 databases `inventory`, `social`, `crm`, `workflow` update your .env with the connection info
4. Set up your .env: You can start by copying the `.env.example setup`. Next, update it with the database and Redis connection info, making sure that the host values match your container's name.

5. Check the .env and setup correctly the `REDIS` parameters and your database connections before running the setup-ecosystem
5. Get inside the php container using ```docker exec -it phpLaravel bash```.

6. Use the command ```php artisan kanvas:setup-ecosystem``` to run the kanvas setup
6. Generate app keys with `php artisan key:generate`.
**Note:** Confirm that your app key is correctly registered in the `apps` table within the `kanvas_laravel` database.

7. If you're presenting some errors after running the command from before, drop all the tables from the schema `kanvas_laravel` and run it again
7. Update the app variables in your .env `APP_JWT_TOKEN`, `APP_KEY`, `KANVAS_APP_ID` before running the setup-ecosystem.
**Note:** You can use the default values provided in `tests.yml`.

8. Generate app keys `php artisan key:generate`
8. Use the command ```php artisan kanvas:setup-ecosystem``` to run the kanvas setup.

9. To check if the API is working just make a GET request to ```http://localhost:80/v1/``` and see if the response returns ```"Woot Kanvas"```
9. If you're presenting some errors after running the command from before, drop all the tables from the schema `kanvas_laravel` and run it again.

10. To check if the API is working just make a GET request to ```http://localhost:80/v1/``` and see if the response returns ```"Woot Kanvas"```.

### Setup Inventory
1. composer migrate-inventory
2. Set env var in .env
```
DB_INVENTORY_HOST=mysql
DB_INVENTORY_HOST=mysqlLaravel
DB_INVENTORY_PORT=3306
DB_INVENTORY_DATABASE=inventory
DB_INVENTORY_USERNAME=root
Expand All @@ -76,7 +80,7 @@ DB_INVENTORY_PASSWORD=password
1. composer migrate-social
2. Set env var in .env
```
DB_SOCIAL_HOST=mysql
DB_SOCIAL_HOST=mysqlLaravel
DB_SOCIAL_PORT=3306
DB_SOCIAL_DATABASE=social
DB_SOCIAL_USERNAME=root
Expand All @@ -89,7 +93,7 @@ DB_SOCIAL_PASSWORD=password
1. composer migrate-crm
2. Set env var in .env
```
DB_CRM_HOST=mysql
DB_CRM_HOST=mysqlLaravel
DB_CRM_PORT=3306
DB_CRM_DATABASE=cr
DB_CRM_USERNAME=root
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands\Connectors\Shopify;

use Illuminate\Console\Command;
use Kanvas\Connectors\Shopify\Actions\UploadCategoriesToCollectionAction;
use Kanvas\Apps\Models\Apps;
use Kanvas\Inventory\Categories\Models\Categories;
use Kanvas\Inventory\Warehouses\Models\Warehouses;

class ShopifyUploadCategoryCommand extends Command
{
protected $signature = "kanvas:upload-categories-to-shopify {app_id} {categories_id} {warehouse_id} {shopify_id}";
protected $description = "
";

public function handle()
{
$app = Apps::getById((int) $this->argument('app_id'));
$categories = Categories::getById((int) $this->argument('categories_id'), $app);
$warehouses = Warehouses::getById((int) $this->argument('warehouse_id'), $app);
$shopifyId = $this->argument('shopify_id');
(new UploadCategoriesToCollectionAction($categories, $app, $warehouses, $shopifyId))->execute();
}
}
44 changes: 44 additions & 0 deletions app/Console/Commands/Guild/GuildDailyReportCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands\Guild;

use Baka\Traits\KanvasJobsTrait;
use Illuminate\Console\Command;
use Kanvas\Apps\Models\Apps;
use Kanvas\Companies\Models\Companies;
use Kanvas\Connectors\Apollo\Actions\DailyUsageReportAction;

class GuildDailyReportCommand extends Command
{
use KanvasJobsTrait;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'kanvas-guild:daily-report {app_id?} {company_id?}';

/**
* The console command description.
*
* @var string|null
*/
protected $description = 'Send daily report to the guild';

public function handle(): void
{
//@todo make this run for multiple apps by looking for them at apps settings flag
$app = Apps::getById($this->argument('app_id'));
$company = Companies::getById($this->argument('company_id'));
$this->overwriteAppService($app);

//for now just apollo, but this should be for sending all the different reports
$this->info('Sending Apollo Daily Report - ' . date('Y-m-d'));
$apolloDailyReport = new DailyUsageReportAction($app, $company);
$result = $apolloDailyReport->execute();
$this->info('Total report send ' . count($result));
}
}
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function schedule(Schedule $schedule)
if (getenv('CADDIE_APP_KEY')) {
$schedule->command(MailCaddieLabCommand::class, [getenv('CADDIE_APP_KEY')])
->dailyAt('13:00')
->timezone('America/Santo_Domingo');
->timezone('America/New_York');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\GraphQL\Ecosystem\Mutations\ImporterTemplate;

use Kanvas\MappersImportersTemplates\Models\MapperImporterTemplate;
use Kanvas\MappersImportersTemplates\DataTransferObject\MapperImporterTemplate as MapperImportersTemplatesDto;
use Kanvas\Apps\Models\Apps;
use Kanvas\MappersImportersTemplates\Actions\CreateMapperImporterTemplateAction;

class ImporterTemplateManagementMutation
{
public function create(mixed $root, array $req): MapperImporterTemplate
{
$req = $req['input'];
$dto = new MapperImportersTemplatesDto(
users: auth()->user(),
companies: auth()->user()->getCurrentCompany(),
apps: app(Apps::class),
name: $req['name'],
attributes: $req['attributes'],
description: $req['description'] ?? null,
);
return (new CreateMapperImporterTemplateAction($dto))->execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function create(mixed $root, array $request): Message

$systemModuleId = $messageData['system_modules_id'] ?? null;
$systemModule = $systemModuleId ? SystemModules::getById((int)$systemModuleId, $app) : null;
$messageData['ip_address'] = request()->ip();
$data = MessageInput::fromArray(
$messageData,
$user,
Expand Down
Loading

0 comments on commit dd451eb

Please sign in to comment.