@mintlify/common 1.0.591 → 1.0.592

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.
@@ -0,0 +1,13 @@
1
+ import { PageMetaTags } from '@mintlify/models';
2
+ import { parseAsyncApiString } from '../asyncapi/parseAsyncApiString.js';
3
+ import { parseOpenApiSchemaString, parseOpenApiString } from '../openapi/parseOpenApiString.js';
4
+ export type SchemaTargetType = {
5
+ type: 'schema';
6
+ } & ReturnType<typeof parseOpenApiSchemaString>;
7
+ export type OperationTargetType = {
8
+ type: 'operation';
9
+ } & ReturnType<typeof parseOpenApiString>;
10
+ export type AsyncApiTargetType = {
11
+ type: 'asyncapi';
12
+ } & ReturnType<typeof parseAsyncApiString>;
13
+ export declare const parseApiTargetFromMetadata: (metadata: PageMetaTags) => SchemaTargetType | OperationTargetType | AsyncApiTargetType | undefined;
@@ -0,0 +1,25 @@
1
+ import { parseAsyncApiString } from '../asyncapi/parseAsyncApiString.js';
2
+ import { parseOpenApiSchemaString, parseOpenApiString } from '../openapi/parseOpenApiString.js';
3
+ export const parseApiTargetFromMetadata = (metadata) => {
4
+ const openapiSchema = metadata['openapi-schema'];
5
+ if (typeof openapiSchema === 'string' && openapiSchema.length > 0) {
6
+ return Object.assign({ type: 'schema' }, parseOpenApiSchemaString(openapiSchema));
7
+ }
8
+ const openapi = metadata.openapi;
9
+ if (typeof openapi === 'string' && openapi.length > 0) {
10
+ try {
11
+ return Object.assign({ type: 'operation' }, parseOpenApiString(openapi));
12
+ }
13
+ catch (error) {
14
+ console.error(`unable to parse value "${openapi}" for field "openapi":`, error);
15
+ return undefined;
16
+ }
17
+ }
18
+ const asyncapi = metadata.asyncapi;
19
+ if (typeof asyncapi === 'string' && asyncapi.length > 0) {
20
+ const asyncApiMetadata = parseAsyncApiString(asyncapi);
21
+ return asyncApiMetadata
22
+ ? Object.assign({ type: 'asyncapi' }, asyncApiMetadata) : undefined;
23
+ }
24
+ return undefined;
25
+ };
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export * from './services/aws.js';
23
23
  export * from './slugify.js';
24
24
  export * from './services/aws.js';
25
25
  export * from './truncateAtWordBoundary.js';
26
+ export * from './api-reference/parseApiTargetFromMetadata.js';
package/dist/index.js CHANGED
@@ -23,3 +23,4 @@ export * from './services/aws.js';
23
23
  export * from './slugify.js';
24
24
  export * from './services/aws.js';
25
25
  export * from './truncateAtWordBoundary.js';
26
+ export * from './api-reference/parseApiTargetFromMetadata.js';