@mintlify/common 1.0.1178 → 1.0.1179

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.
@@ -1,7 +1,7 @@
1
1
  import { LocaleType } from '@mintlify/models';
2
2
  import type { DecoratedNavigationConfig, DocsConfig } from '@mintlify/validation';
3
3
  import { DivisionMatch } from './updateFirstHrefInDivision.js';
4
- export declare function scopeDecoratedNavToPath(nav: DecoratedNavigationConfig, currentPath: string): DecoratedNavigationConfig;
4
+ export declare function scopeDecoratedNavToPath(nav: DecoratedNavigationConfig, currentPath: string, userGroups?: Set<string>): DecoratedNavigationConfig;
5
5
  export declare function scopeDocsConfigNavToPath(docsConfig: DocsConfig, currentPath: string): DocsConfig;
6
6
  export type ScopedNavForPath = {
7
7
  scopedNav: DecoratedNavigationConfig;
@@ -516,9 +516,9 @@ function scopeNode(node, ctx) {
516
516
  }
517
517
  return scoped;
518
518
  }
519
- export function scopeDecoratedNavToPath(nav, currentPath) {
519
+ export function scopeDecoratedNavToPath(nav, currentPath, userGroups) {
520
520
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- structural nav traversal over the zod union types
521
- return scopeNode(nav, { currentPath });
521
+ return scopeNode(nav, { currentPath, userGroups });
522
522
  }
523
523
  export function scopeDocsConfigNavToPath(docsConfig, currentPath) {
524
524
  return Object.assign(Object.assign({}, docsConfig), {
@@ -88,6 +88,23 @@ describe('scopeDecoratedNavToPath', () => {
88
88
  const [, v2] = loose(scoped).versions;
89
89
  expect(v2).toEqual({ version: 'v2', href: 'https://v2.example.com' });
90
90
  });
91
+ it('stubs off-path tabs with the first page visible to the given groups', () => {
92
+ const nav = {
93
+ tabs: [
94
+ { tab: 'Help', pages: [page('/help')] },
95
+ {
96
+ tab: 'AIP',
97
+ pages: [
98
+ Object.assign(Object.assign({}, page('/aip/index')), { groups: ['aip'] }),
99
+ Object.assign(Object.assign({}, page('/aip/eqr')), { groups: ['aip', 'eqr'] }),
100
+ ],
101
+ },
102
+ ],
103
+ };
104
+ const scoped = scopeDecoratedNavToPath(nav, '/help', new Set(['eqr']));
105
+ const [, aip] = scoped.tabs;
106
+ expect(aip === null || aip === void 0 ? void 0 : aip.pages).toEqual([{ title: 'AIP', href: '/aip/eqr', groups: ['aip', 'eqr'] }]);
107
+ });
91
108
  });
92
109
  describe('scopeDocsConfigNavToPath', () => {
93
110
  it('stubs sibling raw-language trees with a single page path while keeping metadata', () => {