diff --git a/packages/app-example-plugin/report.api.md b/packages/app-example-plugin/report.api.md index 2269e5c3b3..432174da68 100644 --- a/packages/app-example-plugin/report.api.md +++ b/packages/app-example-plugin/report.api.md @@ -22,11 +22,11 @@ const examplePlugin: OverridableFrontendPlugin< 'page:example': OverridableExtensionDefinition<{ kind: 'page'; name: undefined; - config: {} & { + config: { path: string | undefined; title: string | undefined; }; - configInput: {} & { + configInput: { title?: string | undefined; path?: string | undefined; }; diff --git a/packages/frontend-plugin-api/report-alpha.api.md b/packages/frontend-plugin-api/report-alpha.api.md index 0ec2a76218..acf1152d6c 100644 --- a/packages/frontend-plugin-api/report-alpha.api.md +++ b/packages/frontend-plugin-api/report-alpha.api.md @@ -15,8 +15,7 @@ import { JsonObject } from '@backstage/types'; import { JSX as JSX_2 } from 'react'; import { ReactNode } from 'react'; import { StandardSchemaV1 } from '@standard-schema/spec'; -import { z } from 'zod/v3'; -import { ZodType } from 'zod/v3'; +import type { z } from 'zod/v3'; // @public export type AnyRouteRefParams = @@ -86,12 +85,6 @@ export interface AppTree { readonly root: AppNode; } -// @public -export type ConfigFieldSchema = StandardSchemaV1 | ConfigFieldSchemaFactory; - -// @public @deprecated -export type ConfigFieldSchemaFactory = (zImpl: typeof z) => ZodType; - // @public (undocumented) export interface ConfigurableExtensionDataRef< TData, @@ -170,9 +163,6 @@ export interface ExtensionBlueprint< }>; makeWithOverrides< TName extends string | undefined, - TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; - }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, UParentInputs extends ExtensionDataRef, @@ -198,10 +188,92 @@ export interface ExtensionBlueprint< string}' is already defined in parent definition`; }; output?: Array; + config?: never; configSchema?: TNewExtensionConfigSchema & { [KName in keyof T['config']]?: `Error: Config key '${KName & string}' is already defined in parent schema`; }; + factory( + originalFactory: < + TParamsInput extends AnyParamsInput>, + >( + params: TParamsInput extends ExtensionBlueprintDefineParams + ? TParamsInput + : T['params'] extends ExtensionBlueprintDefineParams + ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams())`' + : T['params'], + context?: { + config?: T['config']; + inputs?: ResolvedInputValueOverrides>; + }, + ) => ExtensionDataContainer>, + context: { + node: AppNode; + apis: ApiHolder; + config: T['config'] & { + [key in keyof TNewExtensionConfigSchema]: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['output']; + }; + inputs: Expand>; + }, + ): Iterable & + VerifyExtensionFactoryOutput< + ExtensionDataRef extends UNewOutput + ? NonNullable + : UNewOutput, + UFactoryOutput + >; + }): OverridableExtensionDefinition<{ + config: Expand< + { + [key in keyof TNewExtensionConfigSchema]: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['output']; + } & T['config'] + >; + configInput: Expand< + { + [key in keyof TNewExtensionConfigSchema]?: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['input']; + } & T['configInput'] + >; + output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput; + inputs: Expand; + kind: T['kind']; + name: string | undefined extends TName ? undefined : TName; + params: T['params']; + }>; + // @deprecated (undocumented) + makeWithOverrides< + TName extends string | undefined, + TExtensionConfigSchema extends { + [key in string]: (zImpl: typeof z) => z.ZodType; + }, + UFactoryOutput extends ExtensionDataValue, + UNewOutput extends ExtensionDataRef, + UParentInputs extends ExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput; + } = {}, + >(args: { + name?: TName; + attachTo?: ExtensionDefinitionAttachTo & + VerifyExtensionAttachTo< + ExtensionDataRef extends UNewOutput + ? NonNullable + : UNewOutput, + UParentInputs + >; + disabled?: boolean; + if?: FilterPredicate; + inputs?: TExtraInputs & { + [KName in keyof T['inputs']]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + configSchema?: never; config?: { schema: TExtensionConfigSchema & { [KName in keyof T['config']]?: `Error: Config key '${KName & @@ -226,10 +298,6 @@ export interface ExtensionBlueprint< node: AppNode; apis: ApiHolder; config: T['config'] & { - [key in keyof TNewExtensionConfigSchema]: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['output']; - } & { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType<((...args: any[]) => any) & TExtensionConfigSchema[key]> >; @@ -245,11 +313,7 @@ export interface ExtensionBlueprint< >; }): OverridableExtensionDefinition<{ config: Expand< - { - [key in keyof TNewExtensionConfigSchema]: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['output']; - } & (string extends keyof TExtensionConfigSchema + (string extends keyof TExtensionConfigSchema ? {} : { [key in keyof TExtensionConfigSchema]: z.infer< @@ -261,11 +325,7 @@ export interface ExtensionBlueprint< T['config'] >; configInput: Expand< - { - [key in keyof TNewExtensionConfigSchema]?: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['input']; - } & (string extends keyof TExtensionConfigSchema + (string extends keyof TExtensionConfigSchema ? {} : z.input< z.ZodObject<{ @@ -501,9 +561,6 @@ export interface OverridableExtensionDefinition< }; // (undocumented) override< - TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; - }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, TExtraInputs extends { @@ -531,10 +588,105 @@ export interface OverridableExtensionDefinition< string}' is already defined in parent definition`; }; output?: Array; + config?: never; configSchema?: TNewExtensionConfigSchema & { [KName in keyof T['config']]?: `Error: Config key '${KName & string}' is already defined in parent schema`; }; + factory?( + originalFactory: < + TFactoryParamsReturn extends AnyParamsInput_2< + NonNullable + >, + >( + context?: Expand< + { + config?: T['config']; + inputs?: ResolvedInputValueOverrides>; + } & ([T['params']] extends [never] + ? {} + : { + params?: TFactoryParamsReturn extends ExtensionBlueprintDefineParams + ? TFactoryParamsReturn + : T['params'] extends ExtensionBlueprintDefineParams + ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams())`' + : Partial; + }) + >, + ) => ExtensionDataContainer>, + context: { + node: AppNode; + apis: ApiHolder; + config: T['config'] & { + [key in keyof TNewExtensionConfigSchema]: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['output']; + }; + inputs: Expand>; + }, + ): Iterable; + } & ([T['params']] extends [never] + ? {} + : { + params?: TParamsInput extends ExtensionBlueprintDefineParams + ? TParamsInput + : T['params'] extends ExtensionBlueprintDefineParams + ? 'Error: This blueprint uses advanced parameter types and requires you to pass parameters as using the following callback syntax: `originalFactory(defineParams => defineParams())`' + : Partial; + }) + > & + VerifyExtensionFactoryOutput< + ExtensionDataRef extends UNewOutput + ? NonNullable + : UNewOutput, + UFactoryOutput + >, + ): OverridableExtensionDefinition<{ + kind: T['kind']; + name: T['name']; + output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput; + inputs: T['inputs'] & TExtraInputs; + config: T['config'] & { + [key in keyof TNewExtensionConfigSchema]: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['output']; + }; + configInput: T['configInput'] & { + [key in keyof TNewExtensionConfigSchema]?: NonNullable< + TNewExtensionConfigSchema[key]['~standard']['types'] + >['input']; + }; + }>; + // @deprecated (undocumented) + override< + TExtensionConfigSchema extends { + [key in string]: (zImpl: typeof z) => z.ZodType; + }, + UFactoryOutput extends ExtensionDataValue, + UNewOutput extends ExtensionDataRef, + TExtraInputs extends { + [inputName in string]: ExtensionInput; + }, + TParamsInput extends AnyParamsInput_2>, + UParentInputs extends ExtensionDataRef, + >( + args: Expand< + { + attachTo?: ExtensionDefinitionAttachTo & + VerifyExtensionAttachTo< + ExtensionDataRef extends UNewOutput + ? NonNullable + : UNewOutput, + UParentInputs + >; + disabled?: boolean; + if?: FilterPredicate; + inputs?: TExtraInputs & { + [KName in keyof T['inputs']]?: `Error: Input '${KName & + string}' is already defined in parent definition`; + }; + output?: Array; + configSchema?: never; config?: { schema: TExtensionConfigSchema & { [KName in keyof T['config']]?: `Error: Config key '${KName & @@ -566,10 +718,6 @@ export interface OverridableExtensionDefinition< node: AppNode; apis: ApiHolder; config: T['config'] & { - [key in keyof TNewExtensionConfigSchema]: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['output']; - } & { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType< ((...args: any[]) => any) & TExtensionConfigSchema[key] @@ -601,19 +749,12 @@ export interface OverridableExtensionDefinition< output: ExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput; inputs: T['inputs'] & TExtraInputs; config: T['config'] & { - [key in keyof TNewExtensionConfigSchema]: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['output']; - } & { [key in keyof TExtensionConfigSchema]: z.infer< ReturnType<((...args: any[]) => any) & TExtensionConfigSchema[key]> >; }; - configInput: T['configInput'] & { - [key in keyof TNewExtensionConfigSchema]?: NonNullable< - TNewExtensionConfigSchema[key]['~standard']['types'] - >['input']; - } & z.input< + configInput: T['configInput'] & + z.input< z.ZodObject<{ [key in keyof TExtensionConfigSchema]: ReturnType< ((...args: any[]) => any) & TExtensionConfigSchema[key] @@ -683,6 +824,27 @@ export type PortableSchema = { schema: JsonObject; }; +// @public (undocumented) +export type RequiredExtensionIds = + UExtensionData extends any + ? UExtensionData['config']['optional'] extends true + ? never + : UExtensionData['id'] + : never; + +// @public +export type ResolvedExtensionInputs< + TInputs extends { + [name in string]: ExtensionInput; + }, +> = { + [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton'] + ? Array>> + : false extends TInputs[InputName]['config']['optional'] + ? Expand> + : Expand | undefined>; +}; + // @public export interface RouteRef< TParams extends AnyRouteRefParams = AnyRouteRefParams, @@ -707,8 +869,31 @@ export interface SubRouteRef< readonly T: TParams; } -// @public @deprecated -export function zodField(factory: (zImpl: typeof z) => T): T; +// @public (undocumented) +export type VerifyExtensionAttachTo< + UOutput extends ExtensionDataRef, + UParentInput extends ExtensionDataRef, +> = ExtensionDataRef extends UParentInput + ? {} + : [RequiredExtensionIds] extends [RequiredExtensionIds] + ? {} + : `Error: This parent extension input requires the following extension data, but it is not declared as guaranteed output of this extension: ${JoinStringUnion< + Exclude, RequiredExtensionIds> + >}`; + +// @public (undocumented) +export type VerifyExtensionFactoryOutput< + UDeclaredOutput extends ExtensionDataRef, + UFactoryOutput extends ExtensionDataValue, +> = [RequiredExtensionIds] extends [UFactoryOutput['id']] + ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] + ? {} + : `Error: The extension factory has undeclared output(s): ${JoinStringUnion< + Exclude + >}` + : `Error: The extension factory is missing the following output(s): ${JoinStringUnion< + Exclude, UFactoryOutput['id']> + >}`; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/frontend-plugin-api/report.api.md b/packages/frontend-plugin-api/report.api.md index 42156875e4..7a7bbe4ffc 100644 --- a/packages/frontend-plugin-api/report.api.md +++ b/packages/frontend-plugin-api/report.api.md @@ -24,8 +24,7 @@ import { PropsWithChildren } from 'react'; import { ReactNode } from 'react'; import { StandardSchemaV1 } from '@standard-schema/spec'; import { SwappableComponentRef as SwappableComponentRef_2 } from '@backstage/frontend-plugin-api'; -import { z } from 'zod/v3'; -import { ZodType } from 'zod/v3'; +import type { z } from 'zod/v3'; // @public @deprecated export type AlertApi = { @@ -390,16 +389,6 @@ export const configApiRef: ApiRef_2 & { readonly $$type: '@backstage/ApiRef'; }; -// @public -export type ConfigFieldSchema = - | StandardSchemaV1 - | ((zImpl: typeof z) => ZodType); - -// @public -export type ConfigSchemaRecord = { - [key: string]: ConfigFieldSchema; -}; - // @public (undocumented) export interface ConfigurableExtensionDataRef< TData, @@ -469,8 +458,6 @@ export function createApiRef(): { }; }; -// Warning: (ae-forgotten-export) The symbol "VerifyExtensionFactoryOutput" needs to be exported by the entry point index.d.ts -// // @public export function createExtension< UOutput extends ExtensionDataRef, @@ -538,7 +525,7 @@ export function createExtension< [inputName in string]: ExtensionInput; }, TConfigSchema extends { - [key: string]: ConfigFieldSchema; + [key: string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, const TKind extends string | undefined = undefined, @@ -599,8 +586,6 @@ export function createExtension< name: string | undefined extends TName ? undefined : TName; }>; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The reference is ambiguous because "createExtension" has more than one declaration; you need to add a TSDoc member reference selector -// // @public export function createExtensionBlueprint< TParams extends object | ExtensionBlueprintDefineParams, @@ -680,7 +665,7 @@ export function createExtensionBlueprint< [inputName in string]: ExtensionInput; }, TConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, TKind extends string, @@ -760,7 +745,7 @@ export type CreateExtensionBlueprintOptions< [inputName in string]: ExtensionInput; }, TConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, TDataRefs extends { @@ -859,7 +844,7 @@ export type CreateExtensionOptions< [inputName in string]: ExtensionInput; }, TConfigSchema extends { - [key: string]: ConfigFieldSchema; + [key: string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, UParentInputs extends ExtensionDataRef, @@ -1339,7 +1324,7 @@ export interface ExtensionBlueprint< makeWithOverrides< TName extends string | undefined, TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, @@ -2080,7 +2065,7 @@ export interface OverridableExtensionDefinition< // @deprecated (undocumented) override< TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, @@ -2459,6 +2444,27 @@ export const Progress: { // @public (undocumented) export type ProgressProps = {}; +// @public (undocumented) +export type RequiredExtensionIds = + UExtensionData extends any + ? UExtensionData['config']['optional'] extends true + ? never + : UExtensionData['id'] + : never; + +// @public +export type ResolvedExtensionInputs< + TInputs extends { + [name in string]: ExtensionInput; + }, +> = { + [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton'] + ? Array>> + : false extends TInputs[InputName]['config']['optional'] + ? Expand> + : Expand | undefined>; +}; + // @public export type RouteFunc = ( ...input: TParams extends undefined ? readonly [] : readonly [params: TParams] @@ -2871,6 +2877,32 @@ export const useTranslationRef: ( t: TranslationFunction; }; +// @public (undocumented) +export type VerifyExtensionAttachTo< + UOutput extends ExtensionDataRef, + UParentInput extends ExtensionDataRef, +> = ExtensionDataRef extends UParentInput + ? {} + : [RequiredExtensionIds] extends [RequiredExtensionIds] + ? {} + : `Error: This parent extension input requires the following extension data, but it is not declared as guaranteed output of this extension: ${JoinStringUnion< + Exclude, RequiredExtensionIds> + >}`; + +// @public (undocumented) +export type VerifyExtensionFactoryOutput< + UDeclaredOutput extends ExtensionDataRef, + UFactoryOutput extends ExtensionDataValue, +> = [RequiredExtensionIds] extends [UFactoryOutput['id']] + ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] + ? {} + : `Error: The extension factory has undeclared output(s): ${JoinStringUnion< + Exclude + >}` + : `Error: The extension factory is missing the following output(s): ${JoinStringUnion< + Exclude, UFactoryOutput['id']> + >}`; + // @public export const vmwareCloudAuthApiRef: ApiRef_2< OAuthApi & @@ -2892,9 +2924,4 @@ export function withApis( (props: PropsWithChildren>): JSX_3.Element; displayName: string; }; - -// Warnings were encountered during analysis: -// -// src/wiring/createExtension.d.ts:280:5 - (ae-forgotten-export) The symbol "VerifyExtensionAttachTo" needs to be exported by the entry point index.d.ts -// src/wiring/createExtension.d.ts:293:9 - (ae-forgotten-export) The symbol "ResolvedExtensionInputs" needs to be exported by the entry point index.d.ts ``` diff --git a/packages/frontend-plugin-api/src/alpha.ts b/packages/frontend-plugin-api/src/alpha.ts index 08226a4013..f622efe4f2 100644 --- a/packages/frontend-plugin-api/src/alpha.ts +++ b/packages/frontend-plugin-api/src/alpha.ts @@ -37,6 +37,10 @@ export type { ExtensionInput, FrontendPlugin, OverridableExtensionDefinition, + ResolvedExtensionInputs, + RequiredExtensionIds, + VerifyExtensionFactoryOutput, + VerifyExtensionAttachTo, } from './wiring'; export type { ApiHolder, @@ -47,11 +51,7 @@ export type { AppNodeSpec, AppTree, } from './apis'; -export type { - PortableSchema, - StandardSchemaV1, - ConfigFieldSchema, -} from './schema'; +export type { PortableSchema, StandardSchemaV1 } from './schema'; export type { AnyRouteRefParams, RouteRef, diff --git a/packages/frontend-plugin-api/src/schema/createPortableSchema.ts b/packages/frontend-plugin-api/src/schema/createPortableSchema.ts index 26d4835e0f..1f99c66a5a 100644 --- a/packages/frontend-plugin-api/src/schema/createPortableSchema.ts +++ b/packages/frontend-plugin-api/src/schema/createPortableSchema.ts @@ -41,89 +41,10 @@ export type { StandardSchemaV1 } from '@standard-schema/spec'; import { type StandardSchemaV1 } from '@standard-schema/spec'; // --------------------------------------------------------------------------- -// Public types +// Internal type for the field record accepted by createPortableSchema // --------------------------------------------------------------------------- -/** - * A single config field schema. Accepts any Standard Schema implementation, - * or the legacy factory form for backward compat. - * @public - */ -export type ConfigFieldSchema = - | StandardSchemaV1 - | ((zImpl: typeof zodV3) => ZodType); - -/** - * A record of per-field config schemas. - * @public - */ -export type ConfigSchemaRecord = { [key: string]: ConfigFieldSchema }; - -/** - * Infers the parsed output type of a config schema record. - * Replaces: `{ [key in keyof T]: z.infer> }` - * - * Split into two mapped types joined by intersection to avoid conditional - * types in the value position, which TypeScript defers in declaration emit. - * Factory-form fields use `ReturnType<...>['_output']` (eagerly evaluated), - * Standard Schema fields use `['~standard']['types']['output']`. - * @ignore - */ -type InferConfigOutput = { - [K in keyof T as T[K] extends (...args: any[]) => any - ? K - : never]: ReturnType any)>['_output']; -} & { - [K in keyof T as T[K] extends (...args: any[]) => any - ? never - : K]: NonNullable< - (T[K] & StandardSchemaV1)['~standard']['types'] - >['output']; -}; - -/** - * Infers the raw input type (before defaults/transforms) of a config - * schema record. - * Replaces: `z.input>` - * - * Fields whose input type includes `undefined` are made optional keys, - * matching the behavior of `z.input>` for ZodDefault - * and ZodOptional fields. - * @ignore - */ -type InferConfigInput = _RequiredInput & - _OptionalInput; - -type _FactoryInput any> = ReturnType['_input']; -type _SchemaInput = NonNullable< - T['~standard']['types'] ->['input']; - -/** @ignore */ -type _RequiredInput = { - [K in keyof T as T[K] extends (...args: any[]) => any - ? undefined extends _FactoryInput any)> - ? never - : K - : undefined extends _SchemaInput - ? never - : K]: T[K] extends (...args: any[]) => any - ? _FactoryInput any)> - : _SchemaInput; -}; - -/** @ignore */ -type _OptionalInput = { - [K in keyof T as T[K] extends (...args: any[]) => any - ? undefined extends _FactoryInput any)> - ? K - : never - : undefined extends _SchemaInput - ? K - : never]?: T[K] extends (...args: any[]) => any - ? _FactoryInput any)> - : _SchemaInput; -}; +type FieldSchema = StandardSchemaV1 | ((zImpl: typeof zodV3) => ZodType); // --------------------------------------------------------------------------- // The PortableSchema — now with per-field tracking for mergeability @@ -156,9 +77,9 @@ export interface MergeablePortableSchema // createPortableSchema — builds from a field record // --------------------------------------------------------------------------- -export function createPortableSchema( - fields: T, -): MergeablePortableSchema, InferConfigInput> { +export function createPortableSchema( + fields: Record, +): MergeablePortableSchema { const fieldValidators: Record = {}; for (const [key, field] of Object.entries(fields)) { diff --git a/packages/frontend-plugin-api/src/schema/index.ts b/packages/frontend-plugin-api/src/schema/index.ts index 3297c09ce3..35d5465cbe 100644 --- a/packages/frontend-plugin-api/src/schema/index.ts +++ b/packages/frontend-plugin-api/src/schema/index.ts @@ -15,8 +15,4 @@ */ export { type PortableSchema } from './types'; -export { - type StandardSchemaV1, - type ConfigFieldSchema, - type ConfigSchemaRecord, -} from './createPortableSchema'; +export { type StandardSchemaV1 } from './createPortableSchema'; diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 5cd8f987f8..dc30c25b49 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -28,7 +28,6 @@ import { ExtensionDataRef, ExtensionDataValue } from './createExtensionDataRef'; import { ExtensionInput } from './createExtensionInput'; import type { z } from 'zod/v3'; import { createSchemaFromZod } from '../schema/createSchemaFromZod'; -import type { ConfigFieldSchema } from '../schema/createPortableSchema'; import { warnConfigSchemaPropDeprecation } from '../schema/createPortableSchema'; import { type StandardSchemaV1 } from '@standard-schema/spec'; import { OpaqueExtensionDefinition } from '@internal/frontend'; @@ -58,7 +57,7 @@ type ResolvedExtensionInput = /** * Converts an extension input map into a matching collection of resolved inputs. * - * @ignore + * @public */ export type ResolvedExtensionInputs< TInputs extends { @@ -95,7 +94,7 @@ type JoinStringUnion< : JoinStringUnion : TResult; -/** @ignore */ +/** @public */ export type RequiredExtensionIds = UExtensionData extends any ? UExtensionData['config']['optional'] extends true @@ -103,7 +102,7 @@ export type RequiredExtensionIds = : UExtensionData['id'] : never; -/** @ignore */ +/** @public */ export type VerifyExtensionFactoryOutput< UDeclaredOutput extends ExtensionDataRef, UFactoryOutput extends ExtensionDataValue, @@ -117,7 +116,7 @@ export type VerifyExtensionFactoryOutput< Exclude, UFactoryOutput['id']> >}`; -/** @ignore */ +/** @public */ export type VerifyExtensionAttachTo< UOutput extends ExtensionDataRef, UParentInput extends ExtensionDataRef, @@ -169,7 +168,7 @@ export type CreateExtensionOptions< TName extends string | undefined, UOutput extends ExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput }, - TConfigSchema extends { [key: string]: ConfigFieldSchema }, + TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, UParentInputs extends ExtensionDataRef, TNewConfigSchema extends { [key: string]: StandardSchemaV1 } = {}, @@ -355,7 +354,7 @@ export interface OverridableExtensionDefinition< */ override< TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, @@ -578,7 +577,7 @@ export function createExtension< export function createExtension< UOutput extends ExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput }, - TConfigSchema extends { [key: string]: ConfigFieldSchema }, + TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, const TKind extends string | undefined = undefined, const TName extends string | undefined = undefined, diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts index 9be7a51f9f..bbd8ceeec3 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts @@ -28,7 +28,6 @@ import { } from './createExtension'; import type { z } from 'zod/v3'; import { ExtensionInput } from './createExtensionInput'; -import type { ConfigFieldSchema } from '../schema/createPortableSchema'; import { type StandardSchemaV1 } from '@standard-schema/spec'; import { ExtensionDataRef, ExtensionDataValue } from './createExtensionDataRef'; import { createExtensionDataContainer } from '@internal/frontend'; @@ -108,7 +107,7 @@ export type CreateExtensionBlueprintOptions< TParams extends object | ExtensionBlueprintDefineParams, UOutput extends ExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput }, - TConfigSchema extends { [key in string]: ConfigFieldSchema }, + TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, TDataRefs extends { [name in string]: ExtensionDataRef }, UParentInputs extends ExtensionDataRef, @@ -350,7 +349,7 @@ export interface ExtensionBlueprint< makeWithOverrides< TName extends string | undefined, TExtensionConfigSchema extends { - [key in string]: ConfigFieldSchema; + [key in string]: (zImpl: typeof z) => z.ZodType; }, UFactoryOutput extends ExtensionDataValue, UNewOutput extends ExtensionDataRef, @@ -524,7 +523,7 @@ function unwrapParams( * in the frontend system documentation. * * Extension blueprints make it much easier for users to create new extensions - * for your plugin. Rather than letting them use {@link createExtension} + * for your plugin. Rather than letting them use `createExtension` * directly, you can define a set of parameters and default factory for your * blueprint, removing a lot of the boilerplate and complexity that is otherwise * needed to create an extension. @@ -634,7 +633,7 @@ export function createExtensionBlueprint< TParams extends object | ExtensionBlueprintDefineParams, UOutput extends ExtensionDataRef, TInputs extends { [inputName in string]: ExtensionInput }, - TConfigSchema extends { [key in string]: ConfigFieldSchema }, + TConfigSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }, UFactoryOutput extends ExtensionDataValue, TKind extends string, UParentInputs extends ExtensionDataRef, diff --git a/packages/frontend-plugin-api/src/wiring/index.ts b/packages/frontend-plugin-api/src/wiring/index.ts index f3a39cc60d..676f5982ec 100644 --- a/packages/frontend-plugin-api/src/wiring/index.ts +++ b/packages/frontend-plugin-api/src/wiring/index.ts @@ -22,6 +22,10 @@ export { type ExtensionDefinitionParameters, type CreateExtensionOptions, type OverridableExtensionDefinition, + type ResolvedExtensionInputs, + type RequiredExtensionIds, + type VerifyExtensionFactoryOutput, + type VerifyExtensionAttachTo, } from './createExtension'; export { createExtensionInput,