keq 2.6.4 → 2.6.6

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 (49) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/src/core.js +2 -2
  3. package/dist/esm/src/create-request.d.ts +1 -1
  4. package/dist/esm/src/middlewares/fetch-arguments-middleware.js +4 -4
  5. package/dist/esm/src/middlewares/fetch-middleware.js +1 -1
  6. package/dist/esm/src/middlewares/retry-middleware.d.ts +1 -1
  7. package/dist/esm/src/middlewares/retry-middleware.js +1 -1
  8. package/dist/esm/src/middlewares/serial-flow-control-middleware.d.ts +1 -1
  9. package/dist/esm/src/middlewares/timeout-middleware.d.ts +1 -1
  10. package/dist/esm/src/router/keq-host-route.d.ts +1 -1
  11. package/dist/esm/src/router/keq-location-route.d.ts +1 -1
  12. package/dist/esm/src/router/keq-location-route.js +1 -1
  13. package/dist/esm/src/router/keq-method-route.d.ts +1 -1
  14. package/dist/esm/src/router/keq-module-route.d.ts +1 -1
  15. package/dist/esm/src/router/keq-module-route.js +1 -1
  16. package/dist/esm/src/router/keq-pathname-route.d.ts +1 -1
  17. package/dist/esm/src/router/keq-pathname-route.js +2 -2
  18. package/dist/esm/src/router/keq-router.d.ts +2 -2
  19. package/dist/esm/src/router/keq-router.js +1 -1
  20. package/dist/esm/src/types/keq-context.d.ts +2 -2
  21. package/dist/esm/src/types/keq-context.js +1 -1
  22. package/dist/esm/src/types/keq-request.d.ts +1 -1
  23. package/dist/esm/src/util/assign-keq-request-body.d.ts +1 -1
  24. package/dist/esm/src/util/assign-keq-request-body.js +4 -4
  25. package/dist/esm/src/util/clone.js +1 -2
  26. package/dist/esm/src/util/compose-middleware.js +2 -2
  27. package/dist/esm/src/util/compose-route.d.ts +1 -1
  28. package/dist/esm/src/util/compose-route.js +1 -1
  29. package/dist/esm/src/util/fix-content-type.d.ts +1 -1
  30. package/dist/esm/src/util/shadow-clone.js +1 -1
  31. package/dist/umd/src/create-request.d.ts +1 -1
  32. package/dist/umd/src/middlewares/retry-middleware.d.ts +1 -1
  33. package/dist/umd/src/middlewares/serial-flow-control-middleware.d.ts +1 -1
  34. package/dist/umd/src/middlewares/timeout-middleware.d.ts +1 -1
  35. package/dist/umd/src/router/keq-host-route.d.ts +1 -1
  36. package/dist/umd/src/router/keq-location-route.d.ts +1 -1
  37. package/dist/umd/src/router/keq-method-route.d.ts +1 -1
  38. package/dist/umd/src/router/keq-module-route.d.ts +1 -1
  39. package/dist/umd/src/router/keq-pathname-route.d.ts +1 -1
  40. package/dist/umd/src/router/keq-pathname-route.js +25 -2
  41. package/dist/umd/src/router/keq-router.d.ts +2 -2
  42. package/dist/umd/src/types/keq-context.d.ts +2 -2
  43. package/dist/umd/src/types/keq-request.d.ts +1 -1
  44. package/dist/umd/src/util/assign-keq-request-body.d.ts +1 -1
  45. package/dist/umd/src/util/clone.js +0 -1
  46. package/dist/umd/src/util/compose-route.d.ts +1 -1
  47. package/dist/umd/src/util/fix-content-type.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/tsconfig.json +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.6.6](https://github.com/keq-request/keq/compare/v2.6.5...v2.6.6) (2024-06-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * unable to package correctly in nuxt3 ([b5ce266](https://github.com/keq-request/keq/commit/b5ce2662d26b180add3496b27ba795f8416a0e58))
11
+
12
+ ## [2.6.5](https://github.com/keq-request/keq/compare/v2.6.4...v2.6.5) (2024-06-03)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * wrong typescript defination ([b1bf5c2](https://github.com/keq-request/keq/commit/b1bf5c2f8b797f8beeb5531e8d075f2c1b395a27))
18
+
5
19
  ## [2.6.4](https://github.com/keq-request/keq/compare/v2.6.3...v2.6.4) (2024-06-02)
6
20
 
7
21
 
@@ -1,7 +1,7 @@
1
1
  import mitt from 'mitt';
2
2
  import { URL } from 'whatwg-url';
3
- import { Exception } from "./exception/exception.js";
4
- import { clone } from "./util/clone.js";
3
+ import { Exception } from './exception/exception.js';
4
+ import { clone } from './util/clone.js';
5
5
  import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from './constant.js';
6
6
  import { composeMiddleware } from './util/compose-middleware.js';
7
7
  import { shadowClone } from './util/shadow-clone.js';
@@ -1,6 +1,6 @@
1
1
  import type { KeqMiddleware } from './types/keq-middleware.js';
2
2
  import type { KeqRequest } from './types/keq-request.js';
3
- import { KeqOperations } from './types/keq-operation.js';
3
+ import type { KeqOperations } from './types/keq-operation.js';
4
4
  interface CreateRequestOptions {
5
5
  initMiddlewares?: KeqMiddleware[];
6
6
  baseOrigin?: string;
@@ -1,8 +1,8 @@
1
1
  import { URL } from 'whatwg-url';
2
- import { Exception } from "../exception/exception.js";
3
- import { compilePathnameTemplate } from "../util/compile-pathname-template.js";
4
- import { ABORT_PROPERTY } from "../constant.js";
5
- import { isBrowser } from "../is/is-browser.js";
2
+ import { Exception } from '../exception/exception.js';
3
+ import { compilePathnameTemplate } from '../util/compile-pathname-template.js';
4
+ import { ABORT_PROPERTY } from '../constant.js';
5
+ import { isBrowser } from '../is/is-browser.js';
6
6
  function compileUrl(obj, routeParams) {
7
7
  const url = new URL(typeof obj === 'string' ? obj : obj.href);
8
8
  try {
@@ -1,4 +1,4 @@
1
- import { Exception } from "../exception/exception.js";
1
+ import { Exception } from '../exception/exception.js';
2
2
  /**
3
3
  * Send Request
4
4
  */
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware";
1
+ import type { KeqMiddleware } from "../types/keq-middleware";
2
2
  export declare function retryMiddleware(): KeqMiddleware;
@@ -1,4 +1,4 @@
1
- import { NEXT_INVOKED_PROPERTY } from "../constant.js";
1
+ import { NEXT_INVOKED_PROPERTY } from '../constant.js';
2
2
  function sleep(ms) {
3
3
  return new Promise((resolve) => setTimeout(resolve, ms));
4
4
  }
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  export declare function serialFlowControlMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  export declare function timeoutMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqHostRoute(host: string): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqLocationRoute(): KeqRoute;
@@ -1,4 +1,4 @@
1
- import { isBrowser } from "../is/is-browser.js";
1
+ import { isBrowser } from '../is/is-browser.js';
2
2
  export function keqLocationRoute() {
3
3
  return (ctx) => isBrowser() && ctx.request.url.host === window.location.host;
4
4
  }
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqMethodRoute(method: any): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from '../types/keq-route.js';
2
2
  export declare function keqModuleRoute(moduleName: string): KeqRoute;
@@ -1,4 +1,4 @@
1
- import { Exception } from "../exception/exception.js";
1
+ import { Exception } from '../exception/exception.js';
2
2
  export function keqModuleRoute(moduleName) {
3
3
  if (!moduleName) {
4
4
  throw new Exception('Module name should not be empty');
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqPathnameRoute(pathname: string): KeqRoute;
@@ -1,4 +1,4 @@
1
- import { minimatch } from 'minimatch';
1
+ import * as m from 'minimatch';
2
2
  export function keqPathnameRoute(pathname) {
3
- return (ctx) => minimatch(ctx.request.url.pathname, pathname);
3
+ return (ctx) => m.minimatch(ctx.request.url.pathname, pathname);
4
4
  }
@@ -1,5 +1,5 @@
1
- import { KeqMiddleware } from "../types/keq-middleware";
2
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware";
2
+ import type { KeqRoute } from "../types/keq-route.js";
3
3
  export declare class KeqRouter {
4
4
  private readonly prependMiddlewares;
5
5
  constructor(prependMiddlewares?: KeqMiddleware[]);
@@ -1,4 +1,4 @@
1
- import { composeMiddleware } from "../util/compose-middleware.js";
1
+ import { composeMiddleware } from '../util/compose-middleware.js';
2
2
  import { keqHostRoute } from './keq-host-route.js';
3
3
  import { keqLocationRoute } from './keq-location-route.js';
4
4
  import { keqMethodRoute } from './keq-method-route.js';
@@ -1,5 +1,5 @@
1
- import { Emitter } from 'mitt';
2
- import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
1
+ import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from '../constant.js';
2
+ import type { Emitter } from 'mitt';
3
3
  import type { KeqOptionsParameter } from './keq-options.js';
4
4
  import type { KeqEvents } from './keq-events.js';
5
5
  import type { KeqGlobal } from './keq-global.js';
@@ -1 +1 @@
1
- import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
1
+ import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from '../constant.js';
@@ -1,9 +1,9 @@
1
+ import { FlattenOperations, KeqOperation, KeqOperations } from './keq-operation.js';
1
2
  import type { URL } from 'whatwg-url';
2
3
  import type { KeqRouter } from "../router/keq-router.js";
3
4
  import type { Keq } from "../keq.js";
4
5
  import type { KeqMiddleware } from './keq-middleware.js';
5
6
  import type { KeqInit } from './keq-init.js';
6
- import { FlattenOperations, KeqOperation, KeqOperations } from './keq-operation.js';
7
7
  type GlobalURL = globalThis.URL;
8
8
  interface KeqRequestFn<OPERATIONS extends Record<string, KeqOperation>> {
9
9
  <Path extends keyof OPERATIONS>(url: Path): Keq<OPERATIONS[Path]['responseBody'], OPERATIONS[Path]>;
@@ -1,2 +1,2 @@
1
- import { KeqContextRequestBody } from "../types/keq-context-request.js";
1
+ import type { KeqContextRequestBody } from '../types/keq-context-request.js';
2
2
  export declare function assignKeqRequestBody(left: KeqContextRequestBody, right: object | Array<any> | FormData | URLSearchParams | string): KeqContextRequestBody;
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
- import { Exception } from "../exception/exception.js";
3
- import { OverwriteArrayBodyException } from "../exception/overwrite-array-body.exception.js";
4
- import { isFormData } from "../is/is-form-data.js";
5
- import { isUrlSearchParams } from "../is/is-url-search-params.js";
2
+ import { Exception } from '../exception/exception.js';
3
+ import { OverwriteArrayBodyException } from '../exception/overwrite-array-body.exception.js';
4
+ import { isFormData } from '../is/is-form-data.js';
5
+ import { isUrlSearchParams } from '../is/is-url-search-params.js';
6
6
  export function assignKeqRequestBody(left, right) {
7
7
  if (Array.isArray(left)) {
8
8
  throw new OverwriteArrayBodyException();
@@ -1,7 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-return */
2
1
  import deepClone from 'clone';
3
2
  import fromEntries from 'object.fromentries';
4
- import { isBlob } from "../is/is-blob";
3
+ import { isBlob } from '../is/is-blob';
5
4
  export function clone(obj) {
6
5
  if (Array.isArray(obj)) {
7
6
  return obj.map((item) => (isBlob(item) ? item : clone(item)));
@@ -1,5 +1,5 @@
1
- import { Exception } from "../exception/exception.js";
2
- import { NEXT_INVOKED_PROPERTY } from "../constant.js";
1
+ import { Exception } from '../exception/exception.js';
2
+ import { NEXT_INVOKED_PROPERTY } from '../constant.js';
3
3
  export function composeMiddleware(middlewares) {
4
4
  if (!middlewares.length) {
5
5
  throw new Exception('At least one middleware');
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import { KeqRoute } from '../types/keq-route.js';
2
2
  export declare function composeRoute(routes: KeqRoute[]): KeqRoute;
@@ -1,4 +1,4 @@
1
- import { Exception } from "../exception/exception";
1
+ import { Exception } from '../exception/exception';
2
2
  export function composeRoute(routes) {
3
3
  if (!routes.length) {
4
4
  throw new Exception('At least one route');
@@ -1,3 +1,3 @@
1
- import { ShorthandContentType } from "../types/content-type.js";
1
+ import type { ShorthandContentType } from "../types/content-type.js";
2
2
  export declare function fixContentType(contentType: ShorthandContentType): string;
3
3
  export declare function fixContentType(contentType: string): string;
@@ -1,4 +1,4 @@
1
- import { isObject } from "../is/is-object.js";
1
+ import { isObject } from '../is/is-object.js';
2
2
  /**
3
3
  * @description 浅拷贝
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import type { KeqMiddleware } from './types/keq-middleware.js';
2
2
  import type { KeqRequest } from './types/keq-request.js';
3
- import { KeqOperations } from './types/keq-operation.js';
3
+ import type { KeqOperations } from './types/keq-operation.js';
4
4
  interface CreateRequestOptions {
5
5
  initMiddlewares?: KeqMiddleware[];
6
6
  baseOrigin?: string;
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware";
1
+ import type { KeqMiddleware } from "../types/keq-middleware";
2
2
  export declare function retryMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  export declare function serialFlowControlMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  export declare function timeoutMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqHostRoute(host: string): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqLocationRoute(): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqMethodRoute(method: any): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from '../types/keq-route.js';
2
2
  export declare function keqModuleRoute(moduleName: string): KeqRoute;
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqRoute } from "../types/keq-route.js";
2
2
  export declare function keqPathnameRoute(pathname: string): KeqRoute;
@@ -1,3 +1,26 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
@@ -10,9 +33,9 @@
10
33
  "use strict";
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
35
  exports.keqPathnameRoute = void 0;
13
- const minimatch_1 = require("minimatch");
36
+ const m = __importStar(require("minimatch"));
14
37
  function keqPathnameRoute(pathname) {
15
- return (ctx) => (0, minimatch_1.minimatch)(ctx.request.url.pathname, pathname);
38
+ return (ctx) => m.minimatch(ctx.request.url.pathname, pathname);
16
39
  }
17
40
  exports.keqPathnameRoute = keqPathnameRoute;
18
41
  });
@@ -1,5 +1,5 @@
1
- import { KeqMiddleware } from "../types/keq-middleware";
2
- import { KeqRoute } from "../types/keq-route.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware";
2
+ import type { KeqRoute } from "../types/keq-route.js";
3
3
  export declare class KeqRouter {
4
4
  private readonly prependMiddlewares;
5
5
  constructor(prependMiddlewares?: KeqMiddleware[]);
@@ -1,5 +1,5 @@
1
- import { Emitter } from 'mitt';
2
- import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
1
+ import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from '../constant.js';
2
+ import type { Emitter } from 'mitt';
3
3
  import type { KeqOptionsParameter } from './keq-options.js';
4
4
  import type { KeqEvents } from './keq-events.js';
5
5
  import type { KeqGlobal } from './keq-global.js';
@@ -1,9 +1,9 @@
1
+ import { FlattenOperations, KeqOperation, KeqOperations } from './keq-operation.js';
1
2
  import type { URL } from 'whatwg-url';
2
3
  import type { KeqRouter } from "../router/keq-router.js";
3
4
  import type { Keq } from "../keq.js";
4
5
  import type { KeqMiddleware } from './keq-middleware.js';
5
6
  import type { KeqInit } from './keq-init.js';
6
- import { FlattenOperations, KeqOperation, KeqOperations } from './keq-operation.js';
7
7
  type GlobalURL = globalThis.URL;
8
8
  interface KeqRequestFn<OPERATIONS extends Record<string, KeqOperation>> {
9
9
  <Path extends keyof OPERATIONS>(url: Path): Keq<OPERATIONS[Path]['responseBody'], OPERATIONS[Path]>;
@@ -1,2 +1,2 @@
1
- import { KeqContextRequestBody } from "../types/keq-context-request.js";
1
+ import type { KeqContextRequestBody } from '../types/keq-context-request.js';
2
2
  export declare function assignKeqRequestBody(left: KeqContextRequestBody, right: object | Array<any> | FormData | URLSearchParams | string): KeqContextRequestBody;
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  "use strict";
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.clone = void 0;
16
- /* eslint-disable @typescript-eslint/no-unsafe-return */
17
16
  const clone_1 = __importDefault(require("clone"));
18
17
  const object_fromentries_1 = __importDefault(require("object.fromentries"));
19
18
  const is_blob_1 = require("../is/is-blob");
@@ -1,2 +1,2 @@
1
- import { KeqRoute } from "../types/keq-route.js";
1
+ import { KeqRoute } from '../types/keq-route.js';
2
2
  export declare function composeRoute(routes: KeqRoute[]): KeqRoute;
@@ -1,3 +1,3 @@
1
- import { ShorthandContentType } from "../types/content-type.js";
1
+ import type { ShorthandContentType } from "../types/content-type.js";
2
2
  export declare function fixContentType(contentType: ShorthandContentType): string;
3
3
  export declare function fixContentType(contentType: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keq",
3
- "version": "2.6.4",
3
+ "version": "2.6.6",
4
4
  "description": "Request API write by Typescript for flexibility, readability, and a low learning curve.",
5
5
  "keywords": [
6
6
  "request",
package/tsconfig.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "strict": true,
4
- "allowSyntheticDefaultImports": true,
5
4
  "esModuleInterop": true,
6
5
  "noImplicitAny": false,
7
6
  "declaration": true,