= (props) => (
11 |
12 | {props.children}
13 |
14 | );
15 |
--------------------------------------------------------------------------------
/docs/src/pages/_app.jsx:
--------------------------------------------------------------------------------
1 | import '../styles/global.css';
2 |
3 | import { fontInter } from '../components/fonts/FontInter';
4 |
5 | export default function App({ Component, pageProps }) {
6 | return (
7 |
8 |
9 |
10 | );
11 | }
12 |
--------------------------------------------------------------------------------
/docs/src/pages/_meta.tsx:
--------------------------------------------------------------------------------
1 | const meta = {
2 | index: 'Projects',
3 | assert: '@httpx/assert',
4 | exception: '@httpx/exception',
5 | 'dsn-parser': '@httpx/dsn-parser',
6 | 'plain-object': '@httpx/plain-object',
7 | sponsors: 'Sponsors',
8 | license: 'License',
9 | };
10 | export default meta;
11 |
--------------------------------------------------------------------------------
/docs/src/pages/assert/_meta.tsx:
--------------------------------------------------------------------------------
1 | const meta = {
2 | index: 'Getting started',
3 | };
4 | export default meta;
5 |
--------------------------------------------------------------------------------
/docs/src/pages/exception/_meta.tsx:
--------------------------------------------------------------------------------
1 | const meta = {
2 | index: 'Getting started',
3 | recipes: 'Recipes',
4 | ecosystem: 'Ecosystem',
5 | advanced: 'Advanced',
6 | };
7 | export default meta;
8 |
--------------------------------------------------------------------------------
/docs/src/pages/exception/advanced.mdx:
--------------------------------------------------------------------------------
1 | ## Advanced
2 |
3 | ### Generic exception
4 |
5 | Although not recommended it's possible to create exception from base classes.
6 |
7 | ```typescript
8 | import { HttpClientException, HttpServerException } from "@httpx/exception";
9 |
10 | const e404 = new HttpClientException(404, 'optional message or params');
11 | const e500 = new HttpServerException(500, 'optional message or params');
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/docs/src/pages/sponsors.mdx:
--------------------------------------------------------------------------------
1 | ## Sponsors ❤️
2 |
3 | If you are enjoying some of my OSS guides or libs for your company, I'd really appreciate a [sponsorship](https://github.com/sponsors/belgattitude), a [coffee](https://ko-fi.com/belgattitude) or a dropped star. That gives me a tasty morning boost and help me to make some of my ideas come true 🙏
4 |
--------------------------------------------------------------------------------
/examples/nextjs-app/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | .pnpm-debug.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
34 | # typescript
35 | *.tsbuildinfo
36 |
--------------------------------------------------------------------------------
/examples/nextjs-app/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
5 | // NOTE: This file should not be edited
6 | // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
7 |
--------------------------------------------------------------------------------
/examples/nextjs-app/postcss.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | '@tailwindcss/postcss': {},
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/examples/nextjs-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/belgattitude/httpx/562fe653da5bf40cc6026da24a1230ca5863bf4f/examples/nextjs-app/public/favicon.ico
--------------------------------------------------------------------------------
/examples/nextjs-app/src/app/api/health/route.ts:
--------------------------------------------------------------------------------
1 | import { type NextRequest, NextResponse } from 'next/server';
2 |
3 | export const dynamic = 'force-dynamic';
4 |
5 | export async function GET(_req: NextRequest) {
6 | return NextResponse.json(
7 | {
8 | time: new Date().toISOString(),
9 | },
10 | {
11 | status: 200,
12 | }
13 | );
14 | }
15 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/app/api/proxy/[...route]/route.ts:
--------------------------------------------------------------------------------
1 | import { Hono } from 'hono';
2 | import { proxy } from 'hono/proxy';
3 | import { handle } from 'hono/vercel';
4 | export const runtime = 'edge';
5 |
6 | const app = new Hono().basePath('/api/proxy');
7 |
8 | const devServer = 'localhost:3000';
9 |
10 | app.get('/hello', (c) => {
11 | return c.text('Hello, World!');
12 | });
13 |
14 | app.get('/backend/:path', async (c) => {
15 | // return proxy('https://example.com:80');
16 | console.log(`http://${devServer}/${c.req.param('path')}`);
17 | return proxy(`http://${devServer}/api/health`);
18 | });
19 |
20 | export const GET = handle(app);
21 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/app/layout.tsx:
--------------------------------------------------------------------------------
1 | import '../styles/globals.css';
2 |
3 | import type { Metadata } from 'next';
4 | import { Inter } from 'next/font/google';
5 | import type { ReactNode } from 'react';
6 |
7 | const inter = Inter({ subsets: ['latin'] });
8 |
9 | export const metadata: Metadata = {
10 | title: 'Create Next App',
11 | description: 'Generated by create next app',
12 | };
13 |
14 | export default function RootLayout({
15 | children,
16 | }: Readonly<{
17 | children: ReactNode;
18 | }>) {
19 | return (
20 |
21 | {children}
22 |
23 | );
24 | }
25 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/app/treeu/layout.tsx:
--------------------------------------------------------------------------------
1 | import 'primereact/resources/themes/soho-light/theme.css';
2 |
3 | import type { ReactNode } from 'react';
4 |
5 | import { PrimeReactTailwindProvider } from '../../providers/PrimeReactTailwindProvider';
6 |
7 | export default function RootLayout({
8 | children,
9 | }: Readonly<{
10 | children: ReactNode;
11 | }>) {
12 | return {children};
13 | }
14 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/app/treeu/page.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { CityMultiSelect } from '../../components/prime/CityMultiSelect';
4 | import { FolderTreeSelect } from '../../components/prime/FolderTreeSelect';
5 |
6 | export default function TreeUDemoPage() {
7 | return (
8 |
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/components/fonts/FontInter.tsx:
--------------------------------------------------------------------------------
1 | import { Inter } from 'next/font/google';
2 | import type { FC, PropsWithChildren } from 'react';
3 |
4 | export const fontInter = Inter({
5 | subsets: ['latin'],
6 | weight: 'variable',
7 | variable: '--font-family-inter',
8 | });
9 |
10 | export const FontLoaderInter: FC = (props) => (
11 |
12 | {props.children}
13 |
14 | );
15 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/components/utils.ts:
--------------------------------------------------------------------------------
1 | import { type ClassValue, clsx } from 'clsx';
2 | import { twMerge } from 'tailwind-merge';
3 |
4 | export function cn(...inputs: ClassValue[]) {
5 | return twMerge(clsx(inputs));
6 | }
7 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/lib/assert.ts:
--------------------------------------------------------------------------------
1 | import { isEan13, isUuidV4, type UuidV4 } from '@httpx/assert';
2 |
3 | export const checkEan13 = (v: unknown): boolean => {
4 | return isEan13(v);
5 | };
6 |
7 | export const testTypeExports = (v: unknown): UuidV4 | null => {
8 | if (isUuidV4(v)) {
9 | return v;
10 | }
11 | return null;
12 | };
13 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/lib/index.ts:
--------------------------------------------------------------------------------
1 | export * from './logger';
2 | export * from './zod.utils';
3 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/lib/logger.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Simplified example for http-exception logging.
3 | *
4 | * Shows a possible way to conditionally log HttpException specific info (context, status codes...).
5 | *
6 | * @see https://github.com/belgattitude/httpx
7 | */
8 | import { isHttpException } from '@httpx/exception';
9 |
10 | export interface LoggerInterface {
11 | log: (message: string, payload?: T) => void;
12 | }
13 |
14 | export class ConsoleLogger implements LoggerInterface {
15 | log(message: string, payload?: unknown) {
16 | if (isHttpException(payload)) {
17 | const { name, statusCode, url } = payload;
18 | console.error(message, { name, statusCode, url });
19 | } else {
20 | console.log(message);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/lib/zod.utils.ts:
--------------------------------------------------------------------------------
1 | import { z, type ZodTypeAny } from 'zod';
2 |
3 | export const zodStringToInt = (schema: ZodTypeAny) =>
4 | z.preprocess((v): number | undefined => {
5 | if (typeof v === 'string') {
6 | return Number.parseInt(v, 10);
7 | }
8 | if (typeof v === 'number') return v;
9 | return undefined;
10 | }, schema);
11 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/pages/api/proxy-cache/[[...route]].ts:
--------------------------------------------------------------------------------
1 | import { handle } from '@hono/node-server/vercel';
2 | import { Hono } from 'hono';
3 | import type { PageConfig } from 'next';
4 |
5 | import { proxyCacheConfig } from '@/server/config/proxy-cache.config';
6 | import { ProxyCache } from '@/server/lib/proxy-cache';
7 |
8 | export const config: PageConfig = {
9 | runtime: 'nodejs',
10 | api: {
11 | bodyParser: false,
12 | },
13 | };
14 |
15 | const proxyCache = new ProxyCache(proxyCacheConfig);
16 | const proxyCacheBasePath = proxyCacheConfig.proxy.basePath;
17 |
18 | const app = new Hono().basePath(proxyCacheBasePath);
19 |
20 | app.all('*', async (c) => {
21 | return proxyCache.getResponse(c);
22 | });
23 |
24 | export default handle(app);
25 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/providers/PrimeReactTailwindProvider.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { PrimeReactProvider } from 'primereact/api';
4 | import type { FC, PropsWithChildren } from 'react';
5 | import { twMerge } from 'tailwind-merge';
6 |
7 | const providerValue = {
8 | // Will add as a pass through preset based on PrimeOne Design
9 | // @link https://primereact.org/tailwind/#unstyledmode
10 | unstyled: false,
11 | pt: {},
12 | ptOptions: {
13 | mergeSections: true,
14 | mergeProps: true,
15 | classNameMergeFunction: twMerge,
16 | },
17 | };
18 |
19 | export const PrimeReactTailwindProvider: FC = (props) => {
20 | return (
21 |
22 | {props.children}
23 |
24 | );
25 | };
26 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/server/config/proxy-cache.config.ts:
--------------------------------------------------------------------------------
1 | import { TimeLruCache } from '@httpx/lru';
2 |
3 | import type {
4 | ProxyCacheConfig,
5 | ProxyCacheItem,
6 | } from '@/server/lib/proxy-cache';
7 |
8 | export const proxyCacheConfig: ProxyCacheConfig = {
9 | compressionAlgo: 'gzip',
10 | proxy: {
11 | basePath: '/api/proxy-cache',
12 | targetBaseUrl: 'http://localhost:3000',
13 | },
14 | cache: new TimeLruCache({
15 | maxSize: 100,
16 | defaultTTL: 180_000,
17 | }),
18 | };
19 |
--------------------------------------------------------------------------------
/examples/nextjs-app/src/server/index.ts:
--------------------------------------------------------------------------------
1 | export * from './parseRequestWithZod';
2 | export * from './withApiErrorHandler';
3 |
--------------------------------------------------------------------------------
/examples/nextjs-app/tsconfig.no-paths.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "paths": {
6 | "@/server/*": ["./server/*"],
7 | "@/lib": ["./lib/index"]
8 | },
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "noEmit": true,
13 | "esModuleInterop": true,
14 | "resolveJsonModule": true,
15 | "isolatedModules": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Supported browsers
2 | defaults
3 | chrome >= 96
4 | firefox >= 90
5 | edge >= 91
6 | safari >= 15
7 | ios >= 15
8 | opera >= 77
9 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # build
4 | /dist
5 |
6 | # dependencies
7 | node_modules
8 |
9 | # testing
10 | /coverage
11 |
12 | # misc
13 | .DS_Store
14 | *.pem
15 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/.size-limit.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | * @link https://github.com/ai/size-limit/
3 | * @type {{name: string, path: string[], limit: string, import?: string, webpack?: boolean}[]}
4 | */
5 | module.exports = [
6 | {
7 | name: 'Everything (ESM)',
8 | path: ['dist/index.mjs'],
9 | import: "*",
10 | limit: '1.15KB',
11 | }
12 | ];
13 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/docs/api/globals.md:
--------------------------------------------------------------------------------
1 | [**prisma-exception**](README.md)
2 |
3 | ***
4 |
5 | # prisma-exception
6 |
7 | ## Variables
8 |
9 | - [export=](variables/export=.md)
10 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/src/index.ts:
--------------------------------------------------------------------------------
1 | export const helloWord = 'cool';
2 |
--------------------------------------------------------------------------------
/integrations/prisma-exception/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "declaration": true,
8 | "declarationMap": false,
9 | "declarationDir": "./dist",
10 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
11 | },
12 | "exclude": ["*.test.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/assert/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Supported browsers
2 | defaults
3 | chrome >= 96
4 | firefox >= 105
5 | edge >= 113
6 | safari >= 15
7 | ios >= 15
8 | opera >= 103
9 | not dead
--------------------------------------------------------------------------------
/packages/assert/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/assert/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/array.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / array.asserts
6 |
7 | # array.asserts
8 |
9 | ## Functions
10 |
11 | - [assertArrayNonEmpty](functions/assertArrayNonEmpty.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/array.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / array.guards
6 |
7 | # array.guards
8 |
9 | ## Functions
10 |
11 | - [isArrayNonEmpty](functions/isArrayNonEmpty.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/array.guards/functions/isArrayNonEmpty.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [array.guards](../README.md) / isArrayNonEmpty
6 |
7 | # Function: isArrayNonEmpty()
8 |
9 | > **isArrayNonEmpty**\<`T`\>(`v`): `v is ArrayNonEmpty`
10 |
11 | Defined in: [array.guards.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/array.guards.ts#L3)
12 |
13 | ## Type Parameters
14 |
15 | ### T
16 |
17 | `T` = `unknown`
18 |
19 | ## Parameters
20 |
21 | ### v
22 |
23 | `unknown`
24 |
25 | ## Returns
26 |
27 | `v is ArrayNonEmpty`
28 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/array.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / array.types
6 |
7 | # array.types
8 |
9 | ## Type Aliases
10 |
11 | - [ArrayNonEmpty](type-aliases/ArrayNonEmpty.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/array.types/type-aliases/ArrayNonEmpty.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [array.types](../README.md) / ArrayNonEmpty
6 |
7 | # Type Alias: ArrayNonEmpty\
8 |
9 | > **ArrayNonEmpty**\<`T`\> = \[`T`, `...T[]`\]
10 |
11 | Defined in: [array.types.ts:1](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/array.types.ts#L1)
12 |
13 | ## Type Parameters
14 |
15 | ### T
16 |
17 | `T` = `unknown`
18 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / barcode.asserts
6 |
7 | # barcode.asserts
8 |
9 | ## Functions
10 |
11 | - [assertEan13](functions/assertEan13.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.asserts/functions/assertEan13.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [barcode.asserts](../README.md) / assertEan13
6 |
7 | # Function: assertEan13()
8 |
9 | > **assertEan13**(`v`, `msgOrErrorFactory?`): `asserts v is Ean13`
10 |
11 | Defined in: [barcode.asserts.ts:10](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/barcode.asserts.ts#L10)
12 |
13 | Assert string is not empty (trims the string by default)
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is Ean13`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / barcode.guards
6 |
7 | # barcode.guards
8 |
9 | ## Functions
10 |
11 | - [isEan13](functions/isEan13.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.guards/functions/isEan13.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [barcode.guards](../README.md) / isEan13
6 |
7 | # Function: isEan13()
8 |
9 | > **isEan13**(`v`): `v is Ean13`
10 |
11 | Defined in: [barcode.guards.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/barcode.guards.ts#L3)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is Ean13`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / barcode.types
6 |
7 | # barcode.types
8 |
9 | ## Type Aliases
10 |
11 | - [Ean13](type-aliases/Ean13.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/barcode.types/type-aliases/Ean13.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [barcode.types](../README.md) / Ean13
6 |
7 | # Type Alias: Ean13
8 |
9 | > **Ean13** = `string` & `WeakOpaqueContainer`\<`"Ean13"`\>
10 |
11 | Defined in: [barcode.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/barcode.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / http.asserts
6 |
7 | # http.asserts
8 |
9 | ## Functions
10 |
11 | - [assertHttpMethod](functions/assertHttpMethod.md)
12 | - [assertHttpValidMethod](functions/assertHttpValidMethod.md)
13 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.asserts/functions/assertHttpValidMethod.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [http.asserts](../README.md) / assertHttpValidMethod
6 |
7 | # Function: assertHttpValidMethod()
8 |
9 | > **assertHttpValidMethod**(`v`, `msgOrErrorFactory?`): `asserts v is HttpMethod`
10 |
11 | Defined in: [http.asserts.ts:10](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/http.asserts.ts#L10)
12 |
13 | Assert the value is a valid http method (case-insensitive)
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is HttpMethod`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.consts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / http.consts
6 |
7 | # http.consts
8 |
9 | ## Variables
10 |
11 | - [httpMethods](variables/httpMethods.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.consts/variables/httpMethods.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [http.consts](../README.md) / httpMethods
6 |
7 | # Variable: httpMethods
8 |
9 | > `const` **httpMethods**: readonly \[`"GET"`, `"POST"`, `"HEAD"`, `"PUT"`, `"DELETE"`, `"CONNECT"`, `"OPTIONS"`, `"PATCH"`, `"TRACE"`\]
10 |
11 | Defined in: [http.consts.ts:1](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/http.consts.ts#L1)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / http.guards
6 |
7 | # http.guards
8 |
9 | ## Functions
10 |
11 | - [isHttpMethod](functions/isHttpMethod.md)
12 | - [isHttpValidMethod](functions/isHttpValidMethod.md)
13 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.guards/functions/isHttpMethod.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [http.guards](../README.md) / isHttpMethod
6 |
7 | # Function: isHttpMethod()
8 |
9 | > **isHttpMethod**\<`T`\>(`method`, `v`): `v is T`
10 |
11 | Defined in: [http.guards.ts:15](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/http.guards.ts#L15)
12 |
13 | ## Type Parameters
14 |
15 | ### T
16 |
17 | `T` *extends* [`HttpMethod`](../../http.types/type-aliases/HttpMethod.md)
18 |
19 | ## Parameters
20 |
21 | ### method
22 |
23 | `T`
24 |
25 | ### v
26 |
27 | `unknown`
28 |
29 | ## Returns
30 |
31 | `v is T`
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.guards/functions/isHttpValidMethod.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [http.guards](../README.md) / isHttpValidMethod
6 |
7 | # Function: isHttpValidMethod()
8 |
9 | > **isHttpValidMethod**(`v`): `v is HttpMethod`
10 |
11 | Defined in: [http.guards.ts:8](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/http.guards.ts#L8)
12 |
13 | Check whether the value is a valid http method (GET, PUT...) in
14 | a case-insensitive manner.
15 |
16 | ## Parameters
17 |
18 | ### v
19 |
20 | `unknown`
21 |
22 | ## Returns
23 |
24 | `v is HttpMethod`
25 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / http.types
6 |
7 | # http.types
8 |
9 | ## Type Aliases
10 |
11 | - [HttpMethod](type-aliases/HttpMethod.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/http.types/type-aliases/HttpMethod.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [http.types](../README.md) / HttpMethod
6 |
7 | # Type Alias: HttpMethod
8 |
9 | > **HttpMethod** = `"GET"` \| `"POST"` \| `"HEAD"` \| `"PUT"` \| `"DELETE"` \| `"CONNECT"` \| `"OPTIONS"` \| `"PATCH"` \| `"TRACE"`
10 |
11 | Defined in: [http.types.ts:1](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/http.types.ts#L1)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / network.asserts
6 |
7 | # network.asserts
8 |
9 | ## Functions
10 |
11 | - [assertNetworkPort](functions/assertNetworkPort.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.asserts/functions/assertNetworkPort.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [network.asserts](../README.md) / assertNetworkPort
6 |
7 | # Function: assertNetworkPort()
8 |
9 | > **assertNetworkPort**(`v`, `msgOrErrorFactory?`): `asserts v is NetworkPort`
10 |
11 | Defined in: [network.asserts.ts:9](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/network.asserts.ts#L9)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ### msgOrErrorFactory?
20 |
21 | `MsgOrErrorFactory`
22 |
23 | ## Returns
24 |
25 | `asserts v is NetworkPort`
26 |
27 | ## Throws
28 |
29 | TypeError
30 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / network.guards
6 |
7 | # network.guards
8 |
9 | ## Functions
10 |
11 | - [isNetworkPort](functions/isNetworkPort.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.guards/functions/isNetworkPort.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [network.guards](../README.md) / isNetworkPort
6 |
7 | # Function: isNetworkPort()
8 |
9 | > **isNetworkPort**(`v`): `v is NetworkPort`
10 |
11 | Defined in: [network.guards.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/network.guards.ts#L3)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is NetworkPort`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / network.types
6 |
7 | # network.types
8 |
9 | ## Type Aliases
10 |
11 | - [NetworkPort](type-aliases/NetworkPort.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/network.types/type-aliases/NetworkPort.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [network.types](../README.md) / NetworkPort
6 |
7 | # Type Alias: NetworkPort
8 |
9 | > **NetworkPort** = `number` & `WeakOpaqueContainer`\<`"NetworkPort"`\>
10 |
11 | Defined in: [network.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/network.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/number.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / number.asserts
6 |
7 | # number.asserts
8 |
9 | ## Functions
10 |
11 | - [assertNumberSafeInt](functions/assertNumberSafeInt.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/number.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / number.guards
6 |
7 | # number.guards
8 |
9 | ## Functions
10 |
11 | - [isNumberSafeInt](functions/isNumberSafeInt.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/number.guards/functions/isNumberSafeInt.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [number.guards](../README.md) / isNumberSafeInt
6 |
7 | # Function: isNumberSafeInt()
8 |
9 | > **isNumberSafeInt**(`v`): `v is NumberSafeInt`
10 |
11 | Defined in: [number.guards.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/number.guards.ts#L3)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is NumberSafeInt`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/number.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / number.types
6 |
7 | # number.types
8 |
9 | ## Type Aliases
10 |
11 | - [NumberSafeInt](type-aliases/NumberSafeInt.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/number.types/type-aliases/NumberSafeInt.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [number.types](../README.md) / NumberSafeInt
6 |
7 | # Type Alias: NumberSafeInt
8 |
9 | > **NumberSafeInt** = `number` & `WeakOpaqueContainer`\<`"NumberSafeInt"`\>
10 |
11 | Defined in: [number.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/number.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / object.asserts
6 |
7 | # object.asserts
8 |
9 | ## Functions
10 |
11 | - [assertPlainObject](functions/assertPlainObject.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / object.guards
6 |
7 | # object.guards
8 |
9 | ## Functions
10 |
11 | - [isPlainObject](functions/isPlainObject.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.internal.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / object.internal.types
6 |
7 | # object.internal.types
8 |
9 | ## Interfaces
10 |
11 | - [DefaultBasePlainObject](interfaces/DefaultBasePlainObject.md)
12 |
13 | ## Type Aliases
14 |
15 | - [BasePlainObject](type-aliases/BasePlainObject.md)
16 | - [PlainObjectDeepPartialUnknown](type-aliases/PlainObjectDeepPartialUnknown.md)
17 | - [PlainObjectKey](type-aliases/PlainObjectKey.md)
18 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.internal.types/type-aliases/BasePlainObject.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [object.internal.types](../README.md) / BasePlainObject
6 |
7 | # Type Alias: BasePlainObject
8 |
9 | > **BasePlainObject** = `Record`\<[`PlainObjectKey`](PlainObjectKey.md), `unknown`\>
10 |
11 | Defined in: [object.internal.types.ts:5](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/object.internal.types.ts#L5)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.internal.types/type-aliases/PlainObjectDeepPartialUnknown.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [object.internal.types](../README.md) / PlainObjectDeepPartialUnknown
6 |
7 | # Type Alias: PlainObjectDeepPartialUnknown\
8 |
9 | > **PlainObjectDeepPartialUnknown**\<`T`\> = `{ [P in keyof T]?: NonNullable extends BasePlainObject ? Simplify>> : unknown }`
10 |
11 | Defined in: [object.internal.types.ts:11](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/object.internal.types.ts#L11)
12 |
13 | ## Type Parameters
14 |
15 | ### T
16 |
17 | `T`
18 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.internal.types/type-aliases/PlainObjectKey.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [object.internal.types](../README.md) / PlainObjectKey
6 |
7 | # Type Alias: PlainObjectKey
8 |
9 | > **PlainObjectKey** = `string` \| `number` \| `symbol`
10 |
11 | Defined in: [object.internal.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/object.internal.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/object.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / object.types
6 |
7 | # object.types
8 |
9 | ## Type Aliases
10 |
11 | - [PlainObject](type-aliases/PlainObject.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / string.asserts
6 |
7 | # string.asserts
8 |
9 | ## Functions
10 |
11 | - [assertParsableSafeInt](functions/assertParsableSafeInt.md)
12 | - [assertParsableStrictIsoDateZ](functions/assertParsableStrictIsoDateZ.md)
13 | - [assertStringNonEmpty](functions/assertStringNonEmpty.md)
14 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.asserts/functions/assertParsableSafeInt.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.asserts](../README.md) / assertParsableSafeInt
6 |
7 | # Function: assertParsableSafeInt()
8 |
9 | > **assertParsableSafeInt**(`v`, `msgOrErrorFactory?`): `asserts v is ParsableSafeInt`
10 |
11 | Defined in: [string.asserts.ts:32](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.asserts.ts#L32)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ### msgOrErrorFactory?
20 |
21 | `MsgOrErrorFactory`
22 |
23 | ## Returns
24 |
25 | `asserts v is ParsableSafeInt`
26 |
27 | ## Throws
28 |
29 | TypeError
30 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / string.guards
6 |
7 | # string.guards
8 |
9 | ## Functions
10 |
11 | - [isParsableSafeInt](functions/isParsableSafeInt.md)
12 | - [isParsableStrictIsoDateZ](functions/isParsableStrictIsoDateZ.md)
13 | - [isStringNonEmpty](functions/isStringNonEmpty.md)
14 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.guards/functions/isParsableSafeInt.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.guards](../README.md) / isParsableSafeInt
6 |
7 | # Function: isParsableSafeInt()
8 |
9 | > **isParsableSafeInt**(`v`): `v is ParsableSafeInt`
10 |
11 | Defined in: [string.guards.ts:14](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.guards.ts#L14)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is ParsableSafeInt`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.guards/functions/isStringNonEmpty.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.guards](../README.md) / isStringNonEmpty
6 |
7 | # Function: isStringNonEmpty()
8 |
9 | > **isStringNonEmpty**(`v`): `v is StringNonEmpty`
10 |
11 | Defined in: [string.guards.ts:9](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.guards.ts#L9)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is StringNonEmpty`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / string.types
6 |
7 | # string.types
8 |
9 | ## Type Aliases
10 |
11 | - [ParsableSafeInt](type-aliases/ParsableSafeInt.md)
12 | - [ParsableStrictIsoDateZ](type-aliases/ParsableStrictIsoDateZ.md)
13 | - [StringNonEmpty](type-aliases/StringNonEmpty.md)
14 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.types/type-aliases/ParsableSafeInt.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.types](../README.md) / ParsableSafeInt
6 |
7 | # Type Alias: ParsableSafeInt
8 |
9 | > **ParsableSafeInt** = `string` & `WeakOpaqueContainer`\<`"ParsableSafeInt"`\>
10 |
11 | Defined in: [string.types.ts:4](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.types.ts#L4)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.types/type-aliases/ParsableStrictIsoDateZ.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.types](../README.md) / ParsableStrictIsoDateZ
6 |
7 | # Type Alias: ParsableStrictIsoDateZ
8 |
9 | > **ParsableStrictIsoDateZ** = `string` & `WeakOpaqueContainer`\<`"ParsableStrictIsoDateZ"`\>
10 |
11 | Defined in: [string.types.ts:5](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.types.ts#L5)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.types/type-aliases/StringNonEmpty.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.types](../README.md) / StringNonEmpty
6 |
7 | # Type Alias: StringNonEmpty
8 |
9 | > **StringNonEmpty** = `string` & `WeakOpaqueContainer`\<`"StringNonEmpty"`\>
10 |
11 | Defined in: [string.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.utils/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / string.utils
6 |
7 | # string.utils
8 |
9 | ## Variables
10 |
11 | - [isoDateTimeZRegexp](variables/isoDateTimeZRegexp.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/string.utils/variables/isoDateTimeZRegexp.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [string.utils](../README.md) / isoDateTimeZRegexp
6 |
7 | # Variable: isoDateTimeZRegexp
8 |
9 | > `const` **isoDateTimeZRegexp**: `RegExp`
10 |
11 | Defined in: [string.utils.ts:1](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/string.utils.ts#L1)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/types.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / types.asserts
6 |
7 | # types.asserts
8 |
9 | ## Functions
10 |
11 | - [assertNever](functions/assertNever.md)
12 | - [assertNeverNoThrow](functions/assertNeverNoThrow.md)
13 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/types.asserts/functions/assertNever.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [types.asserts](../README.md) / assertNever
6 |
7 | # Function: assertNever()
8 |
9 | > **assertNever**(`v`, `msgOrErrorFactory?`): `never`
10 |
11 | Defined in: [types.asserts.ts:8](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/types.asserts.ts#L8)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `never`
18 |
19 | ### msgOrErrorFactory?
20 |
21 | `MsgOrErrorFactory`
22 |
23 | ## Returns
24 |
25 | `never`
26 |
27 | ## Throws
28 |
29 | TypeError
30 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/types.asserts/functions/assertNeverNoThrow.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [types.asserts](../README.md) / assertNeverNoThrow
6 |
7 | # Function: assertNeverNoThrow()
8 |
9 | > **assertNeverNoThrow**(`v`): `never`
10 |
11 | Defined in: [types.asserts.ts:24](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/types.asserts.ts#L24)
12 |
13 | A slight variation of assertNever that doesn't throw in runtime and
14 | will return the value. Typechecks are still enforced.
15 |
16 | ## Parameters
17 |
18 | ### v
19 |
20 | `never`
21 |
22 | ## Returns
23 |
24 | `never`
25 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.asserts/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / uuid.asserts
6 |
7 | # uuid.asserts
8 |
9 | ## Functions
10 |
11 | - [assertUuid](functions/assertUuid.md)
12 | - [assertUuidV1](functions/assertUuidV1.md)
13 | - [assertUuidV3](functions/assertUuidV3.md)
14 | - [assertUuidV4](functions/assertUuidV4.md)
15 | - [assertUuidV5](functions/assertUuidV5.md)
16 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.asserts/functions/assertUuidV1.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.asserts](../README.md) / assertUuidV1
6 |
7 | # Function: assertUuidV1()
8 |
9 | > **assertUuidV1**(`v`, `msgOrErrorFactory?`): `asserts v is UuidV1`
10 |
11 | Defined in: [uuid.asserts.ts:44](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.asserts.ts#L44)
12 |
13 | Asserts a value is a valid uuid v1
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is UuidV1`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.asserts/functions/assertUuidV3.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.asserts](../README.md) / assertUuidV3
6 |
7 | # Function: assertUuidV3()
8 |
9 | > **assertUuidV3**(`v`, `msgOrErrorFactory?`): `asserts v is UuidV3`
10 |
11 | Defined in: [uuid.asserts.ts:58](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.asserts.ts#L58)
12 |
13 | Asserts a value is a valid uuid v3
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is UuidV3`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.asserts/functions/assertUuidV4.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.asserts](../README.md) / assertUuidV4
6 |
7 | # Function: assertUuidV4()
8 |
9 | > **assertUuidV4**(`v`, `msgOrErrorFactory?`): `asserts v is UuidV4`
10 |
11 | Defined in: [uuid.asserts.ts:71](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.asserts.ts#L71)
12 |
13 | Assert a value is a valid uuid v4
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is UuidV4`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.asserts/functions/assertUuidV5.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.asserts](../README.md) / assertUuidV5
6 |
7 | # Function: assertUuidV5()
8 |
9 | > **assertUuidV5**(`v`, `msgOrErrorFactory?`): `asserts v is UuidV5`
10 |
11 | Defined in: [uuid.asserts.ts:84](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.asserts.ts#L84)
12 |
13 | Assert a value is a valid uuid v5
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ### msgOrErrorFactory?
22 |
23 | `MsgOrErrorFactory`
24 |
25 | ## Returns
26 |
27 | `asserts v is UuidV5`
28 |
29 | ## Throws
30 |
31 | TypeError
32 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / uuid.guards
6 |
7 | # uuid.guards
8 |
9 | ## Functions
10 |
11 | - [isUuid](functions/isUuid.md)
12 | - [isUuidV1](functions/isUuidV1.md)
13 | - [isUuidV3](functions/isUuidV3.md)
14 | - [isUuidV4](functions/isUuidV4.md)
15 | - [isUuidV5](functions/isUuidV5.md)
16 | - [isUuidV7](functions/isUuidV7.md)
17 | - [isUuidVersion](functions/isUuidVersion.md)
18 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuid.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuid
6 |
7 | # Function: isUuid()
8 |
9 | > **isUuid**(`v`, `version?`): `v is Uuid`
10 |
11 | Defined in: [uuid.guards.ts:24](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L24)
12 |
13 | Check whether a value is string and passes uuid validation with
14 | optional given version
15 |
16 | ## Parameters
17 |
18 | ### v
19 |
20 | `unknown`
21 |
22 | ### version?
23 |
24 | [`UuidVersion`](../../uuid.types/type-aliases/UuidVersion.md)
25 |
26 | ## Returns
27 |
28 | `v is Uuid`
29 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidV1.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidV1
6 |
7 | # Function: isUuidV1()
8 |
9 | > **isUuidV1**(`v`): `v is UuidV1`
10 |
11 | Defined in: [uuid.guards.ts:32](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L32)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is UuidV1`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidV3.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidV3
6 |
7 | # Function: isUuidV3()
8 |
9 | > **isUuidV3**(`v`): `v is UuidV3`
10 |
11 | Defined in: [uuid.guards.ts:34](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L34)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is UuidV3`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidV4.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidV4
6 |
7 | # Function: isUuidV4()
8 |
9 | > **isUuidV4**(`v`): `v is UuidV4`
10 |
11 | Defined in: [uuid.guards.ts:35](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L35)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is UuidV4`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidV5.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidV5
6 |
7 | # Function: isUuidV5()
8 |
9 | > **isUuidV5**(`v`): `v is UuidV5`
10 |
11 | Defined in: [uuid.guards.ts:36](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L36)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is UuidV5`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidV7.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidV7
6 |
7 | # Function: isUuidV7()
8 |
9 | > **isUuidV7**(`v`): `v is UuidV7`
10 |
11 | Defined in: [uuid.guards.ts:37](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L37)
12 |
13 | ## Parameters
14 |
15 | ### v
16 |
17 | `unknown`
18 |
19 | ## Returns
20 |
21 | `v is UuidV7`
22 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.guards/functions/isUuidVersion.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.guards](../README.md) / isUuidVersion
6 |
7 | # Function: isUuidVersion()
8 |
9 | > **isUuidVersion**(`v`): `v is UuidVersion`
10 |
11 | Defined in: [uuid.guards.ts:16](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.guards.ts#L16)
12 |
13 | Check if a value is a valid uuid version: 1, 3, 4 or 5
14 |
15 | ## Parameters
16 |
17 | ### v
18 |
19 | `unknown`
20 |
21 | ## Returns
22 |
23 | `v is UuidVersion`
24 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.helpers/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / uuid.helpers
6 |
7 | # uuid.helpers
8 |
9 | ## Functions
10 |
11 | - [getUuidVersion](functions/getUuidVersion.md)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.helpers/functions/getUuidVersion.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.helpers](../README.md) / getUuidVersion
6 |
7 | # Function: getUuidVersion()
8 |
9 | > **getUuidVersion**(`uuid`): `null` \| [`UuidVersion`](../../uuid.types/type-aliases/UuidVersion.md)
10 |
11 | Defined in: [uuid.helpers.ts:7](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.helpers.ts#L7)
12 |
13 | Adapted from https://github.com/uuidjs/uuid/blob/main/src/version.js
14 |
15 | ## Parameters
16 |
17 | ### uuid
18 |
19 | `string`
20 |
21 | ## Returns
22 |
23 | `null` \| [`UuidVersion`](../../uuid.types/type-aliases/UuidVersion.md)
24 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / uuid.types
6 |
7 | # uuid.types
8 |
9 | ## Type Aliases
10 |
11 | - [Uuid](type-aliases/Uuid.md)
12 | - [UuidV1](type-aliases/UuidV1.md)
13 | - [UuidV3](type-aliases/UuidV3.md)
14 | - [UuidV4](type-aliases/UuidV4.md)
15 | - [UuidV5](type-aliases/UuidV5.md)
16 | - [UuidV7](type-aliases/UuidV7.md)
17 | - [UuidVersion](type-aliases/UuidVersion.md)
18 | - [UuidVersionOrNumber](type-aliases/UuidVersionOrNumber.md)
19 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/Uuid.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / Uuid
6 |
7 | # Type Alias: Uuid
8 |
9 | > **Uuid** = `string` & `WeakOpaqueContainer`\<`"Uuid"`\>
10 |
11 | Defined in: [uuid.types.ts:3](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L3)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidV1.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidV1
6 |
7 | # Type Alias: UuidV1
8 |
9 | > **UuidV1** = `string` & `WeakOpaqueContainer`\<`"UuidV1"`\>
10 |
11 | Defined in: [uuid.types.ts:5](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L5)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidV3.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidV3
6 |
7 | # Type Alias: UuidV3
8 |
9 | > **UuidV3** = `string` & `WeakOpaqueContainer`\<`"UuidV3"`\>
10 |
11 | Defined in: [uuid.types.ts:6](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L6)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidV4.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidV4
6 |
7 | # Type Alias: UuidV4
8 |
9 | > **UuidV4** = `string` & `WeakOpaqueContainer`\<`"UuidV4"`\>
10 |
11 | Defined in: [uuid.types.ts:7](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L7)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidV5.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidV5
6 |
7 | # Type Alias: UuidV5
8 |
9 | > **UuidV5** = `string` & `WeakOpaqueContainer`\<`"UuidV5"`\>
10 |
11 | Defined in: [uuid.types.ts:8](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L8)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidV7.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidV7
6 |
7 | # Type Alias: UuidV7
8 |
9 | > **UuidV7** = `string` & `WeakOpaqueContainer`\<`"UuidV7"`\>
10 |
11 | Defined in: [uuid.types.ts:9](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L9)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidVersion.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidVersion
6 |
7 | # Type Alias: UuidVersion
8 |
9 | > **UuidVersion** = `1` \| `3` \| `4` \| `5` \| `7`
10 |
11 | Defined in: [uuid.types.ts:11](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L11)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.types/type-aliases/UuidVersionOrNumber.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.types](../README.md) / UuidVersionOrNumber
6 |
7 | # Type Alias: UuidVersionOrNumber
8 |
9 | > **UuidVersionOrNumber** = `number` & `WeakOpaqueContainer`\<`"UuidVersionOrNumber"`\>
10 |
11 | Defined in: [uuid.types.ts:12](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.types.ts#L12)
12 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.utils/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../README.md) / uuid.utils
6 |
7 | # uuid.utils
8 |
9 | ## Variables
10 |
11 | - [uuidRegexp](variables/uuidRegexp.md)
12 | - [uuidSupportedVersions](variables/uuidSupportedVersions.md)
13 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.utils/variables/uuidRegexp.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.utils](../README.md) / uuidRegexp
6 |
7 | # Variable: uuidRegexp
8 |
9 | > `const` **uuidRegexp**: `RegExp`
10 |
11 | Defined in: [uuid.utils.ts:4](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.utils.ts#L4)
12 |
13 | Taken from https://github.com/uuidjs/uuid/blob/main/src/regex.js
14 |
--------------------------------------------------------------------------------
/packages/assert/docs/api/uuid.utils/variables/uuidSupportedVersions.md:
--------------------------------------------------------------------------------
1 | [**@httpx/assert v0.15.2**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/assert](../../README.md) / [uuid.utils](../README.md) / uuidSupportedVersions
6 |
7 | # Variable: uuidSupportedVersions
8 |
9 | > `const` **uuidSupportedVersions**: `Set`\<`number`\>
10 |
11 | Defined in: [uuid.utils.ts:8](https://github.com/belgattitude/httpx/blob/b6bd279cf69f2d17f3ec46e9618a31cb72744279/packages/assert/src/uuid.utils.ts#L8)
12 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/array.guard.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | import { isArrayNonEmpty } from '../array.guards';
4 |
5 | describe('Array typeguards tests', () => {
6 | describe('isArrayNotEmpty', () => {
7 | it.each([
8 | [false, []],
9 | [false, Array.from([])],
10 | [false, new Date()],
11 | [true, Array.from(['cool'])],
12 | [true, ['cool']],
13 | ])('should return %s when %s is given', (expected, v) => {
14 | expect(isArrayNonEmpty(v)).toBe(expected);
15 | });
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/array.types.test.ts:
--------------------------------------------------------------------------------
1 | import { assertType } from 'vitest';
2 |
3 | import { assertArrayNonEmpty } from '../array.asserts';
4 | import type { ArrayNonEmpty } from '../array.types';
5 |
6 | describe('array types tests', () => {
7 | describe('assertArrayNonEmpty', () => {
8 | it('should return a type ArrayNonEmpty compatible with array', () => {
9 | const arr = [0];
10 | assertArrayNonEmpty(arr);
11 | expectTypeOf(arr).toBeArray();
12 | assertType(arr);
13 | });
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/barcode.guards.test.ts:
--------------------------------------------------------------------------------
1 | import { eansTestData } from '../../test/test.data';
2 | import { isEan13 } from '../barcode.guards';
3 |
4 | describe('Barcode guards tests', () => {
5 | describe('isEan13', () => {
6 | it('should return false when length !== 13', () => {
7 | expect(isEan13('123456789012')).toBe(false);
8 | expect(isEan13(null)).toBe(false);
9 | });
10 | it('should return true if length = 13 && checkdigit correct', () => {
11 | expect(isEan13(eansTestData.ean13)).toBe(true);
12 | });
13 | it('should return false when checkdigit is incorrect', () => {
14 | expect(isEan13('1234567890129')).toBe(false);
15 | });
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/barcode.types.test.ts:
--------------------------------------------------------------------------------
1 | import { assertType } from 'vitest';
2 |
3 | import { eansTestData } from '../../test/test.data';
4 | import { assertEan13 } from '../barcode.asserts';
5 | import type { Ean13 } from '../barcode.types';
6 |
7 | describe('barcode types tests', () => {
8 | describe('Ean13', () => {
9 | it('should return a type Ean13 compatible with string', () => {
10 | const ean13 = eansTestData.ean13;
11 | assertEan13(ean13);
12 | expectTypeOf(ean13).toBeString();
13 | assertType(ean13);
14 | });
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/network.guard.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | import { isNetworkPort } from '../network.guards';
4 |
5 | describe('Network typeguards tests', () => {
6 | describe('isNetworkPort', () => {
7 | it.each([
8 | [false, null],
9 | [false, undefined],
10 | [false, 128_000],
11 | [false, BigInt(10)],
12 | [false, new Date()],
13 | [true, 0],
14 | [true, 65_535],
15 | [true, 80],
16 | ])('should return %s when %s is given', (expected, v) => {
17 | expect(isNetworkPort(v)).toBe(expected);
18 | });
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/number.guard.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | import { isNumberSafeInt } from '../number.guards';
4 |
5 | describe('Number typeguards tests', () => {
6 | describe('isNumberSafeInt', () => {
7 | it.each([
8 | [false, []],
9 | [false, BigInt(10)],
10 | [false, 10n],
11 | [false, new Date()],
12 | [true, Number.MIN_SAFE_INTEGER],
13 | [true, Number.MAX_SAFE_INTEGER],
14 | [true, 10],
15 | ])('should return %s when %s is given', (expected, v) => {
16 | expect(isNumberSafeInt(v)).toBe(expected);
17 | });
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/object.assert.test.ts:
--------------------------------------------------------------------------------
1 | import { assertPlainObject } from '../object.asserts';
2 |
3 | describe('object assertions tests', () => {
4 | it('should not throw when value is valid', () => {
5 | expect(() => assertPlainObject({})).not.toThrow();
6 | });
7 | it('should throw when value is invalid', () => {
8 | expect(() => assertPlainObject(new Date())).toThrow(
9 | new TypeError('Value is expected to be a plain object, got: Date')
10 | );
11 | });
12 | it('should throw custom error when value is invalid', () => {
13 | const e = new Error('cool');
14 | expect(() => assertPlainObject('123', () => e)).toThrow(e);
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/uuid.helpers.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | import { isUuidVersion } from '../uuid.guards';
4 | import type { UuidVersion } from '../uuid.types';
5 |
6 | describe('Uuid typeguards tests', () => {
7 | describe('isUuidVersion', () => {
8 | it.each([
9 | [true, 1],
10 | [true, 3],
11 | [true, 4],
12 | [true, 5],
13 | [false, 6],
14 | [false, Number.NaN],
15 | [false, {}],
16 | ])(
17 | 'isUuidVersion should return %s when version is %s and value is %s',
18 | (expected, v) => {
19 | expect(isUuidVersion(v as UuidVersion | undefined)).toBe(expected);
20 | }
21 | );
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/uuid.types.test.ts:
--------------------------------------------------------------------------------
1 | import { assertType } from 'vitest';
2 |
3 | import { uuidsTestData } from '../../test/test.data';
4 | import { assertUuidV4 } from '../uuid.asserts';
5 | import type { UuidV4 } from '../uuid.types';
6 |
7 | describe('uuid types tests', () => {
8 | describe('Uuid', () => {
9 | it('should return a type Uuid compatible with string', () => {
10 | const v4 = uuidsTestData.v4;
11 | assertUuidV4(v4);
12 | expectTypeOf(v4).toBeString();
13 | assertType(v4);
14 | });
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/packages/assert/src/__tests__/uuid.utils.test.ts:
--------------------------------------------------------------------------------
1 | import { uuidsTestData } from '../../test/test.data';
2 | import { getUuidVersion } from '../uuid.helpers';
3 |
4 | describe('uuid utils tests', () => {
5 | describe('getUuidVersion', () => {
6 | it.each([
7 | [null, false as unknown as string],
8 | [null, new Date() as unknown as string],
9 | [1, uuidsTestData.v1],
10 | [3, uuidsTestData.v3],
11 | [4, uuidsTestData.v4],
12 | [5, uuidsTestData.v5],
13 | [7, uuidsTestData.v7],
14 | ])("should return %s when '%s' is given", (expected, value) => {
15 | expect(getUuidVersion(value)).toBe(expected);
16 | });
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/packages/assert/src/array.asserts.ts:
--------------------------------------------------------------------------------
1 | import { isArrayNonEmpty } from './array.guards';
2 | import type { ArrayNonEmpty } from './array.types';
3 | import { formatErrMsg } from './messages/errorMessages';
4 | import type { MsgOrErrorFactory } from './types/internal.types';
5 | import { createAssertException } from './utils/createAssertException';
6 | /**
7 | * Assert string is not empty (trims the string by default)
8 | * @throws TypeError
9 | */
10 | export function assertArrayNonEmpty(
11 | v: unknown,
12 | msgOrErrorFactory?: MsgOrErrorFactory
13 | ): asserts v is ArrayNonEmpty {
14 | if (!isArrayNonEmpty(v)) {
15 | throw createAssertException(
16 | msgOrErrorFactory,
17 | formatErrMsg('non-empty array', v)
18 | );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/assert/src/array.guards.ts:
--------------------------------------------------------------------------------
1 | import type { ArrayNonEmpty } from './array.types';
2 |
3 | export const isArrayNonEmpty = (
4 | v: unknown
5 | ): v is ArrayNonEmpty => {
6 | return Array.isArray(v) && v.length > 0;
7 | };
8 |
--------------------------------------------------------------------------------
/packages/assert/src/array.types.ts:
--------------------------------------------------------------------------------
1 | export type ArrayNonEmpty = [T, ...T[]];
2 |
--------------------------------------------------------------------------------
/packages/assert/src/barcode.asserts.ts:
--------------------------------------------------------------------------------
1 | import { isEan13 } from './barcode.guards';
2 | import type { Ean13 } from './barcode.types';
3 | import { formatErrMsg } from './messages/errorMessages';
4 | import type { MsgOrErrorFactory } from './types/internal.types';
5 | import { createAssertException } from './utils/createAssertException';
6 | /**
7 | * Assert string is not empty (trims the string by default)
8 | * @throws TypeError
9 | */
10 | export function assertEan13(
11 | v: unknown,
12 | msgOrErrorFactory?: MsgOrErrorFactory
13 | ): asserts v is Ean13 {
14 | if (!isEan13(v)) {
15 | throw createAssertException(msgOrErrorFactory, formatErrMsg('ean13', v));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/assert/src/barcode.guards.ts:
--------------------------------------------------------------------------------
1 | import type { Ean13 } from './barcode.types';
2 |
3 | export const isEan13 = (v: unknown): v is Ean13 => {
4 | if (typeof v !== 'string' || v.length !== 13) {
5 | return false;
6 | }
7 | const sum = v
8 | .slice(0, 12)
9 | .split('')
10 | .map((n, i) => Number(n) * (i % 2 ? 3 : 1))
11 | .reduce((sum, n) => sum + n, 0);
12 | return Math.ceil(sum / 10) * 10 - sum === Number(v[12]);
13 | };
14 |
--------------------------------------------------------------------------------
/packages/assert/src/barcode.types.ts:
--------------------------------------------------------------------------------
1 | import type { WeakOpaqueContainer } from './types/opaque.types';
2 |
3 | export type Ean13 = string & WeakOpaqueContainer<'Ean13'>;
4 |
--------------------------------------------------------------------------------
/packages/assert/src/http.consts.ts:
--------------------------------------------------------------------------------
1 | export const httpMethods = [
2 | 'GET',
3 | 'POST',
4 | 'HEAD',
5 | 'PUT',
6 | 'DELETE',
7 | 'CONNECT',
8 | 'OPTIONS',
9 | 'PATCH',
10 | 'TRACE',
11 | ] as const;
12 |
--------------------------------------------------------------------------------
/packages/assert/src/http.guards.ts:
--------------------------------------------------------------------------------
1 | import { httpMethods } from './http.consts';
2 | import type { HttpMethod } from './http.types';
3 |
4 | /**
5 | * Check whether the value is a valid http method (GET, PUT...) in
6 | * a case-insensitive manner.
7 | */
8 | export const isHttpValidMethod = (v: unknown): v is HttpMethod => {
9 | return (
10 | typeof v === 'string' &&
11 | (httpMethods as unknown as string[]).includes(v.toUpperCase())
12 | );
13 | };
14 |
15 | export const isHttpMethod = (
16 | method: T,
17 | v: unknown
18 | ): v is T => {
19 | return typeof v === 'string' && method === v.toUpperCase();
20 | };
21 |
--------------------------------------------------------------------------------
/packages/assert/src/http.types.ts:
--------------------------------------------------------------------------------
1 | export type HttpMethod =
2 | | 'GET'
3 | | 'POST'
4 | | 'HEAD'
5 | | 'PUT'
6 | | 'DELETE'
7 | | 'CONNECT'
8 | | 'OPTIONS'
9 | | 'PATCH'
10 | | 'TRACE';
11 |
--------------------------------------------------------------------------------
/packages/assert/src/messages/__tests__/getTypeInfo.test.ts:
--------------------------------------------------------------------------------
1 | import { getTypeInfo } from '../getTypeInfo';
2 |
3 | describe('getType tests', () => {
4 | it('should return', () => {
5 | expect(getTypeInfo(new Date())).toBe('Date');
6 | });
7 | });
8 |
--------------------------------------------------------------------------------
/packages/assert/src/messages/errorMessages.ts:
--------------------------------------------------------------------------------
1 | import { getTypeInfo } from './getTypeInfo';
2 |
3 | export const errPfx = 'Value is expected to be';
4 | const vowelsAndH = new Set(['a', 'e', 'i', 'o', 'u', 'y', 'h']);
5 | export const formatErrMsg = (
6 | msg: string,
7 | v: unknown,
8 | options?: {
9 | pfx: boolean;
10 | }
11 | ): string => {
12 | const { pfx = true } = options ?? {};
13 | const aOrAn = vowelsAndH.has((msg?.[0] ?? '').toLowerCase()) ? 'an' : 'a';
14 | return `${pfx ? `${errPfx} ${aOrAn} ` : ''}${msg}, got: ${getTypeInfo(v)}`;
15 | };
16 |
--------------------------------------------------------------------------------
/packages/assert/src/network.asserts.ts:
--------------------------------------------------------------------------------
1 | import { formatErrMsg } from './messages/errorMessages';
2 | import { isNetworkPort } from './network.guards';
3 | import type { NetworkPort } from './network.types';
4 | import type { MsgOrErrorFactory } from './types/internal.types';
5 | import { createAssertException } from './utils/createAssertException';
6 | /**
7 | * @throws TypeError
8 | */
9 | export function assertNetworkPort(
10 | v: unknown,
11 | msgOrErrorFactory?: MsgOrErrorFactory
12 | ): asserts v is NetworkPort {
13 | if (!isNetworkPort(v)) {
14 | throw createAssertException(
15 | msgOrErrorFactory,
16 | formatErrMsg('network port', v)
17 | );
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/assert/src/network.guards.ts:
--------------------------------------------------------------------------------
1 | import type { NetworkPort } from './network.types';
2 |
3 | export const isNetworkPort = (v: unknown): v is NetworkPort => {
4 | return typeof v === 'number' && v >= 0 && v <= 65_535;
5 | };
6 |
--------------------------------------------------------------------------------
/packages/assert/src/network.types.ts:
--------------------------------------------------------------------------------
1 | import type { WeakOpaqueContainer } from './types/opaque.types';
2 |
3 | export type NetworkPort = number & WeakOpaqueContainer<'NetworkPort'>;
4 |
--------------------------------------------------------------------------------
/packages/assert/src/number.asserts.ts:
--------------------------------------------------------------------------------
1 | import { formatErrMsg } from './messages/errorMessages';
2 | import { isNumberSafeInt } from './number.guards';
3 | import type { NumberSafeInt } from './number.types';
4 | import type { MsgOrErrorFactory } from './types/internal.types';
5 | import { createAssertException } from './utils/createAssertException';
6 | /**
7 | * Assert string is not empty (trims the string by default)
8 | * @throws TypeError
9 | */
10 | export function assertNumberSafeInt(
11 | v: unknown,
12 | msgOrErrorFactory?: MsgOrErrorFactory
13 | ): asserts v is NumberSafeInt {
14 | if (!isNumberSafeInt(v)) {
15 | throw createAssertException(
16 | msgOrErrorFactory,
17 | formatErrMsg('safe integer', v)
18 | );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/assert/src/number.guards.ts:
--------------------------------------------------------------------------------
1 | import type { NumberSafeInt } from './number.types';
2 |
3 | export const isNumberSafeInt = (v: unknown): v is NumberSafeInt => {
4 | return typeof v === 'number' && Number.isSafeInteger(v);
5 | };
6 |
--------------------------------------------------------------------------------
/packages/assert/src/number.types.ts:
--------------------------------------------------------------------------------
1 | import type { WeakOpaqueContainer } from './types/opaque.types';
2 |
3 | export type NumberSafeInt = number & WeakOpaqueContainer<'NumberSafeInt'>;
4 |
--------------------------------------------------------------------------------
/packages/assert/src/object.internal.types.ts:
--------------------------------------------------------------------------------
1 | import type { Simplify } from './types/internal.types';
2 |
3 | export type PlainObjectKey = string | number | symbol;
4 |
5 | export type BasePlainObject = Record;
6 |
7 | export interface DefaultBasePlainObject extends BasePlainObject {
8 | readonly __tag: 'default-plain-object';
9 | }
10 |
11 | export type PlainObjectDeepPartialUnknown = {
12 | [P in keyof T]?: NonNullable extends BasePlainObject
13 | ? Simplify>>
14 | : unknown;
15 | };
16 |
--------------------------------------------------------------------------------
/packages/assert/src/object.types.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | BasePlainObject,
3 | DefaultBasePlainObject,
4 | PlainObjectDeepPartialUnknown,
5 | PlainObjectKey,
6 | } from './object.internal.types';
7 | import type { Simplify } from './types/internal.types';
8 |
9 | export type PlainObject<
10 | TValue extends BasePlainObject = DefaultBasePlainObject,
11 | > = TValue extends DefaultBasePlainObject
12 | ? Record
13 | : Simplify>;
14 |
--------------------------------------------------------------------------------
/packages/assert/src/string.types.ts:
--------------------------------------------------------------------------------
1 | import type { WeakOpaqueContainer } from './types/opaque.types';
2 |
3 | export type StringNonEmpty = string & WeakOpaqueContainer<'StringNonEmpty'>;
4 | export type ParsableSafeInt = string & WeakOpaqueContainer<'ParsableSafeInt'>;
5 | export type ParsableStrictIsoDateZ = string &
6 | WeakOpaqueContainer<'ParsableStrictIsoDateZ'>;
7 |
--------------------------------------------------------------------------------
/packages/assert/src/string.utils.ts:
--------------------------------------------------------------------------------
1 | export const isoDateTimeZRegexp =
2 | // eslint-disable-next-line unicorn/better-regex
3 | /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/i;
4 |
--------------------------------------------------------------------------------
/packages/assert/src/types.asserts.ts:
--------------------------------------------------------------------------------
1 | import { formatErrMsg } from './messages/errorMessages';
2 | import type { MsgOrErrorFactory } from './types/internal.types';
3 | import { createAssertException } from './utils/createAssertException';
4 |
5 | /**
6 | * @throws TypeError
7 | */
8 | export function assertNever(
9 | v: never,
10 | msgOrErrorFactory?: MsgOrErrorFactory
11 | ): never {
12 | throw createAssertException(
13 | msgOrErrorFactory,
14 | formatErrMsg('A value is not expected (assertNever)', v, {
15 | pfx: false,
16 | })
17 | );
18 | }
19 |
20 | /**
21 | * A slight variation of assertNever that doesn't throw in runtime and
22 | * will return the value. Typechecks are still enforced.
23 | */
24 | export function assertNeverNoThrow(v: never): never {
25 | return v;
26 | }
27 |
--------------------------------------------------------------------------------
/packages/assert/src/types/internal.types.ts:
--------------------------------------------------------------------------------
1 | export type MsgOrErrorFactory = string | (() => Error);
2 |
3 | /**
4 | * @credits https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
5 | */
6 | export type Simplify = {
7 | [KeyType in keyof T]: T[KeyType];
8 | // eslint-disable-next-line sonarjs/no-useless-intersection
9 | } & NonNullable;
10 |
--------------------------------------------------------------------------------
/packages/assert/src/types/opaque.types.ts:
--------------------------------------------------------------------------------
1 | declare const tag: unique symbol;
2 |
3 | export type WeakOpaqueContainer = {
4 | readonly [tag]: Token;
5 | };
6 |
--------------------------------------------------------------------------------
/packages/assert/src/utils/createAssertException.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @throws TypeError
3 | */
4 | export const createAssertException = (
5 | msgOrErrorFactory?: string | (() => Error),
6 | fallbackMsg?: string
7 | ): TypeError | Error => {
8 | if (
9 | typeof msgOrErrorFactory === 'string' ||
10 | msgOrErrorFactory === undefined
11 | ) {
12 | throw new TypeError(
13 | msgOrErrorFactory ?? fallbackMsg ?? 'Assertion did not pass.'
14 | );
15 | }
16 | throw msgOrErrorFactory();
17 | };
18 |
--------------------------------------------------------------------------------
/packages/assert/src/uuid.helpers.ts:
--------------------------------------------------------------------------------
1 | import type { UuidVersion } from './uuid.types';
2 | import { uuidSupportedVersions } from './uuid.utils';
3 |
4 | /**
5 | * Adapted from https://github.com/uuidjs/uuid/blob/main/src/version.js
6 | */
7 | export const getUuidVersion = (uuid: string): UuidVersion | null => {
8 | if (typeof uuid !== 'string') {
9 | return null;
10 | }
11 | const v = Number.parseInt(uuid.slice(14, 15), 16);
12 | if (uuidSupportedVersions.has(v)) {
13 | return v as UuidVersion;
14 | }
15 | return null;
16 | };
17 |
--------------------------------------------------------------------------------
/packages/assert/src/uuid.types.ts:
--------------------------------------------------------------------------------
1 | import type { WeakOpaqueContainer } from './types/opaque.types';
2 |
3 | export type Uuid = string & WeakOpaqueContainer<'Uuid'>;
4 |
5 | export type UuidV1 = string & WeakOpaqueContainer<'UuidV1'>;
6 | export type UuidV3 = string & WeakOpaqueContainer<'UuidV3'>;
7 | export type UuidV4 = string & WeakOpaqueContainer<'UuidV4'>;
8 | export type UuidV5 = string & WeakOpaqueContainer<'UuidV5'>;
9 | export type UuidV7 = string & WeakOpaqueContainer<'UuidV7'>;
10 |
11 | export type UuidVersion = 1 | 3 | 4 | 5 | 7;
12 | export type UuidVersionOrNumber = number &
13 | WeakOpaqueContainer<'UuidVersionOrNumber'>;
14 |
--------------------------------------------------------------------------------
/packages/assert/src/uuid.utils.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Taken from https://github.com/uuidjs/uuid/blob/main/src/regex.js
3 | */
4 | export const uuidRegexp =
5 | // eslint-disable-next-line sonarjs/regex-complexity
6 | /^(?:[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}|0{8}-(?:0{4}-){3}0{12})$/i;
7 |
8 | export const uuidSupportedVersions = new Set([1, 3, 4, 5, 7]);
9 |
--------------------------------------------------------------------------------
/packages/assert/test/test.data.ts:
--------------------------------------------------------------------------------
1 | export const uuidsTestData = {
2 | v1: 'd9428888-122b-11e1-b85c-61cd3cbb3210',
3 | v3: 'a981a0c2-68b1-35dc-bcfc-296e52ab01ec',
4 | v4: '109156be-c4fb-41ea-b1b4-efe1671c5836',
5 | v5: '90123e1c-7512-523e-bb28-76fab9f2f73d',
6 | v7: '018e9db4-6f75-7860-96fe-c3b9ac786b5e',
7 | };
8 |
9 | export const eansTestData = {
10 | ean13: '1234567890128',
11 | };
12 |
--------------------------------------------------------------------------------
/packages/assert/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/assert/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {},
11 | "types": ["vitest/globals"]
12 | },
13 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
14 | "include": [
15 | ".eslintrc.*",
16 | "**/*.ts",
17 | "**/*.tsx",
18 | "**/*.js",
19 | "**/*.jsx",
20 | "**/*.cjs",
21 | "**/*.mjs",
22 | "**/*.json"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/packages/assert/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/*.ts"],
3 | "out": "./docs/api/assert",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": false,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/compress/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/compress/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/compress/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/compress/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'Only { Compressor } (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '{ Compressor }',
8 | limit: '564B',
9 | },
10 | {
11 | name: 'Only { Decompressor } (ESM)',
12 | path: ['dist/index.mjs'],
13 | import: '{ Decompressor }',
14 | limit: '500B',
15 | },
16 | {
17 | name: '{ Decompressor, Compressor } (ESM)',
18 | path: ['dist/index.mjs'],
19 | import: '{ Decompressor, Compressor }',
20 | limit: '670B',
21 | },
22 | ] satisfies SizeLimitConfig;
23 |
--------------------------------------------------------------------------------
/packages/compress/bench/README.md:
--------------------------------------------------------------------------------
1 | ## @httpx/compress
2 |
3 | Benchmarks for [@httpx/compress](../README.md)
4 |
5 | ### Run
6 |
7 | ```bash
8 | yarn install
9 | cd packages/compress
10 | yarn build
11 | yarn bench
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/packages/compress/bench/bench-config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | import { Compressor, Decompressor } from '../src';
4 |
5 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
6 |
7 | export const benchConfig = {
8 | gzipCompressor: new Compressor('gzip'),
9 | deflateCompressor: new Compressor('deflate'),
10 | gzipDecompressor: new Decompressor('gzip'),
11 | deflateDecompressor: new Decompressor('deflate'),
12 | longString: `😊-abcdef-éàù-012345`.repeat(isCiOrCodSpeed ? 500 : 500_000),
13 | benchOptions: {
14 | iterations: isCiOrCodSpeed ? 2 : 4,
15 | },
16 | } as const;
17 |
--------------------------------------------------------------------------------
/packages/compress/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/compress v0.2.1**
2 |
3 | ***
4 |
5 | # @httpx/compress v0.2.1
6 |
7 | ## Classes
8 |
9 | - [Compressor](classes/Compressor.md)
10 | - [Decompressor](classes/Decompressor.md)
11 |
--------------------------------------------------------------------------------
/packages/compress/src/compression-algorithm.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Supported encodings for compression/decompression.
3 | *
4 | * Only 'gzip' and 'deflate' are supported by the Compression Streams API.
5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API
6 | */
7 | export type SupportedCompressionAlgorithm = 'gzip' | 'deflate';
8 |
--------------------------------------------------------------------------------
/packages/compress/src/global-cache.ts:
--------------------------------------------------------------------------------
1 | export const globalCache = {
2 | utf8TextDecoder: new globalThis.TextDecoder(),
3 | utf8TextEncoder: new globalThis.TextEncoder(),
4 | } as const;
5 |
--------------------------------------------------------------------------------
/packages/compress/src/index.ts:
--------------------------------------------------------------------------------
1 | export { Compressor } from './compressor';
2 | export { Decompressor } from './decompressor';
3 |
--------------------------------------------------------------------------------
/packages/compress/src/string-encodings.ts:
--------------------------------------------------------------------------------
1 | export type SupportedStringEncodings = 'base64' | 'base64_urlsafe';
2 | export const supportedStringEncodings = [
3 | 'base64',
4 | 'base64_urlsafe',
5 | ] as const satisfies SupportedStringEncodings[];
6 |
7 | export type EncodeStringOptions = {
8 | encoding?: SupportedStringEncodings;
9 | };
10 |
--------------------------------------------------------------------------------
/packages/compress/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/compress/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {},
11 | "types": ["vitest/globals"]
12 | },
13 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
14 | "include": [
15 | ".eslintrc.*",
16 | "**/*.ts",
17 | "**/*.tsx",
18 | "**/*.js",
19 | "**/*.jsx",
20 | "**/*.cjs",
21 | "**/*.mjs",
22 | "**/*.json"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/packages/compress/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/compress",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/dsn-parser/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Supported browsers
2 | defaults
3 | chrome >= 96
4 | firefox >= 105
5 | edge >= 113
6 | safari >= 15
7 | ios >= 15
8 | opera >= 103
9 | not dead
--------------------------------------------------------------------------------
/packages/dsn-parser/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/dsn-parser/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/dsn-parser/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'Everything (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '*',
8 | limit: '1.15KB',
9 | },
10 | {
11 | name: 'Only parseDsn (ESM)',
12 | path: ['dist/index.mjs'],
13 | import: '{ parseDsn }',
14 | limit: '785B',
15 | },
16 | {
17 | name: 'Everything (CJS)',
18 | import: '*',
19 | path: ['dist/index.cjs'],
20 | limit: '1.40KB',
21 | },
22 | ] satisfies SizeLimitConfig;
23 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/dsn-parser v1.8.6**
2 |
3 | ***
4 |
5 | # @httpx/dsn-parser v1.8.6
6 |
7 | ## Type Aliases
8 |
9 | - [ParsableDsn](type-aliases/ParsableDsn.md)
10 | - [ParsedDsn](type-aliases/ParsedDsn.md)
11 | - [ParseDsnOptions](type-aliases/ParseDsnOptions.md)
12 |
13 | ## Functions
14 |
15 | - [assertParsableDsn](functions/assertParsableDsn.md)
16 | - [convertJdbcToDsn](functions/convertJdbcToDsn.md)
17 | - [isParsableDsn](functions/isParsableDsn.md)
18 | - [parseDsn](functions/parseDsn.md)
19 | - [parseDsnOrThrow](functions/parseDsnOrThrow.md)
20 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/functions/assertParsableDsn.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / assertParsableDsn
6 |
7 | # Function: assertParsableDsn()
8 |
9 | > **assertParsableDsn**(`dsn`, `msg?`): `asserts dsn is ParsableDsn`
10 |
11 | ## Parameters
12 |
13 | ### dsn
14 |
15 | `unknown`
16 |
17 | ### msg?
18 |
19 | `string`
20 |
21 | ## Returns
22 |
23 | `asserts dsn is ParsableDsn`
24 |
25 | ## Throws
26 |
27 | Error when not parsable
28 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/functions/convertJdbcToDsn.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / convertJdbcToDsn
6 |
7 | # Function: convertJdbcToDsn()
8 |
9 | > **convertJdbcToDsn**(`jdbc`): `string`
10 |
11 | ## Parameters
12 |
13 | ### jdbc
14 |
15 | `string`
16 |
17 | ## Returns
18 |
19 | `string`
20 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/functions/isParsableDsn.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / isParsableDsn
6 |
7 | # Function: isParsableDsn()
8 |
9 | > **isParsableDsn**(`dsn`): `dsn is ParsableDsn`
10 |
11 | ## Parameters
12 |
13 | ### dsn
14 |
15 | `unknown`
16 |
17 | ## Returns
18 |
19 | `dsn is ParsableDsn`
20 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/functions/parseDsn.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / parseDsn
6 |
7 | # Function: parseDsn()
8 |
9 | > **parseDsn**(`dsn`, `options?`): `ParserResult`
10 |
11 | ## Parameters
12 |
13 | ### dsn
14 |
15 | `unknown`
16 |
17 | ### options?
18 |
19 | [`ParseDsnOptions`](../type-aliases/ParseDsnOptions.md)
20 |
21 | ## Returns
22 |
23 | `ParserResult`
24 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/functions/parseDsnOrThrow.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / parseDsnOrThrow
6 |
7 | # Function: parseDsnOrThrow()
8 |
9 | > **parseDsnOrThrow**(`dsn`, `options?`): [`ParsedDsn`](../type-aliases/ParsedDsn.md)
10 |
11 | ## Parameters
12 |
13 | ### dsn
14 |
15 | `unknown`
16 |
17 | ### options?
18 |
19 | [`ParseDsnOptions`](../type-aliases/ParseDsnOptions.md) & `object`
20 |
21 | ## Returns
22 |
23 | [`ParsedDsn`](../type-aliases/ParsedDsn.md)
24 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/type-aliases/ParsableDsn.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / ParsableDsn
6 |
7 | # Type Alias: ParsableDsn
8 |
9 | > **ParsableDsn** = `string` & `WeakOpaqueContainer`\<`"ParsableDsn"`\>
10 |
--------------------------------------------------------------------------------
/packages/dsn-parser/docs/api/type-aliases/ParseDsnOptions.md:
--------------------------------------------------------------------------------
1 | [**@httpx/dsn-parser v1.8.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/dsn-parser](../README.md) / ParseDsnOptions
6 |
7 | # Type Alias: ParseDsnOptions
8 |
9 | > **ParseDsnOptions** = `object`
10 |
11 | ## Properties
12 |
13 | ### lowercaseDriver?
14 |
15 | > `optional` **lowercaseDriver**: `boolean`
16 |
17 | Whether to lowercase parsed driver name, default: false
18 |
19 | ***
20 |
21 | ### overrides?
22 |
23 | > `optional` **overrides**: `Omit`\<`Partial`\<[`ParsedDsn`](ParsedDsn.md)\>, `"params"`\>
24 |
25 | Overrides parsed values by those one (except query params)
26 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/__tests__/assert-parsable-dsn.test.ts:
--------------------------------------------------------------------------------
1 | import { assertParsableDsn } from '../assert-parsable-dsn';
2 |
3 | describe('assertParsableDsn', () => {
4 | it.each([
5 | 'redis://localhost',
6 | 'mysql://localhost',
7 | 'postgresql://localhost:35045',
8 | ])('should assert valid dsn', (dsn) => {
9 | expect(assertParsableDsn(dsn)).toBeUndefined();
10 | });
11 | it("should throw when dsn can't be parsed", () => {
12 | expect(() => assertParsableDsn('redis:/')).toThrow(
13 | 'Cannot parse DSN (PARSE_ERROR)'
14 | );
15 | });
16 | it('should throw custom message', () => {
17 | expect(() => assertParsableDsn('redis:/', 'message')).toThrow('message');
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/__tests__/is-parsable-dsn.test.ts:
--------------------------------------------------------------------------------
1 | import { isParsableDsn } from '../is-parsable-dsn';
2 |
3 | describe('isParsableDsn', () => {
4 | it.each([
5 | 'redis://localhost',
6 | 'mysql://localhost',
7 | 'postgresql://localhost:35045',
8 | ])('should assert valid dsn', (dsn) => {
9 | expect(isParsableDsn(dsn)).toBe(true);
10 | });
11 | it("should throw when dsn can't be parsed", () => {
12 | expect(isParsableDsn('redis:/')).toBe(false);
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/assert-parsable-dsn.ts:
--------------------------------------------------------------------------------
1 | import type { ParsableDsn } from './dsn-parser.type';
2 | import { parseDsn } from './parse-dsn';
3 |
4 | /**
5 | * @throws Error when not parsable
6 | */
7 | export const assertParsableDsn = (
8 | dsn: unknown,
9 | msg?: string
10 | ): asserts dsn is ParsableDsn => {
11 | const parsed = parseDsn(dsn as string);
12 | if (!parsed.success) {
13 | throw new Error(msg ?? `${parsed.message} (${parsed.reason})`);
14 | }
15 | };
16 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/convert-jdbc-to-dsn.ts:
--------------------------------------------------------------------------------
1 | export const convertJdbcToDsn = (jdbc: string): string => {
2 | const [part1, ...rest] = jdbc.split(';');
3 | return [part1, rest ? rest.join('&') : undefined].filter(Boolean).join('?');
4 | };
5 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/index.ts:
--------------------------------------------------------------------------------
1 | export { assertParsableDsn } from './assert-parsable-dsn';
2 | export { convertJdbcToDsn } from './convert-jdbc-to-dsn';
3 | export type {
4 | ParsableDsn,
5 | ParsedDsn,
6 | ParseDsnOptions,
7 | } from './dsn-parser.type';
8 | export { isParsableDsn } from './is-parsable-dsn';
9 | export { parseDsn } from './parse-dsn';
10 | export { parseDsnOrThrow } from './parse-dsn-or-throw';
11 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/is-parsable-dsn.ts:
--------------------------------------------------------------------------------
1 | import type { ParsableDsn } from './dsn-parser.type';
2 | import { parseDsn } from './parse-dsn';
3 |
4 | export const isParsableDsn = (dsn: unknown): dsn is ParsableDsn => {
5 | return parseDsn(dsn as string).success;
6 | };
7 |
--------------------------------------------------------------------------------
/packages/dsn-parser/src/parse-dsn-or-throw.ts:
--------------------------------------------------------------------------------
1 | import type { ParsedDsn, ParseDsnOptions } from './dsn-parser.type';
2 | import { parseDsn } from './parse-dsn';
3 |
4 | export const parseDsnOrThrow = (
5 | dsn: unknown,
6 | options?: ParseDsnOptions & {
7 | errorMsgPrefix?: string;
8 | }
9 | ): ParsedDsn => {
10 | const parsedOrError = parseDsn(dsn, options);
11 | if (parsedOrError.success) {
12 | return parsedOrError.value;
13 | }
14 | const pfx = options?.errorMsgPrefix ?? `Can't parse dsn`;
15 | throw new Error(`${pfx}: ${parsedOrError.message} (${parsedOrError.reason})`);
16 | };
17 |
--------------------------------------------------------------------------------
/packages/dsn-parser/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/dsn-parser/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {},
11 | "types": ["vitest/globals"]
12 | },
13 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
14 | "include": [
15 | ".eslintrc.*",
16 | "**/*.ts",
17 | "**/*.tsx",
18 | "**/*.js",
19 | "**/*.jsx",
20 | "**/*.cjs",
21 | "**/*.mjs",
22 | "**/*.json"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/packages/dsn-parser/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/dsn-parser",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/encode/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/encode/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/encode/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/encode/bench/README.md:
--------------------------------------------------------------------------------
1 | ## @httpx/encode
2 |
3 | Benchmarks for [@httpx/encode](../README.md)
4 |
5 | ### Run
6 |
7 | ```bash
8 | yarn install
9 | cd packages/encode
10 | yarn build
11 | yarn bench
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/packages/encode/bench/bench-config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
3 | export const benchConfig = {
4 | longString: `😊-abcdef-éàù-012345a Ā 文 🦄`.repeat(isCiOrCodSpeed ? 50 : 400),
5 | benchOptions: {
6 | iterations: isCiOrCodSpeed ? 2 : 10,
7 | },
8 | } as const;
9 |
--------------------------------------------------------------------------------
/packages/encode/src/base64/base64.nodejs.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import-x/no-nodejs-modules,no-restricted-imports,unicorn/prefer-node-protocol
2 | // import { Buffer } from 'node:buffer';
3 |
4 | import type { Base64Encoder } from './base64.types';
5 |
6 | export const Base64NodeJs = {
7 | encode: (input: string): string =>
8 | // eslint-disable-next-line no-restricted-globals
9 | Buffer.from(input, 'utf8').toString('base64'),
10 |
11 | decode: (input: string): string => {
12 | // eslint-disable-next-line no-restricted-globals
13 | return Buffer.from(input, 'base64').toString('utf8');
14 | },
15 | } as const satisfies Base64Encoder;
16 |
--------------------------------------------------------------------------------
/packages/encode/src/base64/base64.types.ts:
--------------------------------------------------------------------------------
1 | export interface Base64Encoder {
2 | encode: (input: string) => string;
3 | decode: (input: string) => string;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/encode/src/cache/global-cache.ts:
--------------------------------------------------------------------------------
1 | export const globalCache = {
2 | utf8TextDecoder: new globalThis.TextDecoder(),
3 | utf8TextEncoder: new globalThis.TextEncoder(),
4 | } as const;
5 |
--------------------------------------------------------------------------------
/packages/encode/src/index.browser.ts:
--------------------------------------------------------------------------------
1 | export { Base64Browser as Base64 } from './base64/base64.browser';
2 |
--------------------------------------------------------------------------------
/packages/encode/src/index.nodejs.ts:
--------------------------------------------------------------------------------
1 | export { Base64NodeJs as Base64 } from './base64/base64.nodejs';
2 |
--------------------------------------------------------------------------------
/packages/encode/src/index.purejs.ts:
--------------------------------------------------------------------------------
1 | export { Base64Purejs as Base64 } from './base64/base64.purejs';
2 |
--------------------------------------------------------------------------------
/packages/encode/src/index.ts:
--------------------------------------------------------------------------------
1 | import type { Base64Encoder } from './base64/base64.types';
2 |
3 | let b64: Base64Encoder = null as unknown as Base64Encoder;
4 |
5 | try {
6 | if (globalThis.atob !== undefined) {
7 | b64 = await import('./base64/base64.browser.js').then(
8 | (mod) => mod.Base64Browser
9 | );
10 | } else if (globalThis.Buffer === undefined) {
11 | b64 = await import('./base64/base64.nodejs.js').then(
12 | (mod) => mod.Base64NodeJs
13 | );
14 | }
15 | } catch {
16 | b64 = await import('./base64/base64.purejs.js').then(
17 | (mod) => mod.Base64Purejs
18 | );
19 | }
20 |
21 | export const Base64 = b64;
22 |
--------------------------------------------------------------------------------
/packages/encode/test/data/encoding-test.data.ts:
--------------------------------------------------------------------------------
1 | const data = {
2 | asciiString: 'Hello, world!',
3 | japaneseString: 'こんにちは世界',
4 | frenchString: 'Bonjour le monde ! Éàèçêëîïôûù',
5 | germanString: 'Hallo Welt! ÄÖÜäöüß',
6 | emojiString: '🌸😊🚀🔥💧🌍🌟🎉🍕🎶❤️😂👍',
7 | urlUnsafeString: "?=:@&$+!#'()~*%/;:<>\\",
8 | };
9 |
10 | export const getEncodingTestData = (): string => {
11 | return [
12 | data.asciiString,
13 | data.frenchString,
14 | data.germanString,
15 | data.emojiString,
16 | data.japaneseString,
17 | data.urlUnsafeString,
18 | ].join('');
19 | };
20 |
--------------------------------------------------------------------------------
/packages/encode/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "verbatimModuleSyntax": false,
12 | "allowImportingTsExtensions": true,
13 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
14 | },
15 | "include": ["src"],
16 | "exclude": ["*.test.ts"]
17 | }
18 |
--------------------------------------------------------------------------------
/packages/encode/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "resolveJsonModule": true,
10 | "strict": true,
11 | "paths": {},
12 | "types": ["vitest/globals"]
13 | },
14 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
15 | "include": [
16 | ".eslintrc.*",
17 | "**/*.ts",
18 | "**/*.tsx",
19 | "**/*.js",
20 | "**/*.jsx",
21 | "**/*.cjs",
22 | "**/*.mjs",
23 | "**/*.json"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/packages/encode/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/compress",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/exception/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Supported browsers
2 | defaults
3 | chrome >= 96
4 | firefox >= 105
5 | edge >= 113
6 | safari >= 15
7 | ios >= 15
8 | opera >= 103
9 | not dead
10 |
--------------------------------------------------------------------------------
/packages/exception/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # build
4 | /dist
5 |
6 | # dependencies
7 | node_modules
8 |
9 | # testing
10 | /coverage
11 |
12 | # misc
13 | .DS_Store
14 | *.pem
15 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/exception**
2 |
3 | ***
4 |
5 | # @httpx/exception
6 |
7 | ## Modules
8 |
9 | - [base](base/README.md)
10 | - [client](client/README.md)
11 | - [experimental](experimental/README.md)
12 | - [serializer](serializer/README.md)
13 | - [server](server/README.md)
14 | - [types](types/README.md)
15 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/base/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../README.md) / base
6 |
7 | # base
8 |
9 | ## Classes
10 |
11 | - [HttpClientException](classes/HttpClientException.md)
12 | - [HttpException](classes/HttpException.md)
13 | - [HttpServerException](classes/HttpServerException.md)
14 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/experimental/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../README.md) / experimental
6 |
7 | # experimental
8 |
9 | ## Functions
10 |
11 | - [tryOrFail](functions/tryOrFail.md)
12 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/experimental/functions/tryOrFail.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [experimental](../README.md) / tryOrFail
6 |
7 | # Function: tryOrFail()
8 |
9 | > **tryOrFail**\<`T`\>(`fn`): `Promise`\<`ReturnType`\<`T`\>\>
10 |
11 | ## Type Parameters
12 |
13 | ### T
14 |
15 | `T` *extends* `AsyncFn`\<`unknown`[], `unknown`\>
16 |
17 | ## Parameters
18 |
19 | ### fn
20 |
21 | `T`
22 |
23 | ## Returns
24 |
25 | `Promise`\<`ReturnType`\<`T`\>\>
26 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../README.md) / serializer
6 |
7 | # serializer
8 |
9 | ## Classes
10 |
11 | - [SerializerError](classes/SerializerError.md)
12 |
13 | ## Type Aliases
14 |
15 | - [NativeError](type-aliases/NativeError.md)
16 | - [SerializableError](type-aliases/SerializableError.md)
17 | - [SerializableHttpException](type-aliases/SerializableHttpException.md)
18 | - [SerializableNonNativeError](type-aliases/SerializableNonNativeError.md)
19 |
20 | ## Functions
21 |
22 | - [convertToSerializable](functions/convertToSerializable.md)
23 | - [createFromSerializable](functions/createFromSerializable.md)
24 | - [fromJson](functions/fromJson.md)
25 | - [toJson](functions/toJson.md)
26 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/functions/convertToSerializable.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / convertToSerializable
6 |
7 | # Function: convertToSerializable()
8 |
9 | > **convertToSerializable**(`e`, `params?`): `Serializable`
10 |
11 | Convert an Error, NativeError or any HttpException to
12 | an object suitable for serialization (a serializable version).
13 |
14 | ## Parameters
15 |
16 | ### e
17 |
18 | [`HttpException`](../../base/classes/HttpException.md) | [`NativeError`](../type-aliases/NativeError.md)
19 |
20 | ### params?
21 |
22 | `SerializerParams`
23 |
24 | ## Returns
25 |
26 | `Serializable`
27 |
28 | ## Link
29 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/functions/createFromSerializable.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / createFromSerializable
6 |
7 | # Function: createFromSerializable()
8 |
9 | > **createFromSerializable**(`payload`, `params?`): [`HttpException`](../../base/classes/HttpException.md) \| [`NativeError`](../type-aliases/NativeError.md)
10 |
11 | create an Error, NativeError or any HttpException from a
12 | serializable representation
13 |
14 | ## Parameters
15 |
16 | ### payload
17 |
18 | `Serializable`
19 |
20 | ### params?
21 |
22 | `SerializerParams`
23 |
24 | ## Returns
25 |
26 | [`HttpException`](../../base/classes/HttpException.md) \| [`NativeError`](../type-aliases/NativeError.md)
27 |
28 | ## Link
29 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/functions/fromJson.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / fromJson
6 |
7 | # Function: fromJson()
8 |
9 | > **fromJson**(`json`, `params?`): `Error` \| [`HttpException`](../../base/classes/HttpException.md) \| [`SerializerError`](../classes/SerializerError.md)
10 |
11 | ## Parameters
12 |
13 | ### json
14 |
15 | `string`
16 |
17 | ### params?
18 |
19 | `SerializerParams`
20 |
21 | ## Returns
22 |
23 | `Error` \| [`HttpException`](../../base/classes/HttpException.md) \| [`SerializerError`](../classes/SerializerError.md)
24 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/functions/toJson.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / toJson
6 |
7 | # Function: toJson()
8 |
9 | > **toJson**(`exception`, `params?`): `string`
10 |
11 | ## Parameters
12 |
13 | ### exception
14 |
15 | [`HttpException`](../../base/classes/HttpException.md) | [`NativeError`](../type-aliases/NativeError.md)
16 |
17 | ### params?
18 |
19 | `SerializerParams`
20 |
21 | ## Returns
22 |
23 | `string`
24 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/type-aliases/NativeError.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / NativeError
6 |
7 | # Type Alias: NativeError
8 |
9 | > **NativeError** = `Error` \| `EvalError` \| `RangeError` \| `ReferenceError` \| `SyntaxError` \| `TypeError` \| `URIError`
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/type-aliases/SerializableError.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / SerializableError
6 |
7 | # Type Alias: SerializableError
8 |
9 | > **SerializableError** = `DiscriminateSerializable`\<`"NativeError"`\>
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/type-aliases/SerializableHttpException.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / SerializableHttpException
6 |
7 | # Type Alias: SerializableHttpException
8 |
9 | > **SerializableHttpException** = `DiscriminateSerializable`\<`"HttpException"`\>
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/serializer/type-aliases/SerializableNonNativeError.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [serializer](../README.md) / SerializableNonNativeError
6 |
7 | # Type Alias: SerializableNonNativeError
8 |
9 | > **SerializableNonNativeError** = `DiscriminateSerializable`\<`"NonNativeError"`\>
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/types/README.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../README.md) / types
6 |
7 | # types
8 |
9 | ## Interfaces
10 |
11 | - [ErrorWithErrorStatusCode](interfaces/ErrorWithErrorStatusCode.md)
12 | - [ObjectWithErrorStatusCode](interfaces/ObjectWithErrorStatusCode.md)
13 |
14 | ## Type Aliases
15 |
16 | - [HttpErrorStatusCode](type-aliases/HttpErrorStatusCode.md)
17 | - [HttpErrorStatusCodeOrNumber](type-aliases/HttpErrorStatusCodeOrNumber.md)
18 | - [HttpExceptionParams](type-aliases/HttpExceptionParams.md)
19 | - [HttpExceptionParamsWithStatus](type-aliases/HttpExceptionParamsWithStatus.md)
20 | - [HttpValidationIssue](type-aliases/HttpValidationIssue.md)
21 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/types/interfaces/ObjectWithErrorStatusCode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [types](../README.md) / ObjectWithErrorStatusCode
6 |
7 | # Interface: ObjectWithErrorStatusCode
8 |
9 | Object or PlainObject with a indicative statusCode field [4xx,5xx]
10 |
11 | ## Properties
12 |
13 | ### statusCode
14 |
15 | > **statusCode**: [`HttpErrorStatusCodeOrNumber`](../type-aliases/HttpErrorStatusCodeOrNumber.md)
16 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/types/type-aliases/HttpErrorStatusCode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [types](../README.md) / HttpErrorStatusCode
6 |
7 | # Type Alias: HttpErrorStatusCode
8 |
9 | > **HttpErrorStatusCode** = keyof *typeof* `statusMap`
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/types/type-aliases/HttpErrorStatusCodeOrNumber.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [types](../README.md) / HttpErrorStatusCodeOrNumber
6 |
7 | # Type Alias: HttpErrorStatusCodeOrNumber
8 |
9 | > **HttpErrorStatusCodeOrNumber** = [`HttpErrorStatusCode`](HttpErrorStatusCode.md) \| `number` & `object`
10 |
--------------------------------------------------------------------------------
/packages/exception/docs/api/types/type-aliases/HttpExceptionParamsWithStatus.md:
--------------------------------------------------------------------------------
1 | [**@httpx/exception**](../../README.md)
2 |
3 | ***
4 |
5 | [@httpx/exception](../../README.md) / [types](../README.md) / HttpExceptionParamsWithStatus
6 |
7 | # Type Alias: HttpExceptionParamsWithStatus
8 |
9 | > **HttpExceptionParamsWithStatus** = [`HttpExceptionParams`](HttpExceptionParams.md) & `object`
10 |
11 | ## Type declaration
12 |
13 | ### statusCode
14 |
15 | > **statusCode**: [`HttpErrorStatusCode`](HttpErrorStatusCode.md)
16 |
--------------------------------------------------------------------------------
/packages/exception/src/base/index.ts:
--------------------------------------------------------------------------------
1 | export { HttpClientException } from './HttpClientException';
2 | export { HttpException } from './HttpException';
3 | export { HttpServerException } from './HttpServerException';
4 |
--------------------------------------------------------------------------------
/packages/exception/src/experimental/index.ts:
--------------------------------------------------------------------------------
1 | export { tryOrFail } from './tryOrFail';
2 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/error/SerializerError.ts:
--------------------------------------------------------------------------------
1 | import { supportsErrorCause } from '../../support/supportsErrorCause';
2 |
3 | export class SerializerError extends Error {
4 | constructor(
5 | message: string,
6 | params?: {
7 | cause?: Error | undefined;
8 | }
9 | ) {
10 | const { cause } = params ?? {};
11 | super(message);
12 | if (supportsErrorCause() && cause instanceof Error) {
13 | this.cause = cause;
14 | }
15 | Object.setPrototypeOf(this, SerializerError.prototype);
16 | this.name = 'SerializerError';
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/index.ts:
--------------------------------------------------------------------------------
1 | export { SerializerError } from './error/SerializerError';
2 | export { fromJson } from './json/fromJson';
3 | export { toJson } from './json/toJson';
4 | export { convertToSerializable, createFromSerializable } from './mapper';
5 | export type {
6 | NativeError,
7 | SerializableError,
8 | SerializableHttpException,
9 | SerializableNonNativeError,
10 | } from './types';
11 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/json/fromJson.ts:
--------------------------------------------------------------------------------
1 | import type { HttpException } from '../../base';
2 | import { SerializerError } from '../error/SerializerError';
3 | import { createFromSerializable } from '../mapper';
4 | import type { SerializableError, SerializerParams } from '../types';
5 |
6 | export const fromJson = (
7 | json: string,
8 | params?: SerializerParams
9 | ): Error | HttpException | SerializerError => {
10 | let v: SerializableError;
11 | try {
12 | v = JSON.parse(json ?? '') as unknown as SerializableError;
13 | } catch (e) {
14 | return new SerializerError(`Can't parse json`, {
15 | ...(e instanceof Error ? { cause: e } : {}),
16 | });
17 | }
18 | return createFromSerializable(v, params);
19 | };
20 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/json/toJson.ts:
--------------------------------------------------------------------------------
1 | import type { HttpException } from '../../base';
2 | import { SerializerError } from '../error/SerializerError';
3 | import { convertToSerializable } from '../mapper';
4 | import type { NativeError, SerializerParams } from '../types';
5 |
6 | export const toJson = (
7 | exception: Error | HttpException | NativeError,
8 | params?: SerializerParams
9 | ): string => {
10 | const serializable = convertToSerializable(exception, params);
11 | let v: string;
12 | try {
13 | v = JSON.stringify(serializable);
14 | } catch (e) {
15 | throw new SerializerError(`Can't encode into json`, {
16 | ...(e instanceof Error ? { cause: e } : {}),
17 | });
18 | }
19 | return v;
20 | };
21 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/mapper/index.ts:
--------------------------------------------------------------------------------
1 | export { convertToSerializable } from './convertToSerializable';
2 | export { createFromSerializable } from './createFromSerializable';
3 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/typeguard/index.ts:
--------------------------------------------------------------------------------
1 | export { baseExceptionMap, isBaseHttpException } from './isBaseHttpException';
2 | export { isNativeError, nativeErrorMap } from './isNativeError';
3 |
--------------------------------------------------------------------------------
/packages/exception/src/serializer/typeguard/isBaseHttpException.ts:
--------------------------------------------------------------------------------
1 | import { HttpClientException } from '../../base/HttpClientException';
2 | import { HttpException } from '../../base/HttpException';
3 | import { HttpServerException } from '../../base/HttpServerException';
4 |
5 | export const baseExceptionMap = {
6 | HttpClientException: HttpClientException,
7 | HttpException: HttpException,
8 | HttpServerException: HttpServerException,
9 | };
10 |
11 | /**
12 | * Whether the provided name is one of HttpException, HttpClientException, HttpServerException
13 | */
14 | export const isBaseHttpException = (
15 | name: string
16 | ): name is keyof typeof baseExceptionMap => {
17 | return Object.keys(baseExceptionMap).includes(name);
18 | };
19 |
--------------------------------------------------------------------------------
/packages/exception/src/server/index.ts:
--------------------------------------------------------------------------------
1 | export { HttpBadGateway } from './HttpBadGateway';
2 | export { HttpGatewayTimeout } from './HttpGatewayTimeout';
3 | export { HttpInsufficientStorage } from './HttpInsufficientStorage';
4 | export { HttpInternalServerError } from './HttpInternalServerError';
5 | export { HttpLoopDetected } from './HttpLoopDetected';
6 | export { HttpNetworkAuthenticationRequired } from './HttpNetworkAuthenticationRequired';
7 | export { HttpNotExtended } from './HttpNotExtended';
8 | export { HttpNotImplemented } from './HttpNotImplemented';
9 | export { HttpServiceUnavailable } from './HttpServiceUnavailable';
10 | export { HttpVariantAlsoNegotiates } from './HttpVariantAlsoNegotiates';
11 | export { HttpVersionNotSupported } from './HttpVersionNotSupported';
12 |
--------------------------------------------------------------------------------
/packages/exception/src/support/supportsErrorCause.ts:
--------------------------------------------------------------------------------
1 | export const supportsErrorCause = () => {
2 | const cause = Symbol('');
3 | // eslint-disable-next-line unicorn/error-message
4 | return new Error('', { cause })?.cause === cause;
5 | };
6 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isErrorWithErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { ErrorWithErrorStatusCode } from '../types';
2 | import { isHttpErrorStatusCode } from './isHttpErrorStatusCode';
3 |
4 | /**
5 | * Checks if a value is an instanceof Error and has a statusCode field
6 | * indicating an error http status (4xx or 5xx)
7 | */
8 | export const isErrorWithErrorStatusCode = (
9 | error: unknown
10 | ): error is ErrorWithErrorStatusCode => {
11 | return (
12 | error instanceof Error &&
13 | isHttpErrorStatusCode((error as ErrorWithErrorStatusCode)?.statusCode)
14 | );
15 | };
16 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isHttpClientException.ts:
--------------------------------------------------------------------------------
1 | import { HttpClientException } from '../base/HttpClientException';
2 |
3 | /**
4 | * Test whether a value is an instanceof HttpClientException
5 | * and its statusCode is in the 4xx range when the parameter
6 | * checkStatusCode is true (enabled by default).
7 | */
8 | export const isHttpClientException = (
9 | error: unknown,
10 | /**
11 | * Ensure statusCode is in the client range [>=400, <500], true by default
12 | */
13 | checkStatusCode = true
14 | ): error is HttpClientException => {
15 | return (
16 | error instanceof HttpClientException &&
17 | (!checkStatusCode || (error.statusCode > 399 && error.statusCode < 500))
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isHttpErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { HttpErrorStatusCodeOrNumber } from '../types/HttpErrorStatusCodeOrNumber';
2 |
3 | export const isHttpErrorStatusCode = <
4 | T extends HttpErrorStatusCodeOrNumber = HttpErrorStatusCodeOrNumber,
5 | >(
6 | statusCode: unknown
7 | ): statusCode is T => {
8 | return typeof statusCode === 'number' && statusCode > 399 && statusCode < 600;
9 | };
10 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isHttpException.ts:
--------------------------------------------------------------------------------
1 | import { HttpException } from '../base/HttpException';
2 |
3 | /**
4 | * Test whether a value is an instanceof HttpException
5 | * and its statusCode is in the 4xx and 5xx ranges when the parameter
6 | * checkStatusCode is true (enabled by default).
7 | */
8 | export const isHttpException = (
9 | error: unknown /**
10 | * Ensure statusCode is in the error range [>=400, <600], true by default
11 | */,
12 | checkStatusCode = true
13 | ): error is HttpException => {
14 | return (
15 | error instanceof HttpException &&
16 | (!checkStatusCode || (error.statusCode > 399 && error.statusCode < 600))
17 | );
18 | };
19 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isHttpServerException.ts:
--------------------------------------------------------------------------------
1 | import { HttpServerException } from '../base/HttpServerException';
2 |
3 | /**
4 | * Test whether a value is an instanceof HttpServerException
5 | * and its statusCode is in the 5xx range when the parameter
6 | * checkStatusCode is true (enabled by default).
7 | */
8 | export const isHttpServerException = (
9 | error: unknown,
10 | /**
11 | * Ensure statusCode is in the server range [>=500, <600], true by default
12 | */
13 | checkStatusCode = true
14 | ): error is HttpServerException => {
15 | return (
16 | error instanceof HttpServerException &&
17 | (!checkStatusCode || (error.statusCode > 499 && error.statusCode < 600))
18 | );
19 | };
20 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isHttpStatusCode.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Check if the provided value is a valid http status code > 99 and <600
3 | * @see isHttpErrorStatusCode to ensure error range [4xx,5xx]
4 | */
5 | export const isHttpStatusCode = (statusCode: unknown): statusCode is number => {
6 | return typeof statusCode === 'number' && statusCode > 99 && statusCode < 600;
7 | };
8 |
--------------------------------------------------------------------------------
/packages/exception/src/typeguards/isObjectWithErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { ObjectWithErrorStatusCode } from '../types/ObjectWithErrorStatusCode';
2 | import { isHttpErrorStatusCode } from './isHttpErrorStatusCode';
3 |
4 | /**
5 | * Checks if a value is an object (or a plain object) and has a statusCode field
6 | * indicating an error http status (4xx or 5xx)
7 | */
8 | export const isObjectWithErrorStatusCode = (
9 | objOrPlainObject: unknown
10 | ): objOrPlainObject is ObjectWithErrorStatusCode => {
11 | return isHttpErrorStatusCode(
12 | (objOrPlainObject as ObjectWithErrorStatusCode)?.statusCode
13 | );
14 | };
15 |
--------------------------------------------------------------------------------
/packages/exception/src/types/AssignedErrorStatusCodes.ts:
--------------------------------------------------------------------------------
1 | import type { statusMap } from '../status';
2 |
3 | export type AssignedErrorStatusCodes = keyof typeof statusMap;
4 |
--------------------------------------------------------------------------------
/packages/exception/src/types/ErrorWithErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { HttpErrorStatusCodeOrNumber } from './HttpErrorStatusCodeOrNumber';
2 |
3 | export interface ErrorWithErrorStatusCode extends Error {
4 | statusCode: HttpErrorStatusCodeOrNumber;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { statusMap } from '../status';
2 |
3 | export type HttpErrorStatusCode = keyof typeof statusMap;
4 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpErrorStatusCodeOrNumber.ts:
--------------------------------------------------------------------------------
1 | import type { HttpErrorStatusCode } from './HttpErrorStatusCode';
2 |
3 | export type HttpErrorStatusCodeOrNumber =
4 | | HttpErrorStatusCode
5 | // This allows to get typings for known http error statuses while keeping
6 | // the freedom to pass an arbitrary number
7 | // (this trick might be removed by future versions of typescript)
8 | // eslint-disable-next-line sonarjs/no-useless-intersection
9 | | (number & {});
10 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpExceptionParamsWithIssues.ts:
--------------------------------------------------------------------------------
1 | import type { HttpExceptionParams } from './HttpExceptionParams';
2 | import type { HttpValidationIssue } from './HttpValidationIssue';
3 |
4 | /**
5 | * Special case for 422 UnprocessableEntity
6 | */
7 | export type HttpExceptionParamsWithIssues = HttpExceptionParams & {
8 | issues?: HttpValidationIssue[];
9 | };
10 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpExceptionParamsWithStatus.ts:
--------------------------------------------------------------------------------
1 | import type { HttpErrorStatusCode } from './HttpErrorStatusCode';
2 | import type { HttpExceptionParams } from './HttpExceptionParams';
3 |
4 | export type HttpExceptionParamsWithStatus = HttpExceptionParams & {
5 | statusCode: HttpErrorStatusCode;
6 | };
7 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpMethod.ts:
--------------------------------------------------------------------------------
1 | export type HttpMethod =
2 | | 'CONNECT'
3 | | 'DELETE'
4 | | 'GET'
5 | | 'HEAD'
6 | | 'OPTIONS'
7 | | 'PATCH'
8 | | 'POST'
9 | | 'PUT'
10 | | 'QUERY'
11 | | 'TRACE';
12 |
--------------------------------------------------------------------------------
/packages/exception/src/types/HttpValidationIssue.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Related to HttpBadRequest, HttpValidationIssue contains additional validation info.
3 | * Slightly inspired from https://jsonapi.org/format/1.2/#error-objects
4 | * and zod (path).
5 | */
6 | export type HttpValidationIssue = {
7 | /** An application-specific error code, expressed as a string value. */
8 | code?: string;
9 | /** A short, human-readable summary of the problem */
10 | message: string;
11 | /** Param name or path, ie: 'email' or ['addresses', 0, 'line1'] */
12 | path: (number | string)[] | string;
13 | };
14 |
--------------------------------------------------------------------------------
/packages/exception/src/types/ObjectWithErrorStatusCode.ts:
--------------------------------------------------------------------------------
1 | import type { HttpErrorStatusCodeOrNumber } from './HttpErrorStatusCodeOrNumber';
2 |
3 | /**
4 | * Object or PlainObject with a indicative statusCode field [4xx,5xx]
5 | */
6 | export interface ObjectWithErrorStatusCode {
7 | // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
8 | statusCode: HttpErrorStatusCodeOrNumber;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/exception/src/types/index.ts:
--------------------------------------------------------------------------------
1 | export type { ErrorWithErrorStatusCode } from './ErrorWithErrorStatusCode';
2 | export type { HttpErrorStatusCode } from './HttpErrorStatusCode';
3 | export type { HttpErrorStatusCodeOrNumber } from './HttpErrorStatusCodeOrNumber';
4 | export type { HttpExceptionParams } from './HttpExceptionParams';
5 | export type { HttpExceptionParamsWithStatus } from './HttpExceptionParamsWithStatus';
6 | export type { HttpValidationIssue } from './HttpValidationIssue';
7 | export type { ObjectWithErrorStatusCode } from './ObjectWithErrorStatusCode';
8 |
--------------------------------------------------------------------------------
/packages/exception/src/utils/__tests__/getNormalizedParams.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, expect, it } from 'vitest';
2 |
3 | import { getNormalizedParams } from '../getNormalizedParams';
4 |
5 | describe('getSuper', () => {
6 | it('should return an object from string msg', () => {
7 | expect(getNormalizedParams('NotFound', {})).toStrictEqual({
8 | message: 'Not found',
9 | });
10 | expect(getNormalizedParams('NotFound', 'msg')).toStrictEqual({
11 | message: 'msg',
12 | });
13 | expect(
14 | getNormalizedParams('NotFound', {
15 | message: 'msg',
16 | })
17 | ).toStrictEqual({ message: 'msg' });
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/exception/src/utils/getMsgFromCls.ts:
--------------------------------------------------------------------------------
1 | const splitCapsRegexp = /[A-Z]/g;
2 | /**
3 | * Return default message based on http exception className
4 | * @internal
5 | */
6 | export const getMsgFromCls = (className: string) => {
7 | const preserveName =
8 | className.endsWith('Exception') || className === 'HttpVersionNotSupported';
9 | return (preserveName ? className : className.slice(4))
10 | .replaceAll(splitCapsRegexp, (match) => ` ${match}`)
11 | .trim()
12 | .split(' ')
13 | .map((word, idx) => (idx === 0 ? word : word.toLowerCase()))
14 | .join(' ');
15 | };
16 |
--------------------------------------------------------------------------------
/packages/exception/src/utils/getNormalizedParams.ts:
--------------------------------------------------------------------------------
1 | import type { HttpExceptionParams } from '../types/HttpExceptionParams';
2 | import { getMsgFromCls } from './getMsgFromCls';
3 |
4 | /**
5 | * Return params applicable to parent HttpException class when calling super();
6 | *
7 | * @internal
8 | */
9 | export const getNormalizedParams = (
10 | name: string,
11 | msgOrParams?: HttpExceptionParams | string
12 | ): HttpExceptionParams => {
13 | const { message, ...rest } = {
14 | ...(typeof msgOrParams === 'string'
15 | ? { message: msgOrParams }
16 | : (msgOrParams ?? {})),
17 | };
18 | return {
19 | ...rest,
20 | message: message ?? getMsgFromCls(`Http${name}`),
21 | };
22 | };
23 |
--------------------------------------------------------------------------------
/packages/exception/src/utils/index.ts:
--------------------------------------------------------------------------------
1 | export { getMsgFromCls } from './getMsgFromCls';
2 |
--------------------------------------------------------------------------------
/packages/exception/src/utils/initProtoAndName.ts:
--------------------------------------------------------------------------------
1 | import type { HttpException } from '../base/HttpException';
2 |
3 | /**
4 | * @internal
5 | */
6 | export const initProtoAndName = (
7 | obj: HttpException | Error,
8 | name: string,
9 | cls: { prototype: object }
10 | ) => {
11 | Object.setPrototypeOf(obj, cls.prototype);
12 | obj.name = `Http${name}`;
13 | };
14 |
--------------------------------------------------------------------------------
/packages/exception/test/specs/__snapshots__/field-validation-errors.deprecated.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`HttpBadRequest (400) with deprecated field validation > should return unmodified errors 1`] = `[HttpBadRequest: Bad request]`;
4 |
5 | exports[`HttpUnprocessableEntity (422) with field validation errors > should return unmodified errors 1`] = `[HttpUnprocessableEntity: Unprocessable entity]`;
6 |
--------------------------------------------------------------------------------
/packages/exception/test/specs/__snapshots__/field-validation-issues.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`HttpUnprocessableEntity (422) with field validation issues > should return unmodified http validation issues 1`] = `[HttpUnprocessableEntity: Unprocessable entity]`;
4 |
--------------------------------------------------------------------------------
/packages/exception/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "declaration": true,
8 | "declarationMap": false,
9 | "declarationDir": "./dist",
10 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
11 | },
12 | "exclude": ["*.test.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/exception/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": [
3 | "src/base/index.ts",
4 | "src/client/index.ts",
5 | "src/server/index.ts",
6 | "src/serializer/index.ts",
7 | "src/typeguards/index.ts",
8 | "src/types/index.ts",
9 | "src/experimental/index.ts"
10 | ],
11 | "excludePrivate": true,
12 | "excludeProtected": true,
13 | "excludeExternals": false,
14 | "includeVersion": false,
15 | "disableSources": true,
16 | "entryFileName": "README.md",
17 | "githubPages": false,
18 | "readme": "none",
19 | "exclude": ["**/*.test.ts"]
20 | }
21 |
--------------------------------------------------------------------------------
/packages/json-api/.browserslistrc:
--------------------------------------------------------------------------------
1 | # Supported browsers
2 | defaults
3 | chrome >= 96
4 | firefox >= 105
5 | edge >= 113
6 | safari >= 15
7 | ios >= 15
8 | opera >= 103
9 | not dead
--------------------------------------------------------------------------------
/packages/json-api/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/json-api/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 | /_release
11 |
12 | # tests
13 | /coverage
14 | /.nyc_output
15 |
16 | # editor
17 | /.idea
18 | .project
19 | .classpath
20 | .c9/
21 | *.launch
22 | .settings/
23 | *.sublime-workspace
24 | .vscode/*
25 | !.vscode/settings.json
26 | !.vscode/tasks.json
27 | !.vscode/launch.json
28 | !.vscode/extensions.json
29 |
30 | # os
31 | .DS_Store
32 |
33 | # debug
34 | npm-debug.log*
35 | yarn-debug.log*
36 | yarn-error.log*
37 | lerna-debug.log*
38 |
39 |
--------------------------------------------------------------------------------
/packages/json-api/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'Everything (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '*',
8 | limit: '1.15KB',
9 | webpack: false,
10 | },
11 | {
12 | name: 'Everything (CJS)',
13 | path: ['dist/index.cjs'],
14 | import: '*',
15 | limit: '1.15KB',
16 | webpack: false,
17 | },
18 | ] satisfies SizeLimitConfig;
19 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/functions/isJsonApiErrorResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / isJsonApiErrorResponse
6 |
7 | # Function: isJsonApiErrorResponse()
8 |
9 | > **isJsonApiErrorResponse**(`val`): `val is JsonApiErrorResponse`
10 |
11 | ## Parameters
12 |
13 | ### val
14 |
15 | `unknown`
16 |
17 | ## Returns
18 |
19 | `val is JsonApiErrorResponse`
20 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/functions/isJsonApiResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / isJsonApiResponse
6 |
7 | # Function: isJsonApiResponse()
8 |
9 | > **isJsonApiResponse**\<`T`\>(`val`): `val is JsonApiResponse`
10 |
11 | ## Type Parameters
12 |
13 | ### T
14 |
15 | `T` = `unknown`
16 |
17 | ## Parameters
18 |
19 | ### val
20 |
21 | `unknown`
22 |
23 | ## Returns
24 |
25 | `val is JsonApiResponse`
26 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/functions/isJsonApiSuccessResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / isJsonApiSuccessResponse
6 |
7 | # Function: isJsonApiSuccessResponse()
8 |
9 | > **isJsonApiSuccessResponse**\<`T`\>(`val`): `val is JsonApiSuccessResponse`
10 |
11 | ## Type Parameters
12 |
13 | ### T
14 |
15 | `T` = `unknown`
16 |
17 | ## Parameters
18 |
19 | ### val
20 |
21 | `unknown`
22 |
23 | ## Returns
24 |
25 | `val is JsonApiSuccessResponse`
26 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/type-aliases/JsonApiErrorResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / JsonApiErrorResponse
6 |
7 | # Type Alias: JsonApiErrorResponse
8 |
9 | > **JsonApiErrorResponse** = `object`
10 |
11 | ## Properties
12 |
13 | ### errors
14 |
15 | > **errors**: [`JsonApiError`](JsonApiError.md)[]
16 |
17 | ***
18 |
19 | ### success
20 |
21 | > **success**: `false`
22 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/type-aliases/JsonApiResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / JsonApiResponse
6 |
7 | # Type Alias: JsonApiResponse\
8 |
9 | > **JsonApiResponse**\<`T`\> = [`JsonApiErrorResponse`](JsonApiErrorResponse.md) \| [`JsonApiSuccessResponse`](JsonApiSuccessResponse.md)\<`T`\>
10 |
11 | ## Type Parameters
12 |
13 | ### T
14 |
15 | `T`
16 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/type-aliases/JsonApiResponseMeta.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / JsonApiResponseMeta
6 |
7 | # Type Alias: JsonApiResponseMeta
8 |
9 | > **JsonApiResponseMeta** = `object`
10 |
11 | ## Properties
12 |
13 | ### meta?
14 |
15 | > `optional` **meta**: `object` & `Record`\<`string`, `Record`\<`string`, `unknown`\> \| `boolean` \| `number` \| `string`\>
16 |
17 | #### Type declaration
18 |
19 | ##### cacheHit?
20 |
21 | > `optional` **cacheHit**: `boolean`
22 |
--------------------------------------------------------------------------------
/packages/json-api/docs/api/type-aliases/JsonApiSuccessResponse.md:
--------------------------------------------------------------------------------
1 | [**@httpx/json-api v0.5.25**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/json-api](../README.md) / JsonApiSuccessResponse
6 |
7 | # Type Alias: JsonApiSuccessResponse\
8 |
9 | > **JsonApiSuccessResponse**\<`T`\> = `object` & [`JsonApiResponseMeta`](JsonApiResponseMeta.md)
10 |
11 | ## Type declaration
12 |
13 | ### data
14 |
15 | > **data**: `T`
16 |
17 | ### success
18 |
19 | > **success**: `true`
20 |
21 | ## Type Parameters
22 |
23 | ### T
24 |
25 | `T`
26 |
--------------------------------------------------------------------------------
/packages/json-api/src/index.ts:
--------------------------------------------------------------------------------
1 | export {
2 | isJsonApiErrorResponse,
3 | isJsonApiResponse,
4 | isJsonApiSuccessResponse,
5 | } from './json-api.typeguard';
6 | export { JsonApiErrorFactory } from './json-api-error.factory';
7 | export { JsonApiResponseFactory } from './json-api-response.factory';
8 | export type {
9 | JsonApiError,
10 | JsonApiErrorResponse,
11 | JsonApiResponse,
12 | JsonApiResponseMeta,
13 | JsonApiSuccessResponse,
14 | } from './json-api-response.types';
15 |
--------------------------------------------------------------------------------
/packages/json-api/src/typeguards.ts:
--------------------------------------------------------------------------------
1 | export const isPlainObject = (
2 | v: unknown
3 | ): v is Record => {
4 | return (
5 | typeof v === 'object' &&
6 | v !== null &&
7 | (Object.getPrototypeOf(v) as typeof Object.prototype).constructor ===
8 | Object.prototype.constructor
9 | );
10 | };
11 |
--------------------------------------------------------------------------------
/packages/json-api/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/json-api/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "baseUrl": "./src",
6 | "target": "esnext",
7 | "module": "esnext",
8 | "moduleResolution": "bundler",
9 | "verbatimModuleSyntax": true,
10 | "strict": true,
11 | "paths": {
12 | "@httpx/exception": ["../../../packages/exception/src/index"]
13 | },
14 | "types": ["vitest/globals"]
15 | },
16 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
17 | "include": [
18 | ".eslintrc.*",
19 | "**/*.ts",
20 | "**/*.tsx",
21 | "**/*.js",
22 | "**/*.jsx",
23 | "**/*.cjs",
24 | "**/*.mjs",
25 | "**/*.json"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/packages/json-api/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "../../docs/api/json-api",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none"
12 | }
13 |
--------------------------------------------------------------------------------
/packages/lru/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/lru/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/lru/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/lru/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'import { LruCache } (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '{ LruCache }',
8 | limit: '570B',
9 | },
10 | {
11 | name: 'import { TimeLruCache } (ESM)',
12 | path: ['dist/index.mjs'],
13 | import: '{ TimeLruCache }',
14 | limit: '660B',
15 | },
16 | {
17 | name: 'require { LruCache } (CJS)',
18 | import: '{ LruCache }',
19 | path: ['dist/index.cjs'],
20 | limit: '680B',
21 | },
22 | ] satisfies SizeLimitConfig;
23 |
--------------------------------------------------------------------------------
/packages/lru/bench/README.md:
--------------------------------------------------------------------------------
1 | ## @httpx/lru
2 | Benchmarks to measure [@httpx/lru](../README.md) performance over
3 | popular libraries.
4 |
5 | ### Run
6 |
7 | ```bash
8 | yarn install
9 | cd packages/lru
10 | yarn build
11 | yarn bench
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/packages/lru/bench/bench-options.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | const defaultOptions = vitestBenchOptionsConfig.createBenchOptions({
4 | iterations: {
5 | ciOrCodSpeed: 1,
6 | local: 1,
7 | },
8 | });
9 |
10 | const { isCiOrCodSpeed } = vitestBenchOptionsConfig;
11 |
12 | export const benchOptions = {
13 | iterations: defaultOptions.iterations,
14 | time: isCiOrCodSpeed ? 100 : 500,
15 | };
16 |
17 | const SEEDS_COUNT = isCiOrCodSpeed ? 10 : 1000;
18 |
19 | export const benchSeeds = {
20 | lruMaxSize: SEEDS_COUNT,
21 | lruMaxSizeHalf: Math.floor(SEEDS_COUNT / 2),
22 | getSeeds: () => {
23 | return Array.from({ length: SEEDS_COUNT }).map((_, i) => ({
24 | key: `key-${i}`,
25 | value: `value-${i}`,
26 | }));
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/packages/lru/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/lru v0.9.0**
2 |
3 | ***
4 |
5 | # @httpx/lru v0.9.0
6 |
7 | ## Classes
8 |
9 | - [LruCache](classes/LruCache.md)
10 | - [NullLruCache](classes/NullLruCache.md)
11 | - [NullTimeLruCache](classes/NullTimeLruCache.md)
12 | - [TimeLruCache](classes/TimeLruCache.md)
13 |
14 | ## Interfaces
15 |
16 | - [ILruCache](interfaces/ILruCache.md)
17 | - [ITimeLruCache](interfaces/ITimeLruCache.md)
18 | - [LruCacheHasOptions](interfaces/LruCacheHasOptions.md)
19 |
20 | ## Type Aliases
21 |
22 | - [BaseCacheKeyTypes](type-aliases/BaseCacheKeyTypes.md)
23 | - [LruCacheParams](type-aliases/LruCacheParams.md)
24 | - [SupportedCacheValues](type-aliases/SupportedCacheValues.md)
25 | - [TimeLruCacheParams](type-aliases/TimeLruCacheParams.md)
26 |
--------------------------------------------------------------------------------
/packages/lru/docs/api/interfaces/LruCacheHasOptions.md:
--------------------------------------------------------------------------------
1 | [**@httpx/lru v0.9.0**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/lru](../README.md) / LruCacheHasOptions
6 |
7 | # Interface: LruCacheHasOptions
8 |
9 | ## Properties
10 |
11 | ### touch?
12 |
13 | > `optional` **touch**: `boolean`
14 |
15 | If true, the item will be marked as recently used.
16 |
17 | #### Default
18 |
19 | ```ts
20 | option touchOnHas in the constructor
21 | ```
22 |
--------------------------------------------------------------------------------
/packages/lru/docs/api/type-aliases/BaseCacheKeyTypes.md:
--------------------------------------------------------------------------------
1 | [**@httpx/lru v0.9.0**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/lru](../README.md) / BaseCacheKeyTypes
6 |
7 | # Type Alias: BaseCacheKeyTypes
8 |
9 | > **BaseCacheKeyTypes** = `string` \| `number`
10 |
--------------------------------------------------------------------------------
/packages/lru/docs/api/type-aliases/SupportedCacheValues.md:
--------------------------------------------------------------------------------
1 | [**@httpx/lru v0.9.0**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/lru](../README.md) / SupportedCacheValues
6 |
7 | # Type Alias: SupportedCacheValues
8 |
9 | > **SupportedCacheValues** = `Readonly`\<`BaseCacheValueTypes`\> \| `BaseCacheValueTypes`
10 |
--------------------------------------------------------------------------------
/packages/lru/docs/api/type-aliases/TimeLruCacheParams.md:
--------------------------------------------------------------------------------
1 | [**@httpx/lru v0.9.0**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/lru](../README.md) / TimeLruCacheParams
6 |
7 | # Type Alias: TimeLruCacheParams\
8 |
9 | > **TimeLruCacheParams**\<`TValue`, `TKey`\> = [`LruCacheParams`](LruCacheParams.md)\<`TValue`, `TKey`\> & `object`
10 |
11 | ## Type declaration
12 |
13 | ### defaultTTL
14 |
15 | > **defaultTTL**: `Milliseconds`
16 |
17 | Default time to live for each entry in milliseconds
18 |
19 | ## Type Parameters
20 |
21 | ### TValue
22 |
23 | `TValue`
24 |
25 | ### TKey
26 |
27 | `TKey` *extends* [`BaseCacheKeyTypes`](BaseCacheKeyTypes.md) = `string`
28 |
--------------------------------------------------------------------------------
/packages/lru/src/__tests__/types.test.ts:
--------------------------------------------------------------------------------
1 | import { expectTypeOf } from 'vitest';
2 |
3 | import type { SupportedCacheValues } from '../types';
4 |
5 | describe('Types tests', () => {
6 | describe('SupportedCacheValues', () => {
7 | it('should pass', () => {
8 | const _str: SupportedCacheValues = 'string';
9 | expectTypeOf(_str).toEqualTypeOf();
10 |
11 | // @ts-expect-error - should not allow undefined
12 | const _undefined: SupportedCacheValues = undefined;
13 |
14 | const _object: SupportedCacheValues = new Intl.Locale('en');
15 |
16 | // @ts-expect-error - should not allow promises
17 | const _async: SupportedCacheValues = new Promise(() => {});
18 | });
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/packages/lru/src/doubly-linked-node.ts:
--------------------------------------------------------------------------------
1 | import type { BaseCacheKeyTypes } from './types';
2 |
3 | export class DoublyLinkedNode {
4 | readonly key: TKey;
5 | prev: DoublyLinkedNode | null = null;
6 | next: DoublyLinkedNode | null = null;
7 | constructor(key: TKey) {
8 | this.key = key;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/lru/src/index.ts:
--------------------------------------------------------------------------------
1 | export type { LruCacheParams } from './lru-cache';
2 | export { LruCache } from './lru-cache';
3 | export type { ILruCache } from './lru-cache.interface';
4 | export { NullLruCache } from './null-lru-cache';
5 | export { NullTimeLruCache } from './null-time-lru-cache';
6 | export type { TimeLruCacheParams } from './time-lru-cache';
7 | export { TimeLruCache } from './time-lru-cache';
8 | export type { ITimeLruCache } from './time-lru-cache.interface';
9 | export type {
10 | BaseCacheKeyTypes,
11 | LruCacheHasOptions,
12 | SupportedCacheValues,
13 | } from './types';
14 |
--------------------------------------------------------------------------------
/packages/lru/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/lru/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {
11 | "@httpx/devtools-vitest": ["../../devtools/vitest/src/index.ts"]
12 | },
13 | "types": ["vitest/globals"]
14 | },
15 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
16 | "include": [
17 | ".eslintrc.*",
18 | "**/*.ts",
19 | "**/*.tsx",
20 | "**/*.js",
21 | "**/*.jsx",
22 | "**/*.cjs",
23 | "**/*.mjs",
24 | "**/*.json"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/lru/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/lru",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/memo-intl/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/memo-intl/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/memo-intl/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | _release
7 |
8 | # production output
9 | /dist
10 | /build
11 | /out
12 |
13 | # tests
14 | /coverage
15 | /.nyc_output
16 |
17 | # editor
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 | .vscode/*
26 | !.vscode/settings.json
27 | !.vscode/tasks.json
28 | !.vscode/launch.json
29 | !.vscode/extensions.json
30 |
31 | # os
32 | .DS_Store
33 |
34 | # debug
35 | npm-debug.log*
36 | yarn-debug.log*
37 | yarn-error.log*
38 | lerna-debug.log*
39 |
40 |
--------------------------------------------------------------------------------
/packages/memo-intl/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'Everything (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '*',
8 | limit: '935B',
9 | },
10 | {
11 | name: 'MIntl (ESM)',
12 | path: ['dist/index.mjs'],
13 | import: '{ MIntl }',
14 | limit: '800B',
15 | },
16 | {
17 | name: 'Everything (CJS)',
18 | import: '*',
19 | path: ['dist/index.cjs'],
20 | limit: '1.60KB',
21 | },
22 | ] satisfies SizeLimitConfig;
23 |
--------------------------------------------------------------------------------
/packages/memo-intl/bench/bench.config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
4 |
5 | export const benchConfig = {
6 | samples: isCiOrCodSpeed ? 1 : 1000,
7 | benchOptions: {
8 | iterations: isCiOrCodSpeed ? 1 : 4,
9 | },
10 | } as const;
11 |
--------------------------------------------------------------------------------
/packages/memo-intl/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/memo-intl v1.2.7**
2 |
3 | ***
4 |
5 | # @httpx/memo-intl v1.2.7
6 |
7 | ## Variables
8 |
9 | - [MIntl](variables/MIntl.md)
10 |
--------------------------------------------------------------------------------
/packages/memo-intl/src/index.ts:
--------------------------------------------------------------------------------
1 | export { MIntl } from './m-intl';
2 |
--------------------------------------------------------------------------------
/packages/memo-intl/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "baseUrl": ".",
6 | "moduleResolution": "bundler",
7 | "declaration": true,
8 | "declarationMap": false,
9 | "declarationDir": "./dist",
10 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
11 | },
12 | "exclude": ["*.test.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/memo-intl/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {
11 | "@httpx/lru": ["../../packages/lru/src/index"]
12 | },
13 | "types": ["vitest/globals"]
14 | },
15 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
16 | "include": [
17 | ".eslintrc.*",
18 | "**/*.ts",
19 | "**/*.tsx",
20 | "**/*.js",
21 | "**/*.jsx",
22 | "**/*.cjs",
23 | "**/*.mjs",
24 | "**/*.json"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/memo-intl/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/memo-intl",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/plain-object/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/plain-object/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/plain-object/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/plain-object/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/plain-object v2.0.6**
2 |
3 | ***
4 |
5 | # @httpx/plain-object v2.0.6
6 |
7 | ## Type Aliases
8 |
9 | - [PlainObject](type-aliases/PlainObject.md)
10 | - [StaticBuiltInClass](type-aliases/StaticBuiltInClass.md)
11 |
12 | ## Functions
13 |
14 | - [assertPlainObject](functions/assertPlainObject.md)
15 | - [isPlainObject](functions/isPlainObject.md)
16 | - [isStaticBuiltInClass](functions/isStaticBuiltInClass.md)
17 |
--------------------------------------------------------------------------------
/packages/plain-object/docs/api/functions/isStaticBuiltInClass.md:
--------------------------------------------------------------------------------
1 | [**@httpx/plain-object v2.0.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/plain-object](../README.md) / isStaticBuiltInClass
6 |
7 | # Function: isStaticBuiltInClass()
8 |
9 | > **isStaticBuiltInClass**(`v`): `v is StaticBuiltInClass`
10 |
11 | ## Parameters
12 |
13 | ### v
14 |
15 | `unknown`
16 |
17 | ## Returns
18 |
19 | `v is StaticBuiltInClass`
20 |
--------------------------------------------------------------------------------
/packages/plain-object/docs/api/type-aliases/PlainObject.md:
--------------------------------------------------------------------------------
1 | [**@httpx/plain-object v2.0.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/plain-object](../README.md) / PlainObject
6 |
7 | # Type Alias: PlainObject\
8 |
9 | > **PlainObject**\<`TValue`\> = `TValue` *extends* `DefaultBasePlainObject` ? `Record`\<`PlainObjectKey`, `unknown`\> : `Simplify`\<`PlainObjectDeepPartialUnknown`\<`TValue`\>\>
10 |
11 | ## Type Parameters
12 |
13 | ### TValue
14 |
15 | `TValue` *extends* `BasePlainObject` = `DefaultBasePlainObject`
16 |
--------------------------------------------------------------------------------
/packages/plain-object/docs/api/type-aliases/StaticBuiltInClass.md:
--------------------------------------------------------------------------------
1 | [**@httpx/plain-object v2.0.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/plain-object](../README.md) / StaticBuiltInClass
6 |
7 | # Type Alias: StaticBuiltInClass
8 |
9 | > **StaticBuiltInClass** = `Math` \| `JSON` \| `Atomics`
10 |
--------------------------------------------------------------------------------
/packages/plain-object/src/__tests__/assert-plain-object.test.ts:
--------------------------------------------------------------------------------
1 | import { assertPlainObject } from '../assert-plain-object';
2 |
3 | describe('object assertions tests', () => {
4 | it('should not throw when value is valid', () => {
5 | expect(() => assertPlainObject({})).not.toThrow();
6 | });
7 | it('should throw when value is invalid', () => {
8 | expect(() => assertPlainObject(new Date())).toThrow(
9 | new TypeError('Not a PlainObject')
10 | );
11 | });
12 | it('should throw custom error when value is invalid', () => {
13 | const e = new Error('cool');
14 | expect(() => assertPlainObject('123', () => e)).toThrow(e);
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/packages/plain-object/src/__tests__/is-static-built-in-class.test.ts:
--------------------------------------------------------------------------------
1 | import { isStaticBuiltInClass } from '../is-static-built-in-class';
2 |
3 | describe('isStaticBuiltInClass', () => {
4 | it('should return true for static built-in classes', () => {
5 | expect(isStaticBuiltInClass(Math)).toBe(true);
6 | expect(isStaticBuiltInClass(JSON)).toBe(true);
7 | expect(isStaticBuiltInClass(Atomics)).toBe(true);
8 | });
9 | it('should return false for if not a static built-in class', () => {
10 | expect(isStaticBuiltInClass(new Date())).toBe(false);
11 | expect(isStaticBuiltInClass({})).toBe(false);
12 | expect(isStaticBuiltInClass(null)).toBe(false);
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/packages/plain-object/src/index.ts:
--------------------------------------------------------------------------------
1 | export { assertPlainObject } from './assert-plain-object';
2 | export { isPlainObject } from './is-plain-object';
3 | export type { StaticBuiltInClass } from './is-static-built-in-class';
4 | export { isStaticBuiltInClass } from './is-static-built-in-class';
5 | export type { PlainObject } from './plain-object.types';
6 |
--------------------------------------------------------------------------------
/packages/plain-object/src/internal.types.ts:
--------------------------------------------------------------------------------
1 | export type PlainObjectKey = string | number | symbol;
2 |
3 | export type BasePlainObject = Record;
4 |
5 | export interface DefaultBasePlainObject extends BasePlainObject {
6 | readonly __tag: 'default-plain-object';
7 | }
8 |
9 | export type Simplify = {
10 | [P in keyof T]: T[P];
11 | // eslint-disable-next-line sonarjs/no-useless-intersection
12 | } & NonNullable;
13 |
14 | export type PlainObjectDeepPartialUnknown = {
15 | [P in keyof T]?: NonNullable extends BasePlainObject
16 | ? Simplify>>
17 | : unknown;
18 | };
19 |
20 | export type MsgOrErrorFactory = string | (() => Error);
21 |
--------------------------------------------------------------------------------
/packages/plain-object/src/is-static-built-in-class.ts:
--------------------------------------------------------------------------------
1 | export type StaticBuiltInClass = Math | JSON | Atomics;
2 |
3 | export const isStaticBuiltInClass = (v: unknown): v is StaticBuiltInClass => {
4 | return v === Math || v === JSON || v === Atomics;
5 | };
6 |
--------------------------------------------------------------------------------
/packages/plain-object/src/plain-object.types.ts:
--------------------------------------------------------------------------------
1 | import type {
2 | BasePlainObject,
3 | DefaultBasePlainObject,
4 | PlainObjectDeepPartialUnknown,
5 | PlainObjectKey,
6 | Simplify,
7 | } from './internal.types';
8 |
9 | export type PlainObject<
10 | TValue extends BasePlainObject = DefaultBasePlainObject,
11 | > = TValue extends DefaultBasePlainObject
12 | ? Record
13 | : Simplify>;
14 |
--------------------------------------------------------------------------------
/packages/plain-object/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/plain-object/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {},
11 | "types": ["vitest/globals"]
12 | },
13 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
14 | "include": [
15 | ".eslintrc.*",
16 | "**/*.ts",
17 | "**/*.tsx",
18 | "**/*.js",
19 | "**/*.jsx",
20 | "**/*.cjs",
21 | "**/*.mjs",
22 | "**/*.json"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/packages/plain-object/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/plain-object",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/stable-hash/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/stable-hash/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/stable-hash/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | _release
7 |
8 | # production output
9 | /dist
10 | /build
11 | /out
12 |
13 | # tests
14 | /coverage
15 | /.nyc_output
16 |
17 | # editor
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 | .vscode/*
26 | !.vscode/settings.json
27 | !.vscode/tasks.json
28 | !.vscode/launch.json
29 | !.vscode/extensions.json
30 |
31 | # os
32 | .DS_Store
33 |
34 | # debug
35 | npm-debug.log*
36 | yarn-debug.log*
37 | yarn-error.log*
38 | lerna-debug.log*
39 |
40 |
--------------------------------------------------------------------------------
/packages/stable-hash/bench/bench-config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
3 | export const benchConfig = {
4 | benchOptions: {
5 | iterations: isCiOrCodSpeed ? 2 : 10,
6 | },
7 | } as const;
8 |
--------------------------------------------------------------------------------
/packages/stable-hash/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/stable-hash v0.2.0**
2 |
3 | ***
4 |
5 | # @httpx/stable-hash v0.2.0
6 |
7 | ## Functions
8 |
9 | - [createStableHash](functions/createStableHash.md)
10 | - [createStableHashOrThrow](functions/createStableHashOrThrow.md)
11 | - [createStableKey](functions/createStableKey.md)
12 | - [createStableKeyOrThrow](functions/createStableKeyOrThrow.md)
13 |
--------------------------------------------------------------------------------
/packages/stable-hash/src/__snapshots__/create-stable-key-or-throw.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`createStableKeyOrThrow > Object params > Test full example 1`] = `"{"key1":1,"key2":[1,2,3],"key3":true,"key7":{"key1":"2025-02-11T08:58:32.075Z","key2":true},"key8":"a string"}"`;
4 |
--------------------------------------------------------------------------------
/packages/stable-hash/src/create-stable-key.test.ts:
--------------------------------------------------------------------------------
1 | import { createStableKey } from './create-stable-key';
2 |
3 | describe('createStableKey', () => {
4 | describe('Return a result object', () => {
5 | const baseParams = {
6 | string: 'string',
7 | number: 1,
8 | date: new Date('2025-02-11T08:58:32.075z'),
9 | boolean: true,
10 | bigint: BigInt(1),
11 | null: null,
12 | undefined: undefined,
13 | } as const;
14 |
15 | it('should return a sort object params', () => {
16 | expect(createStableKey(baseParams)).toStrictEqual({
17 | success: true,
18 | key: '{"bigint":"[1n]","boolean":true,"date":"2025-02-11T08:58:32.075Z","null":null,"number":1,"string":"string","undefined":"[undefined]"}',
19 | });
20 | });
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/packages/stable-hash/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createStableHash } from './create-stable-hash';
2 | export { createStableHashOrThrow } from './create-stable-hash-or-throw';
3 | export { createStableKey } from './create-stable-key';
4 | export { createStableKeyOrThrow } from './create-stable-key-or-throw';
5 |
--------------------------------------------------------------------------------
/packages/stable-hash/src/sort-obj-keys.test.ts:
--------------------------------------------------------------------------------
1 | import { sortObjKeys } from './sort-obj-keys';
2 |
3 | describe('sortObjKeys', () => {
4 | const createObject = () => ({
5 | z: 'z',
6 | a: 'a',
7 | });
8 | it('should return a sorted object', () => {
9 | const obj = createObject();
10 | const sorted = sortObjKeys(obj);
11 | expect(sorted).toStrictEqual({
12 | a: 'a',
13 | z: 'z',
14 | });
15 | });
16 | it('should not mutate the original object', () => {
17 | const obj = createObject();
18 | const backup = JSON.stringify(obj);
19 | const _sorted = sortObjKeys(obj);
20 | expect(JSON.stringify(obj)).toStrictEqual(backup);
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/packages/stable-hash/src/sort-obj-keys.ts:
--------------------------------------------------------------------------------
1 | export const sortObjKeys = (object: T): T => {
2 | const sortedKeys = Object.keys(object).sort() as unknown as [keyof T];
3 | const sorted = {} as T;
4 | for (const key of sortedKeys) {
5 | sorted[key] = object[key];
6 | }
7 | return sorted;
8 | };
9 |
--------------------------------------------------------------------------------
/packages/stable-hash/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "baseUrl": ".",
6 | "moduleResolution": "bundler",
7 | "declaration": true,
8 | "declarationMap": false,
9 | "declarationDir": "./dist",
10 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
11 | },
12 | "exclude": ["*.test.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/stable-hash/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "moduleResolution": "bundler",
8 | "verbatimModuleSyntax": true,
9 | "strict": true,
10 | "paths": {
11 | "@httpx/plain-object": ["../../packages/plain-object/src/index"]
12 | },
13 | "types": ["vitest/globals"]
14 | },
15 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
16 | "include": [
17 | ".eslintrc.*",
18 | "**/*.ts",
19 | "**/*.tsx",
20 | "**/*.js",
21 | "**/*.jsx",
22 | "**/*.cjs",
23 | "**/*.mjs",
24 | "**/*.json"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/packages/stable-hash/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/stable-hash",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/treeu/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/treeu/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/treeu/.gitignore:
--------------------------------------------------------------------------------
1 | # changeset compatible _release
2 |
3 | _release
4 |
5 | # dependencies
6 | node_modules
7 | /.pnp
8 | .pnp.js
9 |
10 | # production output
11 | /dist
12 | /build
13 | /out
14 |
15 | # tests
16 | /coverage
17 | /.nyc_output
18 |
19 | # editor
20 | /.idea
21 | .project
22 | .classpath
23 | .c9/
24 | *.launch
25 | .settings/
26 | *.sublime-workspace
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 |
33 | # os
34 | .DS_Store
35 |
36 | # debug
37 | npm-debug.log*
38 | yarn-debug.log*
39 | yarn-error.log*
40 | lerna-debug.log*
41 |
42 |
--------------------------------------------------------------------------------
/packages/treeu/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit'
2 |
3 | module.exports = [
4 | // Tree
5 | {
6 | name: 'Only { Tree } (ESM)',
7 | path: ['dist/index.mjs'],
8 | import: '{ Tree }',
9 | limit: '70B',
10 | },
11 | // Search
12 | {
13 | name: 'Only { DfsTreeSearch } (ESM)',
14 | path: ['dist/index.mjs'],
15 | import: '{ DfsTreeSearch }',
16 | limit: '280B',
17 | },
18 | // Mappers
19 | {
20 | name: 'Only { FlatTreeWsMapper } (ESM)',
21 | path: ['dist/index.mjs'],
22 | import: '{ FlatTreeWsMapper }',
23 | limit: '810B',
24 | },
25 | {
26 | name: 'Everything (ESM)',
27 | import: '*',
28 | path: ['dist/index.mjs'],
29 | limit: '2KB',
30 | },
31 | ] satisfies SizeLimitConfig;
32 |
--------------------------------------------------------------------------------
/packages/treeu/bench/README.md:
--------------------------------------------------------------------------------
1 | ## @httpx/treeu benchmarks
2 |
3 | Benchmarks to measure [@httpx/treeu](../README.md) performance over
4 | popular libraries.
5 |
6 | ### Run
7 |
8 | ```bash
9 | yarn install
10 | cd packages/treeu
11 | yarn build
12 | yarn bench
13 | ```
14 |
15 |
--------------------------------------------------------------------------------
/packages/treeu/bench/bench-config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
4 |
5 | export const benchConfig = {
6 | benchOptions: {
7 | iterations: isCiOrCodSpeed ? 2 : 10,
8 | },
9 | } as const;
10 |
--------------------------------------------------------------------------------
/packages/treeu/bench/mapper.bench.ts:
--------------------------------------------------------------------------------
1 | import { bench, describe } from 'vitest';
2 |
3 | import { FlatTreeWsMapper } from '../src';
4 | import { benchConfig } from './bench-config';
5 | import { getBenchFlatTreeWsData } from './treeu-bench-data';
6 |
7 | describe(`Bench mapper (10_000 entries)`, async () => {
8 | const pathNames = getBenchFlatTreeWsData();
9 | bench(
10 | 'FlatTreeWsMapper.toTreeNodesOrThrow',
11 | () => {
12 | new FlatTreeWsMapper().toTreeNodesOrThrow(pathNames, {
13 | separator: '/',
14 | });
15 | },
16 | benchConfig.benchOptions
17 | );
18 | });
19 |
--------------------------------------------------------------------------------
/packages/treeu/bench/treeu-bench-data.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | import type { FlatTreeWsMap } from '../src/mapper/flat-tree-ws-mapper';
4 |
5 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
6 |
7 | type Custom = {
8 | idx: number;
9 | };
10 |
11 | export const getBenchFlatTreeWsData = (): FlatTreeWsMap => {
12 | const length = isCiOrCodSpeed ? 100 : 10_000;
13 | const arr = Array.from({ length });
14 | const map: FlatTreeWsMap = new Map();
15 | for (let i = 0; i < arr.length; i++) {
16 | const key = String(i).padStart(String(length).length, '0');
17 | map.set(key, { idx: i });
18 | }
19 | return map;
20 | };
21 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/treeu v0.4.12**
2 |
3 | ***
4 |
5 | # @httpx/treeu v0.4.12
6 |
7 | ## Classes
8 |
9 | - [DfsTreeSearch](classes/DfsTreeSearch.md)
10 | - [FlatTreeWsMapper](classes/FlatTreeWsMapper.md)
11 | - [Tree](classes/Tree.md)
12 |
13 | ## Interfaces
14 |
15 | - [TreeLeafNode](interfaces/TreeLeafNode.md)
16 | - [TreeParentNode](interfaces/TreeParentNode.md)
17 | - [TreeRootNode](interfaces/TreeRootNode.md)
18 |
19 | ## Type Aliases
20 |
21 | - [FlatTreeWs](type-aliases/FlatTreeWs.md)
22 | - [TreeNode](type-aliases/TreeNode.md)
23 | - [TreeNodeValue](type-aliases/TreeNodeValue.md)
24 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/interfaces/TreeLeafNode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / TreeLeafNode
6 |
7 | # Interface: TreeLeafNode\
8 |
9 | ## Type Parameters
10 |
11 | ### TValue
12 |
13 | `TValue` *extends* [`TreeNodeValue`](../type-aliases/TreeNodeValue.md) \| `undefined` = `undefined`
14 |
15 | ### TId
16 |
17 | `TId` *extends* `TreeNodeValidId` = `string`
18 |
19 | ## Properties
20 |
21 | ### children
22 |
23 | > **children**: \[\]
24 |
25 | ***
26 |
27 | ### id
28 |
29 | > **id**: `TId`
30 |
31 | ***
32 |
33 | ### parentId
34 |
35 | > **parentId**: `TId`
36 |
37 | ***
38 |
39 | ### value?
40 |
41 | > `optional` **value**: `TValue`
42 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/interfaces/TreeParentNode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / TreeParentNode
6 |
7 | # Interface: TreeParentNode\
8 |
9 | ## Type Parameters
10 |
11 | ### TValue
12 |
13 | `TValue` *extends* [`TreeNodeValue`](../type-aliases/TreeNodeValue.md) \| `undefined` = `undefined`
14 |
15 | ### TId
16 |
17 | `TId` *extends* `TreeNodeValidId` = `string`
18 |
19 | ## Properties
20 |
21 | ### children
22 |
23 | > **children**: [`TreeNode`](../type-aliases/TreeNode.md)\<`TValue`, `TId`\>[]
24 |
25 | ***
26 |
27 | ### id
28 |
29 | > **id**: `TId`
30 |
31 | ***
32 |
33 | ### parentId
34 |
35 | > **parentId**: `null` \| `TId`
36 |
37 | ***
38 |
39 | ### value?
40 |
41 | > `optional` **value**: `TValue`
42 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/interfaces/TreeRootNode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / TreeRootNode
6 |
7 | # Interface: TreeRootNode\
8 |
9 | ## Type Parameters
10 |
11 | ### TValue
12 |
13 | `TValue` *extends* [`TreeNodeValue`](../type-aliases/TreeNodeValue.md) \| `undefined` = `undefined`
14 |
15 | ### TId
16 |
17 | `TId` *extends* `TreeNodeValidId` = `string`
18 |
19 | ## Properties
20 |
21 | ### children
22 |
23 | > **children**: [`TreeNode`](../type-aliases/TreeNode.md)\<`TValue`, `TId`\>[]
24 |
25 | ***
26 |
27 | ### id
28 |
29 | > **id**: `TId`
30 |
31 | ***
32 |
33 | ### parentId
34 |
35 | > **parentId**: `null`
36 |
37 | ***
38 |
39 | ### value?
40 |
41 | > `optional` **value**: `TValue`
42 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/type-aliases/FlatTreeWs.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / FlatTreeWs
6 |
7 | # Type Alias: FlatTreeWs\
8 |
9 | > **FlatTreeWs**\<`TValue`, `TKey`\> = `FlatTreeWsMap`\<`TValue`, `TKey`\> \| `FlatTreeWsRecord`\<`TValue`, `TKey`\>
10 |
11 | ## Type Parameters
12 |
13 | ### TValue
14 |
15 | `TValue` *extends* [`TreeNodeValue`](TreeNodeValue.md) \| `undefined`
16 |
17 | ### TKey
18 |
19 | `TKey` *extends* `FlatTreeWsUniqueKey` = `string`
20 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/type-aliases/TreeNode.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / TreeNode
6 |
7 | # Type Alias: TreeNode\
8 |
9 | > **TreeNode**\<`TValue`, `TId`\> = [`TreeRootNode`](../interfaces/TreeRootNode.md)\<`TValue`, `TId`\> \| [`TreeParentNode`](../interfaces/TreeParentNode.md)\<`TValue`, `TId`\> \| [`TreeLeafNode`](../interfaces/TreeLeafNode.md)\<`TValue`, `TId`\>
10 |
11 | ## Type Parameters
12 |
13 | ### TValue
14 |
15 | `TValue` *extends* [`TreeNodeValue`](TreeNodeValue.md) \| `undefined` = `undefined`
16 |
17 | ### TId
18 |
19 | `TId` *extends* `TreeNodeValidId` = `string`
20 |
--------------------------------------------------------------------------------
/packages/treeu/docs/api/type-aliases/TreeNodeValue.md:
--------------------------------------------------------------------------------
1 | [**@httpx/treeu v0.4.12**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/treeu](../README.md) / TreeNodeValue
6 |
7 | # Type Alias: TreeNodeValue
8 |
9 | > **TreeNodeValue** = `Record`\<`string`, `unknown`\> \| `string` \| `number` \| `boolean` \| `null`
10 |
--------------------------------------------------------------------------------
/packages/treeu/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "targets": {
3 | "typecheck": {
4 | "dependsOn": ["build, ^typecheck"],
5 | "inputs": [
6 | "default",
7 | "^public",
8 | {
9 | "externalDependencies": ["typescript"]
10 | }
11 | ],
12 | "outputs": ["{projectRoot}/tsconfig.tsbuildinfo"],
13 | "cache": true
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/packages/treeu/src/index.ts:
--------------------------------------------------------------------------------
1 | export type { FlatTreeWs } from './mapper/flat-tree-ws-mapper';
2 | export { FlatTreeWsMapper } from './mapper/flat-tree-ws-mapper';
3 | export { DfsTreeSearch } from './search/dfs-tree-search';
4 | export { Tree } from './tree';
5 | export type * from './tree.types';
6 |
--------------------------------------------------------------------------------
/packages/treeu/src/mapper/mapper.types.ts:
--------------------------------------------------------------------------------
1 | import type { TreeNode, TreeNodeValue } from '../tree.types';
2 |
3 | export type TreeMapperResult<
4 | TValue extends TreeNodeValue | undefined,
5 | TKey extends string = string,
6 | > =
7 | | {
8 | success: true;
9 | treeNodes: TreeNode[];
10 | }
11 | | {
12 | success: false;
13 | message: string;
14 | issues: TreeMapperIssue[];
15 | };
16 |
17 | export type TreeMapperIssue = {
18 | message: string;
19 | };
20 |
--------------------------------------------------------------------------------
/packages/treeu/src/tree.ts:
--------------------------------------------------------------------------------
1 | import type { TreeNode, TreeNodeValue } from './tree.types';
2 |
3 | export class Tree<
4 | TValue extends TreeNodeValue | undefined,
5 | TKey extends string = string,
6 | > {
7 | constructor(protected readonly treeNodes: TreeNode[]) {}
8 |
9 | getTreeNodes = (): TreeNode[] => {
10 | return this.treeNodes;
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/packages/treeu/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "paths": {},
12 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
13 | },
14 | "exclude": ["*.test.ts"]
15 | }
16 |
--------------------------------------------------------------------------------
/packages/treeu/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "../../tsconfig.base.json",
4 | "compilerOptions": {
5 | "target": "esnext",
6 | "module": "esnext",
7 | "baseUrl": ".",
8 | "moduleResolution": "bundler",
9 | "verbatimModuleSyntax": true,
10 | "strict": true,
11 | "paths": {
12 | "@httpx/plain-object": ["../../packages/plain-object/src/index"]
13 | },
14 | "types": ["vitest/globals"]
15 | },
16 | "exclude": ["**/node_modules", "**/.*/*", "dist", "coverage"],
17 | "include": [
18 | ".eslintrc.*",
19 | "**/*.ts",
20 | "**/*.tsx",
21 | "**/*.js",
22 | "**/*.jsx",
23 | "**/*.cjs",
24 | "**/*.mjs",
25 | "**/*.json"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/packages/treeu/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/treeu",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/xcache/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 | chrome >= 96
3 | firefox >= 105
4 | edge >= 113
5 | safari >= 15
6 | ios >= 15
7 | opera >= 103
8 | not dead
--------------------------------------------------------------------------------
/packages/xcache/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | out
3 | build
4 | coverage
5 | _release
6 |
7 |
--------------------------------------------------------------------------------
/packages/xcache/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 | /.pnp
4 | .pnp.js
5 |
6 | # production output
7 | /dist
8 | /build
9 | /out
10 |
11 | # tests
12 | /coverage
13 | /.nyc_output
14 |
15 | # editor
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 | .vscode/*
24 | !.vscode/settings.json
25 | !.vscode/tasks.json
26 | !.vscode/launch.json
27 | !.vscode/extensions.json
28 |
29 | # os
30 | .DS_Store
31 |
32 | # debug
33 | npm-debug.log*
34 | yarn-debug.log*
35 | yarn-error.log*
36 | lerna-debug.log*
37 |
38 |
--------------------------------------------------------------------------------
/packages/xcache/.size-limit.ts:
--------------------------------------------------------------------------------
1 | import type { SizeLimitConfig } from 'size-limit';
2 |
3 | module.exports = [
4 | {
5 | name: 'import { XCache } (ESM)',
6 | path: ['dist/index.mjs'],
7 | import: '{ XCache }',
8 | limit: '570B',
9 | },
10 | ] satisfies SizeLimitConfig;
11 |
--------------------------------------------------------------------------------
/packages/xcache/bench/README.md:
--------------------------------------------------------------------------------
1 | ## @httpx/mcache
2 |
3 | Benchmarks to measure [@httpx/mcache](../README.md) performance.
4 |
5 | ### Run
6 |
7 | ```bash
8 | yarn install
9 | cd packages/mcache
10 | yarn build
11 | yarn bench
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/packages/xcache/bench/bench-config.ts:
--------------------------------------------------------------------------------
1 | import { vitestBenchOptionsConfig } from '@httpx/devtools-vitest';
2 |
3 | const isCiOrCodSpeed = vitestBenchOptionsConfig.isCiOrCodSpeed;
4 |
5 | export const benchConfig = {
6 | benchOptions: {
7 | iterations: isCiOrCodSpeed ? 3 : 10,
8 | },
9 | } as const;
10 |
--------------------------------------------------------------------------------
/packages/xcache/bench/m-cache.bench.ts:
--------------------------------------------------------------------------------
1 | import { bench } from 'vitest';
2 |
3 | const options: Parameters[2] = {
4 | time: 1,
5 | };
6 |
7 | describe('MCache benches', () => {
8 | bench(
9 | 'should be fast',
10 | () => {
11 | const a = 1;
12 | },
13 | options
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/packages/xcache/docs/api/README.md:
--------------------------------------------------------------------------------
1 | **@httpx/xcache v0.0.6**
2 |
3 | ***
4 |
5 | # @httpx/xcache v0.0.6
6 |
7 | ## Classes
8 |
9 | - [XCache](classes/XCache.md)
10 |
--------------------------------------------------------------------------------
/packages/xcache/docs/api/classes/XCache.md:
--------------------------------------------------------------------------------
1 | [**@httpx/xcache v0.0.6**](../README.md)
2 |
3 | ***
4 |
5 | [@httpx/xcache](../README.md) / XCache
6 |
7 | # Class: XCache
8 |
9 | ## Constructors
10 |
11 | ### Constructor
12 |
13 | > **new XCache**(): `XCache`
14 |
15 | #### Returns
16 |
17 | `XCache`
18 |
--------------------------------------------------------------------------------
/packages/xcache/src/index.ts:
--------------------------------------------------------------------------------
1 | export { XCache } from './x-cache';
2 |
--------------------------------------------------------------------------------
/packages/xcache/src/x-cache.test.ts:
--------------------------------------------------------------------------------
1 | describe('MCache tests', () => {
2 | it('should be tested', () => {
3 | expect(true).toBe(true);
4 | });
5 | });
6 |
--------------------------------------------------------------------------------
/packages/xcache/src/x-cache.ts:
--------------------------------------------------------------------------------
1 | export class XCache {
2 | constructor() {
3 | throw new Error('Not yet implemented');
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/packages/xcache/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "rootDir": "./src",
6 | "baseUrl": ".",
7 | "moduleResolution": "bundler",
8 | "declaration": true,
9 | "declarationMap": false,
10 | "declarationDir": "./dist",
11 | "tsBuildInfoFile": "./tsconfig.build.tsbuildinfo" // for tsup rollup dts tsBuildInfoFile is required when using incremental
12 | },
13 | "exclude": ["*.test.ts"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/xcache/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": ["src/index.ts"],
3 | "out": "./docs/api/lru",
4 | "excludePrivate": true,
5 | "excludeProtected": true,
6 | "excludeExternals": true,
7 | "includeVersion": true,
8 | "disableSources": true,
9 | "entryFileName": "README.md",
10 | "githubPages": false,
11 | "readme": "none",
12 | "exclude": ["**/*.test.ts", "**/*.bench.ts"]
13 | }
14 |
--------------------------------------------------------------------------------
/tsconfig.base.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "useUnknownInCatchVariables": true,
5 | "noImplicitOverride": true,
6 | "noUncheckedIndexedAccess": true,
7 | "allowUnreachableCode": false,
8 | "noFallthroughCasesInSwitch": true,
9 | "strictNullChecks": true,
10 | "allowJs": true,
11 | "skipLibCheck": true,
12 | "exactOptionalPropertyTypes": true,
13 | "forceConsistentCasingInFileNames": true,
14 | "noEmit": true,
15 | "esModuleInterop": true,
16 | "moduleResolution": "Bundler",
17 | "module": "ESNext",
18 | "resolveJsonModule": true,
19 | "verbatimModuleSyntax": true,
20 | "incremental": true,
21 | "newLine": "lf"
22 | },
23 | "exclude": ["**/node_modules", "**/.*/"]
24 | }
25 |
--------------------------------------------------------------------------------