frontend-plugin-api: use @standard-schema/spec dependency instead of inlining
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
"@backstage/filter-predicates": "workspace:^",
|
||||
"@backstage/types": "workspace:^",
|
||||
"@backstage/version-bridge": "workspace:^",
|
||||
"@standard-schema/spec": "^1.1.0",
|
||||
"zod": "^3.25.76 || ^4.0.0",
|
||||
"zod-to-json-schema": "^3.25.1"
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@ import { FilterPredicate } from '@backstage/filter-predicates';
|
||||
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';
|
||||
|
||||
@@ -85,6 +86,11 @@ export interface AppTree {
|
||||
readonly root: AppNode;
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ConfigFieldSchema =
|
||||
| StandardSchemaV1
|
||||
| ((zImpl: typeof z) => ZodType);
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ConfigurableExtensionDataRef<
|
||||
TData,
|
||||
@@ -161,7 +167,6 @@ export interface ExtensionBlueprint<
|
||||
inputs: T['inputs'];
|
||||
params: T['params'];
|
||||
}>;
|
||||
// Warning: (ae-forgotten-export) The symbol "ConfigFieldSchema" needs to be exported by the entry point alpha.d.ts
|
||||
makeWithOverrides<
|
||||
TName extends string | undefined,
|
||||
TExtensionConfigSchema extends {
|
||||
@@ -650,6 +655,8 @@ export interface RouteRef<
|
||||
readonly T: TParams;
|
||||
}
|
||||
|
||||
export { StandardSchemaV1 };
|
||||
|
||||
// @public
|
||||
export interface SubRouteRef<
|
||||
TParams extends AnyRouteRefParams = AnyRouteRefParams,
|
||||
|
||||
@@ -22,6 +22,7 @@ import { JSX as JSX_3 } from 'react/jsx-runtime';
|
||||
import { Observable } from '@backstage/types';
|
||||
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';
|
||||
@@ -2146,75 +2147,7 @@ export namespace SessionState {
|
||||
export type SignedOut = typeof SessionState.SignedOut;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
||||
// (undocumented)
|
||||
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace StandardSchemaV1 {
|
||||
// (undocumented)
|
||||
export interface FailureResult {
|
||||
// (undocumented)
|
||||
readonly issues: ReadonlyArray<Issue>;
|
||||
}
|
||||
// (undocumented)
|
||||
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<
|
||||
Schema['~standard']['types']
|
||||
>['input'];
|
||||
// (undocumented)
|
||||
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<
|
||||
Schema['~standard']['types']
|
||||
>['output'];
|
||||
// (undocumented)
|
||||
export interface Issue {
|
||||
// (undocumented)
|
||||
readonly message: string;
|
||||
// (undocumented)
|
||||
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface Options {
|
||||
// (undocumented)
|
||||
readonly libraryOptions?: Record<string, unknown> | undefined;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface PathSegment {
|
||||
// (undocumented)
|
||||
readonly key: PropertyKey;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface Props<Input = unknown, Output = Input> {
|
||||
// (undocumented)
|
||||
readonly types?: Types<Input, Output> | undefined;
|
||||
// (undocumented)
|
||||
readonly validate: (
|
||||
value: unknown,
|
||||
options?: Options | undefined,
|
||||
) => Result<Output> | Promise<Result<Output>>;
|
||||
// (undocumented)
|
||||
readonly vendor: string;
|
||||
// (undocumented)
|
||||
readonly version: 1;
|
||||
}
|
||||
// (undocumented)
|
||||
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
||||
// (undocumented)
|
||||
export interface SuccessResult<Output> {
|
||||
// (undocumented)
|
||||
readonly issues?: undefined;
|
||||
// (undocumented)
|
||||
readonly value: Output;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface Types<Input = unknown, Output = Input> {
|
||||
// (undocumented)
|
||||
readonly input: Input;
|
||||
// (undocumented)
|
||||
readonly output: Output;
|
||||
}
|
||||
}
|
||||
export { StandardSchemaV1 };
|
||||
|
||||
// @public
|
||||
export interface StorageApi {
|
||||
|
||||
@@ -47,7 +47,11 @@ export type {
|
||||
AppNodeSpec,
|
||||
AppTree,
|
||||
} from './apis';
|
||||
export type { PortableSchema } from './schema';
|
||||
export type {
|
||||
PortableSchema,
|
||||
StandardSchemaV1,
|
||||
ConfigFieldSchema,
|
||||
} from './schema';
|
||||
export type {
|
||||
AnyRouteRefParams,
|
||||
RouteRef,
|
||||
|
||||
@@ -33,77 +33,12 @@ import { z as zodV3, type ZodType } from 'zod/v3';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
import { PortableSchema } from './types';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Standard Schema V1 — inlined from https://standardschema.dev
|
||||
//
|
||||
// This is the cross-library interface implemented by zod v3.25+, zod v4,
|
||||
// valibot, arktype, and others. It's designed to be inlined: "Libraries
|
||||
// wishing to implement the spec can copy/paste the code block below into
|
||||
// their codebase" — no npm dependency required.
|
||||
//
|
||||
// See: https://github.com/standard-schema/standard-schema
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The Standard Schema interface.
|
||||
* @public
|
||||
*/
|
||||
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
||||
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export namespace StandardSchemaV1 {
|
||||
export interface Props<Input = unknown, Output = Input> {
|
||||
readonly version: 1;
|
||||
readonly vendor: string;
|
||||
readonly validate: (
|
||||
value: unknown,
|
||||
options?: Options | undefined,
|
||||
) => Result<Output> | Promise<Result<Output>>;
|
||||
readonly types?: Types<Input, Output> | undefined;
|
||||
}
|
||||
|
||||
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
||||
|
||||
export interface SuccessResult<Output> {
|
||||
readonly value: Output;
|
||||
readonly issues?: undefined;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
readonly libraryOptions?: Record<string, unknown> | undefined;
|
||||
}
|
||||
|
||||
export interface FailureResult {
|
||||
readonly issues: ReadonlyArray<Issue>;
|
||||
}
|
||||
|
||||
export interface Issue {
|
||||
readonly message: string;
|
||||
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
||||
}
|
||||
|
||||
export interface PathSegment {
|
||||
readonly key: PropertyKey;
|
||||
}
|
||||
|
||||
export interface Types<Input = unknown, Output = Input> {
|
||||
readonly input: Input;
|
||||
readonly output: Output;
|
||||
}
|
||||
|
||||
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<
|
||||
Schema['~standard']['types']
|
||||
>['input'];
|
||||
|
||||
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<
|
||||
Schema['~standard']['types']
|
||||
>['output'];
|
||||
}
|
||||
export type { StandardSchemaV1 } from '@standard-schema/spec';
|
||||
import { type StandardSchemaV1 } from '@standard-schema/spec';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Public types
|
||||
|
||||
@@ -3779,6 +3779,7 @@ __metadata:
|
||||
"@backstage/test-utils": "workspace:^"
|
||||
"@backstage/types": "workspace:^"
|
||||
"@backstage/version-bridge": "workspace:^"
|
||||
"@standard-schema/spec": "npm:^1.1.0"
|
||||
"@testing-library/jest-dom": "npm:^6.0.0"
|
||||
"@testing-library/react": "npm:^16.0.0"
|
||||
"@types/react": "npm:^18.0.0"
|
||||
@@ -19062,7 +19063,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@standard-schema/spec@npm:^1.0.0":
|
||||
"@standard-schema/spec@npm:^1.0.0, @standard-schema/spec@npm:^1.1.0":
|
||||
version: 1.1.0
|
||||
resolution: "@standard-schema/spec@npm:1.1.0"
|
||||
checksum: 10/a209615c9e8b2ea535d7db0a5f6aa0f962fd4ab73ee86a46c100fb78116964af1f55a27c1794d4801e534a196794223daa25ff5135021e03c7828aa3d95e1763
|
||||
|
||||
Reference in New Issue
Block a user