@apimatic/cli 1.5.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 @@
|
|
|
1
|
+
{"version":3,"file":"generation-status.js","sourceRoot":"","sources":["../../../src/types/portal/generation-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,+BASX;AATD,WAAY,+BAA+B;IACzC,oDAAiB,CAAA;IACjB,wEAAqC,CAAA;IACrC,8EAA2C,CAAA;IAC3C,0DAAuB,CAAA;IACvB,oDAAiB,CAAA;IACjB,sEAAmC,CAAA;IACnC,0EAAuC,CAAA;IACvC,sDAAmB,CAAA;AACrB,CAAC,EATW,+BAA+B,KAA/B,+BAA+B,QAS1C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DirectoryPath } from '../file/directoryPath.js';
|
|
2
|
+
import { FileName } from '../file/fileName.js';
|
|
3
|
+
import { FilePath } from '../file/filePath.js';
|
|
4
|
+
import { SuggestedSite } from './config/site-config.js';
|
|
5
|
+
import { Endpoint } from './endpoint.js';
|
|
6
|
+
/**
|
|
7
|
+
* Whether a parsed document is one a portal can be built from. `format` names what it is
|
|
8
|
+
* instead when that can be told from the document, and is null when nothing identifies it --
|
|
9
|
+
* a Postman collection, or any other JSON that carries no version key at all.
|
|
10
|
+
*/
|
|
11
|
+
export type SpecFormat = {
|
|
12
|
+
supported: true;
|
|
13
|
+
} | {
|
|
14
|
+
supported: false;
|
|
15
|
+
format: string | null;
|
|
16
|
+
};
|
|
17
|
+
/** A path item kept in another file, where `pointer` locates it; empty for the whole file. */
|
|
18
|
+
export interface PathItemReference {
|
|
19
|
+
path: string;
|
|
20
|
+
file: FilePath;
|
|
21
|
+
pointer: string;
|
|
22
|
+
}
|
|
23
|
+
/** A specification as written to disk, read the one way the wizard and the build agree on. */
|
|
24
|
+
export declare class OpenApiDocument {
|
|
25
|
+
private readonly document;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Undefined when neither parser accepts the text. A document that parses to something other
|
|
29
|
+
* than an object is kept, and reports itself as no specification at all.
|
|
30
|
+
*/
|
|
31
|
+
static parse(fileName: FileName, contents: string): OpenApiDocument | undefined;
|
|
32
|
+
/** Every operation declared inline or behind a `$ref` into this document; see `pathItemReferences` for the rest. */
|
|
33
|
+
endpoints(): Endpoint[];
|
|
34
|
+
/** The path items kept in other local files, resolved against the `directory` this document sits in. */
|
|
35
|
+
pathItemReferences(directory: DirectoryPath): PathItemReference[];
|
|
36
|
+
/** The operations of the path item `pointer` locates in this document, as they are mounted at `path`. */
|
|
37
|
+
endpointsAt(path: string, pointer: string): Endpoint[];
|
|
38
|
+
format(): SpecFormat;
|
|
39
|
+
/**
|
|
40
|
+
* Both fields are written into generated files, so each is collapsed to one line. The
|
|
41
|
+
* description stops at its first blank line: past it a specification's description is
|
|
42
|
+
* usually a guide to the API, not a summary of it.
|
|
43
|
+
*/
|
|
44
|
+
suggestedSite(): SuggestedSite;
|
|
45
|
+
private paths;
|
|
46
|
+
private endpointsOf;
|
|
47
|
+
private followLocal;
|
|
48
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { basename, dirname } from 'node:path';
|
|
2
|
+
import { parse as parseYaml } from 'yaml';
|
|
3
|
+
import { FileName } from '../file/fileName.js';
|
|
4
|
+
import { FilePath } from '../file/filePath.js';
|
|
5
|
+
import { isJsonObject } from '../../utils/json-utils.js';
|
|
6
|
+
import { stripByteOrderMark } from '../../utils/string-utils.js';
|
|
7
|
+
import { PLACEHOLDER_SITE } from './config/site-config.js';
|
|
8
|
+
import { Endpoint } from './endpoint.js';
|
|
9
|
+
const DESCRIPTION_LIMIT = 300;
|
|
10
|
+
const HTTP_METHODS = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']);
|
|
11
|
+
const URL_SCHEME = /^[a-z][a-z\d+.-]+:/i;
|
|
12
|
+
// The options @scalar/json-magic bundles with, so a spec reads here as it does in the portal.
|
|
13
|
+
const YAML_OPTIONS = { merge: true, maxAliasCount: 10000 };
|
|
14
|
+
/** A specification as written to disk, read the one way the wizard and the build agree on. */
|
|
15
|
+
export class OpenApiDocument {
|
|
16
|
+
document;
|
|
17
|
+
constructor(document) {
|
|
18
|
+
this.document = document;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Undefined when neither parser accepts the text. A document that parses to something other
|
|
22
|
+
* than an object is kept, and reports itself as no specification at all.
|
|
23
|
+
*/
|
|
24
|
+
static parse(fileName, contents) {
|
|
25
|
+
try {
|
|
26
|
+
// JSON is valid YAML, but the YAML parser is far slower and specs run to megabytes,
|
|
27
|
+
// so each extension gets the parser built for it.
|
|
28
|
+
const text = stripByteOrderMark(contents);
|
|
29
|
+
const document = fileName.hasExtension('.json') ? JSON.parse(text) : parseYaml(text, YAML_OPTIONS);
|
|
30
|
+
return new OpenApiDocument(isJsonObject(document) ? document : {});
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Every operation declared inline or behind a `$ref` into this document; see `pathItemReferences` for the rest. */
|
|
37
|
+
endpoints() {
|
|
38
|
+
return Object.entries(this.paths()).flatMap(([path, pathItem]) => this.endpointsOf(path, pathItem));
|
|
39
|
+
}
|
|
40
|
+
/** The path items kept in other local files, resolved against the `directory` this document sits in. */
|
|
41
|
+
pathItemReferences(directory) {
|
|
42
|
+
return Object.entries(this.paths()).flatMap(([path, pathItem]) => {
|
|
43
|
+
const reference = isJsonObject(pathItem) && typeof pathItem.$ref === 'string' ? pathItem.$ref : '';
|
|
44
|
+
const [file, pointer = ''] = reference.split('#');
|
|
45
|
+
if (file === '' || URL_SCHEME.test(file)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return [{ path, file: new FilePath(directory.resolve(dirname(file)), new FileName(basename(file))), pointer }];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** The operations of the path item `pointer` locates in this document, as they are mounted at `path`. */
|
|
52
|
+
endpointsAt(path, pointer) {
|
|
53
|
+
return this.endpointsOf(path, valueAt(this.document, pointer));
|
|
54
|
+
}
|
|
55
|
+
format() {
|
|
56
|
+
const openapi = this.document.openapi;
|
|
57
|
+
if (typeof openapi === 'string') {
|
|
58
|
+
return openapi.startsWith('3.') ? { supported: true } : { supported: false, format: `OpenAPI ${openapi}` };
|
|
59
|
+
}
|
|
60
|
+
if (this.document.swagger !== undefined) {
|
|
61
|
+
return { supported: false, format: `Swagger ${versionLabel(this.document.swagger)}` };
|
|
62
|
+
}
|
|
63
|
+
if (this.document.asyncapi !== undefined) {
|
|
64
|
+
return { supported: false, format: `AsyncAPI ${versionLabel(this.document.asyncapi)}` };
|
|
65
|
+
}
|
|
66
|
+
return { supported: false, format: null };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Both fields are written into generated files, so each is collapsed to one line. The
|
|
70
|
+
* description stops at its first blank line: past it a specification's description is
|
|
71
|
+
* usually a guide to the API, not a summary of it.
|
|
72
|
+
*/
|
|
73
|
+
suggestedSite() {
|
|
74
|
+
const info = this.document.info;
|
|
75
|
+
const fields = isJsonObject(info) ? info : {};
|
|
76
|
+
const name = oneLine(fields.title) ?? PLACEHOLDER_SITE.name;
|
|
77
|
+
const description = oneLine(firstParagraph(fields.description));
|
|
78
|
+
return { name, description: description === null ? null : cap(description, DESCRIPTION_LIMIT) };
|
|
79
|
+
}
|
|
80
|
+
paths() {
|
|
81
|
+
return isJsonObject(this.document.paths) ? this.document.paths : {};
|
|
82
|
+
}
|
|
83
|
+
endpointsOf(path, pathItem) {
|
|
84
|
+
return Object.entries(this.followLocal(pathItem, new Set()))
|
|
85
|
+
.filter(([key, value]) => HTTP_METHODS.has(key.toLowerCase()) && isJsonObject(value))
|
|
86
|
+
.map(([method]) => new Endpoint(method, path));
|
|
87
|
+
}
|
|
88
|
+
// Siblings of a `$ref` override what it points to, as the portal bundles a path item.
|
|
89
|
+
followLocal(pathItem, seen) {
|
|
90
|
+
if (!isJsonObject(pathItem)) {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
const { $ref, ...siblings } = pathItem;
|
|
94
|
+
if (typeof $ref !== 'string' || !$ref.startsWith('#') || seen.has($ref)) {
|
|
95
|
+
return siblings;
|
|
96
|
+
}
|
|
97
|
+
seen.add($ref);
|
|
98
|
+
return { ...this.followLocal(valueAt(this.document, $ref.slice(1)), seen), ...siblings };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function valueAt(document, pointer) {
|
|
102
|
+
try {
|
|
103
|
+
const segments = pointer
|
|
104
|
+
.split('/')
|
|
105
|
+
.slice(1)
|
|
106
|
+
.map((segment) => decodeURIComponent(segment));
|
|
107
|
+
return segments.reduce((node, segment) => (isJsonObject(node) ? node[segment.replace(/~1/g, '/').replace(/~0/g, '~')] : undefined), document);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function firstParagraph(value) {
|
|
114
|
+
return typeof value === 'string' ? value.trim().split(/\n\s*\n/)[0] : value;
|
|
115
|
+
}
|
|
116
|
+
// Version keys are strings in well-formed documents; anything else is named rather than
|
|
117
|
+
// stringified into `[object Object]`.
|
|
118
|
+
function versionLabel(version) {
|
|
119
|
+
return typeof version === 'string' || typeof version === 'number' ? `${version}` : '(unknown version)';
|
|
120
|
+
}
|
|
121
|
+
function oneLine(value) {
|
|
122
|
+
if (typeof value !== 'string') {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const collapsed = value.replace(/\s+/g, ' ').trim();
|
|
126
|
+
return collapsed.length > 0 ? collapsed : null;
|
|
127
|
+
}
|
|
128
|
+
// Cuts on a word boundary when one is near enough the limit, so the site description does
|
|
129
|
+
// not end mid-word.
|
|
130
|
+
function cap(value, limit) {
|
|
131
|
+
if (value.length <= limit) {
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
const cut = value.slice(0, limit);
|
|
135
|
+
const lastSpace = cut.lastIndexOf(' ');
|
|
136
|
+
return (lastSpace > limit - 40 ? cut.slice(0, lastSpace) : cut).trimEnd();
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=openapi-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-document.js","sourceRoot":"","sources":["../../../src/types/portal/openapi-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAc,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgBzC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OA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,KAAK,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CAAC,SAAS,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FileName } from '../file/fileName.js';
|
|
2
|
+
export declare const GENERATED_INCLUDES_DIRECTORY_NAME = "generated-includes";
|
|
3
|
+
export declare const SDK_DOCS_FOLDER = "sdk-docs";
|
|
4
|
+
/** One Markdown file a generated page includes, with the folder it goes in. */
|
|
5
|
+
export interface PageFragment {
|
|
6
|
+
folder: string;
|
|
7
|
+
fileName: FileName;
|
|
8
|
+
contents: string;
|
|
9
|
+
}
|
|
10
|
+
/** Where a language's SDK docs are written, from the root of the portal project. */
|
|
11
|
+
export declare function sdkDocsPath(language: string): string;
|
|
12
|
+
/** Included rather than held, so MDX compiles them as Markdown, where a `{` or `<` is only text. */
|
|
13
|
+
export declare function pageFragments(sdkDocs: ReadonlyMap<string, string>): PageFragment[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FileName } from '../file/fileName.js';
|
|
2
|
+
// Beside the generated directory, not in it: there the collection and the prerender would take each for a page.
|
|
3
|
+
export const GENERATED_INCLUDES_DIRECTORY_NAME = 'generated-includes';
|
|
4
|
+
export const SDK_DOCS_FOLDER = 'sdk-docs';
|
|
5
|
+
/** Where a language's SDK docs are written, from the root of the portal project. */
|
|
6
|
+
export function sdkDocsPath(language) {
|
|
7
|
+
return [GENERATED_INCLUDES_DIRECTORY_NAME, SDK_DOCS_FOLDER, `${sdkDocsFileName(language)}`].join('/');
|
|
8
|
+
}
|
|
9
|
+
/** Included rather than held, so MDX compiles them as Markdown, where a `{` or `<` is only text. */
|
|
10
|
+
export function pageFragments(sdkDocs) {
|
|
11
|
+
return [...sdkDocs].map(([language, markdown]) => ({
|
|
12
|
+
folder: SDK_DOCS_FOLDER,
|
|
13
|
+
fileName: sdkDocsFileName(language),
|
|
14
|
+
contents: markdownFile(markdown)
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
function sdkDocsFileName(language) {
|
|
18
|
+
return new FileName(`${language}.md`);
|
|
19
|
+
}
|
|
20
|
+
function markdownFile(text) {
|
|
21
|
+
const trimmed = text.trimEnd();
|
|
22
|
+
return trimmed.length === 0 ? '' : `${trimmed}\n`;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=page-fragments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-fragments.js","sourceRoot":"","sources":["../../../src/types/portal/page-fragments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,gHAAgH;AAChH,MAAM,CAAC,MAAM,iCAAiC,GAAG,oBAAoB,CAAC;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;AAS1C,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,CAAC,iCAAiC,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxG,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,aAAa,CAAC,OAAoC;IAChE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC;QACnC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC;KACjC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB;IACvC,OAAO,IAAI,QAAQ,CAAC,GAAG,QAAQ,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { FileName } from '../file/fileName.js';
|
|
3
|
+
export type PageRecord = Readonly<Record<string, string>>;
|
|
4
|
+
/** A page's values: strings for its placeholders, and lists of records for its sections. */
|
|
5
|
+
export type PageValues = Readonly<Record<string, string | readonly PageRecord[]>>;
|
|
6
|
+
/** Refuses a tag MDX would misread; inside a section, tags are checked per item, so an empty list checks none. */
|
|
7
|
+
export declare class PageTemplate {
|
|
8
|
+
private readonly fileName;
|
|
9
|
+
private readonly text;
|
|
10
|
+
constructor(fileName: FileName, text: string);
|
|
11
|
+
render(values: PageValues): Result<string, string>;
|
|
12
|
+
/** `scopes` runs from the page's own values to the innermost section's item, as mustache looks names up. */
|
|
13
|
+
private problemIn;
|
|
14
|
+
private problemWith;
|
|
15
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Mustache from 'mustache';
|
|
2
|
+
import { err, ok } from 'neverthrow';
|
|
3
|
+
import { errorMessage } from '../../utils/error-utils.js';
|
|
4
|
+
const KEY = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
5
|
+
/** The tags a page may use besides comments: placeholders, sections and inverted sections. */
|
|
6
|
+
const TAG_TYPES = ['name', '#', '^'];
|
|
7
|
+
// The values are MDX source, which reads its own braces and tags, so nothing is escaped.
|
|
8
|
+
const RENDER_OPTIONS = { escape: (value) => String(value) };
|
|
9
|
+
/** Refuses a tag MDX would misread; inside a section, tags are checked per item, so an empty list checks none. */
|
|
10
|
+
export class PageTemplate {
|
|
11
|
+
fileName;
|
|
12
|
+
text;
|
|
13
|
+
constructor(fileName, text) {
|
|
14
|
+
this.fileName = fileName;
|
|
15
|
+
this.text = text;
|
|
16
|
+
}
|
|
17
|
+
render(values) {
|
|
18
|
+
let tokens;
|
|
19
|
+
try {
|
|
20
|
+
tokens = Mustache.parse(this.text);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return err(`${this.fileName}: ${errorMessage(error)}`);
|
|
24
|
+
}
|
|
25
|
+
const problem = this.problemIn(tokens, [values]);
|
|
26
|
+
return problem === undefined ? ok(Mustache.render(this.text, values, {}, RENDER_OPTIONS)) : err(problem);
|
|
27
|
+
}
|
|
28
|
+
/** `scopes` runs from the page's own values to the innermost section's item, as mustache looks names up. */
|
|
29
|
+
problemIn(tokens, scopes) {
|
|
30
|
+
for (const token of tokens) {
|
|
31
|
+
const problem = this.problemWith(token, scopes);
|
|
32
|
+
if (problem !== undefined) {
|
|
33
|
+
return problem;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
problemWith(token, scopes) {
|
|
39
|
+
const [type, key, start, end] = token;
|
|
40
|
+
if (type === 'text' || type === '!') {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const tag = this.text.slice(start, end);
|
|
44
|
+
if (!TAG_TYPES.includes(type) || !KEY.test(key)) {
|
|
45
|
+
// Most likely a JSX object, `{{ ... }}`, which a space between the braces keeps out of the tags.
|
|
46
|
+
return (`${this.fileName}: '${tag}' is not a placeholder. A placeholder is {{key}} and a section ` +
|
|
47
|
+
`{{#key}}...{{/key}}; write a JSX object as '{ { ... } }'.`);
|
|
48
|
+
}
|
|
49
|
+
const value = [...scopes].reverse().find((scope) => Object.hasOwn(scope, key))?.[key];
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
return `${this.fileName}: '${tag}' names a value the page is not given.`;
|
|
52
|
+
}
|
|
53
|
+
if (type === 'name') {
|
|
54
|
+
return typeof value === 'string'
|
|
55
|
+
? undefined
|
|
56
|
+
: `${this.fileName}: '${tag}' names a list, which is written as a section, {{#${key}}}...{{/${key}}}.`;
|
|
57
|
+
}
|
|
58
|
+
// A section over a list is read once per item; any other section in the scopes it stands in.
|
|
59
|
+
const inner = token[4];
|
|
60
|
+
const itemScopes = type === '#' && typeof value !== 'string' ? value.map((item) => [...scopes, item]) : [scopes];
|
|
61
|
+
return itemScopes.map((itemScope) => this.problemIn(inner, itemScope)).find((problem) => problem !== undefined);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=page-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-template.js","sourceRoot":"","sources":["../../../src/types/portal/page-template.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQ1D,MAAM,GAAG,GAAG,yBAAyB,CAAC;AAEtC,8FAA8F;AAC9F,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAErC,yFAAyF;AACzF,MAAM,cAAc,GAAG,EAAE,MAAM,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAErE,kHAAkH;AAClH,MAAM,OAAO,YAAY;IACM,QAAQ;IAA6B,IAAI;IAAtE,YAA6B,QAAkB,EAAmB,IAAY;wBAAjD,QAAQ;oBAA6B,IAAI;IAAW,CAAC;IAE3E,MAAM,CAAC,MAAkB;QAC9B,IAAI,MAA8B,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAA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gBAC1F,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACtF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC,QAAQ,MAAM,GAAG,wCAAwC,CAAC;QAC3E,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,OAAO,KAAK,KAAK,QAAQ;gBAC9B,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,MAAM,GAAG,qDAAqD,GAAG,WAAW,GAAG,KAAK,CAAC;QAC3G,CAAC;QACD,6FAA6F;QAC7F,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAA2B,CAAC;QACjD,MAAM,UAAU,GAAG,IAAI,KAAK,GAAG,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjH,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;IAClH,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { FileName } from '../file/fileName.js';
|
|
3
|
+
/** What the build reads from a page's front matter that the CLI needs. */
|
|
4
|
+
export interface PageFrontMatter {
|
|
5
|
+
/** What the sidebar and a tab name the page by. */
|
|
6
|
+
title: string;
|
|
7
|
+
}
|
|
8
|
+
/** A Markdown image the build imports, where it looks for the file, and the path it looks up there. */
|
|
9
|
+
export interface PageImage {
|
|
10
|
+
/** As the page writes it. */
|
|
11
|
+
url: string;
|
|
12
|
+
line: number;
|
|
13
|
+
/** An image written as `/…` is read from the static directory, any other from beside its page. */
|
|
14
|
+
from: 'static' | 'page';
|
|
15
|
+
/** Decoded, without its query or fragment, with `/` between segments. */
|
|
16
|
+
path: string;
|
|
17
|
+
}
|
|
18
|
+
/** A page as the build parses it: its front matter held to the build's schema, and the images the build imports. */
|
|
19
|
+
export interface ParsedPage {
|
|
20
|
+
frontMatter: Result<PageFrontMatter, string[]>;
|
|
21
|
+
images: PageImage[];
|
|
22
|
+
}
|
|
23
|
+
/** Parsed once, as the build parses it, `.mdx` as MDX; a body that does not parse is the build's to report. */
|
|
24
|
+
export declare function parsePage(contents: string, fileName: FileName, label: string): Promise<ParsedPage>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { frontmatter } from 'fumadocs-core/content/md/frontmatter';
|
|
2
|
+
import { err, ok } from 'neverthrow';
|
|
3
|
+
import { errorMessage } from '../../utils/error-utils.js';
|
|
4
|
+
import { isJsonObject } from '../../utils/json-utils.js';
|
|
5
|
+
const EXPECTED = { string: 'text', boolean: 'true or false' };
|
|
6
|
+
// A scheme, a drive letter or a network path: none of them names a file the build imports.
|
|
7
|
+
const NOT_A_FILE = /^(?:[a-z][a-z\d+.-]*:|\/\/)/i;
|
|
8
|
+
/** Parsed once, as the build parses it, `.mdx` as MDX; a body that does not parse is the build's to report. */
|
|
9
|
+
export async function parsePage(contents, fileName, label) {
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = frontmatter(contents);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const reason = errorMessage(error).split('\n')[0];
|
|
16
|
+
return { frontMatter: err([`${label}: its front matter is not valid YAML. ${reason}`]), images: [] };
|
|
17
|
+
}
|
|
18
|
+
// Blanked rather than cut, so every line keeps its number.
|
|
19
|
+
const body = '\n'.repeat(parsed.matter.split('\n').length - 1) + contents.slice(parsed.matter.length);
|
|
20
|
+
return {
|
|
21
|
+
frontMatter: await checkedFrontMatter(parsed, label),
|
|
22
|
+
images: await imagesIn(body, fileName.hasExactExtension('.mdx'))
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Held to the build's own schema, which fails the whole build over one page. */
|
|
26
|
+
async function checkedFrontMatter({ matter, data }, label) {
|
|
27
|
+
if (matter.length === 0) {
|
|
28
|
+
return err([`${label} has no front matter, which is where its title goes.`]);
|
|
29
|
+
}
|
|
30
|
+
// On first use: zod, which the schema is written in, adds a tenth of a second to every command's start.
|
|
31
|
+
const { pageSchema: schema } = await import('fumadocs-core/source/schema');
|
|
32
|
+
const fields = isJsonObject(data) ? data : {};
|
|
33
|
+
const checked = schema.safeParse(fields);
|
|
34
|
+
if (!checked.success) {
|
|
35
|
+
return err(checked.error.issues.map((issue) => describeIssue(issue, fields, label)));
|
|
36
|
+
}
|
|
37
|
+
// The schema takes an empty title, and the page is then a blank entry in the sidebar.
|
|
38
|
+
if (checked.data.title.trim().length === 0) {
|
|
39
|
+
return err([`${label}: 'title' must not be empty.`]);
|
|
40
|
+
}
|
|
41
|
+
return ok({ title: checked.data.title });
|
|
42
|
+
}
|
|
43
|
+
function describeIssue(issue, fields, label) {
|
|
44
|
+
const field = issue.path.join('.');
|
|
45
|
+
if (field === 'title') {
|
|
46
|
+
return titleError(fields.title, label);
|
|
47
|
+
}
|
|
48
|
+
const expected = issue.code === 'invalid_type' ? EXPECTED[issue.expected] : undefined;
|
|
49
|
+
return expected === undefined
|
|
50
|
+
? `${label}: '${field}': ${issue.message}.`
|
|
51
|
+
: `${label}: '${field}' must be ${expected}.`;
|
|
52
|
+
}
|
|
53
|
+
function titleError(title, label) {
|
|
54
|
+
if (title === undefined) {
|
|
55
|
+
return `${label} has no 'title' in its front matter.`;
|
|
56
|
+
}
|
|
57
|
+
if (title === null) {
|
|
58
|
+
return `${label}: 'title' must not be empty.`;
|
|
59
|
+
}
|
|
60
|
+
return `${label}: 'title' must be text. Put it in quotes if it looks like a number or true or false.`;
|
|
61
|
+
}
|
|
62
|
+
async function imagesIn(body, isMdx) {
|
|
63
|
+
// On first use, as the schema is: most commands never read a page.
|
|
64
|
+
const { remark } = await import('remark');
|
|
65
|
+
const processor = isMdx ? remark().use((await import('remark-mdx')).default) : remark();
|
|
66
|
+
let tree;
|
|
67
|
+
try {
|
|
68
|
+
tree = processor.parse(body);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const images = [];
|
|
74
|
+
const visit = (node) => {
|
|
75
|
+
const image = node.type === 'image' && node.url !== undefined ? located(node.url) : null;
|
|
76
|
+
if (image !== null) {
|
|
77
|
+
images.push({ ...image, line: node.position?.start.line ?? 0 });
|
|
78
|
+
}
|
|
79
|
+
node.children?.forEach(visit);
|
|
80
|
+
};
|
|
81
|
+
visit(tree);
|
|
82
|
+
return images;
|
|
83
|
+
}
|
|
84
|
+
function located(url) {
|
|
85
|
+
const address = url.split(/[?#]/, 1)[0];
|
|
86
|
+
if (address.length === 0 || address.endsWith('/') || NOT_A_FILE.test(address)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const path = decodedAddress(address);
|
|
90
|
+
return path.startsWith('/') ? { url, from: 'static', path: path.replace(/^\/+/, '') } : { url, from: 'page', path };
|
|
91
|
+
}
|
|
92
|
+
function decodedAddress(address) {
|
|
93
|
+
try {
|
|
94
|
+
return decodeURI(address);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return address;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sour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,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FilePath } from '../file/filePath.js';
|
|
2
|
+
import { CodeSampleCatalogs } from './code-samples.js';
|
|
3
|
+
/**
|
|
4
|
+
* What one `/portal-artifacts` run delivered, unpacked and read but not yet placed. The samples
|
|
5
|
+
* and the SDK docs are in memory because the build merges or includes them; the SDKs and the
|
|
6
|
+
* plugin are still files, because placing them is copying them.
|
|
7
|
+
*
|
|
8
|
+
* The paths point inside the directory the caller handed to `generate`, so they live exactly as
|
|
9
|
+
* long as that directory does.
|
|
10
|
+
*/
|
|
11
|
+
export declare class PortalArtifacts {
|
|
12
|
+
readonly codeSampleCatalogs: CodeSampleCatalogs;
|
|
13
|
+
/** Keyed by the language name the server delivered, which is what it is placed under. */
|
|
14
|
+
readonly sdks: ReadonlyMap<string, FilePath>;
|
|
15
|
+
/** Each language's getting-started Markdown, keyed as `sdks` is. */
|
|
16
|
+
readonly sdkDocs: ReadonlyMap<string, string>;
|
|
17
|
+
readonly plugin: FilePath | undefined;
|
|
18
|
+
constructor(codeSampleCatalogs: CodeSampleCatalogs,
|
|
19
|
+
/** Keyed by the language name the server delivered, which is what it is placed under. */
|
|
20
|
+
sdks: ReadonlyMap<string, FilePath>,
|
|
21
|
+
/** Each language's getting-started Markdown, keyed as `sdks` is. */
|
|
22
|
+
sdkDocs: ReadonlyMap<string, string>, plugin: FilePath | undefined);
|
|
23
|
+
/** A run that was never made: a portal declaring no languages and no plugin has nothing to ask for. */
|
|
24
|
+
static none(): PortalArtifacts;
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CodeSampleCatalogs } from './code-samples.js';
|
|
2
|
+
/**
|
|
3
|
+
* What one `/portal-artifacts` run delivered, unpacked and read but not yet placed. The samples
|
|
4
|
+
* and the SDK docs are in memory because the build merges or includes them; the SDKs and the
|
|
5
|
+
* plugin are still files, because placing them is copying them.
|
|
6
|
+
*
|
|
7
|
+
* The paths point inside the directory the caller handed to `generate`, so they live exactly as
|
|
8
|
+
* long as that directory does.
|
|
9
|
+
*/
|
|
10
|
+
export class PortalArtifacts {
|
|
11
|
+
codeSampleCatalogs;
|
|
12
|
+
sdks;
|
|
13
|
+
sdkDocs;
|
|
14
|
+
plugin;
|
|
15
|
+
constructor(codeSampleCatalogs,
|
|
16
|
+
/** Keyed by the language name the server delivered, which is what it is placed under. */
|
|
17
|
+
sdks,
|
|
18
|
+
/** Each language's getting-started Markdown, keyed as `sdks` is. */
|
|
19
|
+
sdkDocs, plugin) {
|
|
20
|
+
this.codeSampleCatalogs = codeSampleCatalogs;
|
|
21
|
+
this.sdks = sdks;
|
|
22
|
+
this.sdkDocs = sdkDocs;
|
|
23
|
+
this.plugin = plugin;
|
|
24
|
+
}
|
|
25
|
+
/** A run that was never made: a portal declaring no languages and no plugin has nothing to ask for. */
|
|
26
|
+
static none() {
|
|
27
|
+
return new PortalArtifacts(new CodeSampleCatalogs([]), new Map(), new Map(), undefined);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=portal-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-artifacts.js","sourceRoot":"","sources":["../../../src/types/portal/portal-artifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAER,kBAAkB;IAElB,IAAI;IAEJ,OAAO;IACP,MAAM;IANxB,YACkB,kBAAsC;IACtD,yFAAyF;IACzE,IAAmC;IACnD,oEAAoE;IACpD,OAAoC,EACpC,MAA4B;kCAL5B,kBAAkB;oBAElB,IAAI;uBAEJ,OAAO;sBACP,MAAM;IACrB,CAAC;IAEJ,uGAAuG;IAChG,MAAM,CAAC,IAAI;QAChB,OAAO,IAAI,eAAe,CAAC,IAAI,kBAAkB,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAC1F,CAAC;CACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { UrlPath } from '../file/urlPath.js';
|
|
3
|
+
import { AiConfig } from './config/ai-config.js';
|
|
4
|
+
import { BrandConfig, ColorMode } from './config/brand-config.js';
|
|
5
|
+
import { NavigationConfig } from './config/navigation-config.js';
|
|
6
|
+
import { SiteConfig, SuggestedSite } from './config/site-config.js';
|
|
7
|
+
import { StaticAsset } from './config/static-asset.js';
|
|
8
|
+
export interface PortalLink {
|
|
9
|
+
label: string;
|
|
10
|
+
url: string;
|
|
11
|
+
/** Whether it leaves the portal, which opens it in a new tab. */
|
|
12
|
+
external: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What the browser bundle is told about the portal, written to `portal.identity.json`. Nothing
|
|
16
|
+
* here may address the machine the portal was built on. `portal-template/src/lib/portal-types.ts`
|
|
17
|
+
* declares the same type, and test/portal-template.test.ts holds the two equal.
|
|
18
|
+
*/
|
|
19
|
+
export interface PortalIdentity {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
/** Origin only, with no trailing slash. */
|
|
23
|
+
siteUrl: string | null;
|
|
24
|
+
/** Site-relative, one per colour mode; the same URL twice when one image serves both. */
|
|
25
|
+
logo: {
|
|
26
|
+
light: string;
|
|
27
|
+
dark: string;
|
|
28
|
+
} | null;
|
|
29
|
+
/** Site-relative, with the image type its extension names, when it names one. */
|
|
30
|
+
favicon: {
|
|
31
|
+
url: string;
|
|
32
|
+
type: string | null;
|
|
33
|
+
} | null;
|
|
34
|
+
colorMode: ColorMode;
|
|
35
|
+
links: PortalLink[];
|
|
36
|
+
/** Whether each page offers to open itself in an external AI assistant. */
|
|
37
|
+
pageActions: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare class PortalConfig {
|
|
40
|
+
private readonly site;
|
|
41
|
+
private readonly brand;
|
|
42
|
+
private readonly navigation;
|
|
43
|
+
private readonly ai;
|
|
44
|
+
private readonly pluginAddress;
|
|
45
|
+
private constructor();
|
|
46
|
+
/** The block quickstart writes: the specification's own name and description, and every default spelled out. */
|
|
47
|
+
static scaffolded(site: SuggestedSite): PortalConfig;
|
|
48
|
+
/**
|
|
49
|
+
* `block` is whatever the file holds under `portal`. `suggested` is what the only specification
|
|
50
|
+
* says about itself, or null when there are several; it fills the site's name and description
|
|
51
|
+
* when the block leaves them out.
|
|
52
|
+
*/
|
|
53
|
+
static fromBlock(block: unknown, suggested: SuggestedSite | null): Result<PortalConfig, string[]>;
|
|
54
|
+
siteTitle(): string;
|
|
55
|
+
/** Where the context plugin is hosted when it is not bundled into the portal, or null when it is. */
|
|
56
|
+
pluginUrl(): UrlPath | null;
|
|
57
|
+
brandSettings(): BrandConfig;
|
|
58
|
+
staticFiles(): StaticAsset[];
|
|
59
|
+
identity(): PortalIdentity;
|
|
60
|
+
/** Every namespace included, defaults and all, which is what quickstart writes. */
|
|
61
|
+
toJSON(): PortalBlock;
|
|
62
|
+
}
|
|
63
|
+
export interface PortalBlock {
|
|
64
|
+
site: ReturnType<SiteConfig['toJSON']>;
|
|
65
|
+
brand: ReturnType<BrandConfig['toJSON']>;
|
|
66
|
+
navigation: ReturnType<NavigationConfig['toJSON']>;
|
|
67
|
+
ai: ReturnType<AiConfig['toJSON']>;
|
|
68
|
+
pluginUrl?: string;
|
|
69
|
+
}
|