@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
|
@@ -1,30 +1,231 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { err, ok } from 'neverthrow';
|
|
2
|
+
import { getAuthInfo } from '../client-utils/auth-manager.js';
|
|
3
|
+
import { FileService } from '../infrastructure/file-service.js';
|
|
4
|
+
import { withDirPath } from '../infrastructure/tmp-extensions.js';
|
|
5
|
+
import { QuickstartPrompts } from '../prompts/quickstart.js';
|
|
6
|
+
import { UrlPath } from '../types/file/urlPath.js';
|
|
7
|
+
import { LoginAction } from './auth/login.js';
|
|
8
|
+
import { ActionResult } from './action-result.js';
|
|
9
|
+
import { ValidateAction } from './api/validate.js';
|
|
10
|
+
import { SpecContext } from '../types/spec-context.js';
|
|
11
|
+
import { OpenApiDocument } from '../types/portal/openapi-document.js';
|
|
12
|
+
import { PortalAuthorizationService } from '../infrastructure/services/portal-authorization-service.js';
|
|
13
|
+
import { FileDownloadService } from '../infrastructure/services/file-download-service.js';
|
|
14
|
+
import { PortalProjectService } from '../infrastructure/portal-project-service.js';
|
|
15
|
+
import { envInfo } from '../infrastructure/env-info.js';
|
|
16
|
+
import { schemaUrlFor } from '../types/apimatic-config/document.js';
|
|
17
|
+
import { PLACEHOLDER_METADATA } from '../types/plugin/plugin-config.js';
|
|
18
|
+
import { ProjectContext } from '../types/project-context.js';
|
|
19
|
+
import { DEFAULT_PORTAL_PORT, PortalServeAction } from './portal/serve.js';
|
|
5
20
|
export class QuickstartAction {
|
|
21
|
+
prompts = new QuickstartPrompts();
|
|
22
|
+
fileService = new FileService();
|
|
23
|
+
fileDownloadService = new FileDownloadService();
|
|
24
|
+
authorizationService = new PortalAuthorizationService();
|
|
25
|
+
projectService = new PortalProjectService();
|
|
26
|
+
configDir;
|
|
27
|
+
commandMetadata;
|
|
28
|
+
defaultSpecUrl = new UrlPath(`https://raw.githubusercontent.com/apimatic/sample-docs-as-code-portal/refs/heads/v2/src/spec/openapi.json`);
|
|
6
29
|
constructor(configDir, commandMetadata) {
|
|
7
30
|
this.configDir = configDir;
|
|
8
31
|
this.commandMetadata = commandMetadata;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
}
|
|
33
|
+
execute = async (workingDirectory) => {
|
|
34
|
+
this.prompts.welcomeMessage();
|
|
35
|
+
// Asked before anything is written: the user's next command is `portal serve`, which
|
|
36
|
+
// refuses an installation missing the portal build's dependencies, and learning that after
|
|
37
|
+
// the wizard leaves a tree to clean up.
|
|
38
|
+
const runtimeProblem = this.projectService.runtimeProblem();
|
|
39
|
+
if (runtimeProblem !== null) {
|
|
40
|
+
this.prompts.runtimeUnsupported(runtimeProblem);
|
|
41
|
+
return ActionResult.failed();
|
|
42
|
+
}
|
|
43
|
+
const storedAuth = await getAuthInfo(this.configDir.toString());
|
|
44
|
+
if (!storedAuth?.authKey) {
|
|
45
|
+
const loginResult = await new LoginAction(this.configDir, this.commandMetadata).execute();
|
|
46
|
+
if (loginResult.isFailed()) {
|
|
47
|
+
return ActionResult.failed();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Checked before any question is asked: `portal serve`, the next command, refuses without
|
|
51
|
+
// this entitlement.
|
|
52
|
+
const authorization = await this.authorizationService.authorize(this.configDir, this.commandMetadata.shell, null);
|
|
53
|
+
if (authorization.isErr()) {
|
|
54
|
+
this.prompts.authorizationFailed(authorization.error);
|
|
55
|
+
return ActionResult.failed();
|
|
56
|
+
}
|
|
57
|
+
return await withDirPath((tempDirectory) => this.runWizard(workingDirectory, tempDirectory));
|
|
58
|
+
};
|
|
59
|
+
async runWizard(workingDirectory, tempDirectory) {
|
|
60
|
+
const here = ProjectContext.in(workingDirectory);
|
|
61
|
+
const adoptedSpec = await here.portalSource().primarySpec();
|
|
62
|
+
return adoptedSpec === null
|
|
63
|
+
? await this.startProject(tempDirectory)
|
|
64
|
+
: await this.adoptProject(here, workingDirectory, adoptedSpec, tempDirectory);
|
|
65
|
+
}
|
|
66
|
+
// A build downloaded from the platform arrives with its specification in `src/spec/`, so it is not asked for again.
|
|
67
|
+
async adoptProject(project, projectDirectory, specPath, tempDirectory) {
|
|
68
|
+
this.prompts.importSpecStepAdopted(project.sourceDirectory());
|
|
69
|
+
const validated = await this.validate({ file: specPath, source: specPath }, tempDirectory, true);
|
|
70
|
+
if (validated.isErr()) {
|
|
71
|
+
return validated.error;
|
|
72
|
+
}
|
|
73
|
+
this.prompts.createPortalStep();
|
|
74
|
+
const scaffolded = await project.portalSource().adopt(validated.value, schemaUrlFor(envInfo.getCLIVersion()));
|
|
75
|
+
return await this.completeProject(project, projectDirectory, scaffolded);
|
|
76
|
+
}
|
|
77
|
+
async startProject(tempDirectory) {
|
|
78
|
+
this.prompts.importSpecStep();
|
|
79
|
+
const imported = await this.importSpec(tempDirectory);
|
|
80
|
+
if (imported === undefined) {
|
|
81
|
+
return ActionResult.cancelled();
|
|
82
|
+
}
|
|
83
|
+
const validated = await this.validate(imported, tempDirectory, false);
|
|
84
|
+
if (validated.isErr()) {
|
|
85
|
+
return validated.error;
|
|
86
|
+
}
|
|
87
|
+
this.prompts.createPortalStep();
|
|
88
|
+
const projectDirectory = await this.chooseProjectDirectory();
|
|
89
|
+
if (projectDirectory === undefined) {
|
|
90
|
+
return ActionResult.cancelled();
|
|
91
|
+
}
|
|
92
|
+
const project = ProjectContext.in(projectDirectory);
|
|
93
|
+
const scaffolded = await project.portalSource().scaffold(validated.value, schemaUrlFor(envInfo.getCLIVersion()));
|
|
94
|
+
return await this.completeProject(project, projectDirectory, scaffolded);
|
|
95
|
+
}
|
|
96
|
+
async completeProject(project, projectDirectory, scaffolded) {
|
|
97
|
+
const sourceDirectory = project.sourceDirectory();
|
|
98
|
+
if (scaffolded.isErr()) {
|
|
99
|
+
this.prompts.scaffoldFailed(scaffolded.error, sourceDirectory);
|
|
100
|
+
return ActionResult.failed();
|
|
101
|
+
}
|
|
102
|
+
const selection = await this.prompts.selectLanguages();
|
|
103
|
+
if (!selection?.length) {
|
|
104
|
+
this.prompts.noLanguagesSelected();
|
|
105
|
+
return ActionResult.cancelled();
|
|
106
|
+
}
|
|
107
|
+
const pluginConfig = project.pluginConfig();
|
|
108
|
+
const languagesRecorded = await pluginConfig.recordLanguages(selection);
|
|
109
|
+
const pluginConfigRecorded = languagesRecorded.isErr()
|
|
110
|
+
? languagesRecorded
|
|
111
|
+
: await pluginConfig.upsertMetadata(PLACEHOLDER_METADATA);
|
|
112
|
+
if (pluginConfigRecorded.isErr()) {
|
|
113
|
+
this.prompts.configNotWritten(pluginConfigRecorded.error, sourceDirectory);
|
|
114
|
+
return ActionResult.failed();
|
|
115
|
+
}
|
|
116
|
+
// Reported rather than fatal: what Git tracks does not decide whether a portal can be built.
|
|
117
|
+
const ignored = await project.upsertGitignore();
|
|
118
|
+
if (ignored.isErr()) {
|
|
119
|
+
this.prompts.gitignoreNotUpdated(ignored.error, projectDirectory);
|
|
120
|
+
}
|
|
121
|
+
const structure = await this.fileService.getDirectory(sourceDirectory);
|
|
122
|
+
this.prompts.printDirectoryStructure(projectDirectory, structure);
|
|
123
|
+
const result = await new PortalServeAction(this.configDir, this.commandMetadata, null).execute(project, DEFAULT_PORTAL_PORT, true, () => this.prompts.nextSteps(scaffolded.value));
|
|
124
|
+
return result.isFailed() ? ActionResult.failed() : ActionResult.success();
|
|
125
|
+
}
|
|
126
|
+
async importSpec(tempDirectory) {
|
|
127
|
+
// Dropped once the CLI's own sample has failed: re-offering the address the user just
|
|
128
|
+
// watched fail, pre-filled, is the one suggestion that cannot work.
|
|
129
|
+
let sampleUrl = this.defaultSpecUrl;
|
|
130
|
+
for (;;) {
|
|
131
|
+
const inputPath = await this.prompts.specPathPrompt(sampleUrl);
|
|
132
|
+
if (!inputPath) {
|
|
133
|
+
this.prompts.noSpecSpecified();
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
if (inputPath instanceof UrlPath) {
|
|
137
|
+
const downloaded = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(inputPath));
|
|
138
|
+
if (downloaded.isErr()) {
|
|
139
|
+
this.prompts.specDownloadFailed(inputPath, downloaded.error);
|
|
140
|
+
if (sampleUrl !== null && inputPath.isEqual(sampleUrl)) {
|
|
141
|
+
sampleUrl = null;
|
|
142
|
+
}
|
|
143
|
+
continue;
|
|
25
144
|
}
|
|
145
|
+
const file = await new SpecContext(tempDirectory).save(downloaded.value.stream, downloaded.value.filename);
|
|
146
|
+
return { file, source: inputPath };
|
|
147
|
+
}
|
|
148
|
+
if (await this.fileService.fileExists(inputPath)) {
|
|
149
|
+
return { file: inputPath, source: inputPath };
|
|
150
|
+
}
|
|
151
|
+
this.prompts.specFileDoesNotExist();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* `adopted` decides what a failure offers. The sample can replace a specification the user
|
|
156
|
+
* named, but not one their project carries: an adopted `spec/` already holds the document the
|
|
157
|
+
* portal would be built from, and nothing here moves the sample into it.
|
|
158
|
+
*/
|
|
159
|
+
async validate(spec, tempDirectory, adopted) {
|
|
160
|
+
this.prompts.validateSpecStep();
|
|
161
|
+
let validation = 'unchecked';
|
|
162
|
+
await new ValidateAction(this.configDir, this.commandMetadata).execute(spec.file, false, (check) => {
|
|
163
|
+
validation = check;
|
|
164
|
+
});
|
|
165
|
+
// The service's own error is already on screen; the spec may be valid, so there is nothing to fix.
|
|
166
|
+
if (validation === 'unchecked') {
|
|
167
|
+
return err(ActionResult.failed());
|
|
168
|
+
}
|
|
169
|
+
let checked = spec.file;
|
|
170
|
+
if (validation === 'invalid') {
|
|
171
|
+
this.prompts.specValidationFailed(spec.source);
|
|
172
|
+
if (adopted || !(await this.prompts.useDefaultSpecPrompt())) {
|
|
173
|
+
this.prompts.fixYourSpec();
|
|
174
|
+
return err(ActionResult.cancelled());
|
|
175
|
+
}
|
|
176
|
+
const downloaded = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(this.defaultSpecUrl));
|
|
177
|
+
if (downloaded.isErr()) {
|
|
178
|
+
this.prompts.serviceError(downloaded.error);
|
|
179
|
+
return err(ActionResult.failed());
|
|
180
|
+
}
|
|
181
|
+
checked = await new SpecContext(tempDirectory).save(downloaded.value.stream, downloaded.value.filename);
|
|
182
|
+
}
|
|
183
|
+
// The validation above accepts Swagger 2.0, which a portal cannot be built from. Asked
|
|
184
|
+
// here rather than left to `portal serve`, which refuses only once the project is
|
|
185
|
+
// written -- and running the wizard again then rejects the non-empty tree it created.
|
|
186
|
+
const format = await this.specFormat(checked);
|
|
187
|
+
if (!format.supported) {
|
|
188
|
+
if (format.format === null) {
|
|
189
|
+
this.prompts.specNotRecognised(checked);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
this.prompts.specFormatUnsupported(checked, format.format);
|
|
193
|
+
}
|
|
194
|
+
return err(ActionResult.failed());
|
|
195
|
+
}
|
|
196
|
+
return ok(checked);
|
|
197
|
+
}
|
|
198
|
+
async chooseProjectDirectory() {
|
|
199
|
+
for (;;) {
|
|
200
|
+
const projectDirectory = await this.prompts.projectDirectoryPrompt();
|
|
201
|
+
if (!projectDirectory) {
|
|
202
|
+
this.prompts.noProjectDirectoryProvided();
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
if (!(await this.fileService.directoryExists(projectDirectory))) {
|
|
206
|
+
this.prompts.projectDirectoryDoesNotExist(projectDirectory);
|
|
207
|
+
}
|
|
208
|
+
else if (!(await this.fileService.directoryEmpty(projectDirectory))) {
|
|
209
|
+
this.prompts.projectDirectoryNotEmpty(projectDirectory);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return projectDirectory;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// A split specification arrives as an archive, and a file that cannot be read is left to
|
|
217
|
+
// the build too, which says so with the file in front of it.
|
|
218
|
+
async specFormat(specPath) {
|
|
219
|
+
try {
|
|
220
|
+
if (await this.fileService.isZipFile(specPath)) {
|
|
221
|
+
return { supported: true };
|
|
26
222
|
}
|
|
27
|
-
|
|
223
|
+
const document = OpenApiDocument.parse(specPath.name(), await this.fileService.getContents(specPath));
|
|
224
|
+
return document === undefined ? { supported: true } : document.format();
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return { supported: true };
|
|
228
|
+
}
|
|
28
229
|
}
|
|
29
230
|
}
|
|
30
231
|
//# sourceMappingURL=quickstart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../src/actions/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../src/actions/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,E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{ ActionResult } from '../action-result.js';
|
|
3
3
|
import { CommandMetadata } from '../../types/common/command-metadata.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Language, Stability } from '../../types/sdk/generate.js';
|
|
5
|
+
import { ProjectContext } from '../../types/project-context.js';
|
|
6
6
|
export declare class GenerateAction {
|
|
7
7
|
private readonly prompts;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly sdkGenerationService;
|
|
9
9
|
private readonly configDir;
|
|
10
10
|
private readonly commandMetadata;
|
|
11
11
|
private readonly authKey;
|
|
12
12
|
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
|
|
13
|
-
readonly execute: (
|
|
14
|
-
sourceTreeTrackingInitiated: boolean;
|
|
15
|
-
conflictsResolved: boolean;
|
|
16
|
-
}>>;
|
|
13
|
+
readonly execute: (project: ProjectContext, sdkDirectory: DirectoryPath, language: Language, stability: Stability, force: boolean, zipSdk: boolean, apiVersion?: string, packageSettingsDirectory?: DirectoryPath) => Promise<ActionResult>;
|
|
17
14
|
}
|
|
@@ -1,105 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SdkGenerationService } from '../../infrastructure/services/sdk-generation-service.js';
|
|
2
2
|
import { ActionResult } from '../action-result.js';
|
|
3
3
|
import { withDirPath } from '../../infrastructure/tmp-extensions.js';
|
|
4
|
-
import { SdkContext } from '../../types/sdk-context.js';
|
|
5
4
|
import { SdkGeneratePrompts } from '../../prompts/sdk/generate.js';
|
|
6
5
|
import { TempContext } from '../../types/temp-context.js';
|
|
7
|
-
import {
|
|
8
|
-
import { BuildContext } from '../../types/build-context.js';
|
|
6
|
+
import { isAvailableLanguage } from '../../types/sdk/generate.js';
|
|
9
7
|
export class GenerateAction {
|
|
8
|
+
prompts = new SdkGeneratePrompts();
|
|
9
|
+
sdkGenerationService = new SdkGenerationService();
|
|
10
|
+
configDir;
|
|
11
|
+
commandMetadata;
|
|
12
|
+
authKey;
|
|
10
13
|
constructor(configDir, commandMetadata, authKey = null) {
|
|
11
|
-
this.prompts = new SdkGeneratePrompts();
|
|
12
|
-
this.portalService = new PortalService();
|
|
13
|
-
this.execute = async (buildDirectory, destinationSdkDirectory, language, force, zipSdk, skipChanges, trackChanges, codegenOption, stabilityWasProvided, apiVersion, packageVersion, packageSettingsDirectory) => {
|
|
14
|
-
this.prompts.warnIfStabilityIgnored(codegenOption, stabilityWasProvided);
|
|
15
|
-
if (buildDirectory.isEqual(destinationSdkDirectory)) {
|
|
16
|
-
this.prompts.sameBuildAndSdkDir(buildDirectory);
|
|
17
|
-
return ActionResult.failed();
|
|
18
|
-
}
|
|
19
|
-
const rootBuildContext = new BuildContext(buildDirectory);
|
|
20
|
-
if (!(await rootBuildContext.exists())) {
|
|
21
|
-
this.prompts.srcDirectoryEmpty(buildDirectory);
|
|
22
|
-
return ActionResult.failed();
|
|
23
|
-
}
|
|
24
|
-
const versionedContextGetter = async () => {
|
|
25
|
-
if (!(await rootBuildContext.isVersionedBuild())) {
|
|
26
|
-
if (apiVersion)
|
|
27
|
-
this.prompts.apiVersionOnlyApplicableWithVersionedBuild();
|
|
28
|
-
return { version: undefined, buildContext: rootBuildContext };
|
|
29
|
-
}
|
|
30
|
-
const versionedBuildDirectory = await rootBuildContext.getVersionedBuildDirectory();
|
|
31
|
-
if (!versionedBuildDirectory) {
|
|
32
|
-
this.prompts.invalidVersionedDocsDirectory(buildDirectory);
|
|
33
|
-
return ActionResult.failed();
|
|
34
|
-
}
|
|
35
|
-
const singleVersionedBuildDirectory = await rootBuildContext.getSingleVersionedBuildDirectory();
|
|
36
|
-
if (!apiVersion && singleVersionedBuildDirectory) {
|
|
37
|
-
return {
|
|
38
|
-
version: singleVersionedBuildDirectory.leafName(),
|
|
39
|
-
buildContext: new BuildContext(singleVersionedBuildDirectory)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
const selectedVersionedBuildDirectory = await rootBuildContext.getSelectedVersionedBuildDirectory(apiVersion ? async () => apiVersion : this.prompts.selectVersion);
|
|
43
|
-
if (!selectedVersionedBuildDirectory) {
|
|
44
|
-
this.prompts.versionNotFound();
|
|
45
|
-
return ActionResult.failed();
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
version: selectedVersionedBuildDirectory.leafName(),
|
|
49
|
-
buildContext: new BuildContext(selectedVersionedBuildDirectory)
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
const versionedContext = await versionedContextGetter();
|
|
53
|
-
if (versionedContext instanceof ActionResult) {
|
|
54
|
-
return versionedContext;
|
|
55
|
-
}
|
|
56
|
-
const { version, buildContext } = versionedContext;
|
|
57
|
-
if (!(await buildContext.getSpecContext().validate())) {
|
|
58
|
-
this.prompts.specDirectoryEmpty(buildDirectory);
|
|
59
|
-
return ActionResult.failed();
|
|
60
|
-
}
|
|
61
|
-
const hasSdkSourceTree = await buildContext.hasSdkSourceTree(language);
|
|
62
|
-
const sdkContext = new SdkContext(language, destinationSdkDirectory, skipChanges && hasSdkSourceTree, version);
|
|
63
|
-
if (!force && (await sdkContext.exists()) && !(await this.prompts.overwriteSdk(destinationSdkDirectory))) {
|
|
64
|
-
this.prompts.destinationDirNotEmpty();
|
|
65
|
-
return ActionResult.cancelled();
|
|
66
|
-
}
|
|
67
|
-
return await withDirPath(async (tempDirectory) => {
|
|
68
|
-
const tempContext = new TempContext(tempDirectory);
|
|
69
|
-
const buildZipPath = await buildContext.getBuildZipPath(tempDirectory, packageSettingsDirectory);
|
|
70
|
-
if (codegenOption.isV4()) {
|
|
71
|
-
this.prompts.sdkCustomizationsNotSupportedForV4();
|
|
72
|
-
const response = await this.prompts.generateV4SDK(this.portalService.generateV4Sdk(buildZipPath, language, codegenOption.stabilityLevel(), this.configDir, this.commandMetadata, this.authKey));
|
|
73
|
-
if (response.isErr()) {
|
|
74
|
-
this.prompts.sdkGenerationServiceError(response.error);
|
|
75
|
-
return ActionResult.failed();
|
|
76
|
-
}
|
|
77
|
-
const responseSdkZipPath = await tempContext.save(response.value);
|
|
78
|
-
const tempSdk = await sdkContext.loadSdkInTempDirectory(tempDirectory, responseSdkZipPath);
|
|
79
|
-
this.prompts.sdkGenerated(await sdkContext.save(tempSdk, zipSdk));
|
|
80
|
-
return ActionResult.success();
|
|
81
|
-
}
|
|
82
|
-
const response = await this.prompts.generateSDK(this.portalService.generateSdk(buildZipPath, language, this.configDir, this.commandMetadata, this.authKey, packageVersion));
|
|
83
|
-
if (response.isErr()) {
|
|
84
|
-
this.prompts.sdkGenerationServiceError(response.error);
|
|
85
|
-
return ActionResult.failed();
|
|
86
|
-
}
|
|
87
|
-
const responseSdkZipPath = await tempContext.save(response.value.sdk);
|
|
88
|
-
const tempSdk = await sdkContext.loadSdkInTempDirectory(tempDirectory, responseSdkZipPath);
|
|
89
|
-
if (!trackChanges && !hasSdkSourceTree) {
|
|
90
|
-
this.prompts.sdkGenerated(await sdkContext.save(tempSdk, zipSdk));
|
|
91
|
-
return ActionResult.success();
|
|
92
|
-
}
|
|
93
|
-
const sdkSourceTreeTempFilePath = await tempContext.save(response.value.sdkSourceTree);
|
|
94
|
-
const tempSdkWithSourceTree = await sdkContext.loadSdkWithSourceTreeInTempDirectory(tempDirectory, responseSdkZipPath, sdkSourceTreeTempFilePath);
|
|
95
|
-
const destinationSourceTreePath = buildContext.getSdkSourceTree(language);
|
|
96
|
-
const mergeSourceTree = new MergeSourceTreeAction();
|
|
97
|
-
return await mergeSourceTree.execute(tempSdkWithSourceTree, tempSdk, destinationSourceTreePath, trackChanges, skipChanges, hasSdkSourceTree, language, destinationSdkDirectory, version, zipSdk);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
14
|
this.configDir = configDir;
|
|
101
15
|
this.commandMetadata = commandMetadata;
|
|
102
16
|
this.authKey = authKey;
|
|
103
17
|
}
|
|
18
|
+
execute = async (project, sdkDirectory, language, stability, force, zipSdk, apiVersion, packageSettingsDirectory) => {
|
|
19
|
+
if (!isAvailableLanguage(language)) {
|
|
20
|
+
this.prompts.languageNotAvailable(language);
|
|
21
|
+
return ActionResult.failed();
|
|
22
|
+
}
|
|
23
|
+
const sourceDirectory = project.sourceDirectory();
|
|
24
|
+
if (project.isSourceDirectory(sdkDirectory)) {
|
|
25
|
+
this.prompts.sameSourceAndSdkDir(sourceDirectory);
|
|
26
|
+
return ActionResult.failed();
|
|
27
|
+
}
|
|
28
|
+
if (!(await project.sourceExists())) {
|
|
29
|
+
this.prompts.sourceDirectoryEmpty(sourceDirectory);
|
|
30
|
+
return ActionResult.failed();
|
|
31
|
+
}
|
|
32
|
+
if (apiVersion && !(await project.isVersioned())) {
|
|
33
|
+
this.prompts.apiVersionOnlyApplicableWithVersionedBuild();
|
|
34
|
+
}
|
|
35
|
+
const toBuild = await project.versionToBuild(apiVersion, this.prompts.selectVersion);
|
|
36
|
+
if (toBuild.isErr()) {
|
|
37
|
+
this.prompts.noVersionToBuild(toBuild.error, sourceDirectory);
|
|
38
|
+
return ActionResult.failed();
|
|
39
|
+
}
|
|
40
|
+
const buildFrom = toBuild.value;
|
|
41
|
+
if (!(await buildFrom.specsExist())) {
|
|
42
|
+
this.prompts.specDirectoryEmpty(sourceDirectory);
|
|
43
|
+
return ActionResult.failed();
|
|
44
|
+
}
|
|
45
|
+
const sdkContext = buildFrom.sdk(language, sdkDirectory);
|
|
46
|
+
if (!force && (await sdkContext.exists()) && !(await this.prompts.overwriteSdk(sdkDirectory))) {
|
|
47
|
+
this.prompts.destinationDirNotEmpty();
|
|
48
|
+
return ActionResult.cancelled();
|
|
49
|
+
}
|
|
50
|
+
return await withDirPath(async (tempDirectory) => {
|
|
51
|
+
const tempContext = new TempContext(tempDirectory);
|
|
52
|
+
const buildZipPath = await buildFrom.buildZip(tempDirectory, packageSettingsDirectory);
|
|
53
|
+
const response = await this.prompts.generateSdk(this.sdkGenerationService.generateSdk(buildZipPath, language, stability, this.configDir, this.commandMetadata, this.authKey));
|
|
54
|
+
if (response.isErr()) {
|
|
55
|
+
this.prompts.sdkGenerationServiceError(response.error);
|
|
56
|
+
return ActionResult.failed();
|
|
57
|
+
}
|
|
58
|
+
const responseSdkZipPath = await tempContext.save(response.value);
|
|
59
|
+
const tempSdk = await sdkContext.loadSdkInTempDirectory(tempDirectory, responseSdkZipPath);
|
|
60
|
+
this.prompts.sdkGenerated(await sdkContext.save(tempSdk, zipSdk));
|
|
61
|
+
return ActionResult.success();
|
|
62
|
+
});
|
|
63
|
+
};
|
|
104
64
|
}
|
|
105
65
|
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/actions/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/actions/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAuB,MAAM,6BAA6B,CAAC;AAGvF,MAAM,OAAO,cAAc;IACR,OAAO,GAAuB,IAAI,kBAAkB,EAAE,CAAC;IACvD,oBAAoB,GAAyB,IAAI,oBAAoB,EAAE,CAAC;IACxE,SAAS,CAAgB;IACzB,eAAe,CAAkB;IACjC,OAAO,CAAgB;IAExC,YAAY,SAAwB,EAAE,eAAgC,EAAE,OAAO,GAAkB,IAAI;QACnG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEe,OAAO,GAAG,KAAK,EAC7B,OAAuB,EACvB,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,CAAC,sBAAsB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;YAC3F,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAElE,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;CACH"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { CommandMetadata } from '../../../types/common/command-metadata.js';
|
|
2
2
|
import { DirectoryPath } from '../../../types/file/directoryPath.js';
|
|
3
3
|
import { ActionResult } from '../../action-result.js';
|
|
4
|
+
import { ProjectContext } from '../../../types/project-context.js';
|
|
4
5
|
export declare class SdkPublishInteractiveAction {
|
|
5
6
|
private readonly configDir;
|
|
6
7
|
private readonly commandMetadata;
|
|
7
8
|
private readonly prompts;
|
|
8
9
|
private readonly publishingApiService;
|
|
9
10
|
constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata);
|
|
10
|
-
readonly execute: (
|
|
11
|
-
static workingDirectoryValidator(
|
|
12
|
-
static sdkDirectoryValidator(
|
|
11
|
+
readonly execute: (defaultProjectDirectory: DirectoryPath, onPublishSdkError: (errorMessage: string) => void) => Promise<ActionResult>;
|
|
12
|
+
static workingDirectoryValidator(defaultProjectDirectory: DirectoryPath): (value: string | undefined) => string | undefined;
|
|
13
|
+
static sdkDirectoryValidator(project: ProjectContext): (value: string | undefined) => string | undefined;
|
|
13
14
|
}
|