@apimatic/cli 1.4.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -212
- package/apimatic.schema.json +550 -0
- package/lib/actions/action-result.js +3 -0
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/transform.js +36 -33
- package/lib/actions/api/transform.js.map +1 -1
- package/lib/actions/api/validate.d.ts +9 -6
- package/lib/actions/api/validate.js +44 -38
- package/lib/actions/api/validate.js.map +1 -1
- package/lib/actions/auth/login.js +7 -4
- package/lib/actions/auth/login.js.map +1 -1
- package/lib/actions/auth/logout.js +2 -1
- package/lib/actions/auth/logout.js.map +1 -1
- package/lib/actions/auth/status.js +5 -3
- package/lib/actions/auth/status.js.map +1 -1
- package/lib/actions/plugin/generate.d.ts +5 -1
- package/lib/actions/plugin/generate.js +83 -56
- package/lib/actions/plugin/generate.js.map +1 -1
- package/lib/actions/plugin/publish.d.ts +2 -1
- package/lib/actions/plugin/publish.js +34 -37
- package/lib/actions/plugin/publish.js.map +1 -1
- package/lib/actions/plugin/record-metadata.d.ts +3 -2
- package/lib/actions/plugin/record-metadata.js +33 -30
- package/lib/actions/plugin/record-metadata.js.map +1 -1
- package/lib/actions/portal/generate.d.ts +8 -6
- package/lib/actions/portal/generate.js +50 -61
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/prepare-project.d.ts +25 -0
- package/lib/actions/portal/prepare-project.js +68 -0
- package/lib/actions/portal/prepare-project.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +21 -6
- package/lib/actions/portal/serve.js +170 -153
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/publishing/profile/list.js +4 -2
- package/lib/actions/publishing/profile/list.js.map +1 -1
- package/lib/actions/quickstart.d.ts +23 -5
- package/lib/actions/quickstart.js +222 -21
- package/lib/actions/quickstart.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +4 -7
- package/lib/actions/sdk/generate.js +53 -93
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/actions/sdk/publish/interactive.d.ts +4 -3
- package/lib/actions/sdk/publish/interactive.js +96 -97
- package/lib/actions/sdk/publish/interactive.js.map +1 -1
- package/lib/actions/sdk/publish/non-interactive.d.ts +4 -2
- package/lib/actions/sdk/publish/non-interactive.js +91 -90
- package/lib/actions/sdk/publish/non-interactive.js.map +1 -1
- package/lib/actions/sdk/publish.d.ts +3 -2
- package/lib/actions/sdk/publish.js +55 -53
- package/lib/actions/sdk/publish.js.map +1 -1
- package/lib/actions/sdk/record-published-sdk.d.ts +14 -0
- package/lib/actions/sdk/record-published-sdk.js +57 -0
- package/lib/actions/sdk/record-published-sdk.js.map +1 -0
- package/lib/client-utils/auth-manager.js +1 -1
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/commands/api/transform.d.ts +1 -1
- package/lib/commands/api/transform.js +44 -40
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.js +16 -16
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.js +14 -15
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.js +5 -6
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.js +4 -5
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/plugin/generate.d.ts +3 -3
- package/lib/commands/plugin/generate.js +20 -20
- package/lib/commands/plugin/generate.js.map +1 -1
- package/lib/commands/plugin/publish.js +18 -18
- package/lib/commands/plugin/publish.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +9 -8
- package/lib/commands/portal/generate.js +36 -27
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +7 -9
- package/lib/commands/portal/serve.js +41 -44
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/publishing/profile/list.js +8 -12
- package/lib/commands/publishing/profile/list.js.map +1 -1
- package/lib/commands/quickstart.d.ts +5 -5
- package/lib/commands/quickstart.js +18 -24
- package/lib/commands/quickstart.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +5 -7
- package/lib/commands/sdk/generate.js +58 -70
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/commands/sdk/publish.d.ts +6 -7
- package/lib/commands/sdk/publish.js +66 -60
- package/lib/commands/sdk/publish.js.map +1 -1
- package/lib/hooks/node-version.d.ts +3 -0
- package/lib/hooks/node-version.js +12 -0
- package/lib/hooks/node-version.js.map +1 -0
- package/lib/hooks/not-found.js +2 -3
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/hooks/utils.d.ts +4 -2
- package/lib/hooks/utils.js +2 -2
- package/lib/hooks/utils.js.map +1 -1
- package/lib/infrastructure/env-info.d.ts +3 -0
- package/lib/infrastructure/env-info.js +13 -6
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +35 -8
- package/lib/infrastructure/file-service.js +149 -53
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/file-watch-service.d.ts +40 -0
- package/lib/infrastructure/file-watch-service.js +167 -0
- package/lib/infrastructure/file-watch-service.js.map +1 -0
- package/lib/infrastructure/generation-status-poller.d.ts +8 -7
- package/lib/infrastructure/generation-status-poller.js +20 -12
- package/lib/infrastructure/generation-status-poller.js.map +1 -1
- package/lib/infrastructure/launcher-service.js +6 -6
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +15 -1
- package/lib/infrastructure/network-service.js.map +1 -1
- package/lib/infrastructure/portal-build-service.d.ts +19 -0
- package/lib/infrastructure/portal-build-service.js +58 -0
- package/lib/infrastructure/portal-build-service.js.map +1 -0
- package/lib/infrastructure/portal-dev-server-service.d.ts +29 -0
- package/lib/infrastructure/portal-dev-server-service.js +135 -0
- package/lib/infrastructure/portal-dev-server-service.js.map +1 -0
- package/lib/infrastructure/portal-pages-service.d.ts +17 -0
- package/lib/infrastructure/portal-pages-service.js +103 -0
- package/lib/infrastructure/portal-pages-service.js.map +1 -0
- package/lib/infrastructure/portal-project-service.d.ts +77 -0
- package/lib/infrastructure/portal-project-service.js +309 -0
- package/lib/infrastructure/portal-project-service.js.map +1 -0
- package/lib/infrastructure/service-error.d.ts +1 -0
- package/lib/infrastructure/service-error.js +39 -41
- package/lib/infrastructure/service-error.js.map +1 -1
- package/lib/infrastructure/services/api-client-factory.js +15 -13
- package/lib/infrastructure/services/api-client-factory.js.map +1 -1
- package/lib/infrastructure/services/api-service.d.ts +7 -5
- package/lib/infrastructure/services/api-service.js +28 -20
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/auth-service.js +4 -9
- package/lib/infrastructure/services/auth-service.js.map +1 -1
- package/lib/infrastructure/services/file-download-service.js +3 -3
- package/lib/infrastructure/services/file-download-service.js.map +1 -1
- package/lib/infrastructure/services/plugin-service.d.ts +1 -8
- package/lib/infrastructure/services/plugin-service.js +11 -22
- package/lib/infrastructure/services/plugin-service.js.map +1 -1
- package/lib/infrastructure/services/portal-artifacts-service.d.ts +44 -0
- package/lib/infrastructure/services/portal-artifacts-service.js +268 -0
- package/lib/infrastructure/services/portal-artifacts-service.js.map +1 -0
- package/lib/infrastructure/services/portal-authorization-service.d.ts +22 -0
- package/lib/infrastructure/services/portal-authorization-service.js +23 -0
- package/lib/infrastructure/services/portal-authorization-service.js.map +1 -0
- package/lib/infrastructure/services/publishing-api-service.d.ts +1 -1
- package/lib/infrastructure/services/publishing-api-service.js +11 -15
- package/lib/infrastructure/services/publishing-api-service.js.map +1 -1
- package/lib/infrastructure/services/sdk-generation-service.d.ts +21 -0
- package/lib/infrastructure/services/sdk-generation-service.js +118 -0
- package/lib/infrastructure/services/sdk-generation-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.js +5 -4
- package/lib/infrastructure/services/telemetry-service.js.map +1 -1
- package/lib/infrastructure/services/transformation-service.js +29 -32
- package/lib/infrastructure/services/transformation-service.js.map +1 -1
- package/lib/infrastructure/services/validation-service.d.ts +12 -53
- package/lib/infrastructure/services/validation-service.js +24 -199
- package/lib/infrastructure/services/validation-service.js.map +1 -1
- package/lib/infrastructure/timer-extensions.d.ts +2 -0
- package/lib/infrastructure/timer-extensions.js +10 -0
- package/lib/infrastructure/timer-extensions.js.map +1 -0
- package/lib/infrastructure/tmp-extensions.d.ts +31 -1
- package/lib/infrastructure/tmp-extensions.js +86 -3
- package/lib/infrastructure/tmp-extensions.js.map +1 -1
- package/lib/infrastructure/zip-service.js +2 -2
- package/lib/infrastructure/zip-service.js.map +1 -1
- package/lib/prompts/api/validate.d.ts +6 -7
- package/lib/prompts/api/validate.js +12 -12
- package/lib/prompts/api/validate.js.map +1 -1
- package/lib/prompts/format.d.ts +4 -0
- package/lib/prompts/format.js +5 -0
- package/lib/prompts/format.js.map +1 -1
- package/lib/prompts/plugin/generate.d.ts +17 -12
- package/lib/prompts/plugin/generate.js +94 -44
- package/lib/prompts/plugin/generate.js.map +1 -1
- package/lib/prompts/plugin/publish.d.ts +2 -1
- package/lib/prompts/plugin/publish.js +8 -7
- package/lib/prompts/plugin/publish.js.map +1 -1
- package/lib/prompts/plugin/record-metadata.d.ts +1 -0
- package/lib/prompts/plugin/record-metadata.js +10 -7
- package/lib/prompts/plugin/record-metadata.js.map +1 -1
- package/lib/prompts/portal/artifacts.d.ts +8 -0
- package/lib/prompts/portal/artifacts.js +26 -0
- package/lib/prompts/portal/artifacts.js.map +1 -0
- package/lib/prompts/portal/authorization.d.ts +6 -0
- package/lib/prompts/portal/authorization.js +29 -0
- package/lib/prompts/portal/authorization.js.map +1 -0
- package/lib/prompts/portal/code-samples.d.ts +1 -0
- package/lib/prompts/portal/code-samples.js +9 -0
- package/lib/prompts/portal/code-samples.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +14 -9
- package/lib/prompts/portal/generate.js +48 -26
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/prepare-project.d.ts +20 -0
- package/lib/prompts/portal/prepare-project.js +36 -0
- package/lib/prompts/portal/prepare-project.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +32 -12
- package/lib/prompts/portal/serve.js +102 -39
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/source.d.ts +26 -0
- package/lib/prompts/portal/source.js +253 -0
- package/lib/prompts/portal/source.js.map +1 -0
- package/lib/prompts/prompt.d.ts +11 -3
- package/lib/prompts/prompt.js +39 -15
- package/lib/prompts/prompt.js.map +1 -1
- package/lib/prompts/quickstart.d.ts +46 -3
- package/lib/prompts/quickstart.js +199 -12
- package/lib/prompts/quickstart.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +15 -13
- package/lib/prompts/sdk/generate.js +29 -32
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/prompts/sdk/publish/interactive.d.ts +10 -6
- package/lib/prompts/sdk/publish/interactive.js +26 -24
- package/lib/prompts/sdk/publish/interactive.js.map +1 -1
- package/lib/prompts/sdk/publish/non-interactive.d.ts +2 -1
- package/lib/prompts/sdk/publish/non-interactive.js +5 -4
- package/lib/prompts/sdk/publish/non-interactive.js.map +1 -1
- package/lib/prompts/sdk/publish.d.ts +3 -3
- package/lib/prompts/sdk/publish.js +13 -17
- package/lib/prompts/sdk/publish.js.map +1 -1
- package/lib/prompts/sdk/record-published-sdk.d.ts +7 -0
- package/lib/prompts/sdk/record-published-sdk.js +26 -0
- package/lib/prompts/sdk/record-published-sdk.js.map +1 -0
- package/lib/types/apimatic-config/document.d.ts +70 -0
- package/lib/types/apimatic-config/document.js +167 -0
- package/lib/types/apimatic-config/document.js.map +1 -0
- package/lib/types/apimatic-config/languages-block.d.ts +39 -0
- package/lib/types/apimatic-config/languages-block.js +58 -0
- package/lib/types/apimatic-config/languages-block.js.map +1 -0
- package/lib/types/apimatic-config-context.d.ts +48 -0
- package/lib/types/apimatic-config-context.js +121 -0
- package/lib/types/apimatic-config-context.js.map +1 -0
- package/lib/types/build/build.d.ts +1 -89
- package/lib/types/build/build.js +6 -161
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/events/domain-event.js +3 -0
- package/lib/types/events/domain-event.js.map +1 -1
- package/lib/types/events/quickstart-completed.js +3 -3
- package/lib/types/events/quickstart-completed.js.map +1 -1
- package/lib/types/events/quickstart-initiated.js +3 -3
- package/lib/types/events/quickstart-initiated.js.map +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js +1 -1
- package/lib/types/events/sdk-publish-validation-failed.js.map +1 -1
- package/lib/types/file/directory.d.ts +4 -9
- package/lib/types/file/directory.js +17 -65
- package/lib/types/file/directory.js.map +1 -1
- package/lib/types/file/directoryPath.d.ts +17 -0
- package/lib/types/file/directoryPath.js +47 -2
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/fileName.d.ts +8 -0
- package/lib/types/file/fileName.js +28 -6
- package/lib/types/file/fileName.js.map +1 -1
- package/lib/types/file/filePath.d.ts +18 -2
- package/lib/types/file/filePath.js +39 -4
- package/lib/types/file/filePath.js.map +1 -1
- package/lib/types/file/resource-input.js +1 -2
- package/lib/types/file/resource-input.js.map +1 -1
- package/lib/types/file/urlPath.js +2 -1
- package/lib/types/file/urlPath.js.map +1 -1
- package/lib/types/flags-provider.js +22 -22
- package/lib/types/flags-provider.js.map +1 -1
- package/lib/types/package-settings-context.js +2 -1
- package/lib/types/package-settings-context.js.map +1 -1
- package/lib/types/plugin/plugin-config.d.ts +10 -50
- package/lib/types/plugin/plugin-config.js +7 -1
- package/lib/types/plugin/plugin-config.js.map +1 -1
- package/lib/types/plugin-config-context.d.ts +30 -37
- package/lib/types/plugin-config-context.js +108 -139
- package/lib/types/plugin-config-context.js.map +1 -1
- package/lib/types/plugin-context.js +3 -2
- package/lib/types/plugin-context.js.map +1 -1
- package/lib/types/portal/code-samples.d.ts +27 -0
- package/lib/types/portal/code-samples.js +67 -0
- package/lib/types/portal/code-samples.js.map +1 -0
- package/lib/types/portal/config/ai-config.d.ts +15 -0
- package/lib/types/portal/config/ai-config.js +26 -0
- package/lib/types/portal/config/ai-config.js.map +1 -0
- package/lib/types/portal/config/brand-config.d.ts +55 -0
- package/lib/types/portal/config/brand-config.js +105 -0
- package/lib/types/portal/config/brand-config.js.map +1 -0
- package/lib/types/portal/config/color.d.ts +19 -0
- package/lib/types/portal/config/color.js +43 -0
- package/lib/types/portal/config/color.js.map +1 -0
- package/lib/types/portal/config/fields.d.ts +23 -0
- package/lib/types/portal/config/fields.js +67 -0
- package/lib/types/portal/config/fields.js.map +1 -0
- package/lib/types/portal/config/link.d.ts +18 -0
- package/lib/types/portal/config/link.js +72 -0
- package/lib/types/portal/config/link.js.map +1 -0
- package/lib/types/portal/config/navigation-config.d.ts +13 -0
- package/lib/types/portal/config/navigation-config.js +30 -0
- package/lib/types/portal/config/navigation-config.js.map +1 -0
- package/lib/types/portal/config/site-config.d.ts +32 -0
- package/lib/types/portal/config/site-config.js +88 -0
- package/lib/types/portal/config/site-config.js.map +1 -0
- package/lib/types/portal/config/static-asset.d.ts +25 -0
- package/lib/types/portal/config/static-asset.js +77 -0
- package/lib/types/portal/config/static-asset.js.map +1 -0
- package/lib/types/portal/content-notices.d.ts +20 -0
- package/lib/types/portal/content-notices.js +2 -0
- package/lib/types/portal/content-notices.js.map +1 -0
- package/lib/types/portal/content-tree.d.ts +103 -0
- package/lib/types/portal/content-tree.js +344 -0
- package/lib/types/portal/content-tree.js.map +1 -0
- package/lib/types/portal/endpoint.d.ts +6 -0
- package/lib/types/portal/endpoint.js +12 -0
- package/lib/types/portal/endpoint.js.map +1 -0
- package/lib/types/portal/generated-pages.d.ts +68 -0
- package/lib/types/portal/generated-pages.js +111 -0
- package/lib/types/portal/generated-pages.js.map +1 -0
- package/lib/types/portal/generation-status.d.ts +31 -0
- package/lib/types/portal/generation-status.js +26 -0
- package/lib/types/portal/generation-status.js.map +1 -0
- package/lib/types/portal/openapi-document.d.ts +48 -0
- package/lib/types/portal/openapi-document.js +138 -0
- package/lib/types/portal/openapi-document.js.map +1 -0
- package/lib/types/portal/page-fragments.d.ts +13 -0
- package/lib/types/portal/page-fragments.js +24 -0
- package/lib/types/portal/page-fragments.js.map +1 -0
- package/lib/types/portal/page-template.d.ts +15 -0
- package/lib/types/portal/page-template.js +64 -0
- package/lib/types/portal/page-template.js.map +1 -0
- package/lib/types/portal/page.d.ts +24 -0
- package/lib/types/portal/page.js +100 -0
- package/lib/types/portal/page.js.map +1 -0
- package/lib/types/portal/portal-artifacts.d.ts +25 -0
- package/lib/types/portal/portal-artifacts.js +30 -0
- package/lib/types/portal/portal-artifacts.js.map +1 -0
- package/lib/types/portal/portal-config.d.ts +69 -0
- package/lib/types/portal/portal-config.js +105 -0
- package/lib/types/portal/portal-config.js.map +1 -0
- package/lib/types/portal/portal-downloads.d.ts +8 -0
- package/lib/types/portal/portal-downloads.js +14 -0
- package/lib/types/portal/portal-downloads.js.map +1 -0
- package/lib/types/portal/portal-languages.d.ts +15 -0
- package/lib/types/portal/portal-languages.js +45 -0
- package/lib/types/portal/portal-languages.js.map +1 -0
- package/lib/types/portal/portal-navigation.d.ts +65 -0
- package/lib/types/portal/portal-navigation.js +217 -0
- package/lib/types/portal/portal-navigation.js.map +1 -0
- package/lib/types/portal/portal-sdk.d.ts +15 -0
- package/lib/types/portal/portal-sdk.js +28 -0
- package/lib/types/portal/portal-sdk.js.map +1 -0
- package/lib/types/portal/portal-source.d.ts +129 -0
- package/lib/types/portal/portal-source.js +2 -0
- package/lib/types/portal/portal-source.js.map +1 -0
- package/lib/types/portal/portal-stylesheet.d.ts +19 -0
- package/lib/types/portal/portal-stylesheet.js +40 -0
- package/lib/types/portal/portal-stylesheet.js.map +1 -0
- package/lib/types/portal/portal-tabs.d.ts +33 -0
- package/lib/types/portal/portal-tabs.js +38 -0
- package/lib/types/portal/portal-tabs.js.map +1 -0
- package/lib/types/portal/preview-config.d.ts +20 -0
- package/lib/types/portal/preview-config.js +32 -0
- package/lib/types/portal/preview-config.js.map +1 -0
- package/lib/types/portal/preview-content.d.ts +18 -0
- package/lib/types/portal/preview-content.js +50 -0
- package/lib/types/portal/preview-content.js.map +1 -0
- package/lib/types/portal/published-package.d.ts +12 -0
- package/lib/types/portal/published-package.js +35 -0
- package/lib/types/portal/published-package.js.map +1 -0
- package/lib/types/portal/unknown-fields.d.ts +5 -0
- package/lib/types/portal/unknown-fields.js +10 -0
- package/lib/types/portal/unknown-fields.js.map +1 -0
- package/lib/types/portal-context.d.ts +38 -6
- package/lib/types/portal-context.js +71 -24
- package/lib/types/portal-context.js.map +1 -1
- package/lib/types/portal-source-context.d.ts +77 -0
- package/lib/types/portal-source-context.js +408 -0
- package/lib/types/portal-source-context.js.map +1 -0
- package/lib/types/project-context.d.ts +49 -0
- package/lib/types/project-context.js +151 -0
- package/lib/types/project-context.js.map +1 -0
- package/lib/types/project-layout.d.ts +9 -0
- package/lib/types/project-layout.js +10 -0
- package/lib/types/project-layout.js.map +1 -0
- package/lib/types/publish/package-settings-configuration.d.ts +2 -0
- package/lib/types/publish/profile-id.js +1 -0
- package/lib/types/publish/profile-id.js.map +1 -1
- package/lib/types/publish/publishing-profile.d.ts +3 -1
- package/lib/types/publish/publishing-profile.js +33 -15
- package/lib/types/publish/publishing-profile.js.map +1 -1
- package/lib/types/publish/publishing-profiles.js +2 -1
- package/lib/types/publish/publishing-profiles.js.map +1 -1
- package/lib/types/publish/version.js +1 -0
- package/lib/types/publish/version.js.map +1 -1
- package/lib/types/resource-context.js +3 -2
- package/lib/types/resource-context.js.map +1 -1
- package/lib/types/sdk/generate.d.ts +22 -16
- package/lib/types/sdk/generate.js +64 -41
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk/stability-choice.d.ts +12 -0
- package/lib/types/sdk/stability-choice.js +24 -0
- package/lib/types/sdk/stability-choice.js.map +1 -0
- package/lib/types/sdk-context.d.ts +4 -5
- package/lib/types/sdk-context.js +10 -18
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/spec-context.d.ts +5 -4
- package/lib/types/spec-context.js +9 -8
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.d.ts +1 -1
- package/lib/types/temp-context.js +5 -4
- package/lib/types/temp-context.js.map +1 -1
- package/lib/types/transform-context.d.ts +9 -5
- package/lib/types/transform-context.js +21 -18
- package/lib/types/transform-context.js.map +1 -1
- package/lib/utils/error-utils.d.ts +2 -0
- package/lib/utils/error-utils.js +5 -0
- package/lib/utils/error-utils.js.map +1 -0
- package/lib/utils/json-utils.d.ts +2 -0
- package/lib/utils/json-utils.js +4 -0
- package/lib/utils/json-utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +8 -1
- package/lib/utils/string-utils.js +13 -26
- package/lib/utils/string-utils.js.map +1 -1
- package/lib/utils/utils.d.ts +1 -3
- package/lib/utils/utils.js +12 -40
- package/lib/utils/utils.js.map +1 -1
- package/oclif.manifest.json +69 -357
- package/package.json +47 -25
- package/portal-pages/context-plugin.mdx +26 -0
- package/portal-pages/sdk.mdx +8 -0
- package/portal-pages/sdks.mdx +11 -0
- package/portal-template/NOTICE +37 -0
- package/portal-template/downloads.ts +41 -0
- package/portal-template/generated-pages-reload.ts +51 -0
- package/portal-template/package.json +11 -0
- package/portal-template/portal-config.ts +32 -0
- package/portal-template/prerender-pages.ts +81 -0
- package/portal-template/spec-reload.ts +26 -0
- package/portal-template/src/components/api-page.tsx +15 -0
- package/portal-template/src/components/code-block.tsx +9 -0
- package/portal-template/src/components/command-block.tsx +50 -0
- package/portal-template/src/components/example-layout.tsx +99 -0
- package/portal-template/src/components/logos.tsx +127 -0
- package/portal-template/src/components/mdx.tsx +28 -0
- package/portal-template/src/components/not-found.tsx +11 -0
- package/portal-template/src/components/plugin-install.tsx +22 -0
- package/portal-template/src/components/plugin-support.tsx +53 -0
- package/portal-template/src/components/sdk-actions.tsx +79 -0
- package/portal-template/src/components/sdk-cards.tsx +100 -0
- package/portal-template/src/components/search.tsx +41 -0
- package/portal-template/src/components/usage-tabs.tsx +92 -0
- package/portal-template/src/lib/code-samples.server.ts +40 -0
- package/portal-template/src/lib/code-samples.ts +43 -0
- package/portal-template/src/lib/code-titles.ts +29 -0
- package/portal-template/src/lib/install-command.ts +13 -0
- package/portal-template/src/lib/json.ts +5 -0
- package/portal-template/src/lib/layout.shared.tsx +41 -0
- package/portal-template/src/lib/layout.tsx +16 -0
- package/portal-template/src/lib/llms.server.ts +54 -0
- package/portal-template/src/lib/media-adapters.ts +34 -0
- package/portal-template/src/lib/navigation.ts +406 -0
- package/portal-template/src/lib/openapi-bundle.server.ts +343 -0
- package/portal-template/src/lib/openapi-filter.ts +191 -0
- package/portal-template/src/lib/openapi-labels.ts +15 -0
- package/portal-template/src/lib/openapi-methods.ts +12 -0
- package/portal-template/src/lib/openapi-section.server.ts +280 -0
- package/portal-template/src/lib/openapi-slim.ts +202 -0
- package/portal-template/src/lib/openapi.server.ts +16 -0
- package/portal-template/src/lib/portal-types.ts +36 -0
- package/portal-template/src/lib/portal.server.ts +13 -0
- package/portal-template/src/lib/portal.ts +11 -0
- package/portal-template/src/lib/rehype-code-titles.ts +53 -0
- package/portal-template/src/lib/request-examples.ts +72 -0
- package/portal-template/src/lib/seo.ts +21 -0
- package/portal-template/src/lib/shared.ts +51 -0
- package/portal-template/src/lib/shiki-bundle.ts +104 -0
- package/portal-template/src/lib/sitemap.server.ts +20 -0
- package/portal-template/src/lib/source.server.ts +27 -0
- package/portal-template/src/lib/source.ts +49 -0
- package/portal-template/src/lib/tabs.ts +37 -0
- package/portal-template/src/router.tsx +12 -0
- package/portal-template/src/routes/$.tsx +194 -0
- package/portal-template/src/routes/__root.tsx +56 -0
- package/portal-template/src/routes/api/search[.]json.ts +9 -0
- package/portal-template/src/routes/llms-full[.]txt.ts +10 -0
- package/portal-template/src/routes/llms[.]txt.ts +10 -0
- package/portal-template/src/routes/robots[.]txt.ts +10 -0
- package/portal-template/src/routes/sitemap[.]xml.ts +10 -0
- package/portal-template/src/routes/spa-shell.tsx +7 -0
- package/portal-template/src/routes/{$}[.]md.ts +21 -0
- package/portal-template/src/styles/app.css +33 -0
- package/portal-template/tsconfig.json +26 -0
- package/portal-template/vite.config.ts +68 -0
- package/lib/actions/plugin/record-sdk.d.ts +0 -14
- package/lib/actions/plugin/record-sdk.js +0 -60
- package/lib/actions/plugin/record-sdk.js.map +0 -1
- package/lib/actions/portal/copilot.d.ts +0 -17
- package/lib/actions/portal/copilot.js +0 -89
- package/lib/actions/portal/copilot.js.map +0 -1
- package/lib/actions/portal/quickstart.d.ts +0 -18
- package/lib/actions/portal/quickstart.js +0 -238
- package/lib/actions/portal/quickstart.js.map +0 -1
- package/lib/actions/portal/recipe/new-recipe.d.ts +0 -15
- package/lib/actions/portal/recipe/new-recipe.js +0 -177
- package/lib/actions/portal/recipe/new-recipe.js.map +0 -1
- package/lib/actions/portal/toc/new-toc.d.ts +0 -21
- package/lib/actions/portal/toc/new-toc.js +0 -95
- package/lib/actions/portal/toc/new-toc.js.map +0 -1
- package/lib/actions/sdk/merge-source-tree.d.ts +0 -12
- package/lib/actions/sdk/merge-source-tree.js +0 -78
- package/lib/actions/sdk/merge-source-tree.js.map +0 -1
- package/lib/actions/sdk/quickstart.d.ts +0 -18
- package/lib/actions/sdk/quickstart.js +0 -188
- package/lib/actions/sdk/quickstart.js.map +0 -1
- package/lib/actions/sdk/save-changes.d.ts +0 -8
- package/lib/actions/sdk/save-changes.js +0 -93
- package/lib/actions/sdk/save-changes.js.map +0 -1
- package/lib/application/portal/recipe/portal-recipe.d.ts +0 -8
- package/lib/application/portal/recipe/portal-recipe.js +0 -33
- package/lib/application/portal/recipe/portal-recipe.js.map +0 -1
- package/lib/application/portal/recipe/recipe-generator.d.ts +0 -21
- package/lib/application/portal/recipe/recipe-generator.js +0 -130
- package/lib/application/portal/recipe/recipe-generator.js.map +0 -1
- package/lib/application/portal/toc/toc-content-parser.d.ts +0 -5
- package/lib/application/portal/toc/toc-content-parser.js +0 -44
- package/lib/application/portal/toc/toc-content-parser.js.map +0 -1
- package/lib/application/portal/toc/toc-structure-generator.d.ts +0 -11
- package/lib/application/portal/toc/toc-structure-generator.js +0 -165
- package/lib/application/portal/toc/toc-structure-generator.js.map +0 -1
- package/lib/commands/portal/copilot.d.ts +0 -13
- package/lib/commands/portal/copilot.js +0 -34
- package/lib/commands/portal/copilot.js.map +0 -1
- package/lib/commands/portal/recipe/new.d.ts +0 -12
- package/lib/commands/portal/recipe/new.js +0 -45
- package/lib/commands/portal/recipe/new.js.map +0 -1
- package/lib/commands/portal/toc/new.d.ts +0 -16
- package/lib/commands/portal/toc/new.js +0 -68
- package/lib/commands/portal/toc/new.js.map +0 -1
- package/lib/commands/sdk/save-changes.d.ts +0 -14
- package/lib/commands/sdk/save-changes.js +0 -51
- package/lib/commands/sdk/save-changes.js.map +0 -1
- package/lib/infrastructure/debounce-service.d.ts +0 -10
- package/lib/infrastructure/debounce-service.js +0 -55
- package/lib/infrastructure/debounce-service.js.map +0 -1
- package/lib/infrastructure/services/portal-service.d.ts +0 -43
- package/lib/infrastructure/services/portal-service.js +0 -337
- package/lib/infrastructure/services/portal-service.js.map +0 -1
- package/lib/prompts/plugin/record-sdk.d.ts +0 -9
- package/lib/prompts/plugin/record-sdk.js +0 -40
- package/lib/prompts/plugin/record-sdk.js.map +0 -1
- package/lib/prompts/portal/copilot.d.ts +0 -18
- package/lib/prompts/portal/copilot.js +0 -82
- package/lib/prompts/portal/copilot.js.map +0 -1
- package/lib/prompts/portal/quickstart.d.ts +0 -42
- package/lib/prompts/portal/quickstart.js +0 -243
- package/lib/prompts/portal/quickstart.js.map +0 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +0 -29
- package/lib/prompts/portal/recipe/new-recipe.js +0 -165
- package/lib/prompts/portal/recipe/new-recipe.js.map +0 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +0 -16
- package/lib/prompts/portal/toc/new-toc.js +0 -50
- package/lib/prompts/portal/toc/new-toc.js.map +0 -1
- package/lib/prompts/sdk/merge-source-tree.d.ts +0 -22
- package/lib/prompts/sdk/merge-source-tree.js +0 -90
- package/lib/prompts/sdk/merge-source-tree.js.map +0 -1
- package/lib/prompts/sdk/quickstart.d.ts +0 -38
- package/lib/prompts/sdk/quickstart.js +0 -196
- package/lib/prompts/sdk/quickstart.js.map +0 -1
- package/lib/prompts/sdk/save-changes.d.ts +0 -21
- package/lib/prompts/sdk/save-changes.js +0 -84
- package/lib/prompts/sdk/save-changes.js.map +0 -1
- package/lib/types/build-context.d.ts +0 -26
- package/lib/types/build-context.js +0 -111
- package/lib/types/build-context.js.map +0 -1
- package/lib/types/events/recipe-creation-failed.d.ts +0 -5
- package/lib/types/events/recipe-creation-failed.js +0 -8
- package/lib/types/events/recipe-creation-failed.js.map +0 -1
- package/lib/types/events/sdk-changes-saved.d.ts +0 -8
- package/lib/types/events/sdk-changes-saved.js +0 -11
- package/lib/types/events/sdk-changes-saved.js.map +0 -1
- package/lib/types/events/sdk-changes-tracked.d.ts +0 -8
- package/lib/types/events/sdk-changes-tracked.js +0 -11
- package/lib/types/events/sdk-changes-tracked.js.map +0 -1
- package/lib/types/events/sdk-conflicts-resolved.d.ts +0 -8
- package/lib/types/events/sdk-conflicts-resolved.js +0 -11
- package/lib/types/events/sdk-conflicts-resolved.js.map +0 -1
- package/lib/types/events/toc-creation-failed.d.ts +0 -5
- package/lib/types/events/toc-creation-failed.js +0 -8
- package/lib/types/events/toc-creation-failed.js.map +0 -1
- package/lib/types/merge-source-tree-context.d.ts +0 -28
- package/lib/types/merge-source-tree-context.js +0 -63
- package/lib/types/merge-source-tree-context.js.map +0 -1
- package/lib/types/plugin/language-entry.d.ts +0 -9
- package/lib/types/plugin/language-entry.js +0 -64
- package/lib/types/plugin/language-entry.js.map +0 -1
- package/lib/types/recipe/recipe.d.ts +0 -22
- package/lib/types/recipe/recipe.js +0 -6
- package/lib/types/recipe/recipe.js.map +0 -1
- package/lib/types/recipe-context.d.ts +0 -9
- package/lib/types/recipe-context.js +0 -26
- package/lib/types/recipe-context.js.map +0 -1
- package/lib/types/save-changes-context.d.ts +0 -17
- package/lib/types/save-changes-context.js +0 -42
- package/lib/types/save-changes-context.js.map +0 -1
- package/lib/types/sdl/sdl.d.ts +0 -10
- package/lib/types/sdl/sdl.js +0 -18
- package/lib/types/sdl/sdl.js.map +0 -1
- package/lib/types/toc/toc-components.d.ts +0 -36
- package/lib/types/toc/toc-components.js +0 -94
- package/lib/types/toc/toc-components.js.map +0 -1
- package/lib/types/toc/toc.d.ts +0 -67
- package/lib/types/toc/toc.js +0 -2
- package/lib/types/toc/toc.js.map +0 -1
- package/lib/types/toc-context.d.ts +0 -12
- package/lib/types/toc-context.js +0 -26
- package/lib/types/toc-context.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-interactive.js","sourceRoot":"","sources":["../../../../src/prompts/sdk/publish/non-interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"non-interactive.js","sourceRoot":"","sources":["../../../../src/prompts/sdk/publish/non-interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,MAAM,OAAO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log.js';
|
|
|
4
4
|
import { PublishingInfo } from '../../types/publish-api/publishing-info.js';
|
|
5
5
|
import { PublishType } from '../../types/publish-api/publishing-profile-item.js';
|
|
6
6
|
import { SemVersion } from '../../types/publish/version.js';
|
|
7
|
-
import {
|
|
7
|
+
import { Language, Stability } from '../../types/sdk/generate.js';
|
|
8
8
|
import { PublishingProfile } from '../../types/publish/publishing-profile.js';
|
|
9
9
|
export type PublishingOutcome = 'succeeded' | 'failed' | 'cancelled';
|
|
10
10
|
export declare class SdkPublishPrompts {
|
|
@@ -20,6 +20,6 @@ export interface PublishingDetails {
|
|
|
20
20
|
language: Language;
|
|
21
21
|
version: SemVersion;
|
|
22
22
|
publishType: PublishType[];
|
|
23
|
-
|
|
23
|
+
stability?: Stability;
|
|
24
24
|
}
|
|
25
|
-
export declare function formatPublishingDetails({ profile, language, version, publishType,
|
|
25
|
+
export declare function formatPublishingDetails({ profile, language, version, publishType, stability }: PublishingDetails): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { log, spinner } from '@clack/prompts';
|
|
2
|
+
import { sleep } from '../../infrastructure/timer-extensions.js';
|
|
2
3
|
import { PublishType } from '../../types/publish-api/publishing-profile-item.js';
|
|
3
4
|
import { noteWrapped, withSpinner } from '../prompt.js';
|
|
4
5
|
import { format as f } from '../format.js';
|
|
@@ -24,10 +25,10 @@ ${f.link(publishingLogUrl)}`;
|
|
|
24
25
|
async pollPublishingStatus(getSdkPublishingLogFn) {
|
|
25
26
|
const TERMINAL_STATES = new Set(['Succeeded', 'Failed', 'Exception', 'InternalError']);
|
|
26
27
|
const POLL_INTERVAL_MS = 10000; // poll after every 10 seconds.
|
|
27
|
-
|
|
28
|
+
const waitAbort = new AbortController();
|
|
28
29
|
const spin = spinner({
|
|
29
30
|
onCancel: () => {
|
|
30
|
-
|
|
31
|
+
waitAbort.abort();
|
|
31
32
|
},
|
|
32
33
|
cancelMessage: 'Publishing is still running on APIMatic and will continue without the CLI.'
|
|
33
34
|
});
|
|
@@ -43,14 +44,13 @@ ${f.link(publishingLogUrl)}`;
|
|
|
43
44
|
const statusMessage = [...events]
|
|
44
45
|
.sort((a, b) => (a.publishType === 'SourceCode' ? -1 : b.publishType === 'SourceCode' ? 1 : 0))
|
|
45
46
|
.map((event) => {
|
|
46
|
-
var _a;
|
|
47
47
|
const target = event.publishType === 'SourceCode' ? 'Source Code' : 'Package';
|
|
48
48
|
const eventLabels = {
|
|
49
49
|
Queued: 'Queued',
|
|
50
50
|
InProgress: 'In Progress',
|
|
51
51
|
Succeeded: 'Published'
|
|
52
52
|
};
|
|
53
|
-
const label =
|
|
53
|
+
const label = eventLabels[event.eventType] ?? 'Failed';
|
|
54
54
|
return `${target}: [${label}]`;
|
|
55
55
|
})
|
|
56
56
|
.join(' | ');
|
|
@@ -60,23 +60,19 @@ ${f.link(publishingLogUrl)}`;
|
|
|
60
60
|
return isExecutionSuccessful ? 'succeeded' : 'failed';
|
|
61
61
|
}
|
|
62
62
|
spin.message(statusMessage);
|
|
63
|
-
await
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
resolve();
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
abortWait = undefined;
|
|
63
|
+
const sleepResult = await sleep(POLL_INTERVAL_MS, waitAbort.signal);
|
|
64
|
+
if (sleepResult !== 'ok') {
|
|
65
|
+
return sleepResult;
|
|
66
|
+
}
|
|
71
67
|
}
|
|
72
68
|
return 'cancelled';
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
|
-
export function formatPublishingDetails({ profile, language, version, publishType,
|
|
71
|
+
export function formatPublishingDetails({ profile, language, version, publishType, stability }) {
|
|
76
72
|
const targets = [...publishType]
|
|
77
|
-
.map((t) => (t === PublishType.PackagePublishing ?
|
|
78
|
-
.join(
|
|
79
|
-
const
|
|
80
|
-
return `\n\n Profile: ${profile}\n Language: ${language}\n Version: ${version}\n Targets: ${targets}${
|
|
73
|
+
.map((t) => (t === PublishType.PackagePublishing ? 'Package' : 'Source Code'))
|
|
74
|
+
.join(' + ');
|
|
75
|
+
const level = stability ? `\n Stability: ${stability}` : '';
|
|
76
|
+
return `\n\n Profile: ${profile}\n Language: ${language}\n Version: ${version}\n Targets: ${targets}${level}`;
|
|
81
77
|
}
|
|
82
78
|
//# sourceMappingURL=publish.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/prompts/sdk/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/prompts/sdk/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAC;AAGjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,OAAO,iBAAiB;IACrB,UAAU,CAAC,EAAiD;QACjE,OAAO,WAAW,CAAC,gBAAgB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,EAAE,CAAC,CAAC;IAC9F,CAAC;IAEM,yBAAyB,CAAC,YAA0B;QACzD,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAEM,YAAY,CAAC,iBAAyB;QAC3C,GAAG,CAAC,IAAI,CACN,kGAAkG;YAChG,iBAAiB,CACpB,CAAC;IACJ,CAAC;IAEM,uBAAuB,CAAC,iBAAyB;QACtD,GAAG,CAAC,IAAI,CAAC,0CAA0C,GAAG,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAEM,qBAAqB,CAAC,gBAAwB;QACnD,MAA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O,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACS;IAClB,MAAM,OAAO,GAAG,CAAC,GAAG,WAAW,CAAC;SAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;SAC7E,IAAI,CAAC,KAAK,CAAC,CAAC;IAEf,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,kBAAkB,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,OAAO,oBAAoB,OAAO,kBAAkB,QAAQ,kBAAkB,OAAO,kBAAkB,OAAO,GAAG,KAAK,EAAE,CAAC;AAC3H,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Language } from '../../types/sdk/generate.js';
|
|
2
|
+
export declare class RecordPublishedSdkPrompts {
|
|
3
|
+
sdkRecorded(language: Language, configExists: boolean): void;
|
|
4
|
+
noSourceRepository(language: Language): void;
|
|
5
|
+
configUnreadable(reason?: string): void;
|
|
6
|
+
configNotWritten(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { log } from '@clack/prompts';
|
|
2
|
+
import { APIMATIC_CONFIG_FILE_NAME } from '../../types/apimatic-config/document.js';
|
|
3
|
+
import { format as f } from '../format.js';
|
|
4
|
+
export class RecordPublishedSdkPrompts {
|
|
5
|
+
sdkRecorded(language, configExists) {
|
|
6
|
+
const message = (configExists
|
|
7
|
+
? `Updated ${f.var(APIMATIC_CONFIG_FILE_NAME)} for ${f.var(language)}. `
|
|
8
|
+
: `Created ${f.var(APIMATIC_CONFIG_FILE_NAME)} and added ${f.var(language)}. `) +
|
|
9
|
+
`Run '${f.cmdAlt('apimatic', 'plugin', 'generate')}' to build your context plugin.`;
|
|
10
|
+
log.info(message);
|
|
11
|
+
}
|
|
12
|
+
noSourceRepository(language) {
|
|
13
|
+
const message = `Context plugin generation needs a source repository, and none was published for ${f.var(language)}. ` +
|
|
14
|
+
`Publish the SDK's source code to complete its ${f.var(APIMATIC_CONFIG_FILE_NAME)} entry.`;
|
|
15
|
+
log.warn(message);
|
|
16
|
+
}
|
|
17
|
+
configUnreadable(reason) {
|
|
18
|
+
const cause = reason ? `: ${reason}` : '';
|
|
19
|
+
const message = `${f.var(APIMATIC_CONFIG_FILE_NAME)} cannot be used${cause}, so this published SDK's details were not added to it. ` + `Fix it and try again.`;
|
|
20
|
+
log.warn(message);
|
|
21
|
+
}
|
|
22
|
+
configNotWritten() {
|
|
23
|
+
log.warn(`${f.var(APIMATIC_CONFIG_FILE_NAME)} could not be written, so this published SDK's details were not added to it.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=record-published-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-published-sdk.js","sourceRoot":"","sources":["../../../src/prompts/sdk/record-published-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,yBAAyB;IAC7B,WAAW,CAAC,QAAkB,EAAE,YAAqB;QAC1D,MAAM,OAAO,GACX,CAAC,YAAY;YACX,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI;YACxE,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;YACjF,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,iCAAiC,CAAC;QACtF,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,kBAAkB,CAAC,QAAkB;QAC1C,MAAM,OAAO,GACX,mFAAmF,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI;YACtG,iDAAiD,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,SAAS,CAAC;QAC7F,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,gBAAgB,CAAC,MAAe;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM,OAAO,GACX,GAAG,CAAC,CAAC,GAAG,CACN,yBAAyB,CAC1B,kBAAkB,KAAK,0DAA0D,GAAG,uBAAuB,CAAC;QAC/G,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,gBAAgB;QACrB,GAAG,CAAC,IAAI,CACN,GAAG,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,8EAA8E,CAClH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
export declare const APIMATIC_CONFIG_FILE_NAME = "apimatic.json";
|
|
3
|
+
/** Where editors find the file's schema: the copy the published package carries, for this major. */
|
|
4
|
+
export declare const APIMATIC_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@apimatic/cli@2/apimatic.schema.json";
|
|
5
|
+
/**
|
|
6
|
+
* The schema address a file written by this version of the CLI carries. jsDelivr resolves a
|
|
7
|
+
* major range to its newest stable release and never to a prerelease, so `@2` leads nowhere
|
|
8
|
+
* until 2.0.0 ships; a prerelease names its own version instead, which jsDelivr serves exactly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function schemaUrlFor(cliVersion: string): string;
|
|
11
|
+
/** The one format this CLI reads. A file naming another is refused rather than misread. */
|
|
12
|
+
export declare const SCHEMA_VERSION = 1;
|
|
13
|
+
/** A block one command owns. */
|
|
14
|
+
export type ConfigBlockName = 'portal' | 'plugin' | 'languages';
|
|
15
|
+
/** Where a finding comes from: a block, or `root` for the file itself and the keys beside the blocks. */
|
|
16
|
+
export type ConfigBlock = 'root' | ConfigBlockName;
|
|
17
|
+
/**
|
|
18
|
+
* Something wrong with the file, kept apart from its wording. The portal path lists findings
|
|
19
|
+
* one sentence each and the plugin path folds them into one clause behind the file's name; both
|
|
20
|
+
* read the same `field` and `problem`, so the two cannot drift.
|
|
21
|
+
*/
|
|
22
|
+
export interface ConfigFinding {
|
|
23
|
+
block: ConfigBlock;
|
|
24
|
+
/** The key the finding is about, as a dotted path from the root, or null for the file as a whole. */
|
|
25
|
+
field: string | null;
|
|
26
|
+
/** What is wrong with it, as a predicate: "is not a JSON object". */
|
|
27
|
+
problem: string;
|
|
28
|
+
}
|
|
29
|
+
/** The parsed `apimatic.json`: its blocks, the keys around them in the order written, and what is wrong with it. */
|
|
30
|
+
export declare class ApimaticConfigDocument {
|
|
31
|
+
private readonly root;
|
|
32
|
+
private readonly findings;
|
|
33
|
+
private constructor();
|
|
34
|
+
/** What a file the CLI creates starts from. */
|
|
35
|
+
static empty(): ApimaticConfigDocument;
|
|
36
|
+
/**
|
|
37
|
+
* Refuses only what no command could use: a file holding no JSON object at all. Everything
|
|
38
|
+
* else parses, and what is wrong inside it is carried as findings for each command to read or
|
|
39
|
+
* ignore by block, so a malformed block one command owns never stops another.
|
|
40
|
+
*/
|
|
41
|
+
static parse(text: string): Result<ApimaticConfigDocument, ConfigFinding[]>;
|
|
42
|
+
private static of;
|
|
43
|
+
private static analyze;
|
|
44
|
+
private static schemaVersionFindings;
|
|
45
|
+
private static pluginFindings;
|
|
46
|
+
private static languagesFindings;
|
|
47
|
+
/** As written, whatever that is: the portal's own parser says what is wrong with it. */
|
|
48
|
+
portal(): unknown;
|
|
49
|
+
/** The block, or undefined when it is absent or, as the findings say, not an object. */
|
|
50
|
+
plugin(): Record<string, unknown> | undefined;
|
|
51
|
+
/** The block, or undefined when it is absent or, as the findings say, not an object. */
|
|
52
|
+
languages(): Record<string, unknown> | undefined;
|
|
53
|
+
findingsFor(...blocks: ConfigBlock[]): ConfigFinding[];
|
|
54
|
+
/** `$schema` goes first among the keys, where a reader looks for it. */
|
|
55
|
+
referencingSchema(schemaUrl: string): ApimaticConfigDocument;
|
|
56
|
+
/**
|
|
57
|
+
* The document with one block replaced. A block the file already holds keeps its place among
|
|
58
|
+
* the other keys; a new one goes after the last.
|
|
59
|
+
*/
|
|
60
|
+
with(block: ConfigBlockName, value: object): ApimaticConfigDocument;
|
|
61
|
+
/** The file's text, keys in the order held, in the indentation and with the ending the caller found. */
|
|
62
|
+
serialize(indent: string, trailingNewline: boolean): string;
|
|
63
|
+
}
|
|
64
|
+
/** One sentence per finding, each naming the file or the field, for a list a user fixes one line at a time. */
|
|
65
|
+
export declare function findingSentences(findings: readonly ConfigFinding[]): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Every finding as one clause about the file, for a message that has already named it:
|
|
68
|
+
* "it is empty", "its 'languages' is not a JSON object".
|
|
69
|
+
*/
|
|
70
|
+
export declare function findingClause(findings: readonly ConfigFinding[]): string;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { err, ok } from 'neverthrow';
|
|
2
|
+
import { isJsonObject } from '../../utils/json-utils.js';
|
|
3
|
+
import { stripByteOrderMark } from '../../utils/string-utils.js';
|
|
4
|
+
import { PLUGIN_ID_PATTERN } from '../plugin/plugin-config.js';
|
|
5
|
+
import { SemVersion } from '../publish/version.js';
|
|
6
|
+
export const APIMATIC_CONFIG_FILE_NAME = 'apimatic.json';
|
|
7
|
+
/** Where editors find the file's schema: the copy the published package carries, for this major. */
|
|
8
|
+
export const APIMATIC_SCHEMA_URL = 'https://cdn.jsdelivr.net/npm/@apimatic/cli@2/apimatic.schema.json';
|
|
9
|
+
/**
|
|
10
|
+
* The schema address a file written by this version of the CLI carries. jsDelivr resolves a
|
|
11
|
+
* major range to its newest stable release and never to a prerelease, so `@2` leads nowhere
|
|
12
|
+
* until 2.0.0 ships; a prerelease names its own version instead, which jsDelivr serves exactly.
|
|
13
|
+
*/
|
|
14
|
+
export function schemaUrlFor(cliVersion) {
|
|
15
|
+
return /^\d+\.\d+\.\d+-\S+$/.test(cliVersion)
|
|
16
|
+
? `https://cdn.jsdelivr.net/npm/@apimatic/cli@${cliVersion}/apimatic.schema.json`
|
|
17
|
+
: APIMATIC_SCHEMA_URL;
|
|
18
|
+
}
|
|
19
|
+
/** The one format this CLI reads. A file naming another is refused rather than misread. */
|
|
20
|
+
export const SCHEMA_VERSION = 1;
|
|
21
|
+
const NOT_A_JSON_OBJECT = 'is not a JSON object';
|
|
22
|
+
const MALFORMED_PLUGIN_ID = `must be lower-case alphanumeric words separated by single dashes, for example 'acme-payments'`;
|
|
23
|
+
const MALFORMED_PLUGIN_VERSION = `must be a version in the format major.minor.patch, for example '0.1.0'`;
|
|
24
|
+
/** The parsed `apimatic.json`: its blocks, the keys around them in the order written, and what is wrong with it. */
|
|
25
|
+
export class ApimaticConfigDocument {
|
|
26
|
+
root;
|
|
27
|
+
findings;
|
|
28
|
+
constructor(root, findings) {
|
|
29
|
+
this.root = root;
|
|
30
|
+
this.findings = findings;
|
|
31
|
+
}
|
|
32
|
+
/** What a file the CLI creates starts from. */
|
|
33
|
+
static empty() {
|
|
34
|
+
return ApimaticConfigDocument.of({ schemaVersion: SCHEMA_VERSION });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Refuses only what no command could use: a file holding no JSON object at all. Everything
|
|
38
|
+
* else parses, and what is wrong inside it is carried as findings for each command to read or
|
|
39
|
+
* ignore by block, so a malformed block one command owns never stops another.
|
|
40
|
+
*/
|
|
41
|
+
static parse(text) {
|
|
42
|
+
const contents = stripByteOrderMark(text);
|
|
43
|
+
if (contents.trim() === '') {
|
|
44
|
+
return err([{ block: 'root', field: null, problem: 'is empty' }]);
|
|
45
|
+
}
|
|
46
|
+
let data;
|
|
47
|
+
try {
|
|
48
|
+
data = JSON.parse(contents);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return err([{ block: 'root', field: null, problem: 'is not valid JSON' }]);
|
|
52
|
+
}
|
|
53
|
+
if (!isJsonObject(data)) {
|
|
54
|
+
return err([{ block: 'root', field: null, problem: NOT_A_JSON_OBJECT }]);
|
|
55
|
+
}
|
|
56
|
+
return ok(ApimaticConfigDocument.of(data));
|
|
57
|
+
}
|
|
58
|
+
static of(root) {
|
|
59
|
+
return new ApimaticConfigDocument(root, ApimaticConfigDocument.analyze(root));
|
|
60
|
+
}
|
|
61
|
+
// The shape checks are what the writers need: a merge spreads a block, which turns a string
|
|
62
|
+
// into `{"0":"a"}` and a number into nothing, so a wrong shape is refused before it can
|
|
63
|
+
// corrupt the file. The identity checks are the plugin's own rules, reported here so the
|
|
64
|
+
// portal path can leave them unread.
|
|
65
|
+
static analyze(root) {
|
|
66
|
+
return [
|
|
67
|
+
...ApimaticConfigDocument.schemaVersionFindings(root.schemaVersion),
|
|
68
|
+
...ApimaticConfigDocument.pluginFindings(root.plugin),
|
|
69
|
+
...ApimaticConfigDocument.languagesFindings(root.languages)
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
static schemaVersionFindings(schemaVersion) {
|
|
73
|
+
if (schemaVersion === undefined || schemaVersion === SCHEMA_VERSION) {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
const written = JSON.stringify(schemaVersion);
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
block: 'root',
|
|
80
|
+
field: 'schemaVersion',
|
|
81
|
+
problem: `is ${written}, which this version of the CLI does not read; it reads ${SCHEMA_VERSION}`
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
static pluginFindings(plugin) {
|
|
86
|
+
if (plugin === undefined) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
if (!isJsonObject(plugin)) {
|
|
90
|
+
return [{ block: 'plugin', field: 'plugin', problem: NOT_A_JSON_OBJECT }];
|
|
91
|
+
}
|
|
92
|
+
const findings = [];
|
|
93
|
+
const id = plugin.pluginId;
|
|
94
|
+
if (typeof id === 'string' && (id.trim() === '' || !PLUGIN_ID_PATTERN.test(id))) {
|
|
95
|
+
findings.push({ block: 'plugin', field: 'plugin.pluginId', problem: MALFORMED_PLUGIN_ID });
|
|
96
|
+
}
|
|
97
|
+
const version = plugin.pluginVersion;
|
|
98
|
+
if (typeof version === 'string' && (version.trim() === '' || SemVersion.tryCreate(version).isErr())) {
|
|
99
|
+
findings.push({ block: 'plugin', field: 'plugin.pluginVersion', problem: MALFORMED_PLUGIN_VERSION });
|
|
100
|
+
}
|
|
101
|
+
return findings;
|
|
102
|
+
}
|
|
103
|
+
static languagesFindings(languages) {
|
|
104
|
+
if (languages === undefined) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
if (!isJsonObject(languages)) {
|
|
108
|
+
return [{ block: 'languages', field: 'languages', problem: NOT_A_JSON_OBJECT }];
|
|
109
|
+
}
|
|
110
|
+
// Both levels are spread by `upsertLanguage`, so both are refused when they are not objects.
|
|
111
|
+
return Object.entries(languages).flatMap(([language, entry]) => {
|
|
112
|
+
if (!isJsonObject(entry)) {
|
|
113
|
+
return [{ block: 'languages', field: `languages.${language}`, problem: NOT_A_JSON_OBJECT }];
|
|
114
|
+
}
|
|
115
|
+
if (entry.publishing !== undefined && !isJsonObject(entry.publishing)) {
|
|
116
|
+
return [{ block: 'languages', field: `languages.${language}.publishing`, problem: NOT_A_JSON_OBJECT }];
|
|
117
|
+
}
|
|
118
|
+
return [];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** As written, whatever that is: the portal's own parser says what is wrong with it. */
|
|
122
|
+
portal() {
|
|
123
|
+
return this.root.portal;
|
|
124
|
+
}
|
|
125
|
+
/** The block, or undefined when it is absent or, as the findings say, not an object. */
|
|
126
|
+
plugin() {
|
|
127
|
+
return isJsonObject(this.root.plugin) ? this.root.plugin : undefined;
|
|
128
|
+
}
|
|
129
|
+
/** The block, or undefined when it is absent or, as the findings say, not an object. */
|
|
130
|
+
languages() {
|
|
131
|
+
return isJsonObject(this.root.languages) ? this.root.languages : undefined;
|
|
132
|
+
}
|
|
133
|
+
findingsFor(...blocks) {
|
|
134
|
+
return this.findings.filter((finding) => blocks.includes(finding.block));
|
|
135
|
+
}
|
|
136
|
+
/** `$schema` goes first among the keys, where a reader looks for it. */
|
|
137
|
+
referencingSchema(schemaUrl) {
|
|
138
|
+
const rest = { ...this.root };
|
|
139
|
+
delete rest.$schema;
|
|
140
|
+
return ApimaticConfigDocument.of({ $schema: schemaUrl, ...rest });
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The document with one block replaced. A block the file already holds keeps its place among
|
|
144
|
+
* the other keys; a new one goes after the last.
|
|
145
|
+
*/
|
|
146
|
+
with(block, value) {
|
|
147
|
+
return ApimaticConfigDocument.of({ ...this.root, [block]: value });
|
|
148
|
+
}
|
|
149
|
+
/** The file's text, keys in the order held, in the indentation and with the ending the caller found. */
|
|
150
|
+
serialize(indent, trailingNewline) {
|
|
151
|
+
return JSON.stringify(this.root, null, indent) + (trailingNewline ? '\n' : '');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** One sentence per finding, each naming the file or the field, for a list a user fixes one line at a time. */
|
|
155
|
+
export function findingSentences(findings) {
|
|
156
|
+
return findings.map(({ field, problem }) => field === null ? `${APIMATIC_CONFIG_FILE_NAME} ${problem}.` : `'${field}' ${problem}.`);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Every finding as one clause about the file, for a message that has already named it:
|
|
160
|
+
* "it is empty", "its 'languages' is not a JSON object".
|
|
161
|
+
*/
|
|
162
|
+
export function findingClause(findings) {
|
|
163
|
+
return findings
|
|
164
|
+
.map(({ field, problem }) => (field === null ? `it ${problem}` : `its '${field}' ${problem}`))
|
|
165
|
+
.join('; ');
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/types/apimatic-config/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAEzD,oGAAoG;AACpG,MAAM,CAAC,MAAM,mBAAmB,GAAG,mEAAmE,CAAC;AAEvG;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,OAAO,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC;QAC3C,CAAC,CAAC,8CAA8C,UAAU,uBAAuB;QACjF,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAqBhC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,MAAM,mBAAmB,GAAG,+FAA+F,CAAC;AAE5H,MAAM,wBAAwB,GAAG,wEAAwE,CAAC;AAE1G,oHAAoH;AACpH,MAAM,OAAO,sBAAsB;IAEd,IAAI;IACJ,QAAQ;IAF3B,YACmB,IAA6B,EAC7B,QAAkC;oBADlC,IAAI;wBACJ,QAAQ;IACxB,CAAC;IAEJ,+CAA+C;IACxC,MAAM,CAAC,KAAK;QACjB,OAAO,sBAAsB,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;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CAAC,CAAC;IACjF,CAAC;CACF;AAED,+GAA+G;AAC/G,MAAM,UAAU,gBAAgB,CAAC,QAAkC;IACjE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CACzC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,yBAAyB,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,OAAO,GAAG,CACvF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkC;IAC9D,OAAO,QAAQ;SACZ,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC;SAC7F,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JsonObject } from '../../utils/json-utils.js';
|
|
2
|
+
import { GitConfiguration, PackageConfigurationForLanguage, PackageSettingsState } from '../publish/package-settings-configuration.js';
|
|
3
|
+
import { SemVersion, SemVersionString } from '../publish/version.js';
|
|
4
|
+
import { Language } from '../sdk/generate.js';
|
|
5
|
+
import { ApimaticConfigDocument } from './document.js';
|
|
6
|
+
export declare const LANGUAGES_EXAMPLE = "\"languages\": { \"typescript\": {} }";
|
|
7
|
+
export interface LanguageSource {
|
|
8
|
+
repositoryUrl: string;
|
|
9
|
+
branch?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The package's name is not here: the service reads it from `packageConfiguration`. */
|
|
12
|
+
interface PackageRelease {
|
|
13
|
+
version: SemVersionString;
|
|
14
|
+
}
|
|
15
|
+
interface LanguagePublishing<TConfiguration> {
|
|
16
|
+
source?: LanguageSource;
|
|
17
|
+
package?: PackageRelease;
|
|
18
|
+
/** Optional because a profile can configure a repository without a package. */
|
|
19
|
+
packageConfiguration?: TConfiguration;
|
|
20
|
+
}
|
|
21
|
+
export type LanguagePublishingEntry<L extends Language> = LanguagePublishing<PackageConfigurationForLanguage[L]>;
|
|
22
|
+
/** Without `publishing`, the language was asked for but nothing has been published yet. */
|
|
23
|
+
export interface PluginLanguageEntry<L extends Language> {
|
|
24
|
+
publishing?: LanguagePublishingEntry<L>;
|
|
25
|
+
}
|
|
26
|
+
export type PluginLanguages = Partial<{
|
|
27
|
+
[L in Language]: PluginLanguageEntry<L>;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const languagesOf: (document: ApimaticConfigDocument) => PluginLanguages;
|
|
30
|
+
export declare const isPublished: (entry: PluginLanguageEntry<Language> | undefined) => boolean;
|
|
31
|
+
export declare function buildLanguageEntry<L extends Language>(language: L, gitConfiguration: GitConfiguration | undefined, packageConfiguration: PackageConfigurationForLanguage[L] | undefined, packageVersion: SemVersion | undefined): PluginLanguageEntry<L>;
|
|
32
|
+
export declare function withLanguage<L extends Language>(languages: PluginLanguages, language: L, entry: PluginLanguageEntry<L>, packageSettings: PackageSettingsState): PluginLanguages;
|
|
33
|
+
export interface RecordedPublishing {
|
|
34
|
+
repositoryUrl: string | null;
|
|
35
|
+
version: string | null;
|
|
36
|
+
packageConfiguration: Readonly<JsonObject>;
|
|
37
|
+
}
|
|
38
|
+
export declare function recordedPublishing(entry: unknown): RecordedPublishing;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isJsonObject } from '../../utils/json-utils.js';
|
|
2
|
+
const GITHUB_BASE_URL = 'https://github.com';
|
|
3
|
+
export const LANGUAGES_EXAMPLE = '"languages": { "typescript": {} }';
|
|
4
|
+
export const languagesOf = (document) => (document.languages() ?? {});
|
|
5
|
+
export const isPublished = (entry) => Boolean(entry?.publishing?.source ?? entry?.publishing?.package);
|
|
6
|
+
export function buildLanguageEntry(language, gitConfiguration, packageConfiguration, packageVersion) {
|
|
7
|
+
const repositoryName = gitConfiguration?.repositoryName?.trim();
|
|
8
|
+
const source = repositoryName
|
|
9
|
+
? {
|
|
10
|
+
repositoryUrl: `${GITHUB_BASE_URL}/${repositoryName}`,
|
|
11
|
+
branch: gitConfiguration?.branch ? gitConfiguration.branch : undefined
|
|
12
|
+
}
|
|
13
|
+
: undefined;
|
|
14
|
+
return {
|
|
15
|
+
publishing: {
|
|
16
|
+
source,
|
|
17
|
+
package: packageVersion ? { version: packageVersion.toString() } : undefined,
|
|
18
|
+
// Written even without a release: it says how the package is set up, not that one exists.
|
|
19
|
+
packageConfiguration
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function withLanguage(languages, language, entry, packageSettings) {
|
|
24
|
+
const existingEntry = languages[language];
|
|
25
|
+
const existingPublishing = existingEntry?.publishing;
|
|
26
|
+
const publishing = entry.publishing
|
|
27
|
+
? {
|
|
28
|
+
...existingPublishing,
|
|
29
|
+
...entry.publishing,
|
|
30
|
+
source: entry.publishing.source ?? existingPublishing?.source,
|
|
31
|
+
package: entry.publishing.package ?? existingPublishing?.package,
|
|
32
|
+
packageConfiguration: packageSettings === 'disabled'
|
|
33
|
+
? undefined
|
|
34
|
+
: entry.publishing.packageConfiguration ?? existingPublishing?.packageConfiguration
|
|
35
|
+
}
|
|
36
|
+
: existingPublishing;
|
|
37
|
+
return { ...languages, [language]: { ...existingEntry, ...entry, ...(publishing ? { publishing } : {}) } };
|
|
38
|
+
}
|
|
39
|
+
export function recordedPublishing(entry) {
|
|
40
|
+
const publishing = objectAt(entry, 'publishing');
|
|
41
|
+
const source = objectAt(publishing, 'source');
|
|
42
|
+
const release = objectAt(publishing, 'package');
|
|
43
|
+
return {
|
|
44
|
+
repositoryUrl: stringAt(source, 'repositoryUrl'),
|
|
45
|
+
version: stringAt(release, 'version'),
|
|
46
|
+
packageConfiguration: objectAt(publishing, 'packageConfiguration')
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// `T` only types `key`, so renaming a field fails to compile here instead of reading nothing.
|
|
50
|
+
function objectAt(value, key) {
|
|
51
|
+
const found = isJsonObject(value) ? value[key] : undefined;
|
|
52
|
+
return isJsonObject(found) ? found : {};
|
|
53
|
+
}
|
|
54
|
+
function stringAt(value, key) {
|
|
55
|
+
const found = value[key];
|
|
56
|
+
return typeof found === 'string' ? found : null;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=languages-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages-block.js","sourceRoot":"","sources":["../../../src/types/apimatic-config/languages-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,2BAA2B,CAAC;AAUrE,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AA4BrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgC,EAAmB,EAAE,CAC/E,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,CAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAgD,EAAW,EAAE,CACvF,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAEnE,MAAM,UAAU,kBAAkB,CAChC,QAAW,EACX,gBAA8C,EAC9C,oBAAoE,EACpE,cAAsC;IAEtC,MAAM,cAAc,GAAG,gBAAgB,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAChE,MAAM,MAAM,GAA+B,cAAc;QACvD,CAAC,CAAC;YACE,aAAa,EAAE,GAAG,eAAe,IAAI,cAAc,EAAE;YACrD,MAAM,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACvE;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,UAAU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AO,GAAG,QAAQ,CAA8B,UAAU,EAAE,SAAS,CAAC,CAAC;IAE7E,OAAO;QACL,aAAa,EAAE,QAAQ,CAAiB,MAAM,EAAE,eAAe,CAAC;QAChE,OAAO,EAAE,QAAQ,CAAiB,OAAO,EAAE,SAAS,CAAC;QACrD,oBAAoB,EAAE,QAAQ,CAA8B,UAAU,EAAE,sBAAsB,CAAC;KAChG,CAAC;AACJ,CAAC;AAED,8FAA8F;AAC9F,SAAS,QAAQ,CAAI,KAAc,EAAE,GAAqB;IACxD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAI,KAAiB,EAAE,GAAqB;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { ApimaticConfigDocument, ConfigBlockName, ConfigFinding } from './apimatic-config/document.js';
|
|
3
|
+
import { DirectoryPath } from './file/directoryPath.js';
|
|
4
|
+
import { FilePath } from './file/filePath.js';
|
|
5
|
+
/**
|
|
6
|
+
* What a reader finds. `path` rides along purely so a prompt can say where to fix the file.
|
|
7
|
+
* A parsed document may still carry findings; each command reads the blocks it owns.
|
|
8
|
+
*/
|
|
9
|
+
export type ApimaticConfigState = {
|
|
10
|
+
state: 'missing';
|
|
11
|
+
} | {
|
|
12
|
+
state: 'unparseable';
|
|
13
|
+
findings: ConfigFinding[];
|
|
14
|
+
path: FilePath;
|
|
15
|
+
} | {
|
|
16
|
+
state: 'parsed';
|
|
17
|
+
document: ApimaticConfigDocument;
|
|
18
|
+
path: FilePath;
|
|
19
|
+
};
|
|
20
|
+
export type ApimaticConfigWriteFailure = 'unreadable' | 'unwritable';
|
|
21
|
+
/** The `apimatic.json` in a project's `src/`, beside `APIMATIC-BUILD.json`. */
|
|
22
|
+
export declare class ApimaticConfigContext {
|
|
23
|
+
private readonly sourceDirectory;
|
|
24
|
+
private readonly fileService;
|
|
25
|
+
constructor(sourceDirectory: DirectoryPath);
|
|
26
|
+
private get configFile();
|
|
27
|
+
exists(): Promise<boolean>;
|
|
28
|
+
read(): Promise<ApimaticConfigState>;
|
|
29
|
+
/**
|
|
30
|
+
* Reads the document, hands the whole of it to `apply`, writes back the whole of what comes
|
|
31
|
+
* back. `blocks` names what the caller is about to write: a finding in one of them, or at
|
|
32
|
+
* the root, refuses the write, so a merge never spreads a malformed block into the file. A
|
|
33
|
+
* missing file starts from the empty document. A file that exists but cannot be parsed is
|
|
34
|
+
* left alone rather than overwritten, and a write fault is reported rather than thrown: this
|
|
35
|
+
* runs after work that already succeeded, and nothing here may turn that into a crash. A merge
|
|
36
|
+
* that changes nothing writes nothing, so re-running a command leaves the file as it was saved.
|
|
37
|
+
*/
|
|
38
|
+
merge(blocks: readonly ConfigBlockName[], apply: (document: ApimaticConfigDocument) => ApimaticConfigDocument): Promise<Result<ApimaticConfigDocument, ApimaticConfigWriteFailure>>;
|
|
39
|
+
/**
|
|
40
|
+
* Rewrites the file without its byte-order mark, if it has one. Reading past a mark is enough
|
|
41
|
+
* while the file stays here, but `plugin generate` zips it and sends it to a parser that is
|
|
42
|
+
* not this one. Only the mark goes: the rest is written back byte for byte, so a layout this
|
|
43
|
+
* CLI never chose, and the line endings with it, survive a rewrite nobody asked for.
|
|
44
|
+
*/
|
|
45
|
+
removeByteOrderMark(): Promise<Result<void, ApimaticConfigWriteFailure>>;
|
|
46
|
+
private load;
|
|
47
|
+
private static detectFormat;
|
|
48
|
+
}
|