@mintlify/common 1.0.302 → 1.0.303

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,2 @@
1
+ import { AsyncAPIDocument, AsyncAPIDocumentInterface } from '../types/asyncapi.js';
2
+ export declare function asyncApiCheck(document: AsyncAPIDocument): Promise<AsyncAPIDocumentInterface | undefined>;
@@ -0,0 +1,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Parser } from '@asyncapi/parser';
11
+ export function asyncApiCheck(document) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ var _a;
14
+ try {
15
+ const parser = new Parser();
16
+ const { document: schema, diagnostics } = yield parser.parse(document);
17
+ if (diagnostics.length > 0) {
18
+ throw new Error((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message);
19
+ }
20
+ return schema;
21
+ }
22
+ catch (_b) {
23
+ return undefined;
24
+ }
25
+ });
26
+ }
@@ -0,0 +1,2 @@
1
+ import { AsyncAPIDocument } from '../types/asyncapi.js';
2
+ export declare const getAsyncApiDocumentFromUrl: (url: string) => Promise<AsyncAPIDocument>;
@@ -0,0 +1,34 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Parser } from '@asyncapi/parser';
11
+ import yaml from 'js-yaml';
12
+ export const getAsyncApiDocumentFromUrl = (url) => __awaiter(void 0, void 0, void 0, function* () {
13
+ try {
14
+ new URL(url);
15
+ }
16
+ catch (error) {
17
+ throw new Error(`Invalid URL: ${url}`);
18
+ }
19
+ const response = yield fetch(url);
20
+ const data = yield response.text();
21
+ const asyncApiDocument = yaml.load(data);
22
+ if (!asyncApiDocument) {
23
+ throw new Error(`Could not load AsyncAPI document from ${url}`);
24
+ }
25
+ const parser = new Parser();
26
+ const diagnostic = yield parser.validate(asyncApiDocument);
27
+ if (diagnostic.length > 0) {
28
+ const firstDiagnosis = diagnostic[0];
29
+ if (firstDiagnosis) {
30
+ throw new Error(`This AsyncAPI document is invalid, ${firstDiagnosis.path}, ${firstDiagnosis.code}`);
31
+ }
32
+ }
33
+ return asyncApiDocument;
34
+ });
@@ -0,0 +1,3 @@
1
+ export * from './asyncapi/getAsyncApiDocumentFromUrl.js';
2
+ export * from './asyncapi/asyncApiCheck.js';
3
+ export * from './types/asyncapi.js';
@@ -0,0 +1,3 @@
1
+ export * from './asyncapi/getAsyncApiDocumentFromUrl.js';
2
+ export * from './asyncapi/asyncApiCheck.js';
3
+ export * from './types/asyncapi.js';