keq 5.0.0-alpha.6 → 5.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +187 -240
  2. package/jest.browser.config.ts +22 -0
  3. package/jest.config.cts +22 -0
  4. package/package.json +21 -24
  5. package/dist/index.cjs.js +0 -1115
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.esm.js +0 -1082
  8. package/dist/package.json +0 -65
  9. package/dist/src/constant.d.ts +0 -2
  10. package/dist/src/core.d.ts +0 -36
  11. package/dist/src/create-request.d.ts +0 -9
  12. package/dist/src/exception/exception.d.ts +0 -4
  13. package/dist/src/exception/invalid-arguments.exception.d.ts +0 -4
  14. package/dist/src/index.d.ts +0 -23
  15. package/dist/src/is/is-array-buffer.d.ts +0 -1
  16. package/dist/src/is/is-blob.d.ts +0 -4
  17. package/dist/src/is/is-browser.d.ts +0 -1
  18. package/dist/src/is/is-buffer.d.ts +0 -1
  19. package/dist/src/is/is-file.d.ts +0 -1
  20. package/dist/src/is/is-form-data.d.ts +0 -1
  21. package/dist/src/is/is-function.d.ts +0 -1
  22. package/dist/src/is/is-headers.d.ts +0 -1
  23. package/dist/src/is/is-object.d.ts +0 -1
  24. package/dist/src/is/is-readable-stream.d.ts +0 -1
  25. package/dist/src/is/is-string.d.ts +0 -1
  26. package/dist/src/is/is-url-search-params.d.ts +0 -1
  27. package/dist/src/keq.d.ts +0 -93
  28. package/dist/src/middlewares/abort-flow-control-middleware.d.ts +0 -2
  29. package/dist/src/middlewares/fetch-arguments-middleware.d.ts +0 -2
  30. package/dist/src/middlewares/fetch-middleware.d.ts +0 -5
  31. package/dist/src/middlewares/proxy-response-middleware.d.ts +0 -2
  32. package/dist/src/middlewares/retry-middleware.d.ts +0 -2
  33. package/dist/src/middlewares/serial-flow-control-middleware.d.ts +0 -2
  34. package/dist/src/middlewares/timeout-middleware.d.ts +0 -2
  35. package/dist/src/request.d.ts +0 -1
  36. package/dist/src/router/keq-host-route.d.ts +0 -2
  37. package/dist/src/router/keq-location-route.d.ts +0 -2
  38. package/dist/src/router/keq-method-route.d.ts +0 -2
  39. package/dist/src/router/keq-module-route.d.ts +0 -2
  40. package/dist/src/router/keq-pathname-route.d.ts +0 -2
  41. package/dist/src/router/keq-router.d.ts +0 -12
  42. package/dist/src/types/content-type.d.ts +0 -2
  43. package/dist/src/types/exclude-property.d.ts +0 -3
  44. package/dist/src/types/extract-property.d.ts +0 -3
  45. package/dist/src/types/keq-context-request.d.ts +0 -18
  46. package/dist/src/types/keq-context.d.ts +0 -62
  47. package/dist/src/types/keq-events.d.ts +0 -8
  48. package/dist/src/types/keq-flow-control.d.ts +0 -7
  49. package/dist/src/types/keq-global.d.ts +0 -6
  50. package/dist/src/types/keq-init.d.ts +0 -2
  51. package/dist/src/types/keq-middleware.d.ts +0 -3
  52. package/dist/src/types/keq-next.d.ts +0 -1
  53. package/dist/src/types/keq-operation.d.ts +0 -44
  54. package/dist/src/types/keq-options.d.ts +0 -55
  55. package/dist/src/types/keq-query-value.d.ts +0 -6
  56. package/dist/src/types/keq-request.d.ts +0 -32
  57. package/dist/src/types/keq-resolve-with-mode.d.ts +0 -1
  58. package/dist/src/types/keq-retry.d.ts +0 -3
  59. package/dist/src/types/keq-route.d.ts +0 -2
  60. package/dist/src/types/keq-timeout.d.ts +0 -3
  61. package/dist/src/util/base64.d.ts +0 -2
  62. package/dist/src/util/clone-body.d.ts +0 -1
  63. package/dist/src/util/compile-url.d.ts +0 -1
  64. package/dist/src/util/compose-middleware.d.ts +0 -2
  65. package/dist/src/util/compose-route.d.ts +0 -2
  66. package/dist/src/util/create-response-proxy.d.ts +0 -1
  67. package/dist/src/util/fix-content-type.d.ts +0 -3
  68. package/dist/src/util/get-unique-code-identifier.d.ts +0 -1
  69. package/dist/src/util/is-valid-header-value.d.ts +0 -1
  70. package/dist/src/util/merge-keq-request-body.d.ts +0 -2
  71. package/dist/src/util/shallow-clone.d.ts +0 -4
  72. package/project.json +0 -16
  73. package/tsconfig.json +0 -28
  74. package/tsconfig.lib.json +0 -15
