@mintlify/common 1.0.1177 → 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.
@@ -5,5 +5,6 @@ export declare const coreRemarkMdxPlugins: PluggableList;
5
5
  export declare const coreRemark: import("unified").Processor<Root, undefined, undefined, Root, string>;
6
6
  export declare const getAST: (str: string, filePath?: string) => Root;
7
7
  export declare const stringifyTree: (tree: Root) => string;
8
+ export declare const stringifyTreeForAgents: (tree: Root) => string;
8
9
  export declare function stripVisibilityForMarkdown(mdx: string): string;
9
10
  export declare function transformContentForMarkdown(mdx: string, mentionOptions?: RemarkUserMentionsOptions): string;
@@ -17,6 +17,13 @@ export const coreRemarkMdxPlugins = [
17
17
  remarkMath,
18
18
  ];
19
19
  export const coreRemark = remark().use(coreRemarkMdxPlugins).freeze();
20
+ const agentRemarkMdxPlugins = [
21
+ remarkMdx,
22
+ [remarkGfm, { tablePipeAlign: false }],
23
+ [remarkFrontmatter, ['yaml', 'toml']],
24
+ remarkMath,
25
+ ];
26
+ const agentRemark = remark().use(agentRemarkMdxPlugins).freeze();
20
27
  export const getAST = (str, filePath) => {
21
28
  if (isJsxOrTsx(filePath)) {
22
29
  return getJsxEsmTree(str, filePath);
@@ -24,14 +31,15 @@ export const getAST = (str, filePath) => {
24
31
  return coreRemark().parse(preprocessCustomHeadingIds(preprocessMdxFragmentCode(str)));
25
32
  };
26
33
  export const stringifyTree = (tree) => coreRemark().use(remarkStringify).stringify(tree);
34
+ export const stringifyTreeForAgents = (tree) => agentRemark().use(remarkStringify).stringify(tree);
27
35
  export function stripVisibilityForMarkdown(mdx) {
28
36
  const tree = getAST(mdx);
29
37
  remarkVisibilityForMarkdown()(tree);
30
- return stringifyTree(tree);
38
+ return stringifyTreeForAgents(tree);
31
39
  }
32
40
  export function transformContentForMarkdown(mdx, mentionOptions = {}) {
33
41
  const tree = getAST(mdx);
34
42
  remarkVisibilityForMarkdown()(tree);
35
43
  remarkUserMentions(mentionOptions)(tree);
36
- return stringifyTree(tree);
44
+ return stringifyTreeForAgents(tree);
37
45
  }
@@ -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', () => {