@mintlify/common 1.0.305 → 1.0.307
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/asyncapi/asyncApiCheck.d.ts +2 -2
- package/dist/asyncapi/asyncApiCheck.js +4 -2
- package/dist/asyncapi/validate.d.ts +7 -0
- package/dist/asyncapi/validate.js +20 -0
- package/dist/asyncapi.d.ts +1 -0
- package/dist/asyncapi.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/title.d.ts +1 -0
- package/dist/title.js +8 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/asyncapi.d.ts +8 -2
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function asyncApiCheck(
|
|
1
|
+
import { AsyncAPIDocumentInterface } from '../types/asyncapi.js';
|
|
2
|
+
export declare function asyncApiCheck(obj: object): Promise<AsyncAPIDocumentInterface | undefined>;
|
|
@@ -8,12 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Parser } from '@asyncapi/parser';
|
|
11
|
-
export function asyncApiCheck(
|
|
11
|
+
export function asyncApiCheck(obj) {
|
|
12
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
13
|
var _a;
|
|
14
14
|
try {
|
|
15
|
+
const objectAsInput = typeof obj === 'string' ? obj : JSON.stringify(obj);
|
|
15
16
|
const parser = new Parser();
|
|
16
|
-
const { document: schema, diagnostics } = yield parser.parse(
|
|
17
|
+
const { document: schema, diagnostics } = yield parser.parse(objectAsInput);
|
|
18
|
+
console.log(diagnostics[0]);
|
|
17
19
|
if (diagnostics.length > 0) {
|
|
18
20
|
throw new Error((_a = diagnostics[0]) === null || _a === void 0 ? void 0 : _a.message);
|
|
19
21
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AsyncAPIDocumentInterface } from '../types/asyncapi.js';
|
|
2
|
+
export type ValidateResult = {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
errorMessage?: string;
|
|
5
|
+
schema?: AsyncAPIDocumentInterface;
|
|
6
|
+
};
|
|
7
|
+
export declare const validateAsyncApi: (document: unknown) => Promise<ValidateResult>;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 const validateAsyncApi = (document) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const documentAsInput = typeof document === 'string' ? document : JSON.stringify(document);
|
|
13
|
+
const parser = new Parser();
|
|
14
|
+
const { document: schema, diagnostics } = yield parser.parse(documentAsInput);
|
|
15
|
+
if (diagnostics.length > 0) {
|
|
16
|
+
const errorMessages = diagnostics.map((diagnostic) => diagnostic.message).join('\n');
|
|
17
|
+
return { valid: false, errorMessage: errorMessages, schema: undefined };
|
|
18
|
+
}
|
|
19
|
+
return { valid: true, errorMessage: undefined, schema };
|
|
20
|
+
});
|
package/dist/asyncapi.d.ts
CHANGED
package/dist/asyncapi.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/title.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertStrToTitle(str: string): string;
|
package/dist/title.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function convertStrToTitle(str) {
|
|
2
|
+
const spacedString = str.replace(/[-_\/]/g, ' ');
|
|
3
|
+
const words = spacedString.split(/(?=[A-Z])|\s+/);
|
|
4
|
+
const titleCasedWords = words.map((word) => {
|
|
5
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
6
|
+
});
|
|
7
|
+
return titleCasedWords.join(' ').trim();
|
|
8
|
+
}
|