@@ -1,32 +0,0 @@
1
- import { FlattenOperations, KeqOperation, KeqOperations } from './keq-operation.js';
2
- import type { KeqRouter } from '~/router/keq-router.js';
3
- import type { Keq } from '~/keq.js';
4
- import type { KeqMiddleware } from './keq-middleware.js';
5
- import type { KeqInit } from './keq-init.js';
6
- interface KeqRequestFn<OPERATIONS extends Record<string, KeqOperation>> {
7
- <Path extends keyof OPERATIONS>(url: Path): Keq<OPERATIONS[Path]['responseBody'], OPERATIONS[Path]>;
8
- <OUTPUT = any>(url: string): Keq<OUTPUT>;
9
- <OUTPUT = any>(url: URL): Keq<OUTPUT>;
10
- }
11
- type PickKeqOperationsProperty<T extends KeqOperations, P extends keyof T, X extends keyof KeqOperation> = T extends {
12
- [Path in keyof T as Path extends P ? Path : never]: {
13
- [Method in keyof T[Path] as T[Path][Method] extends KeqOperation ? Method : never]: infer R;
14
- };
15
- } ? R extends KeqOperation ? R[X] : never : never;
16
- export interface KeqRequest<OPERATIONS extends KeqOperations = KeqOperations> {
17
- <Path extends keyof OPERATIONS>(url: Path, init: Omit<KeqInit, 'global'>): Keq<Exclude<PickKeqOperationsProperty<OPERATIONS, Path, 'responseBody'>, undefined>>;
18
- <OUTPUT = any>(url: string, init: Omit<KeqInit, 'global'>): Keq<OUTPUT>;
19
- <OUTPUT = any>(url: URL, init: Omit<KeqInit, 'global'>): Keq<OUTPUT>;
20
- baseOrigin: (baseOrigin: string) => void;
21
- get: KeqRequestFn<FlattenOperations<OPERATIONS, 'get'>>;
22
- post: KeqRequestFn<FlattenOperations<OPERATIONS, 'post'>>;
23
- del: KeqRequestFn<FlattenOperations<OPERATIONS, 'delete'>>;
24
- delete: KeqRequestFn<FlattenOperations<OPERATIONS, 'delete'>>;
25
- put: KeqRequestFn<FlattenOperations<OPERATIONS, 'put'>>;
26
- patch: KeqRequestFn<FlattenOperations<OPERATIONS, 'patch'>>;
27
- head: KeqRequestFn<FlattenOperations<OPERATIONS, 'head'>>;
28
- options: KeqRequestFn<FlattenOperations<OPERATIONS, 'options'>>;
29
- use(firstMiddleware: KeqMiddleware, ...middleware: KeqMiddleware[]): this;
30
- useRouter(): KeqRouter;
31
- }
32
- export {};
@@ -1 +0,0 @@
1
- export type KeqResolveMethod = 'intelligent' | 'response' | 'text' | 'json' | 'form-data' | 'blob' | 'array-buffer';
@@ -1,3 +0,0 @@
1
- import type { KeqContext } from './keq-context.js';
2
- export type KeqRetryOn = (attempt: number, error: unknown | null, ctx: KeqContext) => (boolean | Promise<boolean>);
3
- export type KeqRetryDelay = number | ((attempt: number, error: unknown | null, ctx: KeqContext) => number | Promise<number>);
@@ -1,2 +0,0 @@
1
- import type { KeqContext } from './keq-context.js';
2
- export type KeqRoute = (ctx: KeqContext) => Promise<boolean> | boolean;
@@ -1,3 +0,0 @@
1
- export interface KeqTimeout {
2
- millisecond: number;
3
- }
@@ -1,2 +0,0 @@
1
- export declare const base64Encode: ((str: string) => string);
2
- export declare const base64Decode: ((str: string) => string);
@@ -1 +0,0 @@
1
- export declare function cloneBody<T>(obj: T): T;
@@ -1 +0,0 @@
1
- export declare function compileUrl(obj: string | URL, routeParams: Record<string, string | number>): URL;
@@ -1,2 +0,0 @@
1
- import type { KeqMiddleware } from '../types/keq-middleware.js';
2
- export declare function composeMiddleware(middlewares: KeqMiddleware[]): KeqMiddleware;
@@ -1,2 +0,0 @@
1
- import { KeqRoute } from '../types/keq-route.js';
2
- export declare function composeRoute(routes: KeqRoute[]): KeqRoute;
@@ -1 +0,0 @@
1
- export declare function createResponseProxy(res: Response): Response;
@@ -1,3 +0,0 @@
1
- import type { ShorthandContentType } from '~/types/content-type.js';
2
- export declare function fixContentType(contentType: ShorthandContentType): string;
3
- export declare function fixContentType(contentType: string): string;
@@ -1 +0,0 @@
1
- export declare function getUniqueCodeIdentifier(depth?: number): string;
@@ -1 +0,0 @@
1
- export declare function isValidHeaderValue(str: any): boolean;
@@ -1,2 +0,0 @@
1
- import type { KeqContextRequestBody } from '../types/keq-context-request.js';
2
- export declare function mergeKeqRequestBody(left: KeqContextRequestBody, right: KeqContextRequestBody): KeqContextRequestBody;
@@ -1,4 +0,0 @@
1
- /**
2
- * @description 浅拷贝
3
- */
4
- export declare function shallowClone<T = any>(obj: T): T;
package/project.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "targets": {
3
- "rollup:build": {
4
- "executor": "@nx/rollup:rollup",
5
- "outputs": ["{options.outputPath}"],
6
-
7
- "options": {
8
- "useLegacyTypescriptPlugin": false,
9
- "format": ["esm", "cjs"],
10
- "main": "./src/index.ts",
11
- "tsConfig": "./tsconfig.lib.json",
12
- "outputPath": "./dist"
13
- }
14
- }
15
- }
16
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "esModuleInterop": true,
5
- "noImplicitAny": false,
6
- "declaration": true,
7
- "noEmitOnError": true,
8
- "resolveJsonModule": true,
9
- "skipLibCheck": true,
10
- "moduleResolution": "node",
11
- "module": "ESNext",
12
- "target": "ESNext",
13
- "baseUrl": "./",
14
- "rootDir": "./",
15
- "lib": ["DOM", "Es2015.Proxy", "ESNext", "DOM.Iterable"],
16
- "paths": {
17
- "~/*": ["./src/*"],
18
- "~~/*": ["./*"]
19
- }
20
- },
21
- "exclude": ["node_modules", "dist"],
22
- "include": ["**/*.ts", ".eslintrc.cjs", "jest.config.ts"],
23
- "ts-node": {
24
- "compilerOptions": {
25
- "module": "CommonJS"
26
- }
27
- }
28
- }
package/tsconfig.lib.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "esnext",
5
- "target": "esnext",
6
- "preserveWatchOutput": true,
7
- "resolveJsonModule": false
8
- },
9
- "include": [
10
- "./src/**/*.ts"
11
- ],
12
- "exclude": [
13
- "./src/**/*.spec.ts"
14
- ]
15
- }