@little-nebulae/http 0.4.0 → 0.5.0

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ValueOf } from "type-fest";
2
+ import { ExtractFrom } from "@little-nebulae/utility-types";
2
3
  export declare const HTTP_HEADER_ENUM: {
3
4
  readonly AUTHORIZATION: "authorization";
4
5
  readonly CACHE_CONTROL: "cache-control";
@@ -39,6 +40,15 @@ export declare const HTTP_REQUEST_METHOD_ENUM: {
39
40
  readonly CONNECT: "CONNECT";
40
41
  };
41
42
  export type HttpRequestMethod = ValueOf<typeof HTTP_REQUEST_METHOD_ENUM>;
43
+ export declare const HTTP_CACHE_MODE_ENUM: {
44
+ readonly DEFAULT: "default";
45
+ readonly NO_STORE: "no-store";
46
+ readonly RELOAD: "reload";
47
+ readonly NO_CACHE: "no-cache";
48
+ readonly FORCE_CACHE: "force-cache";
49
+ readonly ONLY_IF_CACHED: "only-if-cached";
50
+ };
51
+ export type HttpCacheMode = ValueOf<typeof HTTP_CACHE_MODE_ENUM>;
42
52
  export declare const HTTP_RESPONSE_STATUS_ENUM: {
43
53
  readonly BAD_REQUEST: {
44
54
  readonly CODE: 400;
@@ -741,4 +751,18 @@ export declare const HTTP_MEDIA_TYPE_ENUM: {
741
751
  PLAIN: "text/plain";
742
752
  };
743
753
  export type HttpMediaType = ValueOf<typeof HTTP_MEDIA_TYPE_ENUM>;
754
+ export type HttpRequestMethodThatAllowsBodyInRequest = ExtractFrom<HttpRequestMethod, "OPTIONS">;
755
+ export declare function isHttpRequestMethodThatAllowsBodyInRequest(method: string): method is HttpRequestMethodThatAllowsBodyInRequest;
756
+ export type HttpRequestMethodThatAllowsBodyInSuccessfulResponse = ExtractFrom<HttpRequestMethod, "DELETE" | "OPTIONS" | "PATCH" | "PUT">;
757
+ export declare function isHttpRequestMethodThatAllowsBodyInSuccessfulResponse(method: string): method is HttpRequestMethodThatAllowsBodyInSuccessfulResponse;
758
+ export type HttpRequestMethodThatForbidsBodyInRequest = ExtractFrom<HttpRequestMethod, "CONNECT" | "DELETE" | "GET" | "HEAD" | "TRACE">;
759
+ export declare function isHttpRequestMethodThatForbidsBodyInRequest(method: string): method is HttpRequestMethodThatForbidsBodyInRequest;
760
+ export type HttpRequestMethodThatForbidsBodyInSuccessfulResponse = ExtractFrom<HttpRequestMethod, "CONNECT" | "HEAD">;
761
+ export declare function isHttpRequestMethodThatForbidsBodyInSuccessfulResponse(method: string): method is HttpRequestMethodThatForbidsBodyInSuccessfulResponse;
762
+ export type HttpRequestMethodThatForbidsBodyInErrorResponse = ExtractFrom<HttpRequestMethod, "HEAD">;
763
+ export declare function isHttpRequestMethodThatForbidsBodyInErrorResponse(method: string): method is HttpRequestMethodThatForbidsBodyInErrorResponse;
764
+ export type HttpRequestMethodThatRequiresBodyInRequest = ExtractFrom<HttpRequestMethod, "PATCH" | "POST" | "PUT" | "QUERY">;
765
+ export declare function isHttpRequestMethodThatRequiresBodyInRequest(method: string): method is HttpRequestMethodThatRequiresBodyInRequest;
766
+ export type HttpRequestMethodThatRequiresBodyInSuccessfulResponse = ExtractFrom<HttpRequestMethod, "GET" | "POST" | "QUERY" | "TRACE">;
767
+ export declare function isHttpRequestMethodThatRequiresBodyInSuccessfulResponse(method: string): method is HttpRequestMethodThatRequiresBodyInSuccessfulResponse;
744
768
  export {};
package/dist/index.js CHANGED
@@ -38,6 +38,15 @@ const HTTP_REQUEST_METHOD_ENUM = {
38
38
  TRACE: "TRACE",
39
39
  CONNECT: "CONNECT"
40
40
  };
41
+ // src/constants/cache-mode.ts
42
+ const HTTP_CACHE_MODE_ENUM = {
43
+ DEFAULT: "default",
44
+ NO_STORE: "no-store",
45
+ RELOAD: "reload",
46
+ NO_CACHE: "no-cache",
47
+ FORCE_CACHE: "force-cache",
48
+ ONLY_IF_CACHED: "only-if-cached"
49
+ };
41
50
  // src/constants/response-statuses/error/client.ts
42
51
  const HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM = {
43
52
  BAD_REQUEST: {
@@ -325,4 +334,32 @@ const HTTP_MEDIA_TYPE_ENUM = {
325
334
  ...HTTP_APPLICATION_MEDIA_TYPE_ENUM,
326
335
  ...HTTP_TEXT_MEDIA_TYPE_ENUM
327
336
  };
328
- export { HTTP_APPLICATION_MEDIA_TYPE_ENUM, HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM, HTTP_ERROR_RESPONSE_STATUS_ENUM, HTTP_HEADER_ENUM, HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM, HTTP_MEDIA_TYPE_ENUM, HTTP_REDIRECTION_RESPONSE_STATUS_ENUM, HTTP_REQUEST_METHOD_ENUM, HTTP_RESPONSE_STATUS_ENUM, HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM, HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM, HTTP_TEXT_MEDIA_TYPE_ENUM };
337
+ // src/guards/request-method/allows/body-in-request.ts
338
+ function isHttpRequestMethodThatAllowsBodyInRequest(method) {
339
+ return method === HTTP_REQUEST_METHOD_ENUM.OPTIONS;
340
+ }
341
+ // src/guards/request-method/allows/body-in-successful-response.ts
342
+ function isHttpRequestMethodThatAllowsBodyInSuccessfulResponse(method) {
343
+ return method === HTTP_REQUEST_METHOD_ENUM.DELETE || method === HTTP_REQUEST_METHOD_ENUM.OPTIONS || method === HTTP_REQUEST_METHOD_ENUM.PATCH || method === HTTP_REQUEST_METHOD_ENUM.PUT;
344
+ }
345
+ // src/guards/request-method/forbids/body-in-request.ts
346
+ function isHttpRequestMethodThatForbidsBodyInRequest(method) {
347
+ return method === HTTP_REQUEST_METHOD_ENUM.CONNECT || method === HTTP_REQUEST_METHOD_ENUM.DELETE || method === HTTP_REQUEST_METHOD_ENUM.GET || method === HTTP_REQUEST_METHOD_ENUM.HEAD || method === HTTP_REQUEST_METHOD_ENUM.TRACE;
348
+ }
349
+ // src/guards/request-method/forbids/body-in-successful-response.ts
350
+ function isHttpRequestMethodThatForbidsBodyInSuccessfulResponse(method) {
351
+ return method === HTTP_REQUEST_METHOD_ENUM.CONNECT || method === HTTP_REQUEST_METHOD_ENUM.HEAD;
352
+ }
353
+ // src/guards/request-method/forbids/body-in-error-response.ts
354
+ function isHttpRequestMethodThatForbidsBodyInErrorResponse(method) {
355
+ return method === HTTP_REQUEST_METHOD_ENUM.HEAD;
356
+ }
357
+ // src/guards/request-method/requires/body-in-request.ts
358
+ function isHttpRequestMethodThatRequiresBodyInRequest(method) {
359
+ return method === HTTP_REQUEST_METHOD_ENUM.PATCH || method === HTTP_REQUEST_METHOD_ENUM.POST || method === HTTP_REQUEST_METHOD_ENUM.PUT || method === HTTP_REQUEST_METHOD_ENUM.QUERY;
360
+ }
361
+ // src/guards/request-method/requires/body-in-successful-response.ts
362
+ function isHttpRequestMethodThatRequiresBodyInSuccessfulResponse(method) {
363
+ return method === HTTP_REQUEST_METHOD_ENUM.GET || method === HTTP_REQUEST_METHOD_ENUM.POST || method === HTTP_REQUEST_METHOD_ENUM.QUERY || method === HTTP_REQUEST_METHOD_ENUM.TRACE;
364
+ }
365
+ export { HTTP_APPLICATION_MEDIA_TYPE_ENUM, HTTP_CACHE_MODE_ENUM, HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM, HTTP_ERROR_RESPONSE_STATUS_ENUM, HTTP_HEADER_ENUM, HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM, HTTP_MEDIA_TYPE_ENUM, HTTP_REDIRECTION_RESPONSE_STATUS_ENUM, HTTP_REQUEST_METHOD_ENUM, HTTP_RESPONSE_STATUS_ENUM, HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM, HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM, HTTP_TEXT_MEDIA_TYPE_ENUM, isHttpRequestMethodThatAllowsBodyInRequest, isHttpRequestMethodThatAllowsBodyInSuccessfulResponse, isHttpRequestMethodThatForbidsBodyInErrorResponse, isHttpRequestMethodThatForbidsBodyInRequest, isHttpRequestMethodThatForbidsBodyInSuccessfulResponse, isHttpRequestMethodThatRequiresBodyInRequest, isHttpRequestMethodThatRequiresBodyInSuccessfulResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@little-nebulae/http",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -17,18 +17,20 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@arethetypeswrong/core": "0.18.5",
20
+ "@little-nebulae/utility-types": "0.5.0",
20
21
  "@types/node": "26.6.6",
21
22
  "oxfmt": "0.78.0",
22
23
  "oxlint": "1.93.0",
23
24
  "oxlint-tsgolint": "7.0.2007",
24
25
  "publint": "0.3.25",
25
26
  "tsdown": "0.23.7",
26
- "type-fest": "5.10.0",
27
+ "type-fest": "6.0.0",
27
28
  "typescript": "7.1.0-beta",
28
29
  "vitest": "5.1.0"
29
30
  },
30
31
  "peerDependencies": {
31
- "type-fest": "^5.0.0"
32
+ "@little-nebulae/utility-types": "0",
33
+ "type-fest": "^6.0.0"
32
34
  },
33
35
  "devEngines": {
34
36
  "packageManager": {