@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.
- 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 +222 -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 +102 -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 +199 -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 +70 -0
- package/lib/types/apimatic-config/document.js +167 -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 +69 -357
- 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,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,CAA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QACjG,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,SAAS;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;CACF;AAED,SAAS,YAAY,CAAC,QAAkB,EAAE,OAAgB;IACxD,OAAO,EAAE,IAAI,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":"br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C,OAAO,CAAC;QAC7B,OAAO,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC;IACvG,CAAC;IAEM,MAAM;QAMX,OAAO;YACL,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3D,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,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;YACpB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK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AI,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,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AAG,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,CAAC;SACxC,CAAC,CACH,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI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AE,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,I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|
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
|
+
}
|