@fleetbase/ember-core

中文文档
0.3.26发布于 2026/10/14AGPL-3.0-or-later近 30 天下载 4724

Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.

原始使用文档
文档目录11 节
  1. Overview
  2. Documentation
  3. Installation
  4. Usage
  5. Registering an extension
  6. Using the services
  7. What's included
  8. Development
  9. Testing and coverage
  10. Contributing
  11. License

Fleetbase

Fleetbase Ember Core

The services, contracts, decorators and utilities behind the Fleetbase console — and the foundation every Fleetbase extension is built on.

npm CI Coverage Downloads License

Documentation · Quickstart · Ember UI · Contributing


Overview

@fleetbase/ember-core is the Ember addon that the Fleetbase console and every Fleetbase extension share. It provides:

  • The Universe — the extensibility layer an extension uses to plug into the console: menus, registries, dashboard widgets, lifecycle hooks, engine loading and resource views.
  • Contracts — small, chainable classes that describe what an extension contributes (MenuItem, Widget, Hook, TableColumn, ResourceAction and more).
  • Application services — authentication, the API client, the current user, CRUD workflows, filters, notifications, sockets, theming and more.
  • Decorators and utilities — store- and API-backed properties, engine service injection, and the helpers the console relies on throughout.

Components live in the companion addon, @fleetbase/ember-ui.

Documentation

The documentation lives at fleetbase.io/docs/extension-development.

TopicGuide
Building your first extensionQuickstart · Extension anatomy
How an extension is loadedArchitecture · Extension registration
The Universe and its sub-servicesUniverse overview · Menus · Registries · Widgets · Hooks · Extension manager
Extending another engine's tables and details viewsResource views
API referenceContracts · Ember services · Decorators

Installation

pnpm add @fleetbase/ember-core

Or, with Ember CLI:

ember install @fleetbase/ember-core

Requires Node 18 or newer. The addon is built and tested against Ember 5.4.

Usage

Registering an extension

An extension contributes to the console from the setupExtension hook in its addon/extension.js. The universe it receives is the entry point to everything else:

// addon/extension.js
import { ResourceAction, TableColumn } from '@fleetbase/ember-core/contracts';

export default {
    setupExtension(app, universe) {
        // Add an item to the console header
        universe.getService('menu').registerHeaderMenuItem('Acme', 'console.acme', {
            icon: 'rocket',
            priority: 5,
        });

        // Add a column and a row action to Fleet-Ops' drivers table
        const views = universe.getService('resource-view');

        views.register(
            'fleet-ops:driver:table:columns',
            new TableColumn({ id: 'safety-score', label: 'Safety Score', valuePath: 'meta.safety_score' }).after('status')
        );

        views.register(
            'fleet-ops:driver:table:row-actions',
            new ResourceAction({ id: 'acme-sync', label: 'Sync to Acme', icon: 'sync', permission: 'acme sync driver' })
                .withHandler((driver, ctx) => ctx.owner.lookup('service:acme').sync(driver))
        );
    },
};

Using the services

Every service is injected the usual way:

import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class OrdersController extends Controller {
    @service fetch;
    @service currentUser;
    @service notifications;

    @action async dispatch(order) {
        await this.fetch.post(`orders/${order.id}/dispatch`);
        this.notifications.success(`Dispatched by ${this.currentUser.name}`);
    }
}

What's included

Universe — the extensibility layer

universe is a facade over six sub-services, each reached with universe.getService(name):

NameResponsible for
menuHeader items, admin and settings menus, account dropdowns and custom menu registries
registryNamed registries, and registering components, services and helpers across engines
widgetDashboard widgets and dashboards
hookApplication lifecycle and custom hooks
resource-viewColumns, actions and menu items on other engines' tables and details views
extension-managerLoading engines and sharing services between them
Contracts — imported from @fleetbase/ember-core/contracts
ContractDescribes
MenuItem, MenuPanelMenu entries and the admin panels that group them
ExtensionComponentA component that lives in an engine and is loaded on demand
WidgetA dashboard widget
HookA lifecycle or custom hook handler
RegistryA named registry
TableColumnA column added to a resource table
ResourceActionA row, bulk or details-menu action
ActionButtonA toolbar or details-header button
Services
ServiceResponsible for
sessionAuthentication and session lifecycle
current-userThe signed-in user, their organization, permissions and preferences
fetchThe Fleetbase API client: requests, uploads, downloads and caching
crudDelete, bulk-action, export and import workflows
resource-actionThe base for model-specific action services
filtersQuery-param filters for resource tables
table-contextSelection state for the active table
abilitiesPermission checks
notificationsToast notifications
socketReal-time channels, authenticated with session socket tokens
chatChat channels and messages
eventsApplication event tracking
themeLight and dark themes and route body classes
languageLocale selection
loaderLoading overlays
app-cachePersistent client-side cache
url-search-paramsReading and writing the URL's query string
custom-fields-registryCustom fields attached to any model
Decorators
DecoratorDoes
@engineServiceInjects a service from another engine
@fromStoreBacks a property with a store query
@fetchFromBacks a property with an API request

Development

pnpm install --frozen-lockfile

pnpm start                # serve the dummy app
pnpm test                 # lint + the full suite
pnpm run test:ember       # the suite on its own
pnpm run lint             # eslint, ember-template-lint, stylelint
pnpm run build            # production build

Run a subset while working on one area:

pnpm exec ember test --filter="Unit | Service | fetch"

Testing and coverage

The suite runs in headless Chrome through Testem. Coverage is gated at 100% of the addon/ source — statements, branches, functions and lines, checked per file — and enforced in CI, with results reported to Codecov.

pnpm run coverage            # run the suite with coverage
pnpm run coverage:check      # enforce the gate

Contributing

See the Contributing guide. Questions and ideas are welcome in GitHub Discussions and on Discord.

License

Licensed under the GNU Affero General Public License v3.0 or later.

版本与发布记录

@fleetbase/ember-core 共发布 70 个版本,首次发布于 2023/05/17;过去 12 个月发布了 20 个版本。

版本发布日期距今
0.3.26latest2026/10/141 个月前
0.3.252026/10/051 个月前
0.3.242026/07/014 个月前
0.3.232026/06/194 个月前
0.3.222026/06/125 个月前
0.3.212026/06/055 个月前

关于 @fleetbase/ember-core 的常见问题

@fleetbase/ember-core 是什么?

Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.

如何安装 @fleetbase/ember-core?

在项目目录运行 npm install @fleetbase/ember-core,或使用 pnpm add / yarn add / bun add。

@fleetbase/ember-core 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fleetbase__ember-core 是否存在。

@fleetbase/ember-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fleetbase/ember-core 可以商用吗?

@fleetbase/ember-core 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@fleetbase/ember-core 的下载量有多少?

根据 npm 官方下载统计,@fleetbase/ember-core 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,724 次,日均约 157 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fleetbase/ember-core 还在维护吗?

最新版本 0.3.26 发布于 2026/10/14(1 个月前);至今共发布 70 个版本,其中过去 12 个月发布了 20 个;首次发布于 2023/05/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。