@carlonicora/nextjs-jsonapi 1.109.0 → 1.110.0

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.
Files changed (146) hide show
  1. package/dist/{AssistantMessageInterface-Cs1yb-gF.d.ts → AssistantMessageInterface-BNzf1etU.d.ts} +14 -1
  2. package/dist/{AssistantMessageInterface-DQ3mH5L8.d.mts → AssistantMessageInterface-DrgHDjZ5.d.mts} +14 -1
  3. package/dist/{BlockNoteEditor-3XYBZLWO.js → BlockNoteEditor-7OKW6HHN.js} +19 -20
  4. package/dist/BlockNoteEditor-7OKW6HHN.js.map +1 -0
  5. package/dist/{BlockNoteEditor-EBFZG7AL.mjs → BlockNoteEditor-K7IIWM3S.mjs} +4 -5
  6. package/dist/{BlockNoteEditor-EBFZG7AL.mjs.map → BlockNoteEditor-K7IIWM3S.mjs.map} +1 -1
  7. package/dist/BlockNoteViewer-OPSCTHKJ.mjs +31 -0
  8. package/dist/BlockNoteViewer-OPSCTHKJ.mjs.map +1 -0
  9. package/dist/BlockNoteViewer-UW5VZ5UF.js +31 -0
  10. package/dist/BlockNoteViewer-UW5VZ5UF.js.map +1 -0
  11. package/dist/billing/index.d.mts +41 -41
  12. package/dist/billing/index.d.ts +41 -41
  13. package/dist/billing/index.js +346 -347
  14. package/dist/billing/index.js.map +1 -1
  15. package/dist/billing/index.mjs +3 -4
  16. package/dist/billing/index.mjs.map +1 -1
  17. package/dist/{chunk-7E3O52U5.js → chunk-6XWW67F2.js} +25 -12
  18. package/dist/chunk-6XWW67F2.js.map +1 -0
  19. package/dist/{chunk-UHO3KUUH.js → chunk-AKXUNE3A.js} +977 -850
  20. package/dist/chunk-AKXUNE3A.js.map +1 -0
  21. package/dist/{chunk-UOYIWJEJ.mjs → chunk-CWVYU4YZ.mjs} +18 -5
  22. package/dist/{chunk-UOYIWJEJ.mjs.map → chunk-CWVYU4YZ.mjs.map} +1 -1
  23. package/dist/{chunk-CRTVAQEK.mjs → chunk-TXVVZLUQ.mjs} +1388 -1261
  24. package/dist/chunk-TXVVZLUQ.mjs.map +1 -0
  25. package/dist/{chunk-CFI4WZ5R.js → chunk-U2HR57MY.js} +111 -5
  26. package/dist/chunk-U2HR57MY.js.map +1 -0
  27. package/dist/chunk-WPAQRB5Q.mjs +7 -0
  28. package/dist/chunk-WPAQRB5Q.mjs.map +1 -0
  29. package/dist/chunk-YBZVWLPH.js +7 -0
  30. package/dist/chunk-YBZVWLPH.js.map +1 -0
  31. package/dist/{chunk-MSNNAHDB.mjs → chunk-ZYPNVEHB.mjs} +112 -6
  32. package/dist/{chunk-MSNNAHDB.mjs.map → chunk-ZYPNVEHB.mjs.map} +1 -1
  33. package/dist/client/index.d.mts +3 -4
  34. package/dist/client/index.d.ts +3 -4
  35. package/dist/client/index.js +4 -5
  36. package/dist/client/index.js.map +1 -1
  37. package/dist/client/index.mjs +3 -4
  38. package/dist/components/index.d.mts +418 -415
  39. package/dist/components/index.d.ts +418 -415
  40. package/dist/components/index.js +6 -5
  41. package/dist/components/index.js.map +1 -1
  42. package/dist/components/index.mjs +5 -4
  43. package/dist/{config-CN23v3eJ.d.ts → config-BrkU_Ynz.d.ts} +2 -2
  44. package/dist/{config-gh88Qn4h.d.mts → config-snd2ToEB.d.mts} +2 -2
  45. package/dist/contexts/index.d.mts +15 -15
  46. package/dist/contexts/index.d.ts +15 -15
  47. package/dist/contexts/index.js +4 -5
  48. package/dist/contexts/index.js.map +1 -1
  49. package/dist/contexts/index.mjs +3 -4
  50. package/dist/core/index.d.mts +35 -4
  51. package/dist/core/index.d.ts +35 -4
  52. package/dist/core/index.js +2 -2
  53. package/dist/core/index.mjs +1 -1
  54. package/dist/features/help/index.d.mts +25 -66
  55. package/dist/features/help/index.d.ts +25 -66
  56. package/dist/features/help/index.js +114 -124
  57. package/dist/features/help/index.js.map +1 -1
  58. package/dist/features/help/index.mjs +95 -105
  59. package/dist/features/help/index.mjs.map +1 -1
  60. package/dist/features/help/server.d.mts +27 -65
  61. package/dist/features/help/server.d.ts +27 -65
  62. package/dist/features/help/server.js +4 -119
  63. package/dist/features/help/server.js.map +1 -1
  64. package/dist/features/help/server.mjs +4 -119
  65. package/dist/features/help/server.mjs.map +1 -1
  66. package/dist/help-content-config.interface-C5ESIod9.d.mts +13 -0
  67. package/dist/help-content-config.interface-C5ESIod9.d.ts +13 -0
  68. package/dist/index.d.mts +3 -3
  69. package/dist/index.d.ts +3 -3
  70. package/dist/index.js +3 -4
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +2 -3
  73. package/dist/server/index.js +3 -3
  74. package/dist/server/index.mjs +1 -1
  75. package/dist/testing/index.d.mts +1 -2
  76. package/dist/testing/index.d.ts +1 -2
  77. package/package.json +1 -6
  78. package/src/client/config.ts +1 -1
  79. package/src/components/index.ts +1 -0
  80. package/src/components/viewers/BlockNoteViewer.tsx +27 -0
  81. package/src/components/viewers/BlockNoteViewerContainer.tsx +10 -0
  82. package/src/core/registry/helpStore.ts +2 -19
  83. package/src/features/assistant-message/components/parts/MessageSourcesContainer.tsx +4 -0
  84. package/src/features/assistant-message/components/parts/tabs/ContentsTab.tsx +5 -5
  85. package/src/features/assistant-message/components/parts/tabs/ReferencesTab.tsx +3 -2
  86. package/src/features/help/components/HelpArticleBody.tsx +27 -19
  87. package/src/features/help/components/HelpHint.tsx +20 -11
  88. package/src/features/help/components/HelpSearchResultRow.tsx +16 -6
  89. package/src/features/help/components/HelpSideNav.tsx +54 -19
  90. package/src/features/help/components/__tests__/HelpAskAi.spec.tsx +1 -1
  91. package/src/features/help/components/__tests__/HelpHint.spec.tsx +17 -17
  92. package/src/features/help/components/__tests__/HelpSearchResultRow.spec.tsx +18 -19
  93. package/src/features/help/components/__tests__/HelpSideNav.spec.tsx +20 -22
  94. package/src/features/help/contexts/HelpContext.spec.tsx +1 -3
  95. package/src/features/help/index.ts +3 -6
  96. package/src/features/help/interfaces/help-content-config.interface.ts +0 -5
  97. package/src/features/help/server-entry.ts +6 -15
  98. package/src/features/help/types/help-article.types.ts +2 -4
  99. package/src/features/how-to/HowToModule.ts +14 -1
  100. package/src/features/how-to/components/forms/HowToEditor.tsx +108 -4
  101. package/src/features/how-to/data/HowTo.spec.ts +43 -0
  102. package/src/features/how-to/data/HowTo.ts +47 -4
  103. package/src/features/how-to/data/HowToInterface.ts +14 -1
  104. package/src/features/how-to/data/HowToService.ts +61 -0
  105. package/dist/BlockNoteEditor-3XYBZLWO.js.map +0 -1
  106. package/dist/chunk-3J7RQBF3.js +0 -123
  107. package/dist/chunk-3J7RQBF3.js.map +0 -1
  108. package/dist/chunk-7E3O52U5.js.map +0 -1
  109. package/dist/chunk-CFI4WZ5R.js.map +0 -1
  110. package/dist/chunk-CQID6RCF.mjs +0 -38
  111. package/dist/chunk-CQID6RCF.mjs.map +0 -1
  112. package/dist/chunk-CRTVAQEK.mjs.map +0 -1
  113. package/dist/chunk-MZTKPPET.mjs +0 -123
  114. package/dist/chunk-MZTKPPET.mjs.map +0 -1
  115. package/dist/chunk-UHO3KUUH.js.map +0 -1
  116. package/dist/chunk-YQQHAFBS.js +0 -38
  117. package/dist/chunk-YQQHAFBS.js.map +0 -1
  118. package/dist/features/help/server/createHelpAssetRouteHandler.d.mts +0 -11
  119. package/dist/features/help/server/createHelpAssetRouteHandler.d.ts +0 -11
  120. package/dist/features/help/server/createHelpAssetRouteHandler.js +0 -43
  121. package/dist/features/help/server/createHelpAssetRouteHandler.js.map +0 -1
  122. package/dist/features/help/server/createHelpAssetRouteHandler.mjs +0 -43
  123. package/dist/features/help/server/createHelpAssetRouteHandler.mjs.map +0 -1
  124. package/dist/help-content-config.interface-B9L02u9i.d.mts +0 -50
  125. package/dist/help-content-config.interface-B9L02u9i.d.ts +0 -50
  126. package/src/features/help/components/mdx/Callout.tsx +0 -21
  127. package/src/features/help/components/mdx/EntityRef.tsx +0 -18
  128. package/src/features/help/components/mdx/KeyBinding.tsx +0 -6
  129. package/src/features/help/components/mdx/Related.tsx +0 -33
  130. package/src/features/help/components/mdx/Screenshot.tsx +0 -9
  131. package/src/features/help/components/mdx/Steps.tsx +0 -21
  132. package/src/features/help/components/mdx/Video.tsx +0 -8
  133. package/src/features/help/components/mdx/mdx-server-components.ts +0 -23
  134. package/src/features/help/components/mdx/mdxComponents.ts +0 -9
  135. package/src/features/help/hooks/useHelpArticle.ts +0 -7
  136. package/src/features/help/hooks/useHelpManifest.ts +0 -5
  137. package/src/features/help/server/__tests__/createHelpAssetRouteHandler.spec.ts +0 -43
  138. package/src/features/help/server/createHelpAssetRouteHandler.ts +0 -35
  139. package/src/features/help/server/generateHelpArticleMetadata.ts +0 -18
  140. package/src/features/help/server/generateHelpArticleStaticParams.ts +0 -7
  141. package/src/features/help/server/generateHelpModeStaticParams.ts +0 -5
  142. package/src/features/help/server/getHelpContent.ts +0 -17
  143. package/src/features/help/server/index.ts +0 -8
  144. package/src/features/help/server/serializeHelpArticle.tsx +0 -46
  145. package/src/features/help/utils/__tests__/helpNavigation.spec.ts +0 -70
  146. package/src/features/help/utils/helpNavigation.ts +0 -29
