frontend-plugin-api: switch naming recommendation from define to defineParams

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-08-01 11:11:51 +02:00
parent e739a01e2d
commit 147482b700
40 changed files with 225 additions and 214 deletions
@@ -62,14 +62,14 @@ Apart from the addition of the blueprint parameters of the first argument to the
### Creating an extension from a blueprint with advanced parameter types
Some blueprints may be defined with something known as "advanced parameter types". This is a feature that enables type inference and transform of the blueprint parameters, and the way that you pass the parameters look a little bit different. Rather than passing the parameters directly, they are instead passed as a callback function of the form `define => define(<params>)`.
Some blueprints may be defined with something known as "advanced parameter types". This is a feature that enables type inference and transform of the blueprint parameters, and the way that you pass the parameters look a little bit different. Rather than passing the parameters directly, they are instead passed as a callback function of the form `defineParams => defineParams(<params>)`.
An example of a blueprint that uses advanced parameter types is the `ApiBlueprint` blueprint. Using it to create a simple implementation for the `AlertApi` might look like this:
```ts
const alertApiBlueprint = ApiBlueprint.make({
params: define =>
define({
params: defineParams =>
defineParams({
api: alertApiRef,
deps: {},
factory: () => new MyAlertApi(),
@@ -82,8 +82,8 @@ This also works with `makeWithOverrides`, where the define callback is passed as
```ts
const alertApiBlueprint = ApiBlueprint.makeWithOverrides({
factory(originalFactory, { config }) {
return originalFactory(define =>
define({
return originalFactory(defineParams =>
defineParams({
api: alertApiRef,
deps: {},
factory: () => new MyAlertApi(config),
@@ -199,8 +199,8 @@ import { ApiBlueprint } from '@backstage/frontend-plugin-api';
const scmIntegrationsApi = ApiBlueprint.make({
name: 'scm-integrations',
params: define =>
define({
params: defineParams =>
defineParams({
api: scmIntegrationsApiRef,
deps: { configApi: configApiRef },
factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi),
@@ -160,8 +160,8 @@ import { exampleApiRef, DefaultExampleApi } from './api';
// highlight-add-start
const exampleApi = ApiBlueprint.make({
name: 'example',
params: define =>
define({
params: defineParams =>
defineParams({
api: exampleApiRef,
deps: {},
factory: () => new DefaultExampleApi(),
@@ -210,8 +210,8 @@ import { workApiRef } from '@internal/plugin-example-react';
import { WorkImpl } from './WorkImpl';
const exampleWorkApi = ApiBlueprint.make({
params: define =>
define({
params: defineParams =>
defineParams({
api: workApiRef,
deps: { storageApi: storageApiRef },
factory: ({ storageApi }) => new WorkImpl({ storageApi }),
@@ -62,8 +62,8 @@ class WorkImpl implements WorkApi {
const workApi = ApiBlueprint.make({
name: 'work',
params: define =>
define({
params: defineParams =>
defineParams({
api: workApiRef,
deps: { storageApi: storageApiRef },
factory: ({ storageApi }) => {
@@ -51,8 +51,8 @@ import {
import { MyApiImpl } from './MyApiImpl';
const myApi = ApiBlueprint.make({
params: define =>
define({
params: defineParams =>
defineParams({
api: myApiRef,
deps: {
configApi: configApiRef,