@kubb/plugin-oas 3.0.0-alpha.1 → 3.0.0-alpha.3
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/OperationGenerator-D7rSlflc.d.cts +158 -0
- package/dist/OperationGenerator-vw0Zf-Mi.d.ts +158 -0
- package/dist/{Schema-an5hOrjZ.d.cts → Schema-DxyOIX7q.d.cts} +1 -1
- package/dist/{Schema-DefwBJMc.d.ts → Schema-gHgN14i2.d.ts} +1 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-BM1IGWqD.d.cts} +1 -1
- package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-BM1IGWqD.d.ts} +1 -1
- package/dist/{chunk-DRLYORTT.cjs → chunk-264TCCJF.cjs} +715 -7
- package/dist/chunk-264TCCJF.cjs.map +1 -0
- package/dist/chunk-7KIEQOVZ.cjs +7 -0
- package/dist/chunk-7KIEQOVZ.cjs.map +1 -0
- package/dist/{chunk-LEACSHKT.js → chunk-FZN3PBEK.js} +713 -5
- package/dist/chunk-FZN3PBEK.js.map +1 -0
- package/dist/chunk-TWKZEVSM.js +7 -0
- package/dist/chunk-TWKZEVSM.js.map +1 -0
- package/dist/components.cjs +4 -9
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +12 -6
- package/dist/components.d.ts +12 -6
- package/dist/components.js +3 -8
- package/dist/components.js.map +1 -1
- package/dist/hooks.cjs +6 -7
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +3 -3
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +1 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +225 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -77
- package/dist/index.d.ts +8 -77
- package/dist/index.js +207 -141
- package/dist/index.js.map +1 -1
- package/dist/{types-Dte3MA6H.d.cts → types-C2RXaY0_.d.cts} +1 -1
- package/dist/{types-Dte3MA6H.d.ts → types-C2RXaY0_.d.ts} +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +9 -9
- package/src/OperationGenerator.ts +62 -31
- package/src/SchemaGenerator.ts +23 -4
- package/src/components/Oas.tsx +8 -2
- package/src/index.ts +3 -9
- package/src/parser.tsx +120 -0
- package/src/plugin.ts +1 -9
- package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
- package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
- package/dist/chunk-CJXRFYEF.cjs +0 -698
- package/dist/chunk-CJXRFYEF.cjs.map +0 -1
- package/dist/chunk-DRLYORTT.cjs.map +0 -1
- package/dist/chunk-K6KUETAI.js +0 -698
- package/dist/chunk-K6KUETAI.js.map +0 -1
- package/dist/chunk-LEACSHKT.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { Oas } from './Oas.tsx'\nexport { Operation } from './Operation.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;AAAA;","names":[]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-7KIEQOVZ.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var _chunkDRLYORTTcjs = require('./chunk-DRLYORTT.cjs');
|
|
6
|
-
require('./chunk-CJXRFYEF.cjs');
|
|
7
5
|
|
|
6
|
+
var _chunk264TCCJFcjs = require('./chunk-264TCCJF.cjs');
|
|
7
|
+
require('./chunk-P42X362U.cjs');
|
|
8
8
|
|
|
9
|
-
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
10
9
|
|
|
11
|
-
// src/components/index.ts
|
|
12
|
-
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
13
10
|
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.Oas = _chunkDRLYORTTcjs.Oas; exports.Operation = _chunkDRLYORTTcjs.Operation; exports.Schema = _chunkDRLYORTTcjs.Schema;
|
|
12
|
+
exports.Oas = _chunk264TCCJFcjs.Oas; exports.Operation = _chunk264TCCJFcjs.Operation; exports.Schema = _chunk264TCCJFcjs.Schema;
|
|
18
13
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs"
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs"],"names":[],"mappings":"AAAA,yGAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,gIAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/components.cjs"}
|
package/dist/components.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-DxyOIX7q.cjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react';
|
|
5
|
-
import { a as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { a as OperationGenerator } from './OperationGenerator-D7rSlflc.cjs';
|
|
6
6
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-
|
|
7
|
+
import './SchemaMapper-BM1IGWqD.cjs';
|
|
8
8
|
import '@kubb/core';
|
|
9
|
-
import './types-
|
|
9
|
+
import './types-C2RXaY0_.cjs';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
type Props$1 = {
|
|
@@ -24,13 +24,19 @@ declare namespace Operation {
|
|
|
24
24
|
type Props = {
|
|
25
25
|
oas: Oas$1;
|
|
26
26
|
operations?: Operation$1[];
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
28
31
|
children?: KubbNode;
|
|
29
32
|
};
|
|
30
33
|
type OasContextProps = {
|
|
31
34
|
oas?: Oas$1;
|
|
32
35
|
operations?: Operation$1[];
|
|
33
|
-
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
39
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
34
40
|
};
|
|
35
41
|
declare function Oas({ oas, children, operations, generator }: Props): KubbNode;
|
|
36
42
|
declare namespace Oas {
|
package/dist/components.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-gHgN14i2.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { Operation as Operation$1, Oas as Oas$1 } from '@kubb/oas';
|
|
4
4
|
import { KubbNode } from '@kubb/react';
|
|
5
|
-
import { a as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { a as OperationGenerator } from './OperationGenerator-vw0Zf-Mi.js';
|
|
6
6
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-
|
|
7
|
+
import './SchemaMapper-BM1IGWqD.js';
|
|
8
8
|
import '@kubb/core';
|
|
9
|
-
import './types-
|
|
9
|
+
import './types-C2RXaY0_.js';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
type Props$1 = {
|
|
@@ -24,13 +24,19 @@ declare namespace Operation {
|
|
|
24
24
|
type Props = {
|
|
25
25
|
oas: Oas$1;
|
|
26
26
|
operations?: Operation$1[];
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated
|
|
29
|
+
*/
|
|
30
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
28
31
|
children?: KubbNode;
|
|
29
32
|
};
|
|
30
33
|
type OasContextProps = {
|
|
31
34
|
oas?: Oas$1;
|
|
32
35
|
operations?: Operation$1[];
|
|
33
|
-
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
39
|
+
generator?: Omit<OperationGenerator, 'build'>;
|
|
34
40
|
};
|
|
35
41
|
declare function Oas({ oas, children, operations, generator }: Props): KubbNode;
|
|
36
42
|
declare namespace Oas {
|
package/dist/components.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
import "./chunk-TWKZEVSM.js";
|
|
1
2
|
import {
|
|
2
3
|
Oas,
|
|
3
4
|
Operation,
|
|
4
5
|
Schema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
init_esm_shims
|
|
9
|
-
} from "./chunk-UB552H4J.js";
|
|
10
|
-
|
|
11
|
-
// src/components/index.ts
|
|
12
|
-
init_esm_shims();
|
|
6
|
+
} from "./chunk-FZN3PBEK.js";
|
|
7
|
+
import "./chunk-UB552H4J.js";
|
|
13
8
|
export {
|
|
14
9
|
Oas,
|
|
15
10
|
Operation,
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/hooks.cjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-CJXRFYEF.cjs');
|
|
5
|
+
var _chunk264TCCJFcjs = require('./chunk-264TCCJF.cjs');
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
|
|
@@ -15,7 +14,7 @@ _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
|
15
14
|
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
16
15
|
var _react = require('@kubb/react');
|
|
17
16
|
function useOas() {
|
|
18
|
-
const { oas } = _react.useContext.call(void 0,
|
|
17
|
+
const { oas } = _react.useContext.call(void 0, _chunk264TCCJFcjs.Oas.Context);
|
|
19
18
|
if (!oas) {
|
|
20
19
|
throw new Error("Oas is not defined");
|
|
21
20
|
}
|
|
@@ -26,7 +25,7 @@ function useOas() {
|
|
|
26
25
|
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
27
26
|
|
|
28
27
|
function useOperation() {
|
|
29
|
-
const { operation } = _react.useContext.call(void 0,
|
|
28
|
+
const { operation } = _react.useContext.call(void 0, _chunk264TCCJFcjs.Operation.Context);
|
|
30
29
|
if (!operation) {
|
|
31
30
|
throw new Error("Operation is not defined");
|
|
32
31
|
}
|
|
@@ -38,7 +37,7 @@ _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
|
38
37
|
|
|
39
38
|
function useOperationManager() {
|
|
40
39
|
const { plugin, pluginManager } = _react.useApp.call(void 0, );
|
|
41
|
-
const { generator } = _react.useContext.call(void 0,
|
|
40
|
+
const { generator } = _react.useContext.call(void 0, _chunk264TCCJFcjs.Oas.Context);
|
|
42
41
|
if (!generator) {
|
|
43
42
|
throw new Error(`'generator' is not defined`);
|
|
44
43
|
}
|
|
@@ -142,7 +141,7 @@ function useOperationManager() {
|
|
|
142
141
|
_chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
|
|
143
142
|
|
|
144
143
|
function useOperations({ method, path } = {}) {
|
|
145
|
-
const { operations } = _react.useContext.call(void 0,
|
|
144
|
+
const { operations } = _react.useContext.call(void 0, _chunk264TCCJFcjs.Oas.Context);
|
|
146
145
|
if (!operations) {
|
|
147
146
|
throw new Error("Operations is not defined");
|
|
148
147
|
}
|
|
@@ -161,5 +160,5 @@ function useOperations({ method, path } = {}) {
|
|
|
161
160
|
|
|
162
161
|
|
|
163
162
|
|
|
164
|
-
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema =
|
|
163
|
+
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunk264TCCJFcjs.useSchema;
|
|
165
164
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8CAAA,CAAA;ADYA;AACA;AEbA,8CAAA,CAAA;AAAA,oCAA2B;AAMpB,SAAS,MAAA,CAAA,EAAkB;AAChC,EAAA,MAAM,EAAE,IAAI,EAAA,EAAI,+BAAA,qBAAW,CAAI,OAAO,CAAA;AAEtC,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA,CAAM,oBAAoB,CAAA;AAAA,EACtC;AAEA,EAAA,OAAO,GAAA;AACT;AFSA;AACA;AGxBA,8CAAA,CAAA;AAAA;AASO,SAAS,YAAA,CAAA,EAA8B;AAC5C,EAAA,MAAM,EAAE,UAAU,EAAA,EAAIA,+BAAAA,2BAAW,CAAU,OAAO,CAAA;AAElD,EAAA,GAAA,CAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,0BAA0B,CAAA;AAAA,EAC5C;AAEA,EAAA,OAAO,SAAA;AACT;AHiBA;AACA;AInCA,8CAAA,CAAA;AAAA;AAwCO,SAAS,mBAAA,CAAA,EAAiD;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,cAAc,EAAA,EAA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,EACF,CAAA;AACF;AJvBA;AACA;AK5IA,8CAAA,CAAA;AAAA;AAsBO,SAAS,aAAA,CAAc,EAAE,MAAA,EAAQ,KAAK,EAAA,EAAwB,CAAC,CAAA,EAAgB;AACpF,EAAA,MAAM,EAAE,WAAW,EAAA,EAAIA,+BAAAA,qBAAW,CAAI,OAAO,CAAA;AAE7C,EAAA,GAAA,CAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,KAAA,CAAM,2BAA2B,CAAA;AAAA,EAC7C;AACA,EAAA,IAAI,MAAA,EAAQ,UAAA;AAEZ,EAAA,GAAA,CAAI,IAAA,EAAM;AACR,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,IAAI,CAAA;AAAA,EACnD;AAEA,EAAA,GAAA,CAAI,MAAA,EAAQ;AACV,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,OAAA,IAAW,MAAM,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,KAAA;AACT;ALsHA;AACE;AACA;AACA;AACA;AACA;AACF,wMAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","sourcesContent":[null,"export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACTA,8CAAA,CAAA;ADWA;AACA;AEZA,8CAAA,CAAA;AAAA,oCAA2B;AAMpB,SAAS,MAAA,CAAA,EAAkB;AAChC,EAAA,MAAM,EAAE,IAAI,EAAA,EAAI,+BAAA,qBAAW,CAAI,OAAO,CAAA;AAEtC,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,KAAA,CAAM,oBAAoB,CAAA;AAAA,EACtC;AAEA,EAAA,OAAO,GAAA;AACT;AFQA;AACA;AGvBA,8CAAA,CAAA;AAAA;AASO,SAAS,YAAA,CAAA,EAA8B;AAC5C,EAAA,MAAM,EAAE,UAAU,EAAA,EAAIA,+BAAAA,2BAAW,CAAU,OAAO,CAAA;AAElD,EAAA,GAAA,CAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,0BAA0B,CAAA;AAAA,EAC5C;AAEA,EAAA,OAAO,SAAA;AACT;AHgBA;AACA;AIlCA,8CAAA,CAAA;AAAA;AAwCO,SAAS,mBAAA,CAAA,EAAiD;AAC/D,EAAA,MAAM,EAAE,MAAA,EAAQ,cAAc,EAAA,EAAI,2BAAA,CAAO;AACzC,EAAA,MAAM,EAAE,UAAU,EAAA,EAAIA,+BAAAA,qBAAW,CAAI,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EAAE,MAAA,EAAQ,KAAK,EAAA,EAAwB,CAAC,CAAA,EAAgB;AACpF,EAAA,MAAM,EAAE,WAAW,EAAA,EAAIA,+BAAAA,qBAAW,CAAI,OAAO,CAAA;AAE7C,EAAA,GAAA,CAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,KAAA,CAAM,2BAA2B,CAAA;AAAA,EAC7C;AACA,EAAA,IAAI,MAAA,EAAQ,UAAA;AAEZ,EAAA,GAAA,CAAI,IAAA,EAAM;AACR,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,IAAI,CAAA;AAAA,EACnD;AAEA,EAAA,GAAA,CAAI,MAAA,EAAQ;AACV,IAAA,MAAA,EAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,OAAA,IAAW,MAAM,CAAA;AAAA,EACvD;AAEA,EAAA,OAAO,KAAA;AACT;ALqHA;AACE;AACA;AACA;AACA;AACA;AACF,wMAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/hooks.cjs","sourcesContent":[null,"export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"]}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
2
2
|
import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
|
|
3
3
|
import * as KubbFile from '@kubb/fs/types';
|
|
4
|
-
import {
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
4
|
+
import { e as OperationSchemas } from './types-C2RXaY0_.cjs';
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-DxyOIX7q.cjs';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-BM1IGWqD.cjs';
|
|
10
10
|
|
|
11
11
|
declare function useOas(): Oas;
|
|
12
12
|
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Oas, Operation, HttpMethod } from '@kubb/oas';
|
|
2
2
|
import { Plugin, ResolveNameParams, FileMetaBase } from '@kubb/core';
|
|
3
3
|
import * as KubbFile from '@kubb/fs/types';
|
|
4
|
-
import {
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
4
|
+
import { e as OperationSchemas } from './types-C2RXaY0_.js';
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-gHgN14i2.js';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-BM1IGWqD.js';
|
|
10
10
|
|
|
11
11
|
declare function useOas(): Oas;
|
|
12
12
|
|
package/dist/hooks.js
CHANGED
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"],"mappings":";;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AACT;;;ACdA;AAAA,SAAS,cAAAA,mBAAkB;AASpB,SAAS,eAA8B;AAC5C,QAAM,EAAE,UAAU,IAAIC,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAC,mBAAkB;AAwC5B,SAAS,sBAAiD;AAC/D,QAAM,EAAE,QAAQ,cAAc,IAAI,OAAO;AACzC,QAAM,EAAE,UAAU,IAAIC,YAAW,IAAI,OAAO;AAE5C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,QAAM,UAAgD,CAAC,WAAW,EAAE,YAAY,OAAO,KAAK,KAAK,MAAM;AACrG,WAAO,cAAc,YAAY;AAAA,MAC/B,MAAM,UAAU,eAAe;AAAA,MAC/B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,UAAgD,CAAC,WAAW,EAAE,YAAY,OAAO,KAAK,UAAU,MAAM,IAAI,CAAC,MAAM;AAErH,UAAM,MAAM,UAAU,QAAQ,EAAE,GAAG,CAAC,GAAG;AACvC,UAAM,OAAO,QAAQ,WAAW,E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