@mintlify/common 1.0.1167 → 1.0.1168
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.
|
@@ -7,3 +7,4 @@ export type NormalizedGroups = {
|
|
|
7
7
|
export declare const isPageGroups: (value: unknown) => value is PageGroups;
|
|
8
8
|
export declare function normalizeGroups(groups: PageGroups | undefined): NormalizedGroups | undefined;
|
|
9
9
|
export declare function checkGroupAccess(groups: PageGroups | undefined, readerGroups: ReadonlySet<string>): boolean;
|
|
10
|
+
export declare function mergePageGroups(existing: PageGroups | undefined, added: string[]): PageGroups;
|
|
@@ -44,3 +44,18 @@ export function checkGroupAccess(groups, readerGroups) {
|
|
|
44
44
|
return true;
|
|
45
45
|
return normalized.includes.some((group) => readerGroups.has(group));
|
|
46
46
|
}
|
|
47
|
+
export function mergePageGroups(existing, added) {
|
|
48
|
+
if (!Array.isArray(existing))
|
|
49
|
+
return added;
|
|
50
|
+
const names = [];
|
|
51
|
+
const rules = [];
|
|
52
|
+
for (const entry of existing) {
|
|
53
|
+
if (typeof entry === 'string')
|
|
54
|
+
names.push(entry);
|
|
55
|
+
else
|
|
56
|
+
rules.push(entry);
|
|
57
|
+
}
|
|
58
|
+
if (rules.length === 0)
|
|
59
|
+
return [...names, ...added];
|
|
60
|
+
return [...rules, { includes: [...names, ...added] }];
|
|
61
|
+
}
|
|
@@ -5,6 +5,7 @@ import { isEqualIgnoringLeadingSlash } from '../paths/isEqualIgnoringLeadingSlas
|
|
|
5
5
|
import { filterDivisions } from './filterDivisions.js';
|
|
6
6
|
import { getFirstPageFromNavigation } from './getFirstPageFromNavigation.js';
|
|
7
7
|
import { getVersionOrLanguageFromPath } from './getVersionOrLanguageFromPath.js';
|
|
8
|
+
import { isPageGroups } from './groupAccess.js';
|
|
8
9
|
import { pathsDifferByOneSegment } from './updateFirstHrefInDivision.js';
|
|
9
10
|
const SCOPED_DIVISION_KEYS = ['versions', 'languages'];
|
|
10
11
|
const DIVISION_TYPE_BY_KEY = {
|
|
@@ -44,10 +45,9 @@ function isDecoratedPageNode(node) {
|
|
|
44
45
|
return typeof node.href === 'string' && typeof node.title === 'string';
|
|
45
46
|
}
|
|
46
47
|
function pageAccessGroups(node) {
|
|
47
|
-
if (
|
|
48
|
+
if (node.groups == null)
|
|
48
49
|
return undefined;
|
|
49
|
-
|
|
50
|
-
return groups.length === node.groups.length ? groups : undefined;
|
|
50
|
+
return isPageGroups(node.groups) ? node.groups : [];
|
|
51
51
|
}
|
|
52
52
|
// inHiddenSubtree propagates hidden from ancestor groups/divisions: a visible
|
|
53
53
|
// page under a hidden group is unreachable in getFirstPageFromNavigation
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import jsYaml from 'js-yaml';
|
|
2
2
|
import { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import { optionallyAddLeadingSlash } from '../fs/optionallySlash.js';
|
|
4
|
+
import { mergePageGroups } from '../navigation/groupAccess.js';
|
|
4
5
|
import { slugToTitle } from '../slug/slugToTitle.js';
|
|
5
6
|
import { buildOpenApiMetaTag } from './buildOpenApiMetaTag.js';
|
|
6
7
|
import { prepareStringToBeValidFilename, generateUniqueFilenameWithoutExtension, } from './filenameUtils.js';
|
|
@@ -126,10 +127,7 @@ export function generateOpenApiPages(opts) {
|
|
|
126
127
|
const { title: titleTag, description } = getOpenApiTitleAndDescription(openApiFiles, openapiMetaTag);
|
|
127
128
|
let xMintMetadata = xMint === null || xMint === void 0 ? void 0 : xMint.metadata;
|
|
128
129
|
if (xMintGroups.length > 0) {
|
|
129
|
-
xMintMetadata = Object.assign(Object.assign({}, xMintMetadata), { groups:
|
|
130
|
-
...(Array.isArray(xMintMetadata === null || xMintMetadata === void 0 ? void 0 : xMintMetadata.groups) ? xMintMetadata.groups : []),
|
|
131
|
-
...xMintGroups,
|
|
132
|
-
] });
|
|
130
|
+
xMintMetadata = Object.assign(Object.assign({}, xMintMetadata), { groups: mergePageGroups(xMintMetadata === null || xMintMetadata === void 0 ? void 0 : xMintMetadata.groups, xMintGroups) });
|
|
133
131
|
}
|
|
134
132
|
const page = {
|
|
135
133
|
title: (_f = (_e = xMintMetadata === null || xMintMetadata === void 0 ? void 0 : xMintMetadata.title) !== null && _e !== void 0 ? _e : titleTag) !== null && _f !== void 0 ? _f : slugToTitle(filenameWithoutExtension),
|