From e739d304be47dfed5bf16c451d31933472c6eedf Mon Sep 17 00:00:00 2001 From: Jon Ursenbach Date: Mon, 16 Oct 2023 14:23:15 -0700 Subject: [PATCH] feat(api): proper esm support and codegen overhauls (#754) * feat(api): wip of proper esm support and codegen overhauls * docs: documenting why we're exporting `createSDK` the way we are * chore(deps): bumping ts-morph * fix: overhauling schemas to now be stored in a `schemas/` directory * fix: storage system didn't properly create subdirectories * fix: broken test * fix: flaky test in ci * fix: bringing back some tests * feat: refactoring codegen'd sdks to be placed into a `src/` directory * fix: pinning installed sdk dependencies to known working versions * fix: cjs compatibility with our `types` file being exported in `index` * fix: removing some dead code * fix: compatibility with node 20 on `npm run debug:bin` * v7.0.0-alpha.5 * fix: minor `tsup` codegen fixes (#759) * chore: minor tsconfig cleanup * fix: point to correct api-core pkg version * fix: install TS as dev-dep * fix: add this to silence the JSON import warning * refactor: slight cleanup * Update packages/api/src/codegen/languages/typescript/index.ts * Revert "refactor: slight cleanup" This reverts commit 3b82df8cc3ee870007d6cd36d2730dee91abc326. * Update packages/api/test/codegen/languages/typescript/index.test.ts Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com> * Update packages/api/test/codegen/languages/typescript/index.test.ts Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com> * fix: pr feedback * fix: ts ignore typo --------- Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com> Co-authored-by: Kanad Gupta --- CHANGELOG.md | 25 ++ lerna.json | 2 +- package-lock.json | 100 +++--- packages/api/bin/api.js | 2 +- packages/api/package.json | 8 +- packages/api/src/codegen/codegenerator.ts | 13 +- packages/api/src/codegen/factory.ts | 18 +- .../src/codegen/languages/typescript/index.ts | 326 ++++++++++-------- packages/api/src/commands/install.ts | 46 +-- packages/api/src/packageInfo.ts | 2 +- packages/api/src/storage.ts | 9 + .../test/__fixtures__/sdk/alby/package.json | 39 +++ .../__fixtures__/sdk/alby/{ => src}/index.ts | 2 - .../sdk/alby/{ => src}/schemas.ts | 0 .../schemas/AmqpExternalRulePatch.ts | 0 .../{ => src}/schemas/AmqpExternalRulePost.ts | 0 .../schemas/AmqpExternalRuleResponse.ts | 0 .../alby/{ => src}/schemas/AmqpRulePatch.ts | 0 .../alby/{ => src}/schemas/AmqpRulePost.ts | 0 .../{ => src}/schemas/AmqpRuleResponse.ts | 0 .../sdk/alby/{ => src}/schemas/AppPatch.ts | 0 .../sdk/alby/{ => src}/schemas/AppPkcs12.ts | 0 .../sdk/alby/{ => src}/schemas/AppPost.ts | 0 .../sdk/alby/{ => src}/schemas/AppResponse.ts | 0 .../alby/{ => src}/schemas/AwsAccessKeys.ts | 0 .../schemas/AwsAccessKeysResponse.ts | 0 .../alby/{ => src}/schemas/AwsAssumeRole.ts | 0 .../{ => src}/schemas/AwsKinesisRulePatch.ts | 0 .../{ => src}/schemas/AwsKinesisRulePost.ts | 0 .../schemas/AwsKinesisRuleResponse.ts | 0 .../{ => src}/schemas/AwsLambdaRulePatch.ts | 0 .../{ => src}/schemas/AwsLambdaRulePost.ts | 0 .../schemas/AwsLambdaRuleResponse.ts | 0 .../alby/{ => src}/schemas/AwsSqsRulePatch.ts | 0 .../alby/{ => src}/schemas/AwsSqsRulePost.ts | 0 .../{ => src}/schemas/AwsSqsRuleResponse.ts | 0 .../schemas/AzureFunctionRulePatch.ts | 0 .../schemas/AzureFunctionRulePost.ts | 0 .../schemas/AzureFunctionRuleResponse.ts | 0 .../schemas/CloudflareWorkerRulePatch.ts | 0 .../schemas/CloudflareWorkerRulePost.ts | 0 .../schemas/CloudflareWorkerRuleResponse.ts | 0 .../DeleteAppsAppIdNamespacesNamespaceId.ts | 0 .../schemas/DeleteAppsAppIdQueuesQueueId.ts | 0 .../schemas/DeleteAppsAppIdRulesRuleId.ts | 0 .../alby/{ => src}/schemas/DeleteAppsId.ts | 0 .../sdk/alby/{ => src}/schemas/Error.ts | 0 .../schemas/GetAccountsAccountIdApps.ts | 0 .../{ => src}/schemas/GetAppsAppIdKeys.ts | 0 .../schemas/GetAppsAppIdNamespaces.ts | 0 .../{ => src}/schemas/GetAppsAppIdQueues.ts | 0 .../{ => src}/schemas/GetAppsAppIdRules.ts | 0 .../schemas/GetAppsAppIdRulesRuleId.ts | 0 .../schemas/GoogleCloudFunctionRulePatch.ts | 0 .../schemas/GoogleCloudFunctionRulePost.ts | 0 .../GoogleCloudFunctionRuleResponse.ts | 0 .../alby/{ => src}/schemas/HttpRulePatch.ts | 0 .../alby/{ => src}/schemas/HttpRulePost.ts | 0 .../{ => src}/schemas/HttpRuleResponse.ts | 0 .../alby/{ => src}/schemas/IftttRulePatch.ts | 0 .../alby/{ => src}/schemas/IftttRulePost.ts | 0 .../{ => src}/schemas/IftttRuleResponse.ts | 0 .../sdk/alby/{ => src}/schemas/KeyPatch.ts | 0 .../sdk/alby/{ => src}/schemas/KeyPost.ts | 0 .../sdk/alby/{ => src}/schemas/KeyResponse.ts | 0 .../sdk/alby/{ => src}/schemas/Me.ts | 0 .../alby/{ => src}/schemas/NamespacePatch.ts | 0 .../alby/{ => src}/schemas/NamespacePost.ts | 0 .../{ => src}/schemas/NamespaceResponse.ts | 0 .../schemas/PatchAppsAppIdKeysKeyId.ts | 0 .../PatchAppsAppIdNamespacesNamespaceId.ts | 0 .../schemas/PatchAppsAppIdRulesRuleId.ts | 0 .../sdk/alby/{ => src}/schemas/PatchAppsId.ts | 0 .../schemas/PostAccountsAccountIdApps.ts | 0 .../{ => src}/schemas/PostAppsAppIdKeys.ts | 0 .../schemas/PostAppsAppIdKeysKeyIdRevoke.ts | 0 .../schemas/PostAppsAppIdNamespaces.ts | 0 .../{ => src}/schemas/PostAppsAppIdQueues.ts | 0 .../{ => src}/schemas/PostAppsAppIdRules.ts | 0 .../{ => src}/schemas/PostAppsIdPkcs12.ts | 0 .../sdk/alby/{ => src}/schemas/Queue.ts | 0 .../alby/{ => src}/schemas/QueueResponse.ts | 0 .../sdk/alby/{ => src}/schemas/RulePatch.ts | 0 .../sdk/alby/{ => src}/schemas/RulePost.ts | 0 .../alby/{ => src}/schemas/RuleResponse.ts | 0 .../sdk/alby/{ => src}/schemas/RuleSource.ts | 0 .../schemas/UnsupportedRuleResponse.ts | 0 .../alby/{ => src}/schemas/ZapierRulePatch.ts | 0 .../alby/{ => src}/schemas/ZapierRulePost.ts | 0 .../{ => src}/schemas/ZapierRuleResponse.ts | 0 .../__fixtures__/sdk/alby/{ => src}/types.ts | 0 .../test/__fixtures__/sdk/alby/tsconfig.json | 9 + .../sdk/operationid-quirks/package.json | 34 ++ .../sdk/operationid-quirks/{ => src}/index.ts | 0 .../sdk/operationid-quirks/tsconfig.json | 9 + .../sdk/optional-payload/package.json | 39 +++ .../sdk/optional-payload/{ => src}/index.ts | 2 - .../sdk/optional-payload/{ => src}/schemas.ts | 0 .../{ => src}/schemas/UpdatePetWithForm.ts | 0 .../sdk/optional-payload/{ => src}/types.ts | 0 .../sdk/optional-payload/tsconfig.json | 9 + .../__fixtures__/sdk/petstore/package.json | 39 +++ .../sdk/petstore/{ => src}/index.ts | 2 - .../sdk/petstore/{ => src}/schemas.ts | 0 .../petstore/{ => src}/schemas/ApiResponse.ts | 0 .../petstore/{ => src}/schemas/Category.ts | 0 .../schemas/CreateUsersWithArrayInput.ts | 0 .../schemas/CreateUsersWithListInput.ts | 0 .../petstore/{ => src}/schemas/DeleteOrder.ts | 0 .../petstore/{ => src}/schemas/DeletePet.ts | 0 .../petstore/{ => src}/schemas/DeleteUser.ts | 0 .../{ => src}/schemas/FindPetsByStatus.ts | 0 .../{ => src}/schemas/FindPetsByTags.ts | 0 .../{ => src}/schemas/GetInventory.ts | 0 .../{ => src}/schemas/GetOrderById.ts | 0 .../petstore/{ => src}/schemas/GetPetById.ts | 0 .../{ => src}/schemas/GetUserByName.ts | 0 .../petstore/{ => src}/schemas/LoginUser.ts | 0 .../sdk/petstore/{ => src}/schemas/Order.ts | 0 .../sdk/petstore/{ => src}/schemas/Pet.ts | 0 .../sdk/petstore/{ => src}/schemas/Tag.ts | 0 .../{ => src}/schemas/UpdatePetWithForm.ts | 0 .../petstore/{ => src}/schemas/UpdateUser.ts | 0 .../petstore/{ => src}/schemas/UploadFile.ts | 0 .../sdk/petstore/{ => src}/schemas/User.ts | 0 .../sdk/petstore/{ => src}/types.ts | 0 .../__fixtures__/sdk/petstore/tsconfig.json | 9 + .../test/__fixtures__/sdk/readme/package.json | 39 +++ .../sdk/readme/{ => src}/index.ts | 2 - .../sdk/readme/{ => src}/schemas.ts | 0 .../sdk/readme/{ => src}/schemas/Apply.ts | 0 .../sdk/readme/{ => src}/schemas/Category.ts | 0 .../sdk/readme/{ => src}/schemas/Changelog.ts | 0 .../{ => src}/schemas/CondensedProjectData.ts | 0 .../{ => src}/schemas/CreateCategory.ts | 0 .../{ => src}/schemas/CreateCustomPage.ts | 0 .../sdk/readme/{ => src}/schemas/CreateDoc.ts | 0 .../readme/{ => src}/schemas/CreateVersion.ts | 0 .../readme/{ => src}/schemas/CustomPage.ts | 0 .../schemas/DeleteApiSpecification.ts | 0 .../{ => src}/schemas/DeleteCategory.ts | 0 .../{ => src}/schemas/DeleteChangelog.ts | 0 .../{ => src}/schemas/DeleteCustomPage.ts | 0 .../sdk/readme/{ => src}/schemas/DeleteDoc.ts | 0 .../readme/{ => src}/schemas/DeleteVersion.ts | 0 .../readme/{ => src}/schemas/DocSchemaPost.ts | 0 .../readme/{ => src}/schemas/DocSchemaPut.ts | 0 .../{ => src}/schemas/DocSchemaResponse.ts | 0 .../{ => src}/schemas/ErrorApikeyEmpty.ts | 0 .../{ => src}/schemas/ErrorApikeyMismatch.ts | 0 .../{ => src}/schemas/ErrorApikeyNotfound.ts | 0 .../{ => src}/schemas/ErrorCategoryInvalid.ts | 0 .../schemas/ErrorCategoryNotfound.ts | 0 .../schemas/ErrorCustompageInvalid.ts | 0 .../schemas/ErrorCustompageNotfound.ts | 0 .../{ => src}/schemas/ErrorDocInvalid.ts | 0 .../{ => src}/schemas/ErrorDocNotfound.ts | 0 .../schemas/ErrorRegistryNotfound.ts | 0 .../{ => src}/schemas/ErrorSpecFileEmpty.ts | 0 .../{ => src}/schemas/ErrorSpecIdDuplicate.ts | 0 .../{ => src}/schemas/ErrorSpecIdInvalid.ts | 0 .../{ => src}/schemas/ErrorSpecInvalid.ts | 0 .../schemas/ErrorSpecInvalidSchema.ts | 0 .../{ => src}/schemas/ErrorSpecNotfound.ts | 0 .../{ => src}/schemas/ErrorSpecTimeout.ts | 0 .../schemas/ErrorSpecVersionNotfound.ts | 0 .../schemas/ErrorVersionCantDemoteStable.ts | 0 .../schemas/ErrorVersionCantRemoveStable.ts | 0 .../schemas/ErrorVersionDuplicate.ts | 0 .../{ => src}/schemas/ErrorVersionEmpty.ts | 0 .../schemas/ErrorVersionForkEmpty.ts | 0 .../schemas/ErrorVersionForkNotfound.ts | 0 .../{ => src}/schemas/ErrorVersionNotfound.ts | 0 .../{ => src}/schemas/GetApiRegistry.ts | 0 .../readme/{ => src}/schemas/GetApiSchema.ts | 0 .../{ => src}/schemas/GetApiSpecification.ts | 0 .../readme/{ => src}/schemas/GetCategories.ts | 0 .../readme/{ => src}/schemas/GetCategory.ts | 0 .../{ => src}/schemas/GetCategoryDocs.ts | 0 .../readme/{ => src}/schemas/GetChangelog.ts | 0 .../readme/{ => src}/schemas/GetChangelogs.ts | 0 .../readme/{ => src}/schemas/GetCustomPage.ts | 0 .../{ => src}/schemas/GetCustomPages.ts | 0 .../sdk/readme/{ => src}/schemas/GetDoc.ts | 0 .../readme/{ => src}/schemas/GetOpenRoles.ts | 0 .../{ => src}/schemas/GetProductionDoc.ts | 0 .../readme/{ => src}/schemas/GetProject.ts | 0 .../readme/{ => src}/schemas/GetVersion.ts | 0 .../readme/{ => src}/schemas/GetVersions.ts | 0 .../readme/{ => src}/schemas/JobOpening.ts | 0 .../readme/{ => src}/schemas/SearchDocs.ts | 0 .../schemas/UpdateApiSpecification.ts | 0 .../{ => src}/schemas/UpdateCategory.ts | 0 .../{ => src}/schemas/UpdateChangelog.ts | 0 .../{ => src}/schemas/UpdateCustomPage.ts | 0 .../sdk/readme/{ => src}/schemas/UpdateDoc.ts | 0 .../readme/{ => src}/schemas/UpdateVersion.ts | 0 .../schemas/UploadApiSpecification.ts | 0 .../sdk/readme/{ => src}/schemas/Version.ts | 0 .../sdk/readme/{ => src}/types.ts | 0 .../__fixtures__/sdk/readme/tsconfig.json | 9 + .../sdk/response-title-quirks/package.json | 39 +++ .../response-title-quirks/{ => src}/index.ts | 2 - .../{ => src}/schemas.ts | 0 .../{ => src}/schemas/GetAnything.ts | 0 .../response-title-quirks/{ => src}/types.ts | 0 .../sdk/response-title-quirks/tsconfig.json | 9 + .../sdk/simple-js-cjs/Category.d.ts | 17 - .../sdk/simple-js-cjs/Category.js | 4 - .../sdk/simple-js-cjs/FindPetsByStatus.d.ts | 96 ------ .../sdk/simple-js-cjs/FindPetsByStatus.js | 8 - .../__fixtures__/sdk/simple-js-cjs/Pet.d.ts | 69 ---- .../__fixtures__/sdk/simple-js-cjs/Pet.js | 9 - .../__fixtures__/sdk/simple-js-cjs/Tag.d.ts | 17 - .../__fixtures__/sdk/simple-js-cjs/Tag.js | 4 - .../__fixtures__/sdk/simple-js-cjs/index.d.ts | 67 ---- .../__fixtures__/sdk/simple-js-cjs/index.js | 87 ----- .../sdk/simple-js-cjs/schemas.d.ts | 5 - .../__fixtures__/sdk/simple-js-cjs/types.d.ts | 7 - .../sdk/simple-js-esm/Category.d.ts | 17 - .../sdk/simple-js-esm/Category.js | 2 - .../sdk/simple-js-esm/FindPetsByStatus.d.ts | 96 ------ .../sdk/simple-js-esm/FindPetsByStatus.js | 3 - .../__fixtures__/sdk/simple-js-esm/Pet.d.ts | 69 ---- .../__fixtures__/sdk/simple-js-esm/Pet.js | 4 - .../__fixtures__/sdk/simple-js-esm/Tag.d.ts | 17 - .../__fixtures__/sdk/simple-js-esm/Tag.js | 2 - .../__fixtures__/sdk/simple-js-esm/index.d.ts | 67 ---- .../__fixtures__/sdk/simple-js-esm/index.js | 76 ---- .../sdk/simple-js-esm/schemas.d.ts | 5 - .../__fixtures__/sdk/simple-js-esm/types.d.ts | 7 - .../test/__fixtures__/sdk/simple/package.json | 39 +++ .../sdk/{simple-ts => simple/src}/index.ts | 4 +- .../sdk/{simple-ts => simple/src}/schemas.ts | 0 .../src}/schemas/Category.ts | 0 .../src}/schemas/FindPetsByStatus.ts | 0 .../{simple-ts => simple/src}/schemas/Pet.ts | 0 .../{simple-ts => simple/src}/schemas/Tag.ts | 0 .../sdk/{simple-ts => simple/src}/types.ts | 0 .../__fixtures__/sdk/simple/tsconfig.json | 9 + .../languages/typescript/index.test.ts | 128 ++----- .../languages/typescript/smoketest.test.ts | 2 +- packages/api/tsconfig.json | 5 +- packages/core/package.json | 4 +- packages/httpsnippet-client-api/package.json | 2 +- packages/test-utils/package.json | 2 +- 246 files changed, 685 insertions(+), 1109 deletions(-) create mode 100644 packages/api/test/__fixtures__/sdk/alby/package.json rename packages/api/test/__fixtures__/sdk/alby/{ => src}/index.ts (90%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpExternalRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpExternalRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpExternalRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AmqpRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AppPatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AppPkcs12.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AppPost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AppResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsAccessKeys.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsAccessKeysResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsAssumeRole.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsKinesisRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsKinesisRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsKinesisRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsLambdaRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsLambdaRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsLambdaRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsSqsRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsSqsRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AwsSqsRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AzureFunctionRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AzureFunctionRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/AzureFunctionRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/CloudflareWorkerRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/CloudflareWorkerRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/CloudflareWorkerRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/DeleteAppsAppIdQueuesQueueId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/DeleteAppsAppIdRulesRuleId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/DeleteAppsId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/Error.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAccountsAccountIdApps.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAppsAppIdKeys.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAppsAppIdNamespaces.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAppsAppIdQueues.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAppsAppIdRules.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GetAppsAppIdRulesRuleId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GoogleCloudFunctionRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GoogleCloudFunctionRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/GoogleCloudFunctionRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/HttpRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/HttpRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/HttpRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/IftttRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/IftttRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/IftttRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/KeyPatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/KeyPost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/KeyResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/Me.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/NamespacePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/NamespacePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/NamespaceResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PatchAppsAppIdKeysKeyId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PatchAppsAppIdNamespacesNamespaceId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PatchAppsAppIdRulesRuleId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PatchAppsId.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAccountsAccountIdApps.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsAppIdKeys.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsAppIdKeysKeyIdRevoke.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsAppIdNamespaces.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsAppIdQueues.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsAppIdRules.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/PostAppsIdPkcs12.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/Queue.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/QueueResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/RulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/RulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/RuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/RuleSource.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/UnsupportedRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/ZapierRulePatch.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/ZapierRulePost.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/schemas/ZapierRuleResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/alby/{ => src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/alby/tsconfig.json create mode 100644 packages/api/test/__fixtures__/sdk/operationid-quirks/package.json rename packages/api/test/__fixtures__/sdk/operationid-quirks/{ => src}/index.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/operationid-quirks/tsconfig.json create mode 100644 packages/api/test/__fixtures__/sdk/optional-payload/package.json rename packages/api/test/__fixtures__/sdk/optional-payload/{ => src}/index.ts (97%) rename packages/api/test/__fixtures__/sdk/optional-payload/{ => src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/optional-payload/{ => src}/schemas/UpdatePetWithForm.ts (100%) rename packages/api/test/__fixtures__/sdk/optional-payload/{ => src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/optional-payload/tsconfig.json create mode 100644 packages/api/test/__fixtures__/sdk/petstore/package.json rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/index.ts (93%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/ApiResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/Category.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/CreateUsersWithArrayInput.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/CreateUsersWithListInput.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/DeleteOrder.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/DeletePet.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/DeleteUser.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/FindPetsByStatus.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/FindPetsByTags.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/GetInventory.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/GetOrderById.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/GetPetById.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/GetUserByName.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/LoginUser.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/Order.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/Pet.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/Tag.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/UpdatePetWithForm.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/UpdateUser.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/UploadFile.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/schemas/User.ts (100%) rename packages/api/test/__fixtures__/sdk/petstore/{ => src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/petstore/tsconfig.json create mode 100644 packages/api/test/__fixtures__/sdk/readme/package.json rename packages/api/test/__fixtures__/sdk/readme/{ => src}/index.ts (86%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/Apply.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/Category.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/Changelog.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CondensedProjectData.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CreateCategory.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CreateCustomPage.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CreateDoc.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CreateVersion.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/CustomPage.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteApiSpecification.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteCategory.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteChangelog.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteCustomPage.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteDoc.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DeleteVersion.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DocSchemaPost.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DocSchemaPut.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/DocSchemaResponse.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorApikeyEmpty.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorApikeyMismatch.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorApikeyNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorCategoryInvalid.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorCategoryNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorCustompageInvalid.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorCustompageNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorDocInvalid.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorDocNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorRegistryNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecFileEmpty.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecIdDuplicate.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecIdInvalid.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecInvalid.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecInvalidSchema.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecTimeout.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorSpecVersionNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionCantDemoteStable.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionCantRemoveStable.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionDuplicate.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionEmpty.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionForkEmpty.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionForkNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/ErrorVersionNotfound.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetApiRegistry.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetApiSchema.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetApiSpecification.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetCategories.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetCategory.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetCategoryDocs.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetChangelog.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetChangelogs.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetCustomPage.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetCustomPages.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetDoc.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetOpenRoles.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetProductionDoc.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetProject.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetVersion.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/GetVersions.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/JobOpening.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/SearchDocs.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateApiSpecification.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateCategory.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateChangelog.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateCustomPage.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateDoc.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UpdateVersion.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/UploadApiSpecification.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/schemas/Version.ts (100%) rename packages/api/test/__fixtures__/sdk/readme/{ => src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/readme/tsconfig.json create mode 100644 packages/api/test/__fixtures__/sdk/response-title-quirks/package.json rename packages/api/test/__fixtures__/sdk/response-title-quirks/{ => src}/index.ts (97%) rename packages/api/test/__fixtures__/sdk/response-title-quirks/{ => src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/response-title-quirks/{ => src}/schemas/GetAnything.ts (100%) rename packages/api/test/__fixtures__/sdk/response-title-quirks/{ => src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/response-title-quirks/tsconfig.json delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/index.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/index.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/schemas.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-cjs/types.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Category.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Category.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/index.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/index.js delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/schemas.d.ts delete mode 100644 packages/api/test/__fixtures__/sdk/simple-js-esm/types.d.ts create mode 100644 packages/api/test/__fixtures__/sdk/simple/package.json rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/index.ts (93%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/schemas.ts (100%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/schemas/Category.ts (100%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/schemas/FindPetsByStatus.ts (100%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/schemas/Pet.ts (100%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/schemas/Tag.ts (100%) rename packages/api/test/__fixtures__/sdk/{simple-ts => simple/src}/types.ts (100%) create mode 100644 packages/api/test/__fixtures__/sdk/simple/tsconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fad7ae3..cc023304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +## 7.0.0-alpha.5 (2023-10-16) + +* fix: bringing back some tests ([d33e655](https://github.com/readmeio/api/commit/d33e655)) +* fix: broken test ([9ade11b](https://github.com/readmeio/api/commit/9ade11b)) +* fix: cjs compatibility with our `types` file being exported in `index` ([330a3a1](https://github.com/readmeio/api/commit/330a3a1)) +* fix: compatibility with node 20 on `npm run debug:bin` ([9fd0370](https://github.com/readmeio/api/commit/9fd0370)) +* fix: flaky test in ci ([8e11923](https://github.com/readmeio/api/commit/8e11923)) +* fix: overhauling schemas to now be stored in a `schemas/` directory ([6463a02](https://github.com/readmeio/api/commit/6463a02)) +* fix: pinning installed sdk dependencies to known working versions ([d4e5d5a](https://github.com/readmeio/api/commit/d4e5d5a)) +* fix: removing some dead code ([488041e](https://github.com/readmeio/api/commit/488041e)) +* fix: storage system didn't properly create subdirectories ([654194e](https://github.com/readmeio/api/commit/654194e)) +* fix(api): nestling generated schemas into a new `schemas/` directory (#756) ([ec74118](https://github.com/readmeio/api/commit/ec74118)), closes [#756](https://github.com/readmeio/api/issues/756) +* fix(api): storage dir not being set properly (#753) ([fa31dd4](https://github.com/readmeio/api/commit/fa31dd4)), closes [#753](https://github.com/readmeio/api/issues/753) +* feat: migrate `api` and `core` to ESM (#733) ([f65bc79](https://github.com/readmeio/api/commit/f65bc79)), closes [#733](https://github.com/readmeio/api/issues/733) +* feat: refactoring codegen'd sdks to be placed into a `src/` directory ([7d7b4cc](https://github.com/readmeio/api/commit/7d7b4cc)) +* feat(api): wip of proper esm support and codegen overhauls ([8e5558d](https://github.com/readmeio/api/commit/8e5558d)) +* chore(deps-dev): bump the minor-development-deps group with 4 updates (#750) ([5259bb7](https://github.com/readmeio/api/commit/5259bb7)), closes [#750](https://github.com/readmeio/api/issues/750) +* chore(deps): bump vitest from 0.34.5 to 0.34.6 (#751) ([ef4b36c](https://github.com/readmeio/api/commit/ef4b36c)), closes [#751](https://github.com/readmeio/api/issues/751) +* chore(deps): bumping ts-morph ([e2e1259](https://github.com/readmeio/api/commit/e2e1259)) +* docs: documenting why we're exporting `createSDK` the way we are ([84872e6](https://github.com/readmeio/api/commit/84872e6)) +* refactor: remove `make-dir` as a dep (#746) ([ab41a72](https://github.com/readmeio/api/commit/ab41a72)), closes [#746](https://github.com/readmeio/api/issues/746) +* refactor(api): minor refactors to how some internal language classes are used (#755) ([518736d](https://github.com/readmeio/api/commit/518736d)), closes [#755](https://github.com/readmeio/api/issues/755) + + + ## 7.0.0-alpha.3 (2023-09-27) * chore(deps): bump fetch-har (#745) ([d7a5d0c](https://github.com/readmeio/api/commit/d7a5d0c)), closes [#745](https://github.com/readmeio/api/issues/745) diff --git a/lerna.json b/lerna.json index 32a73beb..c3a36874 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "packages": ["packages/*"], - "version": "7.0.0-alpha.3" + "version": "7.0.0-alpha.5" } diff --git a/package-lock.json b/package-lock.json index ceaadc01..5cc17d9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3258,27 +3258,27 @@ "dev": true }, "node_modules/@readme/oas-extensions": { - "version": "20.0.4", - "resolved": "https://registry.npmjs.org/@readme/oas-extensions/-/oas-extensions-20.0.4.tgz", - "integrity": "sha512-dP44B6ojZ572vhf51l5U4OVSE/IRTJP2P9t5bH16bP3X38dbXLYIYisd92NQ0jhvUxRPvx1a2qDWNdQ88GWQkQ==", + "version": "20.0.5", + "resolved": "https://registry.npmjs.org/@readme/oas-extensions/-/oas-extensions-20.0.5.tgz", + "integrity": "sha512-U+PIo658pvOXz7ti5wyV6zAZB0IU0rUfaqLPTPxC1xssy1eE6v0xC9e3vBmh4c8WaglHTN3kHrM4SfBkyUchFA==", "dependencies": { - "oas": "^23.0.0" + "oas": "^23.0.1" }, "engines": { "node": ">=18" } }, "node_modules/@readme/oas-to-har": { - "version": "23.0.12", - "resolved": "https://registry.npmjs.org/@readme/oas-to-har/-/oas-to-har-23.0.12.tgz", - "integrity": "sha512-XXJtD/BQwlCeyTFY9ztHz/enNbVYC83kjDVXaBsoTDbCJtFVdo+dcz6Zux7hrABLTJTPAl/L8A4hqBbMBO7kbg==", + "version": "23.0.13", + "resolved": "https://registry.npmjs.org/@readme/oas-to-har/-/oas-to-har-23.0.13.tgz", + "integrity": "sha512-0ADQjN9MP8jGQAWC62Vy1DKKl3zoCdwrg4EZlUnrYTihSn/4WHEqqoKQnigBowyWfPOAhZUUiqRkUjbit512rg==", "dependencies": { "@readme/data-urls": "^3.0.0", - "@readme/oas-extensions": "^20.0.4", + "@readme/oas-extensions": "^20.0.5", "lodash": "^4.17.21", - "oas": "^23.0.0", + "oas": "^23.0.1", "qs": "^6.11.2", - "remove-undefined-objects": "^4.0.1" + "remove-undefined-objects": "^5.0.0" }, "engines": { "node": ">=18" @@ -3434,13 +3434,13 @@ } }, "node_modules/@ts-morph/common": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.18.1.tgz", - "integrity": "sha512-RVE+zSRICWRsfrkAw5qCAK+4ZH9kwEFv5h0+/YeHTLieWP7F4wWq4JsKFuNWG+fYh/KF+8rAtgdj5zb2mm+DVA==", + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.21.0.tgz", + "integrity": "sha512-ES110Mmne5Vi4ypUKrtVQfXFDtCsDXiUiGxF6ILVlE90dDD4fdpC1LSjydl/ml7xJWKSDZwUYD2zkOePMSrPBA==", "dependencies": { "fast-glob": "^3.2.12", - "minimatch": "^5.1.0", - "mkdirp": "^1.0.4", + "minimatch": "^7.4.3", + "mkdirp": "^2.1.6", "path-browserify": "^1.0.1" } }, @@ -3453,14 +3453,31 @@ } }, "node_modules/@ts-morph/common/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.6.tgz", + "integrity": "sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@ts-morph/common/node_modules/mkdirp": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz", + "integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/@tsconfig/node10": { @@ -5633,9 +5650,9 @@ } }, "node_modules/code-block-writer": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-11.0.3.tgz", - "integrity": "sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==" + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-12.0.0.tgz", + "integrity": "sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==" }, "node_modules/code-error-fragment": { "version": "0.0.230", @@ -15530,6 +15547,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, "bin": { "mkdirp": "bin/cmd.js" }, @@ -16394,9 +16412,9 @@ } }, "node_modules/oas": { - "version": "23.0.0", - "resolved": "https://registry.npmjs.org/oas/-/oas-23.0.0.tgz", - "integrity": "sha512-e3G5pdnuw/hFSVtnNmVwDQHr29j3SG6KaL6C6QjfKVnbLqwRWQ+5gHx7Ky5ABxxGtQ17jZLjXl4f/vX9IMgUbg==", + "version": "23.0.1", + "resolved": "https://registry.npmjs.org/oas/-/oas-23.0.1.tgz", + "integrity": "sha512-R3mcbr90nFQQLHSbrGCZYF5ufFo8rIYvkW7JG7VGLzjMA9SuQhAzyzgw0A/+pvg4kR01HJZfb24ts+/y/HoYsQ==", "dependencies": { "@readme/json-schema-ref-parser": "^1.2.0", "@types/json-schema": "^7.0.11", @@ -16407,7 +16425,7 @@ "oas-normalize": "^11.0.1", "openapi-types": "^12.1.1", "path-to-regexp": "^6.2.0", - "remove-undefined-objects": "^4.0.2" + "remove-undefined-objects": "^5.0.0" }, "engines": { "node": ">=18" @@ -18399,11 +18417,11 @@ } }, "node_modules/remove-undefined-objects": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/remove-undefined-objects/-/remove-undefined-objects-4.0.2.tgz", - "integrity": "sha512-6Nh52HADM60lhewwWU30ujMzTjYJk4M5q/LhRYLAacP0hTbzjVWiBVlV84U5RsQA4wDKLwkL0r0qJvti2hRLeQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/remove-undefined-objects/-/remove-undefined-objects-5.0.0.tgz", + "integrity": "sha512-DE8C17uIWeHaY4SqIkpQpHXm0MIdYHtIqjieWuh0I2PG8YcZRxFE6pqeEhnRetsrQ7Lu9uvSNQkDbg95NLpvnQ==", "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/require-directory": { @@ -20068,12 +20086,12 @@ "dev": true }, "node_modules/ts-morph": { - "version": "17.0.1", - "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-17.0.1.tgz", - "integrity": "sha512-10PkHyXmrtsTvZSL+cqtJLTgFXkU43Gd0JCc0Rw6GchWbqKe0Rwgt1v3ouobTZwQzF1mGhDeAlWYBMGRV7y+3g==", + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-20.0.0.tgz", + "integrity": "sha512-JVmEJy2Wow5n/84I3igthL9sudQ8qzjh/6i4tmYCm6IqYyKFlNbJZi7oBdjyqcWSWYRu3CtL0xbT6fS03ESZIg==", "dependencies": { - "@ts-morph/common": "~0.18.0", - "code-block-writer": "^11.0.3" + "@ts-morph/common": "~0.21.0", + "code-block-writer": "^12.0.0" } }, "node_modules/ts-node": { @@ -21974,9 +21992,10 @@ } }, "packages/api": { - "version": "7.0.0-alpha.3", + "version": "7.0.0-alpha.5", "license": "MIT", "dependencies": { + "@readme/api-core": "file:../core", "@readme/openapi-parser": "^2.4.0", "chalk": "^4.1.2", "commander": "^11.0.0", @@ -21993,7 +22012,7 @@ "prompts": "^2.4.2", "semver": "^7.3.8", "ssri": "^10.0.1", - "ts-morph": "^17.0.1", + "ts-morph": "^20.0.0", "validate-npm-package-name": "^5.0.0" }, "bin": { @@ -22001,7 +22020,6 @@ }, "devDependencies": { "@api/test-utils": "file:../test-utils", - "@readme/api-core": "file:../core", "@readme/oas-examples": "^5.12.0", "@types/js-yaml": "^4.0.5", "@types/lodash.camelcase": "^4.3.7", @@ -22026,7 +22044,7 @@ }, "packages/core": { "name": "@readme/api-core", - "version": "7.0.0-alpha.3", + "version": "7.0.0-alpha.5", "license": "MIT", "dependencies": { "@readme/oas-to-har": "^23.0.12", @@ -22037,7 +22055,7 @@ "json-schema-traverse": "^1.0.0", "lodash.merge": "^4.6.2", "oas": "^23.0.0", - "remove-undefined-objects": "^4.0.2" + "remove-undefined-objects": "^5.0.0" }, "devDependencies": { "@api/test-utils": "file:../test-utils", @@ -22054,7 +22072,7 @@ } }, "packages/httpsnippet-client-api": { - "version": "7.0.0-alpha.2", + "version": "7.0.0-alpha.5", "license": "MIT", "dependencies": { "content-type": "^1.0.5", @@ -22079,7 +22097,7 @@ }, "packages/test-utils": { "name": "@api/test-utils", - "version": "7.0.0-alpha.2", + "version": "7.0.0-alpha.5", "dependencies": { "caseless": "^0.12.0", "datauri": "^4.1.0", diff --git a/packages/api/bin/api.js b/packages/api/bin/api.js index c7ad3e20..97c699cc 100755 --- a/packages/api/bin/api.js +++ b/packages/api/bin/api.js @@ -1,2 +1,2 @@ -#!/usr/bin/env node +#!/usr/bin/env NODE_OPTIONS=--no-warnings node import '../dist/bin.js'; diff --git a/packages/api/package.json b/packages/api/package.json index e92808a6..d8a00a4a 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "7.0.0-alpha.3", + "version": "7.0.0-alpha.5", "description": "Magical SDK generation from an OpenAPI definition 🪄", "type": "module", "bin": { @@ -9,7 +9,7 @@ "scripts": { "attw": "attw --pack --format table-flipped", "build": "tsc", - "debug:bin": "node -r ts-node/register src/bin.ts", + "debug:bin": "node --loader ts-node/esm src/bin.ts", "lint:types": "tsc --noEmit", "prebuild": "rm -rf dist/; npm run version", "prepack": "npm run build", @@ -38,6 +38,7 @@ "swagger" ], "dependencies": { + "@readme/api-core": "file:../core", "@readme/openapi-parser": "^2.4.0", "chalk": "^4.1.2", "commander": "^11.0.0", @@ -54,12 +55,11 @@ "prompts": "^2.4.2", "semver": "^7.3.8", "ssri": "^10.0.1", - "ts-morph": "^17.0.1", + "ts-morph": "^20.0.0", "validate-npm-package-name": "^5.0.0" }, "devDependencies": { "@api/test-utils": "file:../test-utils", - "@readme/api-core": "file:../core", "@readme/oas-examples": "^5.12.0", "@types/js-yaml": "^4.0.5", "@types/lodash.camelcase": "^4.3.7", diff --git a/packages/api/src/codegen/codegenerator.ts b/packages/api/src/codegen/codegenerator.ts index 2d8a52ca..cb97b8bb 100644 --- a/packages/api/src/codegen/codegenerator.ts +++ b/packages/api/src/codegen/codegenerator.ts @@ -25,7 +25,14 @@ export default abstract class CodeGenerator { userAgent: string; - requiredPackages!: Record; + requiredPackages!: Record< + string, + { + reason: string; + url: string; + version: string; + } + >; constructor(spec: Oas, specPath: string, identifier: string) { this.spec = spec; @@ -55,10 +62,12 @@ export default abstract class CodeGenerator { } } - abstract compile(): Promise>; + abstract generate(): Promise>; abstract install(storage: Storage, opts?: InstallerOptions): Promise; + abstract compile(storage: Storage, opts?: InstallerOptions): Promise; + hasRequiredPackages() { return Boolean(Object.keys(this.requiredPackages)); } diff --git a/packages/api/src/codegen/factory.ts b/packages/api/src/codegen/factory.ts index 237ad0ab..64e76037 100644 --- a/packages/api/src/codegen/factory.ts +++ b/packages/api/src/codegen/factory.ts @@ -3,7 +3,9 @@ import type Oas from 'oas'; import TSGenerator from './languages/typescript/index.js'; -export type SupportedLanguages = 'js' | 'js-cjs' | 'js-esm' | 'ts'; +export enum SupportedLanguages { + JS = 'js', +} export default function codegenFactory( language: SupportedLanguages, @@ -12,18 +14,8 @@ export default function codegenFactory( identifier: string, ): CodeGenerator { switch (language) { - case 'js': - throw new TypeError('An export format of CommonJS or ECMAScript is required for JavaScript compilation.'); - - case 'js-cjs': - case 'js-esm': - case 'ts': - return new TSGenerator(spec, specPath, identifier, { - outputJS: ['js-cjs', 'js-esm'].includes(language), - - // TS will always generate with ESM-like exports. - compilerTarget: language === 'js-cjs' ? 'cjs' : 'esm', - }); + case SupportedLanguages.JS: + return new TSGenerator(spec, specPath, identifier); default: throw new TypeError(`Unsupported language supplied: ${language}`); diff --git a/packages/api/src/codegen/languages/typescript/index.ts b/packages/api/src/codegen/languages/typescript/index.ts index 0e70f1b0..222b6e86 100644 --- a/packages/api/src/codegen/languages/typescript/index.ts +++ b/packages/api/src/codegen/languages/typescript/index.ts @@ -6,16 +6,18 @@ import type { HttpMethods, SchemaObject } from 'oas/rmoas.types'; import type { SemVer } from 'semver'; import type { ClassDeclaration, + Directory, JSDocStructure, JSDocTagStructure, OptionalKind, ParameterDeclarationStructure, } from 'ts-morph'; -import type { PackageJson } from 'type-fest'; +import type { Options } from 'tsup'; +import type { JsonObject, PackageJson, TsConfigJson } from 'type-fest'; -import fs from 'node:fs'; import path from 'node:path'; +import corePkg from '@readme/api-core/package.json' assert { type: 'json' }; import execa from 'execa'; import setWith from 'lodash.setwith'; import semver from 'semver'; @@ -26,11 +28,6 @@ import CodeGenerator from '../../codegenerator.js'; import { docblockEscape, generateTypeName, wordWrap } from './util.js'; -export interface TSGeneratorOptions { - compilerTarget?: 'cjs' | 'esm'; - outputJS?: boolean; -} - interface OperationTypeHousing { operation: Operation; types: { @@ -57,15 +54,12 @@ interface OperationTypeHousing { * And because our TypeScript type name generator properly ignores `:`, this is safe to prepend to * all generated type names. */ +const REF_PLACEHOLDER = '::convert::'; const REF_PLACEHOLDER_REGEX = /"::convert::([a-zA-Z_$\\d]*)"/g; export default class TSGenerator extends CodeGenerator { project: Project; - outputJS: boolean; - - compilerTarget: 'cjs' | 'esm'; - types: Map; sdk!: ClassDeclaration; @@ -84,51 +78,39 @@ export default class TSGenerator extends CodeGenerator { usesHTTPMethodRangeInterface = false; - constructor(spec: Oas, specPath: string, identifier: string, opts: TSGeneratorOptions = {}) { - const options: { compilerTarget: 'cjs' | 'esm'; outputJS: boolean } = { - outputJS: false, - compilerTarget: 'cjs', - ...opts, - }; - - if (!options.outputJS) { - // TypeScript compilation will always target towards ESM-like imports and exports. - options.compilerTarget = 'esm'; - } - + constructor(spec: Oas, specPath: string, identifier: string) { super(spec, specPath, identifier); this.requiredPackages = { - api: { - reason: "Required for the `@readme/api-core` library that the codegen'd SDK uses for making requests.", + '@readme/api-core': { + reason: "The core magic of your codegen'd SDK and is what is used for making requests.", url: 'https://npm.im/api', + version: + // When running unit tests we're installing `@readme/api-core` but because that package + // source lives in this repository NPM will throw a gnarly "Cannot set properties of null + // (setting 'dev')" workspace error message because we're creating a funky circular + // dependency. + process.env.NODE_ENV === 'test' + ? `file:${path.relative(__dirname, path.dirname(require.resolve('@readme/api-core/package.json')))}` + : corePkg.version, }, 'json-schema-to-ts': { reason: 'Required for TypeScript type handling.', url: 'https://npm.im/json-schema-to-ts', + version: '^2.9.2', }, oas: { reason: 'Used within `@readme/api-core` and is also loaded for TypeScript types.', url: 'https://npm.im/oas', + version: '^23.0.0', }, }; this.project = new Project({ compilerOptions: { - // If we're exporting a TypeScript SDK then we don't need to pollute the codegen directory - // with unnecessary declaration `.d.ts` files. - declaration: options.outputJS, outDir: 'dist', resolveJsonModule: true, - target: options.compilerTarget === 'cjs' ? ScriptTarget.ES5 : ScriptTarget.ES2020, - - // If we're compiling to a CJS target then we need to include this compiler option - // otherwise TS will attempt to load our `openapi.json` import with a `.default` property - // which doesn't exist. `esModuleInterop` wraps imports in a small `__importDefault` - // function that does some determination to see if the module has a default export or not. - // - // Basically without this option CJS code will fail. - ...(options.compilerTarget === 'cjs' ? { esModuleInterop: true } : {}), + target: ScriptTarget.ES2022, }, manipulationSettings: { indentationText: IndentationText.TwoSpaces, @@ -137,49 +119,62 @@ export default class TSGenerator extends CodeGenerator { useInMemoryFileSystem: true, }); - this.compilerTarget = options.compilerTarget; - this.outputJS = options.outputJS; - this.types = new Map(); this.schemas = {}; } + // eslint-disable-next-line class-methods-use-this async install(storage: Storage, opts: InstallerOptions = {}): Promise { const installDir = storage.getIdentifierStorageDir(); - const info = this.spec.getDefinition().info; - let pkgVersion = semver.coerce(info.version); - if (!pkgVersion) { - // If the version that's in `info.version` isn't compatible with semver NPM won't be able to - // handle it properly so we need to fallback to something it can. - pkgVersion = semver.coerce('0.0.0') as SemVer; - } + const npmInstall = ['install', '--save', opts.dryRun ? '--dry-run' : ''].filter(Boolean); - const pkg: PackageJson = { - name: `@api/${storage.identifier}`, - version: pkgVersion.version, - main: `./index.${this.outputJS ? 'js' : 'ts'}`, - types: './index.d.ts', // Types are always present regardless if you're getting compiled JS. - }; + // This will install the installed SDK as a dependency within the current working directory, + // adding `@api/` as a dependency there so you can load it with + // `require('@api/)`. + await execa('npm', [...npmInstall, installDir].filter(Boolean)) + .then(res => { + if (opts.dryRun) { + (opts.logger ? opts.logger : logger)(res.command); + (opts.logger ? opts.logger : logger)(res.stdout); + } + }) + .catch(err => { + // If `npm install` throws this error it always happens **after** our dependencies have been + // installed and is an annoying quirk that sometimes occurs when installing a package within + // our workspace as we're creating a circular dependency on `@readme/api-core`. + if ( + process.env.NODE_ENV === 'test' && + err.message.includes("npm ERR! Cannot set properties of null (setting 'dev')") + ) { + (opts.logger ? opts.logger : logger)("npm threw an error but we're ignoring it"); + return; + } - fs.writeFileSync(path.join(installDir, 'package.json'), JSON.stringify(pkg, null, 2)); + if (opts.dryRun) { + (opts.logger ? opts.logger : logger)(err.message); + return; + } - const npmInstall = ['install', '--save', opts.dryRun ? '--dry-run' : ''].filter(Boolean); + throw err; + }); + } - // This will install packages required for the SDK within its installed directory in `.apis/`. - await execa('npm', [...npmInstall, ...Object.keys(this.requiredPackages)].filter(Boolean), { + /** + * Compile the TS code we generated into JS for use in CJS and ESM environments. + * + */ + // eslint-disable-next-line class-methods-use-this + async compile(storage: Storage, opts: InstallerOptions = {}): Promise { + const installDir = storage.getIdentifierStorageDir(); + + await execa('npm', ['install', 'tsup', 'typescript', '-D'], { cwd: installDir, - }).then(res => { - if (opts.dryRun) { - (opts.logger ? opts.logger : logger)(res.command); - (opts.logger ? opts.logger : logger)(res.stdout); - } }); - // This will install the installed SDK as a dependency within the current working directory, - // adding `@api/` as a dependency there so you can load it with - // `require('@api/)`. - return execa('npm', [...npmInstall, installDir].filter(Boolean)) + await execa('npx', ['tsup'], { + cwd: installDir, + }) .then(res => { if (opts.dryRun) { (opts.logger ? opts.logger : logger)(res.command); @@ -197,39 +192,19 @@ export default class TSGenerator extends CodeGenerator { } /** - * Compile the current OpenAPI definition into a TypeScript library. + * Generate the current OpenAPI definition into a TypeScript library. * */ - async compile() { - const sdkSource = this.createSourceFile(); + async generate() { + const srcDirectory = this.project.createDirectory('src'); + const sdkSource = this.createSDKSource(srcDirectory); + + this.createPackageJSON(); + this.createTSConfig(); if (Object.keys(this.schemas).length) { - this.createSchemasFile(); - this.createTypesFile(); - - /** - * Export all of our available types so they can be used in SDK implementations. Types are - * exported individually because TS has no way right now of allowing us to do - * `export type * from './types'` on a non-named entry. - * - * Types in the main entry point are only being exported for TS outputs as JS users won't be - * able to use them and it clashes with the default SDK export present. - * - * @see {@link https://github.com/microsoft/TypeScript/issues/37238} - * @see {@link https://github.com/readmeio/api/issues/588} - */ - if (!this.outputJS) { - const types = Array.from(this.types.keys()); - types.sort(); - - sdkSource.addExportDeclarations([ - { - isTypeOnly: true, - namedExports: types, - moduleSpecifier: './types', - }, - ]); - } + this.createSchemasFile(srcDirectory); + this.createTypesFile(srcDirectory); } else { // If we don't have any schemas then we shouldn't import a `types` file that doesn't exist. sdkSource @@ -247,42 +222,6 @@ export default class TSGenerator extends CodeGenerator { ?.replaceWithText("import type { ConfigOptions, FetchResponse } from '@readme/api-core';"); } - if (this.outputJS) { - return this.project - .emitToMemory() - .getFiles() - .map(sourceFile => { - const file = path.basename(sourceFile.filePath); - if (file === 'schemas.js' || file === 'types.js') { - // If we're generating a JS SDK then we don't need to generate these two files as the - // user will have `.d.ts` files for them instead. - return {}; - } - - let code = sourceFile.text; - if (file === 'index.js' && this.compilerTarget === 'cjs') { - /** - * There's an annoying quirk with `ts-morph` where if we're exporting a default export - * to a CJS environment, it'll export it as `exports.default`. Because we don't want - * folks in these environments to have to load their SDKs with - * `require('@api/sdk').default` we're overriding that here to change it to being the - * module exports. - * - * `ts-morph` unfortunately doesn't give us any options for programatically doing this - * so we need to resort to modifying the emitted JS code. - */ - code = code - .replace(/Object\.defineProperty\(exports, '__esModule', { value: true }\);\n/, '') - .replace('exports.default = createSDK;', 'module.exports = createSDK;'); - } - - return { - [file]: code, - }; - }) - .reduce((prev, next) => Object.assign(prev, next)); - } - return [ ...this.project.getSourceFiles().map(sourceFile => { // `getFilePath` will always return a string that contains a preceeding directory separator @@ -313,10 +252,10 @@ export default class TSGenerator extends CodeGenerator { * Create our main SDK source file. * */ - private createSourceFile() { + private createSDKSource(sourceDirectory: Directory) { const { operations } = this.loadOperationsAndMethods(); - const sourceFile = this.project.createSourceFile('index.ts', ''); + const sourceFile = sourceDirectory.createSourceFile('index.ts', ''); sourceFile.addImportDeclarations([ // This import will be automatically removed later if the SDK ends up not having any types. @@ -449,7 +388,7 @@ sdk.server('https://eu.api.example.com/v14');`), { name: 'createSDK', initializer: writer => { - // `ts-morph` doesn't have any way to cleanly create an IFEE. + // `ts-morph` doesn't have any way to cleanly create an IIFE. writer.writeLine('(() => { return new SDK(); })()'); return writer; }, @@ -458,25 +397,112 @@ sdk.server('https://eu.api.example.com/v14');`), }); sourceFile.addExportAssignment({ - // Because CJS targets have `createSDK` exported with `module.exports`, but the TS type side - // of things to work right we need to set this as `export =`. Thankfully `ts-morph` will - // handle this accordingly and still create our JS file with `module.exports` and not - // `export =` -- only TS types will have this export style. - isExportEquals: this.compilerTarget === 'cjs' && this.outputJS, + // Because we're exporting `createSDK` as an IIFE constant we need to have it exported as + // `export default createSDK`. `addExportAssignment` by default wants it exported as + // `export = createSDK`, which will throw TS errors because we may also be exporting types in + // the `./types.ts` file. + isExportEquals: false, expression: 'createSDK', }); return sourceFile; } + /** + * Create the `tsconfig.json` file that will allow this SDK to be compiled for use. + * + */ + createTSConfig() { + const sourceFile = this.project.createSourceFile('tsconfig.json', ''); + + const config: TsConfigJson = { + compilerOptions: { + module: 'NodeNext', + resolveJsonModule: true, + }, + include: ['./src/**/*'], + }; + + sourceFile.addStatements(JSON.stringify(config, null, 2)); + + return sourceFile; + } + + /** + * Create the `package.json` file that will ultimately make this SDK available to use. + * + */ + createPackageJSON() { + const sourceFile = this.project.createSourceFile('package.json', ''); + + const hasTypes = !!Object.keys(this.schemas).length; + + const info = this.spec.getDefinition().info; + let pkgVersion = semver.coerce(info.version); + if (!pkgVersion) { + // If the version that's in `info.version` isn't compatible with semver NPM won't be able to + // handle it properly so we need to fallback to something it can. + pkgVersion = semver.coerce('0.0.0') as SemVer; + } + + const tsupOptions: Options = { + cjsInterop: true, + clean: true, + dts: true, + entry: [ + './src/index.ts', + // If this SDK has schemas and generated types then we should also export those too so + // they're available to use. + hasTypes ? './src/types.ts' : '', + ].filter(Boolean), + format: ['esm', 'cjs'], + minify: false, + shims: true, + sourcemap: true, + splitting: true, + }; + + const dependencies = Object.entries(this.requiredPackages) + .map(([dep, { version }]) => ({ [dep]: version })) + .reduce((prev, next) => Object.assign(prev, next)); + + const pkg: PackageJson = { + name: `@api/${this.identifier}`, + version: pkgVersion.version, + main: './dist/index.js', + types: './dist/index.d.ts', + module: './dist/index.mts', + exports: { + '.': { + import: './dist/index.mjs', + require: './dist/index.js', + }, + ...(hasTypes + ? { + './types': { + import: './dist/types.d.mts', + require: './dist/types.d.ts', + }, + } + : {}), + }, + dependencies, + tsup: tsupOptions as JsonObject, + }; + + sourceFile.addStatements(JSON.stringify(pkg, null, 2)); + + return sourceFile; + } + /** * Create our main schemas file. This is where all of the JSON Schema that our TypeScript typing * infrastructure sources its data from. Without this there are no types. * */ - private createSchemasFile() { - const sourceFile = this.project.createSourceFile('schemas.ts', ''); - const schemasDir = this.project.createDirectory('schemas'); + private createSchemasFile(sourceDirectory: Directory) { + const sourceFile = sourceDirectory.createSourceFile('schemas.ts', ''); + const schemasDir = sourceDirectory.createDirectory('schemas'); const sortedSchemas = new Map(Array.from(Object.entries(this.schemas)).sort()); @@ -538,8 +564,8 @@ sdk.server('https://eu.api.example.com/v14');`), * * @see {@link https://npm.im/json-schema-to-ts} */ - private createTypesFile() { - const sourceFile = this.project.createSourceFile('types.ts', ''); + private createTypesFile(sourceDirectory: Directory) { + const sourceFile = sourceDirectory.createSourceFile('types.ts', ''); sourceFile.addImportDeclarations([ { defaultImport: 'type { FromSchema }', moduleSpecifier: 'json-schema-to-ts' }, @@ -815,7 +841,7 @@ sdk.server('https://eu.api.example.com/v14');`), const typeName = generateTypeName(s['x-readme-ref-name']); this.addSchemaToExport(s, typeName, typeName); - return `::convert::${typeName}` as SchemaObject; + return `${REF_PLACEHOLDER}${typeName}` as SchemaObject; } return s; @@ -834,10 +860,10 @@ sdk.server('https://eu.api.example.com/v14');`), .map(([paramType, schema]: [string, string | SchemaObject]) => { let typeName; - if (typeof schema === 'string' && schema.startsWith('::convert::')) { + if (typeof schema === 'string' && schema.startsWith(REF_PLACEHOLDER)) { // If this schema is a string and has our conversion prefix then we've already created // a type for it. - typeName = schema.replace('::convert::', ''); + typeName = schema.replace(REF_PLACEHOLDER, ''); } else { typeName = generateTypeName(operationId, paramType, 'param'); this.addSchemaToExport(schema as SchemaObject, typeName, `${generateTypeName(operationId)}.${paramType}`); @@ -873,7 +899,7 @@ sdk.server('https://eu.api.example.com/v14');`), const typeName = generateTypeName(s['x-readme-ref-name']); this.addSchemaToExport(s, typeName, `${typeName}`); - return `::convert::${typeName}` as SchemaObject; + return `${REF_PLACEHOLDER}${typeName}` as SchemaObject; } return s; @@ -894,10 +920,10 @@ sdk.server('https://eu.api.example.com/v14');`), .map(([status, { description, schema }]) => { let typeName; - if (typeof schema === 'string' && schema.startsWith('::convert::')) { + if (typeof schema === 'string' && schema.startsWith(REF_PLACEHOLDER)) { // If this schema is a string and has our conversion prefix then we've already created // a type for it. - typeName = schema.replace('::convert::', ''); + typeName = schema.replace(REF_PLACEHOLDER, ''); } else { typeName = generateTypeName(operationId, 'response', status); diff --git a/packages/api/src/commands/install.ts b/packages/api/src/commands/install.ts index 348de8fc..28b96579 100644 --- a/packages/api/src/commands/install.ts +++ b/packages/api/src/commands/install.ts @@ -1,11 +1,9 @@ -import type { SupportedLanguages } from '../codegen/factory.js'; - import { Command, Option } from 'commander'; import figures from 'figures'; import Oas from 'oas'; import ora from 'ora'; -import codegenFactory from '../codegen/factory.js'; +import codegenFactory, { SupportedLanguages } from '../codegen/factory.js'; import Fetcher from '../fetcher.js'; import promptTerminal from '../lib/prompt.js'; import logger from '../logger.js'; @@ -19,12 +17,7 @@ cmd .argument('', 'an API to install') .option('-i, --identifier ', 'API identifier (eg. `@api/petstore`)') .addOption( - new Option('-l, --lang ', 'SDK language').choices([ - 'js', // User generally wants JS, we'll prompt if they want CJS or ESM files. - 'js-cjs', - 'js-esm', - 'ts', - ]), + new Option('-l, --lang ', 'SDK language').default(SupportedLanguages.JS).choices([SupportedLanguages.JS]), ) .addOption(new Option('-y, --yes', 'Automatically answer "yes" to any prompts printed')) .action(async (uri: string, options: { identifier?: string; lang: string; yes?: boolean }) => { @@ -36,29 +29,11 @@ cmd type: 'select', name: 'value', message: 'What language would you like to generate an SDK for?', - choices: [ - { title: 'TypeScript', value: 'ts' }, - { title: 'JavaScript', value: 'js' }, - ], + choices: [{ title: 'JavaScript', value: SupportedLanguages.JS }], initial: 1, })); } - // Because our TS generation outputs raw TS source files we don't need to worry about CJS/ESM. - if (language === 'js') { - ({ value: language } = await promptTerminal({ - type: 'select', - name: 'value', - message: 'How are your project imports and exports structured?', - choices: [ - { title: 'CommonJS', description: 'require/exports', value: 'cjs' }, - { title: 'ECMAScript Modules', description: 'import/export', value: 'esm' }, - ], - initial: 0, - format: sel => (sel === 'cjs' ? 'js-cjs' : 'js-esm'), - })); - } - // @todo let them know that we're going to be creating a `.api/ directory // @todo detect if they have a gitigore and .npmignore and if .api woudl be ignored by that // @todo don't support swagger files without upconverting them @@ -120,9 +95,9 @@ cmd // @todo look for a prettier config and if we find one ask them if we should use it spinner = ora('Generating your SDK').start(); - const generator = codegenFactory(language, oas, './openapi.json', identifier); + const generator = codegenFactory(language, oas, '../openapi.json', identifier); const sdkSource = await generator - .compile() + .generate() .then(res => { spinner.succeed(spinner.text); return res; @@ -180,6 +155,17 @@ cmd } } + spinner = ora('Compiling your SDK').start(); + try { + await generator.compile(storage); + spinner.succeed(spinner.text); + } catch (err) { + // @todo cleanup installed files + spinner.fail(spinner.text); + logger(err.message, true); + process.exit(1); + } + logger('🚀 All done!'); }) .addHelpText( diff --git a/packages/api/src/packageInfo.ts b/packages/api/src/packageInfo.ts index 5e3c6409..65d55659 100644 --- a/packages/api/src/packageInfo.ts +++ b/packages/api/src/packageInfo.ts @@ -1,3 +1,3 @@ // This file is automatically updated by the build script. export const PACKAGE_NAME = 'api'; -export const PACKAGE_VERSION = '7.0.0-alpha.3'; +export const PACKAGE_VERSION = '7.0.0-alpha.5'; diff --git a/packages/api/src/storage.ts b/packages/api/src/storage.ts index 3de2fa43..1a0e25be 100644 --- a/packages/api/src/storage.ts +++ b/packages/api/src/storage.ts @@ -194,6 +194,15 @@ export default class Storage { Object.entries(files).forEach(([fileName, contents]) => { const sourceFilePath = path.join(this.getIdentifierStorageDir(), fileName); + // If this file is stored in a subdirectory then we need to create it. + if (path.dirname(fileName) !== '.') { + const dir = path.dirname(fileName); + const dirPath = path.join(this.getIdentifierStorageDir(), dir); + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath); + } + } + fs.writeFileSync(sourceFilePath, contents); savedSource.push(sourceFilePath); diff --git a/packages/api/test/__fixtures__/sdk/alby/package.json b/packages/api/test/__fixtures__/sdk/alby/package.json new file mode 100644 index 00000000..ce7f104c --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/alby/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/alby", + "version": "1.0.14", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/alby/index.ts b/packages/api/test/__fixtures__/sdk/alby/src/index.ts similarity index 90% rename from packages/api/test/__fixtures__/sdk/alby/index.ts rename to packages/api/test/__fixtures__/sdk/alby/src/index.ts index b020444f..3fade660 100644 --- a/packages/api/test/__fixtures__/sdk/alby/index.ts +++ b/packages/api/test/__fixtures__/sdk/alby/src/index.ts @@ -387,5 +387,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { AmqpExternalRulePatch, AmqpExternalRulePost, AmqpExternalRuleResponse, AmqpRulePatch, AmqpRulePost, AmqpRuleResponse, AppPatch, AppPkcs12, AppPost, AppResponse, AwsAccessKeys, AwsAccessKeysResponse, AwsAssumeRole, AwsKinesisRulePatch, AwsKinesisRulePost, AwsKinesisRuleResponse, AwsLambdaRulePatch, AwsLambdaRulePost, AwsLambdaRuleResponse, AwsSqsRulePatch, AwsSqsRulePost, AwsSqsRuleResponse, AzureFunctionRulePatch, AzureFunctionRulePost, AzureFunctionRuleResponse, CloudflareWorkerRulePatch, CloudflareWorkerRulePost, CloudflareWorkerRuleResponse, DeleteAppsAppIdNamespacesNamespaceIdMetadataParam, DeleteAppsAppIdQueuesQueueIdMetadataParam, DeleteAppsAppIdRulesRuleIdMetadataParam, DeleteAppsIdMetadataParam, Error, GetAccountsAccountIdAppsMetadataParam, GetAccountsAccountIdAppsResponse200, GetAppsAppIdKeysMetadataParam, GetAppsAppIdKeysResponse200, GetAppsAppIdNamespacesMetadataParam, GetAppsAppIdNamespacesResponse200, GetAppsAppIdQueuesMetadataParam, GetAppsAppIdQueuesResponse200, GetAppsAppIdRulesMetadataParam, GetAppsAppIdRulesResponse200, GetAppsAppIdRulesRuleIdMetadataParam, GoogleCloudFunctionRulePatch, GoogleCloudFunctionRulePost, GoogleCloudFunctionRuleResponse, HttpRulePatch, HttpRulePost, HttpRuleResponse, IftttRulePatch, IftttRulePost, IftttRuleResponse, KeyPatch, KeyPost, KeyResponse, Me, NamespacePatch, NamespacePost, NamespaceResponse, PatchAppsAppIdKeysKeyIdMetadataParam, PatchAppsAppIdNamespacesNamespaceIdMetadataParam, PatchAppsAppIdRulesRuleIdMetadataParam, PatchAppsIdMetadataParam, PostAccountsAccountIdAppsMetadataParam, PostAppsAppIdKeysKeyIdRevokeMetadataParam, PostAppsAppIdKeysMetadataParam, PostAppsAppIdNamespacesMetadataParam, PostAppsAppIdQueuesMetadataParam, PostAppsAppIdRulesMetadataParam, PostAppsIdPkcs12MetadataParam, Queue, QueueResponse, RulePatch, RulePost, RuleResponse, RuleSource, UnsupportedRuleResponse, ZapierRulePatch, ZapierRulePost, ZapierRuleResponse } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpExternalRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpExternalRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AmqpRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AmqpRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AppPatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AppPatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AppPkcs12.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPkcs12.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AppPkcs12.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPkcs12.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AppPost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AppPost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AppPost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AppResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AppResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AppResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AppResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsAccessKeys.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAccessKeys.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsAccessKeys.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAccessKeys.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsAccessKeysResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAccessKeysResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsAccessKeysResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAccessKeysResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsAssumeRole.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAssumeRole.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsAssumeRole.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsAssumeRole.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsKinesisRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsKinesisRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsLambdaRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsLambdaRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AwsSqsRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AwsSqsRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/AzureFunctionRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/AzureFunctionRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/CloudflareWorkerRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/CloudflareWorkerRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdQueuesQueueId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdQueuesQueueId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdQueuesQueueId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdQueuesQueueId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdRulesRuleId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdRulesRuleId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsAppIdRulesRuleId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsAppIdRulesRuleId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/DeleteAppsId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/DeleteAppsId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/Error.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/Error.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/Error.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/Error.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAccountsAccountIdApps.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAccountsAccountIdApps.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAccountsAccountIdApps.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAccountsAccountIdApps.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdKeys.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdKeys.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdKeys.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdKeys.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdNamespaces.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdNamespaces.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdNamespaces.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdNamespaces.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdQueues.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdQueues.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdQueues.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdQueues.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdRules.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdRules.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdRules.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdRules.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdRulesRuleId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdRulesRuleId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GetAppsAppIdRulesRuleId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GetAppsAppIdRulesRuleId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/GoogleCloudFunctionRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/GoogleCloudFunctionRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/HttpRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/HttpRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/HttpRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/HttpRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/HttpRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/HttpRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/HttpRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/IftttRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/IftttRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/IftttRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/IftttRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/IftttRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/IftttRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/IftttRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/KeyPatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyPatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/KeyPatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyPatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/KeyPost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyPost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/KeyPost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyPost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/KeyResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/KeyResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/KeyResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/Me.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/Me.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/Me.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/Me.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/NamespacePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespacePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/NamespacePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespacePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/NamespacePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespacePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/NamespacePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespacePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/NamespaceResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespaceResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/NamespaceResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/NamespaceResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdKeysKeyId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdKeysKeyId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdKeysKeyId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdKeysKeyId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdNamespacesNamespaceId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdNamespacesNamespaceId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdNamespacesNamespaceId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdNamespacesNamespaceId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdRulesRuleId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdRulesRuleId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsAppIdRulesRuleId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsAppIdRulesRuleId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsId.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsId.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PatchAppsId.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PatchAppsId.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAccountsAccountIdApps.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAccountsAccountIdApps.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAccountsAccountIdApps.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAccountsAccountIdApps.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdKeys.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdKeys.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdKeys.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdKeys.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdKeysKeyIdRevoke.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdKeysKeyIdRevoke.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdKeysKeyIdRevoke.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdKeysKeyIdRevoke.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdNamespaces.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdNamespaces.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdNamespaces.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdNamespaces.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdQueues.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdQueues.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdQueues.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdQueues.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdRules.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdRules.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsAppIdRules.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsAppIdRules.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsIdPkcs12.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsIdPkcs12.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/PostAppsIdPkcs12.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/PostAppsIdPkcs12.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/Queue.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/Queue.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/Queue.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/Queue.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/QueueResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/QueueResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/QueueResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/QueueResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/RulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/RulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/RulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/RulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/RulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/RulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/RulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/RulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/RuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/RuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/RuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/RuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/RuleSource.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/RuleSource.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/RuleSource.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/RuleSource.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/UnsupportedRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/UnsupportedRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/UnsupportedRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/UnsupportedRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRulePatch.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRulePatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRulePatch.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRulePatch.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRulePost.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRulePost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRulePost.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRulePost.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRuleResponse.ts b/packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRuleResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/schemas/ZapierRuleResponse.ts rename to packages/api/test/__fixtures__/sdk/alby/src/schemas/ZapierRuleResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/types.ts b/packages/api/test/__fixtures__/sdk/alby/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/alby/types.ts rename to packages/api/test/__fixtures__/sdk/alby/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/alby/tsconfig.json b/packages/api/test/__fixtures__/sdk/alby/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/alby/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/operationid-quirks/package.json b/packages/api/test/__fixtures__/sdk/operationid-quirks/package.json new file mode 100644 index 00000000..64b24f7a --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/operationid-quirks/package.json @@ -0,0 +1,34 @@ +{ + "name": "@api/operationid-quirks", + "version": "1.0.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/operationid-quirks/index.ts b/packages/api/test/__fixtures__/sdk/operationid-quirks/src/index.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/operationid-quirks/index.ts rename to packages/api/test/__fixtures__/sdk/operationid-quirks/src/index.ts diff --git a/packages/api/test/__fixtures__/sdk/operationid-quirks/tsconfig.json b/packages/api/test/__fixtures__/sdk/operationid-quirks/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/operationid-quirks/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/package.json b/packages/api/test/__fixtures__/sdk/optional-payload/package.json new file mode 100644 index 00000000..2e1d14e1 --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/optional-payload/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/optional-payload", + "version": "1.0.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/index.ts b/packages/api/test/__fixtures__/sdk/optional-payload/src/index.ts similarity index 97% rename from packages/api/test/__fixtures__/sdk/optional-payload/index.ts rename to packages/api/test/__fixtures__/sdk/optional-payload/src/index.ts index f0b145d4..3053fc23 100644 --- a/packages/api/test/__fixtures__/sdk/optional-payload/index.ts +++ b/packages/api/test/__fixtures__/sdk/optional-payload/src/index.ts @@ -88,5 +88,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { UpdatePetWithFormFormDataParam, UpdatePetWithFormMetadataParam } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/schemas.ts b/packages/api/test/__fixtures__/sdk/optional-payload/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/optional-payload/schemas.ts rename to packages/api/test/__fixtures__/sdk/optional-payload/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/schemas/UpdatePetWithForm.ts b/packages/api/test/__fixtures__/sdk/optional-payload/src/schemas/UpdatePetWithForm.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/optional-payload/schemas/UpdatePetWithForm.ts rename to packages/api/test/__fixtures__/sdk/optional-payload/src/schemas/UpdatePetWithForm.ts diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/types.ts b/packages/api/test/__fixtures__/sdk/optional-payload/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/optional-payload/types.ts rename to packages/api/test/__fixtures__/sdk/optional-payload/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/optional-payload/tsconfig.json b/packages/api/test/__fixtures__/sdk/optional-payload/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/optional-payload/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/petstore/package.json b/packages/api/test/__fixtures__/sdk/petstore/package.json new file mode 100644 index 00000000..f62eac40 --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/petstore/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/petstore", + "version": "1.0.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/petstore/index.ts b/packages/api/test/__fixtures__/sdk/petstore/src/index.ts similarity index 93% rename from packages/api/test/__fixtures__/sdk/petstore/index.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/index.ts index 03e12c83..0b199026 100644 --- a/packages/api/test/__fixtures__/sdk/petstore/index.ts +++ b/packages/api/test/__fixtures__/sdk/petstore/src/index.ts @@ -254,5 +254,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { ApiResponse, Category, CreateUsersWithArrayInputBodyParam, CreateUsersWithListInputBodyParam, DeleteOrderMetadataParam, DeletePetMetadataParam, DeleteUserMetadataParam, FindPetsByStatusMetadataParam, FindPetsByStatusResponse200, FindPetsByTagsMetadataParam, FindPetsByTagsResponse200, GetInventoryResponse200, GetOrderByIdMetadataParam, GetPetByIdMetadataParam, GetUserByNameMetadataParam, LoginUserMetadataParam, LoginUserResponse200, Order, Pet, Tag, UpdatePetWithFormFormDataParam, UpdatePetWithFormMetadataParam, UpdateUserMetadataParam, UploadFileBodyParam, UploadFileMetadataParam, User } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/ApiResponse.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/ApiResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/ApiResponse.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/ApiResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/Category.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/Category.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/Category.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/Category.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/CreateUsersWithArrayInput.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/CreateUsersWithArrayInput.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/CreateUsersWithArrayInput.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/CreateUsersWithArrayInput.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/CreateUsersWithListInput.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/CreateUsersWithListInput.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/CreateUsersWithListInput.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/CreateUsersWithListInput.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/DeleteOrder.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeleteOrder.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/DeleteOrder.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeleteOrder.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/DeletePet.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeletePet.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/DeletePet.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeletePet.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/DeleteUser.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeleteUser.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/DeleteUser.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/DeleteUser.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/FindPetsByStatus.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/FindPetsByStatus.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/FindPetsByStatus.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/FindPetsByStatus.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/FindPetsByTags.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/FindPetsByTags.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/FindPetsByTags.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/FindPetsByTags.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/GetInventory.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetInventory.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/GetInventory.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetInventory.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/GetOrderById.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetOrderById.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/GetOrderById.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetOrderById.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/GetPetById.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetPetById.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/GetPetById.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetPetById.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/GetUserByName.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetUserByName.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/GetUserByName.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/GetUserByName.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/LoginUser.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/LoginUser.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/LoginUser.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/LoginUser.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/Order.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/Order.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/Order.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/Order.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/Pet.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/Pet.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/Pet.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/Pet.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/Tag.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/Tag.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/Tag.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/Tag.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/UpdatePetWithForm.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/UpdatePetWithForm.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/UpdatePetWithForm.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/UpdatePetWithForm.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/UpdateUser.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/UpdateUser.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/UpdateUser.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/UpdateUser.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/UploadFile.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/UploadFile.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/UploadFile.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/UploadFile.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/schemas/User.ts b/packages/api/test/__fixtures__/sdk/petstore/src/schemas/User.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/schemas/User.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/schemas/User.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/types.ts b/packages/api/test/__fixtures__/sdk/petstore/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/petstore/types.ts rename to packages/api/test/__fixtures__/sdk/petstore/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/petstore/tsconfig.json b/packages/api/test/__fixtures__/sdk/petstore/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/petstore/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/readme/package.json b/packages/api/test/__fixtures__/sdk/readme/package.json new file mode 100644 index 00000000..e6cce908 --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/readme/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/readme", + "version": "4.355.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/readme/index.ts b/packages/api/test/__fixtures__/sdk/readme/src/index.ts similarity index 86% rename from packages/api/test/__fixtures__/sdk/readme/index.ts rename to packages/api/test/__fixtures__/sdk/readme/src/index.ts index 275bc650..c7a783e5 100644 --- a/packages/api/test/__fixtures__/sdk/readme/index.ts +++ b/packages/api/test/__fixtures__/sdk/readme/src/index.ts @@ -483,5 +483,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { Apply, Category, Changelog, CondensedProjectData, CreateCategoryMetadataParam, CreateCustomPageResponse401, CreateCustomPageResponse403, CreateDocMetadataParam, CreateDocResponse401, CreateDocResponse403, CreateVersionResponse400, CreateVersionResponse401, CreateVersionResponse403, CustomPage, DeleteApiSpecificationMetadataParam, DeleteApiSpecificationResponse401, DeleteApiSpecificationResponse403, DeleteCategoryMetadataParam, DeleteChangelogMetadataParam, DeleteCustomPageMetadataParam, DeleteCustomPageResponse401, DeleteCustomPageResponse403, DeleteDocMetadataParam, DeleteDocResponse401, DeleteDocResponse403, DeleteVersionMetadataParam, DeleteVersionResponse401, DeleteVersionResponse403, DocSchemaPost, DocSchemaPut, DocSchemaResponse, ErrorApikeyEmpty, ErrorApikeyMismatch, ErrorApikeyNotfound, ErrorCategoryInvalid, ErrorCategoryNotfound, ErrorCustompageInvalid, ErrorCustompageNotfound, ErrorDocInvalid, ErrorDocNotfound, ErrorRegistryNotfound, ErrorSpecFileEmpty, ErrorSpecIdDuplicate, ErrorSpecIdInvalid, ErrorSpecInvalid, ErrorSpecInvalidSchema, ErrorSpecNotfound, ErrorSpecTimeout, ErrorSpecVersionNotfound, ErrorVersionCantDemoteStable, ErrorVersionCantRemoveStable, ErrorVersionDuplicate, ErrorVersionEmpty, ErrorVersionForkEmpty, ErrorVersionForkNotfound, ErrorVersionNotfound, GetApiRegistryMetadataParam, GetApiRegistryResponse200, GetApiSchemaResponse200, GetApiSpecificationMetadataParam, GetApiSpecificationResponse200, GetApiSpecificationResponse401, GetApiSpecificationResponse403, GetCategoriesMetadataParam, GetCategoriesResponse200, GetCategoryDocsMetadataParam, GetCategoryMetadataParam, GetChangelogMetadataParam, GetChangelogsMetadataParam, GetChangelogsResponse200, GetCustomPageMetadataParam, GetCustomPageResponse401, GetCustomPageResponse403, GetCustomPagesMetadataParam, GetCustomPagesResponse200, GetCustomPagesResponse401, GetCustomPagesResponse403, GetDocMetadataParam, GetDocResponse401, GetDocResponse403, GetOpenRolesResponse200, GetProductionDocMetadataParam, GetProductionDocResponse401, GetProductionDocResponse403, GetProjectResponse401, GetProjectResponse403, GetVersionMetadataParam, GetVersionResponse401, GetVersionResponse403, GetVersionsResponse401, GetVersionsResponse403, JobOpening, SearchDocsMetadataParam, SearchDocsResponse401, SearchDocsResponse403, UpdateApiSpecificationBodyParam, UpdateApiSpecificationMetadataParam, UpdateApiSpecificationResponse400, UpdateApiSpecificationResponse401, UpdateApiSpecificationResponse403, UpdateCategoryMetadataParam, UpdateChangelogMetadataParam, UpdateCustomPageMetadataParam, UpdateCustomPageResponse401, UpdateCustomPageResponse403, UpdateDocMetadataParam, UpdateDocResponse401, UpdateDocResponse403, UpdateVersionMetadataParam, UpdateVersionResponse401, UpdateVersionResponse403, UploadApiSpecificationBodyParam, UploadApiSpecificationMetadataParam, UploadApiSpecificationResponse400, UploadApiSpecificationResponse401, UploadApiSpecificationResponse403, Version } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/Apply.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/Apply.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/Apply.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/Apply.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/Category.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/Category.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/Category.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/Category.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/Changelog.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/Changelog.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/Changelog.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/Changelog.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CondensedProjectData.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CondensedProjectData.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CondensedProjectData.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CondensedProjectData.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CreateCategory.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateCategory.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CreateCategory.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateCategory.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CreateCustomPage.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateCustomPage.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CreateCustomPage.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateCustomPage.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CreateDoc.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateDoc.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CreateDoc.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateDoc.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CreateVersion.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateVersion.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CreateVersion.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CreateVersion.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/CustomPage.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/CustomPage.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/CustomPage.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/CustomPage.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteApiSpecification.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteApiSpecification.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteApiSpecification.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteApiSpecification.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteCategory.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteCategory.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteCategory.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteCategory.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteChangelog.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteChangelog.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteChangelog.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteChangelog.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteCustomPage.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteCustomPage.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteCustomPage.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteCustomPage.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteDoc.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteDoc.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteDoc.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteDoc.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DeleteVersion.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteVersion.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DeleteVersion.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DeleteVersion.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaPost.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaPost.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaPost.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaPost.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaPut.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaPut.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaPut.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaPut.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaResponse.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaResponse.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/DocSchemaResponse.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/DocSchemaResponse.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyEmpty.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyEmpty.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyEmpty.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyEmpty.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyMismatch.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyMismatch.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyMismatch.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyMismatch.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorApikeyNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorApikeyNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCategoryInvalid.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCategoryInvalid.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCategoryInvalid.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCategoryInvalid.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCategoryNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCategoryNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCategoryNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCategoryNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCustompageInvalid.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCustompageInvalid.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCustompageInvalid.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCustompageInvalid.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCustompageNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCustompageNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorCustompageNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorCustompageNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorDocInvalid.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorDocInvalid.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorDocInvalid.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorDocInvalid.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorDocNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorDocNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorDocNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorDocNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorRegistryNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorRegistryNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorRegistryNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorRegistryNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecFileEmpty.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecFileEmpty.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecFileEmpty.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecFileEmpty.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecIdDuplicate.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecIdDuplicate.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecIdDuplicate.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecIdDuplicate.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecIdInvalid.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecIdInvalid.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecIdInvalid.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecIdInvalid.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecInvalid.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecInvalid.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecInvalid.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecInvalid.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecInvalidSchema.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecInvalidSchema.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecInvalidSchema.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecInvalidSchema.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecTimeout.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecTimeout.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecTimeout.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecTimeout.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecVersionNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecVersionNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorSpecVersionNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorSpecVersionNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionCantDemoteStable.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionCantDemoteStable.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionCantDemoteStable.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionCantDemoteStable.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionCantRemoveStable.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionCantRemoveStable.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionCantRemoveStable.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionCantRemoveStable.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionDuplicate.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionDuplicate.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionDuplicate.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionDuplicate.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionEmpty.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionEmpty.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionEmpty.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionEmpty.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionForkEmpty.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionForkEmpty.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionForkEmpty.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionForkEmpty.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionForkNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionForkNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionForkNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionForkNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionNotfound.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionNotfound.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/ErrorVersionNotfound.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/ErrorVersionNotfound.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetApiRegistry.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiRegistry.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetApiRegistry.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiRegistry.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetApiSchema.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiSchema.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetApiSchema.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiSchema.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetApiSpecification.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiSpecification.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetApiSpecification.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetApiSpecification.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetCategories.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategories.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetCategories.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategories.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetCategory.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategory.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetCategory.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategory.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetCategoryDocs.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategoryDocs.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetCategoryDocs.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCategoryDocs.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetChangelog.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetChangelog.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetChangelog.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetChangelog.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetChangelogs.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetChangelogs.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetChangelogs.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetChangelogs.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetCustomPage.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCustomPage.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetCustomPage.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCustomPage.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetCustomPages.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCustomPages.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetCustomPages.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetCustomPages.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetDoc.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetDoc.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetDoc.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetDoc.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetOpenRoles.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetOpenRoles.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetOpenRoles.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetOpenRoles.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetProductionDoc.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetProductionDoc.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetProductionDoc.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetProductionDoc.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetProject.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetProject.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetProject.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetProject.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetVersion.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetVersion.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetVersion.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetVersion.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/GetVersions.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/GetVersions.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/GetVersions.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/GetVersions.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/JobOpening.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/JobOpening.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/JobOpening.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/JobOpening.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/SearchDocs.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/SearchDocs.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/SearchDocs.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/SearchDocs.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateApiSpecification.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateApiSpecification.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateApiSpecification.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateApiSpecification.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateCategory.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateCategory.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateCategory.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateCategory.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateChangelog.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateChangelog.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateChangelog.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateChangelog.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateCustomPage.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateCustomPage.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateCustomPage.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateCustomPage.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateDoc.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateDoc.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateDoc.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateDoc.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UpdateVersion.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateVersion.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UpdateVersion.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UpdateVersion.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/UploadApiSpecification.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/UploadApiSpecification.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/UploadApiSpecification.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/UploadApiSpecification.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/schemas/Version.ts b/packages/api/test/__fixtures__/sdk/readme/src/schemas/Version.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/schemas/Version.ts rename to packages/api/test/__fixtures__/sdk/readme/src/schemas/Version.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/types.ts b/packages/api/test/__fixtures__/sdk/readme/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/readme/types.ts rename to packages/api/test/__fixtures__/sdk/readme/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/readme/tsconfig.json b/packages/api/test/__fixtures__/sdk/readme/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/readme/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/package.json b/packages/api/test/__fixtures__/sdk/response-title-quirks/package.json new file mode 100644 index 00000000..d08debbe --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/response-title-quirks/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/response-title-quirks", + "version": "1.0.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/index.ts b/packages/api/test/__fixtures__/sdk/response-title-quirks/src/index.ts similarity index 97% rename from packages/api/test/__fixtures__/sdk/response-title-quirks/index.ts rename to packages/api/test/__fixtures__/sdk/response-title-quirks/src/index.ts index 17b3a68e..c0bd30a7 100644 --- a/packages/api/test/__fixtures__/sdk/response-title-quirks/index.ts +++ b/packages/api/test/__fixtures__/sdk/response-title-quirks/src/index.ts @@ -82,5 +82,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { GetAnythingMetadataParam, GetAnythingResponse2XX } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/schemas.ts b/packages/api/test/__fixtures__/sdk/response-title-quirks/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/response-title-quirks/schemas.ts rename to packages/api/test/__fixtures__/sdk/response-title-quirks/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/schemas/GetAnything.ts b/packages/api/test/__fixtures__/sdk/response-title-quirks/src/schemas/GetAnything.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/response-title-quirks/schemas/GetAnything.ts rename to packages/api/test/__fixtures__/sdk/response-title-quirks/src/schemas/GetAnything.ts diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/types.ts b/packages/api/test/__fixtures__/sdk/response-title-quirks/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/response-title-quirks/types.ts rename to packages/api/test/__fixtures__/sdk/response-title-quirks/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/response-title-quirks/tsconfig.json b/packages/api/test/__fixtures__/sdk/response-title-quirks/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/response-title-quirks/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.d.ts deleted file mode 100644 index 55ab3985..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const Category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; -}; -export default Category; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.js b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.js deleted file mode 100644 index 0fa22cc5..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Category.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Category = { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "name": { "type": "string" } }, "title": "Category", "x-readme-ref-name": "Category" }; -exports.default = Category; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.d.ts deleted file mode 100644 index c33301c4..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -declare const FindPetsByStatus: { - readonly metadata: { - readonly allOf: readonly [{ - readonly type: "object"; - readonly properties: { - readonly status: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly enum: readonly ["available", "pending", "sold"]; - readonly default: "available"; - readonly description: "Default: available"; - }; - readonly $schema: "http://json-schema.org/draft-04/schema#"; - readonly description: "Status values that need to be considered for filter"; - }; - }; - readonly required: readonly ["status"]; - }]; - }; - readonly response: { - readonly "200": { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly required: readonly ["name", "photoUrls"]; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly readOnly: true; - readonly default: 40; - readonly examples: readonly [25]; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; - }; - readonly name: { - readonly type: "string"; - readonly examples: readonly ["doggie"]; - }; - readonly photoUrls: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly examples: readonly ["https://example.com/photo.png"]; - }; - }; - readonly tags: { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; - }; - }; - readonly status: { - readonly type: "string"; - readonly description: "pet status in the store\n\n`available` `pending` `sold`"; - readonly enum: readonly ["available", "pending", "sold"]; - }; - }; - readonly title: "Pet"; - readonly "x-readme-ref-name": "Pet"; - }; - readonly $schema: "http://json-schema.org/draft-04/schema#"; - }; - }; -}; -export default FindPetsByStatus; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.js b/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.js deleted file mode 100644 index b1172af3..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/FindPetsByStatus.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Pet_1 = __importDefault(require("./Pet")); -var FindPetsByStatus = { "metadata": { "allOf": [{ "type": "object", "properties": { "status": { "type": "array", "items": { "type": "string", "enum": ["available", "pending", "sold"], "default": "available", "description": "Default: available" }, "$schema": "http://json-schema.org/draft-04/schema#", "description": "Status values that need to be considered for filter" } }, "required": ["status"] }] }, "response": { "200": { "type": "array", "items": Pet_1.default, "$schema": "http://json-schema.org/draft-04/schema#" } } }; -exports.default = FindPetsByStatus; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.d.ts deleted file mode 100644 index 7b225e71..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -declare const Pet: { - readonly type: "object"; - readonly required: readonly ["name", "photoUrls"]; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly readOnly: true; - readonly default: 40; - readonly examples: readonly [25]; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; - }; - readonly name: { - readonly type: "string"; - readonly examples: readonly ["doggie"]; - }; - readonly photoUrls: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly examples: readonly ["https://example.com/photo.png"]; - }; - }; - readonly tags: { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; - }; - }; - readonly status: { - readonly type: "string"; - readonly description: "pet status in the store\n\n`available` `pending` `sold`"; - readonly enum: readonly ["available", "pending", "sold"]; - }; - }; - readonly title: "Pet"; - readonly "x-readme-ref-name": "Pet"; -}; -export default Pet; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.js b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.js deleted file mode 100644 index b162c13b..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Pet.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var Category_1 = __importDefault(require("./Category")); -var Tag_1 = __importDefault(require("./Tag")); -var Pet = { "type": "object", "required": ["name", "photoUrls"], "properties": { "id": { "type": "integer", "format": "int64", "readOnly": true, "default": 40, "examples": [25], "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "category": Category_1.default, "name": { "type": "string", "examples": ["doggie"] }, "photoUrls": { "type": "array", "items": { "type": "string", "examples": ["https://example.com/photo.png"] } }, "tags": { "type": "array", "items": Tag_1.default }, "status": { "type": "string", "description": "pet status in the store\n\n`available` `pending` `sold`", "enum": ["available", "pending", "sold"] } }, "title": "Pet", "x-readme-ref-name": "Pet" }; -exports.default = Pet; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.d.ts deleted file mode 100644 index 1766ceb6..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const Tag: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; -}; -export default Tag; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.js b/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.js deleted file mode 100644 index 06f113f4..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/Tag.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Tag = { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "name": { "type": "string" } }, "title": "Tag", "x-readme-ref-name": "Tag" }; -exports.default = Tag; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.d.ts deleted file mode 100644 index 6476e472..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type * as types from './types'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core'; -import Oas from 'oas'; -import APICore from '@readme/api-core'; -declare class SDK { - spec: Oas; - core: APICore; - constructor(); - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions): void; - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]): this; - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables?: {}): void; - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise>; -} -declare const createSDK: SDK; -export = createSDK; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.js b/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.js deleted file mode 100644 index 30a966dd..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/index.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -var oas_1 = __importDefault(require("oas")); -var api_core_1 = __importDefault(require("@readme/api-core")); -var simple_json_1 = __importDefault(require("@api/test-utils/definitions/simple.json")); -var SDK = /** @class */ (function () { - function SDK() { - this.spec = oas_1.default.init(simple_json_1.default); - this.core = new api_core_1.default(this.spec, 'simple-js-cjs/1.0.0 (api/<>)'); - } - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - SDK.prototype.config = function (config) { - this.core.setConfig(config); - }; - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - SDK.prototype.auth = function () { - var _a; - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - (_a = this.core).setAuth.apply(_a, values); - return this; - }; - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - SDK.prototype.server = function (url, variables) { - if (variables === void 0) { variables = {}; } - this.core.setServer(url, variables); - }; - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - SDK.prototype.findPetsByStatus = function (metadata) { - return this.core.fetch('/pet/findByStatus', 'get', metadata); - }; - return SDK; -}()); -var createSDK = (function () { return new SDK(); })(); -module.exports = createSDK; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/schemas.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/schemas.d.ts deleted file mode 100644 index c302d75e..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/schemas.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Category from './schemas/Category'; -import FindPetsByStatus from './schemas/FindPetsByStatus'; -import Pet from './schemas/Pet'; -import Tag from './schemas/Tag'; -export { Category, FindPetsByStatus, Pet, Tag }; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-cjs/types.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-cjs/types.d.ts deleted file mode 100644 index 5807822c..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-cjs/types.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { FromSchema } from 'json-schema-to-ts'; -import * as schemas from './schemas'; -export type Category = FromSchema; -export type FindPetsByStatusMetadataParam = FromSchema; -export type FindPetsByStatusResponse200 = FromSchema; -export type Pet = FromSchema; -export type Tag = FromSchema; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.d.ts deleted file mode 100644 index 55ab3985..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const Category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; -}; -export default Category; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.js b/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.js deleted file mode 100644 index ebe9254e..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Category.js +++ /dev/null @@ -1,2 +0,0 @@ -const Category = { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "name": { "type": "string" } }, "title": "Category", "x-readme-ref-name": "Category" }; -export default Category; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.d.ts deleted file mode 100644 index c33301c4..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.d.ts +++ /dev/null @@ -1,96 +0,0 @@ -declare const FindPetsByStatus: { - readonly metadata: { - readonly allOf: readonly [{ - readonly type: "object"; - readonly properties: { - readonly status: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly enum: readonly ["available", "pending", "sold"]; - readonly default: "available"; - readonly description: "Default: available"; - }; - readonly $schema: "http://json-schema.org/draft-04/schema#"; - readonly description: "Status values that need to be considered for filter"; - }; - }; - readonly required: readonly ["status"]; - }]; - }; - readonly response: { - readonly "200": { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly required: readonly ["name", "photoUrls"]; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly readOnly: true; - readonly default: 40; - readonly examples: readonly [25]; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; - }; - readonly name: { - readonly type: "string"; - readonly examples: readonly ["doggie"]; - }; - readonly photoUrls: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly examples: readonly ["https://example.com/photo.png"]; - }; - }; - readonly tags: { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; - }; - }; - readonly status: { - readonly type: "string"; - readonly description: "pet status in the store\n\n`available` `pending` `sold`"; - readonly enum: readonly ["available", "pending", "sold"]; - }; - }; - readonly title: "Pet"; - readonly "x-readme-ref-name": "Pet"; - }; - readonly $schema: "http://json-schema.org/draft-04/schema#"; - }; - }; -}; -export default FindPetsByStatus; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.js b/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.js deleted file mode 100644 index d16b00ae..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/FindPetsByStatus.js +++ /dev/null @@ -1,3 +0,0 @@ -import Pet from './Pet'; -const FindPetsByStatus = { "metadata": { "allOf": [{ "type": "object", "properties": { "status": { "type": "array", "items": { "type": "string", "enum": ["available", "pending", "sold"], "default": "available", "description": "Default: available" }, "$schema": "http://json-schema.org/draft-04/schema#", "description": "Status values that need to be considered for filter" } }, "required": ["status"] }] }, "response": { "200": { "type": "array", "items": Pet, "$schema": "http://json-schema.org/draft-04/schema#" } } }; -export default FindPetsByStatus; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.d.ts deleted file mode 100644 index 7b225e71..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -declare const Pet: { - readonly type: "object"; - readonly required: readonly ["name", "photoUrls"]; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly readOnly: true; - readonly default: 40; - readonly examples: readonly [25]; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly category: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Category"; - readonly "x-readme-ref-name": "Category"; - }; - readonly name: { - readonly type: "string"; - readonly examples: readonly ["doggie"]; - }; - readonly photoUrls: { - readonly type: "array"; - readonly items: { - readonly type: "string"; - readonly examples: readonly ["https://example.com/photo.png"]; - }; - }; - readonly tags: { - readonly type: "array"; - readonly items: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; - }; - }; - readonly status: { - readonly type: "string"; - readonly description: "pet status in the store\n\n`available` `pending` `sold`"; - readonly enum: readonly ["available", "pending", "sold"]; - }; - }; - readonly title: "Pet"; - readonly "x-readme-ref-name": "Pet"; -}; -export default Pet; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.js b/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.js deleted file mode 100644 index c3748181..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Pet.js +++ /dev/null @@ -1,4 +0,0 @@ -import Category from './Category'; -import Tag from './Tag'; -const Pet = { "type": "object", "required": ["name", "photoUrls"], "properties": { "id": { "type": "integer", "format": "int64", "readOnly": true, "default": 40, "examples": [25], "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "category": Category, "name": { "type": "string", "examples": ["doggie"] }, "photoUrls": { "type": "array", "items": { "type": "string", "examples": ["https://example.com/photo.png"] } }, "tags": { "type": "array", "items": Tag }, "status": { "type": "string", "description": "pet status in the store\n\n`available` `pending` `sold`", "enum": ["available", "pending", "sold"] } }, "title": "Pet", "x-readme-ref-name": "Pet" }; -export default Pet; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.d.ts deleted file mode 100644 index 1766ceb6..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const Tag: { - readonly type: "object"; - readonly properties: { - readonly id: { - readonly type: "integer"; - readonly format: "int64"; - readonly minimum: -9223372036854776000; - readonly maximum: 9223372036854776000; - }; - readonly name: { - readonly type: "string"; - }; - }; - readonly title: "Tag"; - readonly "x-readme-ref-name": "Tag"; -}; -export default Tag; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.js b/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.js deleted file mode 100644 index b39945bf..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/Tag.js +++ /dev/null @@ -1,2 +0,0 @@ -const Tag = { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "minimum": -9223372036854776000, "maximum": 9223372036854776000 }, "name": { "type": "string" } }, "title": "Tag", "x-readme-ref-name": "Tag" }; -export default Tag; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/index.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/index.d.ts deleted file mode 100644 index 19ddf0d2..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/index.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type * as types from './types'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core'; -import Oas from 'oas'; -import APICore from '@readme/api-core'; -declare class SDK { - spec: Oas; - core: APICore; - constructor(); - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions): void; - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]): this; - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables?: {}): void; - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise>; -} -declare const createSDK: SDK; -export default createSDK; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/index.js b/packages/api/test/__fixtures__/sdk/simple-js-esm/index.js deleted file mode 100644 index a1a65782..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/index.js +++ /dev/null @@ -1,76 +0,0 @@ -import Oas from 'oas'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/simple.json'; -class SDK { - constructor() { - this.spec = Oas.init(definition); - this.core = new APICore(this.spec, 'simple-js-esm/1.0.0 (api/<>)'); - } - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config) { - this.core.setConfig(config); - } - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values) { - this.core.setAuth(...values); - return this; - } - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url, variables = {}) { - this.core.setServer(url, variables); - } - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - findPetsByStatus(metadata) { - return this.core.fetch('/pet/findByStatus', 'get', metadata); - } -} -const createSDK = (() => { return new SDK(); })(); -export default createSDK; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/schemas.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/schemas.d.ts deleted file mode 100644 index c302d75e..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/schemas.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Category from './schemas/Category'; -import FindPetsByStatus from './schemas/FindPetsByStatus'; -import Pet from './schemas/Pet'; -import Tag from './schemas/Tag'; -export { Category, FindPetsByStatus, Pet, Tag }; diff --git a/packages/api/test/__fixtures__/sdk/simple-js-esm/types.d.ts b/packages/api/test/__fixtures__/sdk/simple-js-esm/types.d.ts deleted file mode 100644 index 5807822c..00000000 --- a/packages/api/test/__fixtures__/sdk/simple-js-esm/types.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { FromSchema } from 'json-schema-to-ts'; -import * as schemas from './schemas'; -export type Category = FromSchema; -export type FindPetsByStatusMetadataParam = FromSchema; -export type FindPetsByStatusResponse200 = FromSchema; -export type Pet = FromSchema; -export type Tag = FromSchema; diff --git a/packages/api/test/__fixtures__/sdk/simple/package.json b/packages/api/test/__fixtures__/sdk/simple/package.json new file mode 100644 index 00000000..896bbb8f --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/simple/package.json @@ -0,0 +1,39 @@ +{ + "name": "@api/simple", + "version": "1.0.0", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "module": "./dist/index.mts", + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + }, + "./types": { + "import": "./dist/types.d.mts", + "require": "./dist/types.d.ts" + } + }, + "dependencies": { + "@readme/api-core": "file:../../../../../core", + "json-schema-to-ts": "^2.9.2", + "oas": "^23.0.0" + }, + "tsup": { + "cjsInterop": true, + "clean": true, + "dts": true, + "entry": [ + "./src/index.ts", + "./src/types.ts" + ], + "format": [ + "esm", + "cjs" + ], + "minify": false, + "shims": true, + "sourcemap": true, + "splitting": true + } +} diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/index.ts b/packages/api/test/__fixtures__/sdk/simple/src/index.ts similarity index 93% rename from packages/api/test/__fixtures__/sdk/simple-ts/index.ts rename to packages/api/test/__fixtures__/sdk/simple/src/index.ts index 3e3ccd94..e1c31ea0 100644 --- a/packages/api/test/__fixtures__/sdk/simple-ts/index.ts +++ b/packages/api/test/__fixtures__/sdk/simple/src/index.ts @@ -10,7 +10,7 @@ class SDK { constructor() { this.spec = Oas.init(definition); - this.core = new APICore(this.spec, 'simple-ts/1.0.0 (api/<>)'); + this.core = new APICore(this.spec, 'simple/1.0.0 (api/<>)'); } /** @@ -87,5 +87,3 @@ const createSDK = (() => { return new SDK(); })() ; export default createSDK; - -export type { Category, FindPetsByStatusMetadataParam, FindPetsByStatusResponse200, Pet, Tag } from './types'; diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/schemas.ts b/packages/api/test/__fixtures__/sdk/simple/src/schemas.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/schemas.ts rename to packages/api/test/__fixtures__/sdk/simple/src/schemas.ts diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/schemas/Category.ts b/packages/api/test/__fixtures__/sdk/simple/src/schemas/Category.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/schemas/Category.ts rename to packages/api/test/__fixtures__/sdk/simple/src/schemas/Category.ts diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/schemas/FindPetsByStatus.ts b/packages/api/test/__fixtures__/sdk/simple/src/schemas/FindPetsByStatus.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/schemas/FindPetsByStatus.ts rename to packages/api/test/__fixtures__/sdk/simple/src/schemas/FindPetsByStatus.ts diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/schemas/Pet.ts b/packages/api/test/__fixtures__/sdk/simple/src/schemas/Pet.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/schemas/Pet.ts rename to packages/api/test/__fixtures__/sdk/simple/src/schemas/Pet.ts diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/schemas/Tag.ts b/packages/api/test/__fixtures__/sdk/simple/src/schemas/Tag.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/schemas/Tag.ts rename to packages/api/test/__fixtures__/sdk/simple/src/schemas/Tag.ts diff --git a/packages/api/test/__fixtures__/sdk/simple-ts/types.ts b/packages/api/test/__fixtures__/sdk/simple/src/types.ts similarity index 100% rename from packages/api/test/__fixtures__/sdk/simple-ts/types.ts rename to packages/api/test/__fixtures__/sdk/simple/src/types.ts diff --git a/packages/api/test/__fixtures__/sdk/simple/tsconfig.json b/packages/api/test/__fixtures__/sdk/simple/tsconfig.json new file mode 100644 index 00000000..07af03ae --- /dev/null +++ b/packages/api/test/__fixtures__/sdk/simple/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/api/test/codegen/languages/typescript/index.test.ts b/packages/api/test/codegen/languages/typescript/index.test.ts index 9cabc112..1e7b4c8e 100644 --- a/packages/api/test/codegen/languages/typescript/index.test.ts +++ b/packages/api/test/codegen/languages/typescript/index.test.ts @@ -1,9 +1,8 @@ -import type { TSGeneratorOptions } from '../../../../src/codegen/languages/typescript/index.js'; - import fs from 'node:fs/promises'; import path from 'node:path'; import { loadSpec, responses as mockResponse } from '@api/test-utils'; +import execa from 'execa'; import fetchMock from 'fetch-mock'; import Oas from 'oas'; import uniqueTempDir from 'unique-temp-dir'; @@ -13,13 +12,13 @@ import TSGenerator from '../../../../src/codegen/languages/typescript/index.js'; import * as packageInfo from '../../../../src/packageInfo.js'; import Storage from '../../../../src/storage.js'; -function assertSDKFixture(file: string, fixture: string, opts: TSGeneratorOptions = {}) { +function assertSDKFixture(file: string, fixture: string) { return async () => { const oas = await loadSpec(require.resolve(file)).then(Oas.init); await oas.dereference({ preserveRefAsJSONSchemaTitle: true }); - const ts = new TSGenerator(oas, file, fixture, opts); - const actualFiles = await ts.compile(); + const ts = new TSGenerator(oas, file, fixture); + const actualFiles = await ts.generate(); // Determine if the generated code matches what we've got in our fixture. const dir = path.resolve(path.join(__dirname, '..', '..', '..', '__fixtures__', 'sdk', fixture)); @@ -28,11 +27,11 @@ function assertSDKFixture(file: string, fixture: string, opts: TSGeneratorOption .then(files => { files.sort(); - // The `schemas` directory comes back to us from `fs.readdir` but because we're doing a - // recursive lookup on that we also get `schemas/`. We only care about the - // schema file itself, not the general directory, so we need to exclude this from our list - // of expected files. - return files.filter(f => f !== 'schemas'); + // The `src/schemas` directory comes back to us from `fs.readdir` but because we're doing a + // recursive lookup on that we also get `src/schemas/`. We only care about the + // schema files themselves, not the general directory, so we need to exclude this from our + // list of expected files. + return files.filter(f => !['src', 'src/schemas'].includes(f)); }) .catch(() => { /** @@ -54,26 +53,23 @@ function assertSDKFixture(file: string, fixture: string, opts: TSGeneratorOption // We have to wrap in our current package version into the `<>` placeholder so // we don't need to worry about committing package versions into source control or trying // to mock out our `packageInfo` library, potentially causing sideeffects in other tests. - return new Promise((resolve, reject) => { - fs.readFile(path.join(dir, filename), 'utf8') - .then(expected => expected.replace('<>', packageInfo.PACKAGE_VERSION)) - .then(expected => { - expect(actual).toBe(expected); - resolve(true); - }) - .catch(reject); - }); + return fs + .readFile(path.join(dir, filename), 'utf8') + .then(expected => expected.replace('<>', packageInfo.PACKAGE_VERSION)) + .then(expected => { + expect(actual).toBe(expected); + }); }), ); // Make sure that we can load the SDK without any TS compilation errors. - const sdk = await import(`../../../__fixtures__/sdk/${fixture}`).then(r => r.default); + const sdk = await import(`${dir}/src/index.ts`).then(r => r.default); expect(sdk.constructor.name).toBe('SDK'); }; } describe('typescript', () => { - describe('#installer', () => { + describe('#install', () => { beforeEach(() => { Storage.setStorageDir(uniqueTempDir()); }); @@ -82,7 +78,7 @@ describe('typescript', () => { Storage.reset(); }); - it('should install a `package.json` and the required packages', async () => { + it('should install the required packages', async () => { const logger = vi.fn(); const file = require.resolve('@readme/oas-examples/3.0/json/petstore.json'); @@ -92,21 +88,16 @@ describe('typescript', () => { const storage = new Storage(file, 'petstore'); await storage.load(); - const ts = new TSGenerator(oas, './openapi.json', 'petstore', { compilerTarget: 'cjs' }); - await ts.install(storage, { logger, dryRun: true }); - - const pkgJson = await fs - .readFile(path.join(storage.getIdentifierStorageDir(), 'package.json'), 'utf-8') - .then(JSON.parse); + const ts = new TSGenerator(oas, '../openapi.json', 'petstore'); + const source = await ts.generate(); + await storage.saveSourceFiles(source); - expect(pkgJson).toStrictEqual({ - name: '@api/petstore', - version: '1.0.0', - main: './index.ts', - types: './index.d.ts', - }); + await ts.install(storage, { logger, dryRun: true }); - expect(logger).toHaveBeenCalledWith('npm install --save --dry-run api json-schema-to-ts oas'); + const { stdout } = await execa('ls', ['-R1'], { cwd: storage.getIdentifierStorageDir() }); + expect(stdout).toContain('index.ts'); + expect(stdout).toContain('schemas'); + expect(stdout).toContain('Pet.ts'); /** * NPM has an incredibly difficult time trying to resolve this temp dir when installing @@ -118,15 +109,12 @@ describe('typescript', () => { * * @fixme */ - // expect(logger).to.be.calledWith(`npm install --save --dry-run ${storage.getIdentifierStorageDir()}`); + // expect(logger).toHaveBeenCalledWith(`npm install --save --dry-run ${storage.getIdentifierStorageDir()}`); }, 20000); }); - describe('#generator', () => { - it( - 'should generate typescript (by default)', - assertSDKFixture('@api/test-utils/definitions/simple.json', 'simple-ts'), - ); + describe('#compile', () => { + it('should generate an sdk', assertSDKFixture('@api/test-utils/definitions/simple.json', 'simple')); it( 'should be able to generate valid TS when a body is optional but metadata isnt', @@ -155,30 +143,17 @@ describe('typescript', () => { assertSDKFixture('@api/test-utils/definitions/alby.json', 'alby'), ); - describe('javascript generation', () => { - it( - 'should generate a CommonJS library', - assertSDKFixture('@api/test-utils/definitions/simple.json', 'simple-js-cjs', { outputJS: true }), - ); - - it( - 'should generate am ESM library', - assertSDKFixture('@api/test-utils/definitions/simple.json', 'simple-js-esm', { - outputJS: true, - compilerTarget: 'esm', - }), - ); - }); - describe('integration', () => { afterEach(() => { fetchMock.restore(); }); - it('should be able to make an API request (TS)', async () => { - const sdk = await import('../../../__fixtures__/sdk/simple-ts/index.js').then(r => r.default); + it('should be able to make an API request', async () => { + // eslint-disable-next-line import/no-relative-packages + const sdk = await import('../../../__fixtures__/sdk/simple/src/index.js').then(r => r.default); fetchMock.get('http://petstore.swagger.io/v2/pet/findByStatus?status=available', mockResponse.searchParams); + // @ts-expect-error `findPetsByStatus` types are only present with a fully built out SDK dist which this fixture lacks. await sdk.findPetsByStatus({ status: ['available'] }).then(({ data, status, headers, res }) => { expect(data).toBe('/v2/pet/findByStatus?status=available'); expect(status).toBe(200); @@ -188,10 +163,12 @@ describe('typescript', () => { }); it('should be able to make an API request with an `accept` header`', async () => { - const sdk = await import('../../../__fixtures__/sdk/simple-ts/index.js').then(r => r.default); + // eslint-disable-next-line import/no-relative-packages + const sdk = await import('../../../__fixtures__/sdk/simple/src/index.js').then(r => r.default); fetchMock.get('http://petstore.swagger.io/v2/pet/findByStatus?status=available', mockResponse.headers); await sdk + // @ts-expect-error `findPetsByStatus` types are only present with a fully built out SDK dist which this fixture lacks. .findPetsByStatus({ status: ['available'], accept: 'application/xml' }) .then(({ data, status, headers, res }) => { expect(data).toHaveProperty('accept', 'application/xml'); @@ -200,37 +177,6 @@ describe('typescript', () => { expect(res.constructor.name).toBe('Response'); }); }); - - /** - * This test is impossible to run now because its a `.js` file that's loading ESM code. The - * CJS SDK we're generating here should have a `.cjs` extension but we're going to overhaul - * this entire codegen process with `tsup` so this test is being skipped for now. - * - * @see {@link https://github.com/readmeio/api/pull/734} - */ - // it.skip('should be able to make an API request (JS + CommonJS)', async () => { - // const sdk = await import('../../../__fixtures__/sdk/simple-js-cjs/index.js').then(r => r.default); - // fetchMock.get('http://petstore.swagger.io/v2/pet/findByStatus?status=available', mockResponse.searchParams); - - // await sdk.findPetsByStatus({ status: ['available'] }).then(({ data, status, headers, res }) => { - // expect(data).toBe('/v2/pet/findByStatus?status=available'); - // expect(status).toBe(200); - // expect(headers.constructor.name).toBe('Headers'); - // expect(res.constructor.name).toBe('Response'); - // }); - // }); - - it('should be able to make an API request (JS + ESM)', async () => { - const sdk = await import('../../../__fixtures__/sdk/simple-js-esm/index.js').then(r => r.default); - fetchMock.get('http://petstore.swagger.io/v2/pet/findByStatus?status=available', mockResponse.searchParams); - - await sdk.findPetsByStatus({ status: ['available'] }).then(({ data, status, headers, res }) => { - expect(data).toBe('/v2/pet/findByStatus?status=available'); - expect(status).toBe(200); - expect(headers.constructor.name).toBe('Headers'); - expect(res.constructor.name).toBe('Response'); - }); - }); }); describe('error handling', () => { @@ -245,7 +191,7 @@ describe('typescript', () => { }); const ts = new TSGenerator(oas, 'no-paths', './no-paths.json'); - await expect(ts.compile()).rejects.toThrow( + await expect(ts.generate()).rejects.toThrow( 'Sorry, this OpenAPI definition does not have any operation paths to generate an SDK for.', ); }); diff --git a/packages/api/test/codegen/languages/typescript/smoketest.test.ts b/packages/api/test/codegen/languages/typescript/smoketest.test.ts index ea955940..2162b43e 100644 --- a/packages/api/test/codegen/languages/typescript/smoketest.test.ts +++ b/packages/api/test/codegen/languages/typescript/smoketest.test.ts @@ -70,7 +70,7 @@ describe('typescript smoketest', () => { await oas.dereference({ preserveRefAsJSONSchemaTitle: true }); const ts = new TSGenerator(oas, './path/not/needed.json', name); - const res = await ts.compile(); + const res = await ts.generate(); if (APIS_WITHOUT_SCHEMAS.includes(name)) { expect(Object.keys(res)).toStrictEqual(['index.ts']); diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index ea11e325..659f1b1f 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "esModuleInterop": true, "lib": ["DOM", "DOM.Iterable", "ES2023"], - "outDir": "dist/" + "module": "NodeNext", + "outDir": "dist/", + "resolveJsonModule": true }, "include": ["./src/**/*"] } diff --git a/packages/core/package.json b/packages/core/package.json index 5d16e2bf..83d5d33f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@readme/api-core", - "version": "7.0.0-alpha.3", + "version": "7.0.0-alpha.5", "description": "The magic behind `api` 🧙", "sideEffects": false, "type": "module", @@ -49,7 +49,7 @@ "json-schema-traverse": "^1.0.0", "lodash.merge": "^4.6.2", "oas": "^23.0.0", - "remove-undefined-objects": "^4.0.2" + "remove-undefined-objects": "^5.0.0" }, "devDependencies": { "@api/test-utils": "file:../test-utils", diff --git a/packages/httpsnippet-client-api/package.json b/packages/httpsnippet-client-api/package.json index aa4ba649..dff02278 100644 --- a/packages/httpsnippet-client-api/package.json +++ b/packages/httpsnippet-client-api/package.json @@ -1,6 +1,6 @@ { "name": "httpsnippet-client-api", - "version": "7.0.0-alpha.2", + "version": "7.0.0-alpha.5", "description": "An HTTPSnippet client for generating snippets for the `api` module.", "sideEffects": false, "type": "module", diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 0fe14ba1..9ca1703f 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@api/test-utils", - "version": "7.0.0-alpha.2", + "version": "7.0.0-alpha.5", "scripts": { "lint:types": "tsc --noEmit" },