From 976c2d2b76fc70ab4d86757ee471953905d04d17 Mon Sep 17 00:00:00 2001 From: actions Date: Thu, 17 Oct 2024 15:02:12 +0000 Subject: [PATCH] Adding deno distribution files and moving files from /dist to / --- .github/workflows/ci.yaml | 161 -------- esm/src/axios/createAxiosSharedClient.d.ts | 6 + esm/src/axios/createAxiosSharedClient.mjs | 142 +++++++ esm/src/axios/createAxiosSharedClient.mjs.map | 1 + esm/src/axios/index.d.ts | 1 + esm/src/axios/index.mjs | 2 + esm/src/axios/index.mjs.map | 1 + esm/src/configureCreateHttpClient.d.ts | 26 ++ esm/src/configureCreateHttpClient.mjs | 21 + esm/src/configureCreateHttpClient.mjs.map | 1 + esm/src/createCustomSharedClient.d.ts | 3 + esm/src/createCustomSharedClient.mjs | 8 + esm/src/createCustomSharedClient.mjs.map | 1 + esm/src/defineRoutes.d.ts | 34 ++ esm/src/defineRoutes.mjs | 56 +++ esm/src/defineRoutes.mjs.map | 1 + .../express/createExpressSharedRouter.d.ts | 11 + esm/src/express/createExpressSharedRouter.mjs | 68 ++++ .../express/createExpressSharedRouter.mjs.map | 1 + esm/src/express/index.d.ts | 1 + esm/src/express/index.mjs | 2 + esm/src/express/index.mjs.map | 1 + esm/src/fetch/createFetchSharedClient.d.ts | 10 + esm/src/fetch/createFetchSharedClient.mjs | 195 +++++++++ esm/src/fetch/createFetchSharedClient.mjs.map | 1 + esm/src/fetch/index.d.ts | 1 + esm/src/fetch/index.mjs | 2 + esm/src/fetch/index.mjs.map | 1 + esm/src/fetch/queryParamsToString.d.ts | 8 + esm/src/fetch/queryParamsToString.mjs | 33 ++ esm/src/fetch/queryParamsToString.mjs.map | 1 + esm/src/index.d.ts | 7 + esm/src/index.mjs | 5 + esm/src/index.mjs.map | 1 + esm/src/openapi/createOpenApiGenerator.d.ts | 49 +++ esm/src/openapi/createOpenApiGenerator.mjs | 145 +++++++ .../openapi/createOpenApiGenerator.mjs.map | 1 + esm/src/openapi/index.d.ts | 1 + esm/src/openapi/index.mjs | 2 + esm/src/openapi/index.mjs.map | 1 + esm/src/pathParameters.d.ts | 19 + esm/src/pathParameters.mjs | 11 + esm/src/pathParameters.mjs.map | 1 + .../createSupertestSharedClient.d.ts | 5 + .../supertest/createSupertestSharedClient.mjs | 114 ++++++ .../createSupertestSharedClient.mjs.map | 1 + esm/src/supertest/index.d.ts | 1 + esm/src/supertest/index.mjs | 2 + esm/src/supertest/index.mjs.map | 1 + esm/src/validations.d.ts | 25 ++ esm/src/validations.mjs | 100 +++++ esm/src/validations.mjs.map | 1 + .../createAxiosAndFetchSharedClient.test.d.ts | 1 + .../createAxiosAndFetchSharedClient.test.mjs | 365 +++++++++++++++++ ...eateAxiosAndFetchSharedClient.test.mjs.map | 1 + esm/test/createCustomSharedClient.test.d.ts | 1 + esm/test/createCustomSharedClient.test.mjs | 129 ++++++ .../createCustomSharedClient.test.mjs.map | 1 + esm/test/createOpenApiGenerator.test.d.ts | 1 + esm/test/createOpenApiGenerator.test.mjs | 345 ++++++++++++++++ esm/test/createOpenApiGenerator.test.mjs.map | 1 + esm/test/defineRoutes.test.d.ts | 1 + esm/test/defineRoutes.test.mjs | 42 ++ esm/test/defineRoutes.test.mjs.map | 1 + esm/test/expressAndSupertest.test.d.ts | 1 + esm/test/expressAndSupertest.test.mjs | 289 ++++++++++++++ esm/test/expressAndSupertest.test.mjs.map | 1 + esm/tsconfig.esm.tsbuildinfo | 1 + package.json | 169 +++++++- src/axios/createAxiosSharedClient.d.ts | 6 + src/axios/createAxiosSharedClient.js | 147 +++++++ src/axios/createAxiosSharedClient.js.map | 1 + src/axios/index.d.ts | 1 + src/axios/index.js | 6 + src/axios/index.js.map | 1 + src/configureCreateHttpClient.d.ts | 26 ++ src/configureCreateHttpClient.js | 25 ++ src/configureCreateHttpClient.js.map | 1 + src/createCustomSharedClient.d.ts | 3 + src/createCustomSharedClient.js | 12 + src/createCustomSharedClient.js.map | 1 + src/defineRoutes.d.ts | 34 ++ src/defineRoutes.js | 62 +++ src/defineRoutes.js.map | 1 + src/express/createExpressSharedRouter.d.ts | 11 + src/express/createExpressSharedRouter.js | 72 ++++ src/express/createExpressSharedRouter.js.map | 1 + src/express/index.d.ts | 1 + src/express/index.js | 6 + src/express/index.js.map | 1 + src/fetch/createFetchSharedClient.d.ts | 10 + src/fetch/createFetchSharedClient.js | 200 ++++++++++ src/fetch/createFetchSharedClient.js.map | 1 + src/fetch/index.d.ts | 1 + src/fetch/index.js | 6 + src/fetch/index.js.map | 1 + src/fetch/queryParamsToString.d.ts | 8 + src/fetch/queryParamsToString.js | 37 ++ src/fetch/queryParamsToString.js.map | 1 + src/index.d.ts | 7 + src/index.js | 14 + src/index.js.map | 1 + src/openapi/createOpenApiGenerator.d.ts | 49 +++ src/openapi/createOpenApiGenerator.js | 149 +++++++ src/openapi/createOpenApiGenerator.js.map | 1 + src/openapi/index.d.ts | 1 + src/openapi/index.js | 6 + src/openapi/index.js.map | 1 + src/pathParameters.d.ts | 19 + src/pathParameters.js | 16 + src/pathParameters.js.map | 1 + .../createSupertestSharedClient.d.ts | 5 + src/supertest/createSupertestSharedClient.js | 119 ++++++ .../createSupertestSharedClient.js.map | 1 + src/supertest/index.d.ts | 1 + src/supertest/index.js | 6 + src/supertest/index.js.map | 1 + src/validations.d.ts | 25 ++ src/validations.js | 105 +++++ src/validations.js.map | 1 + .../createAxiosAndFetchSharedClient.test.d.ts | 1 + test/createAxiosAndFetchSharedClient.test.js | 370 ++++++++++++++++++ ...reateAxiosAndFetchSharedClient.test.js.map | 1 + test/createCustomSharedClient.test.d.ts | 1 + test/createCustomSharedClient.test.js | 131 +++++++ test/createCustomSharedClient.test.js.map | 1 + test/createOpenApiGenerator.test.d.ts | 1 + test/createOpenApiGenerator.test.js | 347 ++++++++++++++++ test/createOpenApiGenerator.test.js.map | 1 + test/defineRoutes.test.d.ts | 1 + test/defineRoutes.test.js | 44 +++ test/defineRoutes.test.js.map | 1 + test/expressAndSupertest.test.d.ts | 1 + test/expressAndSupertest.test.js | 294 ++++++++++++++ test/expressAndSupertest.test.js.map | 1 + tsconfig.tsbuildinfo | 1 + 136 files changed, 4874 insertions(+), 180 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 esm/src/axios/createAxiosSharedClient.d.ts create mode 100644 esm/src/axios/createAxiosSharedClient.mjs create mode 100644 esm/src/axios/createAxiosSharedClient.mjs.map create mode 100644 esm/src/axios/index.d.ts create mode 100644 esm/src/axios/index.mjs create mode 100644 esm/src/axios/index.mjs.map create mode 100644 esm/src/configureCreateHttpClient.d.ts create mode 100644 esm/src/configureCreateHttpClient.mjs create mode 100644 esm/src/configureCreateHttpClient.mjs.map create mode 100644 esm/src/createCustomSharedClient.d.ts create mode 100644 esm/src/createCustomSharedClient.mjs create mode 100644 esm/src/createCustomSharedClient.mjs.map create mode 100644 esm/src/defineRoutes.d.ts create mode 100644 esm/src/defineRoutes.mjs create mode 100644 esm/src/defineRoutes.mjs.map create mode 100644 esm/src/express/createExpressSharedRouter.d.ts create mode 100644 esm/src/express/createExpressSharedRouter.mjs create mode 100644 esm/src/express/createExpressSharedRouter.mjs.map create mode 100644 esm/src/express/index.d.ts create mode 100644 esm/src/express/index.mjs create mode 100644 esm/src/express/index.mjs.map create mode 100644 esm/src/fetch/createFetchSharedClient.d.ts create mode 100644 esm/src/fetch/createFetchSharedClient.mjs create mode 100644 esm/src/fetch/createFetchSharedClient.mjs.map create mode 100644 esm/src/fetch/index.d.ts create mode 100644 esm/src/fetch/index.mjs create mode 100644 esm/src/fetch/index.mjs.map create mode 100644 esm/src/fetch/queryParamsToString.d.ts create mode 100644 esm/src/fetch/queryParamsToString.mjs create mode 100644 esm/src/fetch/queryParamsToString.mjs.map create mode 100644 esm/src/index.d.ts create mode 100644 esm/src/index.mjs create mode 100644 esm/src/index.mjs.map create mode 100644 esm/src/openapi/createOpenApiGenerator.d.ts create mode 100644 esm/src/openapi/createOpenApiGenerator.mjs create mode 100644 esm/src/openapi/createOpenApiGenerator.mjs.map create mode 100644 esm/src/openapi/index.d.ts create mode 100644 esm/src/openapi/index.mjs create mode 100644 esm/src/openapi/index.mjs.map create mode 100644 esm/src/pathParameters.d.ts create mode 100644 esm/src/pathParameters.mjs create mode 100644 esm/src/pathParameters.mjs.map create mode 100644 esm/src/supertest/createSupertestSharedClient.d.ts create mode 100644 esm/src/supertest/createSupertestSharedClient.mjs create mode 100644 esm/src/supertest/createSupertestSharedClient.mjs.map create mode 100644 esm/src/supertest/index.d.ts create mode 100644 esm/src/supertest/index.mjs create mode 100644 esm/src/supertest/index.mjs.map create mode 100644 esm/src/validations.d.ts create mode 100644 esm/src/validations.mjs create mode 100644 esm/src/validations.mjs.map create mode 100644 esm/test/createAxiosAndFetchSharedClient.test.d.ts create mode 100644 esm/test/createAxiosAndFetchSharedClient.test.mjs create mode 100644 esm/test/createAxiosAndFetchSharedClient.test.mjs.map create mode 100644 esm/test/createCustomSharedClient.test.d.ts create mode 100644 esm/test/createCustomSharedClient.test.mjs create mode 100644 esm/test/createCustomSharedClient.test.mjs.map create mode 100644 esm/test/createOpenApiGenerator.test.d.ts create mode 100644 esm/test/createOpenApiGenerator.test.mjs create mode 100644 esm/test/createOpenApiGenerator.test.mjs.map create mode 100644 esm/test/defineRoutes.test.d.ts create mode 100644 esm/test/defineRoutes.test.mjs create mode 100644 esm/test/defineRoutes.test.mjs.map create mode 100644 esm/test/expressAndSupertest.test.d.ts create mode 100644 esm/test/expressAndSupertest.test.mjs create mode 100644 esm/test/expressAndSupertest.test.mjs.map create mode 100644 esm/tsconfig.esm.tsbuildinfo create mode 100644 src/axios/createAxiosSharedClient.d.ts create mode 100644 src/axios/createAxiosSharedClient.js create mode 100644 src/axios/createAxiosSharedClient.js.map create mode 100644 src/axios/index.d.ts create mode 100644 src/axios/index.js create mode 100644 src/axios/index.js.map create mode 100644 src/configureCreateHttpClient.d.ts create mode 100644 src/configureCreateHttpClient.js create mode 100644 src/configureCreateHttpClient.js.map create mode 100644 src/createCustomSharedClient.d.ts create mode 100644 src/createCustomSharedClient.js create mode 100644 src/createCustomSharedClient.js.map create mode 100644 src/defineRoutes.d.ts create mode 100644 src/defineRoutes.js create mode 100644 src/defineRoutes.js.map create mode 100644 src/express/createExpressSharedRouter.d.ts create mode 100644 src/express/createExpressSharedRouter.js create mode 100644 src/express/createExpressSharedRouter.js.map create mode 100644 src/express/index.d.ts create mode 100644 src/express/index.js create mode 100644 src/express/index.js.map create mode 100644 src/fetch/createFetchSharedClient.d.ts create mode 100644 src/fetch/createFetchSharedClient.js create mode 100644 src/fetch/createFetchSharedClient.js.map create mode 100644 src/fetch/index.d.ts create mode 100644 src/fetch/index.js create mode 100644 src/fetch/index.js.map create mode 100644 src/fetch/queryParamsToString.d.ts create mode 100644 src/fetch/queryParamsToString.js create mode 100644 src/fetch/queryParamsToString.js.map create mode 100644 src/index.d.ts create mode 100644 src/index.js create mode 100644 src/index.js.map create mode 100644 src/openapi/createOpenApiGenerator.d.ts create mode 100644 src/openapi/createOpenApiGenerator.js create mode 100644 src/openapi/createOpenApiGenerator.js.map create mode 100644 src/openapi/index.d.ts create mode 100644 src/openapi/index.js create mode 100644 src/openapi/index.js.map create mode 100644 src/pathParameters.d.ts create mode 100644 src/pathParameters.js create mode 100644 src/pathParameters.js.map create mode 100644 src/supertest/createSupertestSharedClient.d.ts create mode 100644 src/supertest/createSupertestSharedClient.js create mode 100644 src/supertest/createSupertestSharedClient.js.map create mode 100644 src/supertest/index.d.ts create mode 100644 src/supertest/index.js create mode 100644 src/supertest/index.js.map create mode 100644 src/validations.d.ts create mode 100644 src/validations.js create mode 100644 src/validations.js.map create mode 100644 test/createAxiosAndFetchSharedClient.test.d.ts create mode 100644 test/createAxiosAndFetchSharedClient.test.js create mode 100644 test/createAxiosAndFetchSharedClient.test.js.map create mode 100644 test/createCustomSharedClient.test.d.ts create mode 100644 test/createCustomSharedClient.test.js create mode 100644 test/createCustomSharedClient.test.js.map create mode 100644 test/createOpenApiGenerator.test.d.ts create mode 100644 test/createOpenApiGenerator.test.js create mode 100644 test/createOpenApiGenerator.test.js.map create mode 100644 test/defineRoutes.test.d.ts create mode 100644 test/defineRoutes.test.js create mode 100644 test/defineRoutes.test.js.map create mode 100644 test/expressAndSupertest.test.d.ts create mode 100644 test/expressAndSupertest.test.js create mode 100644 test/expressAndSupertest.test.js.map create mode 100644 tsconfig.tsbuildinfo diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 33fbb72..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,161 +0,0 @@ -name: ci -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - - test_node: - runs-on: ${{ matrix.os }} - strategy: - matrix: - node: [ '20' ] - os: [ ubuntu-latest ] - name: Test with Node v${{ matrix.node }} on ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 9 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - cache: 'pnpm' - - run: pnpm install --frozen-lockfile - - run: pnpm build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: pnpm test - - test_deno: - runs-on: ubuntu-latest - name: test with Deno - steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 9 - - uses: actions/setup-node@v3 - with: - node-version: '20' - cache: 'pnpm' - - name: Cache - uses: actions/cache@v3 - with: - path: ~/.cache/deno - key: deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - restore-keys: | - deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} - deno-${{ runner.os }}- - deno- - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - run: deno --version - - run: pnpm install --frozen-lockfile - - run: pnpm build:deno - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: deno run --unstable --reload --allow-read --allow-env --allow-net deno_dist/mod.ts - - check_if_version_upgraded: - name: Check if version upgrade - # We run this only if it's a push on the default branch or if it's a PR from a - # branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is - # defined but GitHub Action don't allow it yet. - if: | - github.event_name == 'push' || - github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login - runs-on: ubuntu-latest - needs: - - test_node -# - test_deno - outputs: - from_version: ${{ steps.step1.outputs.from_version }} - to_version: ${{ steps.step1.outputs.to_version }} - is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} - is_pre_release: ${{steps.step1.outputs.is_pre_release }} - steps: - - uses: garronej/ts-ci@v2.1.0 - id: step1 - with: - action_name: is_package_json_version_upgraded - branch: ${{ github.head_ref || github.ref }} - - publish: - runs-on: ubuntu-latest - needs: - - check_if_version_upgraded - # We create a release only if the version have been upgraded and we are on the main branch - # or if we are on a branch of the repo that has an PR open on main. - if: | - needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && - ( - github.event_name == 'push' || - needs.check_if_version_upgraded.outputs.is_pre_release == 'true' - ) - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.ref }} - - uses: pnpm/action-setup@v2 - with: - version: 9 - - run: rm -r .github - - name: Remove tmp_branch if it exists - run: git push origin :tmp_branch || true - - run: git checkout -b tmp_branch - - uses: actions/setup-node@v3 - with: - registry-url: https://registry.npmjs.org/ - cache: 'pnpm' - - run: pnpm install --frozen-lockfile - - run: pnpm build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: | - npx -y -p denoify@1.4.8 enable_short_npm_import_path - npx -y -p denoify@1.4.8 remove_deno_dist_from_gitignore - env: - DRY_RUN: "0" - - run: | - if [ "$(npm show . version)" = "$VERSION" ]; then - echo "This version is already published" - exit 0 - fi - if [ "$NODE_AUTH_TOKEN" = "" ]; then - echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" - false - fi - EXTRA_ARGS="" - if [ "$IS_PRE_RELEASE" = "true" ]; then - EXTRA_ARGS="--tag next" - fi - npm publish $EXTRA_ARGS - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} - IS_PRE_RELEASE: ${{ needs.check_if_version_upgraded.outputs.is_pre_release }} - - run: | - git config --global user.name "actions" - git config --global user.email actions@github.com - git add -A - git commit -am "Adding deno distribution files and moving files from /dist to /" - git push origin tmp_branch - - uses: softprops/action-gh-release@v1 - with: - name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} - tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} - target_commitish: tmp_branch - generate_release_notes: false - draft: false - prerelease: ${{ needs.check_if_version_upgraded.outputs.is_pre_release == 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Remove tmp_branch - run: git push origin :tmp_branch \ No newline at end of file diff --git a/esm/src/axios/createAxiosSharedClient.d.ts b/esm/src/axios/createAxiosSharedClient.d.ts new file mode 100644 index 0000000..5dcc408 --- /dev/null +++ b/esm/src/axios/createAxiosSharedClient.d.ts @@ -0,0 +1,6 @@ +import type { AxiosInstance } from "axios"; +import type { UnknownSharedRoute } from "../index.mjs"; +import { HandlerCreator } from "../index.mjs"; +import { ValidationOptions } from "../validations.mjs"; +export declare const createAxiosHandlerCreator: >(axios: AxiosInstance, options?: ValidationOptions) => HandlerCreator; +export declare const createAxiosSharedClient: >(sharedRouters: SharedRoutes, axios: AxiosInstance, validationOptions?: ValidationOptions) => import("../index.mjs").HttpClient; diff --git a/esm/src/axios/createAxiosSharedClient.mjs b/esm/src/axios/createAxiosSharedClient.mjs new file mode 100644 index 0000000..4666172 --- /dev/null +++ b/esm/src/axios/createAxiosSharedClient.mjs @@ -0,0 +1,142 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +import { configureCreateHttpClient } from "../index.mjs"; +import { validateInputParams, validateSchemaWithExplicitError, } from "../validations.mjs"; +var toAxiosResponseType = { + arrayBuffer: "arraybuffer", + blob: "blob", + json: "json", + text: "text", +}; +export var createAxiosHandlerCreator = function (axios, options) { + return function (routeName, routes, replaceParamsInUrl) { + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var route, _b, body, headers, queryParams, _c, data, status, rest, responseBody; + var _d; + if (_a === void 0) { _a = {}; } + var urlParams = _a.urlParams, params = __rest(_a, ["urlParams"]); + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + route = routes[routeName]; + _b = (options === null || options === void 0 ? void 0 : options.skipInputValidation) + ? params + : validateInputParams(route, params, "axios", { withIssuesInMessage: true }), body = _b.body, headers = _b.headers, queryParams = _b.queryParams; + return [4 /*yield*/, axios.request({ + method: route.method, + url: replaceParamsInUrl(route.url, urlParams), + data: body, + params: queryParams, + responseType: toAxiosResponseType[route.responseType], + headers: __assign(__assign({}, axios.defaults.headers), (headers !== null && headers !== void 0 ? headers : {})), + })]; + case 1: + _c = _e.sent(), data = _c.data, status = _c.status, rest = __rest(_c, ["data", "status"]); + responseBody = (options === null || options === void 0 ? void 0 : options.skipResponseValidation) || + ((_d = options === null || options === void 0 ? void 0 : options.skipResponseValidationForStatuses) === null || _d === void 0 ? void 0 : _d.includes(status)) + ? data + : validateSchemaWithExplicitError({ + adapterName: "axios", + checkedSchema: "responses", + responseStatus: status, + params: data, + route: route, + withIssuesInMessage: true, + }); + return [2 /*return*/, __assign(__assign({}, rest), { status: status, body: responseBody })]; + } + }); + }); + }; + }; +}; +export var createAxiosSharedClient = function (sharedRouters, axios, validationOptions) { + return configureCreateHttpClient(createAxiosHandlerCreator(axios, validationOptions))(sharedRouters); +}; +//# sourceMappingURL=createAxiosSharedClient.mjs.map \ No newline at end of file diff --git a/esm/src/axios/createAxiosSharedClient.mjs.map b/esm/src/axios/createAxiosSharedClient.mjs.map new file mode 100644 index 0000000..3b720ec --- /dev/null +++ b/esm/src/axios/createAxiosSharedClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createAxiosSharedClient.mjs","sourceRoot":"","sources":["../../../src/axios/createAxiosSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,yBAAyB,EAAkB,MAAM,IAAI,CAAC;AAE/D,OAAO,EAEL,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAExB,IAAM,mBAAmB,GAA4C;IACnE,WAAW,EAAE,aAAa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P,OAAO,CAAE,iCAAiC,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;gCAC1D,CAAC,CAAC,IAAI;gCACN,CAAC,CAAC,+BAA+B,CAAC;oCAC9B,WAAW,EAAE,OAAO;oCACpB,aAAa,EAAE,WAAW;oCAC1B,cAAc,EAAE,MAAa;oCAC7B,MAAM,EAAE,IAAI;oCACZ,KAAK,OAAA;oCACL,mBAAmB,EAAE,IAAI;iCAC1B,CAAC,CAAC;4BAET,4CAAY,IAAI,KAAE,MAAM,QAAA,EAAE,IAAI,EAAE,YAAY,KAAG;;;;SAChD;IAjCD,CAiCC;AAlCD,CAkCC,CAAC;AAEJ,MAAM,CAAC,IAAM,uBAAuB,GAAG,UAGrC,aAA2B,EAC3B,KAAoB,EACpB,iBAAqC;IAErC,OAAA,yBAAyB,CAAC,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAC5E,aAAa,CACd;AAFD,CAEC,CAAC"} \ No newline at end of file diff --git a/esm/src/axios/index.d.ts b/esm/src/axios/index.d.ts new file mode 100644 index 0000000..293b236 --- /dev/null +++ b/esm/src/axios/index.d.ts @@ -0,0 +1 @@ +export { createAxiosSharedClient } from "./createAxiosSharedClient.mjs"; diff --git a/esm/src/axios/index.mjs b/esm/src/axios/index.mjs new file mode 100644 index 0000000..399f9b7 --- /dev/null +++ b/esm/src/axios/index.mjs @@ -0,0 +1,2 @@ +export { createAxiosSharedClient } from "./createAxiosSharedClient.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/axios/index.mjs.map b/esm/src/axios/index.mjs.map new file mode 100644 index 0000000..6390794 --- /dev/null +++ b/esm/src/axios/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/axios/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"} \ No newline at end of file diff --git a/esm/src/configureCreateHttpClient.d.ts b/esm/src/configureCreateHttpClient.d.ts new file mode 100644 index 0000000..0d665e4 --- /dev/null +++ b/esm/src/configureCreateHttpClient.d.ts @@ -0,0 +1,26 @@ +import { z } from "zod"; +import type { ResponsesToHttpResponse, SharedRoute, UnknownResponses, UnknownSharedRoute } from "./defineRoutes.mjs"; +import { PathParameters, ReplaceParamsInUrl, Url } from "./pathParameters.mjs"; +type EmptyObj = Record; +type AnyObj = Record; +export type HttpResponse = { + status: Status; + body: ResponseBody; + headers: Record; +}; +export type HandlerParams = (PathParameters extends EmptyObj ? AnyObj : { + urlParams: PathParameters; +}) & (z.infer extends void ? AnyObj : { + body: z.infer; +}) & (z.infer extends void ? AnyObj : { + queryParams: z.infer; +}) & (z.infer extends void ? AnyObj : { + headers: z.infer; +}); +export type Handler = (params: HandlerParams | EmptyObj) => Promise>; +export type HttpClient> = { + [RouteName in keyof SharedRoutes]: (...params: [SharedRoutes[RouteName], PathParameters] extends [SharedRoute, EmptyObj] ? [] : [HandlerParams]) => Promise>; +}; +export type HandlerCreator> = (routeName: R, routes: SharedRoutes, replaceParamsInUrl: ReplaceParamsInUrl) => Handler; +export declare const configureCreateHttpClient: >(handlerCreator: HandlerCreator) => >(routes: SharedRoutes) => HttpClient; +export {}; diff --git a/esm/src/configureCreateHttpClient.mjs b/esm/src/configureCreateHttpClient.mjs new file mode 100644 index 0000000..4cdb348 --- /dev/null +++ b/esm/src/configureCreateHttpClient.mjs @@ -0,0 +1,21 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +import { replaceParamsInUrl, keys, } from "./pathParameters.mjs"; +export var configureCreateHttpClient = function (handlerCreator) { + return function (routes) { + return keys(routes).reduce(function (acc, routeName) { + var _a; + return (__assign(__assign({}, acc), (_a = {}, _a[routeName] = handlerCreator(routeName, routes, replaceParamsInUrl), _a))); + }, {}); + }; +}; +//# sourceMappingURL=configureCreateHttpClient.mjs.map \ No newline at end of file diff --git a/esm/src/configureCreateHttpClient.mjs.map b/esm/src/configureCreateHttpClient.mjs.map new file mode 100644 index 0000000..2f3210d --- /dev/null +++ b/esm/src/configureCreateHttpClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"configureCreateHttpClient.mjs","sourceRoot":"","sources":["../../src/configureCreateHttpClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAOA,OAAO,EAEL,kBAAkB,EAElB,IAAI,GAEL,MAAM,kBAAkB,CAAC;AAuC1B,MAAM,CAAC,IAAM,yBAAyB,GACpC,UAA+C,cAAiC;IAChF,OAAA,UACE,MAAoB;QAEpB,OAAA,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CACjB,UAAC,GAAG,EAAE,SAAS;;YAAK,OAAA,uBACf,GAAG,gBACL,SAAS,IAAG,cAAc,CACzB,SAAmB,EACnB,MAAsB,EACtB,kBAAkB,CACnB,OACD;QAPkB,CAOlB,EACF,EAA8B,CAC/B;IAVD,CAUC;AAbH,CAaG,CAAC"} \ No newline at end of file diff --git a/esm/src/createCustomSharedClient.d.ts b/esm/src/createCustomSharedClient.d.ts new file mode 100644 index 0000000..4aa2f43 --- /dev/null +++ b/esm/src/createCustomSharedClient.d.ts @@ -0,0 +1,3 @@ +import { Handler, HttpClient } from "./configureCreateHttpClient.mjs"; +import { UnknownSharedRoute } from "./defineRoutes.mjs"; +export declare const createCustomSharedClient: >(sharedRoutes: SharedRoutes, customHandlers: { [K in keyof SharedRoutes]: Handler; }) => HttpClient; diff --git a/esm/src/createCustomSharedClient.mjs b/esm/src/createCustomSharedClient.mjs new file mode 100644 index 0000000..036ec45 --- /dev/null +++ b/esm/src/createCustomSharedClient.mjs @@ -0,0 +1,8 @@ +import { configureCreateHttpClient } from "./configureCreateHttpClient.mjs"; +export var createCustomSharedClient = function (sharedRoutes, customHandlers) { + var createHttpClient = configureCreateHttpClient(function (routeName) { + return customHandlers[routeName]; + }); + return createHttpClient(sharedRoutes); +}; +//# sourceMappingURL=createCustomSharedClient.mjs.map \ No newline at end of file diff --git a/esm/src/createCustomSharedClient.mjs.map b/esm/src/createCustomSharedClient.mjs.map new file mode 100644 index 0000000..51e3aac --- /dev/null +++ b/esm/src/createCustomSharedClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createCustomSharedClient.mjs","sourceRoot":"","sources":["../../src/createCustomSharedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAIxE,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAGtC,YAA0B,EAC1B,cAEC;IAED,IAAM,gBAAgB,GAAG,yBAAyB,CAAC,UAAC,SAAS;QAC3D,OAAO,cAAc,CAAC,SAAS,CAAQ,CAAC;IAC1C,CAAC,CAAQ,CAAC;IAEV,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/src/defineRoutes.d.ts b/esm/src/defineRoutes.d.ts new file mode 100644 index 0000000..653bdf0 --- /dev/null +++ b/esm/src/defineRoutes.d.ts @@ -0,0 +1,34 @@ +import { z, ZodVoid } from "zod"; +import { HttpResponse } from "./configureCreateHttpClient.mjs"; +import type { Url } from "./pathParameters.mjs"; +export type UnknownResponses = { + [K: number]: z.ZodSchema; +}; +export type ValueOf = T[keyof T]; +export type ValueOfIndexNumber> = T[keyof T & number]; +export type ResponsesToHttpResponse = ValueOf<{ + [K in keyof Responses & number]: HttpResponse>; +}>; +export type ResponseType = "json" | "arrayBuffer" | "blob" | "text"; +type OptionalFields = { + requestBodySchema?: z.Schema; + queryParamsSchema?: z.Schema; + responses?: Responses; + headersSchema?: z.Schema; + responseType?: ResponseType; +}; +export type HttpMethod = "get" | "post" | "put" | "patch" | "delete"; +type MethodAndUrl = { + method: HttpMethod; + url: U; +}; +type SharedRouteWithOptional = MethodAndUrl & OptionalFields; +export type SharedRoute = MethodAndUrl & Required>; +export type UnknownSharedRoute = SharedRoute; +export type UnknownSharedRouteWithUrl = SharedRoute; +export declare const defineRoute: (route: SharedRouteWithOptional) => SharedRoute; +export declare const defineRoutes: >(routes: { [K in keyof T]: T[K]; }) => { [K in keyof T]: T[K]; }; +export declare const listRoutes: >(routes: { [K in keyof T]: T[K]; }) => string[]; +export {}; diff --git a/esm/src/defineRoutes.mjs b/esm/src/defineRoutes.mjs new file mode 100644 index 0000000..aaf2e9b --- /dev/null +++ b/esm/src/defineRoutes.mjs @@ -0,0 +1,56 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +import { z } from "zod"; +export var defineRoute = function (route) { + var _a; + return (__assign(__assign({ requestBodySchema: z.object({}).strict(), queryParamsSchema: z.object({}).strict(), responses: { 201: z.void().or(z.string().max(0)) }, headersSchema: z.object({}) }, route), { responseType: (_a = route.responseType) !== null && _a !== void 0 ? _a : "json" })); +}; +var verifyRoutesUniqAndListRoutes = function (routes) { + var e_1, _a; + var _b; + var occurrencesByMethodAndUrl = {}; + try { + for (var _c = __values(Object.values(routes)), _d = _c.next(); !_d.done; _d = _c.next()) { + var route = _d.value; + var name_1 = "".concat(route.method.toUpperCase(), " ").concat(route.url); + var occurrence = ((_b = occurrencesByMethodAndUrl[name_1]) !== null && _b !== void 0 ? _b : 0) + 1; + if (occurrence > 1) + throw new Error("You cannot have several routes with same http method and url, got: ".concat(name_1, " twice (at least)")); + occurrencesByMethodAndUrl[name_1] = occurrence; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return Object.keys(occurrencesByMethodAndUrl); +}; +export var defineRoutes = function (routes) { + verifyRoutesUniqAndListRoutes(routes); + return routes; +}; +export var listRoutes = function (routes) { return verifyRoutesUniqAndListRoutes(routes); }; +//# sourceMappingURL=defineRoutes.mjs.map \ No newline at end of file diff --git a/esm/src/defineRoutes.mjs.map b/esm/src/defineRoutes.mjs.map new file mode 100644 index 0000000..3763853 --- /dev/null +++ b/esm/src/defineRoutes.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"defineRoutes.mjs","sourceRoot":"","sources":["../../src/defineRoutes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAW,MAAM,KAAK,CAAC;AA6DjC,MAAM,CAAC,IAAM,WAAW,GAAG,UAOzB,KAAyE;;IACd,OAAA,qBAC3D,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAS,EAC/C,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAS,EAC/C,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAS,EACzD,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAQ,IAC/B,KAAK,KACR,YAAY,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,MAAM,IAC1C,CAAA;CAAA,CAAC;AAEH,IAAM,6BAA6B,GAAG,UACpC,MAEC;;;IAED,IAAM,yBAAyB,GAA2B,EAAE,CAAC;;QAE7D,KAAoB,IAAA,KAAA,SAAA,MAAM,CAAC,MAAM,CAAC,MAAM,CAAyB,CAAA,gBAAA,4BAAE,CAAC;YAA/D,IAAM,KAAK,WAAA;YACd,IAAM,MAAI,GAAG,UAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,cAAI,KAAK,CAAC,GAAG,CAAE,CAAC;YAC1D,IAAM,UAAU,GAAG,CAAC,MAAA,yBAAyB,CAAC,MAAI,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC9D,IAAI,UAAU,GAAG,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,6EAAsE,MAAI,sBAAmB,CAC9F,CAAC;YACJ,yBAAyB,CAAC,MAAI,CAAC,GAAG,UAAU,CAAC;QAC/C,CAAC;;;;;;;;;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,YAAY,GAAG,UAC1B,MAEC;IAED,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AACF,MAAM,CAAC,IAAM,UAAU,GAAG,UACxB,MAEC,IACY,OAAA,6BAA6B,CAAC,MAAM,CAAC,EAArC,CAAqC,CAAC"} \ No newline at end of file diff --git a/esm/src/express/createExpressSharedRouter.d.ts b/esm/src/express/createExpressSharedRouter.d.ts new file mode 100644 index 0000000..96392b5 --- /dev/null +++ b/esm/src/express/createExpressSharedRouter.d.ts @@ -0,0 +1,11 @@ +import type { IRoute, RequestHandler, Router } from "express"; +import type { PathParameters, UnknownSharedRoute } from "../index.mjs"; +import { z } from "zod"; +import { ValidationOptions } from "../validations.mjs"; +import { ValueOfIndexNumber } from "../defineRoutes.mjs"; +type ExpressSharedRouterOptions = Pick; +interface ParsedQs { + [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[]; +} +export declare const createExpressSharedRouter: , ExpressSharedRouter extends { [Route in keyof SharedRoutes & string]: (...handlers: RequestHandler, z.infer>, z.infer, z.infer extends void ? ParsedQs : z.infer, any>[]) => IRoute; }>(sharedRoutes: SharedRoutes, expressRouter: Router, options?: ExpressSharedRouterOptions) => ExpressSharedRouter; +export {}; diff --git a/esm/src/express/createExpressSharedRouter.mjs b/esm/src/express/createExpressSharedRouter.mjs new file mode 100644 index 0000000..c5bd7b7 --- /dev/null +++ b/esm/src/express/createExpressSharedRouter.mjs @@ -0,0 +1,68 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +import { keys } from "../index.mjs"; +import { validateInputParams } from "../validations.mjs"; +var makeValidationMiddleware = function (route, options) { + return function (req, res, next) { + try { + if (!options.skipInputValidation) { + var validatedParams = validateInputParams(route, { body: req.body, headers: req.headers, queryParams: req.query }, "express"); + req.body = validatedParams.body; + req.query = validatedParams.queryParams; + req.headers = validatedParams.headers; + } + next(); + } + catch (error) { + var zodError = error.cause; + res.status(400); + res.json({ + status: 400, + message: error.message, + issues: Array.from(new Set(zodIssuesToStrings(zodError.issues))), + }); + } + }; +}; +var zodIssuesToStrings = function (zodIssues) { + return zodIssues.flatMap(function (zodIssue) { + if (zodIssue.code === "invalid_union") { + return zodIssue.unionErrors.flatMap(function (_a) { + var issues = _a.issues; + return zodIssuesToStrings(issues); + }); + } + var message = zodIssue.message, path = zodIssue.path; + return "".concat(path.join("."), " : ").concat(message); + }); +}; +var assignHandlersToExpressRouter = function (expressRouter, route, options) { + if (options === void 0) { options = {}; } + var validationMiddleware = makeValidationMiddleware(route, options); + var url = route.url; + return function () { + var handlers = []; + for (var _i = 0; _i < arguments.length; _i++) { + handlers[_i] = arguments[_i]; + } + return expressRouter.route(url)[route.method](validationMiddleware, handlers); + }; +}; +export var createExpressSharedRouter = function (sharedRoutes, expressRouter, options) { + var expressSharedRouter = keys(sharedRoutes).reduce(function (acc, routeName) { + var _a; + var route = sharedRoutes[routeName]; + return __assign(__assign({}, acc), (_a = {}, _a[routeName] = assignHandlersToExpressRouter(expressRouter, route, options), _a)); + }, {}); + return expressSharedRouter; +}; +//# sourceMappingURL=createExpressSharedRouter.mjs.map \ No newline at end of file diff --git a/esm/src/express/createExpressSharedRouter.mjs.map b/esm/src/express/createExpressSharedRouter.mjs.map new file mode 100644 index 0000000..5af35d4 --- /dev/null +++ b/esm/src/express/createExpressSharedRouter.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createExpressSharedRouter.mjs","sourceRoot":"","sources":["../../../src/express/createExpressSharedRouter.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,OAAO,EAAqB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKxE,IAAM,wBAAwB,GAC5B,UAAC,KAAyB,EAAE,OAAmC;IAC/D,OAAA,UAAC,GAAG,EAAE,GAAG,EAAE,IAAI;QACb,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;gBACjC,IAAM,eAAe,GAAG,mBAAmB,CACzC,KAAK,EACL,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,KAAK,EAAE,EAChE,SAAS,CACV,CAAC;gBACF,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;gBAChC,GAAG,CAAC,KAAK,GAAG,eAAe,CAAC,WAAkB,CAAC;gBAC/C,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC,OAAc,CAAC;YAC/C,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAM,QAAQ,GAAG,KAAK,CAAC,KAAiB,CAAC;YACzC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;Y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AAC,IAAM,yBAAyB,GAAG,UAgBvC,YAA0B,EAC1B,aAAqB,EACrB,OAAoC;IAEpC,IAAM,mBAAmB,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,SAAS;;QACnE,IAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QACtC,6BACK,GAAG,gBACL,SAAS,IAAG,6BAA6B,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,OACzE;IACJ,CAAC,EAAE,EAAyB,CAAC,CAAC;IAE9B,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/src/express/index.d.ts b/esm/src/express/index.d.ts new file mode 100644 index 0000000..d924974 --- /dev/null +++ b/esm/src/express/index.d.ts @@ -0,0 +1 @@ +export { createExpressSharedRouter } from "./createExpressSharedRouter.mjs"; diff --git a/esm/src/express/index.mjs b/esm/src/express/index.mjs new file mode 100644 index 0000000..883a08b --- /dev/null +++ b/esm/src/express/index.mjs @@ -0,0 +1,2 @@ +export { createExpressSharedRouter } from "./createExpressSharedRouter.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/express/index.mjs.map b/esm/src/express/index.mjs.map new file mode 100644 index 0000000..8a3426d --- /dev/null +++ b/esm/src/express/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"} \ No newline at end of file diff --git a/esm/src/fetch/createFetchSharedClient.d.ts b/esm/src/fetch/createFetchSharedClient.d.ts new file mode 100644 index 0000000..4f0f73b --- /dev/null +++ b/esm/src/fetch/createFetchSharedClient.d.ts @@ -0,0 +1,10 @@ +import type { UnknownSharedRoute, Url } from "../index.mjs"; +import { HandlerCreator } from "../index.mjs"; +import { ValidationOptions } from "../validations.mjs"; +type Fetch = typeof fetch; +type FetchConfig = RequestInit & { + baseURL?: Url; +} & ValidationOptions; +export declare const createFetchHandlerCreator: >(fetch: Fetch, options?: FetchConfig) => HandlerCreator; +export declare const createFetchSharedClient: >(sharedRouters: SharedRoutes, fetch: Fetch, config?: FetchConfig) => import("../index.mjs").HttpClient; +export {}; diff --git a/esm/src/fetch/createFetchSharedClient.mjs b/esm/src/fetch/createFetchSharedClient.mjs new file mode 100644 index 0000000..abbf69d --- /dev/null +++ b/esm/src/fetch/createFetchSharedClient.mjs @@ -0,0 +1,195 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +import { configureCreateHttpClient } from "../index.mjs"; +import { queryParamsToString } from "./queryParamsToString.mjs"; +import { validateInputParams, validateSchemaWithExplicitError, } from "../validations.mjs"; +var objectFromEntries = function (entries) { + var e_1, _a; + var result = {}; + try { + for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { + var _b = __read(entries_1_1.value, 2), key = _b[0], value = _b[1]; + result[key] = value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); + } + finally { if (e_1) throw e_1.error; } + } + return result; +}; +export var createFetchHandlerCreator = function (fetch, options) { + if (options === void 0) { options = {}; } + return function (routeName, routes, replaceParamsInUrl) { + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var route, _b, body, headers, queryParams, bodyAsString, stringQueryParams, baseURL, defaultInit, res, processedBody, responseBody; + var _c; + if (_a === void 0) { _a = {}; } + var urlParams = _a.urlParams, params = __rest(_a, ["urlParams"]); + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + route = routes[routeName]; + _b = options.skipInputValidation + ? params + : validateInputParams(route, params, "fetch", { withIssuesInMessage: true }), body = _b.body, headers = _b.headers, queryParams = _b.queryParams; + bodyAsString = JSON.stringify(body); + stringQueryParams = queryParams && Object.keys(queryParams).length > 0 + ? "?" + queryParamsToString(queryParams) + : ""; + baseURL = options.baseURL, defaultInit = __rest(options, ["baseURL"]); + return [4 /*yield*/, fetch((baseURL ? baseURL : "") + + replaceParamsInUrl(route.url, urlParams) + + stringQueryParams, __assign(__assign(__assign(__assign({}, defaultInit), { method: route.method }), (bodyAsString !== "{}" ? { body: bodyAsString } : {})), { headers: __assign(__assign({ "Content-Type": "application/json" }, defaultInit === null || defaultInit === void 0 ? void 0 : defaultInit.headers), (headers !== null && headers !== void 0 ? headers : {})) }))]; + case 1: + res = _d.sent(); + return [4 /*yield*/, responseTypeToResponseBody(res, route.responseType)]; + case 2: + processedBody = _d.sent(); + responseBody = (options === null || options === void 0 ? void 0 : options.skipResponseValidation) || + ((_c = options === null || options === void 0 ? void 0 : options.skipResponseValidationForStatuses) === null || _c === void 0 ? void 0 : _c.includes(res.status)) + ? processedBody + : validateSchemaWithExplicitError({ + adapterName: "fetch", + checkedSchema: "responses", + responseStatus: res.status, + params: processedBody, + route: route, + withIssuesInMessage: true, + }); + console.log({ + "res.headers": res.headers, + "res.headers.entries()": res.headers.entries(), + }); + return [2 /*return*/, { + body: responseBody, + status: res.status, + headers: objectFromEntries(res.headers.entries()), + }]; + } + }); + }); + }; + }; +}; +var responseTypeToResponseBody = function (res, responseType) { + switch (responseType) { + case "json": + return res.json(); + case "text": + return res.text(); + case "blob": + return res.blob(); + case "arrayBuffer": + return res.arrayBuffer(); + default: { + var exhaustiveCheck = responseType; + return exhaustiveCheck; + } + } +}; +export var createFetchSharedClient = function (sharedRouters, fetch, config) { + if (config === void 0) { config = {}; } + return configureCreateHttpClient(createFetchHandlerCreator(fetch, config))(sharedRouters); +}; +//# sourceMappingURL=createFetchSharedClient.mjs.map \ No newline at end of file diff --git a/esm/src/fetch/createFetchSharedClient.mjs.map b/esm/src/fetch/createFetchSharedClient.mjs.map new file mode 100644 index 0000000..38c4d95 --- /dev/null +++ b/esm/src/fetch/createFetchSharedClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createFetchSharedClient.mjs","sourceRoot":"","sources":["../../../src/fetch/createFetchSharedClient.ts"],"names":[],"mappings":";;;;;;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,OAAA;oCACL,mBAAmB,EAAE,IAAI;iCAC1B,CAAC,CAAC;4BAET,OAAO,CAAC,GAAG,CAAC;gCACV,aAAa,EAAE,GAAG,CAAC,OAAO;gCAC1B,uBAAuB,EAAG,GAAG,CAAC,OAAe,CAAC,OAAO,EAAE;6BACxD,CAAC,CAAC;4BAEH,sBAAO;oCACL,IAAI,EAAE,YAAY;oCAClB,MAAM,EAAE,GAAG,CAAC,MAAM;oCAClB,OAAO,EAAE,iBAAiB,CAAE,GAAG,CAAC,OAAe,CAAC,OAAO,EAAE,CAAC;iCAC3D,EAAC;;;;SACH;IAxDD,CAwDC;AAzDD,CAyDC,CAAC;AAEJ,IAAM,0BAA0B,GAAG,UAAC,GAAa,EAAE,YAA0B;IAC3E,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,MAAM;YACT,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC,CAAC;YACR,IAAM,eAAe,GAAU,YAAY,CAAC;YAC5C,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,uBAAuB,GAAG,UAGrC,aAA2B,EAC3B,KAAY,EACZ,MAAwB;IAAxB,uBAAA,EAAA,WAAwB;IACrB,OAAA,yBAAyB,CAAC,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC;AAAlF,CAAkF,CAAC"} \ No newline at end of file diff --git a/esm/src/fetch/index.d.ts b/esm/src/fetch/index.d.ts new file mode 100644 index 0000000..64accb7 --- /dev/null +++ b/esm/src/fetch/index.d.ts @@ -0,0 +1 @@ +export { createFetchSharedClient } from "./createFetchSharedClient.mjs"; diff --git a/esm/src/fetch/index.mjs b/esm/src/fetch/index.mjs new file mode 100644 index 0000000..2036063 --- /dev/null +++ b/esm/src/fetch/index.mjs @@ -0,0 +1,2 @@ +export { createFetchSharedClient } from "./createFetchSharedClient.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/fetch/index.mjs.map b/esm/src/fetch/index.mjs.map new file mode 100644 index 0000000..2bfdf43 --- /dev/null +++ b/esm/src/fetch/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"} \ No newline at end of file diff --git a/esm/src/fetch/queryParamsToString.d.ts b/esm/src/fetch/queryParamsToString.d.ts new file mode 100644 index 0000000..af4d3de --- /dev/null +++ b/esm/src/fetch/queryParamsToString.d.ts @@ -0,0 +1,8 @@ +type RawQueryParams = { + [key: string]: string | boolean | number; +}; +export type QueryParams = { + [K in keyof T]: T[K]; +}; +export declare const queryParamsToString: >(queryParams: Q) => string; +export {}; diff --git a/esm/src/fetch/queryParamsToString.mjs b/esm/src/fetch/queryParamsToString.mjs new file mode 100644 index 0000000..0c822e7 --- /dev/null +++ b/esm/src/fetch/queryParamsToString.mjs @@ -0,0 +1,33 @@ +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +export var queryParamsToString = function (queryParams) { + return Object.keys(queryParams) + .reduce(function (acc, param) { return __spreadArray(__spreadArray([], __read(acc), false), __read((typeof queryParams[param] !== "undefined" + ? ["".concat(param.toString(), "=").concat(encodeURI(queryParams[param].toString()))] + : [])), false); }, []) + .join("&"); +}; +//# sourceMappingURL=queryParamsToString.mjs.map \ No newline at end of file diff --git a/esm/src/fetch/queryParamsToString.mjs.map b/esm/src/fetch/queryParamsToString.mjs.map new file mode 100644 index 0000000..a688c50 --- /dev/null +++ b/esm/src/fetch/queryParamsToString.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"queryParamsToString.mjs","sourceRoot":"","sources":["../../../src/fetch/queryParamsToString.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,CAAC,IAAM,mBAAmB,GAAG,UACjC,WAAc;IAEd,OAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAoB;SACzC,MAAM,CACL,UAAC,GAAa,EAAE,KAAK,IAAK,8CACrB,GAAG,kBACH,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,WAAW;QAC3C,CAAC,CAAC,CAAC,UAAG,KAAK,CAAC,QAAQ,EAAE,cAAI,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAE,CAAC;QACrE,CAAC,CAAC,EAAE,CAAC,WAJiB,CAKzB,EACD,EAAE,CACH;SACA,IAAI,CAAC,GAAG,CAAC;AAVZ,CAUY,CAAC"} \ No newline at end of file diff --git a/esm/src/index.d.ts b/esm/src/index.d.ts new file mode 100644 index 0000000..20feac7 --- /dev/null +++ b/esm/src/index.d.ts @@ -0,0 +1,7 @@ +export { createCustomSharedClient } from "./createCustomSharedClient.mjs"; +export { configureCreateHttpClient } from "./configureCreateHttpClient.mjs"; +export type { HandlerCreator, HttpClient, HttpResponse, } from "./configureCreateHttpClient.mjs"; +export { defineRoutes, defineRoute, listRoutes } from "./defineRoutes.mjs"; +export type { HttpMethod, SharedRoute, UnknownSharedRoute, UnknownSharedRouteWithUrl, } from "./defineRoutes.mjs"; +export type { PathParameters, Url } from "./pathParameters.mjs"; +export { keys } from "./pathParameters.mjs"; diff --git a/esm/src/index.mjs b/esm/src/index.mjs new file mode 100644 index 0000000..7b218a4 --- /dev/null +++ b/esm/src/index.mjs @@ -0,0 +1,5 @@ +export { createCustomSharedClient } from "./createCustomSharedClient.mjs"; +export { configureCreateHttpClient } from "./configureCreateHttpClient.mjs"; +export { defineRoutes, defineRoute, listRoutes } from "./defineRoutes.mjs"; +export { keys } from "./pathParameters.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/index.mjs.map b/esm/src/index.mjs.map new file mode 100644 index 0000000..e7058bf --- /dev/null +++ b/esm/src/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQvE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"} \ No newline at end of file diff --git a/esm/src/openapi/createOpenApiGenerator.d.ts b/esm/src/openapi/createOpenApiGenerator.d.ts new file mode 100644 index 0000000..e46edde --- /dev/null +++ b/esm/src/openapi/createOpenApiGenerator.d.ts @@ -0,0 +1,49 @@ +import { OpenAPIV3_1 as OpenAPI } from "openapi-types"; +import { z } from "zod"; +import { PathParameters, UnknownSharedRoute } from "../index.mjs"; +type OmitFromExisting = Omit; +type Examples = { + [media: string]: OpenAPI.ExampleObject & { + value?: T; + }; +}; +type WithExampleOrExamples = { + example?: T; + examples?: never; +} | { + example?: never; + examples?: Examples; +}; +type OpenApiBody = Pick & { + example?: T; + examples?: Examples; +}; +type ExtraDocParameter = Partial> & WithExampleOrExamples; +type CreateOpenApiGenerator = ; +}, SecuritySchemeName extends string>(sharedRoutesByTag: SharedRoutesByTag, openApiRootDoc: Omit & { + components?: OmitFromExisting & { + securitySchemes?: Record; + }; +}) => (extraDataByRoute: Partial<{ + [Tag in keyof SharedRoutesByTag]: { + [R in keyof SharedRoutesByTag[Tag]]: OmitFromExisting & { + extraDocs: { + securitySchemeToApply?: SecuritySchemeName[]; + urlParams?: PathParameters extends Record ? never : Record, ExtraDocParameter>; + body?: z.infer extends void ? never : OpenApiBody>; + queryParams?: z.infer extends void ? never : { + [K in keyof z.infer]: ExtraDocParameter[K]>; + }; + headerParams?: z.infer extends void ? never : { + [K in keyof z.infer]: ExtraDocParameter[K]>; + }; + responses: { + [S in keyof SharedRoutesByTag[Tag][R]["responses"] & number]: OpenAPI.ResponseObject & WithExampleOrExamples>; + }; + }; + }; + }; +}>) => OpenAPI.Document; +export declare const createOpenApiGenerator: CreateOpenApiGenerator; +export {}; diff --git a/esm/src/openapi/createOpenApiGenerator.mjs b/esm/src/openapi/createOpenApiGenerator.mjs new file mode 100644 index 0000000..3934939 --- /dev/null +++ b/esm/src/openapi/createOpenApiGenerator.mjs @@ -0,0 +1,145 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +import { zodToJsonSchema } from "zod-to-json-schema"; +import { keys } from "../index.mjs"; +var extractFromOpenApiBody = function (openApiRequestBody) { + if (openApiRequestBody === void 0) { openApiRequestBody = {}; } + var examples = openApiRequestBody.examples, example = openApiRequestBody.example, rest = __rest(openApiRequestBody, ["examples", "example"]); + return { + withRequestBodyExemple: __assign(__assign({}, (example && { example: example })), (examples && { examples: examples })), + requestBodyDocs: rest, + }; +}; +export var createOpenApiGenerator = function (sharedRoutesByTag, openApiRootDoc) { return function (extraDataByRoute) { return (__assign(__assign({}, openApiRootDoc), { paths: keys(sharedRoutesByTag).reduce(function (rootAcc, tag) { + var sharedRoutes = sharedRoutesByTag[tag]; + return __assign(__assign({}, rootAcc), keys(sharedRoutes).reduce(function (acc, routeName) { + var _a, _b; + var _c, _d; + var route = sharedRoutes[routeName]; + var _e = (_d = (_c = extraDataByRoute[tag]) === null || _c === void 0 ? void 0 : _c[routeName]) !== null && _d !== void 0 ? _d : {}, extraDocs = _e.extraDocs, extraDataForRoute = __rest(_e, ["extraDocs"]); + var _f = extractFromUrl(route.url, extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.urlParams), formattedUrl = _f.formattedUrl, pathParams = _f.pathParams; + var parameters = __spreadArray(__spreadArray(__spreadArray([], __read((pathParams.length > 0 ? pathParams : [])), false), __read((!isShapeObjectEmpty(route.queryParamsSchema) + ? zodObjectToParameters(route.queryParamsSchema, "query", extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.queryParams) + : [])), false), __read((!isShapeObjectEmpty(route.headersSchema) + ? zodObjectToParameters(route.headersSchema, "header", extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.headerParams) + : [])), false); + var _g = extractFromOpenApiBody(extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.body), withRequestBodyExemple = _g.withRequestBodyExemple, requestBodyDocs = _g.requestBodyDocs; + return __assign(__assign({}, acc), (_a = {}, _a[formattedUrl] = __assign(__assign({}, acc[formattedUrl]), (_b = {}, _b[route.method] = __assign(__assign(__assign(__assign(__assign(__assign({}, extraDataForRoute), { tags: [tag] }), ((extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.securitySchemeToApply) && + securitySchemeNamesToSecurity(extraDocs.securitySchemeToApply))), (parameters.length > 0 && { + parameters: parameters, + })), (!isShapeObjectEmpty(route.requestBodySchema) && { + requestBody: { + required: true, + content: { + "application/json": __assign(__assign({}, withRequestBodyExemple), { schema: __assign(__assign({}, requestBodyDocs), zodToOpenApi(route.requestBodySchema)) }), + }, + }, + })), { responses: keys(route.responses).reduce(function (acc, status) { + var _a; + var _b, _c; + var responseSchema = zodToOpenApi(route.responses[status]); + var _d = (_c = (_b = extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.responses) === null || _b === void 0 ? void 0 : _b[status]) !== null && _c !== void 0 ? _c : {}, example = _d.example, examples = _d.examples, responseDoc = __rest(_d, ["example", "examples"]); + return __assign(__assign({}, acc), (_a = {}, _a[status.toString()] = __assign(__assign({}, responseDoc), (typeof responseSchema === "object" && { + content: { + "application/json": __assign(__assign(__assign({}, (example && { example: example })), (examples && { examples: examples })), { schema: responseSchema }), + }, + })), _a)); + }, {}) }), _b)), _a)); + }, {})); + }, {}) })); }; }; +var extractFromUrl = function (url, extraUrlParameters) { + var pathParams = []; + var formattedUrl = url.replace(/:(.*?)(\/|$)/g, function (_match, group1, group2) { + var extraDocForParam = extraUrlParameters === null || extraUrlParameters === void 0 ? void 0 : extraUrlParameters[group1]; + pathParams.push(__assign(__assign({}, extraDocForParam), { name: group1, required: true, schema: { type: "string" }, in: "path" })); + return "{".concat(group1, "}") + group2; + }); + return { + formattedUrl: formattedUrl, + pathParams: pathParams, + }; +}; +var zodToOpenApi = function (schema) { + var _a = zodToJsonSchema(schema, { + $refStrategy: "none", + }), $schema = _a.$schema, additionalProperties = _a.additionalProperties, rest = __rest(_a, ["$schema", "additionalProperties"]); + return rest; +}; +var isShapeObjectEmpty = function (schema) { + var typeName = getTypeName(schema); + if (typeName === "ZodObject") { + var shape = getShape(schema); + return Object.keys(shape).length === 0; + } + return typeName === undefined; +}; +var zodObjectToParameters = function (schema, paramKind, extraDocumentation) { + if (extraDocumentation === void 0) { extraDocumentation = {}; } + var shape = getShape(schema); + return Object.keys(shape).reduce(function (acc, paramName) { + var paramSchema = shape[paramName]; + var extraDoc = extraDocumentation[paramName]; + var initialTypeName = getTypeName(paramSchema); + var required = initialTypeName !== "ZodOptional"; + var schema = zodToOpenApi(required ? paramSchema : paramSchema._def.innerType); + return __spreadArray(__spreadArray([], __read(acc), false), [ + __assign(__assign({}, extraDoc), { in: paramKind, name: paramName, required: required, schema: schema }), + ], false); + }, []); +}; +var getTypeName = function (schema) { + return schema._def.typeName; +}; +var securitySchemeNamesToSecurity = function (securitySchemeToApply) { return ({ + security: securitySchemeToApply.reduce(function (securityAcc, securitySchemeName) { + var _a; + return __spreadArray(__spreadArray([], __read(securityAcc), false), [(_a = {}, _a[securitySchemeName] = [], _a)], false); + }, []), +}); }; +var getShape = function (schema) { return schema._def.shape(); }; +//# sourceMappingURL=createOpenApiGenerator.mjs.map \ No newline at end of file diff --git a/esm/src/openapi/createOpenApiGenerator.mjs.map b/esm/src/openapi/createOpenApiGenerator.mjs.map new file mode 100644 index 0000000..b3faee5 --- /dev/null +++ b/esm/src/openapi/createOpenApiGenerator.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createOpenApiGenerator.mjs","sourceRoot":"","sources":["../../../src/openapi/createOpenApiGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAsC,MAAM,IAAI,CAAC;AAqF9D,IAAM,sBAAsB,GAAG,UAC7B,kBAAwD;IAAxD,mCAAA,EAAA,uBAAwD;IAKhD,IAAA,QAAQ,GAAuB,kBAAkB,SAAzC,EAAE,OAAO,GAAc,kBAAkB,QAAhC,EAAK,IAAI,UAAK,kBAAkB,EAAnD,uBAA8B,CAAF,CAAwB;IAE1D,OAAO;QACL,sBAAsB,wBACjB,CAAC,OAAO,IAAI,EAAE,OAAO,SAAA,EAAE,CAAC,GACxB,CAAC,QAAQ,IAAI,EAAE,QAAQ,UAAA,EAAE,CAAC,CAC9B;QACD,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,sBAAsB,GACjC,UAAC,iBAAiB,EAAE,cAAc,IAAK,OAAA,UAAC,gBAAgB,IAAK,OAAA,uBACxD,cAAc,KACjB,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,UAAC,OAAO,EAAE,GAAG;QACjD,IAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAE5C,6BACK,OAAO,GACP,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,SAAS;;;YAC1C,IAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;YACtC,IAAM,KACJ,MAAA,MAAA,gBAAgB,CAAC,GAAG,CAAC,0CAAG,SAAS,CAAC,mCAAI,EAAE,EADlC,SAAS,eAAA,EAAK,iBAAiB,cAAjC,aAA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AAK,CAAC,SAAS,CAAC,CAAC;QACrC,IAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAoB,CAAC,CAAC;QAC1D,IAAM,eAAe,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QACjD,IAAM,QAAQ,GAAG,eAAe,KAAK,aAAa,CAAC;QAEnD,IAAM,MAAM,GAAG,YAAY,CACzB,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAC7C,CAAC;QAET,8CACK,GAAG;kCAEA,QAAgB,KACpB,EAAE,EAAE,SAAS,EACb,IAAI,EAAE,SAAS,EACf,QAAQ,UAAA,EACR,MAAM,QAAA;kBAER;IACJ,CAAC,EAAE,EAAsB,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,IAAM,WAAW,GAAG,UAAI,MAAmB;IACzC,OAAC,MAAM,CAAC,IAAY,CAAC,QAAQ;AAA7B,CAA6B,CAAC;AAEhC,IAAM,6BAA6B,GAAG,UAAC,qBAA+B,IAAK,OAAA,CAAC;IAC1E,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CACpC,UAAC,WAAW,EAAE,kBAAkB;;QAAK,8CAAI,WAAW,sBAAI,GAAC,kBAAkB,IAAG,EAAE;IAA3C,CAA8C,EACnF,EAAgC,CACjC;CACF,CAAC,EALyE,CAKzE,CAAC;AAEH,IAAM,QAAQ,GAAG,UAAI,MAAmB,IAAkB,OAAC,MAAM,CAAC,IAAY,CAAC,KAAK,EAAE,EAA5B,CAA4B,CAAC"} \ No newline at end of file diff --git a/esm/src/openapi/index.d.ts b/esm/src/openapi/index.d.ts new file mode 100644 index 0000000..2f7b227 --- /dev/null +++ b/esm/src/openapi/index.d.ts @@ -0,0 +1 @@ +export { createOpenApiGenerator } from "./createOpenApiGenerator.mjs"; diff --git a/esm/src/openapi/index.mjs b/esm/src/openapi/index.mjs new file mode 100644 index 0000000..3ff5f58 --- /dev/null +++ b/esm/src/openapi/index.mjs @@ -0,0 +1,2 @@ +export { createOpenApiGenerator } from "./createOpenApiGenerator.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/openapi/index.mjs.map b/esm/src/openapi/index.mjs.map new file mode 100644 index 0000000..b1045e3 --- /dev/null +++ b/esm/src/openapi/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/openapi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"} \ No newline at end of file diff --git a/esm/src/pathParameters.d.ts b/esm/src/pathParameters.d.ts new file mode 100644 index 0000000..c40384b --- /dev/null +++ b/esm/src/pathParameters.d.ts @@ -0,0 +1,19 @@ +type Http = "http://" | "https://"; +type AbsoluteUrl = `${Http}${string}`; +type RelativeUrl = `/${string}`; +export type Url = AbsoluteUrl | RelativeUrl; +interface ParamsDictionary { + [key: string]: string; +} +type RemoveDomain = S extends RelativeUrl ? S : S extends `${Http}${string}${"/"}${infer P}` ? `/${P}` : "/"; +type RemoveTail = S extends `${infer P}${Tail}` ? P : S; +type GetRouteParameter = RemoveTail, `-${string}`>, `.${string}`>; +export type PathParameters = string extends Route ? ParamsDictionary : RemoveDomain extends `${string}:${infer Rest}` ? (GetRouteParameter extends never ? ParamsDictionary : GetRouteParameter extends `${infer ParamName}?` ? { + [P in ParamName]?: string; +} : { + [P in GetRouteParameter]: string; +}) & (Rest extends `${GetRouteParameter}${infer Next}` ? PathParameters : unknown) : {}; +export type ReplaceParamsInUrl = (path: U, params: PathParameters) => Url; +export declare const replaceParamsInUrl: ReplaceParamsInUrl; +export declare const keys: >(obj: Obj) => (keyof Obj)[]; +export {}; diff --git a/esm/src/pathParameters.mjs b/esm/src/pathParameters.mjs new file mode 100644 index 0000000..7afc705 --- /dev/null +++ b/esm/src/pathParameters.mjs @@ -0,0 +1,11 @@ +export var replaceParamsInUrl = function (url, params) { + if (params === void 0) { params = {}; } + var paramNames = keys(params); + if (paramNames.length === 0) + return url; + return paramNames.reduce(function (acc, paramName) { return acc.replace(":".concat(paramName.toString()), params[paramName]); }, url); +}; +export var keys = function (obj) { + return Object.keys(obj); +}; +//# sourceMappingURL=pathParameters.mjs.map \ No newline at end of file diff --git a/esm/src/pathParameters.mjs.map b/esm/src/pathParameters.mjs.map new file mode 100644 index 0000000..28925ab --- /dev/null +++ b/esm/src/pathParameters.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"pathParameters.mjs","sourceRoot":"","sources":["../../src/pathParameters.ts"],"names":[],"mappings":"AA+CA,MAAM,CAAC,IAAM,kBAAkB,GAAuB,UACpD,GAAG,EACH,MAAyC;IAAzC,uBAAA,EAAA,SAAS,EAAgC;IAEzC,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,OAAO,UAAU,CAAC,MAAM,CACtB,UAAC,GAAG,EAAE,SAAS,IAAK,OAAA,GAAG,CAAC,OAAO,CAAC,WAAI,SAAS,CAAC,QAAQ,EAAE,CAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,EAA1D,CAA0D,EAC9E,GAAU,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,IAAI,GAAG,UAAsC,GAAQ;IAChE,OAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAkB;AAAjC,CAAiC,CAAC"} \ No newline at end of file diff --git a/esm/src/supertest/createSupertestSharedClient.d.ts b/esm/src/supertest/createSupertestSharedClient.d.ts new file mode 100644 index 0000000..be46c3b --- /dev/null +++ b/esm/src/supertest/createSupertestSharedClient.d.ts @@ -0,0 +1,5 @@ +import type { UnknownSharedRoute } from "../index.mjs"; +import { HandlerCreator } from "../index.mjs"; +import type { SuperTest, Test } from "supertest"; +export declare const createSupertestHandlerCreator: (supertestRequest: SuperTest) => HandlerCreator; +export declare const createSupertestSharedClient: >(sharedRoutes: SharedRoutes, supertestRequest: SuperTest) => import("../index.mjs").HttpClient; diff --git a/esm/src/supertest/createSupertestSharedClient.mjs b/esm/src/supertest/createSupertestSharedClient.mjs new file mode 100644 index 0000000..c206a64 --- /dev/null +++ b/esm/src/supertest/createSupertestSharedClient.mjs @@ -0,0 +1,114 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +import { configureCreateHttpClient } from "../index.mjs"; +var supertestRequestToCorrectHttpMethod = function (supertestRequest, method) { return supertestRequest[method]; }; +export var createSupertestHandlerCreator = function (supertestRequest) { + return function (routeName, routes, replaceParamsInUrl) { + var route = routes[routeName]; + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var queryParamsWithCorrectArrays, result; + var _b = _a === void 0 ? {} : _a, headers = _b.headers, body = _b.body, queryParams = _b.queryParams, urlParams = _b.urlParams; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + queryParamsWithCorrectArrays = Object.fromEntries(Object.entries(queryParams !== null && queryParams !== void 0 ? queryParams : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + return [ + Array.isArray(value) ? "".concat(key, "[]") : key, + value, + ]; + })); + return [4 /*yield*/, supertestRequestToCorrectHttpMethod(supertestRequest, route.method)(replaceParamsInUrl(route.url, urlParams)) + .send(body) + .set(headers !== null && headers !== void 0 ? headers : {}) + .query(queryParamsWithCorrectArrays)]; + case 1: + result = _c.sent(); + return [2 /*return*/, __assign(__assign({ status: result.status, body: result.body }, (!Object.keys(route.responses).includes(result.status.toString()) && { + text: result.text, + })), { headers: result.headers })]; + } + }); + }); + }; + }; +}; +export var createSupertestSharedClient = function (sharedRoutes, supertestRequest) { + return configureCreateHttpClient(createSupertestHandlerCreator(supertestRequest))(sharedRoutes); +}; +//# sourceMappingURL=createSupertestSharedClient.mjs.map \ No newline at end of file diff --git a/esm/src/supertest/createSupertestSharedClient.mjs.map b/esm/src/supertest/createSupertestSharedClient.mjs.map new file mode 100644 index 0000000..907cb00 --- /dev/null +++ b/esm/src/supertest/createSupertestSharedClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createSupertestSharedClient.mjs","sourceRoot":"","sources":["../../../src/supertest/createSupertestSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,yBAAyB,EAAkB,MAAM,IAAI,CAAC;AAI/D,IAAM,mCAAmC,GAAG,UAC1C,gBAAiC,EACjC,MAAkB,IACO,OAAA,gBAAgB,CAAC,MAAM,CAAC,EAAxB,CAAwB,CAAC;AAEpD,MAAM,CAAC,IAAM,6BAA6B,GACxC,UAAC,gBAAiC;IAClC,OAAA,UAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB;QACpC,IAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CA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;IAEjC,OAAA,yBAAyB,CAAC,6BAA6B,CAAC,gBAAgB,CAAC,CAAC,CACxE,YAAY,CACb;AAFD,CAEC,CAAC"} \ No newline at end of file diff --git a/esm/src/supertest/index.d.ts b/esm/src/supertest/index.d.ts new file mode 100644 index 0000000..353d901 --- /dev/null +++ b/esm/src/supertest/index.d.ts @@ -0,0 +1 @@ +export { createSupertestSharedClient } from "./createSupertestSharedClient.mjs"; diff --git a/esm/src/supertest/index.mjs b/esm/src/supertest/index.mjs new file mode 100644 index 0000000..3052989 --- /dev/null +++ b/esm/src/supertest/index.mjs @@ -0,0 +1,2 @@ +export { createSupertestSharedClient } from "./createSupertestSharedClient.mjs"; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/esm/src/supertest/index.mjs.map b/esm/src/supertest/index.mjs.map new file mode 100644 index 0000000..fc38675 --- /dev/null +++ b/esm/src/supertest/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/supertest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"} \ No newline at end of file diff --git a/esm/src/validations.d.ts b/esm/src/validations.d.ts new file mode 100644 index 0000000..5970cff --- /dev/null +++ b/esm/src/validations.d.ts @@ -0,0 +1,25 @@ +import type { HandlerParams } from "./configureCreateHttpClient.mjs"; +import type { UnknownSharedRoute } from "./defineRoutes.mjs"; +export type ValidationOptions = { + skipInputValidation?: boolean; + skipResponseValidation?: boolean; + skipResponseValidationForStatuses?: number[]; +}; +type ExtractFromExisting = Extract; +type CheckedSchema = ExtractFromExisting; +export declare const validateSchemaWithExplicitError: ({ checkedSchema, params, route, adapterName, responseStatus, withIssuesInMessage, }: { + checkedSchema: ExtractFromExisting; + params: unknown; + route: R; + adapterName: string; + responseStatus?: CheckedSchema extends "responses" ? keyof R["responses"] : never; + withIssuesInMessage?: boolean; +}) => unknown; +export declare const validateInputParams: (route: UnknownSharedRoute, params: HandlerParams, adapterName: string, options?: { + withIssuesInMessage: boolean; +}) => { + queryParams: unknown; + body: unknown; + headers: unknown; +}; +export {}; diff --git a/esm/src/validations.mjs b/esm/src/validations.mjs new file mode 100644 index 0000000..0c97437 --- /dev/null +++ b/esm/src/validations.mjs @@ -0,0 +1,100 @@ +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +var explicitError = function (_a) { + var _b; + var route = _a.route, error = _a.error, adapterName = _a.adapterName, checkedSchema = _a.checkedSchema, statusCode = _a.statusCode, withIssuesInMessage = _a.withIssuesInMessage; + var newError = new Error(__spreadArray([ + "Shared-route schema '".concat(checkedSchema, "' was not respected in adapter '").concat(adapterName, "'."), + checkedSchema === "responses" && + "Received status: ".concat(statusCode, ". Handled statuses: ").concat(Object.keys(route.responses).join(", "), "."), + "Route: ".concat(route.method.toUpperCase(), " ").concat(route.url) + ], __read((withIssuesInMessage && ((_b = error === null || error === void 0 ? void 0 : error.issues) === null || _b === void 0 ? void 0 : _b.length) + ? ["Issues: " + issuesToString(error === null || error === void 0 ? void 0 : error.issues)] + : [])), false).filter(Boolean) + .join("\n")); + newError.cause = error; + return newError; +}; +export var validateSchemaWithExplicitError = function (_a) { + var checkedSchema = _a.checkedSchema, _b = _a.params, params = _b === void 0 ? {} : _b, route = _a.route, adapterName = _a.adapterName, responseStatus = _a.responseStatus, _c = _a.withIssuesInMessage, withIssuesInMessage = _c === void 0 ? false : _c; + try { + if (checkedSchema === "responses") { + if (!responseStatus) + throw new Error("a response status is required when validating responses"); + var schema = route[checkedSchema][responseStatus]; + if (!schema) + throw new Error("No schema found for this status."); + return schema.parse(params); + } + return route[checkedSchema].parse(params); + } + catch (error) { + throw explicitError({ + route: route, + error: error, + adapterName: adapterName, + checkedSchema: checkedSchema, + statusCode: responseStatus, + withIssuesInMessage: withIssuesInMessage, + }); + } +}; +export var validateInputParams = function (route, params, adapterName, options) { + if (options === void 0) { options = { + withIssuesInMessage: false, + }; } + var withIssuesInMessage = options.withIssuesInMessage; + var queryParams = validateSchemaWithExplicitError({ + adapterName: adapterName, + checkedSchema: "queryParamsSchema", + params: params.queryParams, + route: route, + withIssuesInMessage: withIssuesInMessage, + }); + var body = validateSchemaWithExplicitError({ + adapterName: adapterName, + checkedSchema: "requestBodySchema", + params: params.body, + route: route, + withIssuesInMessage: withIssuesInMessage, + }); + // we validate headers separately because we don't want to re-affect req.headers parsed value + // because we don't want to lose all other headers + validateSchemaWithExplicitError({ + adapterName: adapterName, + checkedSchema: "headersSchema", + params: params.headers, + route: route, + }); + return { queryParams: queryParams, body: body, headers: params.headers }; +}; +var issuesToString = function (issues) { + return issues.map(function (_a) { + var message = _a.message, path = _a.path; + return "".concat(path.join("."), ": ").concat(message); + }).join(" | "); +}; +//# sourceMappingURL=validations.mjs.map \ No newline at end of file diff --git a/esm/src/validations.mjs.map b/esm/src/validations.mjs.map new file mode 100644 index 0000000..58607e1 --- /dev/null +++ b/esm/src/validations.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"validations.mjs","sourceRoot":"","sources":["../../src/validations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAM,aAAa,GAAG,UAAC,EActB;;QAbC,KAAK,WAAA,EACL,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,mBAAmB,yBAAA;IASn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AO,aAAA,EAAE,IAAI,UAAA;QAAO,OAAA,UAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,eAAK,OAAO,CAAE;IAA/B,CAA+B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AAA9E,CAA8E,CAAC"} \ No newline at end of file diff --git a/esm/test/createAxiosAndFetchSharedClient.test.d.ts b/esm/test/createAxiosAndFetchSharedClient.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/test/createAxiosAndFetchSharedClient.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/test/createAxiosAndFetchSharedClient.test.mjs b/esm/test/createAxiosAndFetchSharedClient.test.mjs new file mode 100644 index 0000000..a9ea127 --- /dev/null +++ b/esm/test/createAxiosAndFetchSharedClient.test.mjs @@ -0,0 +1,365 @@ +/* eslint-disable @typescript-eslint/no-unused-expressions */ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import axios from "axios"; +import { defineRoute, defineRoutes, listRoutes } from "../src/index.mjs"; +import { z } from "zod"; +import { createAxiosSharedClient } from "../src/axios/index.mjs"; +import { createFetchSharedClient } from "../src/fetch/index.mjs"; +import { describe, it, expect } from "vitest"; +describe("createAxiosSharedCaller", function () { + it("create a caller from axios and sharedRoutes object", function () { return __awaiter(void 0, void 0, void 0, function () { + var bookSchema, withAuthorizationSchema, routes, axiosSharedCaller, _notExecuted; + return __generator(this, function (_a) { + bookSchema = z.object({ title: z.string(), author: z.string() }); + withAuthorizationSchema = z.object({ authorization: z.string() }); + routes = defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: defineRoute({ + method: "get", + url: "/books", + queryParamsSchema: z.object({ max: z.number() }), + responses: { 200: z.array(bookSchema) }, + }), + getByTitle: defineRoute({ + method: "get", + url: "/books/:title", + responses: { 200: bookSchema, 404: z.object({ message: z.string() }) }, + }), + }); + axiosSharedCaller = createAxiosSharedClient(routes, axios); + expect(listRoutes(routes)).toEqual([ + "POST /books", + "GET /books", + "GET /books/:title", + ]); + _notExecuted = function () { return __awaiter(void 0, void 0, void 0, function () { + var addBookResponse, getAllBooksResponse, getByTitleResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, axiosSharedCaller.addBook({ + body: { title: "lala", author: "bob" }, + headers: { authorization: "some-token" }, + })]; + case 1: + addBookResponse = _a.sent(); + addBookResponse.body; // type is void, as expected + return [4 /*yield*/, axiosSharedCaller.getAllBooks({ + queryParams: { max: 3 }, + })]; + case 2: + getAllBooksResponse = _a.sent(); + getAllBooksResponse.body; // type is Book[], as expected + return [4 /*yield*/, axiosSharedCaller.getByTitle({ + urlParams: { title: "great" }, + })]; + case 3: + getByTitleResponse = _a.sent(); + if (getByTitleResponse.status === 404) { + getByTitleResponse.body; // type is { message: string }, as expected + } + else { + getByTitleResponse.body; // type is Book, as expected + } + return [2 /*return*/]; + } + }); + }); }; + return [2 /*return*/]; + }); + }); }); + describe("Actually calling an endpoint", function () { + // WARNING : This test uses an actual placeholder api (which might not always be available...) + var todoSchema = z.object({ + userId: z.number(), + id: z.number(), + title: z.string(), + completed: z.boolean(), + }); + var routes = defineRoutes({ + getByTodoById: defineRoute({ + method: "get", + url: "https://jsonplaceholder.typicode.com/todos/:todoId", + queryParamsSchema: z.object({ userId: z.number(), max: z.number().optional() }), + responses: { + 200: todoSchema, + 400: z.object({ message: z.string() }), + }, + }), + addPost: defineRoute({ + method: "post", + url: "https://jsonplaceholder.typicode.com/posts", + requestBodySchema: z.object({ + title: z.string(), + body: z.string(), + userId: z.number(), + }), + responses: { 201: z.object({ id: z.number() }) }, + }), + updatePostWithIncorrectReturnCode: defineRoute({ + method: "put", + url: "https://jsonplaceholder.typicode.com/posts/:postId", + requestBodySchema: z.object({ + title: z.string(), + body: z.string(), + userId: z.number(), + }), + responses: { 208: z.object({ id: z.number() }) }, + }), + }); + it.each([ + { name: "axios", httpClient: createAxiosSharedClient(routes, axios) }, + { name: "fetch", httpClient: createFetchSharedClient(routes, fetch) }, + ])("actually calls a placeholder endpoint, using $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var response, expectedResponseBody, addPostResponse; + var httpClient = _b.httpClient, name = _b.name; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + expect(listRoutes(routes)).toEqual([ + "GET https://jsonplaceholder.typicode.com/todos/:todoId", + "POST https://jsonplaceholder.typicode.com/posts", + "PUT https://jsonplaceholder.typicode.com/posts/:postId", + ]); + return [4 /*yield*/, httpClient.getByTodoById({ + urlParams: { todoId: "3" }, + queryParams: { userId: 1, max: undefined }, + })]; + case 1: + response = _c.sent(); + expectedResponseBody = { + id: 3, + userId: 1, + completed: false, + title: "fugiat veniam minus", + }; + expect(response.body).toEqual(expectedResponseBody); + expect(response.status).toBe(200); + return [4 /*yield*/, httpClient.addPost({ + body: { title: "My great post", body: "Some content", userId: 1 }, + })]; + case 2: + addPostResponse = _c.sent(); + expect(addPostResponse.body.id).toBeTypeOf("number"); + expect(addPostResponse.status).toBe(201); + expect(addPostResponse.headers).toMatchObject({ + "content-type": "application/json; charset=utf-8", + }); + return [4 /*yield*/, expect(httpClient.addPost({ body: { wrong: "body" } })).rejects.toThrow([ + "Shared-route schema 'requestBodySchema' was not respected in adapter '".concat(name, "'."), + "Route: POST https://jsonplaceholder.typicode.com/posts", + "Issues: title: Required | body: Required | userId: Required", + ].join("\n"))]; + case 3: + _c.sent(); + return [4 /*yield*/, expect(httpClient.updatePostWithIncorrectReturnCode({ + urlParams: { postId: "1" }, + body: { title: "My great post", body: "Some content", userId: 1 }, + })).rejects.toThrow([ + "Shared-route schema 'responses' was not respected in adapter '".concat(name, "'."), + "Received status: 200. Handled statuses: 208.", + "Route: PUT https://jsonplaceholder.typicode.com/posts/:postId", + ].join("\n"))]; + case 4: + _c.sent(); + return [2 /*return*/]; + } + }); + }); }, { timeout: 3000 }); + it.each([ + { + name: "axios", + httpClient: createAxiosSharedClient(routes, axios, { skipInputValidation: true }), + }, + { + name: "fetch", + httpClient: createFetchSharedClient(routes, fetch, { skipInputValidation: true }), + }, + ])("can skip the validation for input params or response, for $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var response, addPostResponse; + var httpClient = _b.httpClient; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: return [4 /*yield*/, httpClient.addPost({ body: { wrong: "body" } })]; + case 1: + response = _c.sent(); + expect(response.body).toBeTruthy(); + return [4 /*yield*/, httpClient.addPost({ + body: { title: "My great post", body: "Some content", userId: 1 }, + })]; + case 2: + addPostResponse = _c.sent(); + expect(addPostResponse.body.id).toBeTypeOf("number"); + return [2 /*return*/]; + } + }); + }); }); + var skippedStatuses = [200]; + it.each([ + { + name: "axios", + httpClient: createAxiosSharedClient(routes, axios, { + skipResponseValidationForStatuses: skippedStatuses, + }), + }, + { + name: "fetch", + httpClient: createFetchSharedClient(routes, fetch, { + skipResponseValidationForStatuses: skippedStatuses, + }), + }, + ])("can skip the response validation for some selected statuses, for $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var postId, body, response; + var httpClient = _b.httpClient; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + postId = "1"; + body = { title: "My great post", body: "Some content", userId: 1 }; + return [4 /*yield*/, httpClient.updatePostWithIncorrectReturnCode({ + urlParams: { postId: "1" }, + body: body, + })]; + case 1: + response = _c.sent(); + expect(response.status).toBe(200); + expect(response.body).toEqual(__assign(__assign({}, body), { id: +postId })); + return [2 /*return*/]; + } + }); + }); }); + describe("explicit error when calling without respecting the contract", function () { + var todoSchema = z.object({ + userId: z.number(), + id: z.number(), + title: z.string(), + completed: z.boolean(), + }); + var routes = defineRoutes({ + getTodos: defineRoute({ + method: "get", + url: "https://jsonplaceholder.typicode.com/todos", + queryParamsSchema: z.object({ userId: z.number(), max: z.number().optional() }), + responses: { 200: z.array(z.number()) }, // this is not the correct schema, we want to trigger an error on return + }), + addTodo: defineRoute({ + method: "post", + url: "https://jsonplaceholder.typicode.com/todos", + requestBodySchema: todoSchema, + headersSchema: z.object({ authorization: z.string() }), + }), + }); + var httpClient = createFetchSharedClient(routes, fetch); + it("when query params are wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, expect(httpClient.getTodos({ queryParams: { userWrongKey: "yolo" } })).rejects.toThrow([ + "Shared-route schema 'queryParamsSchema' was not respected in adapter 'fetch'.", + "Route: GET https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it("when response body is wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, expect(httpClient.getTodos({ queryParams: { userId: 1 } })).rejects.toThrow([ + "Shared-route schema 'responses' was not respected in adapter 'fetch'.", + "Received status: 200. Handled statuses: 200.", + "Route: GET https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it("when request body is wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, expect(httpClient.addTodo({ + body: { wrong: "yolo" }, + headers: { authorization: "some-token" }, + })).rejects.toThrow([ + "Shared-route schema 'requestBodySchema' was not respected in adapter 'fetch'.", + "Route: POST https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + it("when headers are wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, expect(httpClient.addTodo({ + body: { id: 123, userId: 456, title: "some title", completed: false }, + headers: { auth: "some-token" }, + })).rejects.toThrow([ + "Shared-route schema 'headersSchema' was not respected in adapter 'fetch'.", + "Route: POST https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + }); +}); +//# sourceMappingURL=createAxiosAndFetchSharedClient.test.mjs.map \ No newline at end of file diff --git a/esm/test/createAxiosAndFetchSharedClient.test.mjs.map b/esm/test/createAxiosAndFetchSharedClient.test.mjs.map new file mode 100644 index 0000000..5f1526c --- /dev/null +++ b/esm/test/createAxiosAndFetchSharedClient.test.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createAxiosAndFetchSharedClient.test.mjs","sourceRoot":"","sources":["../../test/createAxiosAndFetchSharedClient.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,yBAAyB,EAAE;IAClC,EAAE,CAAC,oDAAoD,EAAE;;;YACjD,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjE,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,EA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,CAAC,CAAC,OAAO,CAAC,OAAO,CAC/E;gCACE,uEAAuE;gCACvE,8CAA8C;gCAC9C,uDAAuD;6BACxD,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,EAAA;;4BAND,SAMC,CAAC;;;;iBACH,CAAC,CAAC;YAEH,EAAE,CAAC,4BAA4B,EAAE;;;gCAC/B,qBAAM,MAAM,CACV,UAAU,CAAC,OAAO,CAAC;gCACjB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAS;gCAC9B,OAAO,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE;6BACzC,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CACf;gCACE,+EAA+E;gCAC/E,wDAAwD;6BACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,EAAA;;4BAVD,SAUC,CAAC;;;;iBACH,CAAC,CAAC;YAEH,EAAE,CAAC,wBAAwB,EAAE;;;gCAC3B,qBAAM,MAAM,CACV,UAAU,CAAC,OAAO,CAAC;gCACjB,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE;gCACrE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAS;6BACvC,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CACf;gCACE,2EAA2E;gCAC3E,wDAAwD;6BACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,EAAA;;4BAVD,SAUC,CAAC;;;;iBACH,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/test/createCustomSharedClient.test.d.ts b/esm/test/createCustomSharedClient.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/test/createCustomSharedClient.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/test/createCustomSharedClient.test.mjs b/esm/test/createCustomSharedClient.test.mjs new file mode 100644 index 0000000..a19e853 --- /dev/null +++ b/esm/test/createCustomSharedClient.test.mjs @@ -0,0 +1,129 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { z } from "zod"; +import { describe, it, expect } from "vitest"; +import { defineRoute, defineRoutes, createCustomSharedClient } from "../src/index.mjs"; +var bookSchema = z.object({ + title: z.string(), + author: z.string(), +}); +var withAuthorizationSchema = z.object({ authorization: z.string() }); +var myRoutes = defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: defineRoute({ + method: "get", + url: "/books", + queryParamsSchema: z.object({ max: z.number() }), + responses: { 200: z.array(bookSchema) }, + }), + getByTitle: defineRoute({ + method: "get", + url: "/books/:title", + responses: { 200: bookSchema.optional() }, + }), +}); +// const books: Book[] = []; +var createTestHttpClient = function () { + var books = []; + return createCustomSharedClient(myRoutes, { + addBook: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var body = _b.body; + return __generator(this, function (_c) { + books.push(body); + return [2 /*return*/, { status: 201, body: undefined, headers: {} }]; + }); + }); }, + getAllBooks: function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, ({ + status: 200, + body: books, + headers: {}, + })]; + }); + }); }, + getByTitle: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var title = _b.urlParams.title; + return __generator(this, function (_c) { + return [2 /*return*/, ({ + status: 200, + body: books.find(function (book) { return book.title.toLowerCase().includes(title.toLowerCase()); }), + headers: {}, + })]; + }); + }); }, + }); +}; +var httpClient = createTestHttpClient(); +describe("createCustomSharedClient", function () { + it("all routes work fine", function () { return __awaiter(void 0, void 0, void 0, function () { + var myBook, response, allBooks, fetchedBook; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + myBook = { title: "Harry Potter", author: "J.K. Rowling" }; + return [4 /*yield*/, httpClient.addBook({ + body: myBook, + headers: { authorization: "my-token" }, + })]; + case 1: + response = _a.sent(); + expect(response.status).toBe(201); + expect(response.body).toBe(undefined); + return [4 /*yield*/, httpClient.getAllBooks({ + queryParams: { max: 12 }, + })]; + case 2: + allBooks = (_a.sent()).body; + expect(allBooks).toEqual([myBook]); + return [4 /*yield*/, httpClient.getByTitle({ + urlParams: { title: "potter" }, + })]; + case 3: + fetchedBook = (_a.sent()).body; + expect(fetchedBook).toEqual(myBook); + return [2 /*return*/]; + } + }); + }); }); +}); +//# sourceMappingURL=createCustomSharedClient.test.mjs.map \ No newline at end of file diff --git a/esm/test/createCustomSharedClient.test.mjs.map b/esm/test/createCustomSharedClient.test.mjs.map new file mode 100644 index 0000000..9d14f07 --- /dev/null +++ b/esm/test/createCustomSharedClient.test.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createCustomSharedClient.test.mjs","sourceRoot":"","sources":["../../test/createCustomSharedClient.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAC;AAG7E,IAAM,UAAU,GAAmB,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AACH,IAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAExE,IAAM,QAAQ,GAAG,YAAY,CAAC;IAC5B,OAAO,EAAE,WAAW,CAAC;QACnB,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,QAAQ;QACb,iBAAiB,EAAE,UAAU;QAC7B,aAAa,EA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ACZ,CAAC,EAAA;;aAAA;KACH,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,IAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;AAE1C,QAAQ,CAAC,0BAA0B,EAAE;IACnC,EAAE,CAAC,sBAAsB,EAAE;;;;;oBACnB,MAAM,GAAS,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;oBAEtD,qBAAM,UAAU,CAAC,OAAO,CAAC;4BACxC,IAAI,EAAE,MAAM;4BACZ,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE;yBACvC,CAAC,EAAA;;oBAHI,QAAQ,GAAG,SAGf;oBACF,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAEX,qBAAM,UAAU,CAAC,WAAW,CAAC;4BACtD,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;yBACzB,CAAC,EAAA;;oBAFY,QAAQ,GAAK,CAAA,SAEzB,CAAA,KAFoB;oBAGtB,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;oBAEL,qBAAM,UAAU,CAAC,UAAU,CAAC;4BACxD,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;yBAC/B,CAAC,EAAA;;oBAFY,WAAW,GAAK,CAAA,SAE5B,CAAA,KAFuB;oBAGzB,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;;;;SACrC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/test/createOpenApiGenerator.test.d.ts b/esm/test/createOpenApiGenerator.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/test/createOpenApiGenerator.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/test/createOpenApiGenerator.test.mjs b/esm/test/createOpenApiGenerator.test.mjs new file mode 100644 index 0000000..80b7de2 --- /dev/null +++ b/esm/test/createOpenApiGenerator.test.mjs @@ -0,0 +1,345 @@ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +import { defineRoute, defineRoutes } from "../src/index.mjs"; +import { z } from "zod"; +import { createOpenApiGenerator } from "../src/openapi/index.mjs"; +import { it, expect } from "vitest"; +var bookSchema = z.object({ title: z.string(), author: z.string() }); +var withAuthorizationSchema = z.object({ authorization: z.string() }); +var routes = defineRoutes({ + getAllBooks: defineRoute({ + url: "/books", + method: "get", + queryParamsSchema: z.object({ + max: z.number().optional(), + truc: z.string(), + }), + responses: { 200: z.array(bookSchema) }, + }), + getByTitle: defineRoute({ + url: "/books/:title", + method: "get", + responses: { 200: bookSchema, 404: z.object({ message: z.string() }) }, + }), + addBook: defineRoute({ + url: "/books", + method: "post", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), +}); +var rootInfo = { + info: { + title: "My book API", + description: "My test openApi description", + version: "1", + }, + servers: [{ url: "/api" }], + openapi: "3.1.0", + components: { + securitySchemes: { + apiKeyAuth: { + description: "The API key to access this API", + type: "apiKey", + in: "header", + name: "authorization", + }, + }, + }, +}; +var generateOpenApi = createOpenApiGenerator({ Books: routes }, rootInfo); +var generateOpenApiJSON = function () { + return generateOpenApi({ + Books: { + addBook: { + summary: "To add a book", + description: "To add a book", + extraDocs: { + securitySchemeToApply: ["apiKeyAuth"], + headerParams: { + authorization: { + example: "my-auth-token", + }, + }, + body: { + title: "my Book", + description: "Represents a book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: { + title: "Harry Potter (addBook body)", + author: "JK Rowlings (addBook body)", + }, + }, + miserables: { + summary: "Miserables summary (getByTitle param)", + description: "Miserables description (getByTitle param)", + value: { + title: "Les miserables (addBook body)", + author: "Victor Hugo (addBook body)", + }, + }, + }, + }, + responses: { + 201: { + description: "Success 201 for addBook. Returns void", + }, + }, + }, + }, + getByTitle: { + extraDocs: { + urlParams: { + title: { + description: "The title of the book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: "harry-potter", + }, + }, + }, + }, + responses: { + "200": { + description: "Success 200 for getByTitle", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle 200)", + description: "Harry Potter description (getByTitle 200)", + value: { + title: "Harry Potter (getByTitle 200)", + author: "JK Rowlings (getByTitle 200)", + }, + }, + lordOfRing: { + summary: "Lord of the ring summary (getByTitle 200)", + description: "Lord of the ring description (getByTitle 200)", + value: { + title: "Lord of the ring (getByTitle 200)", + author: "Tolkien (getByTitle 200)", + }, + }, + }, + }, + 404: { + description: "Not found 404 for getByTitle", + }, + }, + }, + }, + getAllBooks: { + summary: "To get all books", + description: "To get all books", + extraDocs: { + queryParams: { + max: { + description: "Le maximum à retourner", + example: 15, + allowEmptyValue: true, + }, + truc: { deprecated: true, example: "machin..." }, + }, + responses: { + 200: { + description: "Success 200 for getAllBooks", + }, + }, + }, + }, + }, + }); +}; +var bookJsonSchema = { + additionalProperties: false, + type: "object", + properties: { + title: { type: "string" }, + author: { type: "string" }, + }, + required: ["title", "author"], +}; +var expected = __assign(__assign({}, rootInfo), { paths: { + "/books": { + get: { + summary: "To get all books", + description: "To get all books", + tags: ["Books"], + parameters: [ + { + allowEmptyValue: true, + description: "Le maximum à retourner", + example: 15, + name: "max", + required: false, + schema: { type: "number" }, + in: "query", + }, + { + example: "machin...", + deprecated: true, + in: "query", + name: "truc", + required: true, + schema: { type: "string" }, + }, + ], + responses: { + "200": { + description: "Success 200 for getAllBooks", + content: { + "application/json": { + schema: { + type: "array", + items: bookJsonSchema, + }, + }, + }, + }, + }, + }, + post: { + summary: "To add a book", + description: "To add a book", + tags: ["Books"], + security: [{ apiKeyAuth: [] }], + parameters: [ + { + in: "header", + example: "my-auth-token", + name: "authorization", + required: true, + schema: { + type: "string", + }, + }, + ], + requestBody: { + content: { + "application/json": { + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: { + title: "Harry Potter (addBook body)", + author: "JK Rowlings (addBook body)", + }, + }, + miserables: { + summary: "Miserables summary (getByTitle param)", + description: "Miserables description (getByTitle param)", + value: { + title: "Les miserables (addBook body)", + author: "Victor Hugo (addBook body)", + }, + }, + }, + schema: __assign(__assign({ title: "my Book", description: "Represents a book" }, bookJsonSchema), { additionalProperties: undefined }), + }, + }, + required: true, + }, + responses: { + "201": { + description: "Success 201 for addBook. Returns void", + content: { + "application/json": { + schema: { + anyOf: [ + { + maxLength: 0, + type: "string", + }, + ], + }, + }, + }, + }, + }, + }, + }, + "/books/{title}": { + get: { + tags: ["Books"], + parameters: [ + { + description: "The title of the book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: "harry-potter", + }, + }, + name: "title", + required: true, + schema: { type: "string" }, + in: "path", + }, + ], + responses: { + "404": { + "content": { + "application/json": { + "schema": { + "properties": { + "message": { type: "string" }, + }, + "required": ["message"], + "type": "object", + }, + }, + }, + "description": "Not found 404 for getByTitle", + }, + "200": { + description: "Success 200 for getByTitle", + content: { + "application/json": { + schema: __assign(__assign({}, bookJsonSchema), { additionalProperties: undefined }), + examples: { + harry: { + summary: "Harry Potter summary (getByTitle 200)", + description: "Harry Potter description (getByTitle 200)", + value: { + title: "Harry Potter (getByTitle 200)", + author: "JK Rowlings (getByTitle 200)", + }, + }, + lordOfRing: { + summary: "Lord of the ring summary (getByTitle 200)", + description: "Lord of the ring description (getByTitle 200)", + value: { + title: "Lord of the ring (getByTitle 200)", + author: "Tolkien (getByTitle 200)", + }, + }, + }, + }, + }, + }, + }, + }, + }, + } }); +it("has the expected shape", function () { + var openApiJSON = generateOpenApiJSON(); + // console.log("--- Actual SPEC ---"); + // console.log(JSON.stringify(openApiJSON, null, 2)); + expect(openApiJSON).toEqual(expected); +}); +//# sourceMappingURL=createOpenApiGenerator.test.mjs.map \ No newline at end of file diff --git a/esm/test/createOpenApiGenerator.test.mjs.map b/esm/test/createOpenApiGenerator.test.mjs.map new file mode 100644 index 0000000..3e38ef6 --- /dev/null +++ b/esm/test/createOpenApiGenerator.test.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createOpenApiGenerator.test.mjs","sourceRoot":"","sources":["../../test/createOpenApiGenerator.test.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEpC,IAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvE,IAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAExE,IAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;QACvB,GAAG,EAAE,QAAQ;QACb,MAAM,EAAE,KAAK;QACb,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC;YAC1B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACjB,CAAC;QACF,SAAS,EAAE,EA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D,WAAW,EAAE,+CAA+C;wCAC5D,KAAK,EAAE;4CACL,KAAK,EAAE,mCAAmC;4CAC1C,MAAM,EAAE,0BAA0B;yCACnC;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,GACF,CAAC;AAEF,EAAE,CAAC,wBAAwB,EAAE;IAC3B,IAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,sCAAsC;IACtC,qDAAqD;IAErD,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/test/defineRoutes.test.d.ts b/esm/test/defineRoutes.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/test/defineRoutes.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/test/defineRoutes.test.mjs b/esm/test/defineRoutes.test.mjs new file mode 100644 index 0000000..e71da3c --- /dev/null +++ b/esm/test/defineRoutes.test.mjs @@ -0,0 +1,42 @@ +import { z } from "zod"; +import { describe, it, expect } from "vitest"; +import { defineRoutes, defineRoute, listRoutes } from "../src/index.mjs"; +describe("Shared routes definitions", function () { + describe("defineRoutes", function () { + it("does not allow 2 routes with same method and url", function () { + var createMySharedRoutes = function () { + return defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: z.object({ title: z.string() }), + }), + getAllBooks: defineRoute({ + method: "post", + url: "/books", + responses: { 200: z.array(z.object({ id: z.string(), name: z.string() })) }, + }), + }); + }; + expect(createMySharedRoutes).toThrowError(new Error("You cannot have several routes with same http method and url, got: POST /books twice (at least)")); + }); + it("create routes with the expected types and shows list of routes", function () { + var routes = defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: z.object({ title: z.string() }), + }), + getAllBooks: defineRoute({ + method: "get", + url: "/books", + queryParamsSchema: z.object({ lala: z.string() }), + responses: { 200: z.array(z.object({ id: z.string(), name: z.string() })) }, + }), + }); + expect(function () { return routes.getAllBooks.requestBodySchema.parse({ yo: "lala" }); }).toThrow(); + expect(listRoutes(routes)).toEqual(["POST /books", "GET /books"]); + }); + }); +}); +//# sourceMappingURL=defineRoutes.test.mjs.map \ No newline at end of file diff --git a/esm/test/defineRoutes.test.mjs.map b/esm/test/defineRoutes.test.mjs.map new file mode 100644 index 0000000..96ea721 --- /dev/null +++ b/esm/test/defineRoutes.test.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"defineRoutes.test.mjs","sourceRoot":"","sources":["../../test/defineRoutes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE/D,QAAQ,CAAC,2BAA2B,EAAE;IACpC,QAAQ,CAAC,cAAc,EAAE;QACvB,EAAE,CAAC,kDAAkD,EAAE;YACrD,IAAM,oBAAoB,GAAG;gBAC3B,OAAA,YAAY,CAAC;oBACX,OAAO,EAAE,WAAW,CAAC;wBACnB,MAAM,EAAE,MAAM;wBACd,GAAG,EAAE,QAAQ;wBACb,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;qBACnD,CAAC;oBACF,WAAW,EAAE,WAAW,CAAC;wBACvB,MAAM,EAAE,MAAM;wBACd,GAAG,EAAE,QAAQ;wBACb,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE;qBAC5E,CAAC;iBACH,CAAC;YAXF,CAWE,CAAC;YAEL,MAAM,CAAC,oBAAoB,CAAC,CAAC,YAAY,CACvC,IAAI,KAAK,CACP,iGAAiG,CAClG,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gEAAgE,EAAE;YACnE,IAAM,MAAM,GAAG,YAAY,CAAC;gBAC1B,OAAO,EAAE,WAAW,CAAC;oBACnB,MAAM,EAAE,MAAM;oBACd,GAAG,EAAE,QAAQ;oBACb,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;iBACnD,CAAC;gBACF,WAAW,EAAE,WAAW,CAAC;oBACvB,MAAM,EAAE,KAAK;oBACb,GAAG,EAAE,QAAQ;oBACb,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACjD,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE;iBAC5E,CAAC;aACH,CAAC,CAAC;YAEH,MAAM,CAAC,cAAM,OAAA,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAA1D,CAA0D,CAAC,CAAC,OAAO,EAAE,CAAC;YACnF,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/test/expressAndSupertest.test.d.ts b/esm/test/expressAndSupertest.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/esm/test/expressAndSupertest.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/esm/test/expressAndSupertest.test.mjs b/esm/test/expressAndSupertest.test.mjs new file mode 100644 index 0000000..2da3b27 --- /dev/null +++ b/esm/test/expressAndSupertest.test.mjs @@ -0,0 +1,289 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { defineRoute, defineRoutes, listRoutes } from "../src/index.mjs"; +import { createExpressSharedRouter } from "../src/express/index.mjs"; +import { z } from "zod"; +import { createSupertestSharedClient } from "../src/supertest/createSupertestSharedClient.mjs"; +import supertest from "supertest"; +import express from "express"; +import bodyParser from "body-parser"; +import { Router as ExpressRouter } from "express"; +import { expect, it, describe } from "vitest"; +var zNumberFromString = z.preprocess(function (v) { + var n = parseInt(v); + return isNaN(n) ? v : n; +}, z.number()); +var bookSchema = z.object({ + title: z.string(), + author: z.string(), +}); +var withAuthorizationSchema = z.object({ authorization: z.string() }); +var routes = defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: defineRoute({ + method: "get", + url: "/books", + queryParamsSchema: z.object({ + max: zNumberFromString, + startWith: z.array(z.string()), + }), + responses: { 200: z.array(bookSchema) }, + }), + getBookByTitle: defineRoute({ + method: "get", + url: "/books/:title", + responses: { + 200: bookSchema, + 404: z.object({ message: z.string() }), + }, + }), + getBookWithoutParams: defineRoute({ + method: "get", + url: "/no-params", + responses: { 200: bookSchema.optional() }, + }), +}); +var fakeAuthToken = "my-token"; +var createBookRouter = function () { + var bookDB = []; + var expressRouter = ExpressRouter(); + var expressSharedRouter = createExpressSharedRouter(routes, expressRouter); + var someMiddleware = function (_req, _res, next) { + next(); + }; + expressSharedRouter.getAllBooks(function (_, res) { + console.log("yeah reached ! ", bookDB); + return res.json(bookDB); + }); + expressSharedRouter.addBook(someMiddleware, function (req, res) { + if (req.headers.authorization !== fakeAuthToken) { + res.status(401); + return res.json(); + } + bookDB.push(req.body); + return res.json(); + }); + expressSharedRouter.getBookByTitle(function (req, res) { + if (req.params.title === "throw") + throw new Error("Some unexpected error"); + var book = bookDB.find(function (b) { return b.title === req.params.title; }); + if (!book) { + return res.status(404).json({ message: "Book not found" }); + } + return res.status(200).json(book); + }); + expressSharedRouter.getBookWithoutParams(function (_, res) { + res.status(200).json(); + }); + return expressRouter; +}; +var createExempleApp = function () { + var app = express(); + app.use(bodyParser.json()); + app.use(createBookRouter()); + return app; +}; +describe("createExpressSharedRouter and createSupertestSharedCaller", function () { + it("fails to add if not authenticated", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, heyBook, addBookResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = supertest(app); + supertestSharedCaller = createSupertestSharedClient(routes, supertestRequest); + heyBook = { title: "Hey", author: "Steeve" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: heyBook, + headers: { authorization: "not-the-right-token" }, + })]; + case 1: + addBookResponse = _a.sent(); + expect(listRoutes(routes)).toEqual([ + "POST /books", + "GET /books", + "GET /books/:title", + "GET /no-params", + ]); + expect(addBookResponse.body).toEqual(""); // type is void, but express sends ""; + expect(addBookResponse.status).toBe(401); + return [2 /*return*/]; + } + }); + }); }); + it("fails explicitly when the schema is not respected", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, getAllBooksResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = supertest(app); + supertestSharedCaller = createSupertestSharedClient(routes, supertestRequest); + return [4 /*yield*/, supertestSharedCaller.getAllBooks({ + queryParams: { max: "yolo" }, + })]; + case 1: + getAllBooksResponse = _a.sent(); + expect(getAllBooksResponse.body).toEqual({ + status: 400, + message: "Shared-route schema 'queryParamsSchema' was not respected in adapter 'express'.\nRoute: GET /books", + issues: ["max : Expected number, received string", "startWith : Required"], + }); + expect(getAllBooksResponse.status).toBe(400); + return [2 /*return*/]; + } + }); + }); }); + it("create an express app and a supertest instance with the same sharedRoutes object", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, heyBook, addBookResponse, otherBook, getAllBooksResponse, fetchedBookResponse, bookNotFoundResponse, _a, body, status; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + app = createExempleApp(); + supertestRequest = supertest(app); + supertestSharedCaller = createSupertestSharedClient(routes, supertestRequest); + heyBook = { title: "Hey", author: "Steeve" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: heyBook, + headers: { authorization: fakeAuthToken }, + })]; + case 1: + addBookResponse = _b.sent(); + expect(addBookResponse.body).toEqual(""); // type is void, but express sends ""; + expect(addBookResponse.status).toBe(200); + otherBook = { title: "Other book", author: "Somebody" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: otherBook, + headers: { authorization: fakeAuthToken }, + })]; + case 2: + _b.sent(); + return [4 /*yield*/, supertestSharedCaller.getAllBooks({ + queryParams: { max: 5, startWith: ["yolo"] }, + })]; + case 3: + getAllBooksResponse = _b.sent(); + expectToEqual(getAllBooksResponse.body, [heyBook, otherBook]); + expect(getAllBooksResponse.status).toBe(200); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "Hey" }, + })]; + case 4: + fetchedBookResponse = _b.sent(); + expectToMatch(fetchedBookResponse, { + status: 200, + body: heyBook, + headers: { "content-type": "application/json; charset=utf-8" }, + }); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "not found" }, + })]; + case 5: + bookNotFoundResponse = _b.sent(); + expectToMatch(bookNotFoundResponse, { + status: 404, + body: { message: "Book not found" }, + headers: { "content-type": "application/json; charset=utf-8" }, + }); + return [4 /*yield*/, supertestSharedCaller.getBookWithoutParams()]; + case 6: + _a = _b.sent(), body = _a.body, status = _a.status; + expect(body).toBe(""); // express returns "" for void + expect(status).toEqual(200); + return [2 /*return*/]; + } + }); + }); }); + it("shows when unexpected error occurs (though it does not respect schema)", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, result; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = supertest(app); + supertestSharedCaller = createSupertestSharedClient(routes, supertestRequest); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "throw" }, + })]; + case 1: + result = _a.sent(); + expect(result.status).toBe(500); + expect(result.text).toContain("Some unexpected error"); + return [2 /*return*/]; + } + }); + }); }); +}); +var expectToEqual = function (actual, expected) { return expect(actual).toEqual(expected); }; +var expectToMatch = function (actual, expected) { + return expect(actual).toMatchObject(expected); +}; +// type Book = { title: string; author: string }; +// const bookSchema: z.Schema = z.object({ +// title: z.string(), +// author: z.string(), +// }); +var _routes = defineRoutes({ + addBook: defineRoute({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + }), + getAllBooks: defineRoute({ + method: "get", + url: "/books", + queryParamsSchema: z.object({ max: z.number() }), + responses: { + 200: z.array(bookSchema), + }, + }), + getBookByTitle: defineRoute({ + method: "get", + url: "/books/:title", + headersSchema: z.object({ authorization: z.string() }), + responses: { + 200: bookSchema, + 404: z.object({ message: z.string() }), + }, + }), +}); +//# sourceMappingURL=expressAndSupertest.test.mjs.map \ No newline at end of file diff --git a/esm/test/expressAndSupertest.test.mjs.map b/esm/test/expressAndSupertest.test.mjs.map new file mode 100644 index 0000000..b280acd --- /dev/null +++ b/esm/test/expressAndSupertest.test.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"expressAndSupertest.test.mjs","sourceRoot":"","sources":["../../test/expressAndSupertest.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK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AAC,MAAM,EAAE,EAAE,CAAC;QACtD,SAAS,EAAE;YACT,GAAG,EAAE,UAAU;YACf,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACvC;KACF,CAAC;CACH,CAAC,CAAC"} \ No newline at end of file diff --git a/esm/tsconfig.esm.tsbuildinfo b/esm/tsconfig.esm.tsbuildinfo new file mode 100644 index 0000000..e85a1d2 --- /dev/null +++ b/esm/tsconfig.esm.tsbuildinfo @@ -0,0 +1 @@ +{"fileNames":["../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/typeAliases.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/util.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/ZodError.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/locales/en.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/errors.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/parseUtil.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/enumUtil.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/errorUtil.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/partialUtil.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/types.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/external.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.d.ts","../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/index.d.ts","../../src/pathParameters.ts","../../src/defineRoutes.ts","../../src/configureCreateHttpClient.ts","../../src/createCustomSharedClient.ts","../../src/index.ts","../../src/validations.ts","../../node_modules/.pnpm/axios@1.7.7/node_modules/axios/index.d.ts","../../src/axios/createAxiosSharedClient.ts","../../src/axios/index.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/globals.typedarray.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/buffer.buffer.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/assert.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/assert/strict.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/header.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/readable.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/file.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/fetch.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/formdata.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/connector.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/client.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/errors.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/dispatcher.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/global-dispatcher.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/global-origin.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/pool-stats.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/pool.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/handlers.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/balanced-pool.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/agent.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-interceptor.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-agent.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-client.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-pool.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-errors.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/proxy-agent.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/env-http-proxy-agent.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/retry-handler.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/retry-agent.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/api.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/interceptors.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/util.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/cookies.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/patch.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/websocket.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/eventsource.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/filereader.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/diagnostics-channel.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/content-type.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/cache.d.ts","../../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/index.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/globals.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/async_hooks.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/buffer.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/child_process.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/cluster.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/console.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/constants.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/crypto.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dgram.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dns.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dns/promises.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/domain.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dom-events.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/events.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/fs.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/fs/promises.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/http.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/http2.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/https.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/inspector.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/module.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/net.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/os.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/path.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/perf_hooks.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/process.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/punycode.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/querystring.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/readline.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/readline/promises.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/repl.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/sea.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/sqlite.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/promises.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/consumers.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/web.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/string_decoder.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/test.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/timers.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/timers/promises.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/tls.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/trace_events.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/tty.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/url.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/util.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/v8.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/vm.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/wasi.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/worker_threads.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/zlib.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/globals.global.d.ts","../../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/index.d.ts","../../node_modules/.pnpm/@types+mime@1.3.2/node_modules/@types/mime/index.d.ts","../../node_modules/.pnpm/@types+send@0.17.1/node_modules/@types/send/index.d.ts","../../node_modules/.pnpm/@types+range-parser@1.2.4/node_modules/@types/range-parser/index.d.ts","../../node_modules/.pnpm/@types+qs@6.9.7/node_modules/@types/qs/index.d.ts","../../node_modules/.pnpm/@types+express-serve-static-core@4.17.35/node_modules/@types/express-serve-static-core/index.d.ts","../../node_modules/.pnpm/@types+mime@3.0.1/node_modules/@types/mime/Mime.d.ts","../../node_modules/.pnpm/@types+mime@3.0.1/node_modules/@types/mime/index.d.ts","../../node_modules/.pnpm/@types+http-errors@2.0.1/node_modules/@types/http-errors/index.d.ts","../../node_modules/.pnpm/@types+serve-static@1.15.2/node_modules/@types/serve-static/index.d.ts","../../node_modules/.pnpm/@types+connect@3.4.35/node_modules/@types/connect/index.d.ts","../../node_modules/.pnpm/@types+body-parser@1.19.2/node_modules/@types/body-parser/index.d.ts","../../node_modules/.pnpm/@types+express@4.17.17/node_modules/@types/express/index.d.ts","../../src/express/createExpressSharedRouter.ts","../../src/express/index.ts","../../src/fetch/queryParamsToString.ts","../../src/fetch/createFetchSharedClient.ts","../../src/fetch/index.ts","../../node_modules/.pnpm/openapi-types@12.1.0/node_modules/openapi-types/dist/index.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/Options.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/any.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/Refs.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/errorMessages.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/array.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/bigint.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/boolean.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/date.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/enum.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/intersection.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/literal.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/map.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/nativeEnum.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/never.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/null.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/nullable.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/number.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/object.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/string.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/record.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/set.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/tuple.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/undefined.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/union.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/unknown.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parseDef.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/zodToJsonSchema.d.ts","../../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/index.d.ts","../../src/openapi/createOpenApiGenerator.ts","../../src/openapi/index.ts","../../node_modules/.pnpm/@types+cookiejar@2.1.2/node_modules/@types/cookiejar/index.d.ts","../../node_modules/.pnpm/@types+superagent@4.1.18/node_modules/@types/superagent/index.d.ts","../../node_modules/.pnpm/@types+supertest@2.0.12/node_modules/@types/supertest/index.d.ts","../../src/supertest/createSupertestSharedClient.ts","../../src/supertest/index.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/types.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/helpers.d.ts","../../node_modules/.pnpm/@vitest+pretty-format@2.1.2/node_modules/@vitest/pretty-format/dist/index.d.ts","../../node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/index-c1cfc5e9.d.ts","../../node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/index.d.ts","../../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/tasks--RurNSkd.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/types-Bxe-2Udy.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/diff.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/diff.d.ts","../../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/types.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/error.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/error.d.ts","../../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/index.d.ts","../../node_modules/.pnpm/@types+estree@1.0.6/node_modules/@types/estree/index.d.ts","../../node_modules/.pnpm/rollup@4.24.0/node_modules/rollup/dist/rollup.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/hmrPayload.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/customEvent.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/hot.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/types.d-aGj9QkWt.d.ts","../../node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.d.ts","../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/previous-map.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/input.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/css-syntax-error.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/declaration.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/root.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/warning.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/lazy-result.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/no-work-result.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/processor.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/result.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/document.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/rule.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/node.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/comment.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/container.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/at-rule.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/list.d.ts","../../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/postcss.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/runtime.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/importGlob.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/metadata.d.ts","../../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/index.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/environment-Ddx0EDtY.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/index-Y6kQUiCB.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/index.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/environment.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/environment.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/config.Crbj2GAb.d.ts","../../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/trace-mapping.d-DLVdEqOp.d.ts","../../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/index-CCsqCcr7.d.ts","../../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/index.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/environment.CzISCQ7o.d.ts","../../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/client.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/manager.d.ts","../../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/manager.d.ts","../../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/server.d.ts","../../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/source-map.d.ts","../../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/utils.d.ts","../../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/utils.d.ts","../../node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.d.cts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/benchmark.JVlTzojj.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/reporters.DAfKSDh5.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/vite.8fk186v-.d.ts","../../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/chai.d.cts","../../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.d.ts","../../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/index.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/suite.BMWOKiTe.d.ts","../../node_modules/.pnpm/@vitest+mocker@2.1.2_@vitest+spy@2.1.2_vite@5.4.8_@types+node@22.7.4_/node_modules/@vitest/mocker/dist/types-yDMq238q.d.ts","../../node_modules/.pnpm/@vitest+mocker@2.1.2_@vitest+spy@2.1.2_vite@5.4.8_@types+node@22.7.4_/node_modules/@vitest/mocker/dist/index.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/mocker.cRtM890J.d.ts","../../node_modules/.pnpm/@vitest+spy@2.1.2/node_modules/@vitest/spy/dist/index.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/worker.Chrs-_NL.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/worker.Qtv8v5nL.d.ts","../../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/index.d.ts","../../test/createAxiosAndFetchSharedClient.test.ts","../../test/createCustomSharedClient.test.ts","../../test/createOpenApiGenerator.test.ts","../../test/defineRoutes.test.ts","../../test/expressAndSupertest.test.ts"],"fileIdsList":[[70,112,127,163,173],[70,112,127,163],[70,112],[70,112,124,127,163,165,166,167],[70,112,167,168,172,174],[70,112,170],[70,112,169],[70,71,112],[70,111,112],[70,112,117,147],[70,112,113,118,124,125,132,144,155],[70,112,113,114,124,132],[70,112,115,156],[70,112,116,117,125,133],[70,112,117,144,152],[70,112,118,120,124,132],[70,111,112,119],[70,112,120,121],[70,112,124],[70,112,122,124],[70,111,112,124],[70,112,124,125,126,144,155],[70,112,124,125,126,139,144,147],[70,109,112,160],[70,109,112,120,124,127,132,144,155],[70,112,124,125,127,128,132,144,152,155],[70,112,127,129,144,152,155],[70,112,124,130],[70,112,131,155,160],[70,112,120,124,132,144],[70,112,133],[70,112,134],[70,111,112,135],[70,71,72,111,112,113,114,115,116,117,118,119,120,121,122,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161],[70,112,137],[70,112,138],[70,112,124,139,140],[70,112,139,141,156,158],[70,112,124,144,145,146,147],[70,112,144,146],[70,112,144,145],[70,112,147],[70,112,148],[70,71,112,144],[70,112,124,150,151],[70,112,150,151],[70,112,117,132,144,152],[70,112,153],[112],[69,70,71,72,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162],[70,112,132,154],[70,112,127,138,155],[70,112,117,156],[70,112,144,157],[70,112,131,158],[70,112,159],[70,112,117,124,126,135,144,155,158,160],[70,112,144,161],[70,112,125,144,163,164],[70,112,127,163,170,171],[70,112,125,127,144,163,212],[70,112,213],[70,112,221,222,226],[70,112,283],[70,112,286],[70,112,222,223,226,227,229],[70,112,222],[70,112,222,223,226],[70,112,222,223],[70,112,276],[70,112,261],[70,112,219,261],[70,112,219,261,262],[70,112,264],[70,112,272],[70,112,225],[70,112,219,224],[70,112,217],[70,112,217,218,219,221],[70,112,219],[70,112,228],[70,112,253],[70,112,251,253],[70,112,242,250,251,252,254],[70,112,240],[70,112,243,248,253,256],[70,112,239,256],[70,112,243,244,247,248,249,256],[70,112,243,244,245,247,248,256],[70,112,240,241,242,243,244,248,249,250,252,253,254,256],[70,112,238,240,241,242,243,244,245,247,248,249,250,251,252,253,254,255],[70,112,238,256],[70,112,243,245,246,248,249,256],[70,112,247,256],[70,112,248,249,253,256],[70,112,241,251],[70,112,231,232],[70,112,220],[70,81,85,112,155],[70,81,112,144,155],[70,76,112],[70,78,81,112,152,155],[70,112,132,152],[70,112,163],[70,76,112,163],[70,78,81,112,132,155],[70,73,74,77,80,112,124,144,155],[70,81,88,112],[70,73,79,112],[70,81,102,103,112],[70,77,81,112,147,155,163],[70,102,112,163],[70,75,76,112,163],[70,81,112],[70,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,103,104,105,106,107,108,112],[70,81,96,112],[70,81,88,89,112],[70,79,81,89,90,112],[70,80,112],[70,73,76,81,112],[70,81,85,89,90,112],[70,85,112],[70,79,81,84,112,155],[70,73,78,81,88,112],[70,112,144],[70,76,81,102,112,160,163],[70,112,267,268],[70,112,267],[70,112,260,267,268,281],[70,112,124,125,127,128,129,132,144,152,155,161,163,232,233,234,235,236,237,256,257,258,259],[70,112,233,234,235,236],[70,112,233,234,235],[70,112,233],[70,112,234],[70,112,232],[70,112,230,277,278,292],[70,112,219,230,263,265,292],[70,112,287],[70,112,125,144,219,222,230,260,263,266,269,270,271,273,274,275,279,281,282,292],[70,112,230,277,278,279,292],[70,112,260,280],[70,112,230,263,266,269,270,292],[70,112,160,290],[70,112,125,144,160,219,222,226,230,260,263,265,266,269,270,271,273,274,275,277,278,279,280,281,282,284,285,287,288,289,290,291,292],[70,112,208],[59,70,112],[59,70,112,182,207],[70,112,184,207],[59,70,112,183,184,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206],[59,70,112,184,185,207],[59,70,112,184,185],[59,70,112,184,207],[59,70,112,184],[70,112,184],[59,70,112,184,196,207],[59,70,112,184,190,200,207],[58,70,112],[47,48,58,70,112],[49,50,70,112],[47,48,49,51,52,56,70,112],[48,49,70,112],[57,70,112],[49,70,112],[47,48,49,52,53,54,55,70,112],[61,64,65,66,70,112],[67,70,112],[59,60,61,70,112],[61,62,70,112],[59,60,62,70,112],[59,61,64,65,70,112,175],[70,112,176],[61,64,65,70,112,178],[70,112,179],[60,61,62,63,70,112],[59,64,70,112,181,209],[70,112,210],[64,70,112,214],[70,112,215],[59,61,62,70,112],[59,64,66,68,70,112,180,292],[59,64,70,112,292],[59,64,70,112,181,211,292],[59,64,70,112,174,175,177,214,215,292]],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"9e8ca8ed051c2697578c023d9c29d6df689a083561feba5c14aedee895853999","affectsGlobalScope":true,"impliedFormat":1},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"45d8ccb3dfd57355eb29749919142d4321a0aa4df6acdfc54e30433d7176600a","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"1a94697425a99354df73d9c8291e2ecd4dddd370aed4023c2d6dee6cccb32666","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3f9fc0ec0b96a9e642f11eda09c0be83a61c7b336977f8b9fdb1e9788e925fe","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"5487b97cfa28b26b4a9ef0770f872bdbebd4c46124858de00f242c3eed7519f4","impliedFormat":1},{"version":"7a01f546ace66019156e4232a1bee2fabc2f8eabeb052473d926ee1693956265","impliedFormat":1},{"version":"fb53b1c6a6c799b7e3cc2de3fb5c9a1c04a1c60d4380a37792d84c5f8b33933b","impliedFormat":1},{"version":"8485b6da53ec35637d072e516631d25dae53984500de70a6989058f24354666f","impliedFormat":1},{"version":"ebe80346928736532e4a822154eb77f57ef3389dbe2b3ba4e571366a15448ef2","impliedFormat":1},{"version":"c2cb3c8ff388781258ea9ddbcd8a947f751bddd6886e1d3b3ea09ddaa895df80","impliedFormat":1},{"version":"f672c876c1a04a223cf2023b3d91e8a52bb1544c576b81bf64a8fec82be9969c","impliedFormat":1},{"version":"98a9cc18f661d28e6bd31c436e1984f3980f35e0f0aa9cf795c54f8ccb667ffe","impliedFormat":1},{"version":"c76b0c5727302341d0bdfa2cc2cee4b19ff185b554edb6e8543f0661d8487116","impliedFormat":1},{"version":"2a317fff5810a628d205a507998a77521120b462b03d36babf6eb387da991bee","impliedFormat":1},{"version":"f5ef066942e4f0bd98200aa6a6694b831e73200c9b3ade77ad0aa2409e8fe1b1","impliedFormat":1},{"version":"b9e99cd94f4166a245f5158f7286c05406e2a4c694619bceb7a4f3519d1d768e","impliedFormat":1},{"version":"5568d7c32e5cf5f35e092649f4e5e168c3114c800b1d7545b7ae5e0415704802","impliedFormat":1},{"version":"be139d52709c57e683b367f8e3118a064130c670cd6814e7e5b927adaf2fbb21","signature":"c7c176a5a8a12c6b3d5b28c95320448f17c7d5438485c53a086dea69ed2e6801"},{"version":"5de7af0dec19e520349c8e056c5c378e43629a8e3fcb82a7926834734f35c632","signature":"95c135e1dba8b467665b4e8d8182549223b233077505b2a457722b59d8160670"},{"version":"e0dbb166796de66935d4feda4abd94f0e692eb43cdf73979f939fa4c44f6a1c5","signature":"31a0247df93a17d637c31a4381e08db07ca42816bee5d84a7dfa3e4cbdbbf16e"},{"version":"454671610b0389f294e74f0ffbf4d72c926d9e11da889d359674ae4e3224ef6b","signature":"70aad179112a492efbeed445504038ea12e90db5f6ecf452bd13b606e9263cd9"},{"version":"76c0556d36524e5a16ef84d239fb3992c7cdef0a5535f5f63349917cca1c414c","signature":"c4acec2b887b9279da570a4f056c51a61988231afabbd200590fff738e71e422"},{"version":"5121742e05e48d112d780fe27f600499ffc950db4b605cf27efda628e81311d0","signature":"b129afb002284dfa6b890a5b67da6ce025a68245ae935678ac8ac1fe60bae382"},{"version":"01ba761ce6d75a4142858a053f45d64d255e057049ab1cc4d9a93e76b8b5c444","impliedFormat":99},{"version":"db0b4592f8b44aa0df42d3ba5f8ab20e64fe84d30cde930e572a4465c7b0ccd6","signature":"002ace4931001d9ea1f3717a109a41bf16dcfbb33fe8d9e848d8f2b791034eaf"},"2aa4a640d2afabc591928da1d45c45eedb060a69c17a90fa5e7fa0828aa15e27",{"version":"613b21ccdf3be6329d56e6caa13b258c842edf8377be7bc9f014ed14cdcfc308","affectsGlobalScope":true,"impliedFormat":1},{"version":"2d1319e6b5d0efd8c5eae07eb864a00102151e8b9afddd2d45db52e9aae002c4","affectsGlobalScope":true,"impliedFormat":1},{"version":"f6114eb1e8f70ec08816bdaa6ec740a0a7a01f25743e36f655f00157be394374","impliedFormat":1},{"version":"7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"4d2b0eb911816f66abe4970898f97a2cfc902bcd743cbfa5017fad79f7ef90d8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","impliedFormat":1},{"version":"24b8685c62562f5d98615c5a0c1d05f297cf5065f15246edfe99e81ec4c0e011","impliedFormat":1},{"version":"93507c745e8f29090efb99399c3f77bec07db17acd75634249dc92f961573387","impliedFormat":1},{"version":"339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"bb2cd9339d0201e7e78ccb6ff2f71aac103934bf35eaaa37e139ac2b68af0db8","affectsGlobalScope":true,"impliedFormat":1},{"version":"76103716ba397bbb61f9fa9c9090dca59f39f9047cb1352b2179c5d8e7f4e8d0","impliedFormat":1},{"version":"53eac70430b30089a3a1959d8306b0f9cfaf0de75224b68ef25243e0b5ad1ca3","affectsGlobalScope":true,"impliedFormat":1},{"version":"4314c7a11517e221f7296b46547dbc4df047115b182f544d072bdccffa57fc72","impliedFormat":1},{"version":"115971d64632ea4742b5b115fb64ed04bcaae2c3c342f13d9ba7e3f9ee39c4e7","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb","impliedFormat":1},{"version":"46e07db372dd75edc1a26e68f16d1b7ffb34b7ab3db5cdb3e391a3604ad7bb7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"24642567d3729bcc545bacb65ee7c0db423400c7f1ef757cab25d05650064f98","impliedFormat":1},{"version":"e6f5a38687bebe43a4cef426b69d34373ef68be9a6b1538ec0a371e69f309354","impliedFormat":1},{"version":"a6bf63d17324010ca1fbf0389cab83f93389bb0b9a01dc8a346d092f65b3605f","impliedFormat":1},{"version":"e009777bef4b023a999b2e5b9a136ff2cde37dc3f77c744a02840f05b18be8ff","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true,"impliedFormat":1},{"version":"f501a53b94ba382d9ba396a5c486969a3abc68309828fa67f916035f5d37fe2b","affectsGlobalScope":true,"impliedFormat":1},{"version":"c956ba45704d4a97f7a96923a307a6203bc0e7c4c532930d4c8ca261eaaff32a","impliedFormat":1},{"version":"ab0e88d33ccf15d8b3c891038b5a16094b0dd7e860ab0e2ba08da4384afce02b","impliedFormat":1},{"version":"954580f86c8e2a4abd5dcd1bcdf1a4c7e012495f1c39e058dc738bc93024642a","impliedFormat":1},{"version":"fa56be9b96f747e93b895d8dc2aa4fb9f0816743e6e2abb9d60705e88d4743a2","impliedFormat":1},{"version":"8257c55ff6bff6169142a35fce6811b511d857b4ae4f522cdb6ce20fd2116b2c","impliedFormat":1},{"version":"6d386bc0d7f3afa1d401afc3e00ed6b09205a354a9795196caed937494a713e6","impliedFormat":1},{"version":"3a9e5dddbd6ca9507d0c06a557535ba2224a94a2b0f3e146e8215f93b7e5b3a8","affectsGlobalScope":true,"impliedFormat":1},{"version":"d8b56de03a9f79f3fc1ac3a01a0d63bb48cc15f95a6b95549b4fb420e6030973","impliedFormat":1},{"version":"b1b6ee0d012aeebe11d776a155d8979730440082797695fc8e2a5c326285678f","impliedFormat":1},{"version":"45875bcae57270aeb3ebc73a5e3fb4c7b9d91d6b045f107c1d8513c28ece71c0","impliedFormat":1},{"version":"3c36ab47df4668254ccc170fc42e7d5116fd86a7e408d8dc220e559837cd2bbb","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f6abdaf8764ef01a552a958f45e795b5e79153b87ddad3af5264b86d2681b72","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"c6b4e0a02545304935ecbf7de7a8e056a31bb50939b5b321c9d50a405b5a0bba","impliedFormat":1},{"version":"c86b9afa9b39b12db8e877d23b48888d80f26e1fe72a95f58552746a6e1fa4fe","impliedFormat":1},{"version":"e432b0e3761ca9ba734bdd41e19a75fec1454ca8e9769bfdf8b31011854cf06a","impliedFormat":1},{"version":"e1120271ebbc9952fdc7b2dd3e145560e52e06956345e6fdf91d70ca4886464f","impliedFormat":1},{"version":"15c5e91b5f08be34a78e3d976179bf5b7a9cc28dc0ef1ffebffeb3c7812a2dca","impliedFormat":1},{"version":"a8f06c2382a30b7cb89ad2dfc48fc3b2b490f3dafcd839dadc008e4e5d57031d","impliedFormat":1},{"version":"07b9d3b7204d931acc29269c98ac3aac87ebcba6e05141552d42a4c17f895aa4","impliedFormat":1},{"version":"269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","impliedFormat":1},{"version":"93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","impliedFormat":1},{"version":"1425f76ac97ce8617d1e2fa79e9a14e0fd1cfdaa155e13d4e92403a468177bc2","affectsGlobalScope":true,"impliedFormat":1},{"version":"2754d8221d77c7b382096651925eb476f1066b3348da4b73fe71ced7801edada","impliedFormat":1},{"version":"cca97c55398b8699fa3a96ef261b01d200ed2a44d2983586ab1a81d7d7b23cd9","affectsGlobalScope":true,"impliedFormat":1},{"version":"bef91efa0baea5d0e0f0f27b574a8bc100ce62a6d7e70220a0d58af6acab5e89","affectsGlobalScope":true,"impliedFormat":1},{"version":"f59493f68eade5200559e5016b5855f7d12e6381eb6cab9ad8a379af367b3b2d","impliedFormat":1},{"version":"125e3472965f529de239d2bc85b54579fed8e0b060d1d04de6576fb910a6ec7f","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"18f5c7c4ad71748cffdd42e829398acdfd2d150a887e5f07aae4f2acab68e71b","affectsGlobalScope":true,"impliedFormat":1},{"version":"72ed3074450a4a315063278f046637afdeea90aa72b2292a7976958ceafc344a","affectsGlobalScope":true,"impliedFormat":1},{"version":"a5c09990a37469b0311a92ce8feeb8682e83918723aedbd445bd7a0f510eaaa3","impliedFormat":1},{"version":"6b29aea17044029b257e5bd4e3e4f765cd72b8d3c11c753f363ab92cc3f9f947","impliedFormat":1},{"version":"ac5ed35e649cdd8143131964336ab9076937fa91802ec760b3ea63b59175c10a","impliedFormat":1},{"version":"d008cf1330c86b37a8128265c80795397c287cecff273bc3ce3a4883405f5112","affectsGlobalScope":true,"impliedFormat":1},{"version":"78dc0513cc4f1642906b74dda42146bcbd9df7401717d6e89ea6d72d12ecb539","impliedFormat":1},{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true,"impliedFormat":1},{"version":"f2b6058d3dd78c1b4dafc97083c5d44bdfbf4155194044bd17b8fcca554e766a","impliedFormat":1},{"version":"84e3bbd6f80983d468260fdbfeeb431cc81f7ea98d284d836e4d168e36875e86","impliedFormat":1},{"version":"aad5ffa61406b8e19524738fcf0e6fda8b3485bba98626268fdf252d1b2b630a","impliedFormat":1},{"version":"16d51f964ec125ad2024cf03f0af444b3bc3ec3614d9345cc54d09bab45c9a4c","impliedFormat":1},{"version":"ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc","impliedFormat":1},{"version":"352fc8497a30bc806d7defa0043d85802e5f35a7688731ee9a21456f5cb32a94","affectsGlobalScope":true,"impliedFormat":1},{"version":"5b9ecf7da4d71cf3832dbb8336150fa924631811f488ad4690c2dfec2b4fb1d7","impliedFormat":1},{"version":"951c85f75aac041dddbedfedf565886a7b494e29ec1532e2a9b4a6180560b50e","impliedFormat":1},{"version":"f463d61cf39c3a6a5f96cdf7adfdb72a0b1d663f7b5d5b6dd042adba835430c2","impliedFormat":1},{"version":"f7a9cb83c8fbc081a8b605880d191e0d0527cde2c1b2b2b623beca8f0203a2cd","impliedFormat":1},{"version":"6d829824ead8999f87b6df21200df3c6150391b894b4e80662caa462bd48d073","impliedFormat":1},{"version":"afc559c1b93df37c25aef6b3dfa2d64325b0e112e887ee18bf7e6f4ec383fc90","impliedFormat":1},{"version":"43cdd474c5aa3340da4816bb8f1ae7f3b1bcf9e70d997afc36a0f2c432378c84","impliedFormat":1},{"version":"f5dfb17a2c06fab0dbb847629d703e98b62ef6022e924cf1d1b71cf5a96df166","signature":"d1403ad5fbb688fcbcda3b43a7545a6e463dd3ab30faefaa9597b210f70ac857"},"fa00eede2b2640bcfec133440377a75fc7d4647affa0aa68d1dad3626ec441db",{"version":"69571e322ffb287ea739ba2a674369b3790974f717e8a47d969f84543cde2da2","signature":"4714df73aa332341fd02da657beb85950e4c60eed5c7520b203e5b52b15ed992"},{"version":"4d651811ba936eb2d1f08d60df68da16abfbef58f1f505fb1caa8c3821eb99c4","signature":"fb9115021bdbf31bcf01e37dc768c57611cc03e2163c33894c9b007a832aeffd"},"8b3b10df45a1ec07333e61a4b2ed7c01a2ca295688db942bc1220d328c86eb72",{"version":"cc3e30832aff12a575919d59eb3d680ca7cc999e1041bb0fc489dbe0276b066b","impliedFormat":1},{"version":"dd804b99db086f2f0e24bb373d2a1e9d9177f32f5c8f2c7b37c99accdf835e0c","impliedFormat":1},{"version":"e70f03e85bc8a2385e538a2db0c9ee532f6a9b346872aa809f173a26df7caee1","impliedFormat":1},{"version":"264808a845721a9f3df608a5e7ed12537f976d1645f20cbb448b106068f82332","impliedFormat":1},{"version":"8d484f5d6fd888f53e7cc21957ec2370461c73d230efb3467b9fb1822901535b","impliedFormat":1},{"version":"df73b0c2aa1ffa4a9aebd72baee78edf77ce5023d4476c04eadadbcdeb2964dc","impliedFormat":1},{"version":"065cbd81319d18ffc3b81100fbc60da26daf7fa090b26edf7dd3cc8c1a6cfbc5","impliedFormat":1},{"version":"771c436459c7a2ac2604ffa55a3abd76ffe8cae6aeae700d749f0fa5e8869ff6","impliedFormat":1},{"version":"7d4a2dae1a1ee3b99563747fa815076956911a833954deed5a4aa2d9207df167","impliedFormat":1},{"version":"45f6cd001ba50294b3e9a43800b22e0798cdcdc20c214cafd55d4d7d1914c331","impliedFormat":1},{"version":"b81b383239d2f4f14515331d7017febcb23786d90c5acc9688a891010fe25d4c","impliedFormat":1},{"version":"c60f24b4fd55376e4e095914d8f5345f63b7028d50fc8a0b7ec930f82777cacf","impliedFormat":1},{"version":"5754e79fbbfbb921b60ca1ad35cfbb5940733d93110bb1a935584f90cedb1c68","impliedFormat":1},{"version":"f7fcb70b90e9664b1ff1fb8566d3af99ca1a057d0dcfb94fb69b430463acba27","impliedFormat":1},{"version":"fb3af1e7369a6a52e0382612036ddcea2d089cdb0cccadc968a975043621e5fa","impliedFormat":1},{"version":"51353ffcc4bec12870c1435205dcaedab91ef108123017fd50fe8c3aed2bec04","impliedFormat":1},{"version":"e26befbe9607e9915734929db869fd83943f66e08c8e59d7308c14f6b6e755a3","impliedFormat":1},{"version":"4f596be4c3cb6ab63476dfa81bfe5f2a75768b6fd966d4c716411b4daa98df11","impliedFormat":1},{"version":"6d0e44cb89017602b13264823b15ada2a38e2ccb2a831c3e57680a0eb57d4bed","impliedFormat":1},{"version":"5e3f90d8fbf438ecb335d40e7a830f8deba1f045a2c3a27a8f5a4cdf8f499422","impliedFormat":1},{"version":"3a98713a36fe040df4d7e10a9e57a983f814f5cac42d3fe7919a342a6b9c103f","impliedFormat":1},{"version":"5dbaf247d7887721b20d8cf0a127460782ebbdc4285868f831a2f48104f034b5","impliedFormat":1},{"version":"b44d4ecd18d153d893eb38bfd827c0d624ed6f8fed4d9622489d76b3e4847067","impliedFormat":1},{"version":"23a12ab68ec3b350709bc4c15ddd34d8afa5e94dfccb1346f663f2c4bdb4334a","impliedFormat":1},{"version":"c9dfb06ca7c62fc5a95d33362f66c2bf5bf78d61ab433e62ec44190ea4012910","impliedFormat":1},{"version":"8d8b8fea19a532864502cbe5b298aadc194b970d511998342e38e4b9dea98c48","impliedFormat":1},{"version":"97479d4a4ddc4f4db849e5d6daadda8d986f5a7c580a0d79b3763a536a62268f","impliedFormat":1},{"version":"7efebf1092b8e7dfd08b0e54ec7d86dfabfd505f820d89351d957bfbc0bb3db2","impliedFormat":1},{"version":"032ccc910e4f1baf0355a2e43bc535caec36b1e916e64491ec2cabea5593593b","impliedFormat":1},{"version":"172d26cd2a145e1d1ce28734488e5e5d777a8aba2b1d158e897ba084d251eac7","signature":"5ad4a590a49e81a866a75c7fbb8ed2e83ab0930d5ae51f7156dba5284867ef20"},"5379bd2adb109cb6c15e7f0367c2eb1986d837f9977f50915afe4fc1759522ba",{"version":"8d48b8f8a377ade8dd1f000625bc276eea067f2529cc9cafdf082d17142107d6","impliedFormat":1},{"version":"214f291323316651737db8ca0db4c14ae568a429e59fc5b4f364dd80fe72d5f6","impliedFormat":1},{"version":"76232dbb982272b182a76ad8745a9b02724dc9896e2328ce360e2c56c64c9778","impliedFormat":1},{"version":"30074783847766ab26c1da52664149c5826c25c78dfed680f840faadad5bae0e","signature":"a03049a303d95f933af688a1c541867127a1226a4a200325369c02a39320bab7"},"c16631ce27bbed5b2fe93a3b5a9b76c22b64c909633e9f9a2cca997bc890ac51",{"version":"369ba5259e66ca8c7d35e3234f7a2a0863a770fdb8266505747c65cf346a0804","impliedFormat":99},{"version":"86ecd6bc8313be39460480af6e8eed773e411781a606b1ac4354d4d16a32ed69","impliedFormat":99},{"version":"d2e64a6f25013b099e83bfadb2c388d7bef3e8f3fdb25528225bbc841e7e7e3a","impliedFormat":99},{"version":"f147b6710441cf3ec3234adf63b0593ce5e8c9b692959d21d3babc8454bcf743","impliedFormat":99},{"version":"e96d5373a66c2cfbbc7e6642cf274055aa2c7ff6bd37be7480c66faf9804db6d","impliedFormat":99},{"version":"dfff4c4041d7f80ff6d115aff809f2e5f0083b08ad2bb36630d7343227840445","impliedFormat":99},{"version":"cd73b41ae4f5513b2d29d01ff50afbbe83004af2a88c91d56bf83b8d2c682724","impliedFormat":99},{"version":"7c553fc9e34773ddbaabe0fa1367d4b109101d0868a008f11042bee24b5a925d","impliedFormat":99},{"version":"9962ce696fbdce2421d883ca4b062a54f982496625437ae4d3633376c5ad4a80","impliedFormat":99},{"version":"05c7aef6a4e496b93c2e682cced8903c0dfe6340d04f3fe616176e2782193435","impliedFormat":99},{"version":"a6a10f8ad941a4025cdc69fb697b9c06b99356c36716591fcaea2a7b9034dba8","impliedFormat":99},{"version":"4c17183a07a63bea2653fbfc0a942b027160ddbee823024789a415f9589de327","impliedFormat":99},{"version":"500a67e158e4025f27570ab6a99831680852bb45a44d4c3647ab7567feb1fb4c","impliedFormat":99},{"version":"631737d061b10b7ad67fc09120ec13ce86c3c269c1cfbedef08aaf638ee224d1","impliedFormat":99},{"version":"785b9d575b49124ce01b46f5b9402157c7611e6532effa562ac6aebec0074dfc","impliedFormat":1},{"version":"e58a3ce75105c1557e34fab7408942d77374e047c16383e80880ed1220166dfa","affectsGlobalScope":true,"impliedFormat":1},{"version":"282f98006ed7fa9bb2cd9bdbe2524595cfc4bcd58a0bb3232e4519f2138df811","impliedFormat":1},{"version":"6222e987b58abfe92597e1273ad7233626285bc2d78409d4a7b113d81a83496b","impliedFormat":1},{"version":"cbe726263ae9a7bf32352380f7e8ab66ee25b3457137e316929269c19e18a2be","impliedFormat":1},{"version":"8b96046bf5fb0a815cba6b0880d9f97b7f3a93cf187e8dcfe8e2792e97f38f87","impliedFormat":99},{"version":"bacf2c84cf448b2cd02c717ad46c3d7fd530e0c91282888c923ad64810a4d511","affectsGlobalScope":true,"impliedFormat":1},{"version":"402e5c534fb2b85fa771170595db3ac0dd532112c8fa44fc23f233bc6967488b","impliedFormat":1},{"version":"8885cf05f3e2abf117590bbb951dcf6359e3e5ac462af1c901cfd24c6a6472e2","impliedFormat":1},{"version":"4d979e3c12ffb6497d2b1dc5613130196d986fff764c4526360c0716a162e7e7","impliedFormat":1},{"version":"e61df3640a38d535fd4bc9f4a53aef17c296b58dc4b6394fd576b808dd2fe5e6","impliedFormat":1},{"version":"80781460eca408fe8d2937d9fdbbb780d6aac35f549621e6200c9bee1da5b8fe","impliedFormat":1},{"version":"4719c209b9c00b579553859407a7e5dcfaa1c472994bd62aa5dd3cc0757eb077","impliedFormat":1},{"version":"7ec359bbc29b69d4063fe7dad0baaf35f1856f914db16b3f4f6e3e1bca4099fa","impliedFormat":1},{"version":"b9261ac3e9944d3d72c5ee4cf888ad35d9743a5563405c6963c4e43ee3708ca4","impliedFormat":1},{"version":"c84fd54e8400def0d1ef1569cafd02e9f39a622df9fa69b57ccc82128856b916","impliedFormat":1},{"version":"a022503e75d6953d0e82c2c564508a5c7f8556fad5d7f971372d2d40479e4034","impliedFormat":1},{"version":"2ed6489ef46eb61442d067c08e87e3db501c0bfb2837eee4041a27bf3e792bb0","impliedFormat":1},{"version":"644491cde678bd462bb922c1d0cfab8f17d626b195ccb7f008612dc31f445d2d","impliedFormat":1},{"version":"d60fe6d59d4e19ecc65359490b8535e359ca4b760d2cdb56897ca75d09d41ba3","impliedFormat":1},{"version":"f45a2a8b1777ecb50ed65e1a04bb899d4b676529b7921bd5d69b08573a00c832","impliedFormat":1},{"version":"774b783046ba3d473948132d28a69f52a295b2f378f2939304118ba571b1355e","impliedFormat":1},{"version":"b5734e05c787a40e4f9efe71f16683c5f7dc3bdb0de7c04440c855bd000f8fa7","impliedFormat":1},{"version":"14ba97f0907144771331e1349fdccb5a13526eba0647e6b447e572376d811b6f","impliedFormat":1},{"version":"2a771d907aebf9391ac1f50e4ad37952943515eeea0dcc7e78aa08f508294668","impliedFormat":1},{"version":"7165050eddaed878c2d2cd3cafcaf171072ac39e586a048c0603712b5555f536","impliedFormat":1},{"version":"82e687ebd99518bc63ea04b0c3810fb6e50aa6942decd0ca6f7a56d9b9a212a6","impliedFormat":99},{"version":"7f698624bbbb060ece7c0e51b7236520ebada74b747d7523c7df376453ed6fea","impliedFormat":1},{"version":"8f07f2b6514744ac96e51d7cb8518c0f4de319471237ea10cf688b8d0e9d0225","impliedFormat":1},{"version":"9ae0ca65717af0d3b554a26fd333ad9c78ad3910ad4b22140ff02acb63076927","impliedFormat":99},{"version":"e01ea380015ed698c3c0e2ccd0db72f3fc3ef1abc4519f122aa1c1a8d419a505","impliedFormat":99},{"version":"9e2534be8a9338e750d24acc6076680d49b1643ae993c74510776a92af0c1604","impliedFormat":99},{"version":"c266ab6ddc3c29b4dd77a6f0d0eb4df7dab76d066e385171d88cb97c1120e747","impliedFormat":99},{"version":"e3225dc0bec183183509d290f641786245e6652bc3dce755f7ef404060693c35","impliedFormat":99},{"version":"f2d1a59a658165341b0e2b7879aa2e19ea6a709146b2d3f70ee8a07159d3d08e","impliedFormat":99},{"version":"676ee18819ba49ed188477aa451d24c727273e54e52ce1f285f6e510aa1ad257","impliedFormat":99},{"version":"e6233e1c976265e85aa8ad76c3881febe6264cb06ae3136f0257e1eab4a6cc5a","impliedFormat":99},{"version":"3a07ebaeb3b96c1e7a5fc0588364a8e58c74efd63b62f64b34c33b01907dc320","impliedFormat":99},{"version":"b1e92c7f8608744a7e40c636f7096e98d0dafe2c36aa6ba31b5f5a6c22794e37","impliedFormat":99},{"version":"97c77e6bee16334203cb776e6a2c0ccd4d8b9f1f584a1e3f5aacbf9e8fb618a8","impliedFormat":99},{"version":"7f8ea3140f0c2d102ff2d92ce2ce7fb33d1d209a851032332658a0dd081b0b8e","impliedFormat":99},{"version":"a0e40a10412a69609cbd9b157169c3011b080e66ef46a6370cd1d069a53eb52b","impliedFormat":99},{"version":"b7e28e06011460436d5c2ec2996846ac0c451e135357fc5a7269e5665a32fbd7","impliedFormat":99},{"version":"9a690435fa5e89ac3a0105d793c1ae21e1751ac2a912847de925107aabb9c9c0","impliedFormat":99},{"version":"9f3e99401b5bfdcb2ff75be940e02402b5c23cf8b4f8d0ba552c7d2d97c36568","impliedFormat":99},{"version":"1c65bde9dc8d609b4e01c929391461576e26c5db0d6bfafb666f7fe7619c9e95","impliedFormat":99},{"version":"e666e31d323fef5642f87db0da48a83e58f0aaf9e3823e87eabd8ec7e0441a36","impliedFormat":99},{"version":"69bf2422313487956e4dacf049f30cb91b34968912058d244cb19e4baa24da97","impliedFormat":1},{"version":"112c59da5f9cf6c54a36f669ece3901164dd3c8d45a7481b21ee96dc7bc814a2","impliedFormat":99},{"version":"fa5808c7536ef07ac68288c034f241ac843de42e23fcfcb703c5d1e05c909203","impliedFormat":99},{"version":"68008de4f1088f5f6cc034ac07ee01bede35590d52896c6586c8a0a988a1503e","impliedFormat":99},{"version":"48c411efce1848d1ed55de41d7deb93cbf7c04080912fd87aa517ed25ef42639","affectsGlobalScope":true,"impliedFormat":1},{"version":"11469e21ce79e01ee7e9e0487c69af39f8829e9b8dbb6d145696394c05025a01","affectsGlobalScope":true,"impliedFormat":99},{"version":"fe2d63fcfdde197391b6b70daf7be8c02a60afa90754a5f4a04bdc367f62793d","impliedFormat":99},{"version":"9e2aab1f07250281a63148e3119cc145cba997be2a71850a1afb62c8ba25ea5f","impliedFormat":99},{"version":"deb6818c1889c5da9bc37d171db5855ca9b61f0caa84c734d41a678dfa931900","impliedFormat":99},{"version":"b4bb4551aea38feeb6dae35133789e8f00cc507da74c5c8627bc9170269eed5e","impliedFormat":99},{"version":"ac2414a284bdecfd6ab7b87578744ab056cd04dd574b17853cd76830ef5b72f2","impliedFormat":99},{"version":"83d63d0ede869e5c7e5659f678f6ae7082f2246e62b4640318da47e343137feb","impliedFormat":99},{"version":"c1ddffecc371c0844f7752422dc4a3c276518e6fe01fbe95047f344116548bd4","impliedFormat":99},{"version":"26ee12ad3beb23dcb0b78a390d46b38079e417b99fd1024706e55c66a564285e","impliedFormat":99},{"version":"7c6eabf07a22b6ca1eec0b8c0ece2715146a8cce44cb2cf61c757dcac87db2f6","affectsGlobalScope":true,"impliedFormat":99},{"version":"d78397ab96a178528d37d0eaa27252b0f74bc16b50b6d5119c64dea10c71994c","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"89910e26c04c22959c5192afd2e3d3803ca040e0b1a1e51452a304c4a554deb9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"c2008324d35aac983bae015587fbfa738f4598f1e28f4791ab84af0112bacc92","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"579bf12c76184aa5de39b04fcd079c9f6909e04f820f29919d0c8e776c18c7c8","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"d8300596ef3538edcf904b7cacec4a2515a1a9bc882dbcb763823e75a6b7dcd5","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"}],"root":[[60,65],67,68,[176,180],210,211,215,216,[293,297]],"options":{"declaration":true,"downlevelIteration":true,"esModuleInterop":true,"jsx":4,"module":5,"newLine":1,"noFallthroughCasesInSwitch":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":1},"referencedMap":[[174,1],[173,2],[212,3],[231,3],[168,4],[175,5],[171,3],[164,3],[169,6],[170,7],[71,8],[72,8],[111,9],[112,10],[113,11],[114,12],[115,13],[116,14],[117,15],[118,16],[119,17],[120,18],[121,18],[123,19],[122,20],[124,21],[125,22],[126,23],[110,24],[162,3],[127,25],[128,26],[129,27],[130,28],[131,29],[132,30],[133,31],[134,32],[135,33],[136,34],[137,35],[138,36],[139,37],[140,37],[141,38],[142,3],[143,3],[144,39],[146,40],[145,41],[147,42],[148,43],[149,44],[150,45],[151,46],[152,47],[153,48],[70,49],[69,3],[163,50],[154,51],[155,52],[156,53],[157,54],[158,55],[159,56],[160,57],[161,58],[167,3],[166,3],[165,59],[172,60],[213,61],[214,62],[282,3],[283,63],[284,64],[287,65],[286,3],[219,3],[230,66],[223,67],[227,68],[276,69],[277,70],[261,3],[264,71],[262,72],[263,73],[272,73],[265,74],[273,75],[289,3],[226,76],[225,77],[228,77],[218,78],[222,79],[275,78],[224,80],[217,3],[229,81],[66,3],[237,3],[181,3],[254,82],[252,83],[253,84],[241,85],[242,83],[249,86],[240,87],[245,88],[255,3],[246,89],[251,90],[256,91],[239,92],[247,93],[248,94],[243,95],[250,82],[244,96],[232,97],[238,3],[278,3],[220,3],[221,98],[45,3],[46,3],[8,3],[10,3],[9,3],[2,3],[11,3],[12,3],[13,3],[14,3],[15,3],[16,3],[17,3],[18,3],[3,3],[19,3],[4,3],[20,3],[24,3],[21,3],[22,3],[23,3],[25,3],[26,3],[27,3],[5,3],[28,3],[29,3],[30,3],[31,3],[6,3],[35,3],[32,3],[33,3],[34,3],[36,3],[7,3],[37,3],[42,3],[43,3],[38,3],[39,3],[40,3],[41,3],[1,3],[44,3],[88,99],[98,100],[87,99],[108,101],[79,102],[78,103],[107,104],[101,105],[106,106],[81,107],[95,108],[80,109],[104,110],[76,111],[75,104],[105,112],[77,113],[82,114],[83,3],[86,114],[73,3],[109,115],[99,116],[90,117],[91,118],[93,119],[89,120],[92,121],[102,104],[84,122],[85,123],[94,124],[74,125],[97,116],[96,114],[100,3],[103,126],[271,127],[268,128],[269,127],[274,129],[267,3],[260,130],[257,131],[236,132],[234,133],[233,3],[235,134],[258,3],[259,135],[279,136],[266,137],[270,3],[288,138],[280,139],[285,140],[281,141],[290,142],[291,143],[292,144],[209,145],[182,146],[184,147],[185,148],[207,149],[183,3],[186,150],[187,151],[188,3],[189,3],[190,146],[191,152],[192,153],[193,152],[194,146],[195,3],[196,154],[197,155],[198,151],[199,152],[201,156],[202,150],[200,151],[203,152],[204,3],[205,152],[206,3],[208,147],[59,157],[49,158],[51,159],[57,160],[53,3],[54,3],[52,161],[55,157],[47,3],[48,3],[58,162],[50,163],[56,164],[67,165],[68,166],[62,167],[63,168],[61,169],[176,170],[177,171],[179,172],[180,173],[178,3],[64,174],[210,175],[211,176],[60,3],[215,177],[216,178],[65,179],[293,180],[294,181],[295,182],[296,181],[297,183]],"version":"5.6.2"} \ No newline at end of file diff --git a/package.json b/package.json index d80c7b7..00102d0 100755 --- a/package.json +++ b/package.json @@ -6,22 +6,6 @@ "type": "git", "url": "git@github.com:JeromeBu/shared-routes.git" }, - "scripts": { - "typecheck": "tsc --noEmit", - "build": "pnpm build:cjs && pnpm build:esm # && pnpm build:deno", - "watch": "tsc -w & tsc -p tsconfig.esm.json -w", - "build:cjs": "tsc", - "build:esm": "rm -rf dist/esm && tsc -p tsconfig.esm.json && js2mjs dist/esm", - "build:deno": "denoify", - "test": "vitest", - "lint:check": "eslint . --ext .ts,.tsx", - "lint": "npm run lint:check -- --fix", - "_format": "prettier '**/*.{ts,tsx,json,md}'", - "format": "npm run _format -- --write", - "format:check": "npm run _format -- --list-different", - "make-lib-linkable": "pnpm build:cjs && pnpm build:esm && ts-node --skipProject scripts/make-dist-linkable.ts", - "prepare": "husky install" - }, "lint-staged": { "*.{ts,tsx}": [ "eslint --fix" @@ -38,9 +22,156 @@ "author": "u/jeromebu", "license": "MIT", "files": [ - "src/", - "dist/", - "!dist/tsconfig.tsbuildinfo" + "src/axios/createAxiosSharedClient.ts", + "src/axios/index.ts", + "src/configureCreateHttpClient.ts", + "src/createCustomSharedClient.ts", + "src/defineRoutes.ts", + "src/express/createExpressSharedRouter.ts", + "src/express/index.ts", + "src/fetch/createFetchSharedClient.ts", + "src/fetch/index.ts", + "src/fetch/queryParamsToString.ts", + "src/index.ts", + "src/openapi/createOpenApiGenerator.ts", + "src/openapi/index.ts", + "src/pathParameters.ts", + "src/supertest/createSupertestSharedClient.ts", + "src/supertest/index.ts", + "src/validations.ts", + "esm/src/axios/createAxiosSharedClient.d.ts", + "esm/src/axios/createAxiosSharedClient.mjs", + "esm/src/axios/createAxiosSharedClient.mjs.map", + "esm/src/axios/index.d.ts", + "esm/src/axios/index.mjs", + "esm/src/axios/index.mjs.map", + "esm/src/configureCreateHttpClient.d.ts", + "esm/src/configureCreateHttpClient.mjs", + "esm/src/configureCreateHttpClient.mjs.map", + "esm/src/createCustomSharedClient.d.ts", + "esm/src/createCustomSharedClient.mjs", + "esm/src/createCustomSharedClient.mjs.map", + "esm/src/defineRoutes.d.ts", + "esm/src/defineRoutes.mjs", + "esm/src/defineRoutes.mjs.map", + "esm/src/express/createExpressSharedRouter.d.ts", + "esm/src/express/createExpressSharedRouter.mjs", + "esm/src/express/createExpressSharedRouter.mjs.map", + "esm/src/express/index.d.ts", + "esm/src/express/index.mjs", + "esm/src/express/index.mjs.map", + "esm/src/fetch/createFetchSharedClient.d.ts", + "esm/src/fetch/createFetchSharedClient.mjs", + "esm/src/fetch/createFetchSharedClient.mjs.map", + "esm/src/fetch/index.d.ts", + "esm/src/fetch/index.mjs", + "esm/src/fetch/index.mjs.map", + "esm/src/fetch/queryParamsToString.d.ts", + "esm/src/fetch/queryParamsToString.mjs", + "esm/src/fetch/queryParamsToString.mjs.map", + "esm/src/index.d.ts", + "esm/src/index.mjs", + "esm/src/index.mjs.map", + "esm/src/openapi/createOpenApiGenerator.d.ts", + "esm/src/openapi/createOpenApiGenerator.mjs", + "esm/src/openapi/createOpenApiGenerator.mjs.map", + "esm/src/openapi/index.d.ts", + "esm/src/openapi/index.mjs", + "esm/src/openapi/index.mjs.map", + "esm/src/pathParameters.d.ts", + "esm/src/pathParameters.mjs", + "esm/src/pathParameters.mjs.map", + "esm/src/supertest/createSupertestSharedClient.d.ts", + "esm/src/supertest/createSupertestSharedClient.mjs", + "esm/src/supertest/createSupertestSharedClient.mjs.map", + "esm/src/supertest/index.d.ts", + "esm/src/supertest/index.mjs", + "esm/src/supertest/index.mjs.map", + "esm/src/validations.d.ts", + "esm/src/validations.mjs", + "esm/src/validations.mjs.map", + "esm/test/createAxiosAndFetchSharedClient.test.d.ts", + "esm/test/createAxiosAndFetchSharedClient.test.mjs", + "esm/test/createAxiosAndFetchSharedClient.test.mjs.map", + "esm/test/createCustomSharedClient.test.d.ts", + "esm/test/createCustomSharedClient.test.mjs", + "esm/test/createCustomSharedClient.test.mjs.map", + "esm/test/createOpenApiGenerator.test.d.ts", + "esm/test/createOpenApiGenerator.test.mjs", + "esm/test/createOpenApiGenerator.test.mjs.map", + "esm/test/defineRoutes.test.d.ts", + "esm/test/defineRoutes.test.mjs", + "esm/test/defineRoutes.test.mjs.map", + "esm/test/expressAndSupertest.test.d.ts", + "esm/test/expressAndSupertest.test.mjs", + "esm/test/expressAndSupertest.test.mjs.map", + "esm/tsconfig.esm.tsbuildinfo", + "src/axios/createAxiosSharedClient.d.ts", + "src/axios/createAxiosSharedClient.js", + "src/axios/createAxiosSharedClient.js.map", + "src/axios/index.d.ts", + "src/axios/index.js", + "src/axios/index.js.map", + "src/configureCreateHttpClient.d.ts", + "src/configureCreateHttpClient.js", + "src/configureCreateHttpClient.js.map", + "src/createCustomSharedClient.d.ts", + "src/createCustomSharedClient.js", + "src/createCustomSharedClient.js.map", + "src/defineRoutes.d.ts", + "src/defineRoutes.js", + "src/defineRoutes.js.map", + "src/express/createExpressSharedRouter.d.ts", + "src/express/createExpressSharedRouter.js", + "src/express/createExpressSharedRouter.js.map", + "src/express/index.d.ts", + "src/express/index.js", + "src/express/index.js.map", + "src/fetch/createFetchSharedClient.d.ts", + "src/fetch/createFetchSharedClient.js", + "src/fetch/createFetchSharedClient.js.map", + "src/fetch/index.d.ts", + "src/fetch/index.js", + "src/fetch/index.js.map", + "src/fetch/queryParamsToString.d.ts", + "src/fetch/queryParamsToString.js", + "src/fetch/queryParamsToString.js.map", + "src/index.d.ts", + "src/index.js", + "src/index.js.map", + "src/openapi/createOpenApiGenerator.d.ts", + "src/openapi/createOpenApiGenerator.js", + "src/openapi/createOpenApiGenerator.js.map", + "src/openapi/index.d.ts", + "src/openapi/index.js", + "src/openapi/index.js.map", + "src/pathParameters.d.ts", + "src/pathParameters.js", + "src/pathParameters.js.map", + "src/supertest/createSupertestSharedClient.d.ts", + "src/supertest/createSupertestSharedClient.js", + "src/supertest/createSupertestSharedClient.js.map", + "src/supertest/index.d.ts", + "src/supertest/index.js", + "src/supertest/index.js.map", + "src/validations.d.ts", + "src/validations.js", + "src/validations.js.map", + "test/createAxiosAndFetchSharedClient.test.d.ts", + "test/createAxiosAndFetchSharedClient.test.js", + "test/createAxiosAndFetchSharedClient.test.js.map", + "test/createCustomSharedClient.test.d.ts", + "test/createCustomSharedClient.test.js", + "test/createCustomSharedClient.test.js.map", + "test/createOpenApiGenerator.test.d.ts", + "test/createOpenApiGenerator.test.js", + "test/createOpenApiGenerator.test.js.map", + "test/defineRoutes.test.d.ts", + "test/defineRoutes.test.js", + "test/defineRoutes.test.js.map", + "test/expressAndSupertest.test.d.ts", + "test/expressAndSupertest.test.js", + "test/expressAndSupertest.test.js.map" ], "keywords": [], "homepage": "https://jeromebu.gitbook.io/shared-routes", diff --git a/src/axios/createAxiosSharedClient.d.ts b/src/axios/createAxiosSharedClient.d.ts new file mode 100644 index 0000000..30237a7 --- /dev/null +++ b/src/axios/createAxiosSharedClient.d.ts @@ -0,0 +1,6 @@ +import type { AxiosInstance } from "axios"; +import type { UnknownSharedRoute } from ".."; +import { HandlerCreator } from ".."; +import { ValidationOptions } from "../validations"; +export declare const createAxiosHandlerCreator: >(axios: AxiosInstance, options?: ValidationOptions) => HandlerCreator; +export declare const createAxiosSharedClient: >(sharedRouters: SharedRoutes, axios: AxiosInstance, validationOptions?: ValidationOptions) => import("..").HttpClient; diff --git a/src/axios/createAxiosSharedClient.js b/src/axios/createAxiosSharedClient.js new file mode 100644 index 0000000..c0256f6 --- /dev/null +++ b/src/axios/createAxiosSharedClient.js @@ -0,0 +1,147 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createAxiosSharedClient = exports.createAxiosHandlerCreator = void 0; +var __1 = require(".."); +var validations_1 = require("../validations"); +var toAxiosResponseType = { + arrayBuffer: "arraybuffer", + blob: "blob", + json: "json", + text: "text", +}; +var createAxiosHandlerCreator = function (axios, options) { + return function (routeName, routes, replaceParamsInUrl) { + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var route, _b, body, headers, queryParams, _c, data, status, rest, responseBody; + var _d; + if (_a === void 0) { _a = {}; } + var urlParams = _a.urlParams, params = __rest(_a, ["urlParams"]); + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + route = routes[routeName]; + _b = (options === null || options === void 0 ? void 0 : options.skipInputValidation) + ? params + : (0, validations_1.validateInputParams)(route, params, "axios", { withIssuesInMessage: true }), body = _b.body, headers = _b.headers, queryParams = _b.queryParams; + return [4 /*yield*/, axios.request({ + method: route.method, + url: replaceParamsInUrl(route.url, urlParams), + data: body, + params: queryParams, + responseType: toAxiosResponseType[route.responseType], + headers: __assign(__assign({}, axios.defaults.headers), (headers !== null && headers !== void 0 ? headers : {})), + })]; + case 1: + _c = _e.sent(), data = _c.data, status = _c.status, rest = __rest(_c, ["data", "status"]); + responseBody = (options === null || options === void 0 ? void 0 : options.skipResponseValidation) || + ((_d = options === null || options === void 0 ? void 0 : options.skipResponseValidationForStatuses) === null || _d === void 0 ? void 0 : _d.includes(status)) + ? data + : (0, validations_1.validateSchemaWithExplicitError)({ + adapterName: "axios", + checkedSchema: "responses", + responseStatus: status, + params: data, + route: route, + withIssuesInMessage: true, + }); + return [2 /*return*/, __assign(__assign({}, rest), { status: status, body: responseBody })]; + } + }); + }); + }; + }; +}; +exports.createAxiosHandlerCreator = createAxiosHandlerCreator; +var createAxiosSharedClient = function (sharedRouters, axios, validationOptions) { + return (0, __1.configureCreateHttpClient)((0, exports.createAxiosHandlerCreator)(axios, validationOptions))(sharedRouters); +}; +exports.createAxiosSharedClient = createAxiosSharedClient; +//# sourceMappingURL=createAxiosSharedClient.js.map \ No newline at end of file diff --git a/src/axios/createAxiosSharedClient.js.map b/src/axios/createAxiosSharedClient.js.map new file mode 100644 index 0000000..922f36a --- /dev/null +++ b/src/axios/createAxiosSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createAxiosSharedClient.js","sourceRoot":"","sources":["createAxiosSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAA+D;AAE/D,8CAIwB;AAExB,IAAM,mBAAmB,GAA4C;IACnE,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACb,CAAC;AAEK,IAAM,yBAAyB,GACpC,UACE,KAAoB,EACpB,OAA2B;IAE7B,OAAA,UAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB;QACtC,OAAA;;;;;iGAAO,EAA6B;;;gBAA7B,mBAAA,EAAA,OAA6B;gBAA3B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EAAE,IAAI;iCAC1B,CAAC,CAAC;4BAET,4CAAY,IAAI,KAAE,MAAM,QAAA,EAAE,IAAI,EAAE,YAAY,KAAG;;;;SAChD;IAjCD,CAiCC;AAlCD,CAkCC,CAAC;AAvCS,QAAA,yBAAyB,6BAuClC;AAEG,IAAM,uBAAuB,GAAG,UAGrC,aAA2B,EAC3B,KAAoB,EACpB,iBAAqC;IAErC,OAAA,IAAA,6BAAyB,EAAC,IAAA,iCAAyB,EAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAC5E,aAAa,CACd;AAFD,CAEC,CAAC;AATS,QAAA,uBAAuB,2BAShC"} \ No newline at end of file diff --git a/src/axios/index.d.ts b/src/axios/index.d.ts new file mode 100644 index 0000000..5a59bf2 --- /dev/null +++ b/src/axios/index.d.ts @@ -0,0 +1 @@ +export { createAxiosSharedClient } from "./createAxiosSharedClient"; diff --git a/src/axios/index.js b/src/axios/index.js new file mode 100644 index 0000000..ce08009 --- /dev/null +++ b/src/axios/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createAxiosSharedClient = void 0; +var createAxiosSharedClient_1 = require("./createAxiosSharedClient"); +Object.defineProperty(exports, "createAxiosSharedClient", { enumerable: true, get: function () { return createAxiosSharedClient_1.createAxiosSharedClient; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/axios/index.js.map b/src/axios/index.js.map new file mode 100644 index 0000000..6d4a76b --- /dev/null +++ b/src/axios/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"} \ No newline at end of file diff --git a/src/configureCreateHttpClient.d.ts b/src/configureCreateHttpClient.d.ts new file mode 100644 index 0000000..74eebb0 --- /dev/null +++ b/src/configureCreateHttpClient.d.ts @@ -0,0 +1,26 @@ +import { z } from "zod"; +import type { ResponsesToHttpResponse, SharedRoute, UnknownResponses, UnknownSharedRoute } from "./defineRoutes"; +import { PathParameters, ReplaceParamsInUrl, Url } from "./pathParameters"; +type EmptyObj = Record; +type AnyObj = Record; +export type HttpResponse = { + status: Status; + body: ResponseBody; + headers: Record; +}; +export type HandlerParams = (PathParameters extends EmptyObj ? AnyObj : { + urlParams: PathParameters; +}) & (z.infer extends void ? AnyObj : { + body: z.infer; +}) & (z.infer extends void ? AnyObj : { + queryParams: z.infer; +}) & (z.infer extends void ? AnyObj : { + headers: z.infer; +}); +export type Handler = (params: HandlerParams | EmptyObj) => Promise>; +export type HttpClient> = { + [RouteName in keyof SharedRoutes]: (...params: [SharedRoutes[RouteName], PathParameters] extends [SharedRoute, EmptyObj] ? [] : [HandlerParams]) => Promise>; +}; +export type HandlerCreator> = (routeName: R, routes: SharedRoutes, replaceParamsInUrl: ReplaceParamsInUrl) => Handler; +export declare const configureCreateHttpClient: >(handlerCreator: HandlerCreator) => >(routes: SharedRoutes) => HttpClient; +export {}; diff --git a/src/configureCreateHttpClient.js b/src/configureCreateHttpClient.js new file mode 100644 index 0000000..a46bcbc --- /dev/null +++ b/src/configureCreateHttpClient.js @@ -0,0 +1,25 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.configureCreateHttpClient = void 0; +var pathParameters_1 = require("./pathParameters"); +var configureCreateHttpClient = function (handlerCreator) { + return function (routes) { + return (0, pathParameters_1.keys)(routes).reduce(function (acc, routeName) { + var _a; + return (__assign(__assign({}, acc), (_a = {}, _a[routeName] = handlerCreator(routeName, routes, pathParameters_1.replaceParamsInUrl), _a))); + }, {}); + }; +}; +exports.configureCreateHttpClient = configureCreateHttpClient; +//# sourceMappingURL=configureCreateHttpClient.js.map \ No newline at end of file diff --git a/src/configureCreateHttpClient.js.map b/src/configureCreateHttpClient.js.map new file mode 100644 index 0000000..9035aa0 --- /dev/null +++ b/src/configureCreateHttpClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"configureCreateHttpClient.js","sourceRoot":"","sources":["configureCreateHttpClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,mDAM0B;AAuCnB,IAAM,yBAAyB,GACpC,UAA+C,cAAiC;IAChF,OAAA,UACE,MAAoB;QAEpB,OAAA,IAAA,qBAAI,EAAC,MAAM,CAAC,CAAC,MAAM,CACjB,UAAC,GAAG,EAAE,SAAS;;YAAK,OAAA,uBACf,GAAG,gBACL,SAAS,IAAG,cAAc,CACzB,SAAmB,EACnB,MAAsB,EACtB,mCAAkB,CACnB,OACD;QAPkB,CAOlB,EACF,EAA8B,CAC/B;IAVD,CAUC;AAbH,CAaG,CAAC;AAfO,QAAA,yBAAyB,6BAehC"} \ No newline at end of file diff --git a/src/createCustomSharedClient.d.ts b/src/createCustomSharedClient.d.ts new file mode 100644 index 0000000..a985682 --- /dev/null +++ b/src/createCustomSharedClient.d.ts @@ -0,0 +1,3 @@ +import { Handler, HttpClient } from "./configureCreateHttpClient"; +import { UnknownSharedRoute } from "./defineRoutes"; +export declare const createCustomSharedClient: >(sharedRoutes: SharedRoutes, customHandlers: { [K in keyof SharedRoutes]: Handler; }) => HttpClient; diff --git a/src/createCustomSharedClient.js b/src/createCustomSharedClient.js new file mode 100644 index 0000000..8d202a0 --- /dev/null +++ b/src/createCustomSharedClient.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createCustomSharedClient = void 0; +var configureCreateHttpClient_1 = require("./configureCreateHttpClient"); +var createCustomSharedClient = function (sharedRoutes, customHandlers) { + var createHttpClient = (0, configureCreateHttpClient_1.configureCreateHttpClient)(function (routeName) { + return customHandlers[routeName]; + }); + return createHttpClient(sharedRoutes); +}; +exports.createCustomSharedClient = createCustomSharedClient; +//# sourceMappingURL=createCustomSharedClient.js.map \ No newline at end of file diff --git a/src/createCustomSharedClient.js.map b/src/createCustomSharedClient.js.map new file mode 100644 index 0000000..c572287 --- /dev/null +++ b/src/createCustomSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createCustomSharedClient.js","sourceRoot":"","sources":["createCustomSharedClient.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AAIjE,IAAM,wBAAwB,GAAG,UAGtC,YAA0B,EAC1B,cAEC;IAED,IAAM,gBAAgB,GAAG,IAAA,qDAAyB,EAAC,UAAC,SAAS;QAC3D,OAAO,cAAc,CAAC,SAAS,CAAQ,CAAC;IAC1C,CAAC,CAAQ,CAAC;IAEV,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAbW,QAAA,wBAAwB,4BAanC"} \ No newline at end of file diff --git a/src/defineRoutes.d.ts b/src/defineRoutes.d.ts new file mode 100644 index 0000000..fedfccd --- /dev/null +++ b/src/defineRoutes.d.ts @@ -0,0 +1,34 @@ +import { z, ZodVoid } from "zod"; +import { HttpResponse } from "./configureCreateHttpClient"; +import type { Url } from "./pathParameters"; +export type UnknownResponses = { + [K: number]: z.ZodSchema; +}; +export type ValueOf = T[keyof T]; +export type ValueOfIndexNumber> = T[keyof T & number]; +export type ResponsesToHttpResponse = ValueOf<{ + [K in keyof Responses & number]: HttpResponse>; +}>; +export type ResponseType = "json" | "arrayBuffer" | "blob" | "text"; +type OptionalFields = { + requestBodySchema?: z.Schema; + queryParamsSchema?: z.Schema; + responses?: Responses; + headersSchema?: z.Schema; + responseType?: ResponseType; +}; +export type HttpMethod = "get" | "post" | "put" | "patch" | "delete"; +type MethodAndUrl = { + method: HttpMethod; + url: U; +}; +type SharedRouteWithOptional = MethodAndUrl & OptionalFields; +export type SharedRoute = MethodAndUrl & Required>; +export type UnknownSharedRoute = SharedRoute; +export type UnknownSharedRouteWithUrl = SharedRoute; +export declare const defineRoute: (route: SharedRouteWithOptional) => SharedRoute; +export declare const defineRoutes: >(routes: { [K in keyof T]: T[K]; }) => { [K in keyof T]: T[K]; }; +export declare const listRoutes: >(routes: { [K in keyof T]: T[K]; }) => string[]; +export {}; diff --git a/src/defineRoutes.js b/src/defineRoutes.js new file mode 100644 index 0000000..f59962a --- /dev/null +++ b/src/defineRoutes.js @@ -0,0 +1,62 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.listRoutes = exports.defineRoutes = exports.defineRoute = void 0; +var zod_1 = require("zod"); +var defineRoute = function (route) { + var _a; + return (__assign(__assign({ requestBodySchema: zod_1.z.object({}).strict(), queryParamsSchema: zod_1.z.object({}).strict(), responses: { 201: zod_1.z.void().or(zod_1.z.string().max(0)) }, headersSchema: zod_1.z.object({}) }, route), { responseType: (_a = route.responseType) !== null && _a !== void 0 ? _a : "json" })); +}; +exports.defineRoute = defineRoute; +var verifyRoutesUniqAndListRoutes = function (routes) { + var e_1, _a; + var _b; + var occurrencesByMethodAndUrl = {}; + try { + for (var _c = __values(Object.values(routes)), _d = _c.next(); !_d.done; _d = _c.next()) { + var route = _d.value; + var name_1 = "".concat(route.method.toUpperCase(), " ").concat(route.url); + var occurrence = ((_b = occurrencesByMethodAndUrl[name_1]) !== null && _b !== void 0 ? _b : 0) + 1; + if (occurrence > 1) + throw new Error("You cannot have several routes with same http method and url, got: ".concat(name_1, " twice (at least)")); + occurrencesByMethodAndUrl[name_1] = occurrence; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return Object.keys(occurrencesByMethodAndUrl); +}; +var defineRoutes = function (routes) { + verifyRoutesUniqAndListRoutes(routes); + return routes; +}; +exports.defineRoutes = defineRoutes; +var listRoutes = function (routes) { return verifyRoutesUniqAndListRoutes(routes); }; +exports.listRoutes = listRoutes; +//# sourceMappingURL=defineRoutes.js.map \ No newline at end of file diff --git a/src/defineRoutes.js.map b/src/defineRoutes.js.map new file mode 100644 index 0000000..2d03090 --- /dev/null +++ b/src/defineRoutes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defineRoutes.js","sourceRoot":"","sources":["defineRoutes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAiC;AA6D1B,IAAM,WAAW,GAAG,UAOzB,KAAyE;;IACd,OAAA,qBAC3D,iBAAiB,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAS,EAC/C,iBAAiB,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAS,EAC/C,SAAS,EAAE,EAAE,GAAG,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAS,EACzD,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAQ,IAC/B,KAAK,KACR,YAAY,EAAE,MAAA,KAAK,CAAC,YAAY,mCAAI,MAAM,IAC1C,CAAA;CAAA,CAAC;AAfU,QAAA,WAAW,eAerB;AAEH,IAAM,6BAA6B,GAAG,UACpC,MAEC;;;IAED,IAAM,yBAAyB,GAA2B,EAAE,CAAC;;QAE7D,KAAoB,IAAA,KAAA,SAAA,MAAM,CAAC,MAAM,CAAC,MAAM,CAAyB,CAAA,gBAAA,4BAAE,CAAC;YAA/D,IAAM,KAAK,WAAA;YACd,IAAM,MAAI,GAAG,UAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,cAAI,KAAK,CAAC,GAAG,CAAE,CAAC;YAC1D,IAAM,UAAU,GAAG,CAAC,MAAA,yBAAyB,CAAC,MAAI,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC9D,IAAI,UAAU,GAAG,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,6EAAsE,MAAI,sBAAmB,CAC9F,CAAC;YACJ,yBAAyB,CAAC,MAAI,CAAC,GAAG,UAAU,CAAC;QAC/C,CAAC;;;;;;;;;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAChD,CAAC,CAAC;AAEK,IAAM,YAAY,GAAG,UAC1B,MAEC;IAED,6BAA6B,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAPW,QAAA,YAAY,gBAOvB;AACK,IAAM,UAAU,GAAG,UACxB,MAEC,IACY,OAAA,6BAA6B,CAAC,MAAM,CAAC,EAArC,CAAqC,CAAC;AAJxC,QAAA,UAAU,cAI8B"} \ No newline at end of file diff --git a/src/express/createExpressSharedRouter.d.ts b/src/express/createExpressSharedRouter.d.ts new file mode 100644 index 0000000..0532844 --- /dev/null +++ b/src/express/createExpressSharedRouter.d.ts @@ -0,0 +1,11 @@ +import type { IRoute, RequestHandler, Router } from "express"; +import type { PathParameters, UnknownSharedRoute } from ".."; +import { z } from "zod"; +import { ValidationOptions } from "../validations"; +import { ValueOfIndexNumber } from "../defineRoutes"; +type ExpressSharedRouterOptions = Pick; +interface ParsedQs { + [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[]; +} +export declare const createExpressSharedRouter: , ExpressSharedRouter extends { [Route in keyof SharedRoutes & string]: (...handlers: RequestHandler, z.infer>, z.infer, z.infer extends void ? ParsedQs : z.infer, any>[]) => IRoute; }>(sharedRoutes: SharedRoutes, expressRouter: Router, options?: ExpressSharedRouterOptions) => ExpressSharedRouter; +export {}; diff --git a/src/express/createExpressSharedRouter.js b/src/express/createExpressSharedRouter.js new file mode 100644 index 0000000..c6d9c0c --- /dev/null +++ b/src/express/createExpressSharedRouter.js @@ -0,0 +1,72 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createExpressSharedRouter = void 0; +var __1 = require(".."); +var validations_1 = require("../validations"); +var makeValidationMiddleware = function (route, options) { + return function (req, res, next) { + try { + if (!options.skipInputValidation) { + var validatedParams = (0, validations_1.validateInputParams)(route, { body: req.body, headers: req.headers, queryParams: req.query }, "express"); + req.body = validatedParams.body; + req.query = validatedParams.queryParams; + req.headers = validatedParams.headers; + } + next(); + } + catch (error) { + var zodError = error.cause; + res.status(400); + res.json({ + status: 400, + message: error.message, + issues: Array.from(new Set(zodIssuesToStrings(zodError.issues))), + }); + } + }; +}; +var zodIssuesToStrings = function (zodIssues) { + return zodIssues.flatMap(function (zodIssue) { + if (zodIssue.code === "invalid_union") { + return zodIssue.unionErrors.flatMap(function (_a) { + var issues = _a.issues; + return zodIssuesToStrings(issues); + }); + } + var message = zodIssue.message, path = zodIssue.path; + return "".concat(path.join("."), " : ").concat(message); + }); +}; +var assignHandlersToExpressRouter = function (expressRouter, route, options) { + if (options === void 0) { options = {}; } + var validationMiddleware = makeValidationMiddleware(route, options); + var url = route.url; + return function () { + var handlers = []; + for (var _i = 0; _i < arguments.length; _i++) { + handlers[_i] = arguments[_i]; + } + return expressRouter.route(url)[route.method](validationMiddleware, handlers); + }; +}; +var createExpressSharedRouter = function (sharedRoutes, expressRouter, options) { + var expressSharedRouter = (0, __1.keys)(sharedRoutes).reduce(function (acc, routeName) { + var _a; + var route = sharedRoutes[routeName]; + return __assign(__assign({}, acc), (_a = {}, _a[routeName] = assignHandlersToExpressRouter(expressRouter, route, options), _a)); + }, {}); + return expressSharedRouter; +}; +exports.createExpressSharedRouter = createExpressSharedRouter; +//# sourceMappingURL=createExpressSharedRouter.js.map \ No newline at end of file diff --git a/src/express/createExpressSharedRouter.js.map b/src/express/createExpressSharedRouter.js.map new file mode 100644 index 0000000..f02a7d7 --- /dev/null +++ b/src/express/createExpressSharedRouter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createExpressSharedRouter.js","sourceRoot":"","sources":["createExpressSharedRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,wBAA0B;AAE1B,8CAAwE;AAKxE,IAAM,wBAAwB,GAC5B,UAAC,KAAyB,EAAE,OAAmC;IAC/D,OAAA,UAAC,GAAG,EAAE,GAAG,EAAE,IAAI;QACb,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;gBACjC,IAAM,eAAe,GAAG,IAAA,iCAAmB,EACzC,KAAK,EACL,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,KAAK,EAAE,EAChE,SAAS,CACV,CAAC;gBACF,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;gBAChC,GAAG,CAAC,KAAK,GAAG,eAAe,CAAC,WAAkB,CAAC;gBAC/C,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC,OAAc,CAAC;YAC/C,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAM,QAAQ,GAAG,KAAK,CAAC,KAAiB,CAAC;YACzC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC;gBAC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1B,aAAqB,EACrB,OAAoC;IAEpC,IAAM,mBAAmB,GAAG,IAAA,QAAI,EAAC,YAAY,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,SAAS;;QACnE,IAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QACtC,6BACK,GAAG,gBACL,SAAS,IAAG,6BAA6B,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,OACzE;IACJ,CAAC,EAAE,EAAyB,CAAC,CAAC;IAE9B,OAAO,mBAAmB,CAAC;AAC7B,CAAC,CAAC;AA7BW,QAAA,yBAAyB,6BA6BpC"} \ No newline at end of file diff --git a/src/express/index.d.ts b/src/express/index.d.ts new file mode 100644 index 0000000..8f6a6a7 --- /dev/null +++ b/src/express/index.d.ts @@ -0,0 +1 @@ +export { createExpressSharedRouter } from "./createExpressSharedRouter"; diff --git a/src/express/index.js b/src/express/index.js new file mode 100644 index 0000000..ab63c8d --- /dev/null +++ b/src/express/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createExpressSharedRouter = void 0; +var createExpressSharedRouter_1 = require("./createExpressSharedRouter"); +Object.defineProperty(exports, "createExpressSharedRouter", { enumerable: true, get: function () { return createExpressSharedRouter_1.createExpressSharedRouter; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/express/index.js.map b/src/express/index.js.map new file mode 100644 index 0000000..b0e61ed --- /dev/null +++ b/src/express/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA"} \ No newline at end of file diff --git a/src/fetch/createFetchSharedClient.d.ts b/src/fetch/createFetchSharedClient.d.ts new file mode 100644 index 0000000..a1630c0 --- /dev/null +++ b/src/fetch/createFetchSharedClient.d.ts @@ -0,0 +1,10 @@ +import type { UnknownSharedRoute, Url } from ".."; +import { HandlerCreator } from ".."; +import { ValidationOptions } from "../validations"; +type Fetch = typeof fetch; +type FetchConfig = RequestInit & { + baseURL?: Url; +} & ValidationOptions; +export declare const createFetchHandlerCreator: >(fetch: Fetch, options?: FetchConfig) => HandlerCreator; +export declare const createFetchSharedClient: >(sharedRouters: SharedRoutes, fetch: Fetch, config?: FetchConfig) => import("..").HttpClient; +export {}; diff --git a/src/fetch/createFetchSharedClient.js b/src/fetch/createFetchSharedClient.js new file mode 100644 index 0000000..b71858a --- /dev/null +++ b/src/fetch/createFetchSharedClient.js @@ -0,0 +1,200 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFetchSharedClient = exports.createFetchHandlerCreator = void 0; +var __1 = require(".."); +var queryParamsToString_1 = require("./queryParamsToString"); +var validations_1 = require("../validations"); +var objectFromEntries = function (entries) { + var e_1, _a; + var result = {}; + try { + for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { + var _b = __read(entries_1_1.value, 2), key = _b[0], value = _b[1]; + result[key] = value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); + } + finally { if (e_1) throw e_1.error; } + } + return result; +}; +var createFetchHandlerCreator = function (fetch, options) { + if (options === void 0) { options = {}; } + return function (routeName, routes, replaceParamsInUrl) { + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var route, _b, body, headers, queryParams, bodyAsString, stringQueryParams, baseURL, defaultInit, res, processedBody, responseBody; + var _c; + if (_a === void 0) { _a = {}; } + var urlParams = _a.urlParams, params = __rest(_a, ["urlParams"]); + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + route = routes[routeName]; + _b = options.skipInputValidation + ? params + : (0, validations_1.validateInputParams)(route, params, "fetch", { withIssuesInMessage: true }), body = _b.body, headers = _b.headers, queryParams = _b.queryParams; + bodyAsString = JSON.stringify(body); + stringQueryParams = queryParams && Object.keys(queryParams).length > 0 + ? "?" + (0, queryParamsToString_1.queryParamsToString)(queryParams) + : ""; + baseURL = options.baseURL, defaultInit = __rest(options, ["baseURL"]); + return [4 /*yield*/, fetch((baseURL ? baseURL : "") + + replaceParamsInUrl(route.url, urlParams) + + stringQueryParams, __assign(__assign(__assign(__assign({}, defaultInit), { method: route.method }), (bodyAsString !== "{}" ? { body: bodyAsString } : {})), { headers: __assign(__assign({ "Content-Type": "application/json" }, defaultInit === null || defaultInit === void 0 ? void 0 : defaultInit.headers), (headers !== null && headers !== void 0 ? headers : {})) }))]; + case 1: + res = _d.sent(); + return [4 /*yield*/, responseTypeToResponseBody(res, route.responseType)]; + case 2: + processedBody = _d.sent(); + responseBody = (options === null || options === void 0 ? void 0 : options.skipResponseValidation) || + ((_c = options === null || options === void 0 ? void 0 : options.skipResponseValidationForStatuses) === null || _c === void 0 ? void 0 : _c.includes(res.status)) + ? processedBody + : (0, validations_1.validateSchemaWithExplicitError)({ + adapterName: "fetch", + checkedSchema: "responses", + responseStatus: res.status, + params: processedBody, + route: route, + withIssuesInMessage: true, + }); + console.log({ + "res.headers": res.headers, + "res.headers.entries()": res.headers.entries(), + }); + return [2 /*return*/, { + body: responseBody, + status: res.status, + headers: objectFromEntries(res.headers.entries()), + }]; + } + }); + }); + }; + }; +}; +exports.createFetchHandlerCreator = createFetchHandlerCreator; +var responseTypeToResponseBody = function (res, responseType) { + switch (responseType) { + case "json": + return res.json(); + case "text": + return res.text(); + case "blob": + return res.blob(); + case "arrayBuffer": + return res.arrayBuffer(); + default: { + var exhaustiveCheck = responseType; + return exhaustiveCheck; + } + } +}; +var createFetchSharedClient = function (sharedRouters, fetch, config) { + if (config === void 0) { config = {}; } + return (0, __1.configureCreateHttpClient)((0, exports.createFetchHandlerCreator)(fetch, config))(sharedRouters); +}; +exports.createFetchSharedClient = createFetchSharedClient; +//# sourceMappingURL=createFetchSharedClient.js.map \ No newline at end of file diff --git a/src/fetch/createFetchSharedClient.js.map b/src/fetch/createFetchSharedClient.js.map new file mode 100644 index 0000000..43ad8b6 --- /dev/null +++ b/src/fetch/createFetchSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createFetchSharedClient.js","sourceRoot":"","sources":["createFetchSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wBAA+D;AAE/D,6DAA4D;AAC5D,8CAIwB;AAExB,IAAM,iBAAiB,GAAG,UACxB,OAAmC;;IAEnC,IAAM,MAAM,GAA2B,EAAE,CAAC;;QAC1C,KAA2B,IAAA,YAAA,SAAA,OAAO,CAAA,gCAAA,qDAAE,CAAC;YAA1B,IAAA,KAAA,4BAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;YACpB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;;;;;;;;;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAMK,IAAM,yBAAyB,GACpC,UACE,KAAY,EACZ,OAAyB;IAAzB,wBAAA,EAAA,YAAyB;IAE3B,OAAA,UAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB;QACtC,OAAA;;;;;iGAAO,EAA6B;;;gBAA7B,mBAAA,EAAA,OAA6B;gBAA3B,IAAA,SAAS,eAAA,EAAK,MAAM,cAAtB,aAAwB,CAAF;;;;4BACrB,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;4BAE1B,KAAiC,OAAO,CAAC,mBAAmB;gCAChE,CAAC,CAAC,MAAM;gCACR,CAAC,CAAC,IAAA,iCAAmB,EAAC,KAAK,EAAE,MAAa,EAAE,OAAO,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,EAF7E,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA,CAEoD;4BAEhF,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;4BAEpC,iBAAiB,GACrB,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null +++ b/src/fetch/index.d.ts @@ -0,0 +1 @@ +export { createFetchSharedClient } from "./createFetchSharedClient"; diff --git a/src/fetch/index.js b/src/fetch/index.js new file mode 100644 index 0000000..8588604 --- /dev/null +++ b/src/fetch/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFetchSharedClient = void 0; +var createFetchSharedClient_1 = require("./createFetchSharedClient"); +Object.defineProperty(exports, "createFetchSharedClient", { enumerable: true, get: function () { return createFetchSharedClient_1.createFetchSharedClient; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/fetch/index.js.map b/src/fetch/index.js.map new file mode 100644 index 0000000..6d4a76b --- /dev/null +++ b/src/fetch/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"} \ No newline at end of file diff --git a/src/fetch/queryParamsToString.d.ts b/src/fetch/queryParamsToString.d.ts new file mode 100644 index 0000000..af4d3de --- /dev/null +++ b/src/fetch/queryParamsToString.d.ts @@ -0,0 +1,8 @@ +type RawQueryParams = { + [key: string]: string | boolean | number; +}; +export type QueryParams = { + [K in keyof T]: T[K]; +}; +export declare const queryParamsToString: >(queryParams: Q) => string; +export {}; diff --git a/src/fetch/queryParamsToString.js b/src/fetch/queryParamsToString.js new file mode 100644 index 0000000..d45b588 --- /dev/null +++ b/src/fetch/queryParamsToString.js @@ -0,0 +1,37 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.queryParamsToString = void 0; +var queryParamsToString = function (queryParams) { + return Object.keys(queryParams) + .reduce(function (acc, param) { return __spreadArray(__spreadArray([], __read(acc), false), __read((typeof queryParams[param] !== "undefined" + ? ["".concat(param.toString(), "=").concat(encodeURI(queryParams[param].toString()))] + : [])), false); }, []) + .join("&"); +}; +exports.queryParamsToString = queryParamsToString; +//# sourceMappingURL=queryParamsToString.js.map \ No newline at end of file diff --git a/src/fetch/queryParamsToString.js.map b/src/fetch/queryParamsToString.js.map new file mode 100644 index 0000000..cffe9a9 --- /dev/null +++ b/src/fetch/queryParamsToString.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryParamsToString.js","sourceRoot":"","sources":["queryParamsToString.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAM,mBAAmB,GAAG,UACjC,WAAc;IAEd,OAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAoB;SACzC,MAAM,CACL,UAAC,GAAa,EAAE,KAAK,IAAK,8CACrB,GAAG,kBACH,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,WAAW;QAC3C,CAAC,CAAC,CAAC,UAAG,KAAK,CAAC,QAAQ,EAAE,cAAI,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAE,CAAC;QACrE,CAAC,CAAC,EAAE,CAAC,WAJiB,CAKzB,EACD,EAAE,CACH;SACA,IAAI,CAAC,GAAG,CAAC;AAVZ,CAUY,CAAC;AAbF,QAAA,mBAAmB,uBAajB"} \ No newline at end of file diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..abc702d --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,7 @@ +export { createCustomSharedClient } from "./createCustomSharedClient"; +export { configureCreateHttpClient } from "./configureCreateHttpClient"; +export type { HandlerCreator, HttpClient, HttpResponse, } from "./configureCreateHttpClient"; +export { defineRoutes, defineRoute, listRoutes } from "./defineRoutes"; +export type { HttpMethod, SharedRoute, UnknownSharedRoute, UnknownSharedRouteWithUrl, } from "./defineRoutes"; +export type { PathParameters, Url } from "./pathParameters"; +export { keys } from "./pathParameters"; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..601e71f --- /dev/null +++ b/src/index.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keys = exports.listRoutes = exports.defineRoute = exports.defineRoutes = exports.configureCreateHttpClient = exports.createCustomSharedClient = void 0; +var createCustomSharedClient_1 = require("./createCustomSharedClient"); +Object.defineProperty(exports, "createCustomSharedClient", { enumerable: true, get: function () { return createCustomSharedClient_1.createCustomSharedClient; } }); +var configureCreateHttpClient_1 = require("./configureCreateHttpClient"); +Object.defineProperty(exports, "configureCreateHttpClient", { enumerable: true, get: function () { return configureCreateHttpClient_1.configureCreateHttpClient; } }); +var defineRoutes_1 = require("./defineRoutes"); +Object.defineProperty(exports, "defineRoutes", { enumerable: true, get: function () { return defineRoutes_1.defineRoutes; } }); +Object.defineProperty(exports, "defineRoute", { enumerable: true, get: function () { return defineRoutes_1.defineRoute; } }); +Object.defineProperty(exports, "listRoutes", { enumerable: true, get: function () { return defineRoutes_1.listRoutes; } }); +var pathParameters_1 = require("./pathParameters"); +Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return pathParameters_1.keys; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map new file mode 100644 index 0000000..f7293b9 --- /dev/null +++ b/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA;AAMlC,+CAAuE;AAA9D,4GAAA,YAAY,OAAA;AAAE,2GAAA,WAAW,OAAA;AAAE,0GAAA,UAAU,OAAA;AAQ9C,mDAAwC;AAA/B,sGAAA,IAAI,OAAA"} \ No newline at end of file diff --git a/src/openapi/createOpenApiGenerator.d.ts b/src/openapi/createOpenApiGenerator.d.ts new file mode 100644 index 0000000..81ae4ed --- /dev/null +++ b/src/openapi/createOpenApiGenerator.d.ts @@ -0,0 +1,49 @@ +import { OpenAPIV3_1 as OpenAPI } from "openapi-types"; +import { z } from "zod"; +import { PathParameters, UnknownSharedRoute } from ".."; +type OmitFromExisting = Omit; +type Examples = { + [media: string]: OpenAPI.ExampleObject & { + value?: T; + }; +}; +type WithExampleOrExamples = { + example?: T; + examples?: never; +} | { + example?: never; + examples?: Examples; +}; +type OpenApiBody = Pick & { + example?: T; + examples?: Examples; +}; +type ExtraDocParameter = Partial> & WithExampleOrExamples; +type CreateOpenApiGenerator = ; +}, SecuritySchemeName extends string>(sharedRoutesByTag: SharedRoutesByTag, openApiRootDoc: Omit & { + components?: OmitFromExisting & { + securitySchemes?: Record; + }; +}) => (extraDataByRoute: Partial<{ + [Tag in keyof SharedRoutesByTag]: { + [R in keyof SharedRoutesByTag[Tag]]: OmitFromExisting & { + extraDocs: { + securitySchemeToApply?: SecuritySchemeName[]; + urlParams?: PathParameters extends Record ? never : Record, ExtraDocParameter>; + body?: z.infer extends void ? never : OpenApiBody>; + queryParams?: z.infer extends void ? never : { + [K in keyof z.infer]: ExtraDocParameter[K]>; + }; + headerParams?: z.infer extends void ? never : { + [K in keyof z.infer]: ExtraDocParameter[K]>; + }; + responses: { + [S in keyof SharedRoutesByTag[Tag][R]["responses"] & number]: OpenAPI.ResponseObject & WithExampleOrExamples>; + }; + }; + }; + }; +}>) => OpenAPI.Document; +export declare const createOpenApiGenerator: CreateOpenApiGenerator; +export {}; diff --git a/src/openapi/createOpenApiGenerator.js b/src/openapi/createOpenApiGenerator.js new file mode 100644 index 0000000..7697ee9 --- /dev/null +++ b/src/openapi/createOpenApiGenerator.js @@ -0,0 +1,149 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createOpenApiGenerator = void 0; +var zod_to_json_schema_1 = require("zod-to-json-schema"); +var __1 = require(".."); +var extractFromOpenApiBody = function (openApiRequestBody) { + if (openApiRequestBody === void 0) { openApiRequestBody = {}; } + var examples = openApiRequestBody.examples, example = openApiRequestBody.example, rest = __rest(openApiRequestBody, ["examples", "example"]); + return { + withRequestBodyExemple: __assign(__assign({}, (example && { example: example })), (examples && { examples: examples })), + requestBodyDocs: rest, + }; +}; +var createOpenApiGenerator = function (sharedRoutesByTag, openApiRootDoc) { return function (extraDataByRoute) { return (__assign(__assign({}, openApiRootDoc), { paths: (0, __1.keys)(sharedRoutesByTag).reduce(function (rootAcc, tag) { + var sharedRoutes = sharedRoutesByTag[tag]; + return __assign(__assign({}, rootAcc), (0, __1.keys)(sharedRoutes).reduce(function (acc, routeName) { + var _a, _b; + var _c, _d; + var route = sharedRoutes[routeName]; + var _e = (_d = (_c = extraDataByRoute[tag]) === null || _c === void 0 ? void 0 : _c[routeName]) !== null && _d !== void 0 ? _d : {}, extraDocs = _e.extraDocs, extraDataForRoute = __rest(_e, ["extraDocs"]); + var _f = extractFromUrl(route.url, extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.urlParams), formattedUrl = _f.formattedUrl, pathParams = _f.pathParams; + var parameters = __spreadArray(__spreadArray(__spreadArray([], __read((pathParams.length > 0 ? pathParams : [])), false), __read((!isShapeObjectEmpty(route.queryParamsSchema) + ? zodObjectToParameters(route.queryParamsSchema, "query", extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.queryParams) + : [])), false), __read((!isShapeObjectEmpty(route.headersSchema) + ? zodObjectToParameters(route.headersSchema, "header", extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.headerParams) + : [])), false); + var _g = extractFromOpenApiBody(extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.body), withRequestBodyExemple = _g.withRequestBodyExemple, requestBodyDocs = _g.requestBodyDocs; + return __assign(__assign({}, acc), (_a = {}, _a[formattedUrl] = __assign(__assign({}, acc[formattedUrl]), (_b = {}, _b[route.method] = __assign(__assign(__assign(__assign(__assign(__assign({}, extraDataForRoute), { tags: [tag] }), ((extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.securitySchemeToApply) && + securitySchemeNamesToSecurity(extraDocs.securitySchemeToApply))), (parameters.length > 0 && { + parameters: parameters, + })), (!isShapeObjectEmpty(route.requestBodySchema) && { + requestBody: { + required: true, + content: { + "application/json": __assign(__assign({}, withRequestBodyExemple), { schema: __assign(__assign({}, requestBodyDocs), zodToOpenApi(route.requestBodySchema)) }), + }, + }, + })), { responses: (0, __1.keys)(route.responses).reduce(function (acc, status) { + var _a; + var _b, _c; + var responseSchema = zodToOpenApi(route.responses[status]); + var _d = (_c = (_b = extraDocs === null || extraDocs === void 0 ? void 0 : extraDocs.responses) === null || _b === void 0 ? void 0 : _b[status]) !== null && _c !== void 0 ? _c : {}, example = _d.example, examples = _d.examples, responseDoc = __rest(_d, ["example", "examples"]); + return __assign(__assign({}, acc), (_a = {}, _a[status.toString()] = __assign(__assign({}, responseDoc), (typeof responseSchema === "object" && { + content: { + "application/json": __assign(__assign(__assign({}, (example && { example: example })), (examples && { examples: examples })), { schema: responseSchema }), + }, + })), _a)); + }, {}) }), _b)), _a)); + }, {})); + }, {}) })); }; }; +exports.createOpenApiGenerator = createOpenApiGenerator; +var extractFromUrl = function (url, extraUrlParameters) { + var pathParams = []; + var formattedUrl = url.replace(/:(.*?)(\/|$)/g, function (_match, group1, group2) { + var extraDocForParam = extraUrlParameters === null || extraUrlParameters === void 0 ? void 0 : extraUrlParameters[group1]; + pathParams.push(__assign(__assign({}, extraDocForParam), { name: group1, required: true, schema: { type: "string" }, in: "path" })); + return "{".concat(group1, "}") + group2; + }); + return { + formattedUrl: formattedUrl, + pathParams: pathParams, + }; +}; +var zodToOpenApi = function (schema) { + var _a = (0, zod_to_json_schema_1.zodToJsonSchema)(schema, { + $refStrategy: "none", + }), $schema = _a.$schema, additionalProperties = _a.additionalProperties, rest = __rest(_a, ["$schema", "additionalProperties"]); + return rest; +}; +var isShapeObjectEmpty = function (schema) { + var typeName = getTypeName(schema); + if (typeName === "ZodObject") { + var shape = getShape(schema); + return Object.keys(shape).length === 0; + } + return typeName === undefined; +}; +var zodObjectToParameters = function (schema, paramKind, extraDocumentation) { + if (extraDocumentation === void 0) { extraDocumentation = {}; } + var shape = getShape(schema); + return Object.keys(shape).reduce(function (acc, paramName) { + var paramSchema = shape[paramName]; + var extraDoc = extraDocumentation[paramName]; + var initialTypeName = getTypeName(paramSchema); + var required = initialTypeName !== "ZodOptional"; + var schema = zodToOpenApi(required ? paramSchema : paramSchema._def.innerType); + return __spreadArray(__spreadArray([], __read(acc), false), [ + __assign(__assign({}, extraDoc), { in: paramKind, name: paramName, required: required, schema: schema }), + ], false); + }, []); +}; +var getTypeName = function (schema) { + return schema._def.typeName; +}; +var securitySchemeNamesToSecurity = function (securitySchemeToApply) { return ({ + security: securitySchemeToApply.reduce(function (securityAcc, securitySchemeName) { + var _a; + return __spreadArray(__spreadArray([], __read(securityAcc), false), [(_a = {}, _a[securitySchemeName] = [], _a)], false); + }, []), +}); }; +var getShape = function (schema) { return schema._def.shape(); }; +//# sourceMappingURL=createOpenApiGenerator.js.map \ No newline at end of file diff --git a/src/openapi/createOpenApiGenerator.js.map b/src/openapi/createOpenApiGenerator.js.map new file mode 100644 index 0000000..3ef46e1 --- /dev/null +++ b/src/openapi/createOpenApiGenerator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createOpenApiGenerator.js","sourceRoot":"","sources":["createOpenApiGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yDAAqD;AACrD,wBAA8D;AAqF9D,IAAM,sBAAsB,GAAG,UAC7B,kBAAwD;IAAxD,mCAAA,EAAA,uBAAwD;IAKhD,IAAA,QAAQ,GAAuB,kBAAkB,SAAzC,EAAE,OAAO,GAAc,kBAAkB,QAAhC,EAAK,IAAI,UAAK,kBAAkB,EAAnD,uBAA8B,CAAF,CAAwB;IAE1D,OAAO;QACL,sBAAsB,wBACjB,CAAC,OAAO,IAAI,EAAE,OAAO,SAAA,EAAE,CAAC,GACxB,CAAC,QAAQ,IAAI,EAAE,QAAQ,UAAA,EAAE,CAAC,CAC9B;QACD,eAAe,EAAE,IAAI;KAC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B,GAAG,UAAC,qBAA+B,IAAK,OAAA,CAAC;IAC1E,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CACpC,UAAC,WAAW,EAAE,kBAAkB;;QAAK,8CAAI,WAAW,sBAAI,GAAC,kBAAkB,IAAG,EAAE;IAA3C,CAA8C,EACnF,EAAgC,CACjC;CACF,CAAC,EALyE,CAKzE,CAAC;AAEH,IAAM,QAAQ,GAAG,UAAI,MAAmB,IAAkB,OAAC,MAAM,CAAC,IAAY,CAAC,KAAK,EAAE,EAA5B,CAA4B,CAAC"} \ No newline at end of file diff --git a/src/openapi/index.d.ts b/src/openapi/index.d.ts new file mode 100644 index 0000000..015624c --- /dev/null +++ b/src/openapi/index.d.ts @@ -0,0 +1 @@ +export { createOpenApiGenerator } from "./createOpenApiGenerator"; diff --git a/src/openapi/index.js b/src/openapi/index.js new file mode 100644 index 0000000..e86a5ba --- /dev/null +++ b/src/openapi/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createOpenApiGenerator = void 0; +var createOpenApiGenerator_1 = require("./createOpenApiGenerator"); +Object.defineProperty(exports, "createOpenApiGenerator", { enumerable: true, get: function () { return createOpenApiGenerator_1.createOpenApiGenerator; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/openapi/index.js.map b/src/openapi/index.js.map new file mode 100644 index 0000000..33aa00c --- /dev/null +++ b/src/openapi/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"} \ No newline at end of file diff --git a/src/pathParameters.d.ts b/src/pathParameters.d.ts new file mode 100644 index 0000000..c40384b --- /dev/null +++ b/src/pathParameters.d.ts @@ -0,0 +1,19 @@ +type Http = "http://" | "https://"; +type AbsoluteUrl = `${Http}${string}`; +type RelativeUrl = `/${string}`; +export type Url = AbsoluteUrl | RelativeUrl; +interface ParamsDictionary { + [key: string]: string; +} +type RemoveDomain = S extends RelativeUrl ? S : S extends `${Http}${string}${"/"}${infer P}` ? `/${P}` : "/"; +type RemoveTail = S extends `${infer P}${Tail}` ? P : S; +type GetRouteParameter = RemoveTail, `-${string}`>, `.${string}`>; +export type PathParameters = string extends Route ? ParamsDictionary : RemoveDomain extends `${string}:${infer Rest}` ? (GetRouteParameter extends never ? ParamsDictionary : GetRouteParameter extends `${infer ParamName}?` ? { + [P in ParamName]?: string; +} : { + [P in GetRouteParameter]: string; +}) & (Rest extends `${GetRouteParameter}${infer Next}` ? PathParameters : unknown) : {}; +export type ReplaceParamsInUrl = (path: U, params: PathParameters) => Url; +export declare const replaceParamsInUrl: ReplaceParamsInUrl; +export declare const keys: >(obj: Obj) => (keyof Obj)[]; +export {}; diff --git a/src/pathParameters.js b/src/pathParameters.js new file mode 100644 index 0000000..653d9ab --- /dev/null +++ b/src/pathParameters.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keys = exports.replaceParamsInUrl = void 0; +var replaceParamsInUrl = function (url, params) { + if (params === void 0) { params = {}; } + var paramNames = (0, exports.keys)(params); + if (paramNames.length === 0) + return url; + return paramNames.reduce(function (acc, paramName) { return acc.replace(":".concat(paramName.toString()), params[paramName]); }, url); +}; +exports.replaceParamsInUrl = replaceParamsInUrl; +var keys = function (obj) { + return Object.keys(obj); +}; +exports.keys = keys; +//# sourceMappingURL=pathParameters.js.map \ No newline at end of file diff --git a/src/pathParameters.js.map b/src/pathParameters.js.map new file mode 100644 index 0000000..d7cd4ec --- /dev/null +++ b/src/pathParameters.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pathParameters.js","sourceRoot":"","sources":["pathParameters.ts"],"names":[],"mappings":";;;AA+CO,IAAM,kBAAkB,GAAuB,UACpD,GAAG,EACH,MAAyC;IAAzC,uBAAA,EAAA,SAAS,EAAgC;IAEzC,IAAM,UAAU,GAAG,IAAA,YAAI,EAAC,MAAM,CAAC,CAAC;IAChC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,OAAO,UAAU,CAAC,MAAM,CACtB,UAAC,GAAG,EAAE,SAAS,IAAK,OAAA,GAAG,CAAC,OAAO,CAAC,WAAI,SAAS,CAAC,QAAQ,EAAE,CAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,EAA1D,CAA0D,EAC9E,GAAU,CACX,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B;AAEK,IAAM,IAAI,GAAG,UAAsC,GAAQ;IAChE,OAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAkB;AAAjC,CAAiC,CAAC;AADvB,QAAA,IAAI,QACmB"} \ No newline at end of file diff --git a/src/supertest/createSupertestSharedClient.d.ts b/src/supertest/createSupertestSharedClient.d.ts new file mode 100644 index 0000000..b77e0ad --- /dev/null +++ b/src/supertest/createSupertestSharedClient.d.ts @@ -0,0 +1,5 @@ +import type { UnknownSharedRoute } from ".."; +import { HandlerCreator } from ".."; +import type { SuperTest, Test } from "supertest"; +export declare const createSupertestHandlerCreator: (supertestRequest: SuperTest) => HandlerCreator; +export declare const createSupertestSharedClient: >(sharedRoutes: SharedRoutes, supertestRequest: SuperTest) => import("..").HttpClient; diff --git a/src/supertest/createSupertestSharedClient.js b/src/supertest/createSupertestSharedClient.js new file mode 100644 index 0000000..5ed59cc --- /dev/null +++ b/src/supertest/createSupertestSharedClient.js @@ -0,0 +1,119 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createSupertestSharedClient = exports.createSupertestHandlerCreator = void 0; +var __1 = require(".."); +var supertestRequestToCorrectHttpMethod = function (supertestRequest, method) { return supertestRequest[method]; }; +var createSupertestHandlerCreator = function (supertestRequest) { + return function (routeName, routes, replaceParamsInUrl) { + var route = routes[routeName]; + return function () { + var args_1 = []; + for (var _i = 0; _i < arguments.length; _i++) { + args_1[_i] = arguments[_i]; + } + return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (_a) { + var queryParamsWithCorrectArrays, result; + var _b = _a === void 0 ? {} : _a, headers = _b.headers, body = _b.body, queryParams = _b.queryParams, urlParams = _b.urlParams; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + queryParamsWithCorrectArrays = Object.fromEntries(Object.entries(queryParams !== null && queryParams !== void 0 ? queryParams : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + return [ + Array.isArray(value) ? "".concat(key, "[]") : key, + value, + ]; + })); + return [4 /*yield*/, supertestRequestToCorrectHttpMethod(supertestRequest, route.method)(replaceParamsInUrl(route.url, urlParams)) + .send(body) + .set(headers !== null && headers !== void 0 ? headers : {}) + .query(queryParamsWithCorrectArrays)]; + case 1: + result = _c.sent(); + return [2 /*return*/, __assign(__assign({ status: result.status, body: result.body }, (!Object.keys(route.responses).includes(result.status.toString()) && { + text: result.text, + })), { headers: result.headers })]; + } + }); + }); + }; + }; +}; +exports.createSupertestHandlerCreator = createSupertestHandlerCreator; +var createSupertestSharedClient = function (sharedRoutes, supertestRequest) { + return (0, __1.configureCreateHttpClient)((0, exports.createSupertestHandlerCreator)(supertestRequest))(sharedRoutes); +}; +exports.createSupertestSharedClient = createSupertestSharedClient; +//# sourceMappingURL=createSupertestSharedClient.js.map \ No newline at end of file diff --git a/src/supertest/createSupertestSharedClient.js.map b/src/supertest/createSupertestSharedClient.js.map new file mode 100644 index 0000000..4d90102 --- /dev/null +++ b/src/supertest/createSupertestSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createSupertestSharedClient.js","sourceRoot":"","sources":["createSupertestSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wBAA+D;AAI/D,IAAM,mCAAmC,GAAG,UAC1C,gBAAiC,EACjC,MAAkB,IACO,OAAA,gBAAgB,CAAC,MAAM,CAAC,EAAxB,CAAwB,CAAC;AAE7C,IAAM,6BAA6B,GACxC,UAAC,gBAAiC;IAClC,OAAA,UAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB;QACpC,IAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO;;;;;iGAAO,EAA8C;;oBAA9C,qBAA4C,EAAE,KAAA,EAA5C,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,WAAW,iBAAA,EAAE,SAAS,eAAA;;;;4BAG7C,4BAA4B,GAAG,MAAM,CAAC,WAAW,CACrD,MAAM,CAAC,OAAO,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAC,EAAY;oCAAZ,KAAA,aAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;gCAAM,OAAA;oCACtD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAG,GAAG,OAAI,CAAC,CAAC,CAAC,GAAG;oCACvC,KAAK;iCACN;4BAHuD,CAGvD,CAAC,CACH,CAAC;4BAEa,qBAAM,mCAAmC,CACtD,gBAAgB,EAChB,KAAK,CAAC,MAAM,CACb,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;qCACxC,IAAI,CAAC,IAAI,CAAC;qCACV,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;qCAClB,KAAK,CAAC,4BAA4B,CAAC,EAAA;;4BANhC,MAAM,GAAG,SAMuB;4BAEtC,0CACE,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,IAAI,EAAE,MAAM,CAAC,IAAI,IACd,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI;oCACtE,IAAI,EAAE,MAAM,CAAC,IAAI;iCAClB,CAAC,KACF,OAAO,EAAE,MAAM,CAAC,OAAO,KACvB;;;;SACH,CAAC;IACJ,CAAC;AA7BD,CA6BC,CAAC;AA/BS,QAAA,6BAA6B,iCA+BtC;AAEG,IAAM,2BAA2B,GAAG,UAGzC,YAA0B,EAC1B,gBAAiC;IAEjC,OAAA,IAAA,6BAAyB,EAAC,IAAA,qCAA6B,EAAC,gBAAgB,CAAC,CAAC,CACxE,YAAY,CACb;AAFD,CAEC,CAAC;AARS,QAAA,2BAA2B,+BAQpC"} \ No newline at end of file diff --git a/src/supertest/index.d.ts b/src/supertest/index.d.ts new file mode 100644 index 0000000..8854d2a --- /dev/null +++ b/src/supertest/index.d.ts @@ -0,0 +1 @@ +export { createSupertestSharedClient } from "./createSupertestSharedClient"; diff --git a/src/supertest/index.js b/src/supertest/index.js new file mode 100644 index 0000000..5ab31f3 --- /dev/null +++ b/src/supertest/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createSupertestSharedClient = void 0; +var createSupertestSharedClient_1 = require("./createSupertestSharedClient"); +Object.defineProperty(exports, "createSupertestSharedClient", { enumerable: true, get: function () { return createSupertestSharedClient_1.createSupertestSharedClient; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/supertest/index.js.map b/src/supertest/index.js.map new file mode 100644 index 0000000..318e4f0 --- /dev/null +++ b/src/supertest/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA"} \ No newline at end of file diff --git a/src/validations.d.ts b/src/validations.d.ts new file mode 100644 index 0000000..835913d --- /dev/null +++ b/src/validations.d.ts @@ -0,0 +1,25 @@ +import type { HandlerParams } from "./configureCreateHttpClient"; +import type { UnknownSharedRoute } from "./defineRoutes"; +export type ValidationOptions = { + skipInputValidation?: boolean; + skipResponseValidation?: boolean; + skipResponseValidationForStatuses?: number[]; +}; +type ExtractFromExisting = Extract; +type CheckedSchema = ExtractFromExisting; +export declare const validateSchemaWithExplicitError: ({ checkedSchema, params, route, adapterName, responseStatus, withIssuesInMessage, }: { + checkedSchema: ExtractFromExisting; + params: unknown; + route: R; + adapterName: string; + responseStatus?: CheckedSchema extends "responses" ? keyof R["responses"] : never; + withIssuesInMessage?: boolean; +}) => unknown; +export declare const validateInputParams: (route: UnknownSharedRoute, params: HandlerParams, adapterName: string, options?: { + withIssuesInMessage: boolean; +}) => { + queryParams: unknown; + body: unknown; + headers: unknown; +}; +export {}; diff --git a/src/validations.js b/src/validations.js new file mode 100644 index 0000000..4e215bb --- /dev/null +++ b/src/validations.js @@ -0,0 +1,105 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateInputParams = exports.validateSchemaWithExplicitError = void 0; +var explicitError = function (_a) { + var _b; + var route = _a.route, error = _a.error, adapterName = _a.adapterName, checkedSchema = _a.checkedSchema, statusCode = _a.statusCode, withIssuesInMessage = _a.withIssuesInMessage; + var newError = new Error(__spreadArray([ + "Shared-route schema '".concat(checkedSchema, "' was not respected in adapter '").concat(adapterName, "'."), + checkedSchema === "responses" && + "Received status: ".concat(statusCode, ". Handled statuses: ").concat(Object.keys(route.responses).join(", "), "."), + "Route: ".concat(route.method.toUpperCase(), " ").concat(route.url) + ], __read((withIssuesInMessage && ((_b = error === null || error === void 0 ? void 0 : error.issues) === null || _b === void 0 ? void 0 : _b.length) + ? ["Issues: " + issuesToString(error === null || error === void 0 ? void 0 : error.issues)] + : [])), false).filter(Boolean) + .join("\n")); + newError.cause = error; + return newError; +}; +var validateSchemaWithExplicitError = function (_a) { + var checkedSchema = _a.checkedSchema, _b = _a.params, params = _b === void 0 ? {} : _b, route = _a.route, adapterName = _a.adapterName, responseStatus = _a.responseStatus, _c = _a.withIssuesInMessage, withIssuesInMessage = _c === void 0 ? false : _c; + try { + if (checkedSchema === "responses") { + if (!responseStatus) + throw new Error("a response status is required when validating responses"); + var schema = route[checkedSchema][responseStatus]; + if (!schema) + throw new Error("No schema found for this status."); + return schema.parse(params); + } + return route[checkedSchema].parse(params); + } + catch (error) { + throw explicitError({ + route: route, + error: error, + adapterName: adapterName, + checkedSchema: checkedSchema, + statusCode: responseStatus, + withIssuesInMessage: withIssuesInMessage, + }); + } +}; +exports.validateSchemaWithExplicitError = validateSchemaWithExplicitError; +var validateInputParams = function (route, params, adapterName, options) { + if (options === void 0) { options = { + withIssuesInMessage: false, + }; } + var withIssuesInMessage = options.withIssuesInMessage; + var queryParams = (0, exports.validateSchemaWithExplicitError)({ + adapterName: adapterName, + checkedSchema: "queryParamsSchema", + params: params.queryParams, + route: route, + withIssuesInMessage: withIssuesInMessage, + }); + var body = (0, exports.validateSchemaWithExplicitError)({ + adapterName: adapterName, + checkedSchema: "requestBodySchema", + params: params.body, + route: route, + withIssuesInMessage: withIssuesInMessage, + }); + // we validate headers separately because we don't want to re-affect req.headers parsed value + // because we don't want to lose all other headers + (0, exports.validateSchemaWithExplicitError)({ + adapterName: adapterName, + checkedSchema: "headersSchema", + params: params.headers, + route: route, + }); + return { queryParams: queryParams, body: body, headers: params.headers }; +}; +exports.validateInputParams = validateInputParams; +var issuesToString = function (issues) { + return issues.map(function (_a) { + var message = _a.message, path = _a.path; + return "".concat(path.join("."), ": ").concat(message); + }).join(" | "); +}; +//# sourceMappingURL=validations.js.map \ No newline at end of file diff --git a/src/validations.js.map b/src/validations.js.map new file mode 100644 index 0000000..d5babd4 --- /dev/null +++ b/src/validations.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validations.js","sourceRoot":"","sources":["validations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAM,aAAa,GAAG,UAAC,EActB;;QAbC,KAAK,WAAA,EACL,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,mBAAmB,yBAAA;IASnB,IAAM,QAAQ,GAAG,IAAI,KAAK,CACxB;QACE,+BAAwB,aAAa,6CAAmC,WAAW,OAAI;QACvF,aAAa,KAAK,WAAW;YAC3B,2BAAoB,UAAU,iCAAuB,MAAM,CAAC,IAAI,CAC9D,KAAK,CAAC,SAAS,CAChB,CAAC,IAAI,CAAC,IAAI,CAAC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,CAA8E,CAAC"} \ No newline at end of file diff --git a/test/createAxiosAndFetchSharedClient.test.d.ts b/test/createAxiosAndFetchSharedClient.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/createAxiosAndFetchSharedClient.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/createAxiosAndFetchSharedClient.test.js b/test/createAxiosAndFetchSharedClient.test.js new file mode 100644 index 0000000..42c4901 --- /dev/null +++ b/test/createAxiosAndFetchSharedClient.test.js @@ -0,0 +1,370 @@ +"use strict"; +/* eslint-disable @typescript-eslint/no-unused-expressions */ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var axios_1 = __importDefault(require("axios")); +var src_1 = require("../src"); +var zod_1 = require("zod"); +var axios_2 = require("../src/axios"); +var fetch_1 = require("../src/fetch"); +var vitest_1 = require("vitest"); +(0, vitest_1.describe)("createAxiosSharedCaller", function () { + (0, vitest_1.it)("create a caller from axios and sharedRoutes object", function () { return __awaiter(void 0, void 0, void 0, function () { + var bookSchema, withAuthorizationSchema, routes, axiosSharedCaller, _notExecuted; + return __generator(this, function (_a) { + bookSchema = zod_1.z.object({ title: zod_1.z.string(), author: zod_1.z.string() }); + withAuthorizationSchema = zod_1.z.object({ authorization: zod_1.z.string() }); + routes = (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "get", + url: "/books", + queryParamsSchema: zod_1.z.object({ max: zod_1.z.number() }), + responses: { 200: zod_1.z.array(bookSchema) }, + }), + getByTitle: (0, src_1.defineRoute)({ + method: "get", + url: "/books/:title", + responses: { 200: bookSchema, 404: zod_1.z.object({ message: zod_1.z.string() }) }, + }), + }); + axiosSharedCaller = (0, axios_2.createAxiosSharedClient)(routes, axios_1.default); + (0, vitest_1.expect)((0, src_1.listRoutes)(routes)).toEqual([ + "POST /books", + "GET /books", + "GET /books/:title", + ]); + _notExecuted = function () { return __awaiter(void 0, void 0, void 0, function () { + var addBookResponse, getAllBooksResponse, getByTitleResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, axiosSharedCaller.addBook({ + body: { title: "lala", author: "bob" }, + headers: { authorization: "some-token" }, + })]; + case 1: + addBookResponse = _a.sent(); + addBookResponse.body; // type is void, as expected + return [4 /*yield*/, axiosSharedCaller.getAllBooks({ + queryParams: { max: 3 }, + })]; + case 2: + getAllBooksResponse = _a.sent(); + getAllBooksResponse.body; // type is Book[], as expected + return [4 /*yield*/, axiosSharedCaller.getByTitle({ + urlParams: { title: "great" }, + })]; + case 3: + getByTitleResponse = _a.sent(); + if (getByTitleResponse.status === 404) { + getByTitleResponse.body; // type is { message: string }, as expected + } + else { + getByTitleResponse.body; // type is Book, as expected + } + return [2 /*return*/]; + } + }); + }); }; + return [2 /*return*/]; + }); + }); }); + (0, vitest_1.describe)("Actually calling an endpoint", function () { + // WARNING : This test uses an actual placeholder api (which might not always be available...) + var todoSchema = zod_1.z.object({ + userId: zod_1.z.number(), + id: zod_1.z.number(), + title: zod_1.z.string(), + completed: zod_1.z.boolean(), + }); + var routes = (0, src_1.defineRoutes)({ + getByTodoById: (0, src_1.defineRoute)({ + method: "get", + url: "https://jsonplaceholder.typicode.com/todos/:todoId", + queryParamsSchema: zod_1.z.object({ userId: zod_1.z.number(), max: zod_1.z.number().optional() }), + responses: { + 200: todoSchema, + 400: zod_1.z.object({ message: zod_1.z.string() }), + }, + }), + addPost: (0, src_1.defineRoute)({ + method: "post", + url: "https://jsonplaceholder.typicode.com/posts", + requestBodySchema: zod_1.z.object({ + title: zod_1.z.string(), + body: zod_1.z.string(), + userId: zod_1.z.number(), + }), + responses: { 201: zod_1.z.object({ id: zod_1.z.number() }) }, + }), + updatePostWithIncorrectReturnCode: (0, src_1.defineRoute)({ + method: "put", + url: "https://jsonplaceholder.typicode.com/posts/:postId", + requestBodySchema: zod_1.z.object({ + title: zod_1.z.string(), + body: zod_1.z.string(), + userId: zod_1.z.number(), + }), + responses: { 208: zod_1.z.object({ id: zod_1.z.number() }) }, + }), + }); + vitest_1.it.each([ + { name: "axios", httpClient: (0, axios_2.createAxiosSharedClient)(routes, axios_1.default) }, + { name: "fetch", httpClient: (0, fetch_1.createFetchSharedClient)(routes, fetch) }, + ])("actually calls a placeholder endpoint, using $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var response, expectedResponseBody, addPostResponse; + var httpClient = _b.httpClient, name = _b.name; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + (0, vitest_1.expect)((0, src_1.listRoutes)(routes)).toEqual([ + "GET https://jsonplaceholder.typicode.com/todos/:todoId", + "POST https://jsonplaceholder.typicode.com/posts", + "PUT https://jsonplaceholder.typicode.com/posts/:postId", + ]); + return [4 /*yield*/, httpClient.getByTodoById({ + urlParams: { todoId: "3" }, + queryParams: { userId: 1, max: undefined }, + })]; + case 1: + response = _c.sent(); + expectedResponseBody = { + id: 3, + userId: 1, + completed: false, + title: "fugiat veniam minus", + }; + (0, vitest_1.expect)(response.body).toEqual(expectedResponseBody); + (0, vitest_1.expect)(response.status).toBe(200); + return [4 /*yield*/, httpClient.addPost({ + body: { title: "My great post", body: "Some content", userId: 1 }, + })]; + case 2: + addPostResponse = _c.sent(); + (0, vitest_1.expect)(addPostResponse.body.id).toBeTypeOf("number"); + (0, vitest_1.expect)(addPostResponse.status).toBe(201); + (0, vitest_1.expect)(addPostResponse.headers).toMatchObject({ + "content-type": "application/json; charset=utf-8", + }); + return [4 /*yield*/, (0, vitest_1.expect)(httpClient.addPost({ body: { wrong: "body" } })).rejects.toThrow([ + "Shared-route schema 'requestBodySchema' was not respected in adapter '".concat(name, "'."), + "Route: POST https://jsonplaceholder.typicode.com/posts", + "Issues: title: Required | body: Required | userId: Required", + ].join("\n"))]; + case 3: + _c.sent(); + return [4 /*yield*/, (0, vitest_1.expect)(httpClient.updatePostWithIncorrectReturnCode({ + urlParams: { postId: "1" }, + body: { title: "My great post", body: "Some content", userId: 1 }, + })).rejects.toThrow([ + "Shared-route schema 'responses' was not respected in adapter '".concat(name, "'."), + "Received status: 200. Handled statuses: 208.", + "Route: PUT https://jsonplaceholder.typicode.com/posts/:postId", + ].join("\n"))]; + case 4: + _c.sent(); + return [2 /*return*/]; + } + }); + }); }, { timeout: 3000 }); + vitest_1.it.each([ + { + name: "axios", + httpClient: (0, axios_2.createAxiosSharedClient)(routes, axios_1.default, { skipInputValidation: true }), + }, + { + name: "fetch", + httpClient: (0, fetch_1.createFetchSharedClient)(routes, fetch, { skipInputValidation: true }), + }, + ])("can skip the validation for input params or response, for $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var response, addPostResponse; + var httpClient = _b.httpClient; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: return [4 /*yield*/, httpClient.addPost({ body: { wrong: "body" } })]; + case 1: + response = _c.sent(); + (0, vitest_1.expect)(response.body).toBeTruthy(); + return [4 /*yield*/, httpClient.addPost({ + body: { title: "My great post", body: "Some content", userId: 1 }, + })]; + case 2: + addPostResponse = _c.sent(); + (0, vitest_1.expect)(addPostResponse.body.id).toBeTypeOf("number"); + return [2 /*return*/]; + } + }); + }); }); + var skippedStatuses = [200]; + vitest_1.it.each([ + { + name: "axios", + httpClient: (0, axios_2.createAxiosSharedClient)(routes, axios_1.default, { + skipResponseValidationForStatuses: skippedStatuses, + }), + }, + { + name: "fetch", + httpClient: (0, fetch_1.createFetchSharedClient)(routes, fetch, { + skipResponseValidationForStatuses: skippedStatuses, + }), + }, + ])("can skip the response validation for some selected statuses, for $name", function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var postId, body, response; + var httpClient = _b.httpClient; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + postId = "1"; + body = { title: "My great post", body: "Some content", userId: 1 }; + return [4 /*yield*/, httpClient.updatePostWithIncorrectReturnCode({ + urlParams: { postId: "1" }, + body: body, + })]; + case 1: + response = _c.sent(); + (0, vitest_1.expect)(response.status).toBe(200); + (0, vitest_1.expect)(response.body).toEqual(__assign(__assign({}, body), { id: +postId })); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.describe)("explicit error when calling without respecting the contract", function () { + var todoSchema = zod_1.z.object({ + userId: zod_1.z.number(), + id: zod_1.z.number(), + title: zod_1.z.string(), + completed: zod_1.z.boolean(), + }); + var routes = (0, src_1.defineRoutes)({ + getTodos: (0, src_1.defineRoute)({ + method: "get", + url: "https://jsonplaceholder.typicode.com/todos", + queryParamsSchema: zod_1.z.object({ userId: zod_1.z.number(), max: zod_1.z.number().optional() }), + responses: { 200: zod_1.z.array(zod_1.z.number()) }, // this is not the correct schema, we want to trigger an error on return + }), + addTodo: (0, src_1.defineRoute)({ + method: "post", + url: "https://jsonplaceholder.typicode.com/todos", + requestBodySchema: todoSchema, + headersSchema: zod_1.z.object({ authorization: zod_1.z.string() }), + }), + }); + var httpClient = (0, fetch_1.createFetchSharedClient)(routes, fetch); + (0, vitest_1.it)("when query params are wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, (0, vitest_1.expect)(httpClient.getTodos({ queryParams: { userWrongKey: "yolo" } })).rejects.toThrow([ + "Shared-route schema 'queryParamsSchema' was not respected in adapter 'fetch'.", + "Route: GET https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("when response body is wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, (0, vitest_1.expect)(httpClient.getTodos({ queryParams: { userId: 1 } })).rejects.toThrow([ + "Shared-route schema 'responses' was not respected in adapter 'fetch'.", + "Received status: 200. Handled statuses: 200.", + "Route: GET https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("when request body is wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, (0, vitest_1.expect)(httpClient.addTodo({ + body: { wrong: "yolo" }, + headers: { authorization: "some-token" }, + })).rejects.toThrow([ + "Shared-route schema 'requestBodySchema' was not respected in adapter 'fetch'.", + "Route: POST https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("when headers are wrong", function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, (0, vitest_1.expect)(httpClient.addTodo({ + body: { id: 123, userId: 456, title: "some title", completed: false }, + headers: { auth: "some-token" }, + })).rejects.toThrow([ + "Shared-route schema 'headersSchema' was not respected in adapter 'fetch'.", + "Route: POST https://jsonplaceholder.typicode.com/todos", + ].join("\n"))]; + case 1: + _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + }); + }); +}); +//# sourceMappingURL=createAxiosAndFetchSharedClient.test.js.map \ No newline at end of file diff --git a/test/createAxiosAndFetchSharedClient.test.js.map b/test/createAxiosAndFetchSharedClient.test.js.map new file mode 100644 index 0000000..1bba7ad --- /dev/null +++ b/test/createAxiosAndFetchSharedClient.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createAxiosAndFetchSharedClient.test.js","sourceRoot":"","sources":["createAxiosAndFetchSharedClient.test.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;;;;;;;;;;;;;;;;;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,CAAC,CAAC;YAEH,IAAA,WAAE,EAAC,wBAAwB,EAAE;;;gCAC3B,qBAAM,IAAA,eAAM,EACV,UAAU,CAAC,OAAO,CAAC;gCACjB,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE;gCACrE,OAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAS;6BACvC,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CACf;gCACE,2EAA2E;gCAC3E,wDAAwD;6BACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,EAAA;;4BAVD,SAUC,CAAC;;;;iBACH,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/createCustomSharedClient.test.d.ts b/test/createCustomSharedClient.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/createCustomSharedClient.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/createCustomSharedClient.test.js b/test/createCustomSharedClient.test.js new file mode 100644 index 0000000..17f2baa --- /dev/null +++ b/test/createCustomSharedClient.test.js @@ -0,0 +1,131 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var zod_1 = require("zod"); +var vitest_1 = require("vitest"); +var src_1 = require("../src"); +var bookSchema = zod_1.z.object({ + title: zod_1.z.string(), + author: zod_1.z.string(), +}); +var withAuthorizationSchema = zod_1.z.object({ authorization: zod_1.z.string() }); +var myRoutes = (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "get", + url: "/books", + queryParamsSchema: zod_1.z.object({ max: zod_1.z.number() }), + responses: { 200: zod_1.z.array(bookSchema) }, + }), + getByTitle: (0, src_1.defineRoute)({ + method: "get", + url: "/books/:title", + responses: { 200: bookSchema.optional() }, + }), +}); +// const books: Book[] = []; +var createTestHttpClient = function () { + var books = []; + return (0, src_1.createCustomSharedClient)(myRoutes, { + addBook: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var body = _b.body; + return __generator(this, function (_c) { + books.push(body); + return [2 /*return*/, { status: 201, body: undefined, headers: {} }]; + }); + }); }, + getAllBooks: function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, ({ + status: 200, + body: books, + headers: {}, + })]; + }); + }); }, + getByTitle: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { + var title = _b.urlParams.title; + return __generator(this, function (_c) { + return [2 /*return*/, ({ + status: 200, + body: books.find(function (book) { return book.title.toLowerCase().includes(title.toLowerCase()); }), + headers: {}, + })]; + }); + }); }, + }); +}; +var httpClient = createTestHttpClient(); +(0, vitest_1.describe)("createCustomSharedClient", function () { + (0, vitest_1.it)("all routes work fine", function () { return __awaiter(void 0, void 0, void 0, function () { + var myBook, response, allBooks, fetchedBook; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + myBook = { title: "Harry Potter", author: "J.K. Rowling" }; + return [4 /*yield*/, httpClient.addBook({ + body: myBook, + headers: { authorization: "my-token" }, + })]; + case 1: + response = _a.sent(); + (0, vitest_1.expect)(response.status).toBe(201); + (0, vitest_1.expect)(response.body).toBe(undefined); + return [4 /*yield*/, httpClient.getAllBooks({ + queryParams: { max: 12 }, + })]; + case 2: + allBooks = (_a.sent()).body; + (0, vitest_1.expect)(allBooks).toEqual([myBook]); + return [4 /*yield*/, httpClient.getByTitle({ + urlParams: { title: "potter" }, + })]; + case 3: + fetchedBook = (_a.sent()).body; + (0, vitest_1.expect)(fetchedBook).toEqual(myBook); + return [2 /*return*/]; + } + }); + }); }); +}); +//# sourceMappingURL=createCustomSharedClient.test.js.map \ No newline at end of file diff --git a/test/createCustomSharedClient.test.js.map b/test/createCustomSharedClient.test.js.map new file mode 100644 index 0000000..14d8bf0 --- /dev/null +++ b/test/createCustomSharedClient.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createCustomSharedClient.test.js","sourceRoot":"","sources":["createCustomSharedClient.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAwB;AACxB,iCAA8C;AAC9C,8BAA6E;AAG7E,IAAM,UAAU,GAAmB,OAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AACH,IAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAExE,IAAM,QAAQ,GAAG,IAAA,kBAAY,EAAC;IAC5B,OAAO,EAAE,IAAA,iBAAW,EAAC;QACnB,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,QAAQ;QACb,iBAAiB,EAAE,UAAU;QAC7B,aAAa,EAAE,uBAAuB;KACvC,CAAC;IACF,WAAW,EAAE,IAAA,iBAAW,EAAC;QACvB,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,QAAQ;QACb,iBAAiB,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QAChD,SAAS,EAAE,EAAE,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;KACxC,CAAC;IACF,UAAU,EAAE,IAAA,iBAAW,EAAC;QACtB,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,eAAe;QACpB,SAAS,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE;KAC1C,CAAC;CACH,CAAC,CAAC;AAEH,4BAA4B;AAE5B,IAAM,oBAAoB,GAAG;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AG,CAAC,CAAC;oBAClC,IAAA,eAAM,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAEX,qBAAM,UAAU,CAAC,WAAW,CAAC;4BACtD,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;yBACzB,CAAC,EAAA;;oBAFY,QAAQ,GAAK,CAAA,SAEzB,CAAA,KAFoB;oBAGtB,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;oBAEL,qBAAM,UAAU,CAAC,UAAU,CAAC;4BACxD,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;yBAC/B,CAAC,EAAA;;oBAFY,WAAW,GAAK,CAAA,SAE5B,CAAA,KAFuB;oBAGzB,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;;;;SACrC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/createOpenApiGenerator.test.d.ts b/test/createOpenApiGenerator.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/createOpenApiGenerator.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/createOpenApiGenerator.test.js b/test/createOpenApiGenerator.test.js new file mode 100644 index 0000000..a1fc6f4 --- /dev/null +++ b/test/createOpenApiGenerator.test.js @@ -0,0 +1,347 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var src_1 = require("../src"); +var zod_1 = require("zod"); +var openapi_1 = require("../src/openapi"); +var vitest_1 = require("vitest"); +var bookSchema = zod_1.z.object({ title: zod_1.z.string(), author: zod_1.z.string() }); +var withAuthorizationSchema = zod_1.z.object({ authorization: zod_1.z.string() }); +var routes = (0, src_1.defineRoutes)({ + getAllBooks: (0, src_1.defineRoute)({ + url: "/books", + method: "get", + queryParamsSchema: zod_1.z.object({ + max: zod_1.z.number().optional(), + truc: zod_1.z.string(), + }), + responses: { 200: zod_1.z.array(bookSchema) }, + }), + getByTitle: (0, src_1.defineRoute)({ + url: "/books/:title", + method: "get", + responses: { 200: bookSchema, 404: zod_1.z.object({ message: zod_1.z.string() }) }, + }), + addBook: (0, src_1.defineRoute)({ + url: "/books", + method: "post", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), +}); +var rootInfo = { + info: { + title: "My book API", + description: "My test openApi description", + version: "1", + }, + servers: [{ url: "/api" }], + openapi: "3.1.0", + components: { + securitySchemes: { + apiKeyAuth: { + description: "The API key to access this API", + type: "apiKey", + in: "header", + name: "authorization", + }, + }, + }, +}; +var generateOpenApi = (0, openapi_1.createOpenApiGenerator)({ Books: routes }, rootInfo); +var generateOpenApiJSON = function () { + return generateOpenApi({ + Books: { + addBook: { + summary: "To add a book", + description: "To add a book", + extraDocs: { + securitySchemeToApply: ["apiKeyAuth"], + headerParams: { + authorization: { + example: "my-auth-token", + }, + }, + body: { + title: "my Book", + description: "Represents a book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: { + title: "Harry Potter (addBook body)", + author: "JK Rowlings (addBook body)", + }, + }, + miserables: { + summary: "Miserables summary (getByTitle param)", + description: "Miserables description (getByTitle param)", + value: { + title: "Les miserables (addBook body)", + author: "Victor Hugo (addBook body)", + }, + }, + }, + }, + responses: { + 201: { + description: "Success 201 for addBook. Returns void", + }, + }, + }, + }, + getByTitle: { + extraDocs: { + urlParams: { + title: { + description: "The title of the book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: "harry-potter", + }, + }, + }, + }, + responses: { + "200": { + description: "Success 200 for getByTitle", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle 200)", + description: "Harry Potter description (getByTitle 200)", + value: { + title: "Harry Potter (getByTitle 200)", + author: "JK Rowlings (getByTitle 200)", + }, + }, + lordOfRing: { + summary: "Lord of the ring summary (getByTitle 200)", + description: "Lord of the ring description (getByTitle 200)", + value: { + title: "Lord of the ring (getByTitle 200)", + author: "Tolkien (getByTitle 200)", + }, + }, + }, + }, + 404: { + description: "Not found 404 for getByTitle", + }, + }, + }, + }, + getAllBooks: { + summary: "To get all books", + description: "To get all books", + extraDocs: { + queryParams: { + max: { + description: "Le maximum à retourner", + example: 15, + allowEmptyValue: true, + }, + truc: { deprecated: true, example: "machin..." }, + }, + responses: { + 200: { + description: "Success 200 for getAllBooks", + }, + }, + }, + }, + }, + }); +}; +var bookJsonSchema = { + additionalProperties: false, + type: "object", + properties: { + title: { type: "string" }, + author: { type: "string" }, + }, + required: ["title", "author"], +}; +var expected = __assign(__assign({}, rootInfo), { paths: { + "/books": { + get: { + summary: "To get all books", + description: "To get all books", + tags: ["Books"], + parameters: [ + { + allowEmptyValue: true, + description: "Le maximum à retourner", + example: 15, + name: "max", + required: false, + schema: { type: "number" }, + in: "query", + }, + { + example: "machin...", + deprecated: true, + in: "query", + name: "truc", + required: true, + schema: { type: "string" }, + }, + ], + responses: { + "200": { + description: "Success 200 for getAllBooks", + content: { + "application/json": { + schema: { + type: "array", + items: bookJsonSchema, + }, + }, + }, + }, + }, + }, + post: { + summary: "To add a book", + description: "To add a book", + tags: ["Books"], + security: [{ apiKeyAuth: [] }], + parameters: [ + { + in: "header", + example: "my-auth-token", + name: "authorization", + required: true, + schema: { + type: "string", + }, + }, + ], + requestBody: { + content: { + "application/json": { + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: { + title: "Harry Potter (addBook body)", + author: "JK Rowlings (addBook body)", + }, + }, + miserables: { + summary: "Miserables summary (getByTitle param)", + description: "Miserables description (getByTitle param)", + value: { + title: "Les miserables (addBook body)", + author: "Victor Hugo (addBook body)", + }, + }, + }, + schema: __assign(__assign({ title: "my Book", description: "Represents a book" }, bookJsonSchema), { additionalProperties: undefined }), + }, + }, + required: true, + }, + responses: { + "201": { + description: "Success 201 for addBook. Returns void", + content: { + "application/json": { + schema: { + anyOf: [ + { + maxLength: 0, + type: "string", + }, + ], + }, + }, + }, + }, + }, + }, + }, + "/books/{title}": { + get: { + tags: ["Books"], + parameters: [ + { + description: "The title of the book", + examples: { + harry: { + summary: "Harry Potter summary (getByTitle param)", + description: "Harry Potter description (getByTitle param)", + value: "harry-potter", + }, + }, + name: "title", + required: true, + schema: { type: "string" }, + in: "path", + }, + ], + responses: { + "404": { + "content": { + "application/json": { + "schema": { + "properties": { + "message": { type: "string" }, + }, + "required": ["message"], + "type": "object", + }, + }, + }, + "description": "Not found 404 for getByTitle", + }, + "200": { + description: "Success 200 for getByTitle", + content: { + "application/json": { + schema: __assign(__assign({}, bookJsonSchema), { additionalProperties: undefined }), + examples: { + harry: { + summary: "Harry Potter summary (getByTitle 200)", + description: "Harry Potter description (getByTitle 200)", + value: { + title: "Harry Potter (getByTitle 200)", + author: "JK Rowlings (getByTitle 200)", + }, + }, + lordOfRing: { + summary: "Lord of the ring summary (getByTitle 200)", + description: "Lord of the ring description (getByTitle 200)", + value: { + title: "Lord of the ring (getByTitle 200)", + author: "Tolkien (getByTitle 200)", + }, + }, + }, + }, + }, + }, + }, + }, + }, + } }); +(0, vitest_1.it)("has the expected shape", function () { + var openApiJSON = generateOpenApiJSON(); + // console.log("--- Actual SPEC ---"); + // console.log(JSON.stringify(openApiJSON, null, 2)); + (0, vitest_1.expect)(openApiJSON).toEqual(expected); +}); +//# sourceMappingURL=createOpenApiGenerator.test.js.map \ No newline at end of file diff --git a/test/createOpenApiGenerator.test.js.map b/test/createOpenApiGenerator.test.js.map new file mode 100644 index 0000000..de1e0ed --- /dev/null +++ b/test/createOpenApiGenerator.test.js.map @@ -0,0 +1 @@ +{"version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M,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC1B,EAAE,EAAE,MAAM;qBACX;iBACF;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,SAAS,EAAE;4BACT,kBAAkB,EAAE;gCAClB,QAAQ,EAAE;oCACR,YAAY,EAAE;wCACZ,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qCAC9B;oCACD,UAAU,EAAE,CAAC,SAAS,CAAC;oCACvB,MAAM,EAAE,QAAQ;iCACjB;6BACF;yBACF;wBACD,aAAa,EAAE,8BAA8B;qBAC9C;oBACD,KAAK,EAAE;wBACL,WAAW,EAAE,4BAA4B;wBACzC,OAAO,EAAE;4BACP,kBAAkB,EAAE;gCAClB,MAAM,wBAAO,cAAc,KAAE,oBAAoB,EAAE,SAAS,GAAE;gCAC9D,QAAQ,EAAE;oCACR,KAAK,EAAE;wCACL,OAAO,EAAE,uCAAuC;wCAChD,WAAW,EAAE,2CAA2C;wCACxD,KAAK,EAAE;4CACL,KAAK,EAAE,+BAA+B;4CACtC,MAAM,EAAE,8BAA8B;yCACvC;qCACF;oCACD,UAAU,EAAE;wCACV,OAAO,EAAE,2CAA2C;wCACpD,WAAW,EAAE,+CAA+C;wCAC5D,KAAK,EAAE;4CACL,KAAK,EAAE,mCAAmC;4CAC1C,MAAM,EAAE,0BAA0B;yCACnC;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,GACF,CAAC;AAEF,IAAA,WAAE,EAAC,wBAAwB,EAAE;IAC3B,IAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,sCAAsC;IACtC,qDAAqD;IAErD,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/defineRoutes.test.d.ts b/test/defineRoutes.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/defineRoutes.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/defineRoutes.test.js b/test/defineRoutes.test.js new file mode 100644 index 0000000..3a41ffe --- /dev/null +++ b/test/defineRoutes.test.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var zod_1 = require("zod"); +var vitest_1 = require("vitest"); +var src_1 = require("../src"); +(0, vitest_1.describe)("Shared routes definitions", function () { + (0, vitest_1.describe)("defineRoutes", function () { + (0, vitest_1.it)("does not allow 2 routes with same method and url", function () { + var createMySharedRoutes = function () { + return (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: zod_1.z.object({ title: zod_1.z.string() }), + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + responses: { 200: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), name: zod_1.z.string() })) }, + }), + }); + }; + (0, vitest_1.expect)(createMySharedRoutes).toThrowError(new Error("You cannot have several routes with same http method and url, got: POST /books twice (at least)")); + }); + (0, vitest_1.it)("create routes with the expected types and shows list of routes", function () { + var routes = (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: zod_1.z.object({ title: zod_1.z.string() }), + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "get", + url: "/books", + queryParamsSchema: zod_1.z.object({ lala: zod_1.z.string() }), + responses: { 200: zod_1.z.array(zod_1.z.object({ id: zod_1.z.string(), name: zod_1.z.string() })) }, + }), + }); + (0, vitest_1.expect)(function () { return routes.getAllBooks.requestBodySchema.parse({ yo: "lala" }); }).toThrow(); + (0, vitest_1.expect)((0, src_1.listRoutes)(routes)).toEqual(["POST /books", "GET /books"]); + }); + }); +}); +//# sourceMappingURL=defineRoutes.test.js.map \ No newline at end of file diff --git a/test/defineRoutes.test.js.map b/test/defineRoutes.test.js.map new file mode 100644 index 0000000..1534974 --- /dev/null +++ b/test/defineRoutes.test.js.map @@ -0,0 +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;gBACF,WAAW,EAAE,IAAA,iBAAW,EAAC;oBACvB,MAAM,EAAE,KAAK;oBACb,GAAG,EAAE,QAAQ;oBACb,iBAAiB,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACjD,SAAS,EAAE,EAAE,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE;iBAC5E,CAAC;aACH,CAAC,CAAC;YAEH,IAAA,eAAM,EAAC,cAAM,OAAA,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAA1D,CAA0D,CAAC,CAAC,OAAO,EAAE,CAAC;YACnF,IAAA,eAAM,EAAC,IAAA,gBAAU,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/expressAndSupertest.test.d.ts b/test/expressAndSupertest.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/test/expressAndSupertest.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/expressAndSupertest.test.js b/test/expressAndSupertest.test.js new file mode 100644 index 0000000..b6069ae --- /dev/null +++ b/test/expressAndSupertest.test.js @@ -0,0 +1,294 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var src_1 = require("../src"); +var express_1 = require("../src/express"); +var zod_1 = require("zod"); +var createSupertestSharedClient_1 = require("../src/supertest/createSupertestSharedClient"); +var supertest_1 = __importDefault(require("supertest")); +var express_2 = __importDefault(require("express")); +var body_parser_1 = __importDefault(require("body-parser")); +var express_3 = require("express"); +var vitest_1 = require("vitest"); +var zNumberFromString = zod_1.z.preprocess(function (v) { + var n = parseInt(v); + return isNaN(n) ? v : n; +}, zod_1.z.number()); +var bookSchema = zod_1.z.object({ + title: zod_1.z.string(), + author: zod_1.z.string(), +}); +var withAuthorizationSchema = zod_1.z.object({ authorization: zod_1.z.string() }); +var routes = (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + headersSchema: withAuthorizationSchema, + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "get", + url: "/books", + queryParamsSchema: zod_1.z.object({ + max: zNumberFromString, + startWith: zod_1.z.array(zod_1.z.string()), + }), + responses: { 200: zod_1.z.array(bookSchema) }, + }), + getBookByTitle: (0, src_1.defineRoute)({ + method: "get", + url: "/books/:title", + responses: { + 200: bookSchema, + 404: zod_1.z.object({ message: zod_1.z.string() }), + }, + }), + getBookWithoutParams: (0, src_1.defineRoute)({ + method: "get", + url: "/no-params", + responses: { 200: bookSchema.optional() }, + }), +}); +var fakeAuthToken = "my-token"; +var createBookRouter = function () { + var bookDB = []; + var expressRouter = (0, express_3.Router)(); + var expressSharedRouter = (0, express_1.createExpressSharedRouter)(routes, expressRouter); + var someMiddleware = function (_req, _res, next) { + next(); + }; + expressSharedRouter.getAllBooks(function (_, res) { + console.log("yeah reached ! ", bookDB); + return res.json(bookDB); + }); + expressSharedRouter.addBook(someMiddleware, function (req, res) { + if (req.headers.authorization !== fakeAuthToken) { + res.status(401); + return res.json(); + } + bookDB.push(req.body); + return res.json(); + }); + expressSharedRouter.getBookByTitle(function (req, res) { + if (req.params.title === "throw") + throw new Error("Some unexpected error"); + var book = bookDB.find(function (b) { return b.title === req.params.title; }); + if (!book) { + return res.status(404).json({ message: "Book not found" }); + } + return res.status(200).json(book); + }); + expressSharedRouter.getBookWithoutParams(function (_, res) { + res.status(200).json(); + }); + return expressRouter; +}; +var createExempleApp = function () { + var app = (0, express_2.default)(); + app.use(body_parser_1.default.json()); + app.use(createBookRouter()); + return app; +}; +(0, vitest_1.describe)("createExpressSharedRouter and createSupertestSharedCaller", function () { + (0, vitest_1.it)("fails to add if not authenticated", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, heyBook, addBookResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = (0, supertest_1.default)(app); + supertestSharedCaller = (0, createSupertestSharedClient_1.createSupertestSharedClient)(routes, supertestRequest); + heyBook = { title: "Hey", author: "Steeve" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: heyBook, + headers: { authorization: "not-the-right-token" }, + })]; + case 1: + addBookResponse = _a.sent(); + (0, vitest_1.expect)((0, src_1.listRoutes)(routes)).toEqual([ + "POST /books", + "GET /books", + "GET /books/:title", + "GET /no-params", + ]); + (0, vitest_1.expect)(addBookResponse.body).toEqual(""); // type is void, but express sends ""; + (0, vitest_1.expect)(addBookResponse.status).toBe(401); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("fails explicitly when the schema is not respected", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, getAllBooksResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = (0, supertest_1.default)(app); + supertestSharedCaller = (0, createSupertestSharedClient_1.createSupertestSharedClient)(routes, supertestRequest); + return [4 /*yield*/, supertestSharedCaller.getAllBooks({ + queryParams: { max: "yolo" }, + })]; + case 1: + getAllBooksResponse = _a.sent(); + (0, vitest_1.expect)(getAllBooksResponse.body).toEqual({ + status: 400, + message: "Shared-route schema 'queryParamsSchema' was not respected in adapter 'express'.\nRoute: GET /books", + issues: ["max : Expected number, received string", "startWith : Required"], + }); + (0, vitest_1.expect)(getAllBooksResponse.status).toBe(400); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("create an express app and a supertest instance with the same sharedRoutes object", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, heyBook, addBookResponse, otherBook, getAllBooksResponse, fetchedBookResponse, bookNotFoundResponse, _a, body, status; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + app = createExempleApp(); + supertestRequest = (0, supertest_1.default)(app); + supertestSharedCaller = (0, createSupertestSharedClient_1.createSupertestSharedClient)(routes, supertestRequest); + heyBook = { title: "Hey", author: "Steeve" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: heyBook, + headers: { authorization: fakeAuthToken }, + })]; + case 1: + addBookResponse = _b.sent(); + (0, vitest_1.expect)(addBookResponse.body).toEqual(""); // type is void, but express sends ""; + (0, vitest_1.expect)(addBookResponse.status).toBe(200); + otherBook = { title: "Other book", author: "Somebody" }; + return [4 /*yield*/, supertestSharedCaller.addBook({ + body: otherBook, + headers: { authorization: fakeAuthToken }, + })]; + case 2: + _b.sent(); + return [4 /*yield*/, supertestSharedCaller.getAllBooks({ + queryParams: { max: 5, startWith: ["yolo"] }, + })]; + case 3: + getAllBooksResponse = _b.sent(); + expectToEqual(getAllBooksResponse.body, [heyBook, otherBook]); + (0, vitest_1.expect)(getAllBooksResponse.status).toBe(200); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "Hey" }, + })]; + case 4: + fetchedBookResponse = _b.sent(); + expectToMatch(fetchedBookResponse, { + status: 200, + body: heyBook, + headers: { "content-type": "application/json; charset=utf-8" }, + }); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "not found" }, + })]; + case 5: + bookNotFoundResponse = _b.sent(); + expectToMatch(bookNotFoundResponse, { + status: 404, + body: { message: "Book not found" }, + headers: { "content-type": "application/json; charset=utf-8" }, + }); + return [4 /*yield*/, supertestSharedCaller.getBookWithoutParams()]; + case 6: + _a = _b.sent(), body = _a.body, status = _a.status; + (0, vitest_1.expect)(body).toBe(""); // express returns "" for void + (0, vitest_1.expect)(status).toEqual(200); + return [2 /*return*/]; + } + }); + }); }); + (0, vitest_1.it)("shows when unexpected error occurs (though it does not respect schema)", function () { return __awaiter(void 0, void 0, void 0, function () { + var app, supertestRequest, supertestSharedCaller, result; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + app = createExempleApp(); + supertestRequest = (0, supertest_1.default)(app); + supertestSharedCaller = (0, createSupertestSharedClient_1.createSupertestSharedClient)(routes, supertestRequest); + return [4 /*yield*/, supertestSharedCaller.getBookByTitle({ + urlParams: { title: "throw" }, + })]; + case 1: + result = _a.sent(); + (0, vitest_1.expect)(result.status).toBe(500); + (0, vitest_1.expect)(result.text).toContain("Some unexpected error"); + return [2 /*return*/]; + } + }); + }); }); +}); +var expectToEqual = function (actual, expected) { return (0, vitest_1.expect)(actual).toEqual(expected); }; +var expectToMatch = function (actual, expected) { + return (0, vitest_1.expect)(actual).toMatchObject(expected); +}; +// type Book = { title: string; author: string }; +// const bookSchema: z.Schema = z.object({ +// title: z.string(), +// author: z.string(), +// }); +var _routes = (0, src_1.defineRoutes)({ + addBook: (0, src_1.defineRoute)({ + method: "post", + url: "/books", + requestBodySchema: bookSchema, + }), + getAllBooks: (0, src_1.defineRoute)({ + method: "get", + url: "/books", + queryParamsSchema: zod_1.z.object({ max: zod_1.z.number() }), + responses: { + 200: zod_1.z.array(bookSchema), + }, + }), + getBookByTitle: (0, src_1.defineRoute)({ + method: "get", + url: "/books/:title", + headersSchema: zod_1.z.object({ authorization: zod_1.z.string() }), + responses: { + 200: bookSchema, + 404: zod_1.z.object({ message: zod_1.z.string() }), + }, + }), +}); +//# sourceMappingURL=expressAndSupertest.test.js.map \ No newline at end of file diff --git a/test/expressAndSupertest.test.js.map b/test/expressAndSupertest.test.js.map new file mode 100644 index 0000000..095e9f9 --- /dev/null +++ b/test/expressAndSupertest.test.js.map @@ -0,0 +1 @@ +{"version":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AAE,OAAC,CAAC,KAAK,CAAC,UAAU,CAAC;SACzB;KACF,CAAC;IACF,cAAc,EAAE,IAAA,iBAAW,EAAC;QAC1B,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,eAAe;QACpB,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACtD,SAAS,EAAE;YACT,GAAG,EAAE,UAAU;YACf,GAAG,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACvC;KACF,CAAC;CACH,CAAC,CAAC"} \ No newline at end of file diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo new file mode 100644 index 0000000..31fe51a --- /dev/null +++ b/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"fileNames":["../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/typeAliases.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/util.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/ZodError.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/locales/en.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/errors.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/parseUtil.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/enumUtil.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/errorUtil.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/helpers/partialUtil.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/types.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/external.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.d.ts","../node_modules/.pnpm/zod@3.22.4/node_modules/zod/index.d.ts","../src/pathParameters.ts","../src/defineRoutes.ts","../src/configureCreateHttpClient.ts","../src/createCustomSharedClient.ts","../src/index.ts","../src/validations.ts","../node_modules/.pnpm/axios@1.7.7/node_modules/axios/index.d.ts","../src/axios/createAxiosSharedClient.ts","../src/axios/index.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/globals.typedarray.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/buffer.buffer.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/assert.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/assert/strict.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/header.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/readable.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/file.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/fetch.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/formdata.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/connector.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/client.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/errors.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/dispatcher.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/global-dispatcher.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/global-origin.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/pool-stats.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/pool.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/handlers.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/balanced-pool.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/agent.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-interceptor.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-agent.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-client.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-pool.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/mock-errors.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/proxy-agent.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/env-http-proxy-agent.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/retry-handler.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/retry-agent.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/api.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/interceptors.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/util.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/cookies.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/patch.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/websocket.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/eventsource.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/filereader.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/diagnostics-channel.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/content-type.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/cache.d.ts","../node_modules/.pnpm/undici-types@6.19.8/node_modules/undici-types/index.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/globals.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/async_hooks.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/buffer.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/child_process.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/cluster.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/console.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/constants.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/crypto.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dgram.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dns.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dns/promises.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/domain.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/dom-events.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/events.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/fs.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/fs/promises.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/http.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/http2.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/https.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/inspector.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/module.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/net.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/os.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/path.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/perf_hooks.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/process.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/punycode.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/querystring.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/readline.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/readline/promises.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/repl.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/sea.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/sqlite.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/promises.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/consumers.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/stream/web.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/string_decoder.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/test.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/timers.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/timers/promises.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/tls.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/trace_events.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/tty.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/url.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/util.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/v8.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/vm.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/wasi.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/worker_threads.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/zlib.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/globals.global.d.ts","../node_modules/.pnpm/@types+node@22.7.4/node_modules/@types/node/ts5.6/index.d.ts","../node_modules/.pnpm/@types+mime@1.3.2/node_modules/@types/mime/index.d.ts","../node_modules/.pnpm/@types+send@0.17.1/node_modules/@types/send/index.d.ts","../node_modules/.pnpm/@types+range-parser@1.2.4/node_modules/@types/range-parser/index.d.ts","../node_modules/.pnpm/@types+qs@6.9.7/node_modules/@types/qs/index.d.ts","../node_modules/.pnpm/@types+express-serve-static-core@4.17.35/node_modules/@types/express-serve-static-core/index.d.ts","../node_modules/.pnpm/@types+mime@3.0.1/node_modules/@types/mime/Mime.d.ts","../node_modules/.pnpm/@types+mime@3.0.1/node_modules/@types/mime/index.d.ts","../node_modules/.pnpm/@types+http-errors@2.0.1/node_modules/@types/http-errors/index.d.ts","../node_modules/.pnpm/@types+serve-static@1.15.2/node_modules/@types/serve-static/index.d.ts","../node_modules/.pnpm/@types+connect@3.4.35/node_modules/@types/connect/index.d.ts","../node_modules/.pnpm/@types+body-parser@1.19.2/node_modules/@types/body-parser/index.d.ts","../node_modules/.pnpm/@types+express@4.17.17/node_modules/@types/express/index.d.ts","../src/express/createExpressSharedRouter.ts","../src/express/index.ts","../src/fetch/queryParamsToString.ts","../src/fetch/createFetchSharedClient.ts","../src/fetch/index.ts","../node_modules/.pnpm/openapi-types@12.1.0/node_modules/openapi-types/dist/index.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/Options.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/any.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/Refs.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/errorMessages.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/array.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/bigint.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/boolean.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/date.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/enum.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/intersection.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/literal.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/map.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/nativeEnum.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/never.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/null.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/nullable.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/number.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/object.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/string.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/record.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/set.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/tuple.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/undefined.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/union.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parsers/unknown.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/parseDef.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/src/zodToJsonSchema.d.ts","../node_modules/.pnpm/zod-to-json-schema@3.21.0_zod@3.22.4/node_modules/zod-to-json-schema/index.d.ts","../src/openapi/createOpenApiGenerator.ts","../src/openapi/index.ts","../node_modules/.pnpm/@types+cookiejar@2.1.2/node_modules/@types/cookiejar/index.d.ts","../node_modules/.pnpm/@types+superagent@4.1.18/node_modules/@types/superagent/index.d.ts","../node_modules/.pnpm/@types+supertest@2.0.12/node_modules/@types/supertest/index.d.ts","../src/supertest/createSupertestSharedClient.ts","../src/supertest/index.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/types.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/helpers.d.ts","../node_modules/.pnpm/@vitest+pretty-format@2.1.2/node_modules/@vitest/pretty-format/dist/index.d.ts","../node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/index-c1cfc5e9.d.ts","../node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/index.d.ts","../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/tasks--RurNSkd.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/types-Bxe-2Udy.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/diff.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/diff.d.ts","../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/types.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/error.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/error.d.ts","../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/index.d.ts","../node_modules/.pnpm/@types+estree@1.0.6/node_modules/@types/estree/index.d.ts","../node_modules/.pnpm/rollup@4.24.0/node_modules/rollup/dist/rollup.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/hmrPayload.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/customEvent.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/hot.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/types.d-aGj9QkWt.d.ts","../node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.d.ts","../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/source-map.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/previous-map.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/input.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/css-syntax-error.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/declaration.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/root.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/warning.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/lazy-result.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/no-work-result.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/processor.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/result.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/document.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/rule.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/node.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/comment.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/container.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/at-rule.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/list.d.ts","../node_modules/.pnpm/postcss@8.4.47/node_modules/postcss/lib/postcss.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/runtime.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/importGlob.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/types/metadata.d.ts","../node_modules/.pnpm/vite@5.4.8_@types+node@22.7.4/node_modules/vite/dist/node/index.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/environment-Ddx0EDtY.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/index-Y6kQUiCB.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/index.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/environment.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/environment.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/config.Crbj2GAb.d.ts","../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/trace-mapping.d-DLVdEqOp.d.ts","../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/index-CCsqCcr7.d.ts","../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/index.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/environment.CzISCQ7o.d.ts","../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/client.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/dist/manager.d.ts","../node_modules/.pnpm/@vitest+snapshot@2.1.2/node_modules/@vitest/snapshot/manager.d.ts","../node_modules/.pnpm/vite-node@2.1.2_@types+node@22.7.4/node_modules/vite-node/dist/server.d.ts","../node_modules/.pnpm/@vitest+utils@2.1.2/node_modules/@vitest/utils/dist/source-map.d.ts","../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/dist/utils.d.ts","../node_modules/.pnpm/@vitest+runner@2.1.2/node_modules/@vitest/runner/utils.d.ts","../node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.d.cts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/benchmark.JVlTzojj.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/reporters.DAfKSDh5.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/vite.8fk186v-.d.ts","../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/chai.d.cts","../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.d.ts","../node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/index.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/suite.BMWOKiTe.d.ts","../node_modules/.pnpm/@vitest+mocker@2.1.2_@vitest+spy@2.1.2_vite@5.4.8_@types+node@22.7.4_/node_modules/@vitest/mocker/dist/types-yDMq238q.d.ts","../node_modules/.pnpm/@vitest+mocker@2.1.2_@vitest+spy@2.1.2_vite@5.4.8_@types+node@22.7.4_/node_modules/@vitest/mocker/dist/index.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/mocker.cRtM890J.d.ts","../node_modules/.pnpm/@vitest+spy@2.1.2/node_modules/@vitest/spy/dist/index.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/worker.Chrs-_NL.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/chunks/worker.Qtv8v5nL.d.ts","../node_modules/.pnpm/vitest@2.1.2_@types+node@22.7.4/node_modules/vitest/dist/index.d.ts","../test/createAxiosAndFetchSharedClient.test.ts","../test/createCustomSharedClient.test.ts","../test/createOpenApiGenerator.test.ts","../test/defineRoutes.test.ts","../test/expressAndSupertest.test.ts"],"fileIdsList":[[70,112,127,163,173],[70,112,127,163],[70,112],[70,112,124,127,163,165,166,167],[70,112,167,168,172,174],[70,112,170],[70,112,169],[70,71,112],[70,111,112],[70,112,117,147],[70,112,113,118,124,125,132,144,155],[70,112,113,114,124,132],[70,112,115,156],[70,112,116,117,125,133],[70,112,117,144,152],[70,112,118,120,124,132],[70,111,112,119],[70,112,120,121],[70,112,124],[70,112,122,124],[70,111,112,124],[70,112,124,125,126,144,155],[70,112,124,125,126,139,144,147],[70,109,112,160],[70,109,112,120,124,127,132,144,155],[70,112,124,125,127,128,132,144,152,155],[70,112,127,129,144,152,155],[70,112,124,130],[70,112,131,155,160],[70,112,120,124,132,144],[70,112,133],[70,112,134],[70,111,112,135],[70,71,72,111,112,113,114,115,116,117,118,119,120,121,122,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161],[70,112,137],[70,112,138],[70,112,124,139,140],[70,112,139,141,156,158],[70,112,124,144,145,146,147],[70,112,144,146],[70,112,144,145],[70,112,147],[70,112,148],[70,71,112,144],[70,112,124,150,151],[70,112,150,151],[70,112,117,132,144,152],[70,112,153],[112],[69,70,71,72,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162],[70,112,132,154],[70,112,127,138,155],[70,112,117,156],[70,112,144,157],[70,112,131,158],[70,112,159],[70,112,117,124,126,135,144,155,158,160],[70,112,144,161],[70,112,125,144,163,164],[70,112,127,163,170,171],[70,112,125,127,144,163,212],[70,112,213],[70,112,221,222,226],[70,112,283],[70,112,286],[70,112,222,223,226,227,229],[70,112,222],[70,112,222,223,226],[70,112,222,223],[70,112,276],[70,112,261],[70,112,219,261],[70,112,219,261,262],[70,112,264],[70,112,272],[70,112,225],[70,112,219,224],[70,112,217],[70,112,217,218,219,221],[70,112,219],[70,112,228],[70,112,253],[70,112,251,253],[70,112,242,250,251,252,254],[70,112,240],[70,112,243,248,253,256],[70,112,239,256],[70,112,243,244,247,248,249,256],[70,112,243,244,245,247,248,256],[70,112,240,241,242,243,244,248,249,250,252,253,254,256],[70,112,238,240,241,242,243,244,245,247,248,249,250,251,252,253,254,255],[70,112,238,256],[70,112,243,245,246,248,249,256],[70,112,247,256],[70,112,248,249,253,256],[70,112,241,251],[70,112,231,232],[70,112,220],[70,81,85,112,155],[70,81,112,144,155],[70,76,112],[70,78,81,112,152,155],[70,112,132,152],[70,112,163],[70,76,112,163],[70,78,81,112,132,155],[70,73,74,77,80,112,124,144,155],[70,81,88,112],[70,73,79,112],[70,81,102,103,112],[70,77,81,112,147,155,163],[70,102,112,163],[70,75,76,112,163],[70,81,112],[70,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,103,104,105,106,107,108,112],[70,81,96,112],[70,81,88,89,112],[70,79,81,89,90,112],[70,80,112],[70,73,76,81,112],[70,81,85,89,90,112],[70,85,112],[70,79,81,84,112,155],[70,73,78,81,88,112],[70,112,144],[70,76,81,102,112,160,163],[70,112,267,268],[70,112,267],[70,112,260,267,268,281],[70,112,124,125,127,128,129,132,144,152,155,161,163,232,233,234,235,236,237,256,257,258,259],[70,112,233,234,235,236],[70,112,233,234,235],[70,112,233],[70,112,234],[70,112,232],[70,112,230,277,278,292],[70,112,219,230,263,265,292],[70,112,287],[70,112,125,144,219,222,230,260,263,266,269,270,271,273,274,275,279,281,282,292],[70,112,230,277,278,279,292],[70,112,260,280],[70,112,230,263,266,269,270,292],[70,112,160,290],[70,112,125,144,160,219,222,226,230,260,263,265,266,269,270,271,273,274,275,277,278,279,280,281,282,284,285,287,288,289,290,291,292],[70,112,208],[59,70,112],[59,70,112,182,207],[70,112,184,207],[59,70,112,183,184,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206],[59,70,112,184,185,207],[59,70,112,184,185],[59,70,112,184,207],[59,70,112,184],[70,112,184],[59,70,112,184,196,207],[59,70,112,184,190,200,207],[58,70,112],[47,48,58,70,112],[49,50,70,112],[47,48,49,51,52,56,70,112],[48,49,70,112],[57,70,112],[49,70,112],[47,48,49,52,53,54,55,70,112],[61,64,65,66,70,112],[67,70,112],[59,60,61,70,112],[61,62,70,112],[59,60,62,70,112],[59,61,64,65,70,112,175],[70,112,176],[61,64,65,70,112,178],[70,112,179],[60,61,62,63,70,112],[59,64,70,112,181,209],[70,112,210],[64,70,112,214],[70,112,215],[59,61,62,70,112],[59,64,66,68,70,112,180,292],[59,64,70,112,292],[59,64,70,112,181,211,292],[59,64,70,112,174,175,177,214,215,292]],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"9e8ca8ed051c2697578c023d9c29d6df689a083561feba5c14aedee895853999","affectsGlobalScope":true,"impliedFormat":1},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"45d8ccb3dfd57355eb29749919142d4321a0aa4df6acdfc54e30433d7176600a","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"1a94697425a99354df73d9c8291e2ecd4dddd370aed4023c2d6dee6cccb32666","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3f9fc0ec0b96a9e642f11eda09c0be83a61c7b336977f8b9fdb1e9788e925fe","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"5487b97cfa28b26b4a9ef0770f872bdbebd4c46124858de00f242c3eed7519f4","impliedFormat":1},{"version":"7a01f546ace66019156e4232a1bee2fabc2f8eabeb052473d926ee1693956265","impliedFormat":1},{"version":"fb53b1c6a6c799b7e3cc2de3fb5c9a1c04a1c60d4380a37792d84c5f8b33933b","impliedFormat":1},{"version":"8485b6da53ec35637d072e516631d25dae53984500de70a6989058f24354666f","impliedFormat":1},{"version":"ebe80346928736532e4a822154eb77f57ef3389dbe2b3ba4e571366a15448ef2","impliedFormat":1},{"version":"c2cb3c8ff388781258ea9ddbcd8a947f751bddd6886e1d3b3ea09ddaa895df80","impliedFormat":1},{"version":"f672c876c1a04a223cf2023b3d91e8a52bb1544c576b81bf64a8fec82be9969c","impliedFormat":1},{"version":"98a9cc18f661d28e6bd31c436e1984f3980f35e0f0aa9cf795c54f8ccb667ffe","impliedFormat":1},{"version":"c76b0c5727302341d0bdfa2cc2cee4b19ff185b554edb6e8543f0661d8487116","impliedFormat":1},{"version":"2a317fff5810a628d205a507998a77521120b462b03d36babf6eb387da991bee","impliedFormat":1},{"version":"f5ef066942e4f0bd98200aa6a6694b831e73200c9b3ade77ad0aa2409e8fe1b1","impliedFormat":1},{"version":"b9e99cd94f4166a245f5158f7286c05406e2a4c694619bceb7a4f3519d1d768e","impliedFormat":1},{"version":"5568d7c32e5cf5f35e092649f4e5e168c3114c800b1d7545b7ae5e0415704802","impliedFormat":1},{"version":"be139d52709c57e683b367f8e3118a064130c670cd6814e7e5b927adaf2fbb21","signature":"c7c176a5a8a12c6b3d5b28c95320448f17c7d5438485c53a086dea69ed2e6801"},{"version":"5de7af0dec19e520349c8e056c5c378e43629a8e3fcb82a7926834734f35c632","signature":"95c135e1dba8b467665b4e8d8182549223b233077505b2a457722b59d8160670"},{"version":"e0dbb166796de66935d4feda4abd94f0e692eb43cdf73979f939fa4c44f6a1c5","signature":"31a0247df93a17d637c31a4381e08db07ca42816bee5d84a7dfa3e4cbdbbf16e"},{"version":"454671610b0389f294e74f0ffbf4d72c926d9e11da889d359674ae4e3224ef6b","signature":"70aad179112a492efbeed445504038ea12e90db5f6ecf452bd13b606e9263cd9"},{"version":"76c0556d36524e5a16ef84d239fb3992c7cdef0a5535f5f63349917cca1c414c","signature":"c4acec2b887b9279da570a4f056c51a61988231afabbd200590fff738e71e422"},{"version":"5121742e05e48d112d780fe27f600499ffc950db4b605cf27efda628e81311d0","signature":"b129afb002284dfa6b890a5b67da6ce025a68245ae935678ac8ac1fe60bae382"},{"version":"01ba761ce6d75a4142858a053f45d64d255e057049ab1cc4d9a93e76b8b5c444","impliedFormat":99},{"version":"db0b4592f8b44aa0df42d3ba5f8ab20e64fe84d30cde930e572a4465c7b0ccd6","signature":"002ace4931001d9ea1f3717a109a41bf16dcfbb33fe8d9e848d8f2b791034eaf"},"2aa4a640d2afabc591928da1d45c45eedb060a69c17a90fa5e7fa0828aa15e27",{"version":"613b21ccdf3be6329d56e6caa13b258c842edf8377be7bc9f014ed14cdcfc308","affectsGlobalScope":true,"impliedFormat":1},{"version":"2d1319e6b5d0efd8c5eae07eb864a00102151e8b9afddd2d45db52e9aae002c4","affectsGlobalScope":true,"impliedFormat":1},{"version":"f6114eb1e8f70ec08816bdaa6ec740a0a7a01f25743e36f655f00157be394374","impliedFormat":1},{"version":"7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"4d2b0eb911816f66abe4970898f97a2cfc902bcd743cbfa5017fad79f7ef90d8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","impliedFormat":1},{"version":"24b8685c62562f5d98615c5a0c1d05f297cf5065f15246edfe99e81ec4c0e011","impliedFormat":1},{"version":"93507c745e8f29090efb99399c3f77bec07db17acd75634249dc92f961573387","impliedFormat":1},{"version":"339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"bb2cd9339d0201e7e78ccb6ff2f71aac103934bf35eaaa37e139ac2b68af0db8","affectsGlobalScope":true,"impliedFormat":1},{"version":"76103716ba397bbb61f9fa9c9090dca59f39f9047cb1352b2179c5d8e7f4e8d0","impliedFormat":1},{"version":"53eac70430b30089a3a1959d8306b0f9cfaf0de75224b68ef25243e0b5ad1ca3","affectsGlobalScope":true,"impliedFormat":1},{"version":"4314c7a11517e221f7296b46547dbc4df047115b182f544d072bdccffa57fc72","impliedFormat":1},{"version":"115971d64632ea4742b5b115fb64ed04bcaae2c3c342f13d9ba7e3f9ee39c4e7","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb","impliedFormat":1},{"version":"46e07db372dd75edc1a26e68f16d1b7ffb34b7ab3db5cdb3e391a3604ad7bb7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"24642567d3729bcc545bacb65ee7c0db423400c7f1ef757cab25d05650064f98","impliedFormat":1},{"version":"e6f5a38687bebe43a4cef426b69d34373ef68be9a6b1538ec0a371e69f309354","impliedFormat":1},{"version":"a6bf63d17324010ca1fbf0389cab83f93389bb0b9a01dc8a346d092f65b3605f","impliedFormat":1},{"version":"e009777bef4b023a999b2e5b9a136ff2cde37dc3f77c744a02840f05b18be8ff","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true,"impliedFormat":1},{"version":"f501a53b94ba382d9ba396a5c486969a3abc68309828fa67f916035f5d37fe2b","affectsGlobalScope":true,"impliedFormat":1},{"version":"c956ba45704d4a97f7a96923a307a6203bc0e7c4c532930d4c8ca261eaaff32a","impliedFormat":1},{"version":"ab0e88d33ccf15d8b3c891038b5a16094b0dd7e860ab0e2ba08da4384afce02b","impliedFormat":1},{"version":"954580f86c8e2a4abd5dcd1bcdf1a4c7e012495f1c39e058dc738bc93024642a","impliedFormat":1},{"version":"fa56be9b96f747e93b895d8dc2aa4fb9f0816743e6e2abb9d60705e88d4743a2","impliedFormat":1},{"version":"8257c55ff6bff6169142a35fce6811b511d857b4ae4f522cdb6ce20fd2116b2c","impliedFormat":1},{"version":"6d386bc0d7f3afa1d401afc3e00ed6b09205a354a9795196caed937494a713e6","impliedFormat":1},{"version":"3a9e5dddbd6ca9507d0c06a557535ba2224a94a2b0f3e146e8215f93b7e5b3a8","affectsGlobalScope":true,"impliedFormat":1},{"version":"d8b56de03a9f79f3fc1ac3a01a0d63bb48cc15f95a6b95549b4fb420e6030973","impliedFormat":1},{"version":"b1b6ee0d012aeebe11d776a155d8979730440082797695fc8e2a5c326285678f","impliedFormat":1},{"version":"45875bcae57270aeb3ebc73a5e3fb4c7b9d91d6b045f107c1d8513c28ece71c0","impliedFormat":1},{"version":"3c36ab47df4668254ccc170fc42e7d5116fd86a7e408d8dc220e559837cd2bbb","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f6abdaf8764ef01a552a958f45e795b5e79153b87ddad3af5264b86d2681b72","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"c6b4e0a02545304935ecbf7de7a8e056a31bb50939b5b321c9d50a405b5a0bba","impliedFormat":1},{"version":"c86b9afa9b39b12db8e877d23b48888d80f26e1fe72a95f58552746a6e1fa4fe","impliedFormat":1},{"version":"e432b0e3761ca9ba734bdd41e19a75fec1454ca8e9769bfdf8b31011854cf06a","impliedFormat":1},{"version":"e1120271ebbc9952fdc7b2dd3e145560e52e06956345e6fdf91d70ca4886464f","impliedFormat":1},{"version":"15c5e91b5f08be34a78e3d976179bf5b7a9cc28dc0ef1ffebffeb3c7812a2dca","impliedFormat":1},{"version":"a8f06c2382a30b7cb89ad2dfc48fc3b2b490f3dafcd839dadc008e4e5d57031d","impliedFormat":1},{"version":"07b9d3b7204d931acc29269c98ac3aac87ebcba6e05141552d42a4c17f895aa4","impliedFormat":1},{"version":"269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","impliedFormat":1},{"version":"93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","impliedFormat":1},{"version":"1425f76ac97ce8617d1e2fa79e9a14e0fd1cfdaa155e13d4e92403a468177bc2","affectsGlobalScope":true,"impliedFormat":1},{"version":"2754d8221d77c7b382096651925eb476f1066b3348da4b73fe71ced7801edada","impliedFormat":1},{"version":"cca97c55398b8699fa3a96ef261b01d200ed2a44d2983586ab1a81d7d7b23cd9","affectsGlobalScope":true,"impliedFormat":1},{"version":"bef91efa0baea5d0e0f0f27b574a8bc100ce62a6d7e70220a0d58af6acab5e89","affectsGlobalScope":true,"impliedFormat":1},{"version":"f59493f68eade5200559e5016b5855f7d12e6381eb6cab9ad8a379af367b3b2d","impliedFormat":1},{"version":"125e3472965f529de239d2bc85b54579fed8e0b060d1d04de6576fb910a6ec7f","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"18f5c7c4ad71748cffdd42e829398acdfd2d150a887e5f07aae4f2acab68e71b","affectsGlobalScope":true,"impliedFormat":1},{"version":"72ed3074450a4a315063278f046637afdeea90aa72b2292a7976958ceafc344a","affectsGlobalScope":true,"impliedFormat":1},{"version":"a5c09990a37469b0311a92ce8feeb8682e83918723aedbd445bd7a0f510eaaa3","impliedFormat":1},{"version":"6b29aea17044029b257e5bd4e3e4f765cd72b8d3c11c753f363ab92cc3f9f947","impliedFormat":1},{"version":"ac5ed35e649cdd8143131964336ab9076937fa91802ec760b3ea63b59175c10a","impliedFormat":1},{"version":"d008cf1330c86b37a8128265c80795397c287cecff273bc3ce3a4883405f5112","affectsGlobalScope":true,"impliedFormat":1},{"version":"78dc0513cc4f1642906b74dda42146bcbd9df7401717d6e89ea6d72d12ecb539","impliedFormat":1},{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true,"impliedFormat":1},{"version":"f2b6058d3dd78c1b4dafc97083c5d44bdfbf4155194044bd17b8fcca554e766a","impliedFormat":1},{"version":"84e3bbd6f80983d468260fdbfeeb431cc81f7ea98d284d836e4d168e36875e86","impliedFormat":1},{"version":"aad5ffa61406b8e19524738fcf0e6fda8b3485bba98626268fdf252d1b2b630a","impliedFormat":1},{"version":"16d51f964ec125ad2024cf03f0af444b3bc3ec3614d9345cc54d09bab45c9a4c","impliedFormat":1},{"version":"ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc","impliedFormat":1},{"version":"352fc8497a30bc806d7defa0043d85802e5f35a7688731ee9a21456f5cb32a94","affectsGlobalScope":true,"impliedFormat":1},{"version":"5b9ecf7da4d71cf3832dbb8336150fa924631811f488ad4690c2dfec2b4fb1d7","impliedFormat":1},{"version":"951c85f75aac041dddbedfedf565886a7b494e29ec1532e2a9b4a6180560b50e","impliedFormat":1},{"version":"f463d61cf39c3a6a5f96cdf7adfdb72a0b1d663f7b5d5b6dd042adba835430c2","impliedFormat":1},{"version":"f7a9cb83c8fbc081a8b605880d191e0d0527cde2c1b2b2b623beca8f0203a2cd","impliedFormat":1},{"version":"6d829824ead8999f87b6df21200df3c6150391b894b4e80662caa462bd48d073","impliedFormat":1},{"version":"afc559c1b93df37c25aef6b3dfa2d64325b0e112e887ee18bf7e6f4ec383fc90","impliedFormat":1},{"version":"43cdd474c5aa3340da4816bb8f1ae7f3b1bcf9e70d997afc36a0f2c432378c84","impliedFormat":1},{"version":"f5dfb17a2c06fab0dbb847629d703e98b62ef6022e924cf1d1b71cf5a96df166","signature":"d1403ad5fbb688fcbcda3b43a7545a6e463dd3ab30faefaa9597b210f70ac857"},"fa00eede2b2640bcfec133440377a75fc7d4647affa0aa68d1dad3626ec441db",{"version":"69571e322ffb287ea739ba2a674369b3790974f717e8a47d969f84543cde2da2","signature":"4714df73aa332341fd02da657beb85950e4c60eed5c7520b203e5b52b15ed992"},{"version":"4d651811ba936eb2d1f08d60df68da16abfbef58f1f505fb1caa8c3821eb99c4","signature":"fb9115021bdbf31bcf01e37dc768c57611cc03e2163c33894c9b007a832aeffd"},"8b3b10df45a1ec07333e61a4b2ed7c01a2ca295688db942bc1220d328c86eb72",{"version":"cc3e30832aff12a575919d59eb3d680ca7cc999e1041bb0fc489dbe0276b066b","impliedFormat":1},{"version":"dd804b99db086f2f0e24bb373d2a1e9d9177f32f5c8f2c7b37c99accdf835e0c","impliedFormat":1},{"version":"e70f03e85bc8a2385e538a2db0c9ee532f6a9b346872aa809f173a26df7caee1","impliedFormat":1},{"version":"264808a845721a9f3df608a5e7ed12537f976d1645f20cbb448b106068f82332","impliedFormat":1},{"version":"8d484f5d6fd888f53e7cc21957ec2370461c73d230efb3467b9fb1822901535b","impliedFormat":1},{"version":"df73b0c2aa1ffa4a9aebd72baee78edf77ce5023d4476c04eadadbcdeb2964dc","impliedFormat":1},{"version":"065cbd81319d18ffc3b81100fbc60da26daf7fa090b26edf7dd3cc8c1a6cfbc5","impliedFormat":1},{"version":"771c436459c7a2ac2604ffa55a3abd76ffe8cae6aeae700d749f0fa5e8869ff6","impliedFormat":1},{"version":"7d4a2dae1a1ee3b99563747fa815076956911a833954deed5a4aa2d9207df167","impliedFormat":1},{"version":"45f6cd001ba50294b3e9a43800b22e0798cdcdc20c214cafd55d4d7d1914c331","impliedFormat":1},{"version":"b81b383239d2f4f14515331d7017febcb23786d90c5acc9688a891010fe25d4c","impliedFormat":1},{"version":"c60f24b4fd55376e4e095914d8f5345f63b7028d50fc8a0b7ec930f82777cacf","impliedFormat":1},{"version":"5754e79fbbfbb921b60ca1ad35cfbb5940733d93110bb1a935584f90cedb1c68","impliedFormat":1},{"version":"f7fcb70b90e9664b1ff1fb8566d3af99ca1a057d0dcfb94fb69b430463acba27","impliedFormat":1},{"version":"fb3af1e7369a6a52e0382612036ddcea2d089cdb0cccadc968a975043621e5fa","impliedFormat":1},{"version":"51353ffcc4bec12870c1435205dcaedab91ef108123017fd50fe8c3aed2bec04","impliedFormat":1},{"version":"e26befbe9607e9915734929db869fd83943f66e08c8e59d7308c14f6b6e755a3","impliedFormat":1},{"version":"4f596be4c3cb6ab63476dfa81bfe5f2a75768b6fd966d4c716411b4daa98df11","impliedFormat":1},{"version":"6d0e44cb89017602b13264823b15ada2a38e2ccb2a831c3e57680a0eb57d4bed","impliedFormat":1},{"version":"5e3f90d8fbf438ecb335d40e7a830f8deba1f045a2c3a27a8f5a4cdf8f499422","impliedFormat":1},{"version":"3a98713a36fe040df4d7e10a9e57a983f814f5cac42d3fe7919a342a6b9c103f","impliedFormat":1},{"version":"5dbaf247d7887721b20d8cf0a127460782ebbdc4285868f831a2f48104f034b5","impliedFormat":1},{"version":"b44d4ecd18d153d893eb38bfd827c0d624ed6f8fed4d9622489d76b3e4847067","impliedFormat":1},{"version":"23a12ab68ec3b350709bc4c15ddd34d8afa5e94dfccb1346f663f2c4bdb4334a","impliedFormat":1},{"version":"c9dfb06ca7c62fc5a95d33362f66c2bf5bf78d61ab433e62ec44190ea4012910","impliedFormat":1},{"version":"8d8b8fea19a532864502cbe5b298aadc194b970d511998342e38e4b9dea98c48","impliedFormat":1},{"version":"97479d4a4ddc4f4db849e5d6daadda8d986f5a7c580a0d79b3763a536a62268f","impliedFormat":1},{"version":"7efebf1092b8e7dfd08b0e54ec7d86dfabfd505f820d89351d957bfbc0bb3db2","impliedFormat":1},{"version":"032ccc910e4f1baf0355a2e43bc535caec36b1e916e64491ec2cabea5593593b","impliedFormat":1},{"version":"172d26cd2a145e1d1ce28734488e5e5d777a8aba2b1d158e897ba084d251eac7","signature":"5ad4a590a49e81a866a75c7fbb8ed2e83ab0930d5ae51f7156dba5284867ef20"},"5379bd2adb109cb6c15e7f0367c2eb1986d837f9977f50915afe4fc1759522ba",{"version":"8d48b8f8a377ade8dd1f000625bc276eea067f2529cc9cafdf082d17142107d6","impliedFormat":1},{"version":"214f291323316651737db8ca0db4c14ae568a429e59fc5b4f364dd80fe72d5f6","impliedFormat":1},{"version":"76232dbb982272b182a76ad8745a9b02724dc9896e2328ce360e2c56c64c9778","impliedFormat":1},{"version":"30074783847766ab26c1da52664149c5826c25c78dfed680f840faadad5bae0e","signature":"a03049a303d95f933af688a1c541867127a1226a4a200325369c02a39320bab7"},"c16631ce27bbed5b2fe93a3b5a9b76c22b64c909633e9f9a2cca997bc890ac51",{"version":"369ba5259e66ca8c7d35e3234f7a2a0863a770fdb8266505747c65cf346a0804","impliedFormat":99},{"version":"86ecd6bc8313be39460480af6e8eed773e411781a606b1ac4354d4d16a32ed69","impliedFormat":99},{"version":"d2e64a6f25013b099e83bfadb2c388d7bef3e8f3fdb25528225bbc841e7e7e3a","impliedFormat":99},{"version":"f147b6710441cf3ec3234adf63b0593ce5e8c9b692959d21d3babc8454bcf743","impliedFormat":99},{"version":"e96d5373a66c2cfbbc7e6642cf274055aa2c7ff6bd37be7480c66faf9804db6d","impliedFormat":99},{"version":"dfff4c4041d7f80ff6d115aff809f2e5f0083b08ad2bb36630d7343227840445","impliedFormat":99},{"version":"cd73b41ae4f5513b2d29d01ff50afbbe83004af2a88c91d56bf83b8d2c682724","impliedFormat":99},{"version":"7c553fc9e34773ddbaabe0fa1367d4b109101d0868a008f11042bee24b5a925d","impliedFormat":99},{"version":"9962ce696fbdce2421d883ca4b062a54f982496625437ae4d3633376c5ad4a80","impliedFormat":99},{"version":"05c7aef6a4e496b93c2e682cced8903c0dfe6340d04f3fe616176e2782193435","impliedFormat":99},{"version":"a6a10f8ad941a4025cdc69fb697b9c06b99356c36716591fcaea2a7b9034dba8","impliedFormat":99},{"version":"4c17183a07a63bea2653fbfc0a942b027160ddbee823024789a415f9589de327","impliedFormat":99},{"version":"500a67e158e4025f27570ab6a99831680852bb45a44d4c3647ab7567feb1fb4c","impliedFormat":99},{"version":"631737d061b10b7ad67fc09120ec13ce86c3c269c1cfbedef08aaf638ee224d1","impliedFormat":99},{"version":"785b9d575b49124ce01b46f5b9402157c7611e6532effa562ac6aebec0074dfc","impliedFormat":1},{"version":"e58a3ce75105c1557e34fab7408942d77374e047c16383e80880ed1220166dfa","affectsGlobalScope":true,"impliedFormat":1},{"version":"282f98006ed7fa9bb2cd9bdbe2524595cfc4bcd58a0bb3232e4519f2138df811","impliedFormat":1},{"version":"6222e987b58abfe92597e1273ad7233626285bc2d78409d4a7b113d81a83496b","impliedFormat":1},{"version":"cbe726263ae9a7bf32352380f7e8ab66ee25b3457137e316929269c19e18a2be","impliedFormat":1},{"version":"8b96046bf5fb0a815cba6b0880d9f97b7f3a93cf187e8dcfe8e2792e97f38f87","impliedFormat":99},{"version":"bacf2c84cf448b2cd02c717ad46c3d7fd530e0c91282888c923ad64810a4d511","affectsGlobalScope":true,"impliedFormat":1},{"version":"402e5c534fb2b85fa771170595db3ac0dd532112c8fa44fc23f233bc6967488b","impliedFormat":1},{"version":"8885cf05f3e2abf117590bbb951dcf6359e3e5ac462af1c901cfd24c6a6472e2","impliedFormat":1},{"version":"4d979e3c12ffb6497d2b1dc5613130196d986fff764c4526360c0716a162e7e7","impliedFormat":1},{"version":"e61df3640a38d535fd4bc9f4a53aef17c296b58dc4b6394fd576b808dd2fe5e6","impliedFormat":1},{"version":"80781460eca408fe8d2937d9fdbbb780d6aac35f549621e6200c9bee1da5b8fe","impliedFormat":1},{"version":"4719c209b9c00b579553859407a7e5dcfaa1c472994bd62aa5dd3cc0757eb077","impliedFormat":1},{"version":"7ec359bbc29b69d4063fe7dad0baaf35f1856f914db16b3f4f6e3e1bca4099fa","impliedFormat":1},{"version":"b9261ac3e9944d3d72c5ee4cf888ad35d9743a5563405c6963c4e43ee3708ca4","impliedFormat":1},{"version":"c84fd54e8400def0d1ef1569cafd02e9f39a622df9fa69b57ccc82128856b916","impliedFormat":1},{"version":"a022503e75d6953d0e82c2c564508a5c7f8556fad5d7f971372d2d40479e4034","impliedFormat":1},{"version":"2ed6489ef46eb61442d067c08e87e3db501c0bfb2837eee4041a27bf3e792bb0","impliedFormat":1},{"version":"644491cde678bd462bb922c1d0cfab8f17d626b195ccb7f008612dc31f445d2d","impliedFormat":1},{"version":"d60fe6d59d4e19ecc65359490b8535e359ca4b760d2cdb56897ca75d09d41ba3","impliedFormat":1},{"version":"f45a2a8b1777ecb50ed65e1a04bb899d4b676529b7921bd5d69b08573a00c832","impliedFormat":1},{"version":"774b783046ba3d473948132d28a69f52a295b2f378f2939304118ba571b1355e","impliedFormat":1},{"version":"b5734e05c787a40e4f9efe71f16683c5f7dc3bdb0de7c04440c855bd000f8fa7","impliedFormat":1},{"version":"14ba97f0907144771331e1349fdccb5a13526eba0647e6b447e572376d811b6f","impliedFormat":1},{"version":"2a771d907aebf9391ac1f50e4ad37952943515eeea0dcc7e78aa08f508294668","impliedFormat":1},{"version":"7165050eddaed878c2d2cd3cafcaf171072ac39e586a048c0603712b5555f536","impliedFormat":1},{"version":"82e687ebd99518bc63ea04b0c3810fb6e50aa6942decd0ca6f7a56d9b9a212a6","impliedFormat":99},{"version":"7f698624bbbb060ece7c0e51b7236520ebada74b747d7523c7df376453ed6fea","impliedFormat":1},{"version":"8f07f2b6514744ac96e51d7cb8518c0f4de319471237ea10cf688b8d0e9d0225","impliedFormat":1},{"version":"9ae0ca65717af0d3b554a26fd333ad9c78ad3910ad4b22140ff02acb63076927","impliedFormat":99},{"version":"e01ea380015ed698c3c0e2ccd0db72f3fc3ef1abc4519f122aa1c1a8d419a505","impliedFormat":99},{"version":"9e2534be8a9338e750d24acc6076680d49b1643ae993c74510776a92af0c1604","impliedFormat":99},{"version":"c266ab6ddc3c29b4dd77a6f0d0eb4df7dab76d066e385171d88cb97c1120e747","impliedFormat":99},{"version":"e3225dc0bec183183509d290f641786245e6652bc3dce755f7ef404060693c35","impliedFormat":99},{"version":"f2d1a59a658165341b0e2b7879aa2e19ea6a709146b2d3f70ee8a07159d3d08e","impliedFormat":99},{"version":"676ee18819ba49ed188477aa451d24c727273e54e52ce1f285f6e510aa1ad257","impliedFormat":99},{"version":"e6233e1c976265e85aa8ad76c3881febe6264cb06ae3136f0257e1eab4a6cc5a","impliedFormat":99},{"version":"3a07ebaeb3b96c1e7a5fc0588364a8e58c74efd63b62f64b34c33b01907dc320","impliedFormat":99},{"version":"b1e92c7f8608744a7e40c636f7096e98d0dafe2c36aa6ba31b5f5a6c22794e37","impliedFormat":99},{"version":"97c77e6bee16334203cb776e6a2c0ccd4d8b9f1f584a1e3f5aacbf9e8fb618a8","impliedFormat":99},{"version":"7f8ea3140f0c2d102ff2d92ce2ce7fb33d1d209a851032332658a0dd081b0b8e","impliedFormat":99},{"version":"a0e40a10412a69609cbd9b157169c3011b080e66ef46a6370cd1d069a53eb52b","impliedFormat":99},{"version":"b7e28e06011460436d5c2ec2996846ac0c451e135357fc5a7269e5665a32fbd7","impliedFormat":99},{"version":"9a690435fa5e89ac3a0105d793c1ae21e1751ac2a912847de925107aabb9c9c0","impliedFormat":99},{"version":"9f3e99401b5bfdcb2ff75be940e02402b5c23cf8b4f8d0ba552c7d2d97c36568","impliedFormat":99},{"version":"1c65bde9dc8d609b4e01c929391461576e26c5db0d6bfafb666f7fe7619c9e95","impliedFormat":99},{"version":"e666e31d323fef5642f87db0da48a83e58f0aaf9e3823e87eabd8ec7e0441a36","impliedFormat":99},{"version":"69bf2422313487956e4dacf049f30cb91b34968912058d244cb19e4baa24da97","impliedFormat":1},{"version":"112c59da5f9cf6c54a36f669ece3901164dd3c8d45a7481b21ee96dc7bc814a2","impliedFormat":99},{"version":"fa5808c7536ef07ac68288c034f241ac843de42e23fcfcb703c5d1e05c909203","impliedFormat":99},{"version":"68008de4f1088f5f6cc034ac07ee01bede35590d52896c6586c8a0a988a1503e","impliedFormat":99},{"version":"48c411efce1848d1ed55de41d7deb93cbf7c04080912fd87aa517ed25ef42639","affectsGlobalScope":true,"impliedFormat":1},{"version":"11469e21ce79e01ee7e9e0487c69af39f8829e9b8dbb6d145696394c05025a01","affectsGlobalScope":true,"impliedFormat":99},{"version":"fe2d63fcfdde197391b6b70daf7be8c02a60afa90754a5f4a04bdc367f62793d","impliedFormat":99},{"version":"9e2aab1f07250281a63148e3119cc145cba997be2a71850a1afb62c8ba25ea5f","impliedFormat":99},{"version":"deb6818c1889c5da9bc37d171db5855ca9b61f0caa84c734d41a678dfa931900","impliedFormat":99},{"version":"b4bb4551aea38feeb6dae35133789e8f00cc507da74c5c8627bc9170269eed5e","impliedFormat":99},{"version":"ac2414a284bdecfd6ab7b87578744ab056cd04dd574b17853cd76830ef5b72f2","impliedFormat":99},{"version":"83d63d0ede869e5c7e5659f678f6ae7082f2246e62b4640318da47e343137feb","impliedFormat":99},{"version":"c1ddffecc371c0844f7752422dc4a3c276518e6fe01fbe95047f344116548bd4","impliedFormat":99},{"version":"26ee12ad3beb23dcb0b78a390d46b38079e417b99fd1024706e55c66a564285e","impliedFormat":99},{"version":"7c6eabf07a22b6ca1eec0b8c0ece2715146a8cce44cb2cf61c757dcac87db2f6","affectsGlobalScope":true,"impliedFormat":99},{"version":"d78397ab96a178528d37d0eaa27252b0f74bc16b50b6d5119c64dea10c71994c","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"89910e26c04c22959c5192afd2e3d3803ca040e0b1a1e51452a304c4a554deb9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"c2008324d35aac983bae015587fbfa738f4598f1e28f4791ab84af0112bacc92","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"579bf12c76184aa5de39b04fcd079c9f6909e04f820f29919d0c8e776c18c7c8","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"d8300596ef3538edcf904b7cacec4a2515a1a9bc882dbcb763823e75a6b7dcd5","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"}],"root":[[60,65],67,68,[176,180],210,211,215,216,[293,297]],"options":{"declaration":true,"downlevelIteration":true,"esModuleInterop":true,"jsx":4,"module":1,"newLine":1,"noFallthroughCasesInSwitch":true,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":1},"referencedMap":[[174,1],[173,2],[212,3],[231,3],[168,4],[175,5],[171,3],[164,3],[169,6],[170,7],[71,8],[72,8],[111,9],[112,10],[113,11],[114,12],[115,13],[116,14],[117,15],[118,16],[119,17],[120,18],[121,18],[123,19],[122,20],[124,21],[125,22],[126,23],[110,24],[162,3],[127,25],[128,26],[129,27],[130,28],[131,29],[132,30],[133,31],[134,32],[135,33],[136,34],[137,35],[138,36],[139,37],[140,37],[141,38],[142,3],[143,3],[144,39],[146,40],[145,41],[147,42],[148,43],[149,44],[150,45],[151,46],[152,47],[153,48],[70,49],[69,3],[163,50],[154,51],[155,52],[156,53],[157,54],[158,55],[159,56],[160,57],[161,58],[167,3],[166,3],[165,59],[172,60],[213,61],[214,62],[282,3],[283,63],[284,64],[287,65],[286,3],[219,3],[230,66],[223,67],[227,68],[276,69],[277,70],[261,3],[264,71],[262,72],[263,73],[272,73],[265,74],[273,75],[289,3],[226,76],[225,77],[228,77],[218,78],[222,79],[275,78],[224,80],[217,3],[229,81],[66,3],[237,3],[181,3],[254,82],[252,83],[253,84],[241,85],[242,83],[249,86],[240,87],[245,88],[255,3],[246,89],[251,90],[256,91],[239,92],[247,93],[248,94],[243,95],[250,82],[244,96],[232,97],[238,3],[278,3],[220,3],[221,98],[45,3],[46,3],[8,3],[10,3],[9,3],[2,3],[11,3],[12,3],[13,3],[14,3],[15,3],[16,3],[17,3],[18,3],[3,3],[19,3],[4,3],[20,3],[24,3],[21,3],[22,3],[23,3],[25,3],[26,3],[27,3],[5,3],[28,3],[29,3],[30,3],[31,3],[6,3],[35,3],[32,3],[33,3],[34,3],[36,3],[7,3],[37,3],[42,3],[43,3],[38,3],[39,3],[40,3],[41,3],[1,3],[44,3],[88,99],[98,100],[87,99],[108,101],[79,102],[78,103],[107,104],[101,105],[106,106],[81,107],[95,108],[80,109],[104,110],[76,111],[75,104],[105,112],[77,113],[82,114],[83,3],[86,114],[73,3],[109,115],[99,116],[90,117],[91,118],[93,119],[89,120],[92,121],[102,104],[84,122],[85,123],[94,124],[74,125],[97,116],[96,114],[100,3],[103,126],[271,127],[268,128],[269,127],[274,129],[267,3],[260,130],[257,131],[236,132],[234,133],[233,3],[235,134],[258,3],[259,135],[279,136],[266,137],[270,3],[288,138],[280,139],[285,140],[281,141],[290,142],[291,143],[292,144],[209,145],[182,146],[184,147],[185,148],[207,149],[183,3],[186,150],[187,151],[188,3],[189,3],[190,146],[191,152],[192,153],[193,152],[194,146],[195,3],[196,154],[197,155],[198,151],[199,152],[201,156],[202,150],[200,151],[203,152],[204,3],[205,152],[206,3],[208,147],[59,157],[49,158],[51,159],[57,160],[53,3],[54,3],[52,161],[55,157],[47,3],[48,3],[58,162],[50,163],[56,164],[67,165],[68,166],[62,167],[63,168],[61,169],[176,170],[177,171],[179,172],[180,173],[178,3],[64,174],[210,175],[211,176],[60,3],[215,177],[216,178],[65,179],[293,180],[294,181],[295,182],[296,181],[297,183]],"version":"5.6.2"} \ No newline at end of file