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

@scalar/oas-utils

Package Overview
Dependencies
Maintainers
0
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/oas-utils - npm Package Compare versions

Comparing version 0.2.62 to 0.2.63

dist/helpers/fetchWithProxyFallback.d.ts

8

CHANGELOG.md
# @scalar/oas-utils
## 0.2.63
### Patch Changes
- ada8545: feat: add the sidebar button
- Updated dependencies [ad12c56]
- @scalar/themes@0.9.44
## 0.2.62

@@ -4,0 +12,0 @@

32

dist/entities/spec/collection.d.ts

@@ -110,3 +110,5 @@ import { z } from 'zod';

*/
watchForChanges: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
watchMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/** Keeps track of which integration is associated with the specific collection */
integration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
/**

@@ -117,3 +119,3 @@ * Status of the watcher from above

*/
watchForChangesStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
watchModeStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
}, "strip", z.ZodTypeAny, {

@@ -155,5 +157,6 @@ uid: string;

}>;
watchForChanges: boolean;
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
watchMode: boolean;
watchModeStatus: "IDLE" | "WATCHING" | "ERROR";
documentUrl?: string | undefined;
integration?: string | null | undefined;
}, {

@@ -196,4 +199,5 @@ uid?: string | undefined;

documentUrl?: string | undefined;
watchForChanges?: boolean | undefined;
watchForChangesStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
watchMode?: boolean | undefined;
integration?: string | null | undefined;
watchModeStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
}>;

@@ -401,3 +405,5 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{

*/
watchForChanges: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
watchMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/** Keeps track of which integration is associated with the specific collection */
integration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
/**

@@ -408,3 +414,3 @@ * Status of the watcher from above

*/
watchForChangesStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
watchModeStatus: z.ZodDefault<z.ZodOptional<z.ZodEnum<["IDLE", "WATCHING", "ERROR"]>>>;
}>, "strip", z.ZodTypeAny, {

@@ -450,4 +456,4 @@ type: "collection";

}>;
watchForChanges: boolean;
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
watchMode: boolean;
watchModeStatus: "IDLE" | "WATCHING" | "ERROR";
externalDocs?: {

@@ -478,2 +484,3 @@ url: string;

documentUrl?: string | undefined;
integration?: string | null | undefined;
}, {

@@ -544,4 +551,5 @@ type?: "collection" | undefined;

documentUrl?: string | undefined;
watchForChanges?: boolean | undefined;
watchForChangesStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
watchMode?: boolean | undefined;
integration?: string | null | undefined;
watchModeStatus?: "IDLE" | "WATCHING" | "ERROR" | undefined;
}>;

@@ -548,0 +556,0 @@ export type Collection = z.infer<typeof collectionSchema>;

@@ -71,3 +71,5 @@ import { oasSecurityRequirementSchema, securitySchemeExampleValueSchema } from './security.js';

*/
watchForChanges: z.boolean().optional().default(false),
watchMode: z.boolean().optional().default(false),
/** Keeps track of which integration is associated with the specific collection */
integration: z.string().nullable().optional(),
/**

@@ -78,3 +80,3 @@ * Status of the watcher from above

*/
watchForChangesStatus: z
watchModeStatus: z
.enum(['IDLE', 'WATCHING', 'ERROR'])

@@ -81,0 +83,0 @@ .optional()

