@ekumlin/typescript-toolkit 1.0.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/README.md +98 -0
- package/dist/collections.d.mts +7 -0
- package/dist/collections.d.ts +7 -0
- package/dist/collections.js +60 -0
- package/dist/collections.js.map +1 -0
- package/dist/collections.mjs +31 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/dom.d.mts +161 -0
- package/dist/dom.d.ts +161 -0
- package/dist/dom.js +359 -0
- package/dist/dom.js.map +1 -0
- package/dist/dom.mjs +314 -0
- package/dist/dom.mjs.map +1 -0
- package/dist/environment.d.mts +3 -0
- package/dist/environment.d.ts +3 -0
- package/dist/environment.js +33 -0
- package/dist/environment.js.map +1 -0
- package/dist/environment.mjs +6 -0
- package/dist/environment.mjs.map +1 -0
- package/dist/error.d.mts +5 -0
- package/dist/error.d.ts +5 -0
- package/dist/error.js +61 -0
- package/dist/error.js.map +1 -0
- package/dist/error.mjs +33 -0
- package/dist/error.mjs.map +1 -0
- package/dist/http.d.mts +145 -0
- package/dist/http.d.ts +145 -0
- package/dist/http.js +439 -0
- package/dist/http.js.map +1 -0
- package/dist/http.mjs +283 -0
- package/dist/http.mjs.map +1 -0
- package/dist/io.d.mts +244 -0
- package/dist/io.d.ts +244 -0
- package/dist/io.js +521 -0
- package/dist/io.js.map +1 -0
- package/dist/io.mjs +365 -0
- package/dist/io.mjs.map +1 -0
- package/dist/number.d.mts +8 -0
- package/dist/number.d.ts +8 -0
- package/dist/number.js +70 -0
- package/dist/number.js.map +1 -0
- package/dist/number.mjs +40 -0
- package/dist/number.mjs.map +1 -0
- package/dist/promise.d.mts +3 -0
- package/dist/promise.d.ts +3 -0
- package/dist/promise.js +37 -0
- package/dist/promise.js.map +1 -0
- package/dist/promise.mjs +10 -0
- package/dist/promise.mjs.map +1 -0
- package/dist/routing.d.mts +3 -0
- package/dist/routing.d.ts +3 -0
- package/dist/routing.js +43 -0
- package/dist/routing.js.map +1 -0
- package/dist/routing.mjs +16 -0
- package/dist/routing.mjs.map +1 -0
- package/dist/string.d.mts +9 -0
- package/dist/string.d.ts +9 -0
- package/dist/string.js +75 -0
- package/dist/string.js.map +1 -0
- package/dist/string.mjs +45 -0
- package/dist/string.mjs.map +1 -0
- package/dist/time.d.mts +9 -0
- package/dist/time.d.ts +9 -0
- package/dist/time.js +50 -0
- package/dist/time.js.map +1 -0
- package/dist/time.mjs +21 -0
- package/dist/time.mjs.map +1 -0
- package/dist/types.d.mts +11 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +58 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +23 -0
- package/dist/types.mjs.map +1 -0
- package/dist/values.d.mts +8 -0
- package/dist/values.d.ts +8 -0
- package/dist/values.js +58 -0
- package/dist/values.js.map +1 -0
- package/dist/values.mjs +30 -0
- package/dist/values.mjs.map +1 -0
- package/package.json +40 -0
package/dist/dom.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dom/css.ts","../src/types/guards.ts"],"sourcesContent":["import z from \"zod\";\nimport { isString } from \"../types\";\n\nexport const htmlColorNamesSchema = z.enum([\n\t\"aliceBlue\", // #F0F8FF\n\t\"antiqueWhite\", // #FAEBD7\n\t\"aqua\", // #00FFFF\n\t\"aquamarine\", // #7FFFD4\n\t\"azure\", // #F0FFFF\n\t\"beige\", // #F5F5DC\n\t\"bisque\", // #FFE4C4\n\t\"black\", // #000000\n\t\"blanchedAlmond\", // #FFEBCD\n\t\"blue\", // #0000FF\n\t\"blueViolet\", // #8A2BE2\n\t\"brown\", // #A52A2A\n\t\"burlyWood\", // #DEB887\n\t\"cadetBlue\", // #5F9EA0\n\t\"chartreuse\", // #7FFF00\n\t\"chocolate\", // #D2691E\n\t\"coral\", // #FF7F50\n\t\"cornflowerBlue\", // #6495ED\n\t\"cornsilk\", // #FFF8DC\n\t\"crimson\", // #DC143C\n\t\"cyan\", // #00FFFF\n\t\"darkBlue\", // #00008B\n\t\"darkCyan\", // #008B8B\n\t\"darkGoldenRod\", // #B8860B\n\t\"darkGrey\", // #A9A9A9\n\t\"darkGreen\", // #006400\n\t\"darkKhaki\", // #BDB76B\n\t\"darkMagenta\", // #8B008B\n\t\"darkOliveGreen\", // #556B2F\n\t\"darkOrange\", // #FF8C00\n\t\"darkOrchid\", // #9932CC\n\t\"darkRed\", // #8B0000\n\t\"darkSalmon\", // #E9967A\n\t\"darkSeaGreen\", // #8FBC8F\n\t\"darkSlateBlue\", // #483D8B\n\t\"darkSlateGrey\", // #2F4F4F\n\t\"darkTurquoise\", // #00CED1\n\t\"darkViolet\", // #9400D3\n\t\"deepPink\", // #FF1493\n\t\"deepSkyBlue\", // #00BFFF\n\t\"dimGray\", // #696969\n\t\"dodgerBlue\", // #1E90FF\n\t\"fireBrick\", // #B22222\n\t\"floralWhite\", // #FFFAF0\n\t\"forestGreen\", // #228B22\n\t\"fuchsia\", // #FF00FF\n\t\"gainsboro\", // #DCDCDC\n\t\"ghostWhite\", // #F8F8FF\n\t\"gold\", // #FFD700\n\t\"goldenRod\", // #DAA520\n\t\"grey\", // #808080\n\t\"green\", // #008000\n\t\"greenYellow\", // #ADFF2F\n\t\"honeyDew\", // #F0FFF0\n\t\"hotPink\", // #FF69B4\n\t\"indianRed\", // #CD5C5C\n\t\"indigo\", // #4B0082\n\t\"ivory\", // #FFFFF0\n\t\"khaki\", // #F0E68C\n\t\"lavender\", // #E6E6FA\n\t\"lavenderBlush\", // #FFF0F5\n\t\"lawnGreen\", // #7CFC00\n\t\"lemonChiffon\", // #FFFACD\n\t\"lightBlue\", // #ADD8E6\n\t\"lightCoral\", // #F08080\n\t\"lightCyan\", // #E0FFFF\n\t\"lightGoldenRodYellow\", // #FAFAD2\n\t\"lightGrey\", // #D3D3D3\n\t\"lightGreen\", // #90EE90\n\t\"lightPink\", // #FFB6C1\n\t\"lightSalmon\", // #FFA07A\n\t\"lightSeaGreen\", // #20B2AA\n\t\"lightSkyBlue\", // #87CEFA\n\t\"lightSlateGrey\", // #778899\n\t\"lightSteelBlue\", // #B0C4DE\n\t\"lightYellow\", // #FFFFE0\n\t\"lime\", // #00FF00\n\t\"limeGreen\", // #32CD32\n\t\"linen\", // #FAF0E6\n\t\"magenta\", // #FF00FF\n\t\"maroon\", // #800000\n\t\"mediumAquaMarine\", // #66CDAA\n\t\"mediumBlue\", // #0000CD\n\t\"mediumOrchid\", // #BA55D3\n\t\"mediumPurple\", // #9370D8\n\t\"mediumSeaGreen\", // #3CB371\n\t\"mediumSlateBlue\", // #7B68EE\n\t\"mediumSpringGreen\", // #00FA9A\n\t\"mediumTurquoise\", // #48D1CC\n\t\"mediumVioletRed\", // #C71585\n\t\"midnightBlue\", // #191970\n\t\"mintCream\", // #F5FFFA\n\t\"mistyRose\", // #FFE4E1\n\t\"moccasin\", // #FFE4B5\n\t\"navajoWhite\", // #FFDEAD\n\t\"navy\", // #000080\n\t\"oldLace\", // #FDF5E6\n\t\"olive\", // #808000\n\t\"oliveDrab\", // #6B8E23\n\t\"orange\", // #FFA500\n\t\"orangeRed\", // #FF4500\n\t\"orchid\", // #DA70D6\n\t\"paleGoldenRod\", // #EEE8AA\n\t\"paleGreen\", // #98FB98\n\t\"paleTurquoise\", // #AFEEEE\n\t\"paleVioletRed\", // #D87093\n\t\"papayaWhip\", // #FFEFD5\n\t\"peachPuff\", // #FFDAB9\n\t\"peru\", // #CD853F\n\t\"pink\", // #FFC0CB\n\t\"plum\", // #DDA0DD\n\t\"powderBlue\", // #B0E0E6\n\t\"purple\", // #800080\n\t\"red\", // #FF0000\n\t\"rosyBrown\", // #BC8F8F\n\t\"royalBlue\", // #4169E1\n\t\"saddleBrown\", // #8B4513\n\t\"salmon\", // #FA8072\n\t\"sandyBrown\", // #F4A460\n\t\"seaGreen\", // #2E8B57\n\t\"seaShell\", // #FFF5EE\n\t\"sienna\", // #A0522D\n\t\"silver\", // #C0C0C0\n\t\"skyBlue\", // #87CEEB\n\t\"slateBlue\", // #6A5ACD\n\t\"slateGrey\", // #708090\n\t\"snow\", // #FFFAFA\n\t\"springGreen\", // #00FF7F\n\t\"steelBlue\", // #4682B4\n\t\"tan\", // #D2B48C\n\t\"teal\", // #008080\n\t\"thistle\", // #D8BFD8\n\t\"tomato\", // #FF6347\n\t\"turquoise\", // #40E0D0\n\t\"violet\", // #EE82EE\n\t\"wheat\", // #F5DEB3\n\t\"white\", // #FFFFFF\n\t\"whiteSmoke\", // #F5F5F5\n\t\"yellow\", // #FFFF00\n\t\"yellowGreen\", // #9ACD32\n] as const);\n\nexport type HtmlColorName = z.infer<typeof htmlColorNamesSchema>;\n\nexport const asHtmlColorName = (value: unknown): HtmlColorName =>\n\thtmlColorNamesSchema.parse(value);\n\nexport const isHtmlColorName = (obj: unknown): obj is HtmlColorName =>\n\thtmlColorNamesSchema.safeParse(obj).success;\n\nexport type CssVariable = `var(--${string})`;\n\nexport const isCssVariable = (obj: unknown): obj is CssVariable =>\n\tisString(obj) && !!/^var\\(--[^)]+\\)$/.exec(obj);\n\nexport type CssVariableColor =\n\t| CssVariable\n\t| `rgb(${CssVariable})`\n\t| `rgba(${CssVariable})`;\n\nexport const isCssVariableColor = (obj: unknown): obj is CssVariableColor =>\n\tisCssVariable(obj) ||\n\t(isString(obj) && !!/^rgba?\\(var\\(--[^)]+\\)\\)$/.exec(obj));\n\nexport type HexColor = `#${string}`;\n\nexport const isHexColor = (obj: unknown): obj is HexColor =>\n\tisString(obj) && !!/^#([a-fA-F0-9]{3,4}){1,2}$/.exec(obj);\n\nexport type RgbaColor = `rgba(${number}, ${number}, ${number}, ${number})`;\n\nexport const isRgbaColor = (obj: unknown): obj is RgbaColor =>\n\tisString(obj) &&\n\t!!/^rgba\\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]), *(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]), *(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]), *[01](\\.[0-9]*)?\\)$/.exec(\n\t\tobj,\n\t);\n\nexport type RgbColor = `rgb(${number}, ${number}, ${number})`;\n\nexport const isRgbColor = (obj: unknown): obj is RgbColor =>\n\tisString(obj) &&\n\t!!/^rgb\\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]), *(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]), *(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\)$/.exec(\n\t\tobj,\n\t);\n\nexport type HtmlColor =\n\t| HtmlColorName\n\t| CssVariableColor\n\t| RgbColor\n\t| RgbaColor\n\t| HexColor;\n\nexport const isHtmlColor = (obj: unknown): obj is HtmlColor =>\n\tisHtmlColorName(obj) ||\n\tisCssVariableColor(obj) ||\n\tisHexColor(obj) ||\n\tisRgbaColor(obj) ||\n\tisRgbColor(obj);\n","import { z } from \"zod\";\n\nexport const isArray = (obj: unknown): obj is unknown[] => Array.isArray(obj);\n\nexport const isBoolean = (obj: unknown): obj is boolean =>\n\tobj === true || obj === false;\n\n// biome-ignore lint/complexity/noBannedTypes: Generic function-checking type guard.\nexport const isFunction = (obj: unknown): obj is Function =>\n\ttypeof obj === \"function\";\n\nexport const isNull = (obj: unknown): obj is null => obj === null;\n\nexport const isNullOrUndefined = (obj: unknown): obj is null | undefined =>\n\tisNull(obj) || isUndefined(obj);\n\nexport const isNumber = (obj: unknown): obj is number =>\n\ttypeof obj === \"number\";\n\nexport const isString = (obj: unknown): obj is string =>\n\ttypeof obj === \"string\";\n\nexport const isUndefined = (obj: unknown): obj is undefined =>\n\ttypeof obj === \"undefined\";\n\nexport const isUnknown = (obj: unknown): obj is unknown =>\n\tz.unknown().safeParse(obj).success;\n"],"mappings":";AAAA,OAAOA,QAAO;;;ACAd,SAAS,SAAS;AAmBX,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;;;ADjBT,IAAM,uBAAuBC,GAAE,KAAK;AAAA,EAC1C;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACD,CAAU;AAIH,IAAM,kBAAkB,CAAC,UAC/B,qBAAqB,MAAM,KAAK;AAE1B,IAAM,kBAAkB,CAAC,QAC/B,qBAAqB,UAAU,GAAG,EAAE;AAI9B,IAAM,gBAAgB,CAAC,QAC7B,SAAS,GAAG,KAAK,CAAC,CAAC,mBAAmB,KAAK,GAAG;AAOxC,IAAM,qBAAqB,CAAC,QAClC,cAAc,GAAG,KAChB,SAAS,GAAG,KAAK,CAAC,CAAC,4BAA4B,KAAK,GAAG;AAIlD,IAAM,aAAa,CAAC,QAC1B,SAAS,GAAG,KAAK,CAAC,CAAC,6BAA6B,KAAK,GAAG;AAIlD,IAAM,cAAc,CAAC,QAC3B,SAAS,GAAG,KACZ,CAAC,CAAC,2IAA2I;AAAA,EAC5I;AACD;AAIM,IAAM,aAAa,CAAC,QAC1B,SAAS,GAAG,KACZ,CAAC,CAAC,wHAAwH;AAAA,EACzH;AACD;AASM,IAAM,cAAc,CAAC,QAC3B,gBAAgB,GAAG,KACnB,mBAAmB,GAAG,KACtB,WAAW,GAAG,KACd,YAAY,GAAG,KACf,WAAW,GAAG;","names":["z","z"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/environment/index.ts
|
|
21
|
+
var environment_exports = {};
|
|
22
|
+
__export(environment_exports, {
|
|
23
|
+
isDebug: () => isDebug
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(environment_exports);
|
|
26
|
+
|
|
27
|
+
// src/environment/isDebug.ts
|
|
28
|
+
var isDebug = () => process.env.NODE_ENV === "development";
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
isDebug
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/environment/index.ts","../src/environment/isDebug.ts"],"sourcesContent":["export * from \"./isDebug\";\n","export const isDebug = () => process.env.NODE_ENV === \"development\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,UAAU,MAAM,QAAQ,IAAI,aAAa;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/environment/isDebug.ts"],"sourcesContent":["export const isDebug = () => process.env.NODE_ENV === \"development\";\n"],"mappings":";AAAO,IAAM,UAAU,MAAM,QAAQ,IAAI,aAAa;","names":[]}
|
package/dist/error.d.mts
ADDED
package/dist/error.d.ts
ADDED
package/dist/error.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/error/index.ts
|
|
21
|
+
var error_exports = {};
|
|
22
|
+
__export(error_exports, {
|
|
23
|
+
isError: () => isError,
|
|
24
|
+
toError: () => toError
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(error_exports);
|
|
27
|
+
|
|
28
|
+
// src/error/isError.ts
|
|
29
|
+
var import_zod = require("zod");
|
|
30
|
+
var errorSchema = import_zod.z.object({
|
|
31
|
+
message: import_zod.z.string(),
|
|
32
|
+
name: import_zod.z.string(),
|
|
33
|
+
stack: import_zod.z.string().optional()
|
|
34
|
+
});
|
|
35
|
+
var isError = (obj) => {
|
|
36
|
+
if (obj instanceof Error) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return errorSchema.safeParse(obj).success;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/types/guards.ts
|
|
43
|
+
var import_zod2 = require("zod");
|
|
44
|
+
var isString = (obj) => typeof obj === "string";
|
|
45
|
+
|
|
46
|
+
// src/error/toError.ts
|
|
47
|
+
var toError = (error) => {
|
|
48
|
+
if (isError(error)) {
|
|
49
|
+
return error;
|
|
50
|
+
}
|
|
51
|
+
if (isString(error) || error) {
|
|
52
|
+
return new Error(`${error}`);
|
|
53
|
+
}
|
|
54
|
+
return new Error("Unknown error.");
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
isError,
|
|
59
|
+
toError
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/index.ts","../src/error/isError.ts","../src/types/guards.ts","../src/error/toError.ts"],"sourcesContent":["export * from \"./isError\";\nexport * from \"./toError\";\n","import { z } from \"zod\";\n\nconst errorSchema = z.object({\n\tmessage: z.string(),\n\tname: z.string(),\n\tstack: z.string().optional(),\n});\n\nexport const isError = (obj: unknown): obj is Error => {\n\tif (obj instanceof Error) {\n\t\treturn true;\n\t}\n\n\treturn errorSchema.safeParse(obj).success;\n};\n","import { z } from \"zod\";\n\nexport const isArray = (obj: unknown): obj is unknown[] => Array.isArray(obj);\n\nexport const isBoolean = (obj: unknown): obj is boolean =>\n\tobj === true || obj === false;\n\n// biome-ignore lint/complexity/noBannedTypes: Generic function-checking type guard.\nexport const isFunction = (obj: unknown): obj is Function =>\n\ttypeof obj === \"function\";\n\nexport const isNull = (obj: unknown): obj is null => obj === null;\n\nexport const isNullOrUndefined = (obj: unknown): obj is null | undefined =>\n\tisNull(obj) || isUndefined(obj);\n\nexport const isNumber = (obj: unknown): obj is number =>\n\ttypeof obj === \"number\";\n\nexport const isString = (obj: unknown): obj is string =>\n\ttypeof obj === \"string\";\n\nexport const isUndefined = (obj: unknown): obj is undefined =>\n\ttypeof obj === \"undefined\";\n\nexport const isUnknown = (obj: unknown): obj is unknown =>\n\tz.unknown().safeParse(obj).success;\n","import { isString } from \"../types/guards\";\nimport { isError } from \"./isError\";\n\nexport const toError = (error: unknown): Error => {\n\tif (isError(error)) {\n\t\treturn error;\n\t}\n\n\tif (isString(error) || error) {\n\t\treturn new Error(`${error}`);\n\t}\n\n\treturn new Error(\"Unknown error.\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAElB,IAAM,cAAc,aAAE,OAAO;AAAA,EAC5B,SAAS,aAAE,OAAO;AAAA,EAClB,MAAM,aAAE,OAAO;AAAA,EACf,OAAO,aAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAEM,IAAM,UAAU,CAAC,QAA+B;AACtD,MAAI,eAAe,OAAO;AACzB,WAAO;AAAA,EACR;AAEA,SAAO,YAAY,UAAU,GAAG,EAAE;AACnC;;;ACdA,IAAAA,cAAkB;AAmBX,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;;;ACjBT,IAAM,UAAU,CAAC,UAA0B;AACjD,MAAI,QAAQ,KAAK,GAAG;AACnB,WAAO;AAAA,EACR;AAEA,MAAI,SAAS,KAAK,KAAK,OAAO;AAC7B,WAAO,IAAI,MAAM,GAAG,KAAK,EAAE;AAAA,EAC5B;AAEA,SAAO,IAAI,MAAM,gBAAgB;AAClC;","names":["import_zod"]}
|
package/dist/error.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/error/isError.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var errorSchema = z.object({
|
|
4
|
+
message: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
stack: z.string().optional()
|
|
7
|
+
});
|
|
8
|
+
var isError = (obj) => {
|
|
9
|
+
if (obj instanceof Error) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return errorSchema.safeParse(obj).success;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/types/guards.ts
|
|
16
|
+
import { z as z2 } from "zod";
|
|
17
|
+
var isString = (obj) => typeof obj === "string";
|
|
18
|
+
|
|
19
|
+
// src/error/toError.ts
|
|
20
|
+
var toError = (error) => {
|
|
21
|
+
if (isError(error)) {
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
if (isString(error) || error) {
|
|
25
|
+
return new Error(`${error}`);
|
|
26
|
+
}
|
|
27
|
+
return new Error("Unknown error.");
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
isError,
|
|
31
|
+
toError
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/isError.ts","../src/types/guards.ts","../src/error/toError.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst errorSchema = z.object({\n\tmessage: z.string(),\n\tname: z.string(),\n\tstack: z.string().optional(),\n});\n\nexport const isError = (obj: unknown): obj is Error => {\n\tif (obj instanceof Error) {\n\t\treturn true;\n\t}\n\n\treturn errorSchema.safeParse(obj).success;\n};\n","import { z } from \"zod\";\n\nexport const isArray = (obj: unknown): obj is unknown[] => Array.isArray(obj);\n\nexport const isBoolean = (obj: unknown): obj is boolean =>\n\tobj === true || obj === false;\n\n// biome-ignore lint/complexity/noBannedTypes: Generic function-checking type guard.\nexport const isFunction = (obj: unknown): obj is Function =>\n\ttypeof obj === \"function\";\n\nexport const isNull = (obj: unknown): obj is null => obj === null;\n\nexport const isNullOrUndefined = (obj: unknown): obj is null | undefined =>\n\tisNull(obj) || isUndefined(obj);\n\nexport const isNumber = (obj: unknown): obj is number =>\n\ttypeof obj === \"number\";\n\nexport const isString = (obj: unknown): obj is string =>\n\ttypeof obj === \"string\";\n\nexport const isUndefined = (obj: unknown): obj is undefined =>\n\ttypeof obj === \"undefined\";\n\nexport const isUnknown = (obj: unknown): obj is unknown =>\n\tz.unknown().safeParse(obj).success;\n","import { isString } from \"../types/guards\";\nimport { isError } from \"./isError\";\n\nexport const toError = (error: unknown): Error => {\n\tif (isError(error)) {\n\t\treturn error;\n\t}\n\n\tif (isString(error) || error) {\n\t\treturn new Error(`${error}`);\n\t}\n\n\treturn new Error(\"Unknown error.\");\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAElB,IAAM,cAAc,EAAE,OAAO;AAAA,EAC5B,SAAS,EAAE,OAAO;AAAA,EAClB,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAEM,IAAM,UAAU,CAAC,QAA+B;AACtD,MAAI,eAAe,OAAO;AACzB,WAAO;AAAA,EACR;AAEA,SAAO,YAAY,UAAU,GAAG,EAAE;AACnC;;;ACdA,SAAS,KAAAA,UAAS;AAmBX,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;;;ACjBT,IAAM,UAAU,CAAC,UAA0B;AACjD,MAAI,QAAQ,KAAK,GAAG;AACnB,WAAO;AAAA,EACR;AAEA,MAAI,SAAS,KAAK,KAAK,OAAO;AAC7B,WAAO,IAAI,MAAM,GAAG,KAAK,EAAE;AAAA,EAC5B;AAEA,SAAO,IAAI,MAAM,gBAAgB;AAClC;","names":["z"]}
|
package/dist/http.d.mts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface AuthorizationToken {
|
|
4
|
+
expiresOn: number;
|
|
5
|
+
tokenType: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
declare const getAuthorizationHeader: (token: AuthorizationToken) => string;
|
|
9
|
+
declare const isExpired: (token: AuthorizationToken) => boolean;
|
|
10
|
+
|
|
11
|
+
declare const getQueryParameters: (url: string | URL) => URLSearchParams;
|
|
12
|
+
|
|
13
|
+
type HttpRequestHeader = "Accept" | "Accept-Charset" | "Accept-Datetime" | "Accept-Encoding" | "Accept-Language" | "Authorization" | "Cache-Control" | "Connection" | "Content-Length" | "Content-MD5" | "Content-Type" | "Cookie" | "Date" | "Expect" | "From" | "Host" | "If-Match" | "If-Modified-Since" | "If-None-Match" | "If-Range" | "If-Unmodified-Since" | "Max-Forwards" | "Pragma" | "Proxy-Authorization" | "Range" | "Referer" | "TE" | "Upgrade" | "User-Agent" | "Via" | "Warning";
|
|
14
|
+
type HttpResponseHeader = "Accept-Ranges" | "Age" | "Allow" | "Cache-Control" | "Connection" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-MD5" | "Content-Range" | "Content-Type" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Link" | "Location" | "P3P" | "Pragma" | "Proxy-Authenticate" | "Refresh" | "Retry-After" | "Server" | "Set-Cookie" | "Strict-Transport-Security" | "Trailer" | "Transfer-Encoding" | "Vary" | "Via" | "Warning" | "WWW-Authenticate";
|
|
15
|
+
declare const Accept: HttpRequestHeader;
|
|
16
|
+
declare const AcceptCharset: HttpRequestHeader;
|
|
17
|
+
declare const AcceptDatetime: HttpRequestHeader;
|
|
18
|
+
declare const AcceptEncoding: HttpRequestHeader;
|
|
19
|
+
declare const AcceptLanguage: HttpRequestHeader;
|
|
20
|
+
declare const AcceptRanges: HttpResponseHeader;
|
|
21
|
+
declare const Age: HttpResponseHeader;
|
|
22
|
+
declare const Allow: HttpResponseHeader;
|
|
23
|
+
declare const Authorization: HttpRequestHeader;
|
|
24
|
+
declare const CacheControl: HttpRequestHeader | HttpResponseHeader;
|
|
25
|
+
declare const Connection: HttpRequestHeader | HttpResponseHeader;
|
|
26
|
+
declare const ContentDisposition: HttpResponseHeader;
|
|
27
|
+
declare const ContentEncoding: HttpResponseHeader;
|
|
28
|
+
declare const ContentLanguage: HttpResponseHeader;
|
|
29
|
+
declare const ContentLength: HttpRequestHeader | HttpResponseHeader;
|
|
30
|
+
declare const ContentLocation: HttpResponseHeader;
|
|
31
|
+
declare const ContentMd5: HttpRequestHeader | HttpResponseHeader;
|
|
32
|
+
declare const ContentRange: HttpResponseHeader;
|
|
33
|
+
declare const ContentType: HttpRequestHeader | HttpResponseHeader;
|
|
34
|
+
declare const Cookie: HttpRequestHeader;
|
|
35
|
+
declare const DateTime: HttpRequestHeader | HttpResponseHeader;
|
|
36
|
+
declare const ETag: HttpResponseHeader;
|
|
37
|
+
declare const Expect: HttpRequestHeader;
|
|
38
|
+
declare const Expires: HttpResponseHeader;
|
|
39
|
+
declare const From: HttpRequestHeader;
|
|
40
|
+
declare const Host: HttpRequestHeader;
|
|
41
|
+
declare const IfMatch: HttpRequestHeader;
|
|
42
|
+
declare const IfModifiedSince: HttpRequestHeader;
|
|
43
|
+
declare const IfNoneMatch: HttpRequestHeader;
|
|
44
|
+
declare const IfRange: HttpRequestHeader;
|
|
45
|
+
declare const IfunmodifiedSince: HttpRequestHeader;
|
|
46
|
+
declare const LastModified: HttpResponseHeader;
|
|
47
|
+
declare const Link: HttpResponseHeader;
|
|
48
|
+
declare const LocationUri: HttpResponseHeader;
|
|
49
|
+
declare const MaxForwards: HttpRequestHeader;
|
|
50
|
+
declare const P3P: HttpResponseHeader;
|
|
51
|
+
declare const Pragma: HttpRequestHeader | HttpResponseHeader;
|
|
52
|
+
declare const ProxyAuthenticate: HttpResponseHeader;
|
|
53
|
+
declare const ProxyAuthorization: HttpRequestHeader;
|
|
54
|
+
declare const Ranges: HttpRequestHeader;
|
|
55
|
+
declare const Referer: HttpRequestHeader;
|
|
56
|
+
declare const Referrer: HttpRequestHeader;
|
|
57
|
+
declare const Refresh: HttpResponseHeader;
|
|
58
|
+
declare const RetryAfter: HttpResponseHeader;
|
|
59
|
+
declare const Server: HttpResponseHeader;
|
|
60
|
+
declare const SetCookie: HttpResponseHeader;
|
|
61
|
+
declare const StrictTransportSecurity: HttpResponseHeader;
|
|
62
|
+
declare const TE: HttpRequestHeader;
|
|
63
|
+
declare const Trailer: HttpResponseHeader;
|
|
64
|
+
declare const TransferEncodingRequest: HttpRequestHeader;
|
|
65
|
+
declare const TransferEncodingResponse: HttpResponseHeader;
|
|
66
|
+
declare const Upgrade: HttpRequestHeader;
|
|
67
|
+
declare const UserAgent: HttpRequestHeader;
|
|
68
|
+
declare const Vary: HttpResponseHeader;
|
|
69
|
+
declare const Via: HttpRequestHeader | HttpResponseHeader;
|
|
70
|
+
declare const Warning: HttpRequestHeader | HttpResponseHeader;
|
|
71
|
+
declare const WwwAuthenticate: HttpResponseHeader;
|
|
72
|
+
|
|
73
|
+
type HttpStatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
74
|
+
declare const Continue: HttpStatusCode;
|
|
75
|
+
declare const SwitchingProtocols: HttpStatusCode;
|
|
76
|
+
declare const Processing: HttpStatusCode;
|
|
77
|
+
declare const EarlyHints: HttpStatusCode;
|
|
78
|
+
declare const Ok: HttpStatusCode;
|
|
79
|
+
declare const Created: HttpStatusCode;
|
|
80
|
+
declare const Accepted: HttpStatusCode;
|
|
81
|
+
declare const NonAuthoritativeInformation: HttpStatusCode;
|
|
82
|
+
declare const NoContent: HttpStatusCode;
|
|
83
|
+
declare const ResetContent: HttpStatusCode;
|
|
84
|
+
declare const PartialContent: HttpStatusCode;
|
|
85
|
+
declare const MultiStatus: HttpStatusCode;
|
|
86
|
+
declare const AlreadyReported: HttpStatusCode;
|
|
87
|
+
declare const ImUsed: HttpStatusCode;
|
|
88
|
+
declare const MultipleChoices: HttpStatusCode;
|
|
89
|
+
declare const MovedPermanently: HttpStatusCode;
|
|
90
|
+
declare const Found: HttpStatusCode;
|
|
91
|
+
declare const SeeOther: HttpStatusCode;
|
|
92
|
+
declare const NotModified: HttpStatusCode;
|
|
93
|
+
declare const UseProxyDeprecated: HttpStatusCode;
|
|
94
|
+
declare const TemporaryRedirect: HttpStatusCode;
|
|
95
|
+
declare const PermanentRedirect: HttpStatusCode;
|
|
96
|
+
declare const BadRequest: HttpStatusCode;
|
|
97
|
+
declare const Unauthorized: HttpStatusCode;
|
|
98
|
+
declare const PaymentRequired: HttpStatusCode;
|
|
99
|
+
declare const Forbidden: HttpStatusCode;
|
|
100
|
+
declare const NotFound: HttpStatusCode;
|
|
101
|
+
declare const MethodNotAllowed: HttpStatusCode;
|
|
102
|
+
declare const NotAcceptable: HttpStatusCode;
|
|
103
|
+
declare const ProxyAuthenticationRequired: HttpStatusCode;
|
|
104
|
+
declare const RequestTimeout: HttpStatusCode;
|
|
105
|
+
declare const Conflict: HttpStatusCode;
|
|
106
|
+
declare const Gone: HttpStatusCode;
|
|
107
|
+
declare const LengthRequired: HttpStatusCode;
|
|
108
|
+
declare const PreconditionFailed: HttpStatusCode;
|
|
109
|
+
declare const PayloadTooLarge: HttpStatusCode;
|
|
110
|
+
declare const UriTooLong: HttpStatusCode;
|
|
111
|
+
declare const UnsupportedMediaType: HttpStatusCode;
|
|
112
|
+
declare const RangeNotSatisfiable: HttpStatusCode;
|
|
113
|
+
declare const ExpectationFailed: HttpStatusCode;
|
|
114
|
+
declare const ImATeapot: HttpStatusCode;
|
|
115
|
+
declare const MisdirectedRequest: HttpStatusCode;
|
|
116
|
+
declare const UnprocessableContent: HttpStatusCode;
|
|
117
|
+
declare const Locked: HttpStatusCode;
|
|
118
|
+
declare const FailedDependency: HttpStatusCode;
|
|
119
|
+
declare const TooEarly: HttpStatusCode;
|
|
120
|
+
declare const UpgradeRequired: HttpStatusCode;
|
|
121
|
+
declare const PreconditionRequired: HttpStatusCode;
|
|
122
|
+
declare const TooManyRequests: HttpStatusCode;
|
|
123
|
+
declare const RequestHeaderFieldsTooLarge: HttpStatusCode;
|
|
124
|
+
declare const UnavailableForLegalReasons: HttpStatusCode;
|
|
125
|
+
declare const InternalServerError: HttpStatusCode;
|
|
126
|
+
declare const NotImplemented: HttpStatusCode;
|
|
127
|
+
declare const BadGateway: HttpStatusCode;
|
|
128
|
+
declare const ServiceUnavailable: HttpStatusCode;
|
|
129
|
+
declare const GatewayTimeout: HttpStatusCode;
|
|
130
|
+
declare const HttpVersionNotSupported: HttpStatusCode;
|
|
131
|
+
declare const VariantAlsoNegotiates: HttpStatusCode;
|
|
132
|
+
declare const InsufficientStorage: HttpStatusCode;
|
|
133
|
+
declare const LoopDetected: HttpStatusCode;
|
|
134
|
+
declare const NotExtended: HttpStatusCode;
|
|
135
|
+
declare const NetworkAuthenticationRequired: HttpStatusCode;
|
|
136
|
+
declare const httpStatusCodeSchema: z.ZodNumber;
|
|
137
|
+
declare const clientErrorHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
138
|
+
declare const serverErrorHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
139
|
+
declare const successHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
140
|
+
declare const isHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
141
|
+
declare const isClientErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
142
|
+
declare const isServerErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
143
|
+
declare const isSuccessHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
144
|
+
|
|
145
|
+
export { Accept, AcceptCharset, AcceptDatetime, AcceptEncoding, AcceptLanguage, AcceptRanges, Accepted, Age, Allow, AlreadyReported, Authorization, type AuthorizationToken, BadGateway, BadRequest, CacheControl, Conflict, Connection, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentLocation, ContentMd5, ContentRange, ContentType, Continue, Cookie, Created, DateTime, ETag, EarlyHints, Expect, ExpectationFailed, Expires, FailedDependency, Forbidden, Found, From, GatewayTimeout, Gone, Host, type HttpRequestHeader, type HttpResponseHeader, type HttpStatusCode, HttpVersionNotSupported, IfMatch, IfModifiedSince, IfNoneMatch, IfRange, IfunmodifiedSince, ImATeapot, ImUsed, InsufficientStorage, InternalServerError, LastModified, LengthRequired, Link, LocationUri, Locked, LoopDetected, MaxForwards, MethodNotAllowed, MisdirectedRequest, MovedPermanently, MultiStatus, MultipleChoices, NetworkAuthenticationRequired, NoContent, NonAuthoritativeInformation, NotAcceptable, NotExtended, NotFound, NotImplemented, NotModified, Ok, P3P, PartialContent, PayloadTooLarge, PaymentRequired, PermanentRedirect, Pragma, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticate, ProxyAuthenticationRequired, ProxyAuthorization, RangeNotSatisfiable, Ranges, Referer, Referrer, Refresh, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, RetryAfter, SeeOther, Server, ServiceUnavailable, SetCookie, StrictTransportSecurity, SwitchingProtocols, TE, TemporaryRedirect, TooEarly, TooManyRequests, Trailer, TransferEncodingRequest, TransferEncodingResponse, Unauthorized, UnavailableForLegalReasons, UnprocessableContent, UnsupportedMediaType, Upgrade, UpgradeRequired, UriTooLong, UseProxyDeprecated, UserAgent, VariantAlsoNegotiates, Vary, Via, Warning, WwwAuthenticate, clientErrorHttpStatusCodeSchema, getAuthorizationHeader, getQueryParameters, httpStatusCodeSchema, isClientErrorHttpStatusCode, isExpired, isHttpStatusCode, isServerErrorHttpStatusCode, isSuccessHttpStatusCode, serverErrorHttpStatusCodeSchema, successHttpStatusCodeSchema };
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface AuthorizationToken {
|
|
4
|
+
expiresOn: number;
|
|
5
|
+
tokenType: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
declare const getAuthorizationHeader: (token: AuthorizationToken) => string;
|
|
9
|
+
declare const isExpired: (token: AuthorizationToken) => boolean;
|
|
10
|
+
|
|
11
|
+
declare const getQueryParameters: (url: string | URL) => URLSearchParams;
|
|
12
|
+
|
|
13
|
+
type HttpRequestHeader = "Accept" | "Accept-Charset" | "Accept-Datetime" | "Accept-Encoding" | "Accept-Language" | "Authorization" | "Cache-Control" | "Connection" | "Content-Length" | "Content-MD5" | "Content-Type" | "Cookie" | "Date" | "Expect" | "From" | "Host" | "If-Match" | "If-Modified-Since" | "If-None-Match" | "If-Range" | "If-Unmodified-Since" | "Max-Forwards" | "Pragma" | "Proxy-Authorization" | "Range" | "Referer" | "TE" | "Upgrade" | "User-Agent" | "Via" | "Warning";
|
|
14
|
+
type HttpResponseHeader = "Accept-Ranges" | "Age" | "Allow" | "Cache-Control" | "Connection" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-MD5" | "Content-Range" | "Content-Type" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Link" | "Location" | "P3P" | "Pragma" | "Proxy-Authenticate" | "Refresh" | "Retry-After" | "Server" | "Set-Cookie" | "Strict-Transport-Security" | "Trailer" | "Transfer-Encoding" | "Vary" | "Via" | "Warning" | "WWW-Authenticate";
|
|
15
|
+
declare const Accept: HttpRequestHeader;
|
|
16
|
+
declare const AcceptCharset: HttpRequestHeader;
|
|
17
|
+
declare const AcceptDatetime: HttpRequestHeader;
|
|
18
|
+
declare const AcceptEncoding: HttpRequestHeader;
|
|
19
|
+
declare const AcceptLanguage: HttpRequestHeader;
|
|
20
|
+
declare const AcceptRanges: HttpResponseHeader;
|
|
21
|
+
declare const Age: HttpResponseHeader;
|
|
22
|
+
declare const Allow: HttpResponseHeader;
|
|
23
|
+
declare const Authorization: HttpRequestHeader;
|
|
24
|
+
declare const CacheControl: HttpRequestHeader | HttpResponseHeader;
|
|
25
|
+
declare const Connection: HttpRequestHeader | HttpResponseHeader;
|
|
26
|
+
declare const ContentDisposition: HttpResponseHeader;
|
|
27
|
+
declare const ContentEncoding: HttpResponseHeader;
|
|
28
|
+
declare const ContentLanguage: HttpResponseHeader;
|
|
29
|
+
declare const ContentLength: HttpRequestHeader | HttpResponseHeader;
|
|
30
|
+
declare const ContentLocation: HttpResponseHeader;
|
|
31
|
+
declare const ContentMd5: HttpRequestHeader | HttpResponseHeader;
|
|
32
|
+
declare const ContentRange: HttpResponseHeader;
|
|
33
|
+
declare const ContentType: HttpRequestHeader | HttpResponseHeader;
|
|
34
|
+
declare const Cookie: HttpRequestHeader;
|
|
35
|
+
declare const DateTime: HttpRequestHeader | HttpResponseHeader;
|
|
36
|
+
declare const ETag: HttpResponseHeader;
|
|
37
|
+
declare const Expect: HttpRequestHeader;
|
|
38
|
+
declare const Expires: HttpResponseHeader;
|
|
39
|
+
declare const From: HttpRequestHeader;
|
|
40
|
+
declare const Host: HttpRequestHeader;
|
|
41
|
+
declare const IfMatch: HttpRequestHeader;
|
|
42
|
+
declare const IfModifiedSince: HttpRequestHeader;
|
|
43
|
+
declare const IfNoneMatch: HttpRequestHeader;
|
|
44
|
+
declare const IfRange: HttpRequestHeader;
|
|
45
|
+
declare const IfunmodifiedSince: HttpRequestHeader;
|
|
46
|
+
declare const LastModified: HttpResponseHeader;
|
|
47
|
+
declare const Link: HttpResponseHeader;
|
|
48
|
+
declare const LocationUri: HttpResponseHeader;
|
|
49
|
+
declare const MaxForwards: HttpRequestHeader;
|
|
50
|
+
declare const P3P: HttpResponseHeader;
|
|
51
|
+
declare const Pragma: HttpRequestHeader | HttpResponseHeader;
|
|
52
|
+
declare const ProxyAuthenticate: HttpResponseHeader;
|
|
53
|
+
declare const ProxyAuthorization: HttpRequestHeader;
|
|
54
|
+
declare const Ranges: HttpRequestHeader;
|
|
55
|
+
declare const Referer: HttpRequestHeader;
|
|
56
|
+
declare const Referrer: HttpRequestHeader;
|
|
57
|
+
declare const Refresh: HttpResponseHeader;
|
|
58
|
+
declare const RetryAfter: HttpResponseHeader;
|
|
59
|
+
declare const Server: HttpResponseHeader;
|
|
60
|
+
declare const SetCookie: HttpResponseHeader;
|
|
61
|
+
declare const StrictTransportSecurity: HttpResponseHeader;
|
|
62
|
+
declare const TE: HttpRequestHeader;
|
|
63
|
+
declare const Trailer: HttpResponseHeader;
|
|
64
|
+
declare const TransferEncodingRequest: HttpRequestHeader;
|
|
65
|
+
declare const TransferEncodingResponse: HttpResponseHeader;
|
|
66
|
+
declare const Upgrade: HttpRequestHeader;
|
|
67
|
+
declare const UserAgent: HttpRequestHeader;
|
|
68
|
+
declare const Vary: HttpResponseHeader;
|
|
69
|
+
declare const Via: HttpRequestHeader | HttpResponseHeader;
|
|
70
|
+
declare const Warning: HttpRequestHeader | HttpResponseHeader;
|
|
71
|
+
declare const WwwAuthenticate: HttpResponseHeader;
|
|
72
|
+
|
|
73
|
+
type HttpStatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
74
|
+
declare const Continue: HttpStatusCode;
|
|
75
|
+
declare const SwitchingProtocols: HttpStatusCode;
|
|
76
|
+
declare const Processing: HttpStatusCode;
|
|
77
|
+
declare const EarlyHints: HttpStatusCode;
|
|
78
|
+
declare const Ok: HttpStatusCode;
|
|
79
|
+
declare const Created: HttpStatusCode;
|
|
80
|
+
declare const Accepted: HttpStatusCode;
|
|
81
|
+
declare const NonAuthoritativeInformation: HttpStatusCode;
|
|
82
|
+
declare const NoContent: HttpStatusCode;
|
|
83
|
+
declare const ResetContent: HttpStatusCode;
|
|
84
|
+
declare const PartialContent: HttpStatusCode;
|
|
85
|
+
declare const MultiStatus: HttpStatusCode;
|
|
86
|
+
declare const AlreadyReported: HttpStatusCode;
|
|
87
|
+
declare const ImUsed: HttpStatusCode;
|
|
88
|
+
declare const MultipleChoices: HttpStatusCode;
|
|
89
|
+
declare const MovedPermanently: HttpStatusCode;
|
|
90
|
+
declare const Found: HttpStatusCode;
|
|
91
|
+
declare const SeeOther: HttpStatusCode;
|
|
92
|
+
declare const NotModified: HttpStatusCode;
|
|
93
|
+
declare const UseProxyDeprecated: HttpStatusCode;
|
|
94
|
+
declare const TemporaryRedirect: HttpStatusCode;
|
|
95
|
+
declare const PermanentRedirect: HttpStatusCode;
|
|
96
|
+
declare const BadRequest: HttpStatusCode;
|
|
97
|
+
declare const Unauthorized: HttpStatusCode;
|
|
98
|
+
declare const PaymentRequired: HttpStatusCode;
|
|
99
|
+
declare const Forbidden: HttpStatusCode;
|
|
100
|
+
declare const NotFound: HttpStatusCode;
|
|
101
|
+
declare const MethodNotAllowed: HttpStatusCode;
|
|
102
|
+
declare const NotAcceptable: HttpStatusCode;
|
|
103
|
+
declare const ProxyAuthenticationRequired: HttpStatusCode;
|
|
104
|
+
declare const RequestTimeout: HttpStatusCode;
|
|
105
|
+
declare const Conflict: HttpStatusCode;
|
|
106
|
+
declare const Gone: HttpStatusCode;
|
|
107
|
+
declare const LengthRequired: HttpStatusCode;
|
|
108
|
+
declare const PreconditionFailed: HttpStatusCode;
|
|
109
|
+
declare const PayloadTooLarge: HttpStatusCode;
|
|
110
|
+
declare const UriTooLong: HttpStatusCode;
|
|
111
|
+
declare const UnsupportedMediaType: HttpStatusCode;
|
|
112
|
+
declare const RangeNotSatisfiable: HttpStatusCode;
|
|
113
|
+
declare const ExpectationFailed: HttpStatusCode;
|
|
114
|
+
declare const ImATeapot: HttpStatusCode;
|
|
115
|
+
declare const MisdirectedRequest: HttpStatusCode;
|
|
116
|
+
declare const UnprocessableContent: HttpStatusCode;
|
|
117
|
+
declare const Locked: HttpStatusCode;
|
|
118
|
+
declare const FailedDependency: HttpStatusCode;
|
|
119
|
+
declare const TooEarly: HttpStatusCode;
|
|
120
|
+
declare const UpgradeRequired: HttpStatusCode;
|
|
121
|
+
declare const PreconditionRequired: HttpStatusCode;
|
|
122
|
+
declare const TooManyRequests: HttpStatusCode;
|
|
123
|
+
declare const RequestHeaderFieldsTooLarge: HttpStatusCode;
|
|
124
|
+
declare const UnavailableForLegalReasons: HttpStatusCode;
|
|
125
|
+
declare const InternalServerError: HttpStatusCode;
|
|
126
|
+
declare const NotImplemented: HttpStatusCode;
|
|
127
|
+
declare const BadGateway: HttpStatusCode;
|
|
128
|
+
declare const ServiceUnavailable: HttpStatusCode;
|
|
129
|
+
declare const GatewayTimeout: HttpStatusCode;
|
|
130
|
+
declare const HttpVersionNotSupported: HttpStatusCode;
|
|
131
|
+
declare const VariantAlsoNegotiates: HttpStatusCode;
|
|
132
|
+
declare const InsufficientStorage: HttpStatusCode;
|
|
133
|
+
declare const LoopDetected: HttpStatusCode;
|
|
134
|
+
declare const NotExtended: HttpStatusCode;
|
|
135
|
+
declare const NetworkAuthenticationRequired: HttpStatusCode;
|
|
136
|
+
declare const httpStatusCodeSchema: z.ZodNumber;
|
|
137
|
+
declare const clientErrorHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
138
|
+
declare const serverErrorHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
139
|
+
declare const successHttpStatusCodeSchema: z.ZodIntersection<z.ZodNumber, z.ZodNumber>;
|
|
140
|
+
declare const isHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
141
|
+
declare const isClientErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
142
|
+
declare const isServerErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
143
|
+
declare const isSuccessHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
|
|
144
|
+
|
|
145
|
+
export { Accept, AcceptCharset, AcceptDatetime, AcceptEncoding, AcceptLanguage, AcceptRanges, Accepted, Age, Allow, AlreadyReported, Authorization, type AuthorizationToken, BadGateway, BadRequest, CacheControl, Conflict, Connection, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentLocation, ContentMd5, ContentRange, ContentType, Continue, Cookie, Created, DateTime, ETag, EarlyHints, Expect, ExpectationFailed, Expires, FailedDependency, Forbidden, Found, From, GatewayTimeout, Gone, Host, type HttpRequestHeader, type HttpResponseHeader, type HttpStatusCode, HttpVersionNotSupported, IfMatch, IfModifiedSince, IfNoneMatch, IfRange, IfunmodifiedSince, ImATeapot, ImUsed, InsufficientStorage, InternalServerError, LastModified, LengthRequired, Link, LocationUri, Locked, LoopDetected, MaxForwards, MethodNotAllowed, MisdirectedRequest, MovedPermanently, MultiStatus, MultipleChoices, NetworkAuthenticationRequired, NoContent, NonAuthoritativeInformation, NotAcceptable, NotExtended, NotFound, NotImplemented, NotModified, Ok, P3P, PartialContent, PayloadTooLarge, PaymentRequired, PermanentRedirect, Pragma, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticate, ProxyAuthenticationRequired, ProxyAuthorization, RangeNotSatisfiable, Ranges, Referer, Referrer, Refresh, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, RetryAfter, SeeOther, Server, ServiceUnavailable, SetCookie, StrictTransportSecurity, SwitchingProtocols, TE, TemporaryRedirect, TooEarly, TooManyRequests, Trailer, TransferEncodingRequest, TransferEncodingResponse, Unauthorized, UnavailableForLegalReasons, UnprocessableContent, UnsupportedMediaType, Upgrade, UpgradeRequired, UriTooLong, UseProxyDeprecated, UserAgent, VariantAlsoNegotiates, Vary, Via, Warning, WwwAuthenticate, clientErrorHttpStatusCodeSchema, getAuthorizationHeader, getQueryParameters, httpStatusCodeSchema, isClientErrorHttpStatusCode, isExpired, isHttpStatusCode, isServerErrorHttpStatusCode, isSuccessHttpStatusCode, serverErrorHttpStatusCodeSchema, successHttpStatusCodeSchema };
|