@apimatic/cli 1.4.0 → 2.0.0-beta.1

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 (610) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -212
  3. package/apimatic.schema.json +550 -0
  4. package/lib/actions/action-result.js +3 -0
  5. package/lib/actions/action-result.js.map +1 -1
  6. package/lib/actions/api/transform.js +36 -33
  7. package/lib/actions/api/transform.js.map +1 -1
  8. package/lib/actions/api/validate.d.ts +9 -6
  9. package/lib/actions/api/validate.js +44 -38
  10. package/lib/actions/api/validate.js.map +1 -1
  11. package/lib/actions/auth/login.js +7 -4
  12. package/lib/actions/auth/login.js.map +1 -1
  13. package/lib/actions/auth/logout.js +2 -1
  14. package/lib/actions/auth/logout.js.map +1 -1
  15. package/lib/actions/auth/status.js +5 -3
  16. package/lib/actions/auth/status.js.map +1 -1
  17. package/lib/actions/plugin/generate.d.ts +5 -1
  18. package/lib/actions/plugin/generate.js +83 -56
  19. package/lib/actions/plugin/generate.js.map +1 -1
  20. package/lib/actions/plugin/publish.d.ts +2 -1
  21. package/lib/actions/plugin/publish.js +34 -37
  22. package/lib/actions/plugin/publish.js.map +1 -1
  23. package/lib/actions/plugin/record-metadata.d.ts +3 -2
  24. package/lib/actions/plugin/record-metadata.js +33 -30
  25. package/lib/actions/plugin/record-metadata.js.map +1 -1
  26. package/lib/actions/portal/generate.d.ts +8 -6
  27. package/lib/actions/portal/generate.js +50 -61
  28. package/lib/actions/portal/generate.js.map +1 -1
  29. package/lib/actions/portal/prepare-project.d.ts +25 -0
  30. package/lib/actions/portal/prepare-project.js +68 -0
  31. package/lib/actions/portal/prepare-project.js.map +1 -0
  32. package/lib/actions/portal/serve.d.ts +21 -6
  33. package/lib/actions/portal/serve.js +170 -153
  34. package/lib/actions/portal/serve.js.map +1 -1
  35. package/lib/actions/publishing/profile/list.js +4 -2
  36. package/lib/actions/publishing/profile/list.js.map +1 -1
  37. package/lib/actions/quickstart.d.ts +23 -5
  38. package/lib/actions/quickstart.js +222 -21
  39. package/lib/actions/quickstart.js.map +1 -1
  40. package/lib/actions/sdk/generate.d.ts +4 -7
  41. package/lib/actions/sdk/generate.js +53 -93
  42. package/lib/actions/sdk/generate.js.map +1 -1
  43. package/lib/actions/sdk/publish/interactive.d.ts +4 -3
  44. package/lib/actions/sdk/publish/interactive.js +96 -97
  45. package/lib/actions/sdk/publish/interactive.js.map +1 -1
  46. package/lib/actions/sdk/publish/non-interactive.d.ts +4 -2
  47. package/lib/actions/sdk/publish/non-interactive.js +91 -90
  48. package/lib/actions/sdk/publish/non-interactive.js.map +1 -1
  49. package/lib/actions/sdk/publish.d.ts +3 -2
  50. package/lib/actions/sdk/publish.js +55 -53
  51. package/lib/actions/sdk/publish.js.map +1 -1
  52. package/lib/actions/sdk/record-published-sdk.d.ts +14 -0
  53. package/lib/actions/sdk/record-published-sdk.js +57 -0
  54. package/lib/actions/sdk/record-published-sdk.js.map +1 -0
  55. package/lib/client-utils/auth-manager.js +1 -1
  56. package/lib/client-utils/auth-manager.js.map +1 -1
  57. package/lib/commands/api/transform.d.ts +1 -1
  58. package/lib/commands/api/transform.js +44 -40
  59. package/lib/commands/api/transform.js.map +1 -1
  60. package/lib/commands/api/validate.js +16 -16
  61. package/lib/commands/api/validate.js.map +1 -1
  62. package/lib/commands/auth/login.js +14 -15
  63. package/lib/commands/auth/login.js.map +1 -1
  64. package/lib/commands/auth/logout.js +5 -6
  65. package/lib/commands/auth/logout.js.map +1 -1
  66. package/lib/commands/auth/status.js +4 -5
  67. package/lib/commands/auth/status.js.map +1 -1
  68. package/lib/commands/plugin/generate.d.ts +3 -3
  69. package/lib/commands/plugin/generate.js +20 -20
  70. package/lib/commands/plugin/generate.js.map +1 -1
  71. package/lib/commands/plugin/publish.js +18 -18
  72. package/lib/commands/plugin/publish.js.map +1 -1
  73. package/lib/commands/portal/generate.d.ts +9 -8
  74. package/lib/commands/portal/generate.js +36 -27
  75. package/lib/commands/portal/generate.js.map +1 -1
  76. package/lib/commands/portal/serve.d.ts +7 -9
  77. package/lib/commands/portal/serve.js +41 -44
  78. package/lib/commands/portal/serve.js.map +1 -1
  79. package/lib/commands/publishing/profile/list.js +8 -12
  80. package/lib/commands/publishing/profile/list.js.map +1 -1
  81. package/lib/commands/quickstart.d.ts +5 -5
  82. package/lib/commands/quickstart.js +18 -24
  83. package/lib/commands/quickstart.js.map +1 -1
  84. package/lib/commands/sdk/generate.d.ts +5 -7
  85. package/lib/commands/sdk/generate.js +58 -70
  86. package/lib/commands/sdk/generate.js.map +1 -1
  87. package/lib/commands/sdk/publish.d.ts +6 -7
  88. package/lib/commands/sdk/publish.js +66 -60
  89. package/lib/commands/sdk/publish.js.map +1 -1
  90. package/lib/hooks/node-version.d.ts +3 -0
  91. package/lib/hooks/node-version.js +12 -0
  92. package/lib/hooks/node-version.js.map +1 -0
  93. package/lib/hooks/not-found.js +2 -3
  94. package/lib/hooks/not-found.js.map +1 -1
  95. package/lib/hooks/utils.d.ts +4 -2
  96. package/lib/hooks/utils.js +2 -2
  97. package/lib/hooks/utils.js.map +1 -1
  98. package/lib/infrastructure/env-info.d.ts +3 -0
  99. package/lib/infrastructure/env-info.js +13 -6
  100. package/lib/infrastructure/env-info.js.map +1 -1
  101. package/lib/infrastructure/file-service.d.ts +35 -8
  102. package/lib/infrastructure/file-service.js +149 -53
  103. package/lib/infrastructure/file-service.js.map +1 -1
  104. package/lib/infrastructure/file-watch-service.d.ts +40 -0
  105. package/lib/infrastructure/file-watch-service.js +167 -0
  106. package/lib/infrastructure/file-watch-service.js.map +1 -0
  107. package/lib/infrastructure/generation-status-poller.d.ts +8 -7
  108. package/lib/infrastructure/generation-status-poller.js +20 -12
  109. package/lib/infrastructure/generation-status-poller.js.map +1 -1
  110. package/lib/infrastructure/launcher-service.js +6 -6
  111. package/lib/infrastructure/launcher-service.js.map +1 -1
  112. package/lib/infrastructure/network-service.d.ts +3 -0
  113. package/lib/infrastructure/network-service.js +15 -1
  114. package/lib/infrastructure/network-service.js.map +1 -1
  115. package/lib/infrastructure/portal-build-service.d.ts +19 -0
  116. package/lib/infrastructure/portal-build-service.js +58 -0
  117. package/lib/infrastructure/portal-build-service.js.map +1 -0
  118. package/lib/infrastructure/portal-dev-server-service.d.ts +29 -0
  119. package/lib/infrastructure/portal-dev-server-service.js +135 -0
  120. package/lib/infrastructure/portal-dev-server-service.js.map +1 -0
  121. package/lib/infrastructure/portal-pages-service.d.ts +17 -0
  122. package/lib/infrastructure/portal-pages-service.js +103 -0
  123. package/lib/infrastructure/portal-pages-service.js.map +1 -0
  124. package/lib/infrastructure/portal-project-service.d.ts +77 -0
  125. package/lib/infrastructure/portal-project-service.js +309 -0
  126. package/lib/infrastructure/portal-project-service.js.map +1 -0
  127. package/lib/infrastructure/service-error.d.ts +1 -0
  128. package/lib/infrastructure/service-error.js +39 -41
  129. package/lib/infrastructure/service-error.js.map +1 -1
  130. package/lib/infrastructure/services/api-client-factory.js +15 -13
  131. package/lib/infrastructure/services/api-client-factory.js.map +1 -1
  132. package/lib/infrastructure/services/api-service.d.ts +7 -5
  133. package/lib/infrastructure/services/api-service.js +28 -20
  134. package/lib/infrastructure/services/api-service.js.map +1 -1
  135. package/lib/infrastructure/services/auth-service.js +4 -9
  136. package/lib/infrastructure/services/auth-service.js.map +1 -1
  137. package/lib/infrastructure/services/file-download-service.js +3 -3
  138. package/lib/infrastructure/services/file-download-service.js.map +1 -1
  139. package/lib/infrastructure/services/plugin-service.d.ts +1 -8
  140. package/lib/infrastructure/services/plugin-service.js +11 -22
  141. package/lib/infrastructure/services/plugin-service.js.map +1 -1
  142. package/lib/infrastructure/services/portal-artifacts-service.d.ts +44 -0
  143. package/lib/infrastructure/services/portal-artifacts-service.js +268 -0
  144. package/lib/infrastructure/services/portal-artifacts-service.js.map +1 -0
  145. package/lib/infrastructure/services/portal-authorization-service.d.ts +22 -0
  146. package/lib/infrastructure/services/portal-authorization-service.js +23 -0
  147. package/lib/infrastructure/services/portal-authorization-service.js.map +1 -0
  148. package/lib/infrastructure/services/publishing-api-service.d.ts +1 -1
  149. package/lib/infrastructure/services/publishing-api-service.js +11 -15
  150. package/lib/infrastructure/services/publishing-api-service.js.map +1 -1
  151. package/lib/infrastructure/services/sdk-generation-service.d.ts +21 -0
  152. package/lib/infrastructure/services/sdk-generation-service.js +118 -0
  153. package/lib/infrastructure/services/sdk-generation-service.js.map +1 -0
  154. package/lib/infrastructure/services/telemetry-service.js +5 -4
  155. package/lib/infrastructure/services/telemetry-service.js.map +1 -1
  156. package/lib/infrastructure/services/transformation-service.js +29 -32
  157. package/lib/infrastructure/services/transformation-service.js.map +1 -1
  158. package/lib/infrastructure/services/validation-service.d.ts +12 -53
  159. package/lib/infrastructure/services/validation-service.js +24 -199
  160. package/lib/infrastructure/services/validation-service.js.map +1 -1
  161. package/lib/infrastructure/timer-extensions.d.ts +2 -0
  162. package/lib/infrastructure/timer-extensions.js +10 -0
  163. package/lib/infrastructure/timer-extensions.js.map +1 -0
  164. package/lib/infrastructure/tmp-extensions.d.ts +31 -1
  165. package/lib/infrastructure/tmp-extensions.js +86 -3
  166. package/lib/infrastructure/tmp-extensions.js.map +1 -1
  167. package/lib/infrastructure/zip-service.js +2 -2
  168. package/lib/infrastructure/zip-service.js.map +1 -1
  169. package/lib/prompts/api/validate.d.ts +6 -7
  170. package/lib/prompts/api/validate.js +12 -12
  171. package/lib/prompts/api/validate.js.map +1 -1
  172. package/lib/prompts/format.d.ts +4 -0
  173. package/lib/prompts/format.js +5 -0
  174. package/lib/prompts/format.js.map +1 -1
  175. package/lib/prompts/plugin/generate.d.ts +17 -12
  176. package/lib/prompts/plugin/generate.js +94 -44
  177. package/lib/prompts/plugin/generate.js.map +1 -1
  178. package/lib/prompts/plugin/publish.d.ts +2 -1
  179. package/lib/prompts/plugin/publish.js +8 -7
  180. package/lib/prompts/plugin/publish.js.map +1 -1
  181. package/lib/prompts/plugin/record-metadata.d.ts +1 -0
  182. package/lib/prompts/plugin/record-metadata.js +10 -7
  183. package/lib/prompts/plugin/record-metadata.js.map +1 -1
  184. package/lib/prompts/portal/artifacts.d.ts +8 -0
  185. package/lib/prompts/portal/artifacts.js +26 -0
  186. package/lib/prompts/portal/artifacts.js.map +1 -0
  187. package/lib/prompts/portal/authorization.d.ts +6 -0
  188. package/lib/prompts/portal/authorization.js +29 -0
  189. package/lib/prompts/portal/authorization.js.map +1 -0
  190. package/lib/prompts/portal/code-samples.d.ts +1 -0
  191. package/lib/prompts/portal/code-samples.js +9 -0
  192. package/lib/prompts/portal/code-samples.js.map +1 -0
  193. package/lib/prompts/portal/generate.d.ts +14 -9
  194. package/lib/prompts/portal/generate.js +48 -26
  195. package/lib/prompts/portal/generate.js.map +1 -1
  196. package/lib/prompts/portal/prepare-project.d.ts +20 -0
  197. package/lib/prompts/portal/prepare-project.js +36 -0
  198. package/lib/prompts/portal/prepare-project.js.map +1 -0
  199. package/lib/prompts/portal/serve.d.ts +32 -12
  200. package/lib/prompts/portal/serve.js +102 -39
  201. package/lib/prompts/portal/serve.js.map +1 -1
  202. package/lib/prompts/portal/source.d.ts +26 -0
  203. package/lib/prompts/portal/source.js +253 -0
  204. package/lib/prompts/portal/source.js.map +1 -0
  205. package/lib/prompts/prompt.d.ts +11 -3
  206. package/lib/prompts/prompt.js +39 -15
  207. package/lib/prompts/prompt.js.map +1 -1
  208. package/lib/prompts/quickstart.d.ts +46 -3
  209. package/lib/prompts/quickstart.js +199 -12
  210. package/lib/prompts/quickstart.js.map +1 -1
  211. package/lib/prompts/sdk/generate.d.ts +15 -13
  212. package/lib/prompts/sdk/generate.js +29 -32
  213. package/lib/prompts/sdk/generate.js.map +1 -1
  214. package/lib/prompts/sdk/publish/interactive.d.ts +10 -6
  215. package/lib/prompts/sdk/publish/interactive.js +26 -24
  216. package/lib/prompts/sdk/publish/interactive.js.map +1 -1
  217. package/lib/prompts/sdk/publish/non-interactive.d.ts +2 -1
  218. package/lib/prompts/sdk/publish/non-interactive.js +5 -4
  219. package/lib/prompts/sdk/publish/non-interactive.js.map +1 -1
  220. package/lib/prompts/sdk/publish.d.ts +3 -3
  221. package/lib/prompts/sdk/publish.js +13 -17
  222. package/lib/prompts/sdk/publish.js.map +1 -1
  223. package/lib/prompts/sdk/record-published-sdk.d.ts +7 -0
  224. package/lib/prompts/sdk/record-published-sdk.js +26 -0
  225. package/lib/prompts/sdk/record-published-sdk.js.map +1 -0
  226. package/lib/types/apimatic-config/document.d.ts +70 -0
  227. package/lib/types/apimatic-config/document.js +167 -0
  228. package/lib/types/apimatic-config/document.js.map +1 -0
  229. package/lib/types/apimatic-config/languages-block.d.ts +39 -0
  230. package/lib/types/apimatic-config/languages-block.js +58 -0
  231. package/lib/types/apimatic-config/languages-block.js.map +1 -0
  232. package/lib/types/apimatic-config-context.d.ts +48 -0
  233. package/lib/types/apimatic-config-context.js +121 -0
  234. package/lib/types/apimatic-config-context.js.map +1 -0
  235. package/lib/types/build/build.d.ts +1 -89
  236. package/lib/types/build/build.js +6 -161
  237. package/lib/types/build/build.js.map +1 -1
  238. package/lib/types/events/domain-event.js +3 -0
  239. package/lib/types/events/domain-event.js.map +1 -1
  240. package/lib/types/events/quickstart-completed.js +3 -3
  241. package/lib/types/events/quickstart-completed.js.map +1 -1
  242. package/lib/types/events/quickstart-initiated.js +3 -3
  243. package/lib/types/events/quickstart-initiated.js.map +1 -1
  244. package/lib/types/events/sdk-publish-validation-failed.js +1 -1
  245. package/lib/types/events/sdk-publish-validation-failed.js.map +1 -1
  246. package/lib/types/file/directory.d.ts +4 -9
  247. package/lib/types/file/directory.js +17 -65
  248. package/lib/types/file/directory.js.map +1 -1
  249. package/lib/types/file/directoryPath.d.ts +17 -0
  250. package/lib/types/file/directoryPath.js +47 -2
  251. package/lib/types/file/directoryPath.js.map +1 -1
  252. package/lib/types/file/fileName.d.ts +8 -0
  253. package/lib/types/file/fileName.js +28 -6
  254. package/lib/types/file/fileName.js.map +1 -1
  255. package/lib/types/file/filePath.d.ts +18 -2
  256. package/lib/types/file/filePath.js +39 -4
  257. package/lib/types/file/filePath.js.map +1 -1
  258. package/lib/types/file/resource-input.js +1 -2
  259. package/lib/types/file/resource-input.js.map +1 -1
  260. package/lib/types/file/urlPath.js +2 -1
  261. package/lib/types/file/urlPath.js.map +1 -1
  262. package/lib/types/flags-provider.js +22 -22
  263. package/lib/types/flags-provider.js.map +1 -1
  264. package/lib/types/package-settings-context.js +2 -1
  265. package/lib/types/package-settings-context.js.map +1 -1
  266. package/lib/types/plugin/plugin-config.d.ts +10 -50
  267. package/lib/types/plugin/plugin-config.js +7 -1
  268. package/lib/types/plugin/plugin-config.js.map +1 -1
  269. package/lib/types/plugin-config-context.d.ts +30 -37
  270. package/lib/types/plugin-config-context.js +108 -139
  271. package/lib/types/plugin-config-context.js.map +1 -1
  272. package/lib/types/plugin-context.js +3 -2
  273. package/lib/types/plugin-context.js.map +1 -1
  274. package/lib/types/portal/code-samples.d.ts +27 -0
  275. package/lib/types/portal/code-samples.js +67 -0
  276. package/lib/types/portal/code-samples.js.map +1 -0
  277. package/lib/types/portal/config/ai-config.d.ts +15 -0
  278. package/lib/types/portal/config/ai-config.js +26 -0
  279. package/lib/types/portal/config/ai-config.js.map +1 -0
  280. package/lib/types/portal/config/brand-config.d.ts +55 -0
  281. package/lib/types/portal/config/brand-config.js +105 -0
  282. package/lib/types/portal/config/brand-config.js.map +1 -0
  283. package/lib/types/portal/config/color.d.ts +19 -0
  284. package/lib/types/portal/config/color.js +43 -0
  285. package/lib/types/portal/config/color.js.map +1 -0
  286. package/lib/types/portal/config/fields.d.ts +23 -0
  287. package/lib/types/portal/config/fields.js +67 -0
  288. package/lib/types/portal/config/fields.js.map +1 -0
  289. package/lib/types/portal/config/link.d.ts +18 -0
  290. package/lib/types/portal/config/link.js +72 -0
  291. package/lib/types/portal/config/link.js.map +1 -0
  292. package/lib/types/portal/config/navigation-config.d.ts +13 -0
  293. package/lib/types/portal/config/navigation-config.js +30 -0
  294. package/lib/types/portal/config/navigation-config.js.map +1 -0
  295. package/lib/types/portal/config/site-config.d.ts +32 -0
  296. package/lib/types/portal/config/site-config.js +88 -0
  297. package/lib/types/portal/config/site-config.js.map +1 -0
  298. package/lib/types/portal/config/static-asset.d.ts +25 -0
  299. package/lib/types/portal/config/static-asset.js +77 -0
  300. package/lib/types/portal/config/static-asset.js.map +1 -0
  301. package/lib/types/portal/content-notices.d.ts +20 -0
  302. package/lib/types/portal/content-notices.js +2 -0
  303. package/lib/types/portal/content-notices.js.map +1 -0
  304. package/lib/types/portal/content-tree.d.ts +103 -0
  305. package/lib/types/portal/content-tree.js +344 -0
  306. package/lib/types/portal/content-tree.js.map +1 -0
  307. package/lib/types/portal/endpoint.d.ts +6 -0
  308. package/lib/types/portal/endpoint.js +12 -0
  309. package/lib/types/portal/endpoint.js.map +1 -0
  310. package/lib/types/portal/generated-pages.d.ts +68 -0
  311. package/lib/types/portal/generated-pages.js +111 -0
  312. package/lib/types/portal/generated-pages.js.map +1 -0
  313. package/lib/types/portal/generation-status.d.ts +31 -0
  314. package/lib/types/portal/generation-status.js +26 -0
  315. package/lib/types/portal/generation-status.js.map +1 -0
  316. package/lib/types/portal/openapi-document.d.ts +48 -0
  317. package/lib/types/portal/openapi-document.js +138 -0
  318. package/lib/types/portal/openapi-document.js.map +1 -0
  319. package/lib/types/portal/page-fragments.d.ts +13 -0
  320. package/lib/types/portal/page-fragments.js +24 -0
  321. package/lib/types/portal/page-fragments.js.map +1 -0
  322. package/lib/types/portal/page-template.d.ts +15 -0
  323. package/lib/types/portal/page-template.js +64 -0
  324. package/lib/types/portal/page-template.js.map +1 -0
  325. package/lib/types/portal/page.d.ts +24 -0
  326. package/lib/types/portal/page.js +100 -0
  327. package/lib/types/portal/page.js.map +1 -0
  328. package/lib/types/portal/portal-artifacts.d.ts +25 -0
  329. package/lib/types/portal/portal-artifacts.js +30 -0
  330. package/lib/types/portal/portal-artifacts.js.map +1 -0
  331. package/lib/types/portal/portal-config.d.ts +69 -0
  332. package/lib/types/portal/portal-config.js +105 -0
  333. package/lib/types/portal/portal-config.js.map +1 -0
  334. package/lib/types/portal/portal-downloads.d.ts +8 -0
  335. package/lib/types/portal/portal-downloads.js +14 -0
  336. package/lib/types/portal/portal-downloads.js.map +1 -0
  337. package/lib/types/portal/portal-languages.d.ts +15 -0
  338. package/lib/types/portal/portal-languages.js +45 -0
  339. package/lib/types/portal/portal-languages.js.map +1 -0
  340. package/lib/types/portal/portal-navigation.d.ts +65 -0
  341. package/lib/types/portal/portal-navigation.js +217 -0
  342. package/lib/types/portal/portal-navigation.js.map +1 -0
  343. package/lib/types/portal/portal-sdk.d.ts +15 -0
  344. package/lib/types/portal/portal-sdk.js +28 -0
  345. package/lib/types/portal/portal-sdk.js.map +1 -0
  346. package/lib/types/portal/portal-source.d.ts +129 -0
  347. package/lib/types/portal/portal-source.js +2 -0
  348. package/lib/types/portal/portal-source.js.map +1 -0
  349. package/lib/types/portal/portal-stylesheet.d.ts +19 -0
  350. package/lib/types/portal/portal-stylesheet.js +40 -0
  351. package/lib/types/portal/portal-stylesheet.js.map +1 -0
  352. package/lib/types/portal/portal-tabs.d.ts +33 -0
  353. package/lib/types/portal/portal-tabs.js +38 -0
  354. package/lib/types/portal/portal-tabs.js.map +1 -0
  355. package/lib/types/portal/preview-config.d.ts +20 -0
  356. package/lib/types/portal/preview-config.js +32 -0
  357. package/lib/types/portal/preview-config.js.map +1 -0
  358. package/lib/types/portal/preview-content.d.ts +18 -0
  359. package/lib/types/portal/preview-content.js +50 -0
  360. package/lib/types/portal/preview-content.js.map +1 -0
  361. package/lib/types/portal/published-package.d.ts +12 -0
  362. package/lib/types/portal/published-package.js +35 -0
  363. package/lib/types/portal/published-package.js.map +1 -0
  364. package/lib/types/portal/unknown-fields.d.ts +5 -0
  365. package/lib/types/portal/unknown-fields.js +10 -0
  366. package/lib/types/portal/unknown-fields.js.map +1 -0
  367. package/lib/types/portal-context.d.ts +38 -6
  368. package/lib/types/portal-context.js +71 -24
  369. package/lib/types/portal-context.js.map +1 -1
  370. package/lib/types/portal-source-context.d.ts +77 -0
  371. package/lib/types/portal-source-context.js +408 -0
  372. package/lib/types/portal-source-context.js.map +1 -0
  373. package/lib/types/project-context.d.ts +49 -0
  374. package/lib/types/project-context.js +151 -0
  375. package/lib/types/project-context.js.map +1 -0
  376. package/lib/types/project-layout.d.ts +9 -0
  377. package/lib/types/project-layout.js +10 -0
  378. package/lib/types/project-layout.js.map +1 -0
  379. package/lib/types/publish/package-settings-configuration.d.ts +2 -0
  380. package/lib/types/publish/profile-id.js +1 -0
  381. package/lib/types/publish/profile-id.js.map +1 -1
  382. package/lib/types/publish/publishing-profile.d.ts +3 -1
  383. package/lib/types/publish/publishing-profile.js +33 -15
  384. package/lib/types/publish/publishing-profile.js.map +1 -1
  385. package/lib/types/publish/publishing-profiles.js +2 -1
  386. package/lib/types/publish/publishing-profiles.js.map +1 -1
  387. package/lib/types/publish/version.js +1 -0
  388. package/lib/types/publish/version.js.map +1 -1
  389. package/lib/types/resource-context.js +3 -2
  390. package/lib/types/resource-context.js.map +1 -1
  391. package/lib/types/sdk/generate.d.ts +22 -16
  392. package/lib/types/sdk/generate.js +64 -41
  393. package/lib/types/sdk/generate.js.map +1 -1
  394. package/lib/types/sdk/stability-choice.d.ts +12 -0
  395. package/lib/types/sdk/stability-choice.js +24 -0
  396. package/lib/types/sdk/stability-choice.js.map +1 -0
  397. package/lib/types/sdk-context.d.ts +4 -5
  398. package/lib/types/sdk-context.js +10 -18
  399. package/lib/types/sdk-context.js.map +1 -1
  400. package/lib/types/spec-context.d.ts +5 -4
  401. package/lib/types/spec-context.js +9 -8
  402. package/lib/types/spec-context.js.map +1 -1
  403. package/lib/types/temp-context.d.ts +1 -1
  404. package/lib/types/temp-context.js +5 -4
  405. package/lib/types/temp-context.js.map +1 -1
  406. package/lib/types/transform-context.d.ts +9 -5
  407. package/lib/types/transform-context.js +21 -18
  408. package/lib/types/transform-context.js.map +1 -1
  409. package/lib/utils/error-utils.d.ts +2 -0
  410. package/lib/utils/error-utils.js +5 -0
  411. package/lib/utils/error-utils.js.map +1 -0
  412. package/lib/utils/json-utils.d.ts +2 -0
  413. package/lib/utils/json-utils.js +4 -0
  414. package/lib/utils/json-utils.js.map +1 -0
  415. package/lib/utils/string-utils.d.ts +8 -1
  416. package/lib/utils/string-utils.js +13 -26
  417. package/lib/utils/string-utils.js.map +1 -1
  418. package/lib/utils/utils.d.ts +1 -3
  419. package/lib/utils/utils.js +12 -40
  420. package/lib/utils/utils.js.map +1 -1
  421. package/oclif.manifest.json +69 -357
  422. package/package.json +47 -25
  423. package/portal-pages/context-plugin.mdx +26 -0
  424. package/portal-pages/sdk.mdx +8 -0
  425. package/portal-pages/sdks.mdx +11 -0
  426. package/portal-template/NOTICE +37 -0
  427. package/portal-template/downloads.ts +41 -0
  428. package/portal-template/generated-pages-reload.ts +51 -0
  429. package/portal-template/package.json +11 -0
  430. package/portal-template/portal-config.ts +32 -0
  431. package/portal-template/prerender-pages.ts +81 -0
  432. package/portal-template/spec-reload.ts +26 -0
  433. package/portal-template/src/components/api-page.tsx +15 -0
  434. package/portal-template/src/components/code-block.tsx +9 -0
  435. package/portal-template/src/components/command-block.tsx +50 -0
  436. package/portal-template/src/components/example-layout.tsx +99 -0
  437. package/portal-template/src/components/logos.tsx +127 -0
  438. package/portal-template/src/components/mdx.tsx +28 -0
  439. package/portal-template/src/components/not-found.tsx +11 -0
  440. package/portal-template/src/components/plugin-install.tsx +22 -0
  441. package/portal-template/src/components/plugin-support.tsx +53 -0
  442. package/portal-template/src/components/sdk-actions.tsx +79 -0
  443. package/portal-template/src/components/sdk-cards.tsx +100 -0
  444. package/portal-template/src/components/search.tsx +41 -0
  445. package/portal-template/src/components/usage-tabs.tsx +92 -0
  446. package/portal-template/src/lib/code-samples.server.ts +40 -0
  447. package/portal-template/src/lib/code-samples.ts +43 -0
  448. package/portal-template/src/lib/code-titles.ts +29 -0
  449. package/portal-template/src/lib/install-command.ts +13 -0
  450. package/portal-template/src/lib/json.ts +5 -0
  451. package/portal-template/src/lib/layout.shared.tsx +41 -0
  452. package/portal-template/src/lib/layout.tsx +16 -0
  453. package/portal-template/src/lib/llms.server.ts +54 -0
  454. package/portal-template/src/lib/media-adapters.ts +34 -0
  455. package/portal-template/src/lib/navigation.ts +406 -0
  456. package/portal-template/src/lib/openapi-bundle.server.ts +343 -0
  457. package/portal-template/src/lib/openapi-filter.ts +191 -0
  458. package/portal-template/src/lib/openapi-labels.ts +15 -0
  459. package/portal-template/src/lib/openapi-methods.ts +12 -0
  460. package/portal-template/src/lib/openapi-section.server.ts +280 -0
  461. package/portal-template/src/lib/openapi-slim.ts +202 -0
  462. package/portal-template/src/lib/openapi.server.ts +16 -0
  463. package/portal-template/src/lib/portal-types.ts +36 -0
  464. package/portal-template/src/lib/portal.server.ts +13 -0
  465. package/portal-template/src/lib/portal.ts +11 -0
  466. package/portal-template/src/lib/rehype-code-titles.ts +53 -0
  467. package/portal-template/src/lib/request-examples.ts +72 -0
  468. package/portal-template/src/lib/seo.ts +21 -0
  469. package/portal-template/src/lib/shared.ts +51 -0
  470. package/portal-template/src/lib/shiki-bundle.ts +104 -0
  471. package/portal-template/src/lib/sitemap.server.ts +20 -0
  472. package/portal-template/src/lib/source.server.ts +27 -0
  473. package/portal-template/src/lib/source.ts +49 -0
  474. package/portal-template/src/lib/tabs.ts +37 -0
  475. package/portal-template/src/router.tsx +12 -0
  476. package/portal-template/src/routes/$.tsx +194 -0
  477. package/portal-template/src/routes/__root.tsx +56 -0
  478. package/portal-template/src/routes/api/search[.]json.ts +9 -0
  479. package/portal-template/src/routes/llms-full[.]txt.ts +10 -0
  480. package/portal-template/src/routes/llms[.]txt.ts +10 -0
  481. package/portal-template/src/routes/robots[.]txt.ts +10 -0
  482. package/portal-template/src/routes/sitemap[.]xml.ts +10 -0
  483. package/portal-template/src/routes/spa-shell.tsx +7 -0
  484. package/portal-template/src/routes/{$}[.]md.ts +21 -0
  485. package/portal-template/src/styles/app.css +33 -0
  486. package/portal-template/tsconfig.json +26 -0
  487. package/portal-template/vite.config.ts +68 -0
  488. package/lib/actions/plugin/record-sdk.d.ts +0 -14
  489. package/lib/actions/plugin/record-sdk.js +0 -60
  490. package/lib/actions/plugin/record-sdk.js.map +0 -1
  491. package/lib/actions/portal/copilot.d.ts +0 -17
  492. package/lib/actions/portal/copilot.js +0 -89
  493. package/lib/actions/portal/copilot.js.map +0 -1
  494. package/lib/actions/portal/quickstart.d.ts +0 -18
  495. package/lib/actions/portal/quickstart.js +0 -238
  496. package/lib/actions/portal/quickstart.js.map +0 -1
  497. package/lib/actions/portal/recipe/new-recipe.d.ts +0 -15
  498. package/lib/actions/portal/recipe/new-recipe.js +0 -177
  499. package/lib/actions/portal/recipe/new-recipe.js.map +0 -1
  500. package/lib/actions/portal/toc/new-toc.d.ts +0 -21
  501. package/lib/actions/portal/toc/new-toc.js +0 -95
  502. package/lib/actions/portal/toc/new-toc.js.map +0 -1
  503. package/lib/actions/sdk/merge-source-tree.d.ts +0 -12
  504. package/lib/actions/sdk/merge-source-tree.js +0 -78
  505. package/lib/actions/sdk/merge-source-tree.js.map +0 -1
  506. package/lib/actions/sdk/quickstart.d.ts +0 -18
  507. package/lib/actions/sdk/quickstart.js +0 -188
  508. package/lib/actions/sdk/quickstart.js.map +0 -1
  509. package/lib/actions/sdk/save-changes.d.ts +0 -8
  510. package/lib/actions/sdk/save-changes.js +0 -93
  511. package/lib/actions/sdk/save-changes.js.map +0 -1
  512. package/lib/application/portal/recipe/portal-recipe.d.ts +0 -8
  513. package/lib/application/portal/recipe/portal-recipe.js +0 -33
  514. package/lib/application/portal/recipe/portal-recipe.js.map +0 -1
  515. package/lib/application/portal/recipe/recipe-generator.d.ts +0 -21
  516. package/lib/application/portal/recipe/recipe-generator.js +0 -130
  517. package/lib/application/portal/recipe/recipe-generator.js.map +0 -1
  518. package/lib/application/portal/toc/toc-content-parser.d.ts +0 -5
  519. package/lib/application/portal/toc/toc-content-parser.js +0 -44
  520. package/lib/application/portal/toc/toc-content-parser.js.map +0 -1
  521. package/lib/application/portal/toc/toc-structure-generator.d.ts +0 -11
  522. package/lib/application/portal/toc/toc-structure-generator.js +0 -165
  523. package/lib/application/portal/toc/toc-structure-generator.js.map +0 -1
  524. package/lib/commands/portal/copilot.d.ts +0 -13
  525. package/lib/commands/portal/copilot.js +0 -34
  526. package/lib/commands/portal/copilot.js.map +0 -1
  527. package/lib/commands/portal/recipe/new.d.ts +0 -12
  528. package/lib/commands/portal/recipe/new.js +0 -45
  529. package/lib/commands/portal/recipe/new.js.map +0 -1
  530. package/lib/commands/portal/toc/new.d.ts +0 -16
  531. package/lib/commands/portal/toc/new.js +0 -68
  532. package/lib/commands/portal/toc/new.js.map +0 -1
  533. package/lib/commands/sdk/save-changes.d.ts +0 -14
  534. package/lib/commands/sdk/save-changes.js +0 -51
  535. package/lib/commands/sdk/save-changes.js.map +0 -1
  536. package/lib/infrastructure/debounce-service.d.ts +0 -10
  537. package/lib/infrastructure/debounce-service.js +0 -55
  538. package/lib/infrastructure/debounce-service.js.map +0 -1
  539. package/lib/infrastructure/services/portal-service.d.ts +0 -43
  540. package/lib/infrastructure/services/portal-service.js +0 -337
  541. package/lib/infrastructure/services/portal-service.js.map +0 -1
  542. package/lib/prompts/plugin/record-sdk.d.ts +0 -9
  543. package/lib/prompts/plugin/record-sdk.js +0 -40
  544. package/lib/prompts/plugin/record-sdk.js.map +0 -1
  545. package/lib/prompts/portal/copilot.d.ts +0 -18
  546. package/lib/prompts/portal/copilot.js +0 -82
  547. package/lib/prompts/portal/copilot.js.map +0 -1
  548. package/lib/prompts/portal/quickstart.d.ts +0 -42
  549. package/lib/prompts/portal/quickstart.js +0 -243
  550. package/lib/prompts/portal/quickstart.js.map +0 -1
  551. package/lib/prompts/portal/recipe/new-recipe.d.ts +0 -29
  552. package/lib/prompts/portal/recipe/new-recipe.js +0 -165
  553. package/lib/prompts/portal/recipe/new-recipe.js.map +0 -1
  554. package/lib/prompts/portal/toc/new-toc.d.ts +0 -16
  555. package/lib/prompts/portal/toc/new-toc.js +0 -50
  556. package/lib/prompts/portal/toc/new-toc.js.map +0 -1
  557. package/lib/prompts/sdk/merge-source-tree.d.ts +0 -22
  558. package/lib/prompts/sdk/merge-source-tree.js +0 -90
  559. package/lib/prompts/sdk/merge-source-tree.js.map +0 -1
  560. package/lib/prompts/sdk/quickstart.d.ts +0 -38
  561. package/lib/prompts/sdk/quickstart.js +0 -196
  562. package/lib/prompts/sdk/quickstart.js.map +0 -1
  563. package/lib/prompts/sdk/save-changes.d.ts +0 -21
  564. package/lib/prompts/sdk/save-changes.js +0 -84
  565. package/lib/prompts/sdk/save-changes.js.map +0 -1
  566. package/lib/types/build-context.d.ts +0 -26
  567. package/lib/types/build-context.js +0 -111
  568. package/lib/types/build-context.js.map +0 -1
  569. package/lib/types/events/recipe-creation-failed.d.ts +0 -5
  570. package/lib/types/events/recipe-creation-failed.js +0 -8
  571. package/lib/types/events/recipe-creation-failed.js.map +0 -1
  572. package/lib/types/events/sdk-changes-saved.d.ts +0 -8
  573. package/lib/types/events/sdk-changes-saved.js +0 -11
  574. package/lib/types/events/sdk-changes-saved.js.map +0 -1
  575. package/lib/types/events/sdk-changes-tracked.d.ts +0 -8
  576. package/lib/types/events/sdk-changes-tracked.js +0 -11
  577. package/lib/types/events/sdk-changes-tracked.js.map +0 -1
  578. package/lib/types/events/sdk-conflicts-resolved.d.ts +0 -8
  579. package/lib/types/events/sdk-conflicts-resolved.js +0 -11
  580. package/lib/types/events/sdk-conflicts-resolved.js.map +0 -1
  581. package/lib/types/events/toc-creation-failed.d.ts +0 -5
  582. package/lib/types/events/toc-creation-failed.js +0 -8
  583. package/lib/types/events/toc-creation-failed.js.map +0 -1
  584. package/lib/types/merge-source-tree-context.d.ts +0 -28
  585. package/lib/types/merge-source-tree-context.js +0 -63
  586. package/lib/types/merge-source-tree-context.js.map +0 -1
  587. package/lib/types/plugin/language-entry.d.ts +0 -9
  588. package/lib/types/plugin/language-entry.js +0 -64
  589. package/lib/types/plugin/language-entry.js.map +0 -1
  590. package/lib/types/recipe/recipe.d.ts +0 -22
  591. package/lib/types/recipe/recipe.js +0 -6
  592. package/lib/types/recipe/recipe.js.map +0 -1
  593. package/lib/types/recipe-context.d.ts +0 -9
  594. package/lib/types/recipe-context.js +0 -26
  595. package/lib/types/recipe-context.js.map +0 -1
  596. package/lib/types/save-changes-context.d.ts +0 -17
  597. package/lib/types/save-changes-context.js +0 -42
  598. package/lib/types/save-changes-context.js.map +0 -1
  599. package/lib/types/sdl/sdl.d.ts +0 -10
  600. package/lib/types/sdl/sdl.js +0 -18
  601. package/lib/types/sdl/sdl.js.map +0 -1
  602. package/lib/types/toc/toc-components.d.ts +0 -36
  603. package/lib/types/toc/toc-components.js +0 -94
  604. package/lib/types/toc/toc-components.js.map +0 -1
  605. package/lib/types/toc/toc.d.ts +0 -67
  606. package/lib/types/toc/toc.js +0 -2
  607. package/lib/types/toc/toc.js.map +0 -1
  608. package/lib/types/toc-context.d.ts +0 -12
  609. package/lib/types/toc-context.js +0 -26
  610. package/lib/types/toc-context.js.map +0 -1