/**
* Fetches an OpenAPI/Swagger specification from a given URL.
* Fetches an OpenAPI/Swagger document from a given URL.
*

@@ -4,0 +4,0 @@ * @throws an error if the fetch fails

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

import { redirectToProxy } from './redirectToProxy.js';
import { fetchWithProxyFallback } from './fetchWithProxyFallback.js';
import { formatJsonOrYamlString } from './parse.js';

@@ -9,3 +9,3 @@

/**
* Fetches an OpenAPI/Swagger specification from a given URL.
* Fetches an OpenAPI/Swagger document from a given URL.
*

@@ -20,19 +20,20 @@ * @throws an error if the fetch fails

}
// To use a proxy or not to use a proxy
const response = await fetch(proxy ? redirectToProxy(proxy, url) : url);
// Looks like the request failed
if (response.status !== 200) {
console.error(`[fetchSpecFromUrl] Failed to fetch the specification at ${url} (Status: ${response.status})`);
try {
const response = await fetchWithProxyFallback(url, proxy);
if (!response.ok) {
throw new Error(`Failed to fetch the OpenAPI document: ${url} (Status: ${response.status})`);
}
const text = await response.text();
// If it's JSON, make it pretty
return beautify ? formatJsonOrYamlString(text) : text;
}
catch (error) {
console.error(`[fetchSpecFromUrl] Failed to fetch the OpenAPI document at ${url}`, error);
if (!proxy) {
console.warn(`[fetchSpecFromUrl] Tried to fetch the specification (url: ${url}) without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`);
console.warn(`[fetchSpecFromUrl] Tried to fetch the OpenAPI document (${url}) without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`);
}
throw new Error(`Failed to fetch the specification (Status: ${response.status})`);
throw error;
}
// If it’s JSON, make it pretty
if (beautify)
return formatJsonOrYamlString(await response.text());
else
return await response.text();
}
export { fetchSpecFromUrl };
export * from './concatenateUrlAndPath.js';
export * from './createHash.js';
export * from './fetchSpecFromUrl.js';
export * from './fetchWithProxyFallback.js';
export * from './findVariables.js';
export * from './httpMethods.js';
export * from './httpStatusCodes.js';
export * from './isLocalUrl.js';
export * from './isValidUrl.js';
export * from './iterateTitle.js';
export * from './local-storage.js';
export * from './makeUrlAbsolute.js';
export * from './normalizeMimeType.js';

@@ -15,2 +19,3 @@ export * from './normalizeMimeTypeObject.js';

export * from './redirectToProxy.js';
export * from './regexHelpers.js';
export * from './replaceVariables.js';

@@ -20,4 +25,2 @@ export * from './schema-model.js';

export * from './string.js';
export * from './isValidUrl.js';
export * from './regexHelpers.js';
//# sourceMappingURL=index.d.ts.map
export { concatenateUrlAndPath } from './concatenateUrlAndPath.js';
export { createHash } from './createHash.js';
export { fetchSpecFromUrl } from './fetchSpecFromUrl.js';
export { fetchWithProxyFallback } from './fetchWithProxyFallback.js';
export { findVariables } from './findVariables.js';
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo } from './httpMethods.js';
export { httpStatusCodes } from './httpStatusCodes.js';
export { isLocalUrl } from './isLocalUrl.js';
export { isValidUrl } from './isValidUrl.js';
export { iterateTitle } from './iterateTitle.js';
export { LS_KEYS } from './local-storage.js';
export { makeUrlAbsolute } from './makeUrlAbsolute.js';
export { normalizeMimeType } from './normalizeMimeType.js';

@@ -14,3 +18,4 @@ export { normalizeMimeTypeObject } from './normalizeMimeTypeObject.js';

export { prettyPrintJson, replaceCircularDependencies } from './prettyPrintJson.js';
export { isRelativePath, isRequestToLocalhost, redirectToProxy, shouldUseProxy } from './redirectToProxy.js';
export { isRelativePath, redirectToProxy, shouldUseProxy } from './redirectToProxy.js';
export { pathRegex, variableRegex } from './regexHelpers.js';
export { replaceVariables } from './replaceVariables.js';

@@ -20,3 +25,1 @@ export { schemaModel } from './schema-model.js';

export { camelToTitleWords, capitalize } from './string.js';
export { isValidUrl } from './isValidUrl.js';
export { pathRegex, variableRegex } from './regexHelpers.js';

@@ -7,4 +7,2 @@ /** Redirects the request to a proxy server with a given URL. */

export declare function shouldUseProxy(proxy?: string, url?: string): boolean;
/** Detect requests to localhost */
export declare function isRequestToLocalhost(url: string): boolean;
//# sourceMappingURL=redirectToProxy.d.ts.map

@@ -0,1 +1,3 @@

import { isLocalUrl } from './isLocalUrl.js';
/** Redirects the request to a proxy server with a given URL. */

