From 3ddea5375c2a9f548ccfc80d2ba03b1481a55696 Mon Sep 17 00:00:00 2001 From: actions Date: Thu, 24 Oct 2024 16:22:39 +0000 Subject: [PATCH] Adding deno distribution files and moving files from /dist to / --- .github/workflows/ci.yaml | 161 -------------- axios/createAxiosSharedClient.d.ts | 6 + axios/createAxiosSharedClient.js | 147 +++++++++++++ axios/createAxiosSharedClient.js.map | 1 + axios/index.d.ts | 1 + axios/index.js | 6 + axios/index.js.map | 1 + configureCreateHttpClient.d.ts | 26 +++ configureCreateHttpClient.js | 25 +++ configureCreateHttpClient.js.map | 1 + createCustomSharedClient.d.ts | 3 + createCustomSharedClient.js | 12 ++ createCustomSharedClient.js.map | 1 + defineRoutes.d.ts | 34 +++ defineRoutes.js | 62 ++++++ defineRoutes.js.map | 1 + esm/axios/createAxiosSharedClient.d.ts | 6 + esm/axios/createAxiosSharedClient.mjs | 142 +++++++++++++ esm/axios/createAxiosSharedClient.mjs.map | 1 + esm/axios/index.d.ts | 1 + esm/axios/index.mjs | 2 + esm/axios/index.mjs.map | 1 + esm/configureCreateHttpClient.d.ts | 26 +++ esm/configureCreateHttpClient.mjs | 21 ++ esm/configureCreateHttpClient.mjs.map | 1 + esm/createCustomSharedClient.d.ts | 3 + esm/createCustomSharedClient.mjs | 8 + esm/createCustomSharedClient.mjs.map | 1 + esm/defineRoutes.d.ts | 34 +++ esm/defineRoutes.mjs | 56 +++++ esm/defineRoutes.mjs.map | 1 + esm/express/createExpressSharedRouter.d.ts | 13 ++ esm/express/createExpressSharedRouter.mjs | 75 +++++++ esm/express/createExpressSharedRouter.mjs.map | 1 + esm/express/index.d.ts | 1 + esm/express/index.mjs | 2 + esm/express/index.mjs.map | 1 + esm/fetch/createFetchSharedClient.d.ts | 10 + esm/fetch/createFetchSharedClient.mjs | 195 +++++++++++++++++ esm/fetch/createFetchSharedClient.mjs.map | 1 + esm/fetch/index.d.ts | 1 + esm/fetch/index.mjs | 2 + esm/fetch/index.mjs.map | 1 + esm/fetch/queryParamsToString.d.ts | 8 + esm/fetch/queryParamsToString.mjs | 33 +++ esm/fetch/queryParamsToString.mjs.map | 1 + esm/index.d.ts | 7 + esm/index.mjs | 5 + esm/index.mjs.map | 1 + esm/openapi/createOpenApiGenerator.d.ts | 49 +++++ esm/openapi/createOpenApiGenerator.mjs | 145 +++++++++++++ esm/openapi/createOpenApiGenerator.mjs.map | 1 + esm/openapi/index.d.ts | 1 + esm/openapi/index.mjs | 2 + esm/openapi/index.mjs.map | 1 + esm/pathParameters.d.ts | 19 ++ esm/pathParameters.mjs | 11 + esm/pathParameters.mjs.map | 1 + .../createSupertestSharedClient.d.ts | 5 + esm/supertest/createSupertestSharedClient.mjs | 114 ++++++++++ .../createSupertestSharedClient.mjs.map | 1 + esm/supertest/index.d.ts | 1 + esm/supertest/index.mjs | 2 + esm/supertest/index.mjs.map | 1 + esm/tsconfig.esm.tsbuildinfo | 1 + esm/validations.d.ts | 25 +++ esm/validations.mjs | 100 +++++++++ esm/validations.mjs.map | 1 + express/createExpressSharedRouter.d.ts | 13 ++ express/createExpressSharedRouter.js | 79 +++++++ express/createExpressSharedRouter.js.map | 1 + express/index.d.ts | 1 + express/index.js | 6 + express/index.js.map | 1 + fetch/createFetchSharedClient.d.ts | 10 + fetch/createFetchSharedClient.js | 200 ++++++++++++++++++ fetch/createFetchSharedClient.js.map | 1 + fetch/index.d.ts | 1 + fetch/index.js | 6 + fetch/index.js.map | 1 + fetch/queryParamsToString.d.ts | 8 + fetch/queryParamsToString.js | 37 ++++ fetch/queryParamsToString.js.map | 1 + index.d.ts | 7 + index.js | 14 ++ index.js.map | 1 + openapi/createOpenApiGenerator.d.ts | 49 +++++ openapi/createOpenApiGenerator.js | 149 +++++++++++++ openapi/createOpenApiGenerator.js.map | 1 + openapi/index.d.ts | 1 + openapi/index.js | 6 + openapi/index.js.map | 1 + package.json | 181 ++++++++++++---- pathParameters.d.ts | 19 ++ pathParameters.js | 16 ++ pathParameters.js.map | 1 + supertest/createSupertestSharedClient.d.ts | 5 + supertest/createSupertestSharedClient.js | 119 +++++++++++ supertest/createSupertestSharedClient.js.map | 1 + supertest/index.d.ts | 1 + supertest/index.js | 6 + supertest/index.js.map | 1 + tsconfig.tsbuildinfo | 1 + validations.d.ts | 25 +++ validations.js | 105 +++++++++ validations.js.map | 1 + 106 files changed, 2507 insertions(+), 201 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 axios/createAxiosSharedClient.d.ts create mode 100644 axios/createAxiosSharedClient.js create mode 100644 axios/createAxiosSharedClient.js.map create mode 100644 axios/index.d.ts create mode 100644 axios/index.js create mode 100644 axios/index.js.map create mode 100644 configureCreateHttpClient.d.ts create mode 100644 configureCreateHttpClient.js create mode 100644 configureCreateHttpClient.js.map create mode 100644 createCustomSharedClient.d.ts create mode 100644 createCustomSharedClient.js create mode 100644 createCustomSharedClient.js.map create mode 100644 defineRoutes.d.ts create mode 100644 defineRoutes.js create mode 100644 defineRoutes.js.map create mode 100644 esm/axios/createAxiosSharedClient.d.ts create mode 100644 esm/axios/createAxiosSharedClient.mjs create mode 100644 esm/axios/createAxiosSharedClient.mjs.map create mode 100644 esm/axios/index.d.ts create mode 100644 esm/axios/index.mjs create mode 100644 esm/axios/index.mjs.map create mode 100644 esm/configureCreateHttpClient.d.ts create mode 100644 esm/configureCreateHttpClient.mjs create mode 100644 esm/configureCreateHttpClient.mjs.map create mode 100644 esm/createCustomSharedClient.d.ts create mode 100644 esm/createCustomSharedClient.mjs create mode 100644 esm/createCustomSharedClient.mjs.map create mode 100644 esm/defineRoutes.d.ts create mode 100644 esm/defineRoutes.mjs create mode 100644 esm/defineRoutes.mjs.map create mode 100644 esm/express/createExpressSharedRouter.d.ts create mode 100644 esm/express/createExpressSharedRouter.mjs create mode 100644 esm/express/createExpressSharedRouter.mjs.map create mode 100644 esm/express/index.d.ts create mode 100644 esm/express/index.mjs create mode 100644 esm/express/index.mjs.map create mode 100644 esm/fetch/createFetchSharedClient.d.ts create mode 100644 esm/fetch/createFetchSharedClient.mjs create mode 100644 esm/fetch/createFetchSharedClient.mjs.map create mode 100644 esm/fetch/index.d.ts create mode 100644 esm/fetch/index.mjs create mode 100644 esm/fetch/index.mjs.map create mode 100644 esm/fetch/queryParamsToString.d.ts create mode 100644 esm/fetch/queryParamsToString.mjs create mode 100644 esm/fetch/queryParamsToString.mjs.map create mode 100644 esm/index.d.ts create mode 100644 esm/index.mjs create mode 100644 esm/index.mjs.map create mode 100644 esm/openapi/createOpenApiGenerator.d.ts create mode 100644 esm/openapi/createOpenApiGenerator.mjs create mode 100644 esm/openapi/createOpenApiGenerator.mjs.map create mode 100644 esm/openapi/index.d.ts create mode 100644 esm/openapi/index.mjs create mode 100644 esm/openapi/index.mjs.map create mode 100644 esm/pathParameters.d.ts create mode 100644 esm/pathParameters.mjs create mode 100644 esm/pathParameters.mjs.map create mode 100644 esm/supertest/createSupertestSharedClient.d.ts create mode 100644 esm/supertest/createSupertestSharedClient.mjs create mode 100644 esm/supertest/createSupertestSharedClient.mjs.map create mode 100644 esm/supertest/index.d.ts create mode 100644 esm/supertest/index.mjs create mode 100644 esm/supertest/index.mjs.map create mode 100644 esm/tsconfig.esm.tsbuildinfo create mode 100644 esm/validations.d.ts create mode 100644 esm/validations.mjs create mode 100644 esm/validations.mjs.map create mode 100644 express/createExpressSharedRouter.d.ts create mode 100644 express/createExpressSharedRouter.js create mode 100644 express/createExpressSharedRouter.js.map create mode 100644 express/index.d.ts create mode 100644 express/index.js create mode 100644 express/index.js.map create mode 100644 fetch/createFetchSharedClient.d.ts create mode 100644 fetch/createFetchSharedClient.js create mode 100644 fetch/createFetchSharedClient.js.map create mode 100644 fetch/index.d.ts create mode 100644 fetch/index.js create mode 100644 fetch/index.js.map create mode 100644 fetch/queryParamsToString.d.ts create mode 100644 fetch/queryParamsToString.js create mode 100644 fetch/queryParamsToString.js.map create mode 100644 index.d.ts create mode 100644 index.js create mode 100644 index.js.map create mode 100644 openapi/createOpenApiGenerator.d.ts create mode 100644 openapi/createOpenApiGenerator.js create mode 100644 openapi/createOpenApiGenerator.js.map create mode 100644 openapi/index.d.ts create mode 100644 openapi/index.js create mode 100644 openapi/index.js.map create mode 100644 pathParameters.d.ts create mode 100644 pathParameters.js create mode 100644 pathParameters.js.map create mode 100644 supertest/createSupertestSharedClient.d.ts create mode 100644 supertest/createSupertestSharedClient.js create mode 100644 supertest/createSupertestSharedClient.js.map create mode 100644 supertest/index.d.ts create mode 100644 supertest/index.js create mode 100644 supertest/index.js.map create mode 100644 tsconfig.tsbuildinfo create mode 100644 validations.d.ts create mode 100644 validations.js create mode 100644 validations.js.map 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/axios/createAxiosSharedClient.d.ts b/axios/createAxiosSharedClient.d.ts new file mode 100644 index 0000000..30237a7 --- /dev/null +++ b/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/axios/createAxiosSharedClient.js b/axios/createAxiosSharedClient.js new file mode 100644 index 0000000..c0256f6 --- /dev/null +++ b/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/axios/createAxiosSharedClient.js.map b/axios/createAxiosSharedClient.js.map new file mode 100644 index 0000000..0403785 --- /dev/null +++ b/axios/createAxiosSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createAxiosSharedClient.js","sourceRoot":"","sources":["../src/axios/createAxiosSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BAAyB,CAAF;4BAYvB,YAAY,GAChB,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB;iCAC/B,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iCAAiC,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;gCAC1D,CAAC,CAAC,IAAI;gCACN,CAAC,CAAC,IAAA,6CAA+B,EAAC;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;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/axios/index.d.ts b/axios/index.d.ts new file mode 100644 index 0000000..5a59bf2 --- /dev/null +++ b/axios/index.d.ts @@ -0,0 +1 @@ +export { createAxiosSharedClient } from "./createAxiosSharedClient"; diff --git a/axios/index.js b/axios/index.js new file mode 100644 index 0000000..ce08009 --- /dev/null +++ b/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/axios/index.js.map b/axios/index.js.map new file mode 100644 index 0000000..bf17877 --- /dev/null +++ b/axios/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/axios/index.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"} \ No newline at end of file diff --git a/configureCreateHttpClient.d.ts b/configureCreateHttpClient.d.ts new file mode 100644 index 0000000..74eebb0 --- /dev/null +++ b/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/configureCreateHttpClient.js b/configureCreateHttpClient.js new file mode 100644 index 0000000..a46bcbc --- /dev/null +++ b/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/configureCreateHttpClient.js.map b/configureCreateHttpClient.js.map new file mode 100644 index 0000000..3ad49eb --- /dev/null +++ b/configureCreateHttpClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"configureCreateHttpClient.js","sourceRoot":"","sources":["src/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/createCustomSharedClient.d.ts b/createCustomSharedClient.d.ts new file mode 100644 index 0000000..a985682 --- /dev/null +++ b/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/createCustomSharedClient.js b/createCustomSharedClient.js new file mode 100644 index 0000000..8d202a0 --- /dev/null +++ b/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/createCustomSharedClient.js.map b/createCustomSharedClient.js.map new file mode 100644 index 0000000..69905d4 --- /dev/null +++ b/createCustomSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createCustomSharedClient.js","sourceRoot":"","sources":["src/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/defineRoutes.d.ts b/defineRoutes.d.ts new file mode 100644 index 0000000..fedfccd --- /dev/null +++ b/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/defineRoutes.js b/defineRoutes.js new file mode 100644 index 0000000..f59962a --- /dev/null +++ b/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/defineRoutes.js.map b/defineRoutes.js.map new file mode 100644 index 0000000..ae7ae66 --- /dev/null +++ b/defineRoutes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defineRoutes.js","sourceRoot":"","sources":["src/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/esm/axios/createAxiosSharedClient.d.ts b/esm/axios/createAxiosSharedClient.d.ts new file mode 100644 index 0000000..5dcc408 --- /dev/null +++ b/esm/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/axios/createAxiosSharedClient.mjs b/esm/axios/createAxiosSharedClient.mjs new file mode 100644 index 0000000..4666172 --- /dev/null +++ b/esm/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/axios/createAxiosSharedClient.mjs.map b/esm/axios/createAxiosSharedClient.mjs.map new file mode 100644 index 0000000..5ce4d5a --- /dev/null +++ b/esm/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;IAC1B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,CAAC,IAAM,yBAAyB,GACpC,UACE,KAAoB,EACpB,OAA2B;IAE7B,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,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB;gCACjE,CAAC,CAAC,MAAM;gCACR,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAa,EAAE,OAAO,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,EAF7E,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA,CAEoD;4BAEpD,qBAAM,KAAK,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000..293b236 --- /dev/null +++ b/esm/axios/index.d.ts @@ -0,0 +1 @@ +export { createAxiosSharedClient } from "./createAxiosSharedClient.mjs"; diff --git a/esm/axios/index.mjs b/esm/axios/index.mjs new file mode 100644 index 0000000..399f9b7 --- /dev/null +++ b/esm/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/axios/index.mjs.map b/esm/axios/index.mjs.map new file mode 100644 index 0000000..4d6c8d0 --- /dev/null +++ b/esm/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/configureCreateHttpClient.d.ts b/esm/configureCreateHttpClient.d.ts new file mode 100644 index 0000000..0d665e4 --- /dev/null +++ b/esm/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/configureCreateHttpClient.mjs b/esm/configureCreateHttpClient.mjs new file mode 100644 index 0000000..4cdb348 --- /dev/null +++ b/esm/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/configureCreateHttpClient.mjs.map b/esm/configureCreateHttpClient.mjs.map new file mode 100644 index 0000000..725b3e3 --- /dev/null +++ b/esm/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/createCustomSharedClient.d.ts b/esm/createCustomSharedClient.d.ts new file mode 100644 index 0000000..4aa2f43 --- /dev/null +++ b/esm/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/createCustomSharedClient.mjs b/esm/createCustomSharedClient.mjs new file mode 100644 index 0000000..036ec45 --- /dev/null +++ b/esm/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/createCustomSharedClient.mjs.map b/esm/createCustomSharedClient.mjs.map new file mode 100644 index 0000000..6ed4931 --- /dev/null +++ b/esm/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/defineRoutes.d.ts b/esm/defineRoutes.d.ts new file mode 100644 index 0000000..653bdf0 --- /dev/null +++ b/esm/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/defineRoutes.mjs b/esm/defineRoutes.mjs new file mode 100644 index 0000000..aaf2e9b --- /dev/null +++ b/esm/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/defineRoutes.mjs.map b/esm/defineRoutes.mjs.map new file mode 100644 index 0000000..33bd6fe --- /dev/null +++ b/esm/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,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AAC,EAArC,CAAqC,CAAC"} \ No newline at end of file diff --git a/esm/express/createExpressSharedRouter.d.ts b/esm/express/createExpressSharedRouter.d.ts new file mode 100644 index 0000000..a4a1a6e --- /dev/null +++ b/esm/express/createExpressSharedRouter.d.ts @@ -0,0 +1,13 @@ +import type { IRoute, RequestHandler, Router } from "express"; +import type { PathParameters, UnknownSharedRoute } from "../index.mjs"; +import { z, ZodError } from "zod"; +import { ValidationOptions } from "../validations.mjs"; +import { ValueOfIndexNumber } from "../defineRoutes.mjs"; +export type ExpressSharedRouterOptions = { + onInputValidationError?: (validationResult: ZodError, route: UnknownSharedRoute) => unknown; +} & 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/express/createExpressSharedRouter.mjs b/esm/express/createExpressSharedRouter.mjs new file mode 100644 index 0000000..1d5e8eb --- /dev/null +++ b/esm/express/createExpressSharedRouter.mjs @@ -0,0 +1,75 @@ +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); + if (options === null || options === void 0 ? void 0 : options.onInputValidationError) { + var processedError = options.onInputValidationError(zodError, route); + if (processedError !== zodError) { + res.json(JSON.stringify(processedError, null, 2)); + return; + } + } + 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/express/createExpressSharedRouter.mjs.map b/esm/express/createExpressSharedRouter.mjs.map new file mode 100644 index 0000000..b4dd472 --- /dev/null +++ b/esm/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;AAUxE,IAAM,wBAAwB,GAC5B,UAAC,KAAyB,EAAE,OAAmC;IAC/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,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/express/index.d.ts b/esm/express/index.d.ts new file mode 100644 index 0000000..d924974 --- /dev/null +++ b/esm/express/index.d.ts @@ -0,0 +1 @@ +export { createExpressSharedRouter } from "./createExpressSharedRouter.mjs"; diff --git a/esm/express/index.mjs b/esm/express/index.mjs new file mode 100644 index 0000000..883a08b --- /dev/null +++ b/esm/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/express/index.mjs.map b/esm/express/index.mjs.map new file mode 100644 index 0000000..b646f37 --- /dev/null +++ b/esm/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/fetch/createFetchSharedClient.d.ts b/esm/fetch/createFetchSharedClient.d.ts new file mode 100644 index 0000000..4f0f73b --- /dev/null +++ b/esm/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/fetch/createFetchSharedClient.mjs b/esm/fetch/createFetchSharedClient.mjs new file mode 100644 index 0000000..abbf69d --- /dev/null +++ b/esm/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/fetch/createFetchSharedClient.mjs.map b/esm/fetch/createFetchSharedClient.mjs.map new file mode 100644 index 0000000..8d6a6ca --- /dev/null +++ b/esm/fetch/createFetchSharedClient.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"createFetchSharedClient.mjs","sourceRoot":"","sources":["../../src/fetch/createFetchSharedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,yBAAyB,EAAkB,MAAM,IAAI,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAEL,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAExB,IAAM,iBAAi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AiB,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/fetch/index.d.ts b/esm/fetch/index.d.ts new file mode 100644 index 0000000..64accb7 --- /dev/null +++ b/esm/fetch/index.d.ts @@ -0,0 +1 @@ +export { createFetchSharedClient } from "./createFetchSharedClient.mjs"; diff --git a/esm/fetch/index.mjs b/esm/fetch/index.mjs new file mode 100644 index 0000000..2036063 --- /dev/null +++ b/esm/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/fetch/index.mjs.map b/esm/fetch/index.mjs.map new file mode 100644 index 0000000..10a91b8 --- /dev/null +++ b/esm/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/fetch/queryParamsToString.d.ts b/esm/fetch/queryParamsToString.d.ts new file mode 100644 index 0000000..af4d3de --- /dev/null +++ b/esm/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/fetch/queryParamsToString.mjs b/esm/fetch/queryParamsToString.mjs new file mode 100644 index 0000000..0c822e7 --- /dev/null +++ b/esm/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/fetch/queryParamsToString.mjs.map b/esm/fetch/queryParamsToString.mjs.map new file mode 100644 index 0000000..f4a2f86 --- /dev/null +++ b/esm/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/index.d.ts b/esm/index.d.ts new file mode 100644 index 0000000..20feac7 --- /dev/null +++ b/esm/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/index.mjs b/esm/index.mjs new file mode 100644 index 0000000..7b218a4 --- /dev/null +++ b/esm/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/index.mjs.map b/esm/index.mjs.map new file mode 100644 index 0000000..8afdb18 --- /dev/null +++ b/esm/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/openapi/createOpenApiGenerator.d.ts b/esm/openapi/createOpenApiGenerator.d.ts new file mode 100644 index 0000000..e46edde --- /dev/null +++ b/esm/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/openapi/createOpenApiGenerator.mjs b/esm/openapi/createOpenApiGenerator.mjs new file mode 100644 index 0000000..3934939 --- /dev/null +++ b/esm/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/openapi/createOpenApiGenerator.mjs.map b/esm/openapi/createOpenApiGenerator.mjs.map new file mode 100644 index 0000000..2c5b5e5 --- /dev/null +++ b/esm/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,GA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AAI,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/openapi/index.d.ts b/esm/openapi/index.d.ts new file mode 100644 index 0000000..2f7b227 --- /dev/null +++ b/esm/openapi/index.d.ts @@ -0,0 +1 @@ +export { createOpenApiGenerator } from "./createOpenApiGenerator.mjs"; diff --git a/esm/openapi/index.mjs b/esm/openapi/index.mjs new file mode 100644 index 0000000..3ff5f58 --- /dev/null +++ b/esm/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/openapi/index.mjs.map b/esm/openapi/index.mjs.map new file mode 100644 index 0000000..97240a3 --- /dev/null +++ b/esm/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/pathParameters.d.ts b/esm/pathParameters.d.ts new file mode 100644 index 0000000..c40384b --- /dev/null +++ b/esm/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/pathParameters.mjs b/esm/pathParameters.mjs new file mode 100644 index 0000000..7afc705 --- /dev/null +++ b/esm/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/pathParameters.mjs.map b/esm/pathParameters.mjs.map new file mode 100644 index 0000000..5f97b68 --- /dev/null +++ b/esm/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/supertest/createSupertestSharedClient.d.ts b/esm/supertest/createSupertestSharedClient.d.ts new file mode 100644 index 0000000..be46c3b --- /dev/null +++ b/esm/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/supertest/createSupertestSharedClient.mjs b/esm/supertest/createSupertestSharedClient.mjs new file mode 100644 index 0000000..c206a64 --- /dev/null +++ b/esm/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/supertest/createSupertestSharedClient.mjs.map b/esm/supertest/createSupertestSharedClient.mjs.map new file mode 100644 index 0000000..36fc8da --- /dev/null +++ b/esm/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,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;AAEJ,MAAM,CAAC,IAAM,2BAA2B,GAAG,UAGzC,YAA0B,EAC1B,gBAAiC;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/supertest/index.d.ts b/esm/supertest/index.d.ts new file mode 100644 index 0000000..353d901 --- /dev/null +++ b/esm/supertest/index.d.ts @@ -0,0 +1 @@ +export { createSupertestSharedClient } from "./createSupertestSharedClient.mjs"; diff --git a/esm/supertest/index.mjs b/esm/supertest/index.mjs new file mode 100644 index 0000000..3052989 --- /dev/null +++ b/esm/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/supertest/index.mjs.map b/esm/supertest/index.mjs.map new file mode 100644 index 0000000..fe9c405 --- /dev/null +++ b/esm/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/tsconfig.esm.tsbuildinfo b/esm/tsconfig.esm.tsbuildinfo new file mode 100644 index 0000000..b139c54 --- /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"],"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,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,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]],"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":"6a6195c68c56a17ade1fc929652873f51368c0c9647c386dd154e25e2250f253","signature":"56b7532c9526911c2da35d9bcacb1a07781f1f52d90a16fbcd621e1de00a88a4"},"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"],"root":[[60,65],67,68,[176,180],210,211,215,216],"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],[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],[66,3],[181,3],[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,63],[98,64],[87,63],[108,65],[79,66],[78,67],[107,68],[101,69],[106,70],[81,71],[95,72],[80,73],[104,74],[76,75],[75,68],[105,76],[77,77],[82,78],[83,3],[86,78],[73,3],[109,79],[99,80],[90,81],[91,82],[93,83],[89,84],[92,85],[102,68],[84,86],[85,87],[94,88],[74,89],[97,80],[96,78],[100,3],[103,90],[209,91],[182,92],[184,93],[185,94],[207,95],[183,3],[186,96],[187,97],[188,3],[189,3],[190,92],[191,98],[192,99],[193,98],[194,92],[195,3],[196,100],[197,101],[198,97],[199,98],[201,102],[202,96],[200,97],[203,98],[204,3],[205,98],[206,3],[208,93],[59,103],[49,104],[51,105],[57,106],[53,3],[54,3],[52,107],[55,103],[47,3],[48,3],[58,108],[50,109],[56,110],[67,111],[68,112],[62,113],[63,114],[61,115],[176,116],[177,117],[179,118],[180,119],[178,3],[64,120],[210,121],[211,122],[60,3],[215,123],[216,124],[65,125]],"version":"5.6.2"} \ No newline at end of file diff --git a/esm/validations.d.ts b/esm/validations.d.ts new file mode 100644 index 0000000..5970cff --- /dev/null +++ b/esm/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/validations.mjs b/esm/validations.mjs new file mode 100644 index 0000000..0c97437 --- /dev/null +++ b/esm/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/validations.mjs.map b/esm/validations.mjs.map new file mode 100644 index 0000000..848d7dc --- /dev/null +++ b/esm/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;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,MAAG;QACjB,iBAAU,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,cAAI,KAAK,CAAC,GAAG,CAAE;cAChD,CAAC,mBAAmB,KAAI,MAAC,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,MAAM,0CAAE,MAAM,CAAA;QACvD,CAAC,CAAC,CAAC,UAAU,GAAG,cAAc,CAAE,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC,EAAE,CAAC,UAEN,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;IACD,QAAgB,CAAC,KAAK,GAAG,KAAK,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,+BAA+B,GAAG,UAA+B,EAiB7E;QAhBC,aAAa,mBAAA,EACb,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,KAAK,WAAA,E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A;QACL,mBAAmB,qBAAA;KACpB,CAAC,CAAC;IAEH,6FAA6F;IAC7F,kDAAkD;IAClD,+BAA+B,CAAC;QAC9B,WAAW,aAAA;QACX,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,MAAM,CAAC,OAAO;QACtB,KAAK,OAAA;KACN,CAAC,CAAC;IAEH,OAAO,EAAE,WAAW,aAAA,EAAE,IAAI,MAAA,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;AACxD,CAAC,CAAC;AAEF,IAAM,cAAc,GAAG,UAAC,MAAkB;IACxC,OAAA,MAAM,CAAC,GAAG,CAAC,UAAC,EAAiB;YAAf,OAAO,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/express/createExpressSharedRouter.d.ts b/express/createExpressSharedRouter.d.ts new file mode 100644 index 0000000..34db62f --- /dev/null +++ b/express/createExpressSharedRouter.d.ts @@ -0,0 +1,13 @@ +import type { IRoute, RequestHandler, Router } from "express"; +import type { PathParameters, UnknownSharedRoute } from ".."; +import { z, ZodError } from "zod"; +import { ValidationOptions } from "../validations"; +import { ValueOfIndexNumber } from "../defineRoutes"; +export type ExpressSharedRouterOptions = { + onInputValidationError?: (validationResult: ZodError, route: UnknownSharedRoute) => unknown; +} & 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/express/createExpressSharedRouter.js b/express/createExpressSharedRouter.js new file mode 100644 index 0000000..d4a43bf --- /dev/null +++ b/express/createExpressSharedRouter.js @@ -0,0 +1,79 @@ +"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); + if (options === null || options === void 0 ? void 0 : options.onInputValidationError) { + var processedError = options.onInputValidationError(zodError, route); + if (processedError !== zodError) { + res.json(JSON.stringify(processedError, null, 2)); + return; + } + } + 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/express/createExpressSharedRouter.js.map b/express/createExpressSharedRouter.js.map new file mode 100644 index 0000000..b7c3714 --- /dev/null +++ b/express/createExpressSharedRouter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createExpressSharedRouter.js","sourceRoot":"","sources":["../src/express/createExpressSharedRouter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,wBAA0B;AAE1B,8CAAwE;AAUxE,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;YAEhB,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,EAAE,CAA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AC,GAAa,CAAC;IAEhC,OAAO;QAAC,kBAA6B;aAA7B,UAA6B,EAA7B,qBAA6B,EAA7B,IAA6B;YAA7B,6BAA6B;;QACnC,OAAA,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,QAAQ,CAAC;IAAtE,CAAsE,CAAC;AAC3E,CAAC,CAAC;AAOK,IAAM,yBAAyB,GAAG,UAgBvC,YAA0B,EAC1B,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/express/index.d.ts b/express/index.d.ts new file mode 100644 index 0000000..8f6a6a7 --- /dev/null +++ b/express/index.d.ts @@ -0,0 +1 @@ +export { createExpressSharedRouter } from "./createExpressSharedRouter"; diff --git a/express/index.js b/express/index.js new file mode 100644 index 0000000..ab63c8d --- /dev/null +++ b/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/express/index.js.map b/express/index.js.map new file mode 100644 index 0000000..572dc0c --- /dev/null +++ b/express/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/express/index.ts"],"names":[],"mappings":";;;AAAA,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA"} \ No newline at end of file diff --git a/fetch/createFetchSharedClient.d.ts b/fetch/createFetchSharedClient.d.ts new file mode 100644 index 0000000..a1630c0 --- /dev/null +++ b/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/fetch/createFetchSharedClient.js b/fetch/createFetchSharedClient.js new file mode 100644 index 0000000..b71858a --- /dev/null +++ b/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/fetch/createFetchSharedClient.js.map b/fetch/createFetchSharedClient.js.map new file mode 100644 index 0000000..19ebfa4 --- /dev/null +++ b/fetch/createFetchSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createFetchSharedClient.js","sourceRoot":"","sources":["../src/fetch/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,CA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ACZ,MAAwB;IAAxB,uBAAA,EAAA,WAAwB;IACrB,OAAA,IAAA,6BAAyB,EAAC,IAAA,iCAAyB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC;AAAlF,CAAkF,CAAC;AAN3E,QAAA,uBAAuB,2BAMoD"} \ No newline at end of file diff --git a/fetch/index.d.ts b/fetch/index.d.ts new file mode 100644 index 0000000..01dec98 --- /dev/null +++ b/fetch/index.d.ts @@ -0,0 +1 @@ +export { createFetchSharedClient } from "./createFetchSharedClient"; diff --git a/fetch/index.js b/fetch/index.js new file mode 100644 index 0000000..8588604 --- /dev/null +++ b/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/fetch/index.js.map b/fetch/index.js.map new file mode 100644 index 0000000..84b3586 --- /dev/null +++ b/fetch/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/fetch/index.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"} \ No newline at end of file diff --git a/fetch/queryParamsToString.d.ts b/fetch/queryParamsToString.d.ts new file mode 100644 index 0000000..af4d3de --- /dev/null +++ b/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/fetch/queryParamsToString.js b/fetch/queryParamsToString.js new file mode 100644 index 0000000..d45b588 --- /dev/null +++ b/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/fetch/queryParamsToString.js.map b/fetch/queryParamsToString.js.map new file mode 100644 index 0000000..23cacc0 --- /dev/null +++ b/fetch/queryParamsToString.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryParamsToString.js","sourceRoot":"","sources":["../src/fetch/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/index.d.ts b/index.d.ts new file mode 100644 index 0000000..abc702d --- /dev/null +++ b/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/index.js b/index.js new file mode 100644 index 0000000..601e71f --- /dev/null +++ b/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/index.js.map b/index.js.map new file mode 100644 index 0000000..98e7fc4 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["src/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/openapi/createOpenApiGenerator.d.ts b/openapi/createOpenApiGenerator.d.ts new file mode 100644 index 0000000..81ae4ed --- /dev/null +++ b/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/openapi/createOpenApiGenerator.js b/openapi/createOpenApiGenerator.js new file mode 100644 index 0000000..7697ee9 --- /dev/null +++ b/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/openapi/createOpenApiGenerator.js.map b/openapi/createOpenApiGenerator.js.map new file mode 100644 index 0000000..236b6a5 --- /dev/null +++ b/openapi/createOpenApiGenerator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createOpenApiGenerator.js","sourceRoot":"","sources":["../src/openapi/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,UAA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AQ,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/openapi/index.d.ts b/openapi/index.d.ts new file mode 100644 index 0000000..015624c --- /dev/null +++ b/openapi/index.d.ts @@ -0,0 +1 @@ +export { createOpenApiGenerator } from "./createOpenApiGenerator"; diff --git a/openapi/index.js b/openapi/index.js new file mode 100644 index 0000000..e86a5ba --- /dev/null +++ b/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/openapi/index.js.map b/openapi/index.js.map new file mode 100644 index 0000000..07ca7a2 --- /dev/null +++ b/openapi/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/openapi/index.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 4b16be7..a34360c 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,126 @@ "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", + "axios/createAxiosSharedClient.d.ts", + "axios/createAxiosSharedClient.js", + "axios/createAxiosSharedClient.js.map", + "axios/index.d.ts", + "axios/index.js", + "axios/index.js.map", + "configureCreateHttpClient.d.ts", + "configureCreateHttpClient.js", + "configureCreateHttpClient.js.map", + "createCustomSharedClient.d.ts", + "createCustomSharedClient.js", + "createCustomSharedClient.js.map", + "defineRoutes.d.ts", + "defineRoutes.js", + "defineRoutes.js.map", + "esm/axios/createAxiosSharedClient.d.ts", + "esm/axios/createAxiosSharedClient.mjs", + "esm/axios/createAxiosSharedClient.mjs.map", + "esm/axios/index.d.ts", + "esm/axios/index.mjs", + "esm/axios/index.mjs.map", + "esm/configureCreateHttpClient.d.ts", + "esm/configureCreateHttpClient.mjs", + "esm/configureCreateHttpClient.mjs.map", + "esm/createCustomSharedClient.d.ts", + "esm/createCustomSharedClient.mjs", + "esm/createCustomSharedClient.mjs.map", + "esm/defineRoutes.d.ts", + "esm/defineRoutes.mjs", + "esm/defineRoutes.mjs.map", + "esm/express/createExpressSharedRouter.d.ts", + "esm/express/createExpressSharedRouter.mjs", + "esm/express/createExpressSharedRouter.mjs.map", + "esm/express/index.d.ts", + "esm/express/index.mjs", + "esm/express/index.mjs.map", + "esm/fetch/createFetchSharedClient.d.ts", + "esm/fetch/createFetchSharedClient.mjs", + "esm/fetch/createFetchSharedClient.mjs.map", + "esm/fetch/index.d.ts", + "esm/fetch/index.mjs", + "esm/fetch/index.mjs.map", + "esm/fetch/queryParamsToString.d.ts", + "esm/fetch/queryParamsToString.mjs", + "esm/fetch/queryParamsToString.mjs.map", + "esm/index.d.ts", + "esm/index.mjs", + "esm/index.mjs.map", + "esm/openapi/createOpenApiGenerator.d.ts", + "esm/openapi/createOpenApiGenerator.mjs", + "esm/openapi/createOpenApiGenerator.mjs.map", + "esm/openapi/index.d.ts", + "esm/openapi/index.mjs", + "esm/openapi/index.mjs.map", + "esm/pathParameters.d.ts", + "esm/pathParameters.mjs", + "esm/pathParameters.mjs.map", + "esm/supertest/createSupertestSharedClient.d.ts", + "esm/supertest/createSupertestSharedClient.mjs", + "esm/supertest/createSupertestSharedClient.mjs.map", + "esm/supertest/index.d.ts", + "esm/supertest/index.mjs", + "esm/supertest/index.mjs.map", + "esm/tsconfig.esm.tsbuildinfo", + "esm/validations.d.ts", + "esm/validations.mjs", + "esm/validations.mjs.map", + "express/createExpressSharedRouter.d.ts", + "express/createExpressSharedRouter.js", + "express/createExpressSharedRouter.js.map", + "express/index.d.ts", + "express/index.js", + "express/index.js.map", + "fetch/createFetchSharedClient.d.ts", + "fetch/createFetchSharedClient.js", + "fetch/createFetchSharedClient.js.map", + "fetch/index.d.ts", + "fetch/index.js", + "fetch/index.js.map", + "fetch/queryParamsToString.d.ts", + "fetch/queryParamsToString.js", + "fetch/queryParamsToString.js.map", + "index.d.ts", + "index.js", + "index.js.map", + "openapi/createOpenApiGenerator.d.ts", + "openapi/createOpenApiGenerator.js", + "openapi/createOpenApiGenerator.js.map", + "openapi/index.d.ts", + "openapi/index.js", + "openapi/index.js.map", + "pathParameters.d.ts", + "pathParameters.js", + "pathParameters.js.map", + "supertest/createSupertestSharedClient.d.ts", + "supertest/createSupertestSharedClient.js", + "supertest/createSupertestSharedClient.js.map", + "supertest/index.d.ts", + "supertest/index.js", + "supertest/index.js.map", + "validations.d.ts", + "validations.js", + "validations.js.map" ], "keywords": [], "homepage": "https://jeromebu.gitbook.io/shared-routes", @@ -74,39 +175,39 @@ "zod": "^3.22.4", "zod-to-json-schema": "^3.21.0" }, - "main": "dist/index.js", - "types": "dist/index.d.ts", - "module": "dist/esm/index.mjs", + "main": "index.js", + "types": "index.d.ts", + "module": "esm/index.mjs", "exports": { ".": { - "require": "./dist/index.js", - "import": "./dist/esm/index.mjs", - "types": "./dist/index.d.ts" + "require": "./index.js", + "import": "./esm/index.mjs", + "types": "./index.d.ts" }, "./axios": { - "require": "./dist/axios/index.js", - "import": "./dist/esm/axios/index.mjs", - "types": "./dist/axios/index.d.ts" + "require": "./axios/index.js", + "import": "./esm/axios/index.mjs", + "types": "./axios/index.d.ts" }, "./fetch": { - "require": "./dist/fetch/index.js", - "import": "./dist/esm/fetch/index.mjs", - "types": "./dist/fetch/index.d.ts" + "require": "./fetch/index.js", + "import": "./esm/fetch/index.mjs", + "types": "./fetch/index.d.ts" }, "./express": { - "require": "./dist/express/index.js", - "import": "./dist/esm/express/index.mjs", - "types": "./dist/express/index.d.ts" + "require": "./express/index.js", + "import": "./esm/express/index.mjs", + "types": "./express/index.d.ts" }, "./supertest": { - "require": "./dist/supertest/index.js", - "import": "./dist/esm/supertest/index.mjs", - "types": "./dist/supertest/index.d.ts" + "require": "./supertest/index.js", + "import": "./esm/supertest/index.mjs", + "types": "./supertest/index.d.ts" }, "./openapi": { - "require": "./dist/openapi/index.js", - "import": "./dist/esm/openapi/index.mjs", - "types": "./dist/openapi/index.d.ts" + "require": "./openapi/index.js", + "import": "./esm/openapi/index.mjs", + "types": "./openapi/index.d.ts" } } } diff --git a/pathParameters.d.ts b/pathParameters.d.ts new file mode 100644 index 0000000..c40384b --- /dev/null +++ b/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/pathParameters.js b/pathParameters.js new file mode 100644 index 0000000..653d9ab --- /dev/null +++ b/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/pathParameters.js.map b/pathParameters.js.map new file mode 100644 index 0000000..8a59e2d --- /dev/null +++ b/pathParameters.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pathParameters.js","sourceRoot":"","sources":["src/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/supertest/createSupertestSharedClient.d.ts b/supertest/createSupertestSharedClient.d.ts new file mode 100644 index 0000000..b77e0ad --- /dev/null +++ b/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/supertest/createSupertestSharedClient.js b/supertest/createSupertestSharedClient.js new file mode 100644 index 0000000..5ed59cc --- /dev/null +++ b/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/supertest/createSupertestSharedClient.js.map b/supertest/createSupertestSharedClient.js.map new file mode 100644 index 0000000..254123e --- /dev/null +++ b/supertest/createSupertestSharedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"createSupertestSharedClient.js","sourceRoot":"","sources":["../src/supertest/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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/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/supertest/index.d.ts b/supertest/index.d.ts new file mode 100644 index 0000000..8854d2a --- /dev/null +++ b/supertest/index.d.ts @@ -0,0 +1 @@ +export { createSupertestSharedClient } from "./createSupertestSharedClient"; diff --git a/supertest/index.js b/supertest/index.js new file mode 100644 index 0000000..5ab31f3 --- /dev/null +++ b/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/supertest/index.js.map b/supertest/index.js.map new file mode 100644 index 0000000..221632d --- /dev/null +++ b/supertest/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/supertest/index.ts"],"names":[],"mappings":";;;AAAA,6EAA4E;AAAnE,0IAAA,2BAA2B,OAAA"} \ No newline at end of file diff --git a/tsconfig.tsbuildinfo b/tsconfig.tsbuildinfo new file mode 100644 index 0000000..cb0993c --- /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"],"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,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,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]],"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":"6a6195c68c56a17ade1fc929652873f51368c0c9647c386dd154e25e2250f253","signature":"56b7532c9526911c2da35d9bcacb1a07781f1f52d90a16fbcd621e1de00a88a4"},"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"],"root":[[60,65],67,68,[176,180],210,211,215,216],"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],[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],[66,3],[181,3],[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,63],[98,64],[87,63],[108,65],[79,66],[78,67],[107,68],[101,69],[106,70],[81,71],[95,72],[80,73],[104,74],[76,75],[75,68],[105,76],[77,77],[82,78],[83,3],[86,78],[73,3],[109,79],[99,80],[90,81],[91,82],[93,83],[89,84],[92,85],[102,68],[84,86],[85,87],[94,88],[74,89],[97,80],[96,78],[100,3],[103,90],[209,91],[182,92],[184,93],[185,94],[207,95],[183,3],[186,96],[187,97],[188,3],[189,3],[190,92],[191,98],[192,99],[193,98],[194,92],[195,3],[196,100],[197,101],[198,97],[199,98],[201,102],[202,96],[200,97],[203,98],[204,3],[205,98],[206,3],[208,93],[59,103],[49,104],[51,105],[57,106],[53,3],[54,3],[52,107],[55,103],[47,3],[48,3],[58,108],[50,109],[56,110],[67,111],[68,112],[62,113],[63,114],[61,115],[176,116],[177,117],[179,118],[180,119],[178,3],[64,120],[210,121],[211,122],[60,3],[215,123],[216,124],[65,125]],"version":"5.6.2"} \ No newline at end of file diff --git a/validations.d.ts b/validations.d.ts new file mode 100644 index 0000000..835913d --- /dev/null +++ b/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/validations.js b/validations.js new file mode 100644 index 0000000..4e215bb --- /dev/null +++ b/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/validations.js.map b/validations.js.map new file mode 100644 index 0000000..d5e55d7 --- /dev/null +++ b/validations.js.map @@ -0,0 +1 @@ +{"version":3,"file":"validations.js","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;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,MAAG;QACjB,iBAAU,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,cAAI,KAAK,CAAC,GAAG,CAAE;cAChD,CAAC,mBAAmB,KAAI,MAAC,KAAa,aAAb,KAA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