api-invoke 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -215,6 +215,8 @@ interface Operation {
215
215
  errorHints?: Record<string, string>;
216
216
  /** Tags for grouping operations (e.g. ['users', 'admin']). */
217
217
  tags: string[];
218
+ /** Security scheme names required by this operation. Each inner array is an alternative (OR); items within are required together (AND). Empty array (`[]`) means explicitly no auth. `undefined` means no security info available. */
219
+ security?: string[][];
218
220
  /**
219
221
  * Custom body builder for protocol adapters (e.g., GraphQL).
220
222
  * When set and no explicit 'body' key is in args, the executor calls this instead of flat-arg assembly to construct the request body.
package/dist/index.d.ts CHANGED
@@ -215,6 +215,8 @@ interface Operation {
215
215
  errorHints?: Record<string, string>;
216
216
  /** Tags for grouping operations (e.g. ['users', 'admin']). */
217
217
  tags: string[];
218
+ /** Security scheme names required by this operation. Each inner array is an alternative (OR); items within are required together (AND). Empty array (`[]`) means explicitly no auth. `undefined` means no security info available. */
219
+ security?: string[][];
218
220
  /**
219
221
  * Custom body builder for protocol adapters (e.g., GraphQL).
220
222
  * When set and no explicit 'body' key is in args, the executor calls this instead of flat-arg assembly to construct the request body.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ContentType, ParamLocation, AuthType, HeaderName, ApiInvokeError, ErrorKind, HttpMethod, parseError, authError, httpError, SpecFormat, graphqlError, timeoutError, corsError, API_INVOKE_ERROR_NAME, networkError } from './chunk-TXAOTXB4.js';
2
- export { API_INVOKE_ERROR_NAME, ApiInvokeError, AuthType, ContentType, ErrorKind, HeaderName, HttpMethod, ParamLocation, SpecFormat, authError, corsError, graphqlError, httpError, networkError, parseError, parseGraphQLSchema, timeoutError } from './chunk-TXAOTXB4.js';
1
+ import { ContentType, ParamLocation, AuthType, HeaderName, ApiInvokeError, ErrorKind, HttpMethod, parseError, authError, httpError, SpecFormat, graphqlError, timeoutError, corsError, API_INVOKE_ERROR_NAME, networkError } from './chunk-576QTR6M.js';
2
+ export { API_INVOKE_ERROR_NAME, ApiInvokeError, AuthType, ContentType, ErrorKind, HeaderName, HttpMethod, ParamLocation, SpecFormat, authError, corsError, graphqlError, httpError, networkError, parseError, parseGraphQLSchema, timeoutError } from './chunk-576QTR6M.js';
3
3
  import SwaggerParser from '@apidevtools/swagger-parser';
4
4
 
5
5
  // src/core/sse.ts
@@ -830,6 +830,7 @@ function extractOperations(api, isOpenAPI3) {
830
830
  const { primary: responseSchema, all: responseSchemas } = extractResponseSchemas(op, isOpenAPI3);
831
831
  const responseContentType = extractResponseContentType(op, isOpenAPI3);
832
832
  const errorHints = extractErrorHints(op);
833
+ const security = extractOperationSecurity(op, api);
833
834
  const id = op.operationId ?? `${method}_${path.replace(/[{}\/]/g, "_").replace(/^_|_$/g, "").replace(/_+/g, "_")}`;
834
835
  operations.push({
835
836
  id,
@@ -843,12 +844,22 @@ function extractOperations(api, isOpenAPI3) {
843
844
  responseSchemas: Object.keys(responseSchemas).length > 0 ? responseSchemas : void 0,
844
845
  responseContentType,
845
846
  errorHints,
846
- tags: op.tags ?? []
847
+ tags: op.tags ?? [],
848
+ security
847
849
  });
848
850
  }
849
851
  }
850
852
  return operations;
851
853
  }
854
+ function extractOperationSecurity(op, api) {
855
+ if ("security" in op && op.security !== void 0) {
856
+ return op.security.map((req) => Object.keys(req));
857
+ }
858
+ if ("security" in api && api.security !== void 0) {
859
+ return api.security.map((req) => Object.keys(req));
860
+ }
861
+ return void 0;
862
+ }
852
863
  function parseParameter(param, isOpenAPI3) {
853
864
  const name = param.name;
854
865
  const location = param.in;
@@ -1265,7 +1276,7 @@ async function createClient(input, options = {}) {
1265
1276
  if (isSpecUrl(input)) {
1266
1277
  api = await fetchAndParseSpec(input, options);
1267
1278
  } else if (isGraphQLUrl(input)) {
1268
- const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-PMZEKQPK.js');
1279
+ const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-2SYVX2KD.js');
1269
1280
  api = await parseGraphQLSchema2(input, { endpoint: input, fetch: options.fetch });
1270
1281
  } else {
1271
1282
  api = await tryContentDetection(input, options);
@@ -1273,7 +1284,7 @@ async function createClient(input, options = {}) {
1273
1284
  } else {
1274
1285
  const obj = input;
1275
1286
  if (isGraphQLIntrospection(obj)) {
1276
- const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-PMZEKQPK.js');
1287
+ const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-2SYVX2KD.js');
1277
1288
  api = await parseGraphQLSchema2(input, { endpoint: options.specUrl, fetch: options.fetch });
1278
1289
  } else {
1279
1290
  api = await parseOpenAPISpec(input, { specUrl: options.specUrl });
@@ -1330,7 +1341,7 @@ async function tryContentDetection(url, options) {
1330
1341
  return parseOpenAPISpec(obj, { specUrl: url });
1331
1342
  }
1332
1343
  if (isGraphQLIntrospection(obj)) {
1333
- const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-PMZEKQPK.js');
1344
+ const { parseGraphQLSchema: parseGraphQLSchema2 } = await import('./parser-2SYVX2KD.js');
1334
1345
  return parseGraphQLSchema2(obj, { endpoint: url, fetch: options.fetch });
1335
1346
  }
1336
1347
  return parseRawUrl(url);