@@ -25,13 +27,7 @@ function redirectToProxy(proxy, url) {

// Requests to localhost
if (isRequestToLocalhost(url))
if (isLocalUrl(url))
return false;
return true;
}
/** Detect requests to localhost */
function isRequestToLocalhost(url) {
const { hostname } = new URL(url);
const listOfLocalUrls = ['localhost', '127.0.0.1', '[::1]'];
return listOfLocalUrls.includes(hostname);
}
export { isRelativePath, isRequestToLocalhost, redirectToProxy, shouldUseProxy };
export { isRelativePath, redirectToProxy, shouldUseProxy };

@@ -67,4 +67,4 @@ import type { v_0_0_0 } from '../../migrations/v-0.0.0/types.generated';

'x-scalar-icon': string;
watchForChanges: false;
watchForChangesStatus: "IDLE";
watchMode: false;
watchModeStatus: "IDLE";
}[];

@@ -71,0 +71,0 @@ cookies: v_0_0_0.Cookie[];

@@ -121,4 +121,4 @@ import { parseLocalStorage } from '../local-storage.js';

'x-scalar-icon': 'interface-content-folder',
'watchForChanges': false,
'watchForChangesStatus': 'IDLE',
'watchMode': false,
'watchModeStatus': 'IDLE',
};

@@ -125,0 +125,0 @@ });

@@ -45,4 +45,4 @@ import { type Collection, type Request } from '../entities/spec/index.js';

}>;
watchForChanges: boolean;
watchForChangesStatus: "IDLE" | "WATCHING" | "ERROR";
watchMode: boolean;
watchModeStatus: "IDLE" | "WATCHING" | "ERROR";
externalDocs?: {

@@ -73,3 +73,4 @@ url: string;

documentUrl?: string | undefined;
integration?: string | null | undefined;
};
//# sourceMappingURL=export-spec.d.ts.map

@@ -11,3 +11,3 @@ import { type Collection, type CollectionPayload, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js';

}>;
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchForChanges'> & Pick<ReferenceConfiguration, 'authentication'> & {
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ReferenceConfiguration, 'authentication'> & {
/** Sets the preferred security scheme on the collection instead of the requests */

@@ -24,3 +24,3 @@ setCollectionSecurity?: boolean;

*/
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, documentUrl, setCollectionSecurity, watchForChanges, }?: ImportSpecToWorkspaceArgs): Promise<{
export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, documentUrl, setCollectionSecurity, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
error: false;

@@ -27,0 +27,0 @@ collection: Collection;

@@ -93,3 +93,3 @@ import { securitySchemeSchema, authExampleFromSchema } from '../entities/spec/security.js';

*/
async function importSpecToWorkspace(spec, { authentication, documentUrl, setCollectionSecurity = false, watchForChanges = false, } = {}) {
async function importSpecToWorkspace(spec, { authentication, documentUrl, setCollectionSecurity = false, watchMode = false, } = {}) {
const { schema, errors } = await parseSchema(spec);

@@ -280,3 +280,3 @@ const importWarnings = [...errors.map((e) => e.message)];

...schema,
watchForChanges,
watchMode,
documentUrl,

@@ -283,0 +283,0 @@ auth,

@@ -19,3 +19,3 @@ {

],
"version": "0.2.62",
"version": "0.2.63",
"engines": {

@@ -110,6 +110,7 @@ "node": ">=18"

"zod": "^3.23.8",
"@scalar/import": "0.0.3",
"@scalar/object-utils": "1.1.10",
"@scalar/themes": "0.9.43",
"@scalar/openapi-types": "0.1.4",
"@scalar/types": "0.0.17"
"@scalar/themes": "0.9.44",
"@scalar/types": "0.0.17",
"@scalar/openapi-types": "0.1.4"
},

@@ -122,4 +123,4 @@ "devDependencies": {

"@scalar/build-tooling": "0.1.11",
"@scalar/openapi-types": "0.1.4",
"@scalar/openapi-parser": "0.8.8"
"@scalar/openapi-parser": "0.8.8",
"@scalar/openapi-types": "0.1.4"
},

@@ -126,0 +127,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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