@apimatic/cli 1.5.0 → 2.0.0-beta.2
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.
- package/LICENSE +21 -0
- package/README.md +128 -212
- package/apimatic.schema.json +550 -0
- package/lib/actions/action-result.js +3 -0
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/transform.js +36 -33
- package/lib/actions/api/transform.js.map +1 -1
- package/lib/actions/api/validate.d.ts +9 -6
- package/lib/actions/api/validate.js +44 -38
- package/lib/actions/api/validate.js.map +1 -1
- package/lib/actions/auth/login.js +7 -4
- package/lib/actions/auth/login.js.map +1 -1
- package/lib/actions/auth/logout.js +2 -1
- package/lib/actions/auth/logout.js.map +1 -1
- package/lib/actions/auth/status.js +5 -3
- package/lib/actions/auth/status.js.map +1 -1
- package/lib/actions/plugin/generate.d.ts +5 -1
- package/lib/actions/plugin/generate.js +83 -56
- package/lib/actions/plugin/generate.js.map +1 -1
- package/lib/actions/plugin/publish.d.ts +2 -1
- package/lib/actions/plugin/publish.js +34 -37
- package/lib/actions/plugin/publish.js.map +1 -1
- package/lib/actions/plugin/record-metadata.d.ts +3 -2
- package/lib/actions/plugin/record-metadata.js +33 -30
- package/lib/actions/plugin/record-metadata.js.map +1 -1
- package/lib/actions/portal/generate.d.ts +8 -6
- package/lib/actions/portal/generate.js +50 -61
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/prepare-project.d.ts +25 -0
- package/lib/actions/portal/prepare-project.js +68 -0
- package/lib/actions/portal/prepare-project.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +21 -6
- package/lib/actions/portal/serve.js +170 -153
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/publishing/profile/list.js +4 -2
- package/lib/actions/publishing/profile/list.js.map +1 -1
- package/lib/actions/quickstart.d.ts +23 -5
- package/lib/actions/quickstart.js +221 -21
- package/lib/actions/quickstart.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +4 -7
- package/lib/actions/sdk/generate.js +53 -93
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/actions/sdk/publish/interactive.d.ts +4 -3
- package/lib/actions/sdk/publish/interactive.js +96 -97
- package/lib/actions/sdk/publish/interactive.js.map +1 -1
- package/lib/actions/sdk/publish/non-interactive.d.ts +4 -2
- package/lib/actions/sdk/publish/non-interactive.js +91 -90
- package/lib/actions/sdk/publish/non-interactive.js.map +1 -1
- package/lib/actions/sdk/publish.d.ts +3 -2
- package/lib/actions/sdk/publish.js +55 -53
- package/lib/actions/sdk/publish.js.map +1 -1
- package/lib/actions/sdk/record-published-sdk.d.ts +14 -0
- package/lib/actions/sdk/record-published-sdk.js +57 -0
- package/lib/actions/sdk/record-published-sdk.js.map +1 -0
- package/lib/client-utils/auth-manager.js +1 -1
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/commands/api/transform.d.ts +1 -1
- package/lib/commands/api/transform.js +44 -40
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.js +16 -16
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.js +14 -15
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +5 -6
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +4 -5
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/plugin/generate.d.ts +3 -3
- package/lib/commands/plugin/generate.js +20 -20
- package/lib/commands/plugin/generate.js.map +1 -1
- package/lib/commands/plugin/publish.js +18 -18
- package/lib/commands/plugin/publish.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +9 -8
- package/lib/commands/portal/generate.js +36 -27
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +7 -9
- package/lib/commands/portal/serve.js +41 -44
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/publishing/profile/list.js +8 -12
- package/lib/commands/publishing/profile/list.js.map +1 -1
- package/lib/commands/quickstart.d.ts +5 -5
- package/lib/commands/quickstart.js +18 -24
- package/lib/commands/quickstart.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +5 -7
- package/lib/commands/sdk/generate.js +58 -70
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/commands/sdk/publish.d.ts +6 -7
- package/lib/commands/sdk/publish.js +66 -60
- package/lib/commands/sdk/publish.js.map +1 -1
- package/lib/hooks/node-version.d.ts +3 -0
- package/lib/hooks/node-version.js +12 -0
- package/lib/hooks/node-version.js.map +1 -0
- package/lib/hooks/not-found.js +2 -3
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/hooks/utils.d.ts +4 -2
- package/lib/hooks/utils.js +2 -2
- package/lib/hooks/utils.js.map +1 -1
- package/lib/infrastructure/env-info.d.ts +3 -0
- package/lib/infrastructure/env-info.js +13 -6
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +35 -8
- package/lib/infrastructure/file-service.js +149 -53
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/file-watch-service.d.ts +40 -0
- package/lib/infrastructure/file-watch-service.js +167 -0
- package/lib/infrastructure/file-watch-service.js.map +1 -0
- package/lib/infrastructure/generation-status-poller.d.ts +8 -7
- package/lib/infrastructure/generation-status-poller.js +20 -12
- package/lib/infrastructure/generation-status-poller.js.map +1 -1
- package/lib/infrastructure/launcher-service.js +6 -6
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +15 -1
- package/lib/infrastructure/network-service.js.map +1 -1
- package/lib/infrastructure/portal-build-service.d.ts +19 -0
- package/lib/infrastructure/portal-build-service.js +58 -0
- package/lib/infrastructure/portal-build-service.js.map +1 -0
- package/lib/infrastructure/portal-dev-server-service.d.ts +29 -0
- package/lib/infrastructure/portal-dev-server-service.js +135 -0
- package/lib/infrastructure/portal-dev-server-service.js.map +1 -0
- package/lib/infrastructure/portal-pages-service.d.ts +17 -0
- package/lib/infrastructure/portal-pages-service.js +103 -0
- package/lib/infrastructure/portal-pages-service.js.map +1 -0
- package/lib/infrastructure/portal-project-service.d.ts +77 -0
- package/lib/infrastructure/portal-project-service.js +309 -0
- package/lib/infrastructure/portal-project-service.js.map +1 -0
- package/lib/infrastructure/service-error.d.ts +1 -0
- package/lib/infrastructure/service-error.js +39 -41
- package/lib/infrastructure/service-error.js.map +1 -1
- package/lib/infrastructure/services/api-client-factory.js +15 -13
- package/lib/infrastructure/services/api-client-factory.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +7 -5
- package/lib/infrastructure/services/api-service.js +28 -20
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/auth-service.js +4 -9
- package/lib/infrastructure/services/auth-service.js.map +1 -1
- package/lib/infrastructure/services/file-download-service.js +3 -3
- package/lib/infrastructure/services/file-download-service.js.map +1 -1
- package/lib/infrastructure/services/plugin-service.d.ts +1 -8
- package/lib/infrastructure/services/plugin-service.js +11 -22
- package/lib/infrastructure/services/plugin-service.js.map +1 -1
- package/lib/infrastructure/services/portal-artifacts-service.d.ts +44 -0
- package/lib/infrastructure/services/portal-artifacts-service.js +268 -0
- package/lib/infrastructure/services/portal-artifacts-service.js.map +1 -0
- package/lib/infrastructure/services/portal-authorization-service.d.ts +22 -0
- package/lib/infrastructure/services/portal-authorization-service.js +23 -0
- package/lib/infrastructure/services/portal-authorization-service.js.map +1 -0
- package/lib/infrastructure/services/publishing-api-service.d.ts +1 -1
- package/lib/infrastructure/services/publishing-api-service.js +11 -15
- package/lib/infrastructure/services/publishing-api-service.js.map +1 -1
- package/lib/infrastructure/services/sdk-generation-service.d.ts +21 -0
- package/lib/infrastructure/services/sdk-generation-service.js +118 -0
- package/lib/infrastructure/services/sdk-generation-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.js +5 -4
- package/lib/infrastructure/services/telemetry-service.js.map +1 -1
- package/lib/infrastructure/services/transformation-service.js +29 -32
- package/lib/infrastructure/services/transformation-service.js.map +1 -1
- package/lib/infrastructure/services/validation-service.d.ts +12 -53
- package/lib/infrastructure/services/validation-service.js +24 -199
- package/lib/infrastructure/services/validation-service.js.map +1 -1
- package/lib/infrastructure/timer-extensions.d.ts +2 -0
- package/lib/infrastructure/timer-extensions.js +10 -0
- package/lib/infrastructure/timer-extensions.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +31 -1
- package/lib/infrastructure/tmp-extensions.js +86 -3
- package/lib/infrastructure/tmp-extensions.js.map +1 -1
- package/lib/infrastructure/zip-service.js +2 -2
- package/lib/infrastructure/zip-service.js.map +1 -1
- package/lib/prompts/api/validate.d.ts +6 -7
- package/lib/prompts/api/validate.js +12 -12
- package/lib/prompts/api/validate.js.map +1 -1
- package/lib/prompts/format.d.ts +4 -0
- package/lib/prompts/format.js +5 -0
- package/lib/prompts/format.js.map +1 -1
- package/lib/prompts/plugin/generate.d.ts +17 -12
- package/lib/prompts/plugin/generate.js +94 -44
- package/lib/prompts/plugin/generate.js.map +1 -1
- package/lib/prompts/plugin/publish.d.ts +2 -1
- package/lib/prompts/plugin/publish.js +8 -7
- package/lib/prompts/plugin/publish.js.map +1 -1
- package/lib/prompts/plugin/record-metadata.d.ts +1 -0
- package/lib/prompts/plugin/record-metadata.js +10 -7
- package/lib/prompts/plugin/record-metadata.js.map +1 -1
- package/lib/prompts/portal/artifacts.d.ts +8 -0
- package/lib/prompts/portal/artifacts.js +26 -0
- package/lib/prompts/portal/artifacts.js.map +1 -0
- package/lib/prompts/portal/authorization.d.ts +6 -0
- package/lib/prompts/portal/authorization.js +29 -0
- package/lib/prompts/portal/authorization.js.map +1 -0
- package/lib/prompts/portal/code-samples.d.ts +1 -0
- package/lib/prompts/portal/code-samples.js +9 -0
- package/lib/prompts/portal/code-samples.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +14 -9
- package/lib/prompts/portal/generate.js +48 -26
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/prepare-project.d.ts +20 -0
- package/lib/prompts/portal/prepare-project.js +36 -0
- package/lib/prompts/portal/prepare-project.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +32 -12
- package/lib/prompts/portal/serve.js +100 -39
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/source.d.ts +26 -0
- package/lib/prompts/portal/source.js +253 -0
- package/lib/prompts/portal/source.js.map +1 -0
- package/lib/prompts/prompt.d.ts +11 -3
- package/lib/prompts/prompt.js +39 -15
- package/lib/prompts/prompt.js.map +1 -1
- package/lib/prompts/quickstart.d.ts +46 -3
- package/lib/prompts/quickstart.js +193 -12
- package/lib/prompts/quickstart.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +15 -13
- package/lib/prompts/sdk/generate.js +29 -32
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/prompts/sdk/publish/interactive.d.ts +10 -6
- package/lib/prompts/sdk/publish/interactive.js +26 -24
- package/lib/prompts/sdk/publish/interactive.js.map +1 -1
- package/lib/prompts/sdk/publish/non-interactive.d.ts +2 -1
- package/lib/prompts/sdk/publish/non-interactive.js +5 -4
- package/lib/prompts/sdk/publish/non-interactive.js.map +1 -1
- package/lib/prompts/sdk/publish.d.ts +3 -3
- package/lib/prompts/sdk/publish.js +13 -17
- package/lib/prompts/sdk/publish.js.map +1 -1
- package/lib/prompts/sdk/record-published-sdk.d.ts +7 -0
- package/lib/prompts/sdk/record-published-sdk.js +26 -0
- package/lib/prompts/sdk/record-published-sdk.js.map +1 -0
- package/lib/types/apimatic-config/document.d.ts +68 -0
- package/lib/types/apimatic-config/document.js +161 -0
- package/lib/types/apimatic-config/document.js.map +1 -0
- package/lib/types/apimatic-config/languages-block.d.ts +39 -0
- package/lib/types/apimatic-config/languages-block.js +58 -0
- package/lib/types/apimatic-config/languages-block.js.map +1 -0
- package/lib/types/apimatic-config-context.d.ts +48 -0
- package/lib/types/apimatic-config-context.js +121 -0
- package/lib/types/apimatic-config-context.js.map +1 -0
- package/lib/types/build/build.d.ts +1 -89
- package/lib/types/build/build.js +6 -161
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/events/domain-event.js +3 -0
- package/lib/types/events/domain-event.js.map +1 -1
- package/lib/types/events/quickstart-completed.js +3 -3
- package/lib/types/events/quickstart-completed.js.map +1 -1
- package/lib/types/events/quickstart-initiated.js +3 -3
- package/lib/types/events/quickstart-initiated.js.map +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js.map +1 -1
- package/lib/types/file/directory.d.ts +4 -9
- package/lib/types/file/directory.js +17 -65
- package/lib/types/file/directory.js.map +1 -1
- package/lib/types/file/directoryPath.d.ts +17 -0
- package/lib/types/file/directoryPath.js +47 -2
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/fileName.d.ts +8 -0
- package/lib/types/file/fileName.js +28 -6
- package/lib/types/file/fileName.js.map +1 -1
- package/lib/types/file/filePath.d.ts +18 -2
- package/lib/types/file/filePath.js +39 -4
- package/lib/types/file/filePath.js.map +1 -1
- package/lib/types/file/resource-input.js +1 -2
- package/lib/types/file/resource-input.js.map +1 -1
- package/lib/types/file/urlPath.js +2 -1
- package/lib/types/file/urlPath.js.map +1 -1
- package/lib/types/flags-provider.js +22 -22
- package/lib/types/flags-provider.js.map +1 -1
- package/lib/types/package-settings-context.js +2 -1
- package/lib/types/package-settings-context.js.map +1 -1
- package/lib/types/plugin/plugin-config.d.ts +10 -50
- package/lib/types/plugin/plugin-config.js +7 -1
- package/lib/types/plugin/plugin-config.js.map +1 -1
- package/lib/types/plugin-config-context.d.ts +30 -37
- package/lib/types/plugin-config-context.js +108 -139
- package/lib/types/plugin-config-context.js.map +1 -1
- package/lib/types/plugin-context.js +3 -2
- package/lib/types/plugin-context.js.map +1 -1
- package/lib/types/portal/code-samples.d.ts +27 -0
- package/lib/types/portal/code-samples.js +67 -0
- package/lib/types/portal/code-samples.js.map +1 -0
- package/lib/types/portal/config/ai-config.d.ts +15 -0
- package/lib/types/portal/config/ai-config.js +26 -0
- package/lib/types/portal/config/ai-config.js.map +1 -0
- package/lib/types/portal/config/brand-config.d.ts +55 -0
- package/lib/types/portal/config/brand-config.js +105 -0
- package/lib/types/portal/config/brand-config.js.map +1 -0
- package/lib/types/portal/config/color.d.ts +19 -0
- package/lib/types/portal/config/color.js +43 -0
- package/lib/types/portal/config/color.js.map +1 -0
- package/lib/types/portal/config/fields.d.ts +23 -0
- package/lib/types/portal/config/fields.js +67 -0
- package/lib/types/portal/config/fields.js.map +1 -0
- package/lib/types/portal/config/link.d.ts +18 -0
- package/lib/types/portal/config/link.js +72 -0
- package/lib/types/portal/config/link.js.map +1 -0
- package/lib/types/portal/config/navigation-config.d.ts +13 -0
- package/lib/types/portal/config/navigation-config.js +30 -0
- package/lib/types/portal/config/navigation-config.js.map +1 -0
- package/lib/types/portal/config/site-config.d.ts +32 -0
- package/lib/types/portal/config/site-config.js +88 -0
- package/lib/types/portal/config/site-config.js.map +1 -0
- package/lib/types/portal/config/static-asset.d.ts +25 -0
- package/lib/types/portal/config/static-asset.js +77 -0
- package/lib/types/portal/config/static-asset.js.map +1 -0
- package/lib/types/portal/content-notices.d.ts +20 -0
- package/lib/types/portal/content-notices.js +2 -0
- package/lib/types/portal/content-notices.js.map +1 -0
- package/lib/types/portal/content-tree.d.ts +103 -0
- package/lib/types/portal/content-tree.js +344 -0
- package/lib/types/portal/content-tree.js.map +1 -0
- package/lib/types/portal/endpoint.d.ts +6 -0
- package/lib/types/portal/endpoint.js +12 -0
- package/lib/types/portal/endpoint.js.map +1 -0
- package/lib/types/portal/generated-pages.d.ts +68 -0
- package/lib/types/portal/generated-pages.js +111 -0
- package/lib/types/portal/generated-pages.js.map +1 -0
- package/lib/types/portal/generation-status.d.ts +31 -0
- package/lib/types/portal/generation-status.js +26 -0
- package/lib/types/portal/generation-status.js.map +1 -0
- package/lib/types/portal/openapi-document.d.ts +48 -0
- package/lib/types/portal/openapi-document.js +138 -0
- package/lib/types/portal/openapi-document.js.map +1 -0
- package/lib/types/portal/page-fragments.d.ts +13 -0
- package/lib/types/portal/page-fragments.js +24 -0
- package/lib/types/portal/page-fragments.js.map +1 -0
- package/lib/types/portal/page-template.d.ts +15 -0
- package/lib/types/portal/page-template.js +64 -0
- package/lib/types/portal/page-template.js.map +1 -0
- package/lib/types/portal/page.d.ts +24 -0
- package/lib/types/portal/page.js +100 -0
- package/lib/types/portal/page.js.map +1 -0
- package/lib/types/portal/portal-artifacts.d.ts +25 -0
- package/lib/types/portal/portal-artifacts.js +30 -0
- package/lib/types/portal/portal-artifacts.js.map +1 -0
- package/lib/types/portal/portal-config.d.ts +69 -0
- package/lib/types/portal/portal-config.js +105 -0
- package/lib/types/portal/portal-config.js.map +1 -0
- package/lib/types/portal/portal-downloads.d.ts +8 -0
- package/lib/types/portal/portal-downloads.js +14 -0
- package/lib/types/portal/portal-downloads.js.map +1 -0
- package/lib/types/portal/portal-languages.d.ts +15 -0
- package/lib/types/portal/portal-languages.js +45 -0
- package/lib/types/portal/portal-languages.js.map +1 -0
- package/lib/types/portal/portal-navigation.d.ts +65 -0
- package/lib/types/portal/portal-navigation.js +217 -0
- package/lib/types/portal/portal-navigation.js.map +1 -0
- package/lib/types/portal/portal-sdk.d.ts +15 -0
- package/lib/types/portal/portal-sdk.js +28 -0
- package/lib/types/portal/portal-sdk.js.map +1 -0
- package/lib/types/portal/portal-source.d.ts +129 -0
- package/lib/types/portal/portal-source.js +2 -0
- package/lib/types/portal/portal-source.js.map +1 -0
- package/lib/types/portal/portal-stylesheet.d.ts +19 -0
- package/lib/types/portal/portal-stylesheet.js +40 -0
- package/lib/types/portal/portal-stylesheet.js.map +1 -0
- package/lib/types/portal/portal-tabs.d.ts +33 -0
- package/lib/types/portal/portal-tabs.js +38 -0
- package/lib/types/portal/portal-tabs.js.map +1 -0
- package/lib/types/portal/preview-config.d.ts +20 -0
- package/lib/types/portal/preview-config.js +32 -0
- package/lib/types/portal/preview-config.js.map +1 -0
- package/lib/types/portal/preview-content.d.ts +18 -0
- package/lib/types/portal/preview-content.js +50 -0
- package/lib/types/portal/preview-content.js.map +1 -0
- package/lib/types/portal/published-package.d.ts +12 -0
- package/lib/types/portal/published-package.js +35 -0
- package/lib/types/portal/published-package.js.map +1 -0
- package/lib/types/portal/unknown-fields.d.ts +5 -0
- package/lib/types/portal/unknown-fields.js +10 -0
- package/lib/types/portal/unknown-fields.js.map +1 -0
- package/lib/types/portal-context.d.ts +38 -6
- package/lib/types/portal-context.js +71 -24
- package/lib/types/portal-context.js.map +1 -1
- package/lib/types/portal-source-context.d.ts +77 -0
- package/lib/types/portal-source-context.js +408 -0
- package/lib/types/portal-source-context.js.map +1 -0
- package/lib/types/project-context.d.ts +49 -0
- package/lib/types/project-context.js +151 -0
- package/lib/types/project-context.js.map +1 -0
- package/lib/types/project-layout.d.ts +9 -0
- package/lib/types/project-layout.js +10 -0
- package/lib/types/project-layout.js.map +1 -0
- package/lib/types/publish/package-settings-configuration.d.ts +2 -0
- package/lib/types/publish/profile-id.js +1 -0
- package/lib/types/publish/profile-id.js.map +1 -1
- package/lib/types/publish/publishing-profile.d.ts +3 -1
- package/lib/types/publish/publishing-profile.js +33 -15
- package/lib/types/publish/publishing-profile.js.map +1 -1
- package/lib/types/publish/publishing-profiles.js +2 -1
- package/lib/types/publish/publishing-profiles.js.map +1 -1
- package/lib/types/publish/version.js +1 -0
- package/lib/types/publish/version.js.map +1 -1
- package/lib/types/resource-context.js +3 -2
- package/lib/types/resource-context.js.map +1 -1
- package/lib/types/sdk/generate.d.ts +22 -16
- package/lib/types/sdk/generate.js +64 -41
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk/stability-choice.d.ts +12 -0
- package/lib/types/sdk/stability-choice.js +24 -0
- package/lib/types/sdk/stability-choice.js.map +1 -0
- package/lib/types/sdk-context.d.ts +4 -5
- package/lib/types/sdk-context.js +10 -18
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/spec-context.d.ts +5 -4
- package/lib/types/spec-context.js +9 -8
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.d.ts +1 -1
- package/lib/types/temp-context.js +5 -4
- package/lib/types/temp-context.js.map +1 -1
- package/lib/types/transform-context.d.ts +9 -5
- package/lib/types/transform-context.js +21 -18
- package/lib/types/transform-context.js.map +1 -1
- package/lib/utils/error-utils.d.ts +2 -0
- package/lib/utils/error-utils.js +5 -0
- package/lib/utils/error-utils.js.map +1 -0
- package/lib/utils/json-utils.d.ts +2 -0
- package/lib/utils/json-utils.js +4 -0
- package/lib/utils/json-utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +8 -1
- package/lib/utils/string-utils.js +13 -26
- package/lib/utils/string-utils.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -3
- package/lib/utils/utils.js +12 -40
- package/lib/utils/utils.js.map +1 -1
- package/oclif.manifest.json +154 -442
- package/package.json +47 -25
- package/portal-pages/context-plugin.mdx +26 -0
- package/portal-pages/sdk.mdx +8 -0
- package/portal-pages/sdks.mdx +11 -0
- package/portal-template/NOTICE +37 -0
- package/portal-template/downloads.ts +41 -0
- package/portal-template/generated-pages-reload.ts +51 -0
- package/portal-template/package.json +11 -0
- package/portal-template/portal-config.ts +32 -0
- package/portal-template/prerender-pages.ts +81 -0
- package/portal-template/spec-reload.ts +26 -0
- package/portal-template/src/components/api-page.tsx +15 -0
- package/portal-template/src/components/code-block.tsx +9 -0
- package/portal-template/src/components/command-block.tsx +50 -0
- package/portal-template/src/components/example-layout.tsx +99 -0
- package/portal-template/src/components/logos.tsx +127 -0
- package/portal-template/src/components/mdx.tsx +28 -0
- package/portal-template/src/components/not-found.tsx +11 -0
- package/portal-template/src/components/plugin-install.tsx +22 -0
- package/portal-template/src/components/plugin-support.tsx +53 -0
- package/portal-template/src/components/sdk-actions.tsx +79 -0
- package/portal-template/src/components/sdk-cards.tsx +100 -0
- package/portal-template/src/components/search.tsx +41 -0
- package/portal-template/src/components/usage-tabs.tsx +92 -0
- package/portal-template/src/lib/code-samples.server.ts +40 -0
- package/portal-template/src/lib/code-samples.ts +43 -0
- package/portal-template/src/lib/code-titles.ts +29 -0
- package/portal-template/src/lib/install-command.ts +13 -0
- package/portal-template/src/lib/json.ts +5 -0
- package/portal-template/src/lib/layout.shared.tsx +41 -0
- package/portal-template/src/lib/layout.tsx +16 -0
- package/portal-template/src/lib/llms.server.ts +54 -0
- package/portal-template/src/lib/media-adapters.ts +34 -0
- package/portal-template/src/lib/navigation.ts +406 -0
- package/portal-template/src/lib/openapi-bundle.server.ts +343 -0
- package/portal-template/src/lib/openapi-filter.ts +191 -0
- package/portal-template/src/lib/openapi-labels.ts +15 -0
- package/portal-template/src/lib/openapi-methods.ts +12 -0
- package/portal-template/src/lib/openapi-section.server.ts +280 -0
- package/portal-template/src/lib/openapi-slim.ts +202 -0
- package/portal-template/src/lib/openapi.server.ts +16 -0
- package/portal-template/src/lib/portal-types.ts +36 -0
- package/portal-template/src/lib/portal.server.ts +13 -0
- package/portal-template/src/lib/portal.ts +11 -0
- package/portal-template/src/lib/rehype-code-titles.ts +53 -0
- package/portal-template/src/lib/request-examples.ts +72 -0
- package/portal-template/src/lib/seo.ts +21 -0
- package/portal-template/src/lib/shared.ts +51 -0
- package/portal-template/src/lib/shiki-bundle.ts +104 -0
- package/portal-template/src/lib/sitemap.server.ts +20 -0
- package/portal-template/src/lib/source.server.ts +27 -0
- package/portal-template/src/lib/source.ts +49 -0
- package/portal-template/src/lib/tabs.ts +37 -0
- package/portal-template/src/router.tsx +12 -0
- package/portal-template/src/routes/$.tsx +194 -0
- package/portal-template/src/routes/__root.tsx +56 -0
- package/portal-template/src/routes/api/search[.]json.ts +9 -0
- package/portal-template/src/routes/llms-full[.]txt.ts +10 -0
- package/portal-template/src/routes/llms[.]txt.ts +10 -0
- package/portal-template/src/routes/robots[.]txt.ts +10 -0
- package/portal-template/src/routes/sitemap[.]xml.ts +10 -0
- package/portal-template/src/routes/spa-shell.tsx +7 -0
- package/portal-template/src/routes/{$}[.]md.ts +21 -0
- package/portal-template/src/styles/app.css +33 -0
- package/portal-template/tsconfig.json +26 -0
- package/portal-template/vite.config.ts +68 -0
- package/lib/actions/plugin/record-sdk.d.ts +0 -14
- package/lib/actions/plugin/record-sdk.js +0 -60
- package/lib/actions/plugin/record-sdk.js.map +0 -1
- package/lib/actions/portal/copilot.d.ts +0 -17
- package/lib/actions/portal/copilot.js +0 -89
- package/lib/actions/portal/copilot.js.map +0 -1
- package/lib/actions/portal/quickstart.d.ts +0 -18
- package/lib/actions/portal/quickstart.js +0 -238
- package/lib/actions/portal/quickstart.js.map +0 -1
- package/lib/actions/portal/recipe/new-recipe.d.ts +0 -15
- package/lib/actions/portal/recipe/new-recipe.js +0 -177
- package/lib/actions/portal/recipe/new-recipe.js.map +0 -1
- package/lib/actions/portal/toc/new-toc.d.ts +0 -21
- package/lib/actions/portal/toc/new-toc.js +0 -95
- package/lib/actions/portal/toc/new-toc.js.map +0 -1
- package/lib/actions/sdk/merge-source-tree.d.ts +0 -12
- package/lib/actions/sdk/merge-source-tree.js +0 -78
- package/lib/actions/sdk/merge-source-tree.js.map +0 -1
- package/lib/actions/sdk/quickstart.d.ts +0 -18
- package/lib/actions/sdk/quickstart.js +0 -188
- package/lib/actions/sdk/quickstart.js.map +0 -1
- package/lib/actions/sdk/save-changes.d.ts +0 -8
- package/lib/actions/sdk/save-changes.js +0 -93
- package/lib/actions/sdk/save-changes.js.map +0 -1
- package/lib/application/portal/recipe/portal-recipe.d.ts +0 -8
- package/lib/application/portal/recipe/portal-recipe.js +0 -33
- package/lib/application/portal/recipe/portal-recipe.js.map +0 -1
- package/lib/application/portal/recipe/recipe-generator.d.ts +0 -21
- package/lib/application/portal/recipe/recipe-generator.js +0 -130
- package/lib/application/portal/recipe/recipe-generator.js.map +0 -1
- package/lib/application/portal/toc/toc-content-parser.d.ts +0 -5
- package/lib/application/portal/toc/toc-content-parser.js +0 -44
- package/lib/application/portal/toc/toc-content-parser.js.map +0 -1
- package/lib/application/portal/toc/toc-structure-generator.d.ts +0 -11
- package/lib/application/portal/toc/toc-structure-generator.js +0 -165
- package/lib/application/portal/toc/toc-structure-generator.js.map +0 -1
- package/lib/commands/portal/copilot.d.ts +0 -13
- package/lib/commands/portal/copilot.js +0 -34
- package/lib/commands/portal/copilot.js.map +0 -1
- package/lib/commands/portal/recipe/new.d.ts +0 -12
- package/lib/commands/portal/recipe/new.js +0 -45
- package/lib/commands/portal/recipe/new.js.map +0 -1
- package/lib/commands/portal/toc/new.d.ts +0 -16
- package/lib/commands/portal/toc/new.js +0 -68
- package/lib/commands/portal/toc/new.js.map +0 -1
- package/lib/commands/sdk/save-changes.d.ts +0 -14
- package/lib/commands/sdk/save-changes.js +0 -51
- package/lib/commands/sdk/save-changes.js.map +0 -1
- package/lib/infrastructure/debounce-service.d.ts +0 -10
- package/lib/infrastructure/debounce-service.js +0 -55
- package/lib/infrastructure/debounce-service.js.map +0 -1
- package/lib/infrastructure/services/portal-service.d.ts +0 -43
- package/lib/infrastructure/services/portal-service.js +0 -337
- package/lib/infrastructure/services/portal-service.js.map +0 -1
- package/lib/prompts/plugin/record-sdk.d.ts +0 -9
- package/lib/prompts/plugin/record-sdk.js +0 -40
- package/lib/prompts/plugin/record-sdk.js.map +0 -1
- package/lib/prompts/portal/copilot.d.ts +0 -18
- package/lib/prompts/portal/copilot.js +0 -82
- package/lib/prompts/portal/copilot.js.map +0 -1
- package/lib/prompts/portal/quickstart.d.ts +0 -42
- package/lib/prompts/portal/quickstart.js +0 -243
- package/lib/prompts/portal/quickstart.js.map +0 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +0 -29
- package/lib/prompts/portal/recipe/new-recipe.js +0 -165
- package/lib/prompts/portal/recipe/new-recipe.js.map +0 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +0 -16
- package/lib/prompts/portal/toc/new-toc.js +0 -50
- package/lib/prompts/portal/toc/new-toc.js.map +0 -1
- package/lib/prompts/sdk/merge-source-tree.d.ts +0 -22
- package/lib/prompts/sdk/merge-source-tree.js +0 -90
- package/lib/prompts/sdk/merge-source-tree.js.map +0 -1
- package/lib/prompts/sdk/quickstart.d.ts +0 -38
- package/lib/prompts/sdk/quickstart.js +0 -196
- package/lib/prompts/sdk/quickstart.js.map +0 -1
- package/lib/prompts/sdk/save-changes.d.ts +0 -21
- package/lib/prompts/sdk/save-changes.js +0 -84
- package/lib/prompts/sdk/save-changes.js.map +0 -1
- package/lib/types/build-context.d.ts +0 -26
- package/lib/types/build-context.js +0 -111
- package/lib/types/build-context.js.map +0 -1
- package/lib/types/events/recipe-creation-failed.d.ts +0 -5
- package/lib/types/events/recipe-creation-failed.js +0 -8
- package/lib/types/events/recipe-creation-failed.js.map +0 -1
- package/lib/types/events/sdk-changes-saved.d.ts +0 -8
- package/lib/types/events/sdk-changes-saved.js +0 -11
- package/lib/types/events/sdk-changes-saved.js.map +0 -1
- package/lib/types/events/sdk-changes-tracked.d.ts +0 -8
- package/lib/types/events/sdk-changes-tracked.js +0 -11
- package/lib/types/events/sdk-changes-tracked.js.map +0 -1
- package/lib/types/events/sdk-conflicts-resolved.d.ts +0 -8
- package/lib/types/events/sdk-conflicts-resolved.js +0 -11
- package/lib/types/events/sdk-conflicts-resolved.js.map +0 -1
- package/lib/types/events/toc-creation-failed.d.ts +0 -5
- package/lib/types/events/toc-creation-failed.js +0 -8
- package/lib/types/events/toc-creation-failed.js.map +0 -1
- package/lib/types/merge-source-tree-context.d.ts +0 -28
- package/lib/types/merge-source-tree-context.js +0 -63
- package/lib/types/merge-source-tree-context.js.map +0 -1
- package/lib/types/plugin/language-entry.d.ts +0 -9
- package/lib/types/plugin/language-entry.js +0 -64
- package/lib/types/plugin/language-entry.js.map +0 -1
- package/lib/types/recipe/recipe.d.ts +0 -22
- package/lib/types/recipe/recipe.js +0 -6
- package/lib/types/recipe/recipe.js.map +0 -1
- package/lib/types/recipe-context.d.ts +0 -9
- package/lib/types/recipe-context.js +0 -26
- package/lib/types/recipe-context.js.map +0 -1
- package/lib/types/save-changes-context.d.ts +0 -17
- package/lib/types/save-changes-context.js +0 -42
- package/lib/types/save-changes-context.js.map +0 -1
- package/lib/types/sdl/sdl.d.ts +0 -10
- package/lib/types/sdl/sdl.js +0 -18
- package/lib/types/sdl/sdl.js.map +0 -1
- package/lib/types/toc/toc-components.d.ts +0 -36
- package/lib/types/toc/toc-components.js +0 -94
- package/lib/types/toc/toc-components.js.map +0 -1
- package/lib/types/toc/toc.d.ts +0 -67
- package/lib/types/toc/toc.js +0 -2
- package/lib/types/toc/toc.js.map +0 -1
- package/lib/types/toc-context.d.ts +0 -12
- package/lib/types/toc-context.js +0 -26
- package/lib/types/toc-context.js.map +0 -1
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { PathUtils } from 'fumadocs-core/source';
|
|
2
|
+
import type { ContentStorage, PageTreeTransformer } from 'fumadocs-core/source';
|
|
3
|
+
import type { Folder, Node } from 'fumadocs-core/page-tree';
|
|
4
|
+
import { apiBaseDir, containsUrl, docsRoute } from './shared';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Only what this file needs of the builder context. `loader()` infers a storage type from
|
|
8
|
+
* the exact sources it is given, and the hooks take it as `this`, so depending on the whole
|
|
9
|
+
* context would tie the transformer to one particular set of sources.
|
|
10
|
+
*/
|
|
11
|
+
interface NavigationStorage {
|
|
12
|
+
read(path: string): { format: string; type?: string; data: unknown } | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface NavigationBuilder {
|
|
16
|
+
resolveFlattenPath(name: string, format: string): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface NavigationContext {
|
|
20
|
+
storage: NavigationStorage;
|
|
21
|
+
builder: NavigationBuilder;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Everything in this directory that no other entry names. */
|
|
25
|
+
const REST_TOKEN = '...';
|
|
26
|
+
/** The API reference, positioned as one node. */
|
|
27
|
+
const API_REFERENCE_TOKEN = 'apimatic:api';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The folders the CLI generates, each a tab of its own, by the token that positions it and in
|
|
31
|
+
* the order they take when the root `nav.json` names none of them. The CLI's
|
|
32
|
+
* `GENERATED_SECTIONS` lists the same, and a test holds the two together.
|
|
33
|
+
*/
|
|
34
|
+
export const GENERATED_SECTIONS = [
|
|
35
|
+
{ token: 'apimatic:sdks', folder: 'sdks' },
|
|
36
|
+
{ token: 'apimatic:plugin', folder: 'context-plugin' }
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
const NAVIGATION_FILE_STEM = 'nav';
|
|
40
|
+
|
|
41
|
+
const API_REFERENCE_TITLE = 'API Reference';
|
|
42
|
+
|
|
43
|
+
/** Where the home page is served, which is how its node is told apart from every other page. */
|
|
44
|
+
const HOME_URL = docsRoute;
|
|
45
|
+
|
|
46
|
+
/** Fixed, as tab matching goes by id after serialisation; Fumadocs' ids never start with a slash. */
|
|
47
|
+
const HOME_TAB_ID = '/tab/home';
|
|
48
|
+
|
|
49
|
+
/** The Home tab's name when the root `nav.json` gives none, and the fallback home page's. */
|
|
50
|
+
const HOME_NAME = 'Home';
|
|
51
|
+
|
|
52
|
+
/** The node the fallback home page gets when there is no index page; see `withFallbackHomePage`. */
|
|
53
|
+
const SYNTHETIC_HOME_ID = '/page/home';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The key the generated pages are passed to `loader()` under, which the storage stamps onto
|
|
57
|
+
* every file of that source.
|
|
58
|
+
*/
|
|
59
|
+
export const GENERATED_SOURCE = 'generated';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The key the reference pages are passed to `loader()` under in `source.server.ts`. It tells
|
|
63
|
+
* a specification's section apart from a folder the user made under `content/api/`, which
|
|
64
|
+
* lands in the same virtual directory.
|
|
65
|
+
*/
|
|
66
|
+
export const OPENAPI_SOURCE = 'openapi';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Applies the order in each directory's `nav.json` to the page tree.
|
|
70
|
+
*
|
|
71
|
+
* The hook fires for every directory once its children are built, so this never resolves
|
|
72
|
+
* anything: it permutes a list Fumadocs has already ordered correctly, which is what makes
|
|
73
|
+
* losing a page structurally impossible. Entries that match nothing are ignored rather than
|
|
74
|
+
* reported, because `PortalSourceContext` has already refused a file that contains one.
|
|
75
|
+
*/
|
|
76
|
+
export function navigationTransformer<S extends ContentStorage>(): PageTreeTransformer<S> {
|
|
77
|
+
return {
|
|
78
|
+
folder(node, folderPath) {
|
|
79
|
+
// A directory holding a `nav.json` and no page still gets a folder node, because the
|
|
80
|
+
// metadata file is in storage. The CLI treats such a directory as no folder, so the
|
|
81
|
+
// parent's file cannot name it; showing it empty would contradict that refusal. A
|
|
82
|
+
// folder whose only page is its index is not empty: the folder itself links to it.
|
|
83
|
+
node.children = node.children.filter((child) => !isEmptyFolder(child));
|
|
84
|
+
|
|
85
|
+
// The root is ordered even with no file of its own: naming nothing still puts the
|
|
86
|
+
// generated sections and the API reference at their defaults, and Fumadocs' own order
|
|
87
|
+
// would not. It sorts folders by path, so `api` lands above a user folder called anything
|
|
88
|
+
// later in the alphabet, and a generated folder lands in the middle of the user's pages.
|
|
89
|
+
// Below the root those defaults do not apply, so a folder with no file keeps Fumadocs'
|
|
90
|
+
// order untouched, which is every tag folder of every specification.
|
|
91
|
+
const settings = readSettings(this, folderPath);
|
|
92
|
+
const order = settings?.pages;
|
|
93
|
+
if (folderPath === '' || order !== undefined) {
|
|
94
|
+
node.children = reorder(this, node, folderPath, order ?? []);
|
|
95
|
+
}
|
|
96
|
+
if (folderPath === apiBaseDir) {
|
|
97
|
+
applyApiStructure(this, node);
|
|
98
|
+
}
|
|
99
|
+
// Last, to outrank the index page's title and the API wrapper's; at the root it names Home instead.
|
|
100
|
+
if (folderPath !== '' && settings?.title !== undefined) {
|
|
101
|
+
node.name = settings.title;
|
|
102
|
+
}
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A tab per folder the root `nav.json` lists, the API reference and each generated folder; the rest is Home. */
|
|
109
|
+
export function tabsTransformer<S extends ContentStorage>(): PageTreeTransformer<S> {
|
|
110
|
+
return {
|
|
111
|
+
root(root) {
|
|
112
|
+
root.children = groupIntoTabs(this, root.children);
|
|
113
|
+
return root;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** What a directory's `nav.json` says about it. Absent fields leave Fumadocs' own answer. */
|
|
119
|
+
interface NavigationSettings {
|
|
120
|
+
pages: string[] | undefined;
|
|
121
|
+
title: string | undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function readSettings(context: NavigationContext, folderPath: string): NavigationSettings | undefined {
|
|
125
|
+
// Resolved through the builder's own index so the extension is never hard-coded.
|
|
126
|
+
const path = context.builder.resolveFlattenPath(PathUtils.joinPath(folderPath, NAVIGATION_FILE_STEM), 'meta');
|
|
127
|
+
const file = context.storage.read(path);
|
|
128
|
+
// Under `portal serve` a half-typed file reloads to here whatever the CLI says of it, and `null` would throw.
|
|
129
|
+
if (file === undefined || file.format !== 'meta' || typeof file.data !== 'object' || file.data === null) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { pages, title } = file.data as { pages?: unknown; title?: unknown };
|
|
134
|
+
// A half-typed title reloads to here as an empty string, which would blank the folder in
|
|
135
|
+
// the sidebar with nothing to click. The CLI refuses one; the preview keeps the default
|
|
136
|
+
// name until the file is worth reading again.
|
|
137
|
+
const named = typeof title === 'string' ? title.trim() : '';
|
|
138
|
+
return {
|
|
139
|
+
pages: Array.isArray(pages) ? pages.filter((entry): entry is string => typeof entry === 'string') : undefined,
|
|
140
|
+
title: named.length > 0 ? named : undefined
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isTabFolder(rootSettings: NavigationSettings | undefined, folder: Folder): boolean {
|
|
145
|
+
const folderPath = folder.$ref?.folder;
|
|
146
|
+
return (
|
|
147
|
+
folderPath !== undefined &&
|
|
148
|
+
folderPath !== apiBaseDir &&
|
|
149
|
+
lists(rootSettings, folderPath) &&
|
|
150
|
+
// The home page is the Home tab's, whichever `(group)` folder serves it.
|
|
151
|
+
!containsUrl([folder], HOME_URL)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function groupIntoTabs(context: NavigationContext, children: Node[]): Node[] {
|
|
156
|
+
const settings = readSettings(context, '');
|
|
157
|
+
const tabs: Folder[] = [];
|
|
158
|
+
const loose: Node[] = [];
|
|
159
|
+
|
|
160
|
+
for (const child of children) {
|
|
161
|
+
if (
|
|
162
|
+
child.type === 'folder' &&
|
|
163
|
+
(isApiReference(child) || isTabFolder(settings, child) || isInjected(context, child))
|
|
164
|
+
) {
|
|
165
|
+
tabs.push(asTab(child));
|
|
166
|
+
} else {
|
|
167
|
+
loose.push(child);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Fumadocs points a tab at the page with the same path inside the tab being left, when
|
|
172
|
+
// there is one, and finds it through the folders' `$ref`. Between tabs that is the wrong
|
|
173
|
+
// page -- `/api/overview` from `/tutorials/overview` -- so a tab always opens where its
|
|
174
|
+
// own list starts. Nothing past this transformer reads a folder's `$ref`.
|
|
175
|
+
for (const tab of tabs) {
|
|
176
|
+
delete tab.$ref;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const home: Folder = {
|
|
180
|
+
type: 'folder',
|
|
181
|
+
$id: HOME_TAB_ID,
|
|
182
|
+
name: settings?.title ?? HOME_NAME,
|
|
183
|
+
root: true,
|
|
184
|
+
children: withFallbackHomePage(loose)
|
|
185
|
+
};
|
|
186
|
+
// Home opens the site, so it leads wherever the file lists its pages; `index` orders them only.
|
|
187
|
+
return [home, ...tabs];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Without an index page the route still renders a home page, which needs a node to be in a tab. */
|
|
191
|
+
function withFallbackHomePage(loose: Node[]): Node[] {
|
|
192
|
+
if (containsUrl(loose, HOME_URL)) {
|
|
193
|
+
return loose;
|
|
194
|
+
}
|
|
195
|
+
return [{ type: 'page', $id: SYNTHETIC_HOME_ID, name: HOME_NAME, url: HOME_URL }, ...loose];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* A folder as a tab. Its index page, when it has one, becomes the first of its pages: a root
|
|
200
|
+
* folder's own link is not listed in its sidebar, and Fumadocs does not look there when it
|
|
201
|
+
* decides which tab is active.
|
|
202
|
+
*/
|
|
203
|
+
function asTab(folder: Folder): Folder {
|
|
204
|
+
folder.root = true;
|
|
205
|
+
if (folder.index !== undefined) {
|
|
206
|
+
folder.children = [folder.index, ...folder.children];
|
|
207
|
+
folder.index = undefined;
|
|
208
|
+
}
|
|
209
|
+
return folder;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function lists(settings: NavigationSettings | undefined, name: string): boolean {
|
|
213
|
+
return settings?.pages?.some((entry) => entry.trim() === name) ?? false;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Titles the wrapper and, for a single specification, lifts its section away.
|
|
218
|
+
*
|
|
219
|
+
* Fumadocs names an untitled folder by uppercasing its first character only, so `api` would
|
|
220
|
+
* render as "Api", which reads as a typo. The section below it is named after the
|
|
221
|
+
* specification's file, which with one document only restates the portal's own title; with
|
|
222
|
+
* two or more the names tell them apart and are worth a level. Adding a second document
|
|
223
|
+
* therefore inserts a level rather than renaming anything.
|
|
224
|
+
*
|
|
225
|
+
* Only the sections count. Pages the user puts under `content/api/` share this folder, and
|
|
226
|
+
* adding one must not push every operation down a level: the lifted tag folders take the
|
|
227
|
+
* section's place, with those pages staying beside them where the order already put them.
|
|
228
|
+
*/
|
|
229
|
+
function applyApiStructure(context: NavigationContext, node: Folder): void {
|
|
230
|
+
// A user who gives the folder an index page has named it, as any other folder is named.
|
|
231
|
+
if (node.index === undefined) {
|
|
232
|
+
node.name = API_REFERENCE_TITLE;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const sections = node.children.filter((child) => isSpecSection(context, child));
|
|
236
|
+
if (sections.length === 1) {
|
|
237
|
+
const [only] = sections;
|
|
238
|
+
// The section's index page, if a user gave it one, sits on the folder rather than among
|
|
239
|
+
// its children, and would be lost with the folder. Lifted first, as Fumadocs itself
|
|
240
|
+
// expands a folder into its index followed by its children.
|
|
241
|
+
const lifted = only.index === undefined ? only.children : [only.index, ...only.children];
|
|
242
|
+
node.children = node.children.flatMap((child) => (child === only ? lifted : [child]));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Whether a folder holds one specification's reference pages rather than the user's own. */
|
|
247
|
+
function isSpecSection(context: NavigationContext, child: Node): child is Folder {
|
|
248
|
+
if (child.type !== 'folder') {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const page = firstPageIn(child);
|
|
252
|
+
return page !== undefined && isFromSource(context, page, OPENAPI_SOURCE);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The first page beneath a folder, at any depth; a section's pages sit under its tag folders. */
|
|
256
|
+
function firstPageIn(folder: Folder): Node | undefined {
|
|
257
|
+
for (const child of folder.children) {
|
|
258
|
+
if (child.type === 'page') {
|
|
259
|
+
return child;
|
|
260
|
+
}
|
|
261
|
+
if (child.type === 'folder') {
|
|
262
|
+
const page = firstPageIn(child);
|
|
263
|
+
if (page !== undefined) {
|
|
264
|
+
return page;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function reorder(context: NavigationContext, node: Folder, folderPath: string, order: string[]): Node[] {
|
|
272
|
+
const remaining = new Set(node.children);
|
|
273
|
+
// Asked once per child: the token, both bands and the anchor all want to know, and each
|
|
274
|
+
// answer is a storage read.
|
|
275
|
+
const injectedChildren = new Set(node.children.filter((child) => isInjected(context, child)));
|
|
276
|
+
const isInjectedChild = (child: Node): boolean => injectedChildren.has(child);
|
|
277
|
+
const named: Node[] = [];
|
|
278
|
+
let restIndex: number | undefined;
|
|
279
|
+
|
|
280
|
+
const claim = (child: Node | undefined): void => {
|
|
281
|
+
if (child !== undefined) {
|
|
282
|
+
remaining.delete(child);
|
|
283
|
+
named.push(child);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// Every token names a node that lives at the content root, and the CLI refuses each one
|
|
288
|
+
// anywhere else. Honouring them in a nested directory would let the two halves of the
|
|
289
|
+
// format disagree about a file only one of them had rejected.
|
|
290
|
+
const isContentRoot = folderPath === '';
|
|
291
|
+
|
|
292
|
+
for (const raw of order) {
|
|
293
|
+
const entry = raw.trim();
|
|
294
|
+
const section = GENERATED_SECTIONS.find((candidate) => candidate.token === entry);
|
|
295
|
+
if (entry === REST_TOKEN) {
|
|
296
|
+
restIndex = named.length;
|
|
297
|
+
} else if (entry === API_REFERENCE_TOKEN) {
|
|
298
|
+
if (isContentRoot) {
|
|
299
|
+
claim([...remaining].find((child) => isApiReference(child)));
|
|
300
|
+
}
|
|
301
|
+
} else if (section !== undefined) {
|
|
302
|
+
if (isContentRoot) {
|
|
303
|
+
claim([...remaining].find((child) => isInjectedChild(child) && isSectionFolder(child, section)));
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
claim(matching(context, [...remaining], folderPath, entry));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// What is left keeps its default order, in three bands. The generated sections and the API
|
|
311
|
+
// reference have defaults of their own rather than travelling with the content, so that
|
|
312
|
+
// a later release adding a section never splits the band or reorders a sidebar nobody
|
|
313
|
+
// touched. The sections keep the CLI's order: Fumadocs' own is by path, which would put
|
|
314
|
+
// `context-plugin` above `sdks`.
|
|
315
|
+
const rest = [...remaining];
|
|
316
|
+
const api = rest.filter((child) => isApiReference(child));
|
|
317
|
+
const injected = rest.filter(isInjectedChild).sort((left, right) => sectionRank(left) - sectionRank(right));
|
|
318
|
+
const content = rest.filter((child) => !isApiReference(child) && !isInjectedChild(child));
|
|
319
|
+
|
|
320
|
+
// With no rest token, unnamed content joins the user's own pages: after the last one the
|
|
321
|
+
// file named. Appending at the end instead would drop it below the whole API reference,
|
|
322
|
+
// and inserting before the reference would lift it above one the file deliberately put
|
|
323
|
+
// first.
|
|
324
|
+
const at = restIndex ?? afterNamedContent(named, isInjectedChild);
|
|
325
|
+
const ordered = [...named.slice(0, at), ...content, ...named.slice(at)];
|
|
326
|
+
|
|
327
|
+
// Before the API reference, but never above the user's own pages: when the file puts the
|
|
328
|
+
// reference first, the band follows the content instead.
|
|
329
|
+
const anchor = Math.max(anchorIn(ordered), at + content.length);
|
|
330
|
+
return [...ordered.slice(0, anchor), ...injected, ...ordered.slice(anchor), ...api];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The child an entry addresses. A page is compared against the virtual path the builder
|
|
335
|
+
* resolves its name to, a folder against its own path, which is why `noRef` has to stay at
|
|
336
|
+
* its default of false. When a page and a folder share the name, the folder wins, as it
|
|
337
|
+
* does for the same entry in Fumadocs' own metadata.
|
|
338
|
+
*/
|
|
339
|
+
function matching(context: NavigationContext, children: Node[], folderPath: string, entry: string): Node | undefined {
|
|
340
|
+
const target = PathUtils.joinPath(folderPath, entry);
|
|
341
|
+
const folder = children.find((child) => child.type === 'folder' && child.$ref?.folder === target);
|
|
342
|
+
if (folder !== undefined) {
|
|
343
|
+
return folder;
|
|
344
|
+
}
|
|
345
|
+
const pagePath = context.builder.resolveFlattenPath(target, 'page');
|
|
346
|
+
return children.find((child) => child.type === 'page' && child.$ref === pagePath);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function afterNamedContent(named: Node[], isInjectedChild: (child: Node) => boolean): number {
|
|
350
|
+
for (let index = named.length - 1; index >= 0; index -= 1) {
|
|
351
|
+
if (!isApiReference(named[index]) && !isInjectedChild(named[index])) {
|
|
352
|
+
return index + 1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Nothing named is the user's own, so everything named is what the CLI adds, and the
|
|
356
|
+
// user's pages keep their default place above all of it.
|
|
357
|
+
return 0;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function anchorIn(children: Node[]): number {
|
|
361
|
+
const index = children.findIndex((child) => isApiReference(child));
|
|
362
|
+
return index === -1 ? children.length : index;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function isApiReference(child: Node): child is Folder {
|
|
366
|
+
return child.type === 'folder' && child.$ref?.folder === apiBaseDir;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function isEmptyFolder(child: Node): boolean {
|
|
370
|
+
return child.type === 'folder' && child.children.length === 0 && child.index === undefined;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Whether a node came from the generated source rather than the user's content directory. A
|
|
375
|
+
* folder is judged by its index page first: the context plugin's holds nothing else, and
|
|
376
|
+
* `firstPageIn` walks only a folder's children.
|
|
377
|
+
*/
|
|
378
|
+
function isInjected(context: NavigationContext, child: Node): boolean {
|
|
379
|
+
if (child.type === 'folder') {
|
|
380
|
+
const page = child.index ?? firstPageIn(child);
|
|
381
|
+
return page !== undefined && isFromSource(context, page, GENERATED_SOURCE);
|
|
382
|
+
}
|
|
383
|
+
return isFromSource(context, child, GENERATED_SOURCE);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Where a generated folder comes in `GENERATED_SECTIONS`. Anything else sorts after them, which
|
|
388
|
+
* only a loose generated page could be, and the CLI writes none.
|
|
389
|
+
*/
|
|
390
|
+
function sectionRank(child: Node): number {
|
|
391
|
+
const rank = GENERATED_SECTIONS.findIndex((section) => isSectionFolder(child, section));
|
|
392
|
+
return rank === -1 ? GENERATED_SECTIONS.length : rank;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function isSectionFolder(child: Node, section: (typeof GENERATED_SECTIONS)[number]): boolean {
|
|
396
|
+
return child.type === 'folder' && child.$ref?.folder === section.folder;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Whether a page was passed to `loader()` under this key, which the storage stamps on it. */
|
|
400
|
+
function isFromSource(context: NavigationContext, child: Node, source: string): boolean {
|
|
401
|
+
if (child.type !== 'page' || child.$ref === undefined) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
return context.storage.read(child.$ref)?.type === source;
|
|
405
|
+
}
|
|
406
|
+
|