@kubb/plugin-ts 4.1.4 → 4.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/components-Cf7RuPmU.cjs +580 -0
- package/dist/components-Cf7RuPmU.cjs.map +1 -0
- package/dist/components-Wl2A-qA2.js +491 -0
- package/dist/components-Wl2A-qA2.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +2 -3
- package/dist/components.d.ts +2 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{plugin--SAE5fJd.cjs → plugin--YEvuFfE.cjs} +30 -26
- package/dist/plugin--YEvuFfE.cjs.map +1 -0
- package/dist/{plugin-C6Jg0eqz.js → plugin-BafrBt4Q.js} +31 -27
- package/dist/plugin-BafrBt4Q.js.map +1 -0
- package/dist/{types-C7OjrC1J.d.ts → types-DpBnlY1n.d.cts} +78 -122
- package/dist/{types-BLgrg7-y.d.cts → types-gqUseg33.d.ts} +79 -123
- package/package.json +10 -10
- package/src/components/Type.tsx +8 -10
- package/src/factory.ts +578 -0
- package/src/generators/oasGenerator.tsx +6 -7
- package/src/generators/typeGenerator.tsx +21 -12
- package/src/parser.ts +1 -1
- package/src/plugin.ts +5 -8
- package/dist/components-3SwDb74W.cjs +0 -1962
- package/dist/components-3SwDb74W.cjs.map +0 -1
- package/dist/components-CSEFpzdz.js +0 -1940
- package/dist/components-CSEFpzdz.js.map +0 -1
- package/dist/plugin--SAE5fJd.cjs.map +0 -1
- package/dist/plugin-C6Jg0eqz.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-BafrBt4Q.js","names":["properties: Record<string, ts.TypeNode>","factory.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","options","type","Type","options","groupName: Group['name']","transformers"],"sources":["../src/generators/typeGenerator.tsx","../src/generators/oasGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/fabric-core/parsers/typescript'\nimport {\n createReactGenerator,\n isKeyword,\n type OperationSchemas,\n type OperationSchema as OperationSchemaType,\n SchemaGenerator,\n schemaKeywords,\n} from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport type ts from 'typescript'\nimport { Type } from '../components'\nimport * as factory from '../factory.ts'\nimport { pluginTsName } from '../plugin.ts'\nimport type { PluginTs } from '../types'\n\nfunction printCombinedSchema({ name, schemas, pluginManager }: { name: string; schemas: OperationSchemas; pluginManager: PluginManager }): string {\n const properties: Record<string, ts.TypeNode> = {}\n\n if (schemas.response) {\n properties['response'] = factory.createUnionDeclaration({\n nodes: schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['request'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['pathParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['queryParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['headerParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map((error) => {\n const identifier = pluginManager.resolveName({\n name: error.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(\n Object.keys(properties)\n .map((key) => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature({\n name: transformers.pascalCase(key),\n type,\n })\n })\n .filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print([namespaceNode])\n}\n\nexport const typeGenerator = createReactGenerator<PluginTs>({\n name: 'typescript',\n Operation({ operation, options }) {\n const { mapper, enumType, syntaxType, optionalType } = options\n\n const plugin = usePlugin<PluginTs>()\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getName, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const type = getName(operation, { type: 'function', pluginKey: [pluginTsName] })\n const combinedSchemaName = operation.method === 'get' ? `${type}Query` : `${type}Mutation`\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const type = {\n name: schemaManager.getName(name, { type: 'type' }),\n typedName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(options.operationName || name, { group }),\n }\n\n return (\n <Oas.Schema key={[name, schemaObject.$ref].join('-')} name={name} schemaObject={schemaObject} tree={tree}>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={description}\n tree={tree}\n schema={schemaObject}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n keysToOmit={keysToOmit}\n syntaxType={syntaxType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {operationSchemas.map(mapOperationSchema)}\n\n <File.Source name={combinedSchemaName} isExportable isIndexable isTypeOnly>\n {printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager })}\n </File.Source>\n </File>\n )\n },\n Schema({ schema, options }) {\n const { mapper, enumType, syntaxType, optionalType } = options\n const {\n options: { output },\n } = usePlugin<PluginTs>()\n const mode = useMode()\n\n const oas = useOas()\n const pluginManager = usePluginManager()\n\n const { getName, getImports, getFile } = useSchemaManager()\n const imports = getImports(schema.tree)\n const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema)\n\n if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\n\n let typedName = getName(schema.name, { type: 'type' })\n\n if (enumType === 'asConst' && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) {\n typedName = typedName += 'Key' //Suffix for avoiding collisions (https://github.com/kubb-labs/kubb/issues/1873)\n }\n\n const type = {\n name: getName(schema.name, { type: 'function' }),\n typedName,\n file: getFile(schema.name),\n }\n\n return (\n <File\n baseName={type.file.baseName}\n path={type.file.path}\n meta={type.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[schema.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations() {\n const {\n options: { output },\n key: pluginKey,\n } = usePlugin<PluginTs>()\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { oasGenerator, typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = createPlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumSuffix = 'enum',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n },\n context() {\n return {\n usedEnumNames: {} as Record<string, number>,\n }\n },\n pre: [pluginOasName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAsBA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAMA,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,cAAcC,uBAA+B,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AAEF,SAAOC,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;GACvF,EACH,CAAC;AAGJ,KAAI,QAAQ,SAAS;EACnB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,QAAQ;GACtB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,aAAaD,wBAAgCC,iBAAyB,WAAW,EAAE,OAAU;;AAG1G,KAAI,QAAQ,YAAY;EACtB,MAAM,aAAa,cAAc,YAAY;GAC3C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,cAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,cAAc,MAXI,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
import ts from "typescript";
|
|
9
10
|
|
|
10
11
|
//#region ../oas/src/types.d.ts
|
|
@@ -47,17 +48,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
47
48
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
48
49
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
49
50
|
*/
|
|
50
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
51
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
51
52
|
#private;
|
|
52
|
-
constructor(options?: TOptions, context?: TContext);
|
|
53
|
-
get options(): TOptions;
|
|
53
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
54
|
+
get options(): TOptions$1;
|
|
54
55
|
get context(): TContext;
|
|
55
|
-
set options(options: TOptions);
|
|
56
|
+
set options(options: TOptions$1);
|
|
56
57
|
abstract build(...params: unknown[]): unknown;
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../core/src/fs/types.d.ts
|
|
60
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
61
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
61
62
|
type Import = {
|
|
62
63
|
/**
|
|
63
64
|
* Import name to be used
|
|
@@ -131,7 +132,7 @@ type BaseName = `${string}.${string}`;
|
|
|
131
132
|
* Path will be full qualified path to a specified file
|
|
132
133
|
*/
|
|
133
134
|
type Path = string;
|
|
134
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
135
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
135
136
|
type OptionalPath = Path | undefined | null;
|
|
136
137
|
type File<TMeta extends object = object> = {
|
|
137
138
|
/**
|
|
@@ -220,9 +221,7 @@ type Logger = {
|
|
|
220
221
|
};
|
|
221
222
|
//#endregion
|
|
222
223
|
//#region ../core/src/utils/types.d.ts
|
|
223
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
224
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
225
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
224
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
226
225
|
//#endregion
|
|
227
226
|
//#region ../core/src/types.d.ts
|
|
228
227
|
type InputPath = {
|
|
@@ -335,11 +334,11 @@ TName extends string = string,
|
|
|
335
334
|
/**
|
|
336
335
|
* Options of the plugin.
|
|
337
336
|
*/
|
|
338
|
-
TOptions extends object = object,
|
|
337
|
+
TOptions$1 extends object = object,
|
|
339
338
|
/**
|
|
340
339
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
341
340
|
*/
|
|
342
|
-
TResolvedOptions extends object = TOptions,
|
|
341
|
+
TResolvedOptions extends object = TOptions$1,
|
|
343
342
|
/**
|
|
344
343
|
* Context that you want to expose to other plugins.
|
|
345
344
|
*/
|
|
@@ -353,23 +352,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
353
352
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
354
353
|
*/
|
|
355
354
|
key: PluginKey<TName | string>;
|
|
356
|
-
options: TOptions;
|
|
355
|
+
options: TOptions$1;
|
|
357
356
|
resolvedOptions: TResolvedOptions;
|
|
358
357
|
context: TContext;
|
|
359
358
|
resolvePathOptions: TResolvePathOptions;
|
|
360
359
|
};
|
|
361
360
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
362
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
361
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
363
362
|
/**
|
|
364
363
|
* Unique name used for the plugin
|
|
365
364
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
366
365
|
* @example @kubb/typescript
|
|
367
366
|
*/
|
|
368
|
-
name: TOptions['name'];
|
|
367
|
+
name: TOptions$1['name'];
|
|
369
368
|
/**
|
|
370
369
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
371
370
|
*/
|
|
372
|
-
options: TOptions['resolvedOptions'];
|
|
371
|
+
options: TOptions$1['resolvedOptions'];
|
|
373
372
|
/**
|
|
374
373
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
375
374
|
* Can be used to validate dependent plugins.
|
|
@@ -379,23 +378,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
379
378
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
380
379
|
*/
|
|
381
380
|
post?: Array<string>;
|
|
382
|
-
} & (TOptions['context'] extends never ? {
|
|
381
|
+
} & (TOptions$1['context'] extends never ? {
|
|
383
382
|
context?: never;
|
|
384
383
|
} : {
|
|
385
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
384
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
386
385
|
});
|
|
387
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
388
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
386
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
387
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
389
388
|
/**
|
|
390
389
|
* Unique name used for the plugin
|
|
391
390
|
* @example @kubb/typescript
|
|
392
391
|
*/
|
|
393
|
-
name: TOptions['name'];
|
|
392
|
+
name: TOptions$1['name'];
|
|
394
393
|
/**
|
|
395
394
|
* Internal key used when a developer uses more than one of the same plugin
|
|
396
395
|
* @private
|
|
397
396
|
*/
|
|
398
|
-
key: TOptions['key'];
|
|
397
|
+
key: TOptions$1['key'];
|
|
399
398
|
/**
|
|
400
399
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
401
400
|
* Can be used to validate dependent plugins.
|
|
@@ -408,49 +407,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
408
407
|
/**
|
|
409
408
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
410
409
|
*/
|
|
411
|
-
options: TOptions['resolvedOptions'];
|
|
412
|
-
} & (TOptions['context'] extends never ? {
|
|
410
|
+
options: TOptions$1['resolvedOptions'];
|
|
411
|
+
} & (TOptions$1['context'] extends never ? {
|
|
413
412
|
context?: never;
|
|
414
413
|
} : {
|
|
415
|
-
context: TOptions['context'];
|
|
414
|
+
context: TOptions$1['context'];
|
|
416
415
|
});
|
|
417
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
418
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
416
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
417
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
419
418
|
/**
|
|
420
419
|
* Start of the lifecycle of a plugin.
|
|
421
420
|
* @type hookParallel
|
|
422
421
|
*/
|
|
423
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
422
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
424
423
|
/**
|
|
425
424
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
426
425
|
* Options can als be included.
|
|
427
426
|
* @type hookFirst
|
|
428
427
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
429
428
|
*/
|
|
430
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
429
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
431
430
|
/**
|
|
432
431
|
* Resolve to a name based on a string.
|
|
433
432
|
* Useful when converting to PascalCase or camelCase.
|
|
434
433
|
* @type hookFirst
|
|
435
434
|
* @example ('pet') => 'Pet'
|
|
436
435
|
*/
|
|
437
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
436
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
437
|
/**
|
|
439
438
|
* End of the plugin lifecycle.
|
|
440
439
|
* @type hookParallel
|
|
441
440
|
*/
|
|
442
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
441
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
443
442
|
};
|
|
444
443
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
445
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
446
|
-
type ResolvePathParams<TOptions = object> = {
|
|
444
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
445
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
447
446
|
pluginKey?: Plugin['key'];
|
|
448
447
|
baseName: BaseName;
|
|
449
448
|
mode?: Mode;
|
|
450
449
|
/**
|
|
451
450
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
452
451
|
*/
|
|
453
|
-
options?: TOptions;
|
|
452
|
+
options?: TOptions$1;
|
|
454
453
|
};
|
|
455
454
|
type ResolveNameParams = {
|
|
456
455
|
name: string;
|
|
@@ -463,12 +462,15 @@ type ResolveNameParams = {
|
|
|
463
462
|
*/
|
|
464
463
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
465
464
|
};
|
|
466
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
465
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
467
466
|
config: Config;
|
|
467
|
+
/**
|
|
468
|
+
* @deprecated
|
|
469
|
+
*/
|
|
468
470
|
fileManager: FileManager;
|
|
469
471
|
pluginManager: PluginManager;
|
|
470
472
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
471
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
473
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
472
474
|
resolveName: (params: ResolveNameParams) => string;
|
|
473
475
|
logger: Logger;
|
|
474
476
|
/**
|
|
@@ -478,12 +480,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
478
480
|
/**
|
|
479
481
|
* Current plugin
|
|
480
482
|
*/
|
|
481
|
-
plugin: Plugin<TOptions>;
|
|
483
|
+
plugin: Plugin<TOptions$1>;
|
|
482
484
|
};
|
|
483
485
|
/**
|
|
484
486
|
* Specify the export location for the files and define the behavior of the output
|
|
485
487
|
*/
|
|
486
|
-
type Output<TOptions> = {
|
|
488
|
+
type Output<TOptions$1> = {
|
|
487
489
|
/**
|
|
488
490
|
* Path to the output folder or file that will contain the generated code
|
|
489
491
|
*/
|
|
@@ -496,11 +498,11 @@ type Output<TOptions> = {
|
|
|
496
498
|
/**
|
|
497
499
|
* Add a banner text in the beginning of every file
|
|
498
500
|
*/
|
|
499
|
-
banner?: string | ((options: TOptions) => string);
|
|
501
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
500
502
|
/**
|
|
501
503
|
* Add a footer text in the beginning of every file
|
|
502
504
|
*/
|
|
503
|
-
footer?: string | ((options: TOptions) => string);
|
|
505
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
504
506
|
};
|
|
505
507
|
type GroupContext = {
|
|
506
508
|
group: string;
|
|
@@ -516,73 +518,19 @@ type Group = {
|
|
|
516
518
|
name?: (context: GroupContext) => string;
|
|
517
519
|
};
|
|
518
520
|
//#endregion
|
|
519
|
-
//#region ../core/src/FileManager.d.ts
|
|
520
|
-
type FileMetaBase = {
|
|
521
|
-
pluginKey?: Plugin['key'];
|
|
522
|
-
};
|
|
523
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
524
|
-
type AddIndexesProps = {
|
|
525
|
-
type: BarrelType | false | undefined;
|
|
526
|
-
/**
|
|
527
|
-
* Root based on root and output.path specified in the config
|
|
528
|
-
*/
|
|
529
|
-
root: string;
|
|
530
|
-
/**
|
|
531
|
-
* Output for plugin
|
|
532
|
-
*/
|
|
533
|
-
output: {
|
|
534
|
-
path: string;
|
|
535
|
-
};
|
|
536
|
-
group?: {
|
|
537
|
-
output: string;
|
|
538
|
-
exportAs: string;
|
|
539
|
-
};
|
|
540
|
-
logger?: Logger;
|
|
541
|
-
meta?: FileMetaBase;
|
|
542
|
-
};
|
|
543
|
-
type WriteFilesProps = {
|
|
544
|
-
root: Config['root'];
|
|
545
|
-
extension?: Record<Extname, Extname | ''>;
|
|
546
|
-
logger?: Logger;
|
|
547
|
-
dryRun?: boolean;
|
|
548
|
-
};
|
|
549
|
-
declare class FileManager {
|
|
550
|
-
#private;
|
|
551
|
-
constructor();
|
|
552
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
553
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
554
|
-
deleteByPath(path: Path): Promise<void>;
|
|
555
|
-
clear(): Promise<void>;
|
|
556
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
557
|
-
processFiles({
|
|
558
|
-
dryRun,
|
|
559
|
-
root,
|
|
560
|
-
extension,
|
|
561
|
-
logger
|
|
562
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
563
|
-
getBarrelFiles({
|
|
564
|
-
type,
|
|
565
|
-
meta,
|
|
566
|
-
root,
|
|
567
|
-
output,
|
|
568
|
-
logger
|
|
569
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
570
|
-
static getMode(path: string | undefined | null): Mode;
|
|
571
|
-
}
|
|
572
|
-
//#endregion
|
|
573
521
|
//#region ../core/src/PluginManager.d.ts
|
|
574
522
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
575
523
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
576
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
524
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
577
525
|
message: string;
|
|
578
526
|
strategy: Strategy;
|
|
579
|
-
hookName: H;
|
|
527
|
+
hookName: H$1;
|
|
580
528
|
plugin: Plugin;
|
|
581
529
|
parameters?: unknown[] | undefined;
|
|
582
530
|
output?: unknown;
|
|
583
531
|
};
|
|
584
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
585
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
532
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
533
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
586
534
|
result: Result;
|
|
587
535
|
plugin: Plugin;
|
|
588
536
|
};
|
|
@@ -598,16 +546,19 @@ type Events = {
|
|
|
598
546
|
executed: [executer: Executer];
|
|
599
547
|
error: [error: Error];
|
|
600
548
|
};
|
|
601
|
-
type GetFileProps<TOptions = object> = {
|
|
549
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
602
550
|
name: string;
|
|
603
551
|
mode?: Mode;
|
|
604
552
|
extname: Extname;
|
|
605
553
|
pluginKey: Plugin['key'];
|
|
606
|
-
options?: TOptions;
|
|
554
|
+
options?: TOptions$1;
|
|
607
555
|
};
|
|
608
556
|
declare class PluginManager {
|
|
609
557
|
#private;
|
|
610
558
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
559
|
+
/**
|
|
560
|
+
* @deprecated do not use from pluginManager
|
|
561
|
+
*/
|
|
611
562
|
readonly fileManager: FileManager;
|
|
612
563
|
readonly events: EventEmitter<Events>;
|
|
613
564
|
readonly config: Config;
|
|
@@ -716,6 +667,11 @@ declare class PluginManager {
|
|
|
716
667
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
717
668
|
}
|
|
718
669
|
//#endregion
|
|
670
|
+
//#region ../core/src/FileManager.d.ts
|
|
671
|
+
type FileMetaBase = {
|
|
672
|
+
pluginKey?: Plugin['key'];
|
|
673
|
+
};
|
|
674
|
+
//#endregion
|
|
719
675
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
720
676
|
type SchemaKeywordMapper = {
|
|
721
677
|
object: {
|
|
@@ -1009,12 +965,12 @@ type ByContentType = {
|
|
|
1009
965
|
};
|
|
1010
966
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1011
967
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1012
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1013
|
-
options: Partial<TOptions>;
|
|
968
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
969
|
+
options: Partial<TOptions$1>;
|
|
1014
970
|
};
|
|
1015
971
|
//#endregion
|
|
1016
972
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1017
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
973
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1018
974
|
oas: Oas;
|
|
1019
975
|
pluginManager: PluginManager;
|
|
1020
976
|
/**
|
|
@@ -1023,7 +979,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1023
979
|
plugin: Plugin<TPluginOptions>;
|
|
1024
980
|
mode: Mode;
|
|
1025
981
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1026
|
-
override: Array<Override<TOptions>> | undefined;
|
|
982
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1027
983
|
contentType?: contentType;
|
|
1028
984
|
output?: string;
|
|
1029
985
|
};
|
|
@@ -1054,7 +1010,7 @@ type SchemaProps$1 = {
|
|
|
1054
1010
|
name?: string;
|
|
1055
1011
|
parentName?: string;
|
|
1056
1012
|
};
|
|
1057
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1013
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1058
1014
|
#private;
|
|
1059
1015
|
refs: Refs;
|
|
1060
1016
|
/**
|
|
@@ -1073,39 +1029,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1073
1029
|
}
|
|
1074
1030
|
//#endregion
|
|
1075
1031
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1076
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1077
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1078
|
-
options: TOptions['resolvedOptions'];
|
|
1032
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1033
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1034
|
+
options: TOptions$1['resolvedOptions'];
|
|
1079
1035
|
operations: Array<Operation$1>;
|
|
1080
1036
|
};
|
|
1081
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1082
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1083
|
-
options: TOptions['resolvedOptions'];
|
|
1037
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1038
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1039
|
+
options: TOptions$1['resolvedOptions'];
|
|
1084
1040
|
operation: Operation$1;
|
|
1085
1041
|
};
|
|
1086
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1087
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1088
|
-
options: TOptions['resolvedOptions'];
|
|
1042
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1043
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1044
|
+
options: TOptions$1['resolvedOptions'];
|
|
1089
1045
|
schema: {
|
|
1090
1046
|
name: string;
|
|
1091
1047
|
tree: Array<Schema>;
|
|
1092
1048
|
value: SchemaObject$1;
|
|
1093
1049
|
};
|
|
1094
1050
|
};
|
|
1095
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1051
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1096
1052
|
name: string;
|
|
1097
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1098
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1099
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1053
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1054
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1055
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1100
1056
|
};
|
|
1101
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1057
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1102
1058
|
//#endregion
|
|
1103
1059
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1104
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1060
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1105
1061
|
oas: Oas;
|
|
1106
1062
|
exclude: Array<Exclude$1> | undefined;
|
|
1107
1063
|
include: Array<Include> | undefined;
|
|
1108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1064
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1109
1065
|
contentType: contentType | undefined;
|
|
1110
1066
|
pluginManager: PluginManager;
|
|
1111
1067
|
/**
|
|
@@ -1241,5 +1197,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
|
|
|
1241
1197
|
usedEnumNames: Record<string, number>;
|
|
1242
1198
|
}, ResolvePathOptions>;
|
|
1243
1199
|
//#endregion
|
|
1244
|
-
export {
|
|
1245
|
-
//# sourceMappingURL=types-
|
|
1200
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1201
|
+
//# sourceMappingURL=types-DpBnlY1n.d.cts.map
|