diff --git a/composer.json b/composer.json index 153893e..3058906 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/registry-bridge", - "version": "0.0.14", + "version": "0.0.15", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "keywords": [ "fleetbase-extension", @@ -20,7 +20,7 @@ ], "require": { "php": "^8.0", - "fleetbase/core-api": "^1.5.9", + "fleetbase/core-api": "^1.5.10", "laravel/cashier": "^15.2.1", "php-http/guzzle7-adapter": "^1.0", "psr/http-factory-implementation": "*", diff --git a/config/environment.js b/config/environment.js index aed9cc0..68951f9 100644 --- a/config/environment.js +++ b/config/environment.js @@ -10,16 +10,9 @@ module.exports = function (environment) { modulePrefix: name, environment, mountedEngineRoutePrefix: getMountedEngineRoutePrefix(), - stripe: { publishableKey: getenv('STRIPE_KEY'), }, - - 'ember-leaflet': { - excludeCSS: true, - excludeJS: true, - excludeImages: true, - }, }; return ENV; diff --git a/extension.json b/extension.json index 170c157..461173b 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Registry Bridge", - "version": "0.0.14", + "version": "0.0.15", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "repository": "https://github.com/fleetbase/registry-bridge", "license": "AGPL-3.0-or-later", diff --git a/package.json b/package.json index 11f9909..96b40c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/registry-bridge-engine", - "version": "0.0.14", + "version": "0.0.15", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "fleetbase": { "route": "extensions" @@ -39,8 +39,8 @@ }, "dependencies": { "@babel/core": "^7.23.2", - "@fleetbase/ember-core": "^0.2.19", - "@fleetbase/ember-ui": "^0.2.32", + "@fleetbase/ember-core": "^0.2.21", + "@fleetbase/ember-ui": "^0.2.34", "@fortawesome/ember-fontawesome": "^2.0.0", "@fortawesome/fontawesome-svg-core": "6.4.0", "@fortawesome/free-solid-svg-icons": "6.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24de26c..58e0e7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,11 +12,11 @@ importers: specifier: ^7.23.2 version: 7.25.2 '@fleetbase/ember-core': - specifier: ^0.2.19 - version: 0.2.19(@ember/string@3.1.1)(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0) + specifier: ^0.2.21 + version: 0.2.21(@ember/string@3.1.1)(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0) '@fleetbase/ember-ui': - specifier: ^0.2.32 - version: 0.2.32(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(@glimmer/component@1.1.2(@babel/core@7.25.2))(@glimmer/tracking@1.1.2)(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(postcss@8.4.41)(rollup@2.79.1)(tracked-built-ins@3.3.0)(webpack@5.94.0) + specifier: ^0.2.34 + version: 0.2.34(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(@glimmer/component@1.1.2(@babel/core@7.25.2))(@glimmer/tracking@1.1.2)(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(postcss@8.4.41)(rollup@2.79.1)(tracked-built-ins@3.3.0)(webpack@5.94.0) '@fortawesome/ember-fontawesome': specifier: ^2.0.0 version: 2.0.0(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(rollup@2.79.1)(webpack@5.94.0) @@ -1347,12 +1347,12 @@ packages: peerDependencies: ember-source: '>= 4.0.0' - '@fleetbase/ember-core@0.2.19': - resolution: {integrity: sha512-xXRBp+dqZ975bPyAxvxlw1K+kcVxu1XZ9/Db+eySNPS2ua+wswg8+KyegnU6hkJflDgFjo7xTqBL30WVrjRUiQ==} + '@fleetbase/ember-core@0.2.21': + resolution: {integrity: sha512-Jwe4ME+cJp24Oaf6wfd1QJK6g3D6/Ff+qUMinJ40yoMImpo3zKA+IAxfQSBPIf+9BrmNG31wquTz4WR7Um47LQ==} engines: {node: '>= 18'} - '@fleetbase/ember-ui@0.2.32': - resolution: {integrity: sha512-+6lPyziomGKA405ILe6DSY9tBfehMTO1pSpe/8ZUQrez06wda6Ci4C2DCNd5vWmOlOtiC91cRKLUcN6Myx9dwQ==} + '@fleetbase/ember-ui@0.2.34': + resolution: {integrity: sha512-9uLCufgIaMFgGR+G4m73shaiRz+F16CDs7jj4jFzQGSUQByaBcbSetiMoGXSnx+3IncaKAn8rjAVPd+QrDDRMg==} engines: {node: '>= 18'} '@floating-ui/core@1.6.7': @@ -9671,7 +9671,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@fleetbase/ember-core@0.2.19(@ember/string@3.1.1)(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0)': + '@fleetbase/ember-core@0.2.21(@ember/string@3.1.1)(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0)': dependencies: '@babel/core': 7.25.2 compress-json: 3.1.0 @@ -9704,7 +9704,7 @@ snapshots: - utf-8-validate - webpack - '@fleetbase/ember-ui@0.2.32(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(@glimmer/component@1.1.2(@babel/core@7.25.2))(@glimmer/tracking@1.1.2)(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(postcss@8.4.41)(rollup@2.79.1)(tracked-built-ins@3.3.0)(webpack@5.94.0)': + '@fleetbase/ember-ui@0.2.34(@ember/test-helpers@3.3.1(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(webpack@5.94.0))(@glimmer/component@1.1.2(@babel/core@7.25.2))(@glimmer/tracking@1.1.2)(ember-resolver@11.0.1(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)))(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0))(postcss@8.4.41)(rollup@2.79.1)(tracked-built-ins@3.3.0)(webpack@5.94.0)': dependencies: '@babel/core': 7.25.2 '@ember/render-modifiers': 2.1.0(@babel/core@7.25.2)(ember-source@5.4.1(@babel/core@7.25.2)(@glimmer/component@1.1.2(@babel/core@7.25.2))(rsvp@4.8.5)(webpack@5.94.0)) diff --git a/server/src/Http/Controllers/Internal/v1/RegistryController.php b/server/src/Http/Controllers/Internal/v1/RegistryController.php index 4b563cf..e588b3b 100644 --- a/server/src/Http/Controllers/Internal/v1/RegistryController.php +++ b/server/src/Http/Controllers/Internal/v1/RegistryController.php @@ -42,15 +42,55 @@ public function categories() * @return \Illuminate\Http\JsonResponse * A JSON response containing a list of installed engines with their metadata */ - public function getInstalledEngines() + public function getInstalledEngines(Request $request) { - $installedExtensions = RegistryExtension::disableCache()->whereHas('installs', function ($query) { - $query->where('company_uuid', session('company')); - })->get()->map(function ($extension) { - return $extension->currentBundle->meta['package.json'] ?? []; - }); + if ($request->user() && $request->session()->has('company')) { + $installedExtensions = RegistryExtension::disableCache()->whereHas('installs', function ($query) { + $query->where('company_uuid', session('company')); + })->get()->map(function ($extension) { + return $extension->currentBundle->meta['package.json'] ?? []; + }); - return response()->json($installedExtensions); + return response()->json($installedExtensions); + } + + return []; + } + + /** + * Determines if a specified engine is installed for the authenticated user's company. + * + * Retrieves the 'engine' input from the request and checks if the user is authenticated, + * the session has a 'company', and the 'engine' parameter is provided. It then queries + * the `RegistryExtension` model to determine if the engine is installed for the company. + * + * @param Request $request the incoming HTTP request containing the 'engine' parameter + * + * @return array An associative array with the installation status, e.g., ['installed' => true]. + */ + public function getEngineInstallStatus(Request $request) + { + $engine = $request->input('engine'); + + if ($request->user() && $request->session()->has('company') && $engine) { + $installed = RegistryExtension::disableCache() + ->whereHas( + 'currentBundle', + function ($query) use ($engine) { + $query->where('meta->package.json->name', $engine); + } + ) + ->whereHas( + 'installs', + function ($query) { + $query->where('company_uuid', session('company')); + } + )->exists(); + + return ['installed' => $installed]; + } + + return ['installed' => false]; } /** diff --git a/server/src/routes.php b/server/src/routes.php index 034becc..5dac42c 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -14,6 +14,8 @@ */ // Lookup package endpoint Route::get(config('internals.api.routing.prefix', '~registry') . '/v1/lookup', 'Fleetbase\RegistryBridge\Http\Controllers\Internal\v1\RegistryController@lookupPackage'); +Route::get(config('internals.api.routing.prefix', '~registry') . '/v1/engines', 'Fleetbase\RegistryBridge\Http\Controllers\Internal\v1\RegistryController@getInstalledEngines'); +Route::get(config('internals.api.routing.prefix', '~registry') . '/v1/engine-install-status', 'Fleetbase\RegistryBridge\Http\Controllers\Internal\v1\RegistryController@getEngineInstallStatus'); Route::prefix(config('internals.api.routing.prefix', '~registry'))->middleware(['fleetbase.registry'])->namespace('Fleetbase\RegistryBridge\Http\Controllers')->group( function ($router) { /* @@ -36,7 +38,6 @@ function ($router) { $router->group(['middleware' => ['fleetbase.protected', 'throttle:60,1']], function ($router) { $router->get('categories', 'RegistryController@categories'); - $router->get('engines', 'RegistryController@getInstalledEngines'); $router->group(['prefix' => 'installer'], function ($router) { $router->post('install', 'ExtensionInstallerController@install');