@@ -0,0 +1,67 @@
1
+ import { languageLabel } from '../sdk/generate.js';
2
+ import { isJsonObject } from '../../utils/json-utils.js';
3
+ import { Endpoint } from './endpoint.js';
4
+ export class CodeSampleCatalog {
5
+ samplesByEndpoint;
6
+ constructor(samplesByEndpoint) {
7
+ this.samplesByEndpoint = samplesByEndpoint;
8
+ }
9
+ static fromJson(language, json) {
10
+ if (!isJsonObject(json) || !isJsonObject(json.paths)) {
11
+ return undefined;
12
+ }
13
+ const samplesByEndpoint = new Map();
14
+ for (const [path, methods] of Object.entries(json.paths)) {
15
+ if (!isJsonObject(methods)) {
16
+ return undefined;
17
+ }
18
+ for (const [method, sources] of Object.entries(methods)) {
19
+ if (!isSources(sources)) {
20
+ return undefined;
21
+ }
22
+ const endpoint = new Endpoint(method, path);
23
+ samplesByEndpoint.set(`${endpoint}`, { endpoint, sample: toCodeSample(language, sources) });
24
+ }
25
+ }
26
+ return new CodeSampleCatalog(samplesByEndpoint);
27
+ }
28
+ sampleFor(endpoint) {
29
+ return this.samplesByEndpoint.get(`${endpoint}`)?.sample;
30
+ }
31
+ endpoints() {
32
+ return [...this.samplesByEndpoint.values()].map(({ endpoint }) => endpoint);
33
+ }
34
+ }
35
+ export class CodeSampleCatalogs {
36
+ catalogs;
37
+ constructor(catalogs) {
38
+ this.catalogs = catalogs;
39
+ }
40
+ isEmpty() {
41
+ return this.catalogs.length === 0;
42
+ }
43
+ samplesFor(endpoint) {
44
+ return this.catalogs.flatMap((catalog) => catalog.sampleFor(endpoint) ?? []);
45
+ }
46
+ unplacedIn(documented) {
47
+ const names = new Set(documented.map(String));
48
+ return [...new Set(this.endpoints().map(String))].filter((endpoint) => !names.has(endpoint));
49
+ }
50
+ toJson() {
51
+ const json = {};
52
+ for (const endpoint of this.endpoints()) {
53
+ json[endpoint.path] = { ...json[endpoint.path], [endpoint.method]: this.samplesFor(endpoint) };
54
+ }
55
+ return json;
56
+ }
57
+ endpoints() {
58
+ return this.catalogs.flatMap((catalog) => catalog.endpoints());
59
+ }
60
+ }
61
+ function toCodeSample(language, sources) {
62
+ return { lang: language, label: languageLabel(language), sources };
63
+ }
64
+ function isSources(value) {
65
+ return isJsonObject(value) && Object.values(value).every((source) => typeof source === 'string');
66
+ }
67
+ //# sourceMappingURL=code-samples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-samples.js","sourceRoot":"","sources":["../../../src/types/portal/code-samples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAkBzC,MAAM,OAAO,iBAAiB;IACS,iBAAiB;IAAtD,YAAqC,iBAA4C;iCAA5C,iBAAiB;IAA8B,CAAC;IAE9E,MAAM,CAAC,QAAQ,CAAC,QAAkB,EAAE,IAAa;QACt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I,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC;AACnG,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { Parsed } from './fields.js';
2
+ export declare class AiConfig {
3
+ private readonly pageActions;
4
+ private constructor();
5
+ static readonly defaults: AiConfig;
6
+ static parse(value: unknown, path: string): Parsed<AiConfig>;
7
+ /**
8
+ * Whether each page offers to open itself in an external AI assistant. A portal published
9
+ * under someone else's brand carries that endorsement, so it can be turned off.
10
+ */
11
+ offersPageActions(): boolean;
12
+ toJSON(): {
13
+ pageActions: boolean;
14
+ };
15
+ }
@@ -0,0 +1,26 @@
1
+ import { Result } from 'neverthrow';
2
+ import { allOf, namespace, optionalBoolean, unknownKeys } from './fields.js';
3
+ const KNOWN = ['pageActions'];
4
+ export class AiConfig {
5
+ pageActions;
6
+ constructor(pageActions) {
7
+ this.pageActions = pageActions;
8
+ }
9
+ static defaults = new AiConfig(true);
10
+ static parse(value, path) {
11
+ return namespace(value, path).andThen((data) => allOf(unknownKeys(data, KNOWN, path), Result.combineWithAllErrors([
12
+ optionalBoolean(data.pageActions, `${path}.pageActions`, AiConfig.defaults.pageActions)
13
+ ])).map(([pageActions]) => new AiConfig(pageActions)));
14
+ }
15
+ /**
16
+ * Whether each page offers to open itself in an external AI assistant. A portal published
17
+ * under someone else's brand carries that endorsement, so it can be turned off.
18
+ */
19
+ offersPageActions() {
20
+ return this.pageActions;
21
+ }
22
+ toJSON() {
23
+ return { pageActions: this.pageActions };
24
+ }
25
+ }
26
+ //# sourceMappingURL=ai-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-config.js","sourceRoot":"","sources":["../../../../src/types/portal/config/ai-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAU,WAAW,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,KAAK,GAAG,CAAC,aAAa,CAAC,CAAC;AAE9B,MAAM,OAAO,QAAQ;IACkB,WAAW;IAAhD,YAAqC,WAAoB;2BAApB,WAAW;IAAY,CAAC;IAEtD,MAAM,CAAU,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE9C,MAAM,CAAC,KAAK,CAAC,KAAc,EAAE,IAAY;QAC9C,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7C,KAAK,CACH,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAC9B,MAAM,CAAC,oBAAoB,CAAC;YAC1B,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;SACxF,CAAC,CACH,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CACpD,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ import { Color } from './color.js';
2
+ import { Parsed } from './fields.js';
3
+ import { StaticAsset } from './static-asset.js';
4
+ export declare const COLOR_MODES: readonly ['light', 'dark', 'both'];
5
+ export type ColorMode = (typeof COLOR_MODES)[number];
6
+ export declare class Logo {
7
+ private readonly images;
8
+ private constructor();
9
+ static parse(value: unknown, path: string): Parsed<Logo>;
10
+ light(): StaticAsset;
11
+ dark(): StaticAsset;
12
+ files(): StaticAsset[];
13
+ toJSON(): string | {
14
+ light: string;
15
+ dark: string;
16
+ };
17
+ }
18
+ export declare class BrandColors {
19
+ private readonly primary;
20
+ private constructor();
21
+ static readonly defaults: BrandColors;
22
+ static parse(value: unknown, path: string): Parsed<BrandColors>;
23
+ /** The primary for each mode, or null when the theme's own applies. */
24
+ primaryColors(): {
25
+ light: Color;
26
+ dark: Color;
27
+ } | null;
28
+ toJSON(): {
29
+ primary?: string | {
30
+ light: string;
31
+ dark: string;
32
+ };
33
+ };
34
+ private static parseColor;
35
+ }
36
+ export declare class BrandConfig {
37
+ private readonly logo;
38
+ private readonly favicon;
39
+ private readonly colors;
40
+ private readonly colorMode;
41
+ private constructor();
42
+ static readonly defaults: BrandConfig;
43
+ static parse(value: unknown, path: string): Parsed<BrandConfig>;
44
+ logoImages(): Logo | null;
45
+ faviconImage(): StaticAsset | null;
46
+ brandColors(): BrandColors;
47
+ mode(): ColorMode;
48
+ files(): StaticAsset[];
49
+ toJSON(): {
50
+ logo?: ReturnType<Logo['toJSON']>;
51
+ favicon?: string;
52
+ colors: ReturnType<BrandColors['toJSON']>;
53
+ colorMode: ColorMode;
54
+ };
55
+ }
@@ -0,0 +1,105 @@
1
+ import { err, ok, Result } from 'neverthrow';
2
+ import { Color } from './color.js';
3
+ import { allOf, lightDark, namespace, oneOf, optional, unknownKeys } from './fields.js';
4
+ import { StaticAsset } from './static-asset.js';
5
+ export const COLOR_MODES = ['light', 'dark', 'both'];
6
+ const KNOWN = ['logo', 'favicon', 'colors', 'colorMode'];
7
+ const KNOWN_COLORS = ['primary'];
8
+ export class Logo {
9
+ images;
10
+ constructor(images) {
11
+ this.images = images;
12
+ }
13
+ static parse(value, path) {
14
+ return lightDark(value, path, StaticAsset.parse).map((images) => new Logo(images));
15
+ }
16
+ light() {
17
+ return this.images.light;
18
+ }
19
+ dark() {
20
+ return this.images.dark;
21
+ }
22
+ files() {
23
+ return this.images.light.isEqual(this.images.dark) ? [this.images.light] : [this.images.light, this.images.dark];
24
+ }
25
+ toJSON() {
26
+ const { light, dark, single } = this.images;
27
+ return single ? light.toJSON() : { light: light.toJSON(), dark: dark.toJSON() };
28
+ }
29
+ }
30
+ export class BrandColors {
31
+ primary;
32
+ constructor(primary) {
33
+ this.primary = primary;
34
+ }
35
+ static defaults = new BrandColors(null);
36
+ static parse(value, path) {
37
+ return namespace(value, path).andThen((data) => allOf(unknownKeys(data, KNOWN_COLORS, path), Result.combineWithAllErrors([
38
+ optional(data.primary, (primary) => lightDark(primary, `${path}.primary`, BrandColors.parseColor))
39
+ ])).map(([primary]) => new BrandColors(primary)));
40
+ }
41
+ /** The primary for each mode, or null when the theme's own applies. */
42
+ primaryColors() {
43
+ return this.primary === null ? null : { light: this.primary.light, dark: this.primary.dark };
44
+ }
45
+ toJSON() {
46
+ if (this.primary === null) {
47
+ return {};
48
+ }
49
+ const { light, dark, single } = this.primary;
50
+ return { primary: single ? light.toString() : { light: light.toString(), dark: dark.toString() } };
51
+ }
52
+ static parseColor(value, path) {
53
+ const color = typeof value === 'string' ? Color.create(value) : undefined;
54
+ return color === undefined
55
+ ? err([`'${path}' must be a colour written as ${Color.formats}, for example '#1d4ed8'.`])
56
+ : ok(color);
57
+ }
58
+ }
59
+ export class BrandConfig {
60
+ logo;
61
+ favicon;
62
+ colors;
63
+ colorMode;
64
+ constructor(logo, favicon, colors, colorMode) {
65
+ this.logo = logo;
66
+ this.favicon = favicon;
67
+ this.colors = colors;
68
+ this.colorMode = colorMode;
69
+ }
70
+ static defaults = new BrandConfig(null, null, BrandColors.defaults, 'both');
71
+ static parse(value, path) {
72
+ return namespace(value, path).andThen((data) => allOf(unknownKeys(data, KNOWN, path), Result.combineWithAllErrors([
73
+ optional(data.logo, (logo) => Logo.parse(logo, `${path}.logo`)),
74
+ optional(data.favicon, (favicon) => StaticAsset.parse(favicon, `${path}.favicon`)),
75
+ BrandColors.parse(data.colors, `${path}.colors`),
76
+ oneOf(data.colorMode, `${path}.colorMode`, COLOR_MODES, BrandConfig.defaults.colorMode)
77
+ ])).map(([logo, favicon, colors, colorMode]) => new BrandConfig(logo, favicon, colors, colorMode)));
78
+ }
79
+ logoImages() {
80
+ return this.logo;
81
+ }
82
+ faviconImage() {
83
+ return this.favicon ?? this.logo?.light() ?? null;
84
+ }
85
+ brandColors() {
86
+ return this.colors;
87
+ }
88
+ mode() {
89
+ return this.colorMode;
90
+ }
91
+ files() {
92
+ const logos = this.logo?.files() ?? [];
93
+ const favicon = this.favicon;
94
+ return favicon === null || logos.some((logo) => logo.isEqual(favicon)) ? logos : [...logos, favicon];
95
+ }
96
+ toJSON() {
97
+ return {
98
+ ...(this.logo === null ? {} : { logo: this.logo.toJSON() }),
99
+ ...(this.favicon === null ? {} : { favicon: this.favicon.toJSON() }),
100
+ colors: this.colors.toJSON(),
101
+ colorMode: this.colorMode
102
+ };
103
+ }
104
+ }
105
+ //# sourceMappingURL=brand-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brand-config.js","sourceRoot":"","sources":["../../../../src/types/portal/config/brand-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAU,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAI9D,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAEzD,M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,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACpE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Hex only, which is how brand guidelines give a colour: the foreground laid over the primary is
3
+ * chosen by contrast, which needs the colour's channels.
4
+ */
5
+ export declare class Color {
6
+ private readonly written;
7
+ private readonly rgb;
8
+ private constructor();
9
+ static readonly formats = "#rgb or #rrggbb";
10
+ /** The two foregrounds the neutral preset pairs with its own primaries. */
11
+ private static readonly light;
12
+ private static readonly dark;
13
+ static create(value: string): Color | undefined;
14
+ /** WCAG 2 relative luminance. */
15
+ luminance(): number;
16
+ contrastWith(other: Color): number;
17
+ foreground(): Color;
18
+ toString(): string;
19
+ }
@@ -0,0 +1,43 @@
1
+ const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
2
+ /**
3
+ * Hex only, which is how brand guidelines give a colour: the foreground laid over the primary is
4
+ * chosen by contrast, which needs the colour's channels.
5
+ */
6
+ export class Color {
7
+ written;
8
+ rgb;
9
+ constructor(written, rgb) {
10
+ this.written = written;
11
+ this.rgb = rgb;
12
+ }
13
+ static formats = '#rgb or #rrggbb';
14
+ /** The two foregrounds the neutral preset pairs with its own primaries. */
15
+ static light = new Color('hsl(0, 0%, 98%)', { red: 0.98, green: 0.98, blue: 0.98 });
16
+ static dark = new Color('hsl(0, 0%, 9%)', { red: 0.09, green: 0.09, blue: 0.09 });
17
+ static create(value) {
18
+ const text = value.trim();
19
+ if (!HEX.test(text)) {
20
+ return undefined;
21
+ }
22
+ const digits = text.slice(1);
23
+ const pairs = digits.length === 3 ? [...digits].map((digit) => digit + digit) : digits.match(/../g) ?? [];
24
+ const [red, green, blue] = pairs.map((pair) => Number.parseInt(pair, 16) / 255);
25
+ return new Color(text, { red, green, blue });
26
+ }
27
+ /** WCAG 2 relative luminance. */
28
+ luminance() {
29
+ const linear = (channel) => channel <= 0.04045 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
30
+ return 0.2126 * linear(this.rgb.red) + 0.7152 * linear(this.rgb.green) + 0.0722 * linear(this.rgb.blue);
31
+ }
32
+ contrastWith(other) {
33
+ const [lighter, darker] = [this.luminance(), other.luminance()].sort((a, b) => b - a);
34
+ return (lighter + 0.05) / (darker + 0.05);
35
+ }
36
+ foreground() {
37
+ return this.contrastWith(Color.light) >= this.contrastWith(Color.dark) ? Color.light : Color.dark;
38
+ }
39
+ toString() {
40
+ return this.written;
41
+ }
42
+ }
43
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../../src/types/portal/config/color.ts"],"names":[],"mappings":"AAOA,MAAM,GAAG,GAAG,iCAAiC,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,KAAK;IACqB,OAAO;IAA2B,GAAG;IAA1E,YAAqC,OAAe,EAAmB,GAAQ;uBAA1C,OAAO;mBAA2B,GAAG;IAAQ,CAAC;IAE5E,MAAM,CAAU,OAAO,GAAG,iBAAiB,CAAC;IAEnD,2EAA2E;IACnE,MAAM,CAAU,KAAK,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F,MAAM,CAAU,IAAI,GAAG,IAAI,KAAK,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5F,MAAM,CAAC,MAAM,CAAC,KAAa;QAChC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;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S,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtF,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IACpG,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import { Result } from 'neverthrow';
2
+ export type Parsed<T> = Result<T, string[]>;
3
+ export declare function isWebAddress(text: string): boolean;
4
+ export declare function namespace(value: unknown, path: string): Parsed<Record<string, unknown>>;
5
+ export declare function unknownKeys(data: Record<string, unknown>, known: readonly string[], path: string): string[];
6
+ /**
7
+ * Every error at once, unknown keys first, so one edit fixes the file. `fields` is what
8
+ * `Result.combineWithAllErrors` makes of the field parsers.
9
+ */
10
+ export declare function allOf<T>(unknown: string[], fields: Result<T, string[][]>): Parsed<T>;
11
+ export interface LightDark<T> {
12
+ light: T;
13
+ dark: T;
14
+ /** Written once for both modes, which is how it serialises back. */
15
+ single: boolean;
16
+ }
17
+ export declare function lightDark<T>(value: unknown, path: string, parse: (present: unknown, path: string) => Parsed<T>): Parsed<LightDark<T>>;
18
+ export declare function optional<T>(value: unknown, parse: (present: unknown) => Parsed<T>): Parsed<T | null>;
19
+ export declare function optionalBoolean(value: unknown, path: string, fallback: boolean): Parsed<boolean>;
20
+ export declare function oneOf<T extends string>(value: unknown, path: string, allowed: readonly T[], fallback: T): Parsed<T>;
21
+ /** Each value in quotes, listed as a sentence lists them. */
22
+ export declare function quotedList(values: readonly string[], joiner?: 'and' | 'or'): string;
23
+ export declare function nonEmptyString(value: unknown, path: string): Parsed<string>;
@@ -0,0 +1,67 @@
1
+ import { err, ok, Result } from 'neverthrow';
2
+ import { isJsonObject } from '../../../utils/json-utils.js';
3
+ import { listedInProse } from '../../../utils/string-utils.js';
4
+ import { UrlPath } from '../../file/urlPath.js';
5
+ import { unknownFieldErrors } from '../unknown-fields.js';
6
+ // The URL parser also takes `https:example.com`, which a browser on an https site reads as a
7
+ // path of that site.
8
+ export function isWebAddress(text) {
9
+ return /^https?:\/\//i.test(text) && UrlPath.create(text) !== undefined;
10
+ }
11
+ export function namespace(value, path) {
12
+ if (value === undefined) {
13
+ return ok({});
14
+ }
15
+ return isJsonObject(value) ? ok(value) : err([`'${path}' must be a JSON object.`]);
16
+ }
17
+ export function unknownKeys(data, known, path) {
18
+ return unknownFieldErrors(data, new Set(known), (key) => `'${path}.${key}' is not a 'portal' setting.`);
19
+ }
20
+ /**
21
+ * Every error at once, unknown keys first, so one edit fixes the file. `fields` is what
22
+ * `Result.combineWithAllErrors` makes of the field parsers.
23
+ */
24
+ export function allOf(unknown, fields) {
25
+ if (fields.isErr()) {
26
+ return err([...unknown, ...fields.error.flat()]);
27
+ }
28
+ return unknown.length > 0 ? err(unknown) : ok(fields.value);
29
+ }
30
+ export function lightDark(value, path, parse) {
31
+ if (typeof value === 'string') {
32
+ return parse(value, path).map((both) => ({ light: both, dark: both, single: true }));
33
+ }
34
+ if (!isJsonObject(value)) {
35
+ return err([`'${path}' must be a string, or an object with 'light' and 'dark'.`]);
36
+ }
37
+ const mode = (name) => value[name] === undefined ? err([`'${path}.${name}' is required.`]) : parse(value[name], `${path}.${name}`);
38
+ return allOf(unknownKeys(value, ['light', 'dark'], path), Result.combineWithAllErrors([mode('light'), mode('dark')])).map(([light, dark]) => ({ light, dark, single: false }));
39
+ }
40
+ export function optional(value, parse) {
41
+ return value === undefined ? ok(null) : parse(value);
42
+ }
43
+ export function optionalBoolean(value, path, fallback) {
44
+ if (value === undefined) {
45
+ return ok(fallback);
46
+ }
47
+ return typeof value === 'boolean' ? ok(value) : err([`'${path}' must be true or false.`]);
48
+ }
49
+ export function oneOf(value, path, allowed, fallback) {
50
+ if (value === undefined) {
51
+ return ok(fallback);
52
+ }
53
+ if (typeof value === 'string' && allowed.includes(value)) {
54
+ return ok(value);
55
+ }
56
+ return err([`'${path}' must be one of ${quotedList(allowed, 'or')}.`]);
57
+ }
58
+ /** Each value in quotes, listed as a sentence lists them. */
59
+ export function quotedList(values, joiner = 'and') {
60
+ return listedInProse(values.map((value) => `'${value}'`), joiner);
61
+ }
62
+ export function nonEmptyString(value, path) {
63
+ return typeof value === 'string' && value.trim().length > 0
64
+ ? ok(value.trim())
65
+ : err([`'${path}' must be a non-empty string.`]);
66
+ }
67
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/types/portal/config/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,6FAA6F;AAC7F,qBAAqB;AACrB,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,IAAY;IACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;IACD,OAAO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KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChF,OAAO,EAAE,CAAC,KAAU,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,oBAAoB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,UAAU,CAAC,MAAyB,EAAE,MAAM,GAAiB,KAAK;IAChF,OAAO,aAAa,CAClB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,EACnC,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,IAAY;IACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACzD,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,+BAA+B,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Parsed } from './fields.js';
2
+ /** A labelled link in the portal's header. */
3
+ export declare class Link {
4
+ private readonly label;
5
+ private readonly url;
6
+ private readonly external;
7
+ private constructor();
8
+ static parse(value: unknown, path: string): Parsed<Link>;
9
+ text(): string;
10
+ href(): string;
11
+ isExternal(): boolean;
12
+ toJSON(): {
13
+ label: string;
14
+ url: string;
15
+ };
16
+ private static validUrl;
17
+ private static pageOfThePortal;
18
+ }
@@ -0,0 +1,72 @@
1
+ import { err, ok, Result } from 'neverthrow';
2
+ import { isJsonObject } from '../../../utils/json-utils.js';
3
+ import { allOf, isWebAddress, nonEmptyString, unknownKeys } from './fields.js';
4
+ const KNOWN = ['label', 'url'];
5
+ /** Stands in for the portal's own address, which is not known here; `.invalid` never resolves (RFC 6761). */
6
+ const PORTAL_ORIGIN = 'https://portal.invalid';
7
+ /** A labelled link in the portal's header. */
8
+ export class Link {
9
+ label;
10
+ url;
11
+ external;
12
+ constructor(label, url, external) {
13
+ this.label = label;
14
+ this.url = url;
15
+ this.external = external;
16
+ }
17
+ static parse(value, path) {
18
+ if (!isJsonObject(value)) {
19
+ return err([`'${path}' must be a JSON object with 'label' and 'url'.`]);
20
+ }
21
+ return allOf(unknownKeys(value, KNOWN, path), Result.combineWithAllErrors([
22
+ nonEmptyString(value.label, `${path}.label`),
23
+ Link.validUrl(value.url, `${path}.url`)
24
+ ])).map(([label, url]) => new Link(label, url.url, url.external));
25
+ }
26
+ text() {
27
+ return this.label;
28
+ }
29
+ href() {
30
+ return this.url;
31
+ }
32
+ isExternal() {
33
+ return this.external;
34
+ }
35
+ toJSON() {
36
+ return { label: this.label, url: this.url };
37
+ }
38
+ // A page of the portal by its path, or another site by its full address. Anything else
39
+ // renders as a link that goes nowhere useful: `docs/x` resolves against whichever page it
40
+ // sits on, and a `mailto:` or `javascript:` address is not somewhere a header link belongs.
41
+ static validUrl(url, path) {
42
+ const text = typeof url === 'string' ? url.trim() : '';
43
+ const page = text.startsWith('/') ? Link.pageOfThePortal(text) : undefined;
44
+ if (page !== undefined) {
45
+ return ok({ url: page, external: false });
46
+ }
47
+ if (isWebAddress(text)) {
48
+ return ok({ url: text, external: true });
49
+ }
50
+ return err([
51
+ `'${path}' must be a page of the portal starting with '/', or an address starting with 'https://' or 'http://'.`
52
+ ]);
53
+ }
54
+ static pageOfThePortal(text) {
55
+ // An empty segment as a browser reads it leads to another site: `//host`, `/\host`, and `/.//host` once resolved.
56
+ const path = text
57
+ .replace(/[\t\n\r]/g, '')
58
+ .replaceAll('\\', '/')
59
+ .split(/[?#]/)[0];
60
+ if (path.includes('//')) {
61
+ return undefined;
62
+ }
63
+ try {
64
+ const resolved = new URL(text, PORTAL_ORIGIN);
65
+ return resolved.origin === PORTAL_ORIGIN ? `${resolved.pathname}${resolved.search}${resolved.hash}` : undefined;
66
+ }
67
+ catch {
68
+ return undefined;
69
+ }
70
+ }
71
+ }
72
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../../src/types/portal/config/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAU,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvF,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAE/B,6GAA6G;AAC7G,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C,8CAA8C;AAC9C,MAAM,OAAO,IAAI;IAEI,KAAK;IACL,GAAG;IACH,QAAQ;IAH3B,YACmB,KAAa,EACb,GAAW,EACX,QAAiB;qBAFjB,KAAK;mBACL,GAAG;wBACH,QAAQ;IACxB,CAAC;IAEG,MAAM,CAAC,KAAK,CAAC,KAAc,EAAE,IAAY;QAC9C,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,iDAAiD,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,KAAK,CACV,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAC/B,MAAM,CAAC,oBAAoB,CAAC;YAC1B,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,QAAQ,CAAC;YAC5C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,MAAM,CA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EO,MAAM,CAAC,eAAe,CAAC,IAAY;QACzC,kHAAkH;QAClH,MAAM,IAAI,GAAG,IAAI;aACd,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;aACxB,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;aACrB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YAC9C,OAAO,QAAQ,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAClH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { Parsed } from './fields.js';
2
+ import { Link } from './link.js';
3
+ export declare class NavigationConfig {
4
+ private readonly links;
5
+ private constructor();
6
+ static readonly defaults: NavigationConfig;
7
+ static parse(value: unknown, path: string): Parsed<NavigationConfig>;
8
+ headerLinks(): Link[];
9
+ toJSON(): {
10
+ links: ReturnType<Link['toJSON']>[];
11
+ };
12
+ private static parseLinks;
13
+ }
@@ -0,0 +1,30 @@
1
+ import { err, ok, Result } from 'neverthrow';
2
+ import { allOf, namespace, unknownKeys } from './fields.js';
3
+ import { Link } from './link.js';
4
+ const KNOWN = ['links'];
5
+ export class NavigationConfig {
6
+ links;
7
+ constructor(links) {
8
+ this.links = links;
9
+ }
10
+ static defaults = new NavigationConfig([]);
11
+ static parse(value, path) {
12
+ return namespace(value, path).andThen((data) => allOf(unknownKeys(data, KNOWN, path), Result.combineWithAllErrors([NavigationConfig.parseLinks(data.links, `${path}.links`)])).map(([links]) => new NavigationConfig(links)));
13
+ }
14
+ headerLinks() {
15
+ return [...this.links];
16
+ }
17
+ toJSON() {
18
+ return { links: this.links.map((link) => link.toJSON()) };
19
+ }
20
+ static parseLinks(value, path) {
21
+ if (value === undefined) {
22
+ return ok([]);
23
+ }
24
+ if (!Array.isArray(value)) {
25
+ return err([`'${path}' must be a list of links.`]);
26
+ }
27
+ return Result.combineWithAllErrors(value.map((link, index) => Link.parse(link, `${path}[${index}]`))).mapErr((errors) => errors.flat());
28
+ }
29
+ }
30
+ //# sourceMappingURL=navigation-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-config.js","sourceRoot":"","sources":["../../../../src/types/portal/config/navigation-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAU,WAAW,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC;AAExB,MAAM,OAAO,gBAAgB;IACU,KAAK;IAA1C,YAAqC,KAAa;qBAAb,KAAK;IAAW,CAAC;IAE/C,MAAM,CAAU,QAAQ,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAEpD,MAAM,CAAC,KAAK,CAAC,KAAc,EAAE,IAAY;QAC9C,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7C,KAAK,CACH,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAC9B,MAAM,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CACxF,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAChD,CAAC;IACJ,CAAC;IAEM,WAAW;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAEM,MAAM;QACX,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;IAC5D,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,KAAc,EAAE,IAAY;QACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,4BAA4B,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAC1G,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAC1B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ import { UrlPath } from '../../file/urlPath.js';
2
+ import { Parsed } from './fields.js';
3
+ /** What a specification says about itself, which is what a portal is called until the block says otherwise. */
4
+ export interface SuggestedSite {
5
+ name: string;
6
+ description: string | null;
7
+ }
8
+ export declare const PLACEHOLDER_SITE: Readonly<SuggestedSite>;
9
+ export declare class SiteConfig {
10
+ private readonly name;
11
+ private readonly url;
12
+ private readonly description;
13
+ private constructor();
14
+ /**
15
+ * `suggested` fills what the block leaves out. It is the only specification's own, or null
16
+ * when there are several, since no one of them speaks for the portal.
17
+ */
18
+ static parse(value: unknown, path: string, suggested: SuggestedSite | null): Parsed<SiteConfig>;
19
+ static suggested(site: SuggestedSite): SiteConfig;
20
+ siteName(): string;
21
+ siteDescription(): string | null;
22
+ origin(): UrlPath | null;
23
+ toJSON(): {
24
+ name: string;
25
+ url?: string;
26
+ description?: string;
27
+ };
28
+ private static validName;
29
+ private static validDescription;
30
+ private static validUrl;
31
+ private static parseOrigin;
32
+ }