@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,77 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { DirectoryPath } from '../types/file/directoryPath.js';
|
|
3
|
+
import { FilePath } from '../types/file/filePath.js';
|
|
4
|
+
import { CheckedFile } from '../types/portal/content-tree.js';
|
|
5
|
+
import { PortalArtifacts } from '../types/portal/portal-artifacts.js';
|
|
6
|
+
import { PortalSettings, PortalSource } from '../types/portal/portal-source.js';
|
|
7
|
+
export declare const COPIED_DEPENDENCIES: string[];
|
|
8
|
+
export declare const LINKED_DEPENDENCIES: string[];
|
|
9
|
+
export declare const TEMPLATE_DEPENDENCIES: string[];
|
|
10
|
+
/** Where the SDKs and the context plugin are laid out as the site serves them, inside the project. */
|
|
11
|
+
export declare const DOWNLOADS_DIRECTORY_NAME = "downloads";
|
|
12
|
+
/** Where the project keeps its copy of `content/`, and an empty one where the source has none. */
|
|
13
|
+
export declare const CONTENT_COPY_DIRECTORY_NAME = "content";
|
|
14
|
+
export interface PortalProjectPaths {
|
|
15
|
+
projectDirectory: DirectoryPath;
|
|
16
|
+
/** Vite's CLI entry point, resolved from the CLI's own dependencies. */
|
|
17
|
+
viteBinary: FilePath;
|
|
18
|
+
/** The source's `content/`, which the project's copy stands in for; null where the source has none. */
|
|
19
|
+
contentSource: DirectoryPath | null;
|
|
20
|
+
}
|
|
21
|
+
/** `portal.config.json`, which the template reads as `BuildPaths`; a test holds the two to one shape. */
|
|
22
|
+
export interface PortalBuildPaths {
|
|
23
|
+
specs: Record<string, string>;
|
|
24
|
+
codeSamples: string | null;
|
|
25
|
+
contentDir: string;
|
|
26
|
+
generatedDir: string;
|
|
27
|
+
staticDir: string | null;
|
|
28
|
+
downloadsDir: string | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Prepares the throwaway Vite project that both `portal generate` and `portal serve` run.
|
|
32
|
+
* The project points at the user's `src/` by absolute path, but for a copy of `content/`: the
|
|
33
|
+
* browser bundle names the pages' directory, and a preview keeps the copy at what it last accepted.
|
|
34
|
+
*/
|
|
35
|
+
export declare class PortalProjectService {
|
|
36
|
+
private readonly fileService;
|
|
37
|
+
private readonly pagesService;
|
|
38
|
+
private readonly require;
|
|
39
|
+
/** Checks this installation can run the portal build at all, before any work is done. */
|
|
40
|
+
runtimeProblem(): string | null;
|
|
41
|
+
prepare(projectDirectory: DirectoryPath, source: PortalSource, artifacts: PortalArtifacts): Promise<Result<PortalProjectPaths, string>>;
|
|
42
|
+
/**
|
|
43
|
+
* Environment for the child process. Deliberately an allow-list: the auth key must not
|
|
44
|
+
* reach the build, and any stray `VITE_*` variable would be inlined into the output.
|
|
45
|
+
*/
|
|
46
|
+
childEnvironment(): Record<string, string>;
|
|
47
|
+
private writeCodeSamples;
|
|
48
|
+
private writeFragments;
|
|
49
|
+
private writeDownloads;
|
|
50
|
+
private linkDependencies;
|
|
51
|
+
private copyDependencies;
|
|
52
|
+
/** The project's copy of `content/`, which stands empty where the source has none. */
|
|
53
|
+
private contentDirectory;
|
|
54
|
+
private writeConfiguration;
|
|
55
|
+
/**
|
|
56
|
+
* The dev server picks the files up and reloads the browser. Each is written only when its
|
|
57
|
+
* contents change, so an edit that leaves the site as it was, such as a plugin command
|
|
58
|
+
* rewriting its own block, reloads nothing; the answer says whether anything was written.
|
|
59
|
+
*/
|
|
60
|
+
applyConfig(projectDirectory: DirectoryPath, settings: PortalSettings): Promise<Result<boolean, string>>;
|
|
61
|
+
/**
|
|
62
|
+
* Brings the project's copy of `content/` in line: `checked` files as checked, since a later save went
|
|
63
|
+
* unchecked, the rest as on disk, nothing the source lost, and only what changed, so little reloads.
|
|
64
|
+
*/
|
|
65
|
+
applyContent(projectDirectory: DirectoryPath, contentDirectory: DirectoryPath, checked: CheckedFile[]): Promise<Result<void, string>>;
|
|
66
|
+
private syncContent;
|
|
67
|
+
/** Every file below `directory` that the build reads, and none when it is gone. */
|
|
68
|
+
private contentFiles;
|
|
69
|
+
private writeAppearance;
|
|
70
|
+
/**
|
|
71
|
+
* The browser imports `portal.identity.json` whole, since a retained JSON module is not
|
|
72
|
+
* tree-shaken per property, which is why it holds nothing that addresses this machine.
|
|
73
|
+
*/
|
|
74
|
+
private appearanceFiles;
|
|
75
|
+
private templateDirectory;
|
|
76
|
+
private packageDirectory;
|
|
77
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fsExtra from 'fs-extra';
|
|
4
|
+
import { err, ok } from 'neverthrow';
|
|
5
|
+
import { DirectoryPath } from '../types/file/directoryPath.js';
|
|
6
|
+
import { FileName } from '../types/file/fileName.js';
|
|
7
|
+
import { FilePath } from '../types/file/filePath.js';
|
|
8
|
+
import { isSkippedWithin } from '../types/portal/content-tree.js';
|
|
9
|
+
import { GENERATED_DIRECTORY_NAME } from '../types/portal/generated-pages.js';
|
|
10
|
+
import { GENERATED_INCLUDES_DIRECTORY_NAME, pageFragments } from '../types/portal/page-fragments.js';
|
|
11
|
+
import { PLUGIN_DOWNLOAD, SDK_DOWNLOADS_FOLDER, sdkDownload } from '../types/portal/portal-downloads.js';
|
|
12
|
+
import { PortalStylesheet } from '../types/portal/portal-stylesheet.js';
|
|
13
|
+
import { errorMessage } from '../utils/error-utils.js';
|
|
14
|
+
import { envInfo } from './env-info.js';
|
|
15
|
+
import { FileService } from './file-service.js';
|
|
16
|
+
import { PortalPagesService } from './portal-pages-service.js';
|
|
17
|
+
// Copied, not linked: Tailwind rebases their `url()`s onto the project, and no relative path crosses drives.
|
|
18
|
+
export const COPIED_DEPENDENCIES = ['@fontsource-variable/geist', '@fontsource-variable/geist-mono'];
|
|
19
|
+
// Linked one by one rather than through a single link to the CLI's `node_modules`: under a
|
|
20
|
+
// pnpm global install, `npx` or `pnpm dlx` the package has no nested `node_modules`, and a
|
|
21
|
+
// single link also lets Vite write its scratch files into the CLI's own install directory.
|
|
22
|
+
export const LINKED_DEPENDENCIES = [
|
|
23
|
+
'@fumadocs/api-docs',
|
|
24
|
+
'@scalar/json-magic',
|
|
25
|
+
'@tailwindcss/vite',
|
|
26
|
+
'@tanstack/react-router',
|
|
27
|
+
'@tanstack/react-start',
|
|
28
|
+
'@tanstack/start-static-server-functions',
|
|
29
|
+
'@vitejs/plugin-react',
|
|
30
|
+
'fumadocs-core',
|
|
31
|
+
'fumadocs-mdx',
|
|
32
|
+
'fumadocs-openapi',
|
|
33
|
+
'fumadocs-ui',
|
|
34
|
+
'lucide-react',
|
|
35
|
+
'react',
|
|
36
|
+
'react-dom',
|
|
37
|
+
'rehype-raw',
|
|
38
|
+
'shiki',
|
|
39
|
+
'tailwindcss',
|
|
40
|
+
'tslib',
|
|
41
|
+
'vite',
|
|
42
|
+
'yaml'
|
|
43
|
+
];
|
|
44
|
+
export const TEMPLATE_DEPENDENCIES = [...COPIED_DEPENDENCIES, ...LINKED_DEPENDENCIES];
|
|
45
|
+
/** Beside `portal.config.json`; `src/lib/portal.ts` imports it. */
|
|
46
|
+
const IDENTITY_FILE_NAME = 'portal.identity.json';
|
|
47
|
+
/** In `src/styles/`, beside `app.css`, which imports it. */
|
|
48
|
+
const STYLESHEET_FILE_NAME = 'theme.css';
|
|
49
|
+
/** Where the SDKs and the context plugin are laid out as the site serves them, inside the project. */
|
|
50
|
+
export const DOWNLOADS_DIRECTORY_NAME = 'downloads';
|
|
51
|
+
/** Where the project keeps its copy of `content/`, and an empty one where the source has none. */
|
|
52
|
+
export const CONTENT_COPY_DIRECTORY_NAME = 'content';
|
|
53
|
+
/**
|
|
54
|
+
* Prepares the throwaway Vite project that both `portal generate` and `portal serve` run.
|
|
55
|
+
* The project points at the user's `src/` by absolute path, but for a copy of `content/`: the
|
|
56
|
+
* browser bundle names the pages' directory, and a preview keeps the copy at what it last accepted.
|
|
57
|
+
*/
|
|
58
|
+
export class PortalProjectService {
|
|
59
|
+
fileService = new FileService();
|
|
60
|
+
pagesService = new PortalPagesService();
|
|
61
|
+
require = createRequire(import.meta.url);
|
|
62
|
+
/** Checks this installation can run the portal build at all, before any work is done. */
|
|
63
|
+
runtimeProblem() {
|
|
64
|
+
for (const dependency of TEMPLATE_DEPENDENCIES) {
|
|
65
|
+
if (this.packageDirectory(dependency) === undefined) {
|
|
66
|
+
return `The portal build dependency '${dependency}' is missing from this installation. Reinstall the CLI and try again.`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
async prepare(projectDirectory, source, artifacts) {
|
|
72
|
+
const template = this.templateDirectory();
|
|
73
|
+
if (template === undefined) {
|
|
74
|
+
return err('The bundled portal template is missing from this installation. Reinstall the CLI and try again.');
|
|
75
|
+
}
|
|
76
|
+
const viteDirectory = this.packageDirectory('vite');
|
|
77
|
+
if (viteDirectory === undefined) {
|
|
78
|
+
return err("The portal build dependency 'vite' is missing from this installation. Reinstall the CLI and try again.");
|
|
79
|
+
}
|
|
80
|
+
await this.fileService.copyDirectoryContents(template, projectDirectory);
|
|
81
|
+
await this.linkDependencies(projectDirectory);
|
|
82
|
+
await this.copyDependencies(projectDirectory);
|
|
83
|
+
await this.writeConfiguration(projectDirectory, source, await this.contentDirectory(projectDirectory, source), await this.writeCodeSamples(projectDirectory, artifacts.codeSampleCatalogs), await this.writeDownloads(projectDirectory, artifacts));
|
|
84
|
+
const pages = await this.pagesService.write(projectDirectory.join(GENERATED_DIRECTORY_NAME), source.generatedPages);
|
|
85
|
+
if (pages.isErr()) {
|
|
86
|
+
return err(pages.error);
|
|
87
|
+
}
|
|
88
|
+
// Once: they change only with the artifacts, which a preview fetches when it starts.
|
|
89
|
+
await this.writeFragments(projectDirectory.join(GENERATED_INCLUDES_DIRECTORY_NAME), pageFragments(artifacts.sdkDocs));
|
|
90
|
+
return ok({
|
|
91
|
+
projectDirectory,
|
|
92
|
+
viteBinary: new FilePath(viteDirectory.join('bin'), new FileName('vite.js')),
|
|
93
|
+
contentSource: source.contentDirectory
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Environment for the child process. Deliberately an allow-list: the auth key must not
|
|
98
|
+
* reach the build, and any stray `VITE_*` variable would be inlined into the output.
|
|
99
|
+
*/
|
|
100
|
+
childEnvironment() {
|
|
101
|
+
const allowed = [
|
|
102
|
+
'PATH',
|
|
103
|
+
'Path',
|
|
104
|
+
'HOME',
|
|
105
|
+
'USERPROFILE',
|
|
106
|
+
'TMPDIR',
|
|
107
|
+
'TEMP',
|
|
108
|
+
'TMP',
|
|
109
|
+
'LANG',
|
|
110
|
+
'LC_ALL',
|
|
111
|
+
'SYSTEMROOT',
|
|
112
|
+
'SystemRoot',
|
|
113
|
+
'SystemDrive'
|
|
114
|
+
];
|
|
115
|
+
const environment = {};
|
|
116
|
+
for (const name of allowed) {
|
|
117
|
+
const value = process.env[name];
|
|
118
|
+
if (value !== undefined) {
|
|
119
|
+
environment[name] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Large specs push the prerender pass past Node's default heap. V8 honours the last
|
|
123
|
+
// occurrence of the flag, so appending unconditionally would override a limit the user
|
|
124
|
+
// raised on purpose, and lower it on a machine whose default is already higher.
|
|
125
|
+
const nodeOptions = process.env.NODE_OPTIONS ?? '';
|
|
126
|
+
environment.NODE_OPTIONS = /--max[-_]old[-_]space[-_]size/.test(nodeOptions)
|
|
127
|
+
? nodeOptions
|
|
128
|
+
: `${nodeOptions} --max-old-space-size=4096`.trim();
|
|
129
|
+
return environment;
|
|
130
|
+
}
|
|
131
|
+
// The template places the samples on the specs as it bundles them, so the specs are read where they are.
|
|
132
|
+
async writeCodeSamples(projectDirectory, codeSampleCatalogs) {
|
|
133
|
+
if (codeSampleCatalogs.isEmpty()) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const file = new FilePath(projectDirectory, new FileName('code-samples.json'));
|
|
137
|
+
await this.fileService.writeContents(file, JSON.stringify(codeSampleCatalogs.toJson()));
|
|
138
|
+
return file;
|
|
139
|
+
}
|
|
140
|
+
async writeFragments(directory, fragments) {
|
|
141
|
+
for (const { folder, fileName, contents } of fragments) {
|
|
142
|
+
const target = directory.join(folder);
|
|
143
|
+
await this.fileService.createDirectoryIfNotExists(target);
|
|
144
|
+
await this.fileService.writeContents(new FilePath(target, fileName), contents);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async writeDownloads(projectDirectory, artifacts) {
|
|
148
|
+
if (artifacts.sdks.size === 0 && artifacts.plugin === undefined) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const downloads = projectDirectory.join(DOWNLOADS_DIRECTORY_NAME);
|
|
152
|
+
await this.fileService.createDirectoryIfNotExists(downloads);
|
|
153
|
+
for (const [language, archive] of artifacts.sdks) {
|
|
154
|
+
const sdks = downloads.join(SDK_DOWNLOADS_FOLDER);
|
|
155
|
+
await this.fileService.createDirectoryIfNotExists(sdks);
|
|
156
|
+
await this.fileService.copy(archive, new FilePath(sdks, sdkDownload(language)));
|
|
157
|
+
}
|
|
158
|
+
if (artifacts.plugin !== undefined) {
|
|
159
|
+
await this.fileService.copy(artifacts.plugin, new FilePath(downloads, PLUGIN_DOWNLOAD));
|
|
160
|
+
}
|
|
161
|
+
return downloads;
|
|
162
|
+
}
|
|
163
|
+
async linkDependencies(projectDirectory) {
|
|
164
|
+
const modules = projectDirectory.join('node_modules');
|
|
165
|
+
await this.fileService.createDirectoryIfNotExists(modules);
|
|
166
|
+
for (const dependency of LINKED_DEPENDENCIES) {
|
|
167
|
+
const target = this.packageDirectory(dependency);
|
|
168
|
+
if (target === undefined) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const link = modules.join(dependency);
|
|
172
|
+
if (dependency.includes('/')) {
|
|
173
|
+
await this.fileService.createDirectoryIfNotExists(new DirectoryPath(path.dirname(link.toString())));
|
|
174
|
+
}
|
|
175
|
+
// A junction is the only link type Windows grants without elevation.
|
|
176
|
+
await fsExtra.symlink(target.toString(), link.toString(), process.platform === 'win32' ? 'junction' : 'dir');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async copyDependencies(projectDirectory) {
|
|
180
|
+
for (const dependency of COPIED_DEPENDENCIES) {
|
|
181
|
+
const target = this.packageDirectory(dependency);
|
|
182
|
+
if (target !== undefined) {
|
|
183
|
+
await this.fileService.copyDirectoryContents(target, projectDirectory.join('node_modules', dependency));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** The project's copy of `content/`, which stands empty where the source has none. */
|
|
188
|
+
async contentDirectory(projectDirectory, source) {
|
|
189
|
+
const copy = projectDirectory.join(CONTENT_COPY_DIRECTORY_NAME);
|
|
190
|
+
await this.fileService.createDirectoryIfNotExists(copy);
|
|
191
|
+
if (source.contentDirectory !== null) {
|
|
192
|
+
// Before the dev server starts: it lists the pages once, and one missing then stays missing.
|
|
193
|
+
await this.syncContent(source.contentDirectory, copy, []);
|
|
194
|
+
}
|
|
195
|
+
return copy;
|
|
196
|
+
}
|
|
197
|
+
async writeConfiguration(projectDirectory, source, contentDirectory, codeSamples, downloads) {
|
|
198
|
+
const specs = {};
|
|
199
|
+
for (const spec of source.specs) {
|
|
200
|
+
specs[spec.slug] = spec.file.toPosix();
|
|
201
|
+
}
|
|
202
|
+
// Everything here addresses this machine, so it stays behind `portal.server.ts` and the
|
|
203
|
+
// build's own config files.
|
|
204
|
+
const configuration = {
|
|
205
|
+
specs,
|
|
206
|
+
codeSamples: codeSamples === null ? null : codeSamples.toPosix(),
|
|
207
|
+
contentDir: contentDirectory.toPosix(),
|
|
208
|
+
generatedDir: projectDirectory.join(GENERATED_DIRECTORY_NAME).toPosix(),
|
|
209
|
+
staticDir: source.staticDirectory === null ? null : source.staticDirectory.toPosix(),
|
|
210
|
+
downloadsDir: downloads === null ? null : downloads.toPosix()
|
|
211
|
+
};
|
|
212
|
+
await this.fileService.writeContents(new FilePath(projectDirectory, new FileName('portal.config.json')), JSON.stringify(configuration, null, 2));
|
|
213
|
+
await this.writeAppearance(projectDirectory, source.config);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The dev server picks the files up and reloads the browser. Each is written only when its
|
|
217
|
+
* contents change, so an edit that leaves the site as it was, such as a plugin command
|
|
218
|
+
* rewriting its own block, reloads nothing; the answer says whether anything was written.
|
|
219
|
+
*/
|
|
220
|
+
async applyConfig(projectDirectory, settings) {
|
|
221
|
+
let written = false;
|
|
222
|
+
try {
|
|
223
|
+
for (const [file, contents] of this.appearanceFiles(projectDirectory, settings.config)) {
|
|
224
|
+
if (await this.fileService.replaceContentsIfChanged(file, contents)) {
|
|
225
|
+
written = true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
return err(errorMessage(error));
|
|
231
|
+
}
|
|
232
|
+
const pages = await this.pagesService.write(projectDirectory.join(GENERATED_DIRECTORY_NAME), settings.generatedPages);
|
|
233
|
+
return pages.map((pagesWritten) => written || pagesWritten);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Brings the project's copy of `content/` in line: `checked` files as checked, since a later save went
|
|
237
|
+
* unchecked, the rest as on disk, nothing the source lost, and only what changed, so little reloads.
|
|
238
|
+
*/
|
|
239
|
+
async applyContent(projectDirectory, contentDirectory, checked) {
|
|
240
|
+
try {
|
|
241
|
+
await this.syncContent(contentDirectory, projectDirectory.join(CONTENT_COPY_DIRECTORY_NAME), checked);
|
|
242
|
+
return ok(undefined);
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
return err(errorMessage(error));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
async syncContent(from, to, checked) {
|
|
249
|
+
const files = await this.contentFiles(from);
|
|
250
|
+
for (const file of files) {
|
|
251
|
+
const target = file.rebased(from, to);
|
|
252
|
+
const read = checked.find((each) => each.file.isEqual(file));
|
|
253
|
+
if (read === undefined) {
|
|
254
|
+
await this.fileService.copyIfChanged(file, target);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
await this.fileService.replaceContentsIfChanged(target, read.contents);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const copied of await this.contentFiles(to)) {
|
|
261
|
+
if (!files.some((file) => file.rebased(from, to).isEqual(copied))) {
|
|
262
|
+
await this.fileService.deleteFile(copied);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/** Every file below `directory` that the build reads, and none when it is gone. */
|
|
267
|
+
async contentFiles(directory) {
|
|
268
|
+
if (!(await this.fileService.directoryExists(directory))) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
return (await this.fileService.getDirectory(directory))
|
|
272
|
+
.getAllFiles()
|
|
273
|
+
.filter((file) => !isSkippedWithin(file, directory));
|
|
274
|
+
}
|
|
275
|
+
async writeAppearance(projectDirectory, config) {
|
|
276
|
+
for (const [file, contents] of this.appearanceFiles(projectDirectory, config)) {
|
|
277
|
+
await this.fileService.writeContents(file, contents);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The browser imports `portal.identity.json` whole, since a retained JSON module is not
|
|
282
|
+
* tree-shaken per property, which is why it holds nothing that addresses this machine.
|
|
283
|
+
*/
|
|
284
|
+
appearanceFiles(projectDirectory, config) {
|
|
285
|
+
return [
|
|
286
|
+
[new FilePath(projectDirectory, new FileName(IDENTITY_FILE_NAME)), JSON.stringify(config.identity(), null, 2)],
|
|
287
|
+
[
|
|
288
|
+
new FilePath(projectDirectory.join('src').join('styles'), new FileName(STYLESHEET_FILE_NAME)),
|
|
289
|
+
PortalStylesheet.of(config).toString()
|
|
290
|
+
]
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
templateDirectory() {
|
|
294
|
+
const template = envInfo.packageRoot().join('portal-template');
|
|
295
|
+
return this.fileService.directoryExistsSync(template) ? template : undefined;
|
|
296
|
+
}
|
|
297
|
+
// `require.resolve` cannot be used directly: a package whose `exports` map hides
|
|
298
|
+
// `package.json` throws, so the candidate roots are walked instead.
|
|
299
|
+
packageDirectory(name) {
|
|
300
|
+
for (const candidate of this.require.resolve.paths(name) ?? []) {
|
|
301
|
+
const manifest = path.join(candidate, name, 'package.json');
|
|
302
|
+
if (fsExtra.existsSync(manifest)) {
|
|
303
|
+
return new DirectoryPath(path.dirname(manifest));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=portal-project-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-project-service.js","sourceRoot":"","sources":["../../src/infrastructure/portal-project-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAe,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EA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AO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -21,6 +21,7 @@ export declare class ServiceError {
|
|
|
21
21
|
static badRequest(customMessage: string, errors: Record<string, string[]>): ServiceError;
|
|
22
22
|
static forbidden(customMessage: string): ServiceError;
|
|
23
23
|
static notFound(customMessage: string): ServiceError;
|
|
24
|
+
static invalidResponse(customMessage: string): ServiceError;
|
|
24
25
|
static timeout(customMessage: string): ServiceError;
|
|
25
26
|
static unauthorizedWithHint(apiMessage: string | null): ServiceError;
|
|
26
27
|
static readonly values: ServiceError[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import axios from "axios";
|
|
3
2
|
import { ApiError, ProblemDetailsError } from "@apimatic/sdk";
|
|
4
3
|
import { format as f } from "../prompts/format.js";
|
|
@@ -15,28 +14,47 @@ export var ServiceErrorCode;
|
|
|
15
14
|
ServiceErrorCode["Timeout"] = "TIMEOUT";
|
|
16
15
|
})(ServiceErrorCode || (ServiceErrorCode = {}));
|
|
17
16
|
export class ServiceError {
|
|
17
|
+
code;
|
|
18
|
+
defaultMessage;
|
|
19
|
+
errors;
|
|
20
|
+
static defaultErrorMessage = `An unexpected error occurred, please try again later. If the problem persists, please reach out to our team at ${f.var("support@apimatic.io")}`;
|
|
21
|
+
static NotFound = new ServiceError(ServiceErrorCode.NotFound, "Resource not found.", {});
|
|
22
|
+
static ServerError = new ServiceError(ServiceErrorCode.ServerError, this.defaultErrorMessage, {});
|
|
23
|
+
static NetworkError = new ServiceError(ServiceErrorCode.NetworkError, "Unable to connect to the server.", {});
|
|
24
|
+
static InvalidResponse = new ServiceError(ServiceErrorCode.InvalidResponse, this.defaultErrorMessage, {});
|
|
25
|
+
static UnAuthorized = new ServiceError(ServiceErrorCode.UnAuthorized, "Unauthorized access.", {});
|
|
18
26
|
static badRequest(customMessage, errors) {
|
|
19
|
-
return new
|
|
27
|
+
return new ServiceError(ServiceErrorCode.BadRequest, customMessage, errors);
|
|
20
28
|
}
|
|
21
29
|
static forbidden(customMessage) {
|
|
22
|
-
return new
|
|
30
|
+
return new ServiceError(ServiceErrorCode.Forbidden, customMessage, {});
|
|
23
31
|
}
|
|
24
32
|
static notFound(customMessage) {
|
|
25
|
-
return new
|
|
33
|
+
return new ServiceError(ServiceErrorCode.NotFound, customMessage, {});
|
|
34
|
+
}
|
|
35
|
+
static invalidResponse(customMessage) {
|
|
36
|
+
return new ServiceError(ServiceErrorCode.InvalidResponse, customMessage, {});
|
|
26
37
|
}
|
|
27
38
|
static timeout(customMessage) {
|
|
28
|
-
return new
|
|
39
|
+
return new ServiceError(ServiceErrorCode.Timeout, customMessage, {});
|
|
29
40
|
}
|
|
30
41
|
static unauthorizedWithHint(apiMessage) {
|
|
31
42
|
// Both remedies name the full `auth login` command: the key is supplied to
|
|
32
43
|
// that command, not to whichever one hit the 401 — most of them don't accept
|
|
33
44
|
// an --auth-key flag at all.
|
|
34
45
|
const loginCommand = f.cmdAlt("apimatic", "auth", "login");
|
|
35
|
-
const message = `${apiMessage
|
|
46
|
+
const message = `${apiMessage ?? "Authorization has been denied for this request."} ` +
|
|
36
47
|
`Please run ${loginCommand} to log in via browser, ` +
|
|
37
48
|
`or provide a valid auth key using the ${loginCommand} ${f.flag("auth-key")}`;
|
|
38
|
-
return new
|
|
39
|
-
}
|
|
49
|
+
return new ServiceError(ServiceErrorCode.UnAuthorized, message, {});
|
|
50
|
+
}
|
|
51
|
+
static values = [
|
|
52
|
+
ServiceError.NotFound,
|
|
53
|
+
ServiceError.ServerError,
|
|
54
|
+
ServiceError.NetworkError,
|
|
55
|
+
ServiceError.InvalidResponse,
|
|
56
|
+
ServiceError.UnAuthorized
|
|
57
|
+
];
|
|
40
58
|
constructor(code, defaultMessage, errors) {
|
|
41
59
|
this.code = code;
|
|
42
60
|
this.defaultMessage = defaultMessage;
|
|
@@ -49,30 +67,15 @@ export class ServiceError {
|
|
|
49
67
|
return this.errors[key];
|
|
50
68
|
}
|
|
51
69
|
}
|
|
52
|
-
_a = ServiceError;
|
|
53
|
-
ServiceError.defaultErrorMessage = `An unexpected error occurred, please try again later. If the problem persists, please reach out to our team at ${f.var("support@apimatic.io")}`;
|
|
54
|
-
ServiceError.NotFound = new _a(ServiceErrorCode.NotFound, "Resource not found.", {});
|
|
55
|
-
ServiceError.ServerError = new _a(ServiceErrorCode.ServerError, _a.defaultErrorMessage, {});
|
|
56
|
-
ServiceError.NetworkError = new _a(ServiceErrorCode.NetworkError, "Unable to connect to the server.", {});
|
|
57
|
-
ServiceError.InvalidResponse = new _a(ServiceErrorCode.InvalidResponse, _a.defaultErrorMessage, {});
|
|
58
|
-
ServiceError.UnAuthorized = new _a(ServiceErrorCode.UnAuthorized, "Unauthorized access.", {});
|
|
59
|
-
ServiceError.values = [
|
|
60
|
-
_a.NotFound,
|
|
61
|
-
_a.ServerError,
|
|
62
|
-
_a.NetworkError,
|
|
63
|
-
_a.InvalidResponse,
|
|
64
|
-
_a.UnAuthorized
|
|
65
|
-
];
|
|
66
70
|
// A ProblemDetails body carries a `title` plus a map of field errors; surface
|
|
67
71
|
// the title and the first field message.
|
|
68
72
|
function mapProblemDetailsError(error) {
|
|
69
|
-
var _b, _c, _d, _e, _f;
|
|
70
73
|
// ProblemDetails.title and .errors are optional and result may be absent — guard
|
|
71
74
|
// all three so a sparse body can't crash or render a trailing "- null".
|
|
72
75
|
// TODO: This only picks the first error message, improve it to show all errors.
|
|
73
|
-
const errors = (
|
|
74
|
-
const firstFieldMessage =
|
|
75
|
-
const title =
|
|
76
|
+
const errors = (error.result?.errors ?? {});
|
|
77
|
+
const firstFieldMessage = Object.values(errors)[0]?.[0];
|
|
78
|
+
const title = error.result?.title ?? "Request failed.";
|
|
76
79
|
const errorMessage = firstFieldMessage ? `${title}\n- ${firstFieldMessage}` : title;
|
|
77
80
|
if (error.statusCode === 400)
|
|
78
81
|
return ServiceError.badRequest(errorMessage, errors);
|
|
@@ -83,14 +86,13 @@ function mapProblemDetailsError(error) {
|
|
|
83
86
|
// SDK controllers throw typed `ApiError`s (not axios errors). The API reports
|
|
84
87
|
// the reason as {"message": "..."} deserialized into `result`.
|
|
85
88
|
function mapApiError(error) {
|
|
86
|
-
var _b, _c;
|
|
87
89
|
if (error instanceof ProblemDetailsError) {
|
|
88
90
|
const serviceError = mapProblemDetailsError(error);
|
|
89
91
|
if (serviceError)
|
|
90
92
|
return serviceError;
|
|
91
93
|
}
|
|
92
94
|
if (error.statusCode === 401) {
|
|
93
|
-
const apiMessage =
|
|
95
|
+
const apiMessage = error.result?.message ?? null;
|
|
94
96
|
return ServiceError.unauthorizedWithHint(apiMessage);
|
|
95
97
|
}
|
|
96
98
|
if (error.statusCode === 404)
|
|
@@ -104,22 +106,21 @@ function mapApiError(error) {
|
|
|
104
106
|
* map. Every other status is left to `mapTransportError`.
|
|
105
107
|
*/
|
|
106
108
|
function mapAxiosProblemDetails(error) {
|
|
107
|
-
var _b, _c, _d, _e, _f, _g;
|
|
108
109
|
if (!axios.isAxiosError(error)) {
|
|
109
110
|
return undefined;
|
|
110
111
|
}
|
|
111
|
-
const body =
|
|
112
|
+
const body = error.response?.data;
|
|
112
113
|
if (typeof body !== "object" || body === null) {
|
|
113
114
|
return undefined;
|
|
114
115
|
}
|
|
115
|
-
const errors =
|
|
116
|
-
const firstMessage =
|
|
117
|
-
const title =
|
|
116
|
+
const errors = body.errors ?? {};
|
|
117
|
+
const firstMessage = Object.values(errors).flat()[0] ?? body.detail;
|
|
118
|
+
const title = body.title ?? "Request failed.";
|
|
118
119
|
const message = firstMessage ? `${title}\n- ${firstMessage}` : title;
|
|
119
|
-
if (
|
|
120
|
+
if (error.response?.status === 400) {
|
|
120
121
|
return ServiceError.badRequest(message, errors);
|
|
121
122
|
}
|
|
122
|
-
if (
|
|
123
|
+
if (error.response?.status === 403) {
|
|
123
124
|
return ServiceError.forbidden(message);
|
|
124
125
|
}
|
|
125
126
|
return undefined;
|
|
@@ -129,19 +130,16 @@ function mapAxiosProblemDetails(error) {
|
|
|
129
130
|
* user with nothing to act on — the SDK path names the remedy but the axios path does not.
|
|
130
131
|
*/
|
|
131
132
|
export function mapTransportError(error) {
|
|
132
|
-
|
|
133
|
-
if (axios.isAxiosError(error) && ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
|
|
133
|
+
if (axios.isAxiosError(error) && error.response?.status === 401) {
|
|
134
134
|
return ServiceError.unauthorizedWithHint(null);
|
|
135
135
|
}
|
|
136
136
|
return handleServiceError(error);
|
|
137
137
|
}
|
|
138
138
|
/** For responses whose body is readable JSON; a streamed body can only be mapped by status. */
|
|
139
139
|
export function mapRequestError(error) {
|
|
140
|
-
|
|
141
|
-
return (_b = mapAxiosProblemDetails(error)) !== null && _b !== void 0 ? _b : mapTransportError(error);
|
|
140
|
+
return mapAxiosProblemDetails(error) ?? mapTransportError(error);
|
|
142
141
|
}
|
|
143
142
|
export function handleServiceError(error) {
|
|
144
|
-
var _b;
|
|
145
143
|
if (error instanceof ApiError) {
|
|
146
144
|
// A `callAsStream` error body would otherwise hang the CLI. Order against
|
|
147
145
|
// `mapApiError` is free: `error.result` is only populated when the SDK
|
|
@@ -152,7 +150,7 @@ export function handleServiceError(error) {
|
|
|
152
150
|
return serviceError;
|
|
153
151
|
}
|
|
154
152
|
if (axios.isAxiosError(error)) {
|
|
155
|
-
const status =
|
|
153
|
+
const status = error.response?.status;
|
|
156
154
|
if (status === 401)
|
|
157
155
|
return ServiceError.UnAuthorized;
|
|
158
156
|
if (status === 404)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-error.js","sourceRoot":"","sources":["../../src/infrastructure/service-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-error.js","sourceRoot":"","sources":["../../src/infrastructure/service-error.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