@kubb/plugin-oas 3.0.0-alpha.6 → 3.0.0-alpha.8
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-Dzs1oRvm.d.ts → OperationGenerator-DeXrfGDC.d.ts} +2 -2
- package/dist/{OperationGenerator-Do52cvD0.d.cts → OperationGenerator-DhJ0MBKc.d.cts} +2 -2
- package/dist/{Schema-C90zFdkU.d.ts → Schema-B1vcPGiK.d.ts} +2 -4
- package/dist/{Schema-DDVEcNcu.d.cts → Schema-DoSFh7Qd.d.cts} +2 -4
- package/dist/{SchemaMapper-BM1IGWqD.d.cts → SchemaMapper-sGcY1xL5.d.cts} +0 -1
- package/dist/{SchemaMapper-BM1IGWqD.d.ts → SchemaMapper-sGcY1xL5.d.ts} +0 -1
- package/dist/chunk-75BIOXB7.cjs +7 -0
- package/dist/{chunk-7KIEQOVZ.cjs.map → chunk-75BIOXB7.cjs.map} +1 -1
- package/dist/{chunk-UJNAXXVE.js → chunk-MUI5DWM3.js} +458 -465
- package/dist/{chunk-UJNAXXVE.js.map → chunk-MUI5DWM3.js.map} +1 -1
- package/dist/{chunk-Y4V7HHX7.js → chunk-N7EEVJA6.js} +3 -3
- package/dist/{chunk-P42X362U.cjs → chunk-NU4F7G47.cjs} +4 -16
- package/dist/chunk-NU4F7G47.cjs.map +1 -0
- package/dist/{chunk-QLJIL3U5.cjs → chunk-O76YQFZB.cjs} +3 -3
- package/dist/{chunk-QLJIL3U5.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
- package/dist/{chunk-TWKZEVSM.js → chunk-SQ64ESS4.js} +2 -2
- package/dist/{chunk-UB552H4J.js → chunk-SZDO532A.js} +3 -15
- package/dist/{chunk-UB552H4J.js.map → chunk-SZDO532A.js.map} +1 -1
- package/dist/{chunk-RQZBFORW.cjs → chunk-VSVVTCQB.cjs} +481 -488
- package/dist/chunk-VSVVTCQB.cjs.map +1 -0
- package/dist/components.cjs +4 -4
- package/dist/components.d.cts +4 -4
- package/dist/components.d.ts +4 -4
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +12 -12
- 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 +2 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +112 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +83 -86
- package/dist/index.js.map +1 -1
- package/dist/{types-C2RXaY0_.d.cts → types-CZTUCaE5.d.cts} +2 -0
- package/dist/{types-C2RXaY0_.d.ts → types-CZTUCaE5.d.ts} +2 -0
- package/dist/utils.cjs +9 -54
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +5 -35
- package/dist/utils.d.ts +5 -35
- package/dist/utils.js +2 -47
- package/dist/utils.js.map +1 -1
- package/package.json +9 -9
- package/src/SchemaGenerator.ts +2 -2
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Schema.tsx +8 -4
- package/src/hooks/useOperationManager.ts +1 -0
- package/src/plugin.ts +11 -0
- package/src/types.ts +2 -0
- package/src/utils/index.ts +0 -1
- package/dist/chunk-7KIEQOVZ.cjs +0 -7
- package/dist/chunk-P42X362U.cjs.map +0 -1
- package/dist/chunk-RQZBFORW.cjs.map +0 -1
- package/src/utils/getGroupedByTagFiles.ts +0 -84
- /package/dist/{chunk-Y4V7HHX7.js.map → chunk-N7EEVJA6.js.map} +0 -0
- /package/dist/{chunk-TWKZEVSM.js.map → chunk-SQ64ESS4.js.map} +0 -0
package/dist/components.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-75BIOXB7.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('./chunk-
|
|
6
|
+
var _chunkVSVVTCQBcjs = require('./chunk-VSVVTCQB.cjs');
|
|
7
|
+
require('./chunk-NU4F7G47.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.Oas =
|
|
12
|
+
exports.Oas = _chunkVSVVTCQBcjs.Oas; exports.Operation = _chunkVSVVTCQBcjs.Operation; exports.Schema = _chunkVSVVTCQBcjs.Schema;
|
|
13
13
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-DoSFh7Qd.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/types';
|
|
5
|
-
import { a as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { a as OperationGenerator } from './OperationGenerator-DhJ0MBKc.cjs';
|
|
6
|
+
import './SchemaMapper-sGcY1xL5.cjs';
|
|
6
7
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-BM1IGWqD.cjs';
|
|
8
8
|
import '@kubb/core';
|
|
9
|
-
import './types-
|
|
9
|
+
import './types-CZTUCaE5.cjs';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
type Props$1 = {
|
package/dist/components.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as Schema } from './Schema-
|
|
1
|
+
import { S as Schema } from './Schema-B1vcPGiK.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/types';
|
|
5
|
-
import { a as OperationGenerator } from './OperationGenerator-
|
|
5
|
+
import { a as OperationGenerator } from './OperationGenerator-DeXrfGDC.js';
|
|
6
|
+
import './SchemaMapper-sGcY1xL5.js';
|
|
6
7
|
import '@kubb/fs/types';
|
|
7
|
-
import './SchemaMapper-BM1IGWqD.js';
|
|
8
8
|
import '@kubb/core';
|
|
9
|
-
import './types-
|
|
9
|
+
import './types-CZTUCaE5.js';
|
|
10
10
|
import '@kubb/oas/parser';
|
|
11
11
|
|
|
12
12
|
type Props$1 = {
|
package/dist/components.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-SQ64ESS4.js";
|
|
2
2
|
import {
|
|
3
3
|
Oas,
|
|
4
4
|
Operation,
|
|
5
5
|
Schema
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-MUI5DWM3.js";
|
|
7
|
+
import "./chunk-SZDO532A.js";
|
|
8
8
|
export {
|
|
9
9
|
Oas,
|
|
10
10
|
Operation,
|
package/dist/hooks.cjs
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkVSVVTCQBcjs = require('./chunk-VSVVTCQB.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
|
|
9
9
|
|
|
10
10
|
// src/hooks/index.ts
|
|
11
|
-
|
|
11
|
+
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
12
12
|
|
|
13
13
|
// src/hooks/useOas.ts
|
|
14
|
-
|
|
14
|
+
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
15
15
|
var _react = require('@kubb/react');
|
|
16
16
|
function useOas() {
|
|
17
|
-
const { oas } = _react.useContext.call(void 0,
|
|
17
|
+
const { oas } = _react.useContext.call(void 0, _chunkVSVVTCQBcjs.Oas.Context);
|
|
18
18
|
if (!oas) {
|
|
19
19
|
throw new Error("Oas is not defined");
|
|
20
20
|
}
|
|
@@ -22,10 +22,10 @@ function useOas() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// src/hooks/useOperation.ts
|
|
25
|
-
|
|
25
|
+
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
26
26
|
|
|
27
27
|
function useOperation() {
|
|
28
|
-
const { operation } = _react.useContext.call(void 0,
|
|
28
|
+
const { operation } = _react.useContext.call(void 0, _chunkVSVVTCQBcjs.Operation.Context);
|
|
29
29
|
if (!operation) {
|
|
30
30
|
throw new Error("Operation is not defined");
|
|
31
31
|
}
|
|
@@ -33,11 +33,11 @@ function useOperation() {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// src/hooks/useOperationManager.ts
|
|
36
|
-
|
|
36
|
+
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
37
37
|
|
|
38
38
|
function useOperationManager() {
|
|
39
39
|
const { plugin, pluginManager } = _react.useApp.call(void 0, );
|
|
40
|
-
const { generator } = _react.useContext.call(void 0,
|
|
40
|
+
const { generator } = _react.useContext.call(void 0, _chunkVSVVTCQBcjs.Oas.Context);
|
|
41
41
|
if (!generator) {
|
|
42
42
|
throw new Error(`'generator' is not defined`);
|
|
43
43
|
}
|
|
@@ -138,10 +138,10 @@ function useOperationManager() {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// src/hooks/useOperations.ts
|
|
141
|
-
|
|
141
|
+
_chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
|
|
142
142
|
|
|
143
143
|
function useOperations({ method, path } = {}) {
|
|
144
|
-
const { operations } = _react.useContext.call(void 0,
|
|
144
|
+
const { operations } = _react.useContext.call(void 0, _chunkVSVVTCQBcjs.Oas.Context);
|
|
145
145
|
if (!operations) {
|
|
146
146
|
throw new Error("Operations is not defined");
|
|
147
147
|
}
|
|
@@ -160,5 +160,5 @@ function useOperations({ method, path } = {}) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
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 = _chunkVSVVTCQBcjs.useSchema;
|
|
164
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;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,MA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AAC,CAAA;AAAA,IACH;AAAA,EACF,CAAA;AACF;AJxBA;AACA;AK3IA,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;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"]}
|
|
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,EA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A;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;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 //TODO replace with group\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 { e as OperationSchemas } from './types-
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
4
|
+
import { e as OperationSchemas } from './types-CZTUCaE5.cjs';
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-DoSFh7Qd.cjs';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react/types';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-sGcY1xL5.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 { e as OperationSchemas } from './types-
|
|
5
|
-
import { a as SchemaContextProps } from './Schema-
|
|
4
|
+
import { e as OperationSchemas } from './types-CZTUCaE5.js';
|
|
5
|
+
import { a as SchemaContextProps } from './Schema-B1vcPGiK.js';
|
|
6
6
|
import '@kubb/oas/parser';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@kubb/react/types';
|
|
9
|
-
import './SchemaMapper-
|
|
9
|
+
import './SchemaMapper-sGcY1xL5.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":";;;;;;;;;;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;
|
|
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 //TODO replace with group\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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