@@ -1,38 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
4
-
5
- // src/core/registry/helpStore.ts
6
- var HELP_CONTENT_KEY = /* @__PURE__ */ Symbol.for("nextjs-jsonapi:helpContent");
7
- var HELP_READER_KEY = /* @__PURE__ */ Symbol.for("nextjs-jsonapi:helpReader");
8
- var globalStore = globalThis;
9
- if (globalStore[HELP_CONTENT_KEY] === void 0) {
10
- globalStore[HELP_CONTENT_KEY] = null;
11
- }
12
- if (globalStore[HELP_READER_KEY] === void 0) {
13
- globalStore[HELP_READER_KEY] = null;
14
- }
15
- function _setStaticHelpContent(cfg) {
16
- globalStore[HELP_CONTENT_KEY] = cfg;
17
- }
18
- _chunk7QVYU63Ejs.__name.call(void 0, _setStaticHelpContent, "_setStaticHelpContent");
19
- function _getStaticHelpContent() {
20
- return _nullishCoalesce(globalStore[HELP_CONTENT_KEY], () => ( null));
21
- }
22
- _chunk7QVYU63Ejs.__name.call(void 0, _getStaticHelpContent, "_getStaticHelpContent");
23
- function setHelpReader(reader) {
24
- globalStore[HELP_READER_KEY] = reader;
25
- }
26
- _chunk7QVYU63Ejs.__name.call(void 0, setHelpReader, "setHelpReader");
27
- function _getStaticHelpReader() {
28
- return _nullishCoalesce(globalStore[HELP_READER_KEY], () => ( null));
29
- }
30
- _chunk7QVYU63Ejs.__name.call(void 0, _getStaticHelpReader, "_getStaticHelpReader");
31
-
32
-
33
-
34
-
35
-
36
-
37
- exports._setStaticHelpContent = _setStaticHelpContent; exports._getStaticHelpContent = _getStaticHelpContent; exports.setHelpReader = setHelpReader; exports._getStaticHelpReader = _getStaticHelpReader;
38
- //# sourceMappingURL=chunk-YQQHAFBS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-YQQHAFBS.js","../src/core/registry/helpStore.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACWA,IAAM,iBAAA,kBAAmB,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAChE,IAAM,gBAAA,kBAAkB,MAAA,CAAO,GAAA,CAAI,2BAA2B,CAAA;AAE9D,IAAM,YAAA,EAAc,UAAA;AAKpB,GAAA,CAAI,WAAA,CAAY,gBAAgB,EAAA,IAAM,KAAA,CAAA,EAAW;AAC/C,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,IAAA;AAClC;AACA,GAAA,CAAI,WAAA,CAAY,eAAe,EAAA,IAAM,KAAA,CAAA,EAAW;AAC9C,EAAA,WAAA,CAAY,eAAe,EAAA,EAAI,IAAA;AACjC;AAEO,SAAS,qBAAA,CAAsB,GAAA,EAA2B;AAC/D,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,GAAA;AAClC;AAFgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;AAIT,SAAS,qBAAA,CAAA,EAA+C;AAC7D,EAAA,wBAAQ,WAAA,CAAY,gBAAgB,CAAA,UAAkB,MAAA;AACxD;AAFgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;AAIT,SAAS,aAAA,CAAc,MAAA,EAA0B;AACtD,EAAA,WAAA,CAAY,eAAe,EAAA,EAAI,MAAA;AACjC;AAFgB,qCAAA,aAAA,EAAA,eAAA,CAAA;AAIT,SAAS,oBAAA,CAAA,EAA0C;AACxD,EAAA,wBAAO,WAAA,CAAY,eAAe,CAAA,UAAK,MAAA;AACzC;AAFgB,qCAAA,oBAAA,EAAA,sBAAA,CAAA;ADZhB;AACA;AACE;AACA;AACA;AACA;AACF,yMAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-YQQHAFBS.js","sourcesContent":[null,"/**\n * Centralized help-content store accessible from client and server contexts.\n * Uses globalThis Symbol keys to persist across HMR/Turbopack reloads and to\n * bridge between the client-side `configureJsonApi` (in `client/config.ts`)\n * and server-side consumers (HelpProvider, getHelpContent, serializeHelpArticle).\n *\n * NO external dependencies to avoid circular imports.\n *\n * Pattern mirrors `bootstrapStore.ts`.\n */\n\n// Help content config shape is duplicated here as `unknown` to avoid pulling\n// the help feature into this core file. Callers cast on read.\ntype HelpReader = (article: { path: string }) => Promise<string>;\n\nconst HELP_CONTENT_KEY = Symbol.for(\"nextjs-jsonapi:helpContent\");\nconst HELP_READER_KEY = Symbol.for(\"nextjs-jsonapi:helpReader\");\n\nconst globalStore = globalThis as unknown as {\n [HELP_CONTENT_KEY]?: unknown | null;\n [HELP_READER_KEY]?: HelpReader | null;\n};\n\nif (globalStore[HELP_CONTENT_KEY] === undefined) {\n globalStore[HELP_CONTENT_KEY] = null;\n}\nif (globalStore[HELP_READER_KEY] === undefined) {\n globalStore[HELP_READER_KEY] = null;\n}\n\nexport function _setStaticHelpContent(cfg: unknown | null): void {\n globalStore[HELP_CONTENT_KEY] = cfg;\n}\n\nexport function _getStaticHelpContent<T = unknown>(): T | null {\n return (globalStore[HELP_CONTENT_KEY] as T | null) ?? null;\n}\n\nexport function setHelpReader(reader: HelpReader): void {\n globalStore[HELP_READER_KEY] = reader;\n}\n\nexport function _getStaticHelpReader(): HelpReader | null {\n return globalStore[HELP_READER_KEY] ?? null;\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { NextResponse } from 'next/server';
2
-
3
- declare function createHelpAssetRouteHandler({ srcRoot }: {
4
- srcRoot: string;
5
- }): (_req: Request, { params }: {
6
- params: Promise<{
7
- path: string[];
8
- }>;
9
- }) => Promise<NextResponse<unknown>>;
10
-
11
- export { createHelpAssetRouteHandler };
@@ -1,11 +0,0 @@
1
- import { NextResponse } from 'next/server';
2
-
3
- declare function createHelpAssetRouteHandler({ srcRoot }: {
4
- srcRoot: string;
5
- }): (_req: Request, { params }: {
6
- params: Promise<{
7
- path: string[];
8
- }>;
9
- }) => Promise<NextResponse<unknown>>;
10
-
11
- export { createHelpAssetRouteHandler };
@@ -1,43 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _chunk7QVYU63Ejs = require('../../../chunk-7QVYU63E.js');
4
-
5
- // src/features/help/server/createHelpAssetRouteHandler.ts
6
- var _server = require('next/server');
7
- var _promises = require('fs/promises');
8
- var _path = require('path');
9
- var MIME = {
10
- ".png": "image/png",
11
- ".jpg": "image/jpeg",
12
- ".jpeg": "image/jpeg",
13
- ".webp": "image/webp",
14
- ".gif": "image/gif",
15
- ".svg": "image/svg+xml",
16
- ".mp4": "video/mp4",
17
- ".webm": "video/webm"
18
- };
19
- function createHelpAssetRouteHandler({ srcRoot }) {
20
- return /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, async function GET(_req, { params }) {
21
- const { path } = await params;
22
- const safe = path.filter((p) => p !== ".." && !p.includes("/")).join("/");
23
- const filePath = _path.join.call(void 0, srcRoot, safe);
24
- try {
25
- const s = await _promises.stat.call(void 0, filePath);
26
- if (!s.isFile()) return new (0, _server.NextResponse)("Not found", { status: 404 });
27
- const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
28
- const mime = _nullishCoalesce(MIME[ext], () => ( "application/octet-stream"));
29
- const data = await _promises.readFile.call(void 0, filePath);
30
- return new (0, _server.NextResponse)(data, {
31
- status: 200,
32
- headers: { "Content-Type": mime, "Cache-Control": "public, max-age=3600" }
33
- });
34
- } catch (e) {
35
- return new (0, _server.NextResponse)("Not found", { status: 404 });
36
- }
37
- }, "GET");
38
- }
39
- _chunk7QVYU63Ejs.__name.call(void 0, createHelpAssetRouteHandler, "createHelpAssetRouteHandler");
40
-
41
-
42
- exports.createHelpAssetRouteHandler = createHelpAssetRouteHandler;
43
- //# sourceMappingURL=createHelpAssetRouteHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/features/help/server/createHelpAssetRouteHandler.js","../../../../src/features/help/server/createHelpAssetRouteHandler.ts"],"names":[],"mappings":"AAAA;AACE;AACF,6DAAmC;AACnC;AACA;ACJA,qCAA6B;AAC7B,uCAA+B;AAC/B,4BAAqB;AAErB,IAAM,KAAA,EAA+B;AAAA,EACnC,MAAA,EAAQ,WAAA;AAAA,EACR,MAAA,EAAQ,YAAA;AAAA,EACR,OAAA,EAAS,YAAA;AAAA,EACT,OAAA,EAAS,YAAA;AAAA,EACT,MAAA,EAAQ,WAAA;AAAA,EACR,MAAA,EAAQ,eAAA;AAAA,EACR,MAAA,EAAQ,WAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAA;AAEO,SAAS,2BAAA,CAA4B,EAAE,QAAQ,CAAA,EAAwB;AAC5E,EAAA,uBAAO,qCAAA,MAAA,SAAe,GAAA,CAAI,IAAA,EAAe,EAAE,OAAO,CAAA,EAA4C;AAC5F,IAAA,MAAM,EAAE,KAAK,EAAA,EAAI,MAAM,MAAA;AACvB,IAAA,MAAM,KAAA,EAAO,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA,EAAA,GAAM,EAAA,IAAM,KAAA,GAAQ,CAAC,CAAA,CAAE,QAAA,CAAS,GAAG,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACxE,IAAA,MAAM,SAAA,EAAW,wBAAA,OAAK,EAAS,IAAI,CAAA;AACnC,IAAA,IAAI;AACF,MAAA,MAAM,EAAA,EAAI,MAAM,4BAAA,QAAa,CAAA;AAC7B,MAAA,GAAA,CAAI,CAAC,CAAA,CAAE,MAAA,CAAO,CAAA,EAAG,OAAO,IAAI,yBAAA,CAAa,WAAA,EAAa,EAAE,MAAA,EAAQ,IAAI,CAAC,CAAA;AACrE,MAAA,MAAM,IAAA,EAAM,QAAA,CAAS,WAAA,CAAY,CAAA,CAAE,KAAA,CAAM,QAAA,CAAS,WAAA,CAAY,GAAG,CAAC,CAAA;AAClE,MAAA,MAAM,KAAA,mBAAO,IAAA,CAAK,GAAG,CAAA,UAAK,4BAAA;AAC1B,MAAA,MAAM,KAAA,EAAO,MAAM,gCAAA,QAAiB,CAAA;AACpC,MAAA,OAAO,IAAI,yBAAA,CAAa,IAAA,EAAM;AAAA,QAC5B,MAAA,EAAQ,GAAA;AAAA,QACR,OAAA,EAAS,EAAE,cAAA,EAAgB,IAAA,EAAM,eAAA,EAAiB,uBAAuB;AAAA,MAC3E,CAAC,CAAA;AAAA,IACH,EAAA,UAAQ;AACN,MAAA,OAAO,IAAI,yBAAA,CAAa,WAAA,EAAa,EAAE,MAAA,EAAQ,IAAI,CAAC,CAAA;AAAA,IACtD;AAAA,EACF,CAAA,EAjBO,KAAA,CAAA;AAkBT;AAnBgB,qCAAA,2BAAA,EAAA,6BAAA,CAAA;ADwBhB;AACE;AACF,kEAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/features/help/server/createHelpAssetRouteHandler.js","sourcesContent":[null,"import { NextResponse } from \"next/server\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nconst MIME: Record<string, string> = {\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n \".svg\": \"image/svg+xml\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n};\n\nexport function createHelpAssetRouteHandler({ srcRoot }: { srcRoot: string }) {\n return async function GET(_req: Request, { params }: { params: Promise<{ path: string[] }> }) {\n const { path } = await params;\n const safe = path.filter((p) => p !== \"..\" && !p.includes(\"/\")).join(\"/\");\n const filePath = join(srcRoot, safe);\n try {\n const s = await stat(filePath);\n if (!s.isFile()) return new NextResponse(\"Not found\", { status: 404 });\n const ext = filePath.toLowerCase().slice(filePath.lastIndexOf(\".\"));\n const mime = MIME[ext] ?? \"application/octet-stream\";\n const data = await readFile(filePath);\n return new NextResponse(data, {\n status: 200,\n headers: { \"Content-Type\": mime, \"Cache-Control\": \"public, max-age=3600\" },\n });\n } catch {\n return new NextResponse(\"Not found\", { status: 404 });\n }\n };\n}\n"]}
@@ -1,43 +0,0 @@
1
- import {
2
- __name
3
- } from "../../../chunk-PAWJFY3S.mjs";
4
-
5
- // src/features/help/server/createHelpAssetRouteHandler.ts
6
- import { NextResponse } from "next/server";
7
- import { readFile, stat } from "fs/promises";
8
- import { join } from "path";
9
- var MIME = {
10
- ".png": "image/png",
11
- ".jpg": "image/jpeg",
12
- ".jpeg": "image/jpeg",
13
- ".webp": "image/webp",
14
- ".gif": "image/gif",
15
- ".svg": "image/svg+xml",
16
- ".mp4": "video/mp4",
17
- ".webm": "video/webm"
18
- };
19
- function createHelpAssetRouteHandler({ srcRoot }) {
20
- return /* @__PURE__ */ __name(async function GET(_req, { params }) {
21
- const { path } = await params;
22
- const safe = path.filter((p) => p !== ".." && !p.includes("/")).join("/");
23
- const filePath = join(srcRoot, safe);
24
- try {
25
- const s = await stat(filePath);
26
- if (!s.isFile()) return new NextResponse("Not found", { status: 404 });
27
- const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
28
- const mime = MIME[ext] ?? "application/octet-stream";
29
- const data = await readFile(filePath);
30
- return new NextResponse(data, {
31
- status: 200,
32
- headers: { "Content-Type": mime, "Cache-Control": "public, max-age=3600" }
33
- });
34
- } catch {
35
- return new NextResponse("Not found", { status: 404 });
36
- }
37
- }, "GET");
38
- }
39
- __name(createHelpAssetRouteHandler, "createHelpAssetRouteHandler");
40
- export {
41
- createHelpAssetRouteHandler
42
- };
43
- //# sourceMappingURL=createHelpAssetRouteHandler.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/features/help/server/createHelpAssetRouteHandler.ts"],"sourcesContent":["import { NextResponse } from \"next/server\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nconst MIME: Record<string, string> = {\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n \".svg\": \"image/svg+xml\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n};\n\nexport function createHelpAssetRouteHandler({ srcRoot }: { srcRoot: string }) {\n return async function GET(_req: Request, { params }: { params: Promise<{ path: string[] }> }) {\n const { path } = await params;\n const safe = path.filter((p) => p !== \"..\" && !p.includes(\"/\")).join(\"/\");\n const filePath = join(srcRoot, safe);\n try {\n const s = await stat(filePath);\n if (!s.isFile()) return new NextResponse(\"Not found\", { status: 404 });\n const ext = filePath.toLowerCase().slice(filePath.lastIndexOf(\".\"));\n const mime = MIME[ext] ?? \"application/octet-stream\";\n const data = await readFile(filePath);\n return new NextResponse(data, {\n status: 200,\n headers: { \"Content-Type\": mime, \"Cache-Control\": \"public, max-age=3600\" },\n });\n } catch {\n return new NextResponse(\"Not found\", { status: 404 });\n }\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,UAAU,YAAY;AAC/B,SAAS,YAAY;AAErB,IAAM,OAA+B;AAAA,EACnC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AAEO,SAAS,4BAA4B,EAAE,QAAQ,GAAwB;AAC5E,SAAO,sCAAe,IAAI,MAAe,EAAE,OAAO,GAA4C;AAC5F,UAAM,EAAE,KAAK,IAAI,MAAM;AACvB,UAAM,OAAO,KAAK,OAAO,CAAC,MAAM,MAAM,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,GAAG;AACxE,UAAM,WAAW,KAAK,SAAS,IAAI;AACnC,QAAI;AACF,YAAM,IAAI,MAAM,KAAK,QAAQ;AAC7B,UAAI,CAAC,EAAE,OAAO,EAAG,QAAO,IAAI,aAAa,aAAa,EAAE,QAAQ,IAAI,CAAC;AACrE,YAAM,MAAM,SAAS,YAAY,EAAE,MAAM,SAAS,YAAY,GAAG,CAAC;AAClE,YAAM,OAAO,KAAK,GAAG,KAAK;AAC1B,YAAM,OAAO,MAAM,SAAS,QAAQ;AACpC,aAAO,IAAI,aAAa,MAAM;AAAA,QAC5B,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,MAAM,iBAAiB,uBAAuB;AAAA,MAC3E,CAAC;AAAA,IACH,QAAQ;AACN,aAAO,IAAI,aAAa,aAAa,EAAE,QAAQ,IAAI,CAAC;AAAA,IACtD;AAAA,EACF,GAjBO;AAkBT;AAnBgB;","names":[]}
@@ -1,50 +0,0 @@
1
- /**
2
- * Local copy of the help-article types to keep this published frontend library
3
- * decoupled from `@carlonicora/nestjs-neo4jsonapi`. Must stay in sync with
4
- * `packages/nestjs-neo4jsonapi/src/foundations/help-content-sync/interfaces/help-article.interface.ts`.
5
- */
6
- declare const HELP_MODES: readonly ["tutorial", "how-to", "reference", "explanation"];
7
- type HelpMode = (typeof HELP_MODES)[number];
8
- interface HelpHeading {
9
- depth: 2 | 3;
10
- slug: string;
11
- text: string;
12
- }
13
- interface HelpArticle {
14
- id: string;
15
- slug: string;
16
- mode: HelpMode;
17
- title: string;
18
- summary: string;
19
- order: number;
20
- tags: readonly string[];
21
- contextualKeys: readonly string[];
22
- aiIndexed: boolean;
23
- draft: boolean;
24
- contentHash: string;
25
- path: string;
26
- headings: readonly HelpHeading[];
27
- relatedSlugs: readonly string[];
28
- lastUpdated: string;
29
- }
30
- interface HelpRedirect {
31
- from: string;
32
- to: string;
33
- }
34
-
35
- interface HelpBrandConfig {
36
- /** URL of the brand logo image (served by the consuming app). */
37
- logo?: string;
38
- /** Brand label shown in the help header. */
39
- label?: string;
40
- /** Where the "Open app" button navigates for logged-in users. Defaults to "/". */
41
- appHref?: string;
42
- }
43
- interface HelpContentConfig {
44
- manifest: readonly HelpArticle[];
45
- namespaceUuid: string;
46
- redirects?: readonly HelpRedirect[];
47
- brand?: HelpBrandConfig;
48
- }
49
-
50
- export { type HelpContentConfig as H, type HelpArticle as a, type HelpMode as b, type HelpBrandConfig as c, HELP_MODES as d, type HelpHeading as e, type HelpRedirect as f };
@@ -1,50 +0,0 @@
1
- /**
2
- * Local copy of the help-article types to keep this published frontend library
3
- * decoupled from `@carlonicora/nestjs-neo4jsonapi`. Must stay in sync with
4
- * `packages/nestjs-neo4jsonapi/src/foundations/help-content-sync/interfaces/help-article.interface.ts`.
5
- */
6
- declare const HELP_MODES: readonly ["tutorial", "how-to", "reference", "explanation"];
7
- type HelpMode = (typeof HELP_MODES)[number];
8
- interface HelpHeading {
9
- depth: 2 | 3;
10
- slug: string;
11
- text: string;
12
- }
13
- interface HelpArticle {
14
- id: string;
15
- slug: string;
16
- mode: HelpMode;
17
- title: string;
18
- summary: string;
19
- order: number;
20
- tags: readonly string[];
21
- contextualKeys: readonly string[];
22
- aiIndexed: boolean;
23
- draft: boolean;
24
- contentHash: string;
25
- path: string;
26
- headings: readonly HelpHeading[];
27
- relatedSlugs: readonly string[];
28
- lastUpdated: string;
29
- }
30
- interface HelpRedirect {
31
- from: string;
32
- to: string;
33
- }
34
-
35
- interface HelpBrandConfig {
36
- /** URL of the brand logo image (served by the consuming app). */
37
- logo?: string;
38
- /** Brand label shown in the help header. */
39
- label?: string;
40
- /** Where the "Open app" button navigates for logged-in users. Defaults to "/". */
41
- appHref?: string;
42
- }
43
- interface HelpContentConfig {
44
- manifest: readonly HelpArticle[];
45
- namespaceUuid: string;
46
- redirects?: readonly HelpRedirect[];
47
- brand?: HelpBrandConfig;
48
- }
49
-
50
- export { type HelpContentConfig as H, type HelpArticle as a, type HelpMode as b, type HelpBrandConfig as c, HELP_MODES as d, type HelpHeading as e, type HelpRedirect as f };
@@ -1,21 +0,0 @@
1
- import { InfoIcon, AlertTriangleIcon, LightbulbIcon, XCircleIcon, LucideIcon } from "lucide-react";
2
- import { ReactNode } from "react";
3
-
4
- type CalloutType = "info" | "warning" | "tip" | "danger";
5
-
6
- const STYLES: Record<CalloutType, { icon: LucideIcon; ring: string }> = {
7
- info: { icon: InfoIcon, ring: "ring-blue-500/30 bg-blue-500/5" },
8
- warning: { icon: AlertTriangleIcon, ring: "ring-amber-500/30 bg-amber-500/5" },
9
- tip: { icon: LightbulbIcon, ring: "ring-emerald-500/30 bg-emerald-500/5" },
10
- danger: { icon: XCircleIcon, ring: "ring-rose-500/30 bg-rose-500/5" },
11
- };
12
-
13
- export function Callout({ type = "info", children }: { type?: CalloutType; children: ReactNode }) {
14
- const { icon: Icon, ring } = STYLES[type];
15
- return (
16
- <div className={`my-4 flex gap-3 rounded-md ring-1 p-3 ${ring}`}>
17
- <Icon className="mt-0.5 h-4 w-4 shrink-0" />
18
- <div className="text-sm leading-relaxed">{children}</div>
19
- </div>
20
- );
21
- }
@@ -1,18 +0,0 @@
1
- import { Modules } from "../../../../core";
2
- import { ReactNode } from "react";
3
-
4
- export function EntityRef({ type, children }: { type: string; children: ReactNode }) {
5
- let Icon: React.ComponentType<{ className?: string }> | null = null;
6
- try {
7
- const m = Modules.findByName(type);
8
- Icon = m.icon ?? null;
9
- } catch {
10
- Icon = null;
11
- }
12
- return (
13
- <span className="bg-muted text-foreground/90 inline-flex items-center gap-1 rounded px-1.5 py-0.5 align-middle text-xs">
14
- {Icon ? <Icon className="h-3 w-3" /> : null}
15
- {children}
16
- </span>
17
- );
18
- }
@@ -1,6 +0,0 @@
1
- import { ReactNode } from "react";
2
- export function KeyBinding({ children }: { children: ReactNode }) {
3
- return (
4
- <kbd className="bg-muted text-muted-foreground rounded border px-1.5 py-0.5 text-xs font-medium">{children}</kbd>
5
- );
6
- }
@@ -1,33 +0,0 @@
1
- "use client";
2
- import Link from "next/link";
3
- import { useTranslations } from "next-intl";
4
- import { useHelp } from "../../contexts/HelpContext";
5
- import { usePageUrlGenerator } from "../../../../client";
6
- import { articleUrl } from "../../utils/articleUrl";
7
-
8
- export function Related({ slugs }: { slugs: string[] }) {
9
- const t = useTranslations();
10
- const generateUrl = usePageUrlGenerator();
11
- const { manifest } = useHelp();
12
- const items = slugs
13
- .map((s) => manifest.find((a) => `${a.mode}/${a.slug}` === s))
14
- .filter((a): a is NonNullable<typeof a> => Boolean(a));
15
- if (items.length === 0) return null;
16
- return (
17
- <aside className="my-6">
18
- <h3 className="text-muted-foreground mb-2 text-xs font-semibold tracking-wider uppercase">
19
- {t("help.article.related")}
20
- </h3>
21
- <ul className="grid gap-2 sm:grid-cols-2">
22
- {items.map((a) => (
23
- <li key={a.id}>
24
- <Link href={articleUrl(generateUrl, a)} className="hover:bg-muted block rounded border p-3">
25
- <div className="font-medium">{a.title}</div>
26
- <div className="text-muted-foreground text-xs">{a.summary}</div>
27
- </Link>
28
- </li>
29
- ))}
30
- </ul>
31
- </aside>
32
- );
33
- }
@@ -1,9 +0,0 @@
1
- export function Screenshot({ src, alt, caption }: { src: string; alt?: string; caption?: string }) {
2
- const url = src.startsWith("/") ? src : `/help-assets/${src}`;
3
- return (
4
- <figure className="my-4">
5
- <img src={url} alt={alt ?? caption ?? ""} className="rounded-md ring-1 ring-border" />
6
- {caption ? <figcaption className="text-muted-foreground mt-1 text-xs">{caption}</figcaption> : null}
7
- </figure>
8
- );
9
- }
@@ -1,21 +0,0 @@
1
- import { ReactNode, Children } from "react";
2
-
3
- export function Steps({ children }: { children: ReactNode }) {
4
- const items = Children.toArray(children);
5
- return (
6
- <ol className="my-4 list-none space-y-3 pl-0">
7
- {items.map((child, i) => (
8
- <li key={i} className="flex gap-3">
9
- <span className="bg-muted text-muted-foreground flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs">
10
- {i + 1}
11
- </span>
12
- <div className="flex-1 [&>p:first-child]:mt-0">{child}</div>
13
- </li>
14
- ))}
15
- </ol>
16
- );
17
- }
18
-
19
- export function Step({ children }: { children: ReactNode }) {
20
- return <>{children}</>;
21
- }
@@ -1,8 +0,0 @@
1
- export function Video({ src, poster }: { src: string; poster?: string }) {
2
- const url = src.startsWith("/") ? src : `/help-assets/${src}`;
3
- return (
4
- <video controls preload="metadata" poster={poster} className="my-4 w-full rounded-md ring-1 ring-border">
5
- <source src={url} />
6
- </video>
7
- );
8
- }
@@ -1,23 +0,0 @@
1
- // Server-safe subset of MDX_COMPONENTS used by `renderHelpArticle`.
2
- // Mirrors `mdxComponents.ts` but EXCLUDES `Related` (which is a client
3
- // component that uses `useHelp` + `usePageUrlGenerator`). Server-side rendering
4
- // of `<Related>` would require passing the manifest by prop, which the standard
5
- // MDX components map cannot do — articles that need related links should be
6
- // extended via a server-side render hook rather than the MDX shortcode.
7
-
8
- import { Callout } from "./Callout";
9
- import { Steps, Step } from "./Steps";
10
- import { Screenshot } from "./Screenshot";
11
- import { EntityRef } from "./EntityRef";
12
- import { KeyBinding } from "./KeyBinding";
13
- import { Video } from "./Video";
14
-
15
- export const MDX_SERVER_COMPONENTS = {
16
- Callout,
17
- Steps,
18
- Step,
19
- Screenshot,
20
- EntityRef,
21
- KeyBinding,
22
- Video,
23
- } as const;
@@ -1,9 +0,0 @@
1
- import { Callout } from "./Callout";
2
- import { Steps, Step } from "./Steps";
3
- import { Screenshot } from "./Screenshot";
4
- import { EntityRef } from "./EntityRef";
5
- import { KeyBinding } from "./KeyBinding";
6
- import { Video } from "./Video";
7
- import { Related } from "./Related";
8
-
9
- export const MDX_COMPONENTS = { Callout, Steps, Step, Screenshot, EntityRef, KeyBinding, Video, Related };
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { useHelp } from "../contexts/HelpContext";
3
- import { findHelpArticle } from "../utils/helpNavigation";
4
-
5
- export function useHelpArticle(mode: string, slug: string) {
6
- return findHelpArticle(useHelp().manifest, mode, slug);
7
- }
@@ -1,5 +0,0 @@
1
- "use client";
2
- import { useHelp } from "../contexts/HelpContext";
3
- export function useHelpManifest() {
4
- return useHelp().manifest;
5
- }
@@ -1,43 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll } from "vitest";
2
- import { mkdtemp, writeFile, mkdir, rm } from "node:fs/promises";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { createHelpAssetRouteHandler } from "../createHelpAssetRouteHandler";
6
-
7
- describe("createHelpAssetRouteHandler", () => {
8
- let srcRoot: string;
9
-
10
- beforeAll(async () => {
11
- srcRoot = await mkdtemp(join(tmpdir(), "help-assets-"));
12
- await mkdir(srcRoot, { recursive: true });
13
- await writeFile(join(srcRoot, "ok.png"), Buffer.from([0x89, 0x50, 0x4e, 0x47]));
14
- });
15
- afterAll(async () => {
16
- await rm(srcRoot, { recursive: true, force: true });
17
- });
18
-
19
- it("returns 200 with correct MIME for an existing PNG", async () => {
20
- const GET = createHelpAssetRouteHandler({ srcRoot });
21
- const res = await GET(new Request("http://localhost/help-assets/ok.png"), {
22
- params: Promise.resolve({ path: ["ok.png"] }),
23
- });
24
- expect(res.status).toBe(200);
25
- expect(res.headers.get("Content-Type")).toBe("image/png");
26
- });
27
-
28
- it("returns 404 for missing files", async () => {
29
- const GET = createHelpAssetRouteHandler({ srcRoot });
30
- const res = await GET(new Request("http://localhost/help-assets/missing.png"), {
31
- params: Promise.resolve({ path: ["missing.png"] }),
32
- });
33
- expect(res.status).toBe(404);
34
- });
35
-
36
- it("sanitizes path traversal attempts", async () => {
37
- const GET = createHelpAssetRouteHandler({ srcRoot });
38
- const res = await GET(new Request("http://localhost/help-assets/etc/passwd"), {
39
- params: Promise.resolve({ path: ["..", "..", "etc", "passwd"] }),
40
- });
41
- expect(res.status).toBe(404);
42
- });
43
- });
@@ -1,35 +0,0 @@
1
- import { NextResponse } from "next/server";
2
- import { readFile, stat } from "node:fs/promises";
3
- import { join } from "node:path";
4
-
5
- const MIME: Record<string, string> = {
6
- ".png": "image/png",
7
- ".jpg": "image/jpeg",
8
- ".jpeg": "image/jpeg",
9
- ".webp": "image/webp",
10
- ".gif": "image/gif",
11
- ".svg": "image/svg+xml",
12
- ".mp4": "video/mp4",
13
- ".webm": "video/webm",
14
- };
15
-
16
- export function createHelpAssetRouteHandler({ srcRoot }: { srcRoot: string }) {
17
- return async function GET(_req: Request, { params }: { params: Promise<{ path: string[] }> }) {
18
- const { path } = await params;
19
- const safe = path.filter((p) => p !== ".." && !p.includes("/")).join("/");
20
- const filePath = join(srcRoot, safe);
21
- try {
22
- const s = await stat(filePath);
23
- if (!s.isFile()) return new NextResponse("Not found", { status: 404 });
24
- const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
25
- const mime = MIME[ext] ?? "application/octet-stream";
26
- const data = await readFile(filePath);
27
- return new NextResponse(data, {
28
- status: 200,
29
- headers: { "Content-Type": mime, "Cache-Control": "public, max-age=3600" },
30
- });
31
- } catch {
32
- return new NextResponse("Not found", { status: 404 });
33
- }
34
- };
35
- }
@@ -1,18 +0,0 @@
1
- import type { Metadata } from "next";
2
- import { findHelpArticle } from "../utils/helpNavigation";
3
- import { getHelpContent } from "./getHelpContent";
4
-
5
- export async function generateHelpArticleMetadata({
6
- params,
7
- }: {
8
- params: Promise<{ mode: string; slug: string }>;
9
- }): Promise<Metadata> {
10
- const { mode, slug } = await params;
11
- const article = findHelpArticle(getHelpContent().manifest, mode, slug);
12
- if (!article) return {};
13
- return {
14
- title: article.title,
15
- description: article.summary,
16
- openGraph: { title: article.title, description: article.summary },
17
- };
18
- }
@@ -1,7 +0,0 @@
1
- import { getHelpContent } from "./getHelpContent";
2
-
3
- export function generateHelpArticleStaticParams(): { mode: string; slug: string }[] {
4
- return getHelpContent()
5
- .manifest.filter((a) => !a.draft)
6
- .map((a) => ({ mode: a.mode, slug: a.slug }));
7
- }
@@ -1,5 +0,0 @@
1
- import { HELP_MODES } from "../types/help-article.types";
2
-
3
- export function generateHelpModeStaticParams(): { mode: string }[] {
4
- return HELP_MODES.map((mode) => ({ mode }));
5
- }
@@ -1,17 +0,0 @@
1
- import { _getStaticHelpContent } from "../../../core/registry/helpStore";
2
- import type { HelpContentConfig } from "../interfaces/help-content-config.interface";
3
-
4
- /**
5
- * Server-side accessor for the help-content config set via configureJsonApi().
6
- * Returns the same value <HelpProvider> exposes via React Context to client components.
7
- * Throws with a setup error if helpContent was never configured.
8
- */
9
- export function getHelpContent(): HelpContentConfig {
10
- const cfg = _getStaticHelpContent<HelpContentConfig>();
11
- if (!cfg) {
12
- throw new Error(
13
- "Help content not configured — call configureJsonApi({ helpContent: {...} }) before importing help pages.",
14
- );
15
- }
16
- return cfg;
17
- }
@@ -1,8 +0,0 @@
1
- export { getHelpContent } from "./getHelpContent";
2
- export { renderHelpArticle, serializeHelpArticle } from "./serializeHelpArticle";
3
- export { generateHelpArticleStaticParams } from "./generateHelpArticleStaticParams";
4
- export { generateHelpArticleMetadata } from "./generateHelpArticleMetadata";
5
- export { generateHelpModeStaticParams } from "./generateHelpModeStaticParams";
6
- // NOTE: `createHelpAssetRouteHandler` is intentionally NOT re-exported here.
7
- // It uses `node:fs/promises` and must only be reachable via the dedicated
8
- // `@carlonicora/nextjs-jsonapi/help-asset-route` subpath, never the main bundle.
@@ -1,46 +0,0 @@
1
- import { MDXRemote } from "next-mdx-remote/rsc";
2
- import remarkGfm from "remark-gfm";
3
- import rehypeSlug from "rehype-slug";
4
- import rehypeAutolinkHeadings from "rehype-autolink-headings";
5
- import type { ReactElement } from "react";
6
- import type { HelpArticle } from "../types/help-article.types";
7
- import { _getStaticHelpReader } from "../../../core/registry/helpStore";
8
- import { MDX_SERVER_COMPONENTS } from "../components/mdx/mdx-server-components";
9
-
10
- /**
11
- * Server-side: read the article's raw markdown via the registered help reader
12
- * and render it through `next-mdx-remote/rsc`'s server-side MDXRemote, using
13
- * the server-safe MDX components (Callout, Steps, Screenshot, EntityRef,
14
- * KeyBinding, Video). The returned React element can be embedded inside a
15
- * server component (e.g. as `children` of `<HelpArticleBody>`).
16
- *
17
- * Note: `<Related>` is intentionally not part of the server map — it's a client
18
- * component that reads HelpContext. Articles that reference `<Related>` would
19
- * need a separate render path that injects the manifest by prop.
20
- */
21
- export async function renderHelpArticle(article: HelpArticle): Promise<ReactElement> {
22
- const readRawMarkdown = _getStaticHelpReader();
23
- if (!readRawMarkdown) {
24
- throw new Error(
25
- "Help reader not configured. Call setHelpReader(fn) from a server-only entrypoint (e.g. Next.js instrumentation register()) before rendering help articles.",
26
- );
27
- }
28
- const source = await readRawMarkdown(article);
29
- return (
30
- <MDXRemote
31
- source={source}
32
- components={MDX_SERVER_COMPONENTS}
33
- options={{
34
- parseFrontmatter: true,
35
- mdxOptions: {
36
- remarkPlugins: [remarkGfm],
37
- rehypePlugins: [rehypeSlug, [rehypeAutolinkHeadings, { behavior: "wrap" }]],
38
- },
39
- }}
40
- />
41
- );
42
- }
43
-
44
- /** @deprecated Use `renderHelpArticle` instead — the legacy serialize + client
45
- * MDXRemote pattern is incompatible with App Router RSC. */
46
- export const serializeHelpArticle = renderHelpArticle;