Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mintlify/prebuild

Package Overview
Dependencies
Maintainers
5
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mintlify/prebuild - npm Package Compare versions

Comparing version 1.0.68 to 1.0.69

63

dist/prebuild/createPage.js

@@ -0,1 +1,2 @@

import { getOpenApiOperationMethodAndEndpoint } from '@mintlify/common';
import matter from 'gray-matter';

@@ -29,4 +30,4 @@ import isAbsoluteUrl from 'is-absolute-url';

// Append data from OpenAPI if it exists
if (metadata?.openapi) {
const { title, description: openApiDescription } = getOpenApiTitleAndDescription(openApiFiles, metadata?.openapi);
if (metadata.openapi) {
const { title, description: openApiDescription } = getOpenApiTitleAndDescription(openApiFiles, metadata.openapi);
if (title) {

@@ -57,3 +58,3 @@ defaultTitle = title;

// Append data from OpenAPI if it exists
const { title, description } = getOpenApiTitleAndDescription(openApiFiles, metadata?.openapi);
const { title, description } = getOpenApiTitleAndDescription(openApiFiles, metadata.openapi);
if (title) {

@@ -99,8 +100,5 @@ defaultTitle = title;

visit(tree, (node) => {
if (node == null) {
return;
}
const n = node;
if (n.name === 'img' || n.name === 'source') {
const srcAttrIndex = n.attributes.findIndex((attr) => attr?.name === 'src');
const srcAttrIndex = n.attributes.findIndex((attr) => attr.name === 'src');
const nodeUrl = n.attributes[srcAttrIndex].value;

@@ -145,55 +143,14 @@ if (

const getOpenApiTitleAndDescription = (openApiFiles, openApiMetaField) => {
if (openApiFiles == null || !openApiMetaField) {
if (!openApiMetaField) {
return {};
}
const { operation } = getOpenApiOperationMethodAndEndpoint(openApiFiles, openApiMetaField);
if (operation == null) {
const openApiData = getOpenApiOperationMethodAndEndpoint(openApiMetaField, openApiFiles);
if (openApiData == undefined) {
return {};
}
return {
title: operation.summary,
description: operation.description,
title: openApiData.operation.summary,
description: openApiData.operation.description,
};
};
const getOpenApiOperationMethodAndEndpoint = (openApiFiles, openApiMetaField) => {
const { endpoint, method, filename } = extractMethodAndEndpoint(openApiMetaField);
let path;
openApiFiles?.forEach((file) => {
const openApiFile = file.spec;
const openApiPath = openApiFile?.paths && openApiFile?.paths[endpoint];
const isFilenameOrNone = !filename || filename === file.filename;
if (openApiPath && isFilenameOrNone) {
path = openApiPath;
}
});
if (path == null) {
return {};
}
let operation;
if (method) {
operation = path[method.toLowerCase()];
}
else {
const firstOperationKey = Object.keys(path)[0];
operation = path[firstOperationKey];
}
return {
operation,
method,
endpoint,
};
};
const extractMethodAndEndpoint = (openApiMetaField) => {
const methodRegex = /(get|post|put|delete|patch)\s/i;
const trimmed = openApiMetaField.trim();
const foundMethod = trimmed.match(methodRegex);
const startIndexOfMethod = foundMethod ? openApiMetaField.indexOf(foundMethod[0]) : 0;
const endIndexOfMethod = foundMethod ? startIndexOfMethod + foundMethod[0].length - 1 : 0;
const filename = openApiMetaField.substring(0, startIndexOfMethod).trim();
return {
method: foundMethod ? foundMethod[0].slice(0, -1).toUpperCase() : undefined,
endpoint: openApiMetaField.substring(endIndexOfMethod).trim(),
filename: filename ? filename : undefined,
};
};
const getLocationErrString = (filePath, contentDirectoryPath, error) => {

@@ -200,0 +157,0 @@ filePath = isAbsolute(filePath) ? relative(contentDirectoryPath, filePath) : filePath;

7

package.json
{
"name": "@mintlify/prebuild",
"type": "module",
"version": "1.0.68",
"version": "1.0.69",
"description": "Helpful functions for Mintlify's prebuild step",

@@ -71,3 +71,6 @@ "author": "Mintlify, Inc.",

},
"gitHead": "4e76dca81bccf1d79c8439731205b89157c9c796"
"dependencies": {
"@mintlify/common": "1.0.1"
},
"gitHead": "999f35530b15583af7280003c55a90fec3967601"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc