@hey-api/shared 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +313 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +506 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -9
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,8 @@ import ts from "typescript";
|
|
|
3
3
|
import * as semver from "semver";
|
|
4
4
|
import { RangeOptions, SemVer } from "semver";
|
|
5
5
|
import { getResolvedInput } from "@hey-api/json-schema-ref-parser";
|
|
6
|
+
import { IProject, Logger, NameConflictResolver, Node, Project, Ref, RenderContext, StructureLocation, Symbol, SymbolIdentifier, SymbolIn, SymbolMeta } from "@hey-api/codegen-core";
|
|
6
7
|
import { AnyString, MaybeArray, MaybeFunc, MaybePromise } from "@hey-api/types";
|
|
7
|
-
import { IProject, Logger, NameConflictResolver, Node, Project, RenderContext, StructureLocation, Symbol, SymbolIdentifier, SymbolIn, SymbolMeta } from "@hey-api/codegen-core";
|
|
8
8
|
|
|
9
9
|
//#region src/cli.d.ts
|
|
10
10
|
declare function printCliIntro(initialDir: string, showLogo?: boolean): void;
|
|
@@ -2965,6 +2965,40 @@ declare namespace IR {
|
|
|
2965
2965
|
type WebhookObject = IRWebhookObject;
|
|
2966
2966
|
}
|
|
2967
2967
|
//#endregion
|
|
2968
|
+
//#region src/ir/schema-processor.d.ts
|
|
2969
|
+
interface SchemaProcessor {
|
|
2970
|
+
/** Current inherited context (set by withContext) */
|
|
2971
|
+
readonly context: {
|
|
2972
|
+
readonly anchor: string | undefined;
|
|
2973
|
+
readonly tags: ReadonlyArray<string> | undefined;
|
|
2974
|
+
};
|
|
2975
|
+
/** Check if pointer was already emitted */
|
|
2976
|
+
hasEmitted: (path: ReadonlyArray<string | number>) => boolean;
|
|
2977
|
+
/** Mark pointer as emitted. Returns false if already emitted. */
|
|
2978
|
+
markEmitted: (path: ReadonlyArray<string | number>) => boolean;
|
|
2979
|
+
/** Execute with inherited context for nested extractions */
|
|
2980
|
+
withContext: <T>(ctx: {
|
|
2981
|
+
anchor?: string;
|
|
2982
|
+
tags?: ReadonlyArray<string>;
|
|
2983
|
+
}, fn: () => T) => T;
|
|
2984
|
+
}
|
|
2985
|
+
interface SchemaProcessorContext {
|
|
2986
|
+
meta: {
|
|
2987
|
+
resource: string;
|
|
2988
|
+
resourceId: string;
|
|
2989
|
+
role?: string;
|
|
2990
|
+
};
|
|
2991
|
+
namingAnchor?: string;
|
|
2992
|
+
path: ReadonlyArray<string | number>;
|
|
2993
|
+
schema: IR.SchemaObject;
|
|
2994
|
+
tags?: ReadonlyArray<string>;
|
|
2995
|
+
}
|
|
2996
|
+
interface SchemaProcessorResult<Context$1 extends SchemaProcessorContext = SchemaProcessorContext> {
|
|
2997
|
+
process: (ctx: Context$1) => void;
|
|
2998
|
+
}
|
|
2999
|
+
type SchemaExtractor<Context$1 extends SchemaProcessorContext = SchemaProcessorContext> = (ctx: Context$1) => IR.SchemaObject;
|
|
3000
|
+
declare function createSchemaProcessor(): SchemaProcessor;
|
|
3001
|
+
//#endregion
|
|
2968
3002
|
//#region src/openApi/shared/utils/graph.d.ts
|
|
2969
3003
|
/**
|
|
2970
3004
|
* Represents the possible access scopes for OpenAPI nodes.
|
|
@@ -3224,14 +3258,17 @@ type WalkEvents = BaseEvent & ({
|
|
|
3224
3258
|
path: string;
|
|
3225
3259
|
type: Extract<IrTopLevelKind, 'operation'>;
|
|
3226
3260
|
} | {
|
|
3261
|
+
/** Name of the parameter (e.g., "id" for a parameter defined as "#/components/parameters/id"). */
|
|
3227
3262
|
name: string;
|
|
3228
3263
|
parameter: IR.ParameterObject;
|
|
3229
3264
|
type: Extract<IrTopLevelKind, 'parameter'>;
|
|
3230
3265
|
} | {
|
|
3266
|
+
/** Name of the request body (e.g., "CreateUserRequest" for a request body defined as "#/components/requestBodies/CreateUserRequest"). */
|
|
3231
3267
|
name: string;
|
|
3232
3268
|
requestBody: IR.RequestBodyObject;
|
|
3233
3269
|
type: Extract<IrTopLevelKind, 'requestBody'>;
|
|
3234
3270
|
} | {
|
|
3271
|
+
/** Name of the schema (e.g., "User" for a schema defined as "#/components/schemas/User"). */
|
|
3235
3272
|
name: string;
|
|
3236
3273
|
schema: IR.SchemaObject;
|
|
3237
3274
|
type: Extract<IrTopLevelKind, 'schema'>;
|
|
@@ -3528,6 +3565,28 @@ type Hooks = {
|
|
|
3528
3565
|
*/
|
|
3529
3566
|
isQuery?: (operation: IROperationObject) => boolean | undefined;
|
|
3530
3567
|
};
|
|
3568
|
+
schemas?: {
|
|
3569
|
+
/**
|
|
3570
|
+
* Whether to extract the given schema into a separate symbol.
|
|
3571
|
+
*
|
|
3572
|
+
* This affects how schemas are processed and output.
|
|
3573
|
+
*
|
|
3574
|
+
* **Default behavior:** No schemas are extracted.
|
|
3575
|
+
*
|
|
3576
|
+
* @param ctx - The processing context for the schema.
|
|
3577
|
+
* @returns true to extract the schema, false to keep it inline, or undefined to fallback to default behavior.
|
|
3578
|
+
* @example
|
|
3579
|
+
* ```ts
|
|
3580
|
+
* shouldExtract: (ctx) => {
|
|
3581
|
+
* if (ctx.meta.resource === 'requestBody') {
|
|
3582
|
+
* return true;
|
|
3583
|
+
* }
|
|
3584
|
+
* return; // fallback to default behavior
|
|
3585
|
+
* }
|
|
3586
|
+
* ```
|
|
3587
|
+
*/
|
|
3588
|
+
shouldExtract?: (ctx: SchemaProcessorContext) => boolean;
|
|
3589
|
+
};
|
|
3531
3590
|
/**
|
|
3532
3591
|
* Hooks specifically for overriding symbols behavior.
|
|
3533
3592
|
*
|
|
@@ -3647,6 +3706,7 @@ type DefinePlugin<Config extends PluginBaseConfig = PluginBaseConfig, ResolvedCo
|
|
|
3647
3706
|
Handler: (args: {
|
|
3648
3707
|
plugin: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>;
|
|
3649
3708
|
}) => void;
|
|
3709
|
+
/** The plugin instance. */
|
|
3650
3710
|
Instance: PluginInstance<Plugin.Types<Config, ResolvedConfig, Api>>;
|
|
3651
3711
|
Types: Plugin.Types<Config, ResolvedConfig, Api>;
|
|
3652
3712
|
};
|
|
@@ -6831,7 +6891,42 @@ declare namespace OpenApiSchemaObject {
|
|
|
6831
6891
|
}
|
|
6832
6892
|
//#endregion
|
|
6833
6893
|
//#region src/config/parser/patch.d.ts
|
|
6834
|
-
type
|
|
6894
|
+
type PatchInputFn = (spec: OpenApi.V2_0_X | OpenApi.V3_0_X | OpenApi.V3_1_X) => void | Promise<void>;
|
|
6895
|
+
type Patch = PatchInputFn | {
|
|
6896
|
+
/**
|
|
6897
|
+
* Patch the raw OpenAPI spec object in place. Called before all other
|
|
6898
|
+
* patch callbacks. Useful for bulk/structural transformations such as
|
|
6899
|
+
* adding new component definitions or modifying many operations at once.
|
|
6900
|
+
*
|
|
6901
|
+
* @param spec The OpenAPI spec object for the current version.
|
|
6902
|
+
*
|
|
6903
|
+
* @example
|
|
6904
|
+
* ```ts
|
|
6905
|
+
* input: (spec) => {
|
|
6906
|
+
* // Create new component parameters
|
|
6907
|
+
* if (!spec.components) spec.components = {};
|
|
6908
|
+
* if (!spec.components.parameters) spec.components.parameters = {};
|
|
6909
|
+
* spec.components.parameters.MyParam = {
|
|
6910
|
+
* in: 'query',
|
|
6911
|
+
* name: 'myParam',
|
|
6912
|
+
* schema: { type: 'string' }
|
|
6913
|
+
* };
|
|
6914
|
+
*
|
|
6915
|
+
* // Inject parameters into operations
|
|
6916
|
+
* for (const [path, pathItem] of Object.entries(spec.paths ?? {})) {
|
|
6917
|
+
* if (pathItem?.get) {
|
|
6918
|
+
* if (!Array.isArray(pathItem.get.parameters)) {
|
|
6919
|
+
* pathItem.get.parameters = [];
|
|
6920
|
+
* }
|
|
6921
|
+
* pathItem.get.parameters.push({
|
|
6922
|
+
* $ref: '#/components/parameters/MyParam'
|
|
6923
|
+
* });
|
|
6924
|
+
* }
|
|
6925
|
+
* }
|
|
6926
|
+
* }
|
|
6927
|
+
* ```
|
|
6928
|
+
*/
|
|
6929
|
+
input?: PatchInputFn;
|
|
6835
6930
|
/**
|
|
6836
6931
|
* Patch the OpenAPI meta object in place. Useful for modifying general metadata such as title, description, version, or custom fields before further processing.
|
|
6837
6932
|
*
|
|
@@ -6839,16 +6934,51 @@ type Patch = {
|
|
|
6839
6934
|
*/
|
|
6840
6935
|
meta?: (meta: OpenApiMetaObject.V2_0_X | OpenApiMetaObject.V3_0_X | OpenApiMetaObject.V3_1_X) => void;
|
|
6841
6936
|
/**
|
|
6842
|
-
* Patch OpenAPI operations in place.
|
|
6937
|
+
* Patch OpenAPI operations in place. Each function receives the operation
|
|
6938
|
+
* object to be modified in place. Common use cases include injecting
|
|
6939
|
+
* `operationId` for specs that don't have them, adding `x-*` extensions,
|
|
6940
|
+
* setting `deprecated` based on path patterns, or injecting `security`
|
|
6941
|
+
* requirements globally.
|
|
6942
|
+
*
|
|
6943
|
+
* Can be:
|
|
6944
|
+
* - `Record<string, fn>`: Patch specific operations by `"METHOD /path"` key
|
|
6945
|
+
* - `function`: Bulk callback receives `(method, path, operation)` for every operation
|
|
6946
|
+
*
|
|
6947
|
+
* Both patterns support async functions for operations like fetching data
|
|
6948
|
+
* from external sources or performing I/O.
|
|
6843
6949
|
*
|
|
6844
6950
|
* @example
|
|
6951
|
+
* ```js
|
|
6952
|
+
* // Named operations
|
|
6845
6953
|
* operations: {
|
|
6846
6954
|
* 'GET /foo': (operation) => {
|
|
6847
|
-
* operation.responses['200'].description = '
|
|
6955
|
+
* operation.responses['200'].description = 'Success';
|
|
6956
|
+
* },
|
|
6957
|
+
* 'POST /bar': (operation) => {
|
|
6958
|
+
* operation.deprecated = true;
|
|
6959
|
+
* }
|
|
6960
|
+
* }
|
|
6961
|
+
*
|
|
6962
|
+
* // Bulk callback for all operations
|
|
6963
|
+
* operations: (method, path, operation) => {
|
|
6964
|
+
* if (!operation.operationId) {
|
|
6965
|
+
* operation.operationId = method + buildOperationName(path);
|
|
6848
6966
|
* }
|
|
6849
6967
|
* }
|
|
6968
|
+
*
|
|
6969
|
+
* // Async example - inject operationId based on path patterns
|
|
6970
|
+
* operations: async (method, path, operation) => {
|
|
6971
|
+
* if (operation.operationId) return;
|
|
6972
|
+
*
|
|
6973
|
+
* const segments = path.split('/').filter(Boolean);
|
|
6974
|
+
* const parts = segments
|
|
6975
|
+
* .map((seg) => seg.startsWith('{') ? 'ById' : seg)
|
|
6976
|
+
* .join('');
|
|
6977
|
+
* operation.operationId = method + parts;
|
|
6978
|
+
* }
|
|
6979
|
+
* ```
|
|
6850
6980
|
*/
|
|
6851
|
-
operations?: Record<string, (operation: OpenApiOperationObject.V2_0_X | OpenApiOperationObject.V3_0_X | OpenApiOperationObject.V3_1_X) => void
|
|
6981
|
+
operations?: Record<string, (operation: OpenApiOperationObject.V2_0_X | OpenApiOperationObject.V3_0_X | OpenApiOperationObject.V3_1_X) => void | Promise<void>> | ((method: string, path: string, operation: OpenApiOperationObject.V2_0_X | OpenApiOperationObject.V3_0_X | OpenApiOperationObject.V3_1_X) => void | Promise<void>);
|
|
6852
6982
|
/**
|
|
6853
6983
|
* Patch OpenAPI parameters in place. The key is the parameter name, and the function receives the parameter object to modify directly.
|
|
6854
6984
|
*
|
|
@@ -6887,8 +7017,16 @@ type Patch = {
|
|
|
6887
7017
|
* use cases include fixing incorrect data types, removing unwanted
|
|
6888
7018
|
* properties, adding missing fields, or standardizing date/time formats.
|
|
6889
7019
|
*
|
|
7020
|
+
* Can be:
|
|
7021
|
+
* - `Record<string, fn>`: Patch specific named schemas
|
|
7022
|
+
* - `function`: Bulk callback receives `(name, schema)` for every schema
|
|
7023
|
+
*
|
|
7024
|
+
* Both patterns support async functions for operations like fetching data
|
|
7025
|
+
* from external sources or performing I/O.
|
|
7026
|
+
*
|
|
6890
7027
|
* @example
|
|
6891
7028
|
* ```js
|
|
7029
|
+
* // Named schemas
|
|
6892
7030
|
* schemas: {
|
|
6893
7031
|
* Foo: (schema) => {
|
|
6894
7032
|
* // convert date-time format to timestamp
|
|
@@ -6908,9 +7046,26 @@ type Patch = {
|
|
|
6908
7046
|
* delete schema.properties.internalField;
|
|
6909
7047
|
* }
|
|
6910
7048
|
* }
|
|
7049
|
+
*
|
|
7050
|
+
* // Bulk callback for all schemas
|
|
7051
|
+
* schemas: (name, schema) => {
|
|
7052
|
+
* const match = name.match(/_v(\d+)_(\d+)_(\d+)_/);
|
|
7053
|
+
* if (match) {
|
|
7054
|
+
* schema.description = (schema.description || '') +
|
|
7055
|
+
* `\n@version ${match[1]}.${match[2]}.${match[3]}`;
|
|
7056
|
+
* }
|
|
7057
|
+
* }
|
|
7058
|
+
*
|
|
7059
|
+
* // Async example - fetch metadata from external source
|
|
7060
|
+
* schemas: async (name, schema) => {
|
|
7061
|
+
* const metadata = await fetchSchemaMetadata(name);
|
|
7062
|
+
* if (metadata) {
|
|
7063
|
+
* schema.description = `${schema.description}\n\n${metadata.notes}`;
|
|
7064
|
+
* }
|
|
7065
|
+
* }
|
|
6911
7066
|
* ```
|
|
6912
7067
|
*/
|
|
6913
|
-
schemas?: Record<string, (schema: OpenApiSchemaObject.V2_0_X | OpenApiSchemaObject.V3_0_X | OpenApiSchemaObject.V3_1_X) => void
|
|
7068
|
+
schemas?: Record<string, (schema: OpenApiSchemaObject.V2_0_X | OpenApiSchemaObject.V3_0_X | OpenApiSchemaObject.V3_1_X) => void | Promise<void>> | ((name: string, schema: OpenApiSchemaObject.V2_0_X | OpenApiSchemaObject.V3_0_X | OpenApiSchemaObject.V3_1_X) => void | Promise<void>);
|
|
6914
7069
|
/**
|
|
6915
7070
|
* Patch the OpenAPI version string. The function receives the current version and should return the new version string.
|
|
6916
7071
|
* Useful for normalizing or overriding the version value before further processing.
|
|
@@ -7086,6 +7241,21 @@ type UserParser = {
|
|
|
7086
7241
|
name?: NameTransformer;
|
|
7087
7242
|
};
|
|
7088
7243
|
};
|
|
7244
|
+
/**
|
|
7245
|
+
* Sometimes your schema names are auto-generated or follow a naming convention
|
|
7246
|
+
* that produces verbose or awkward type names. You can rename schema component
|
|
7247
|
+
* keys throughout the specification, automatically updating all `$ref` pointers.
|
|
7248
|
+
*
|
|
7249
|
+
* @example
|
|
7250
|
+
* ```ts
|
|
7251
|
+
* {
|
|
7252
|
+
* schemaName: (name) => name.replace(/_v\d+_\d+_\d+_/, '_')
|
|
7253
|
+
* }
|
|
7254
|
+
* ```
|
|
7255
|
+
*
|
|
7256
|
+
* @default undefined
|
|
7257
|
+
*/
|
|
7258
|
+
schemaName?: NameTransformer;
|
|
7089
7259
|
};
|
|
7090
7260
|
/**
|
|
7091
7261
|
* **This is an experimental feature.**
|
|
@@ -7189,6 +7359,13 @@ type Parser = {
|
|
|
7189
7359
|
*/
|
|
7190
7360
|
responses: NamingOptions;
|
|
7191
7361
|
};
|
|
7362
|
+
/**
|
|
7363
|
+
* Rename schema component keys and automatically update all `$ref` pointers
|
|
7364
|
+
* throughout the specification.
|
|
7365
|
+
*
|
|
7366
|
+
* @default undefined
|
|
7367
|
+
*/
|
|
7368
|
+
schemaName?: NameTransformer;
|
|
7192
7369
|
};
|
|
7193
7370
|
/**
|
|
7194
7371
|
* **This is an experimental feature.**
|
|
@@ -7845,6 +8022,105 @@ declare function deduplicateSchema<T extends IR.SchemaObject>({
|
|
|
7845
8022
|
schema: T;
|
|
7846
8023
|
}): T;
|
|
7847
8024
|
//#endregion
|
|
8025
|
+
//#region src/plugins/shared/types/schema.d.ts
|
|
8026
|
+
type SchemaWithType<T extends Required<IR.SchemaObject>['type'] = Required<IR.SchemaObject>['type']> = Omit<IR.SchemaObject, 'type'> & {
|
|
8027
|
+
type: Extract<Required<IR.SchemaObject>['type'], T>;
|
|
8028
|
+
};
|
|
8029
|
+
//#endregion
|
|
8030
|
+
//#region src/ir/schema-walker.d.ts
|
|
8031
|
+
/**
|
|
8032
|
+
* Context passed to all visitor methods.
|
|
8033
|
+
*/
|
|
8034
|
+
interface SchemaVisitorContext<TPlugin = unknown> {
|
|
8035
|
+
/** Current path in the schema tree. */
|
|
8036
|
+
path: Ref<ReadonlyArray<string | number>>;
|
|
8037
|
+
/** The plugin instance. */
|
|
8038
|
+
plugin: TPlugin;
|
|
8039
|
+
}
|
|
8040
|
+
/**
|
|
8041
|
+
* The walk function signature. Fully generic over TResult.
|
|
8042
|
+
*/
|
|
8043
|
+
type Walker<TResult, TPlugin = unknown> = (schema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>) => TResult;
|
|
8044
|
+
/**
|
|
8045
|
+
* The visitor interface. Plugins define their own TResult type.
|
|
8046
|
+
*
|
|
8047
|
+
* The walker handles orchestration (dispatch, deduplication, path tracking).
|
|
8048
|
+
* Result shape and semantics are entirely plugin-defined.
|
|
8049
|
+
*/
|
|
8050
|
+
interface SchemaVisitor<TResult, TPlugin = unknown> {
|
|
8051
|
+
/**
|
|
8052
|
+
* Apply modifiers to a result.
|
|
8053
|
+
*/
|
|
8054
|
+
applyModifiers(result: TResult, ctx: SchemaVisitorContext<TPlugin>, context?: {
|
|
8055
|
+
/** Is this property optional? */
|
|
8056
|
+
optional?: boolean;
|
|
8057
|
+
}): unknown;
|
|
8058
|
+
array(schema: SchemaWithType<'array'>, ctx: SchemaVisitorContext<TPlugin>, walk: Walker<TResult, TPlugin>): TResult;
|
|
8059
|
+
boolean(schema: SchemaWithType<'boolean'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8060
|
+
enum(schema: SchemaWithType<'enum'>, ctx: SchemaVisitorContext<TPlugin>, walk: Walker<TResult, TPlugin>): TResult;
|
|
8061
|
+
integer(schema: SchemaWithType<'integer'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8062
|
+
/**
|
|
8063
|
+
* Called before any dispatch logic. Return a result to short-circuit,
|
|
8064
|
+
* or undefined to continue normal dispatch.
|
|
8065
|
+
*/
|
|
8066
|
+
intercept?(schema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>, walk: Walker<TResult, TPlugin>): TResult | undefined;
|
|
8067
|
+
/**
|
|
8068
|
+
* Handle intersection types. Receives already-walked child results.
|
|
8069
|
+
*/
|
|
8070
|
+
intersection(items: Array<TResult>, schemas: ReadonlyArray<IR.SchemaObject>, parentSchema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8071
|
+
never(schema: SchemaWithType<'never'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8072
|
+
null(schema: SchemaWithType<'null'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8073
|
+
number(schema: SchemaWithType<'number'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8074
|
+
object(schema: SchemaWithType<'object'>, ctx: SchemaVisitorContext<TPlugin>, walk: Walker<TResult, TPlugin>): TResult;
|
|
8075
|
+
/**
|
|
8076
|
+
* Called after each typed schema visitor returns.
|
|
8077
|
+
*/
|
|
8078
|
+
postProcess?(result: TResult, schema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8079
|
+
/**
|
|
8080
|
+
* Handle $ref to another schema.
|
|
8081
|
+
*/
|
|
8082
|
+
reference($ref: string, schema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8083
|
+
string(schema: SchemaWithType<'string'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8084
|
+
tuple(schema: SchemaWithType<'tuple'>, ctx: SchemaVisitorContext<TPlugin>, walk: Walker<TResult, TPlugin>): TResult;
|
|
8085
|
+
undefined(schema: SchemaWithType<'undefined'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8086
|
+
/**
|
|
8087
|
+
* Handle union types. Receives already-walked child results.
|
|
8088
|
+
*/
|
|
8089
|
+
union(items: Array<TResult>, schemas: ReadonlyArray<IR.SchemaObject>, parentSchema: IR.SchemaObject, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8090
|
+
unknown(schema: SchemaWithType<'unknown'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8091
|
+
void(schema: SchemaWithType<'void'>, ctx: SchemaVisitorContext<TPlugin>): TResult;
|
|
8092
|
+
}
|
|
8093
|
+
/**
|
|
8094
|
+
* Create a schema walker from a visitor.
|
|
8095
|
+
*
|
|
8096
|
+
* The walker handles:
|
|
8097
|
+
* - Dispatch order ($ref → type → items → fallback)
|
|
8098
|
+
* - Deduplication of union/intersection schemas
|
|
8099
|
+
* - Path tracking for child schemas
|
|
8100
|
+
*/
|
|
8101
|
+
declare function createSchemaWalker<TResult, TPlugin = unknown>(visitor: SchemaVisitor<TResult, TPlugin>): Walker<TResult, TPlugin>;
|
|
8102
|
+
/**
|
|
8103
|
+
* Helper to create a child context with an extended path.
|
|
8104
|
+
*/
|
|
8105
|
+
declare function childContext<TPlugin>(ctx: SchemaVisitorContext<TPlugin>, ...segments: ReadonlyArray<string | number>): SchemaVisitorContext<TPlugin>;
|
|
8106
|
+
//#endregion
|
|
8107
|
+
//#region src/ir/utils.d.ts
|
|
8108
|
+
/**
|
|
8109
|
+
* Simply adds `items` to the schema. Also handles setting the logical operator
|
|
8110
|
+
* and avoids setting it for a single item or tuples.
|
|
8111
|
+
*/
|
|
8112
|
+
declare function addItemsToSchema({
|
|
8113
|
+
items,
|
|
8114
|
+
logicalOperator,
|
|
8115
|
+
mutateSchemaOneItem,
|
|
8116
|
+
schema
|
|
8117
|
+
}: {
|
|
8118
|
+
items: Array<IR.SchemaObject>;
|
|
8119
|
+
logicalOperator?: IR.SchemaObject['logicalOperator'];
|
|
8120
|
+
mutateSchemaOneItem?: boolean;
|
|
8121
|
+
schema: IR.SchemaObject;
|
|
8122
|
+
}): IR.SchemaObject;
|
|
8123
|
+
//#endregion
|
|
7848
8124
|
//#region src/openApi/index.d.ts
|
|
7849
8125
|
/**
|
|
7850
8126
|
* @internal
|
|
@@ -8009,12 +8285,7 @@ declare function patchOpenApiSpec({
|
|
|
8009
8285
|
}: {
|
|
8010
8286
|
patchOptions: Patch | undefined;
|
|
8011
8287
|
spec: unknown;
|
|
8012
|
-
}): void
|
|
8013
|
-
//#endregion
|
|
8014
|
-
//#region src/plugins/shared/types/schema.d.ts
|
|
8015
|
-
type SchemaWithType<T extends Required<IR.SchemaObject>['type'] = Required<IR.SchemaObject>['type']> = Omit<IR.SchemaObject, 'type'> & {
|
|
8016
|
-
type: Extract<Required<IR.SchemaObject>['type'], T>;
|
|
8017
|
-
};
|
|
8288
|
+
}): Promise<void>;
|
|
8018
8289
|
//#endregion
|
|
8019
8290
|
//#region src/plugins/shared/utils/config.d.ts
|
|
8020
8291
|
declare const definePluginConfig: <T extends Plugin.Types>(defaultConfig: Plugin.Config<T>) => (userConfig?: Omit<T["config"], "name">) => Omit<Plugin.Config<T>, "name"> & {
|
|
@@ -8131,6 +8402,32 @@ declare class MinHeap {
|
|
|
8131
8402
|
private sinkDown;
|
|
8132
8403
|
}
|
|
8133
8404
|
//#endregion
|
|
8405
|
+
//#region src/utils/path.d.ts
|
|
8406
|
+
interface PathToNameOptions {
|
|
8407
|
+
/**
|
|
8408
|
+
* When provided, replaces the root semantic segments with this anchor.
|
|
8409
|
+
* Structural suffixes are still derived from path.
|
|
8410
|
+
*/
|
|
8411
|
+
anchor?: string;
|
|
8412
|
+
}
|
|
8413
|
+
/**
|
|
8414
|
+
* Derives a composite name from a path.
|
|
8415
|
+
*
|
|
8416
|
+
* Examples:
|
|
8417
|
+
* .../User → 'User'
|
|
8418
|
+
* .../User/properties/address → 'UserAddress'
|
|
8419
|
+
* .../User/properties/properties → 'UserProperties'
|
|
8420
|
+
* .../User/properties/address/properties/city → 'UserAddressCity'
|
|
8421
|
+
* .../Pet/additionalProperties → 'PetValue'
|
|
8422
|
+
* .../Order/properties/items/items/0 → 'OrderItems'
|
|
8423
|
+
* paths//event/get/properties/query → 'EventGetQuery'
|
|
8424
|
+
*
|
|
8425
|
+
* With anchor:
|
|
8426
|
+
* paths//event/get/properties/query, { anchor: 'event.subscribe' }
|
|
8427
|
+
* → 'event.subscribe-Query'
|
|
8428
|
+
*/
|
|
8429
|
+
declare function pathToName(path: ReadonlyArray<string | number>, options?: PathToNameOptions): string;
|
|
8430
|
+
//#endregion
|
|
8134
8431
|
//#region src/utils/ref.d.ts
|
|
8135
8432
|
/**
|
|
8136
8433
|
* Returns the reusable component name from `$ref`.
|
|
@@ -8181,7 +8478,7 @@ declare function normalizeJsonPointer(pointer: string): string;
|
|
|
8181
8478
|
*/
|
|
8182
8479
|
declare function pathToJsonPointer(path: ReadonlyArray<string | number>): string;
|
|
8183
8480
|
/**
|
|
8184
|
-
* Checks if a $ref points to a top-level component (not a deep path reference).
|
|
8481
|
+
* Checks if a $ref or path points to a top-level component (not a deep path reference).
|
|
8185
8482
|
*
|
|
8186
8483
|
* Top-level component references:
|
|
8187
8484
|
* - OpenAPI 3.x: #/components/{type}/{name} (3 segments)
|
|
@@ -8190,10 +8487,10 @@ declare function pathToJsonPointer(path: ReadonlyArray<string | number>): string
|
|
|
8190
8487
|
* Deep path references (4+ segments for 3.x, 3+ for 2.0) should be inlined
|
|
8191
8488
|
* because they don't have corresponding registered symbols.
|
|
8192
8489
|
*
|
|
8193
|
-
* @param
|
|
8490
|
+
* @param refOrPath - The $ref string or path array to check
|
|
8194
8491
|
* @returns true if the ref points to a top-level component, false otherwise
|
|
8195
8492
|
*/
|
|
8196
|
-
declare function
|
|
8493
|
+
declare function isTopLevelComponent(refOrPath: string | ReadonlyArray<string | number>): boolean;
|
|
8197
8494
|
declare function resolveRef<T>({
|
|
8198
8495
|
$ref,
|
|
8199
8496
|
spec
|
|
@@ -8211,5 +8508,5 @@ interface Url {
|
|
|
8211
8508
|
}
|
|
8212
8509
|
declare function parseUrl(value: string): Url;
|
|
8213
8510
|
//#endregion
|
|
8214
|
-
export { type AnyConfig, type AnyPluginName, type BaseConfig, type BaseOutput, type BaseUserConfig, type BaseUserOutput, type Casing, type CodeSampleObject, type CommentsOption, ConfigError, ConfigValidationError, Context, type DefinePlugin, type Dependency, type EnumExtensions, type FeatureToggle, type Filters, HeyApiError, type Hooks, type IR, type IndexExportOption, type Input, IntentContext, JobError, type LinguistLanguages, type Logs, MinHeap, type NameTransformer, type NamingConfig, type NamingOptions, type NamingRule, type OpenApi, type OpenApiMetaObject, type OpenApiOperationObject, type OpenApiParameterObject, type OpenApiRequestBodyObject, type OpenApiResponseObject, type OpenApiSchemaObject, type OpenApiV2_0_X, type OpenApiV2_0_XTypes, type OpenApiV3_0_X, type OpenApiV3_0_XTypes, type OpenApiV3_1_X, type OpenApiV3_1_XTypes, OperationPath, type OperationPathStrategy, OperationStrategy, type OperationStructureStrategy, type OperationsStrategy, type OutputHeader, type Parser, type Patch, type Plugin, type PluginConfigMap, type PluginContext, PluginInstance, type PluginInstanceTypes, type PluginNames, type PostProcessor, type SchemaWithType, type SourceConfig, type UserCommentsOption, type UserIndexExportOption, type UserInput, type UserParser, type UserPostProcessor, type UserSourceConfig, type UserWatch, type ValueToObject, type Watch, type WatchValues, applyNaming, buildGraph, checkNodeVersion, compileInputPath, createOperationKey, debugTools, deduplicateSchema, defaultPaginationKeywords, definePluginConfig, dependencyFactory, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getInput, getLogs, getParser, getSpec, hasOperationDataRequired, hasParameterGroupObjectRequired, hasParametersObjectRequired, heyApiRegistryBaseUrl, inputToApiRegistry,
|
|
8511
|
+
export { type AnyConfig, type AnyPluginName, type BaseConfig, type BaseOutput, type BaseUserConfig, type BaseUserOutput, type Casing, type CodeSampleObject, type CommentsOption, ConfigError, ConfigValidationError, Context, type DefinePlugin, type Dependency, type EnumExtensions, type FeatureToggle, type Filters, HeyApiError, type Hooks, type IR, type IndexExportOption, type Input, IntentContext, JobError, type LinguistLanguages, type Logs, MinHeap, type NameTransformer, type NamingConfig, type NamingOptions, type NamingRule, type OpenApi, type OpenApiMetaObject, type OpenApiOperationObject, type OpenApiParameterObject, type OpenApiRequestBodyObject, type OpenApiResponseObject, type OpenApiSchemaObject, type OpenApiV2_0_X, type OpenApiV2_0_XTypes, type OpenApiV3_0_X, type OpenApiV3_0_XTypes, type OpenApiV3_1_X, type OpenApiV3_1_XTypes, OperationPath, type OperationPathStrategy, OperationStrategy, type OperationStructureStrategy, type OperationsStrategy, type OutputHeader, type Parser, type Patch, type Plugin, type PluginConfigMap, type PluginContext, PluginInstance, type PluginInstanceTypes, type PluginNames, type PostProcessor, type SchemaExtractor, type SchemaProcessor, type SchemaProcessorContext, type SchemaProcessorResult, type SchemaVisitor, type SchemaVisitorContext, type SchemaWithType, type SourceConfig, type UserCommentsOption, type UserIndexExportOption, type UserInput, type UserParser, type UserPostProcessor, type UserSourceConfig, type UserWatch, type ValueToObject, type Walker, type Watch, type WatchValues, addItemsToSchema, applyNaming, buildGraph, checkNodeVersion, childContext, compileInputPath, createOperationKey, createSchemaProcessor, createSchemaWalker, debugTools, deduplicateSchema, defaultPaginationKeywords, definePluginConfig, dependencyFactory, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getInput, getLogs, getParser, getSpec, hasOperationDataRequired, hasParameterGroupObjectRequired, hasParametersObjectRequired, heyApiRegistryBaseUrl, inputToApiRegistry, isTopLevelComponent, jsonPointerToPath, loadPackageJson, loadTsConfig, logCrashReport, logInputPaths, mappers, normalizeJsonPointer, openGitHubIssueWithCrashReport, operationPagination, operationResponsesMap, parameterWithPagination, parseOpenApiSpec, parseUrl, parseV2_0_X, parseV3_0_X, parseV3_1_X, patchOpenApiSpec, pathToJsonPointer, pathToName, postprocessOutput, printCliIntro, printCrashReport, refToName, resolveNaming, resolveRef, resolveSource, satisfies, shouldReportCrash, statusCodeToGroup, toCase, utils, valueToObject };
|
|
8215
8512
|
//# sourceMappingURL=index.d.mts.map
|