@mintlify/validation 0.1.121 → 0.1.122
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/index.d.ts +333 -8
- package/dist/index.js +18 -54
- package/dist/mint-config/flattenNavigationVersions.d.ts +2 -0
- package/dist/mint-config/flattenNavigationVersions.js +10 -0
- package/dist/mint-config/refinements/refineMissingVersions.d.ts +6 -0
- package/dist/mint-config/refinements/refineMissingVersions.js +13 -0
- package/dist/mint-config/schemas/anchorColors.js +5 -20
- package/dist/mint-config/schemas/anchors.d.ts +4 -4
- package/dist/mint-config/schemas/colors.js +6 -25
- package/dist/mint-config/schemas/config.d.ts +11 -11
- package/dist/mint-config/schemas/config.js +1 -1
- package/dist/mint-config/schemas/hexColor.d.ts +2 -0
- package/dist/mint-config/schemas/hexColor.js +5 -0
- package/dist/mint-config/schemas/navigation.d.ts +2 -2
- package/dist/mint-config/warnings/aggregateWarnings.d.ts +4 -0
- package/dist/mint-config/warnings/aggregateWarnings.js +4 -0
- package/dist/mint-config/warnings/warnAnchorUrls.d.ts +2 -0
- package/dist/mint-config/warnings/warnAnchorUrls.js +20 -0
- package/dist/mint-config/warnings/warnUnusedVersions.d.ts +2 -0
- package/dist/mint-config/warnings/warnUnusedVersions.js +17 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/any.d.ts +0 -20
- package/dist/any.js +0 -27
- package/dist/mint-config/common.d.ts +0 -6
- package/dist/mint-config/common.js +0 -7
- package/dist/mint-config/hexadecimalPattern.d.ts +0 -1
- package/dist/mint-config/hexadecimalPattern.js +0 -1
- package/dist/mint-config/validateAnchorsWarnings.d.ts +0 -3
- package/dist/mint-config/validateAnchorsWarnings.js +0 -35
- package/dist/mint-config/validateVersionsInNavigation.d.ts +0 -4
- package/dist/mint-config/validateVersionsInNavigation.js +0 -52
- package/dist/sort.d.ts +0 -47
- package/dist/sort.js +0 -72
- package/dist/sortable/Sortable.d.ts +0 -28
- package/dist/sortable/Sortable.js +0 -117
- package/dist/sortable/isSortable.d.ts +0 -2
- package/dist/sortable/isSortable.js +0 -7
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { VersionType, NavigationEntry, NavigationGroup } from '@mintlify/models';
|
|
2
|
-
import { MintValidationResults } from './common.js';
|
|
3
|
-
export declare function flattenNavigationVersions(nav: NavigationEntry[], versions?: string[]): string[];
|
|
4
|
-
export declare function validateVersionsInNavigation(navigation: NavigationGroup[] | undefined, versions?: VersionType[] | undefined): MintValidationResults;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { MintValidationResults } from './common.js';
|
|
2
|
-
import { navigationSchema } from './schemas/navigation.js';
|
|
3
|
-
export function flattenNavigationVersions(nav, versions = []) {
|
|
4
|
-
nav.forEach((val) => {
|
|
5
|
-
if (val == null || typeof val === 'string') {
|
|
6
|
-
return versions;
|
|
7
|
-
}
|
|
8
|
-
if (val.version) {
|
|
9
|
-
versions.push(val.version);
|
|
10
|
-
}
|
|
11
|
-
if (!Array.isArray(val.pages)) {
|
|
12
|
-
return versions;
|
|
13
|
-
}
|
|
14
|
-
return flattenNavigationVersions(val.pages, versions);
|
|
15
|
-
});
|
|
16
|
-
return versions;
|
|
17
|
-
}
|
|
18
|
-
export function validateVersionsInNavigation(navigation, versions = []) {
|
|
19
|
-
const results = new MintValidationResults();
|
|
20
|
-
if (navigation == null || !navigationSchema.safeParse(navigation).success) {
|
|
21
|
-
return results;
|
|
22
|
-
}
|
|
23
|
-
const versionsFromNavigation = flattenNavigationVersions(navigation);
|
|
24
|
-
versionsFromNavigation.forEach((v) => {
|
|
25
|
-
if (versions && !versions.includes(v)) {
|
|
26
|
-
results.errors.push(`Version ${v} is not included in the versions array, but is used in the navigation. Please add ${v} to the versions array.`);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (versionsFromNavigation.length === 0 && versions.length > 0) {
|
|
30
|
-
results.warnings.push('You have versions defined in the config, but no versions are used in the navigation.');
|
|
31
|
-
}
|
|
32
|
-
navigation.forEach((nav) => {
|
|
33
|
-
results.warnings.push(...warnVersionNesting(nav, null));
|
|
34
|
-
});
|
|
35
|
-
return results;
|
|
36
|
-
}
|
|
37
|
-
function warnVersionNesting(navigation, currentVersion) {
|
|
38
|
-
if (typeof navigation === 'string') {
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
const warnings = [];
|
|
42
|
-
if (navigation.version && currentVersion != null && navigation.version !== currentVersion) {
|
|
43
|
-
warnings.push(`Please do not set versions on groups nested inside a group that already has a version. The group "${navigation.group}" has version "${navigation.version}" set and it is nested in a group that has the version "${currentVersion}" set.`);
|
|
44
|
-
}
|
|
45
|
-
if (navigation.pages) {
|
|
46
|
-
return warnings.concat(navigation.pages
|
|
47
|
-
.map((entry) => warnVersionNesting(entry, currentVersion || navigation.version))
|
|
48
|
-
.flat()
|
|
49
|
-
.filter(Boolean));
|
|
50
|
-
}
|
|
51
|
-
return [];
|
|
52
|
-
}
|
package/dist/sort.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { SORT_DIRECTION, SortOptions } from '@mintlify/models';
|
|
2
|
-
export declare function isArray(x: object): x is [];
|
|
3
|
-
/**
|
|
4
|
-
* Creates a comparison function for sorting purposes based on a given direction and an optional key.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of the elements.
|
|
7
|
-
*
|
|
8
|
-
* @param direction - Specifies the direction for sorting (either ASCENDING or DESCENDING).
|
|
9
|
-
* @param key - An optional key on which to base the sorting. If not provided, the object itself will be used.
|
|
10
|
-
*
|
|
11
|
-
* @returns A comparator function to be used with array's `sort` method.
|
|
12
|
-
*/
|
|
13
|
-
export declare function comparer<T>(direction: SORT_DIRECTION, key?: keyof T): (x: T, y: T) => 1 | -1;
|
|
14
|
-
/**
|
|
15
|
-
* Sets a value for a specific key in the ordered object or array. If the value is an object, sorts it before setting.
|
|
16
|
-
*
|
|
17
|
-
* @template T - The type of the main object.
|
|
18
|
-
* @template X - The type of the value to be set.
|
|
19
|
-
*
|
|
20
|
-
* @param key - The key or index where the value should be set.
|
|
21
|
-
* @param value - The value to be set.
|
|
22
|
-
* @param ordered - The target object or array where the value will be set.
|
|
23
|
-
* @param direction - Optional sorting direction for the value if it's an object.
|
|
24
|
-
*/
|
|
25
|
-
export declare function set<T, X>(key: keyof T | number, value: X, ordered: Partial<T> | [], direction?: SORT_DIRECTION): void;
|
|
26
|
-
/**
|
|
27
|
-
* Returns a setter function that can be used to set values in an ordered object based on keys and sorting options.
|
|
28
|
-
*
|
|
29
|
-
* @template T - The type of the main object.
|
|
30
|
-
*
|
|
31
|
-
* @param obj - The source object with values to be set.
|
|
32
|
-
* @param ordered - The target object where values will be set in an ordered manner.
|
|
33
|
-
*
|
|
34
|
-
* @returns A setter function for specific keys of the source object.
|
|
35
|
-
*/
|
|
36
|
-
export declare function getSetter<T>(obj: T & Partial<SortOptions<T>>, ordered: Partial<T>): (key: keyof T) => void;
|
|
37
|
-
/**
|
|
38
|
-
* Sorts an object based on the provided sorting options.
|
|
39
|
-
*
|
|
40
|
-
* @template T - The type of the object.
|
|
41
|
-
*
|
|
42
|
-
* @param obj - The object to be sorted.
|
|
43
|
-
* @param options - Sorting options including direction and other parameters.
|
|
44
|
-
*
|
|
45
|
-
* @returns A new object with sorted entries.
|
|
46
|
-
*/
|
|
47
|
-
export declare function sort<T extends object>(obj: T, options?: Readonly<SortOptions<T>>): T;
|
package/dist/sort.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { SORT_DIRECTION } from '@mintlify/models';
|
|
2
|
-
import { Sortable } from './sortable/Sortable.js';
|
|
3
|
-
export function isArray(x) {
|
|
4
|
-
return Array.isArray(x);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Creates a comparison function for sorting purposes based on a given direction and an optional key.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The type of the elements.
|
|
10
|
-
*
|
|
11
|
-
* @param direction - Specifies the direction for sorting (either ASCENDING or DESCENDING).
|
|
12
|
-
* @param key - An optional key on which to base the sorting. If not provided, the object itself will be used.
|
|
13
|
-
*
|
|
14
|
-
* @returns A comparator function to be used with array's `sort` method.
|
|
15
|
-
*/
|
|
16
|
-
export function comparer(direction, key) {
|
|
17
|
-
return (x, y) => {
|
|
18
|
-
const a = key ? x[key] : x;
|
|
19
|
-
const b = key ? y[key] : y;
|
|
20
|
-
return direction === SORT_DIRECTION.ASCENDING ? (a > b ? 1 : -1) : a > b ? -1 : 1;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Sets a value for a specific key in the ordered object or array. If the value is an object, sorts it before setting.
|
|
25
|
-
*
|
|
26
|
-
* @template T - The type of the main object.
|
|
27
|
-
* @template X - The type of the value to be set.
|
|
28
|
-
*
|
|
29
|
-
* @param key - The key or index where the value should be set.
|
|
30
|
-
* @param value - The value to be set.
|
|
31
|
-
* @param ordered - The target object or array where the value will be set.
|
|
32
|
-
* @param direction - Optional sorting direction for the value if it's an object.
|
|
33
|
-
*/
|
|
34
|
-
export function set(key, value, ordered, direction) {
|
|
35
|
-
if (value && typeof value === 'object') {
|
|
36
|
-
ordered[key] = sort(value, {
|
|
37
|
-
direction: direction !== null && direction !== void 0 ? direction : SORT_DIRECTION.ASCENDING,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
ordered[key] = value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns a setter function that can be used to set values in an ordered object based on keys and sorting options.
|
|
46
|
-
*
|
|
47
|
-
* @template T - The type of the main object.
|
|
48
|
-
*
|
|
49
|
-
* @param obj - The source object with values to be set.
|
|
50
|
-
* @param ordered - The target object where values will be set in an ordered manner.
|
|
51
|
-
*
|
|
52
|
-
* @returns A setter function for specific keys of the source object.
|
|
53
|
-
*/
|
|
54
|
-
export function getSetter(obj, ordered) {
|
|
55
|
-
return (key) => {
|
|
56
|
-
const value = obj[key];
|
|
57
|
-
set(key, value, ordered, obj.direction);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Sorts an object based on the provided sorting options.
|
|
62
|
-
*
|
|
63
|
-
* @template T - The type of the object.
|
|
64
|
-
*
|
|
65
|
-
* @param obj - The object to be sorted.
|
|
66
|
-
* @param options - Sorting options including direction and other parameters.
|
|
67
|
-
*
|
|
68
|
-
* @returns A new object with sorted entries.
|
|
69
|
-
*/
|
|
70
|
-
export function sort(obj, options = { direction: SORT_DIRECTION.ASCENDING }) {
|
|
71
|
-
return new Sortable(obj, options).sort();
|
|
72
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ISortable, SortOptions } from '@mintlify/models';
|
|
2
|
-
/**
|
|
3
|
-
* Provides functionality to sort a given object based on provided sort options.
|
|
4
|
-
*
|
|
5
|
-
* @template T - The type of the object to be sorted.
|
|
6
|
-
*/
|
|
7
|
-
export declare class Sortable<T> implements ISortable<T> {
|
|
8
|
-
readonly obj: Readonly<T>;
|
|
9
|
-
readonly options: Readonly<SortOptions<T>>;
|
|
10
|
-
constructor(obj: Readonly<T>, options?: Readonly<SortOptions<T>>);
|
|
11
|
-
sort(out?: Partial<T> | []): T;
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new sortable entity for a given object with optional sortable properties.
|
|
14
|
-
*
|
|
15
|
-
* @param obj - The object that is to be converted into a sortable.
|
|
16
|
-
*
|
|
17
|
-
* @returns A new sortable instance.
|
|
18
|
-
*/
|
|
19
|
-
static createSortable<T>(obj: T & Partial<ISortable<T>>): Sortable<T>;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a sortable entity from a given object and recursively does the same for its nested properties.
|
|
22
|
-
*
|
|
23
|
-
* @param obj - The root object to start from.
|
|
24
|
-
*
|
|
25
|
-
* @returns A new root sortable instance.
|
|
26
|
-
*/
|
|
27
|
-
static createSortableRecursive<T = never>(obj: T & Partial<ISortable<T>>): Sortable<T>;
|
|
28
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { SORT_DIRECTION } from '@mintlify/models';
|
|
13
|
-
import { any } from '../any.js';
|
|
14
|
-
import { comparer, getSetter, isArray, set } from '../sort.js';
|
|
15
|
-
import { isSortable } from './isSortable.js';
|
|
16
|
-
/**
|
|
17
|
-
* Provides functionality to sort a given object based on provided sort options.
|
|
18
|
-
*
|
|
19
|
-
* @template T - The type of the object to be sorted.
|
|
20
|
-
*/
|
|
21
|
-
export class Sortable {
|
|
22
|
-
constructor(obj, options = { direction: SORT_DIRECTION.ASCENDING }) {
|
|
23
|
-
this.obj = obj;
|
|
24
|
-
this.options = options;
|
|
25
|
-
if (typeof obj !== 'object' || !(obj instanceof Object))
|
|
26
|
-
return;
|
|
27
|
-
if (typeof obj === 'string' || obj instanceof String)
|
|
28
|
-
return;
|
|
29
|
-
this.obj = obj;
|
|
30
|
-
this.options = options;
|
|
31
|
-
if (obj instanceof Sortable) {
|
|
32
|
-
this.obj = obj.obj;
|
|
33
|
-
this.options = Object.assign(Object.assign({}, obj.options), options);
|
|
34
|
-
}
|
|
35
|
-
if (isSortable(this.obj)) {
|
|
36
|
-
const _a = this.obj, { options: opts } = _a, o = __rest(_a, ["options"]);
|
|
37
|
-
this.obj = o;
|
|
38
|
-
this.options = Object.assign(Object.assign({}, opts), this.options);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
sort(out) {
|
|
42
|
-
const { order, direction } = this.options;
|
|
43
|
-
out = out !== null && out !== void 0 ? out : this.obj;
|
|
44
|
-
if (isArray(this.obj)) {
|
|
45
|
-
const length = this.obj.length;
|
|
46
|
-
const values = [...this.obj];
|
|
47
|
-
this.obj.splice(0, this.obj.length);
|
|
48
|
-
for (let i = 0; i < length; i++) {
|
|
49
|
-
set(i, values[i], out, this.options.direction);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (any(order)) {
|
|
53
|
-
const entries = order.sort(comparer(direction, 'index'));
|
|
54
|
-
const keys = entries.map((x) => x.key);
|
|
55
|
-
const values = Object.fromEntries(new Map(keys.map((x) => [x, this.obj[x]])));
|
|
56
|
-
entries.forEach((x) => out === null || out === void 0 ? true : delete out[x.key]);
|
|
57
|
-
for (const entry of entries) {
|
|
58
|
-
const set = getSetter(values, out);
|
|
59
|
-
set(entry.key);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const keys = Object.keys(this.obj).sort(comparer(direction));
|
|
64
|
-
const values = Object.fromEntries(new Map(keys.map((x) => [x, this.obj[x]])));
|
|
65
|
-
keys.forEach((x) => out === null || out === void 0 ? true : delete out[x]);
|
|
66
|
-
for (const key of keys) {
|
|
67
|
-
const set = getSetter(values, out);
|
|
68
|
-
set(key);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return out;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Creates a new sortable entity for a given object with optional sortable properties.
|
|
75
|
-
*
|
|
76
|
-
* @param obj - The object that is to be converted into a sortable.
|
|
77
|
-
*
|
|
78
|
-
* @returns A new sortable instance.
|
|
79
|
-
*/
|
|
80
|
-
static createSortable(obj) {
|
|
81
|
-
var _a, _b, _c;
|
|
82
|
-
const direction = (_b = (_a = obj.options) === null || _a === void 0 ? void 0 : _a.direction) !== null && _b !== void 0 ? _b : SORT_DIRECTION.ASCENDING;
|
|
83
|
-
let order = (_c = obj.options) === null || _c === void 0 ? void 0 : _c.order;
|
|
84
|
-
order = order !== null && order !== void 0 ? order : Object.keys(obj).map((key, index) => ({ key: key, index }));
|
|
85
|
-
const options = {
|
|
86
|
-
direction,
|
|
87
|
-
order,
|
|
88
|
-
};
|
|
89
|
-
if (typeof obj !== 'string') {
|
|
90
|
-
obj.options = options;
|
|
91
|
-
}
|
|
92
|
-
return new Sortable(obj, options);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Creates a sortable entity from a given object and recursively does the same for its nested properties.
|
|
96
|
-
*
|
|
97
|
-
* @param obj - The root object to start from.
|
|
98
|
-
*
|
|
99
|
-
* @returns A new root sortable instance.
|
|
100
|
-
*/
|
|
101
|
-
static createSortableRecursive(obj) {
|
|
102
|
-
const isObject = typeof obj === 'object';
|
|
103
|
-
if (isArray(obj)) {
|
|
104
|
-
for (let i = 0; i < obj.length; i++) {
|
|
105
|
-
this.createSortableRecursive(obj[i]);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else if (isObject) {
|
|
109
|
-
const keys = Object.keys(obj);
|
|
110
|
-
for (const key of keys) {
|
|
111
|
-
const value = obj[key];
|
|
112
|
-
this.createSortableRecursive(value);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return this.createSortable(obj);
|
|
116
|
-
}
|
|
117
|
-
}
|