@ekumlin/typescript-toolkit 1.0.0 → 1.0.1

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/http.d.mts CHANGED
@@ -70,6 +70,17 @@ declare const Via: HttpRequestHeader | HttpResponseHeader;
70
70
  declare const Warning: HttpRequestHeader | HttpResponseHeader;
71
71
  declare const WwwAuthenticate: HttpResponseHeader;
72
72
 
73
+ type HttpMethod = "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE";
74
+ declare const Connect: HttpMethod;
75
+ declare const Delete: HttpMethod;
76
+ declare const Get: HttpMethod;
77
+ declare const Head: HttpMethod;
78
+ declare const Options: HttpMethod;
79
+ declare const Patch: HttpMethod;
80
+ declare const Post: HttpMethod;
81
+ declare const Put: HttpMethod;
82
+ declare const Trace: HttpMethod;
83
+
73
84
  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
85
  declare const Continue: HttpStatusCode;
75
86
  declare const SwitchingProtocols: HttpStatusCode;
@@ -142,4 +153,4 @@ declare const isClientErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCo
142
153
  declare const isServerErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
143
154
  declare const isSuccessHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
144
155
 
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 };
156
+ export { Accept, AcceptCharset, AcceptDatetime, AcceptEncoding, AcceptLanguage, AcceptRanges, Accepted, Age, Allow, AlreadyReported, Authorization, type AuthorizationToken, BadGateway, BadRequest, CacheControl, Conflict, Connect, Connection, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentLocation, ContentMd5, ContentRange, ContentType, Continue, Cookie, Created, DateTime, Delete, ETag, EarlyHints, Expect, ExpectationFailed, Expires, FailedDependency, Forbidden, Found, From, GatewayTimeout, Get, Gone, Head, Host, type HttpMethod, 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, Options, P3P, PartialContent, Patch, PayloadTooLarge, PaymentRequired, PermanentRedirect, Post, Pragma, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticate, ProxyAuthenticationRequired, ProxyAuthorization, Put, RangeNotSatisfiable, Ranges, Referer, Referrer, Refresh, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, RetryAfter, SeeOther, Server, ServiceUnavailable, SetCookie, StrictTransportSecurity, SwitchingProtocols, TE, TemporaryRedirect, TooEarly, TooManyRequests, Trace, 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 CHANGED
@@ -70,6 +70,17 @@ declare const Via: HttpRequestHeader | HttpResponseHeader;
70
70
  declare const Warning: HttpRequestHeader | HttpResponseHeader;
71
71
  declare const WwwAuthenticate: HttpResponseHeader;
72
72
 
73
+ type HttpMethod = "CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE";
74
+ declare const Connect: HttpMethod;
75
+ declare const Delete: HttpMethod;
76
+ declare const Get: HttpMethod;
77
+ declare const Head: HttpMethod;
78
+ declare const Options: HttpMethod;
79
+ declare const Patch: HttpMethod;
80
+ declare const Post: HttpMethod;
81
+ declare const Put: HttpMethod;
82
+ declare const Trace: HttpMethod;
83
+
73
84
  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
85
  declare const Continue: HttpStatusCode;
75
86
  declare const SwitchingProtocols: HttpStatusCode;
@@ -142,4 +153,4 @@ declare const isClientErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCo
142
153
  declare const isServerErrorHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
143
154
  declare const isSuccessHttpStatusCode: (obj: unknown) => obj is HttpStatusCode;
144
155
 
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 };
156
+ export { Accept, AcceptCharset, AcceptDatetime, AcceptEncoding, AcceptLanguage, AcceptRanges, Accepted, Age, Allow, AlreadyReported, Authorization, type AuthorizationToken, BadGateway, BadRequest, CacheControl, Conflict, Connect, Connection, ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentLocation, ContentMd5, ContentRange, ContentType, Continue, Cookie, Created, DateTime, Delete, ETag, EarlyHints, Expect, ExpectationFailed, Expires, FailedDependency, Forbidden, Found, From, GatewayTimeout, Get, Gone, Head, Host, type HttpMethod, 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, Options, P3P, PartialContent, Patch, PayloadTooLarge, PaymentRequired, PermanentRedirect, Post, Pragma, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticate, ProxyAuthenticationRequired, ProxyAuthorization, Put, RangeNotSatisfiable, Ranges, Referer, Referrer, Refresh, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, RetryAfter, SeeOther, Server, ServiceUnavailable, SetCookie, StrictTransportSecurity, SwitchingProtocols, TE, TemporaryRedirect, TooEarly, TooManyRequests, Trace, 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.js CHANGED
@@ -35,6 +35,7 @@ __export(http_exports, {
35
35
  BadRequest: () => BadRequest,
36
36
  CacheControl: () => CacheControl,
37
37
  Conflict: () => Conflict,
38
+ Connect: () => Connect,
38
39
  Connection: () => Connection,
39
40
  ContentDisposition: () => ContentDisposition,
40
41
  ContentEncoding: () => ContentEncoding,
@@ -48,6 +49,7 @@ __export(http_exports, {
48
49
  Cookie: () => Cookie,
49
50
  Created: () => Created,
50
51
  DateTime: () => DateTime,
52
+ Delete: () => Delete,
51
53
  ETag: () => ETag,
52
54
  EarlyHints: () => EarlyHints,
53
55
  Expect: () => Expect,
@@ -58,7 +60,9 @@ __export(http_exports, {
58
60
  Found: () => Found,
59
61
  From: () => From,
60
62
  GatewayTimeout: () => GatewayTimeout,
63
+ Get: () => Get,
61
64
  Gone: () => Gone,
65
+ Head: () => Head,
62
66
  Host: () => Host,
63
67
  HttpVersionNotSupported: () => HttpVersionNotSupported,
64
68
  IfMatch: () => IfMatch,
@@ -91,11 +95,14 @@ __export(http_exports, {
91
95
  NotImplemented: () => NotImplemented,
92
96
  NotModified: () => NotModified,
93
97
  Ok: () => Ok,
98
+ Options: () => Options,
94
99
  P3P: () => P3P,
95
100
  PartialContent: () => PartialContent,
101
+ Patch: () => Patch,
96
102
  PayloadTooLarge: () => PayloadTooLarge,
97
103
  PaymentRequired: () => PaymentRequired,
98
104
  PermanentRedirect: () => PermanentRedirect,
105
+ Post: () => Post,
99
106
  Pragma: () => Pragma,
100
107
  PreconditionFailed: () => PreconditionFailed,
101
108
  PreconditionRequired: () => PreconditionRequired,
@@ -103,6 +110,7 @@ __export(http_exports, {
103
110
  ProxyAuthenticate: () => ProxyAuthenticate,
104
111
  ProxyAuthenticationRequired: () => ProxyAuthenticationRequired,
105
112
  ProxyAuthorization: () => ProxyAuthorization,
113
+ Put: () => Put,
106
114
  RangeNotSatisfiable: () => RangeNotSatisfiable,
107
115
  Ranges: () => Ranges,
108
116
  Referer: () => Referer,
@@ -122,6 +130,7 @@ __export(http_exports, {
122
130
  TemporaryRedirect: () => TemporaryRedirect,
123
131
  TooEarly: () => TooEarly,
124
132
  TooManyRequests: () => TooManyRequests,
133
+ Trace: () => Trace,
125
134
  Trailer: () => Trailer,
126
135
  TransferEncodingRequest: () => TransferEncodingRequest,
127
136
  TransferEncodingResponse: () => TransferEncodingResponse,
@@ -225,6 +234,17 @@ var Via = "Via";
225
234
  var Warning = "Warning";
226
235
  var WwwAuthenticate = "WWW-Authenticate";
227
236
 
237
+ // src/http/httpMethods.ts
238
+ var Connect = "CONNECT";
239
+ var Delete = "DELETE";
240
+ var Get = "GET";
241
+ var Head = "HEAD";
242
+ var Options = "OPTIONS";
243
+ var Patch = "PATCH";
244
+ var Post = "POST";
245
+ var Put = "PUT";
246
+ var Trace = "TRACE";
247
+
228
248
  // src/http/httpStatusCodes.ts
229
249
  var import_zod = require("zod");
230
250
  var Continue = 100;
@@ -320,6 +340,7 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
320
340
  BadRequest,
321
341
  CacheControl,
322
342
  Conflict,
343
+ Connect,
323
344
  Connection,
324
345
  ContentDisposition,
325
346
  ContentEncoding,
@@ -333,6 +354,7 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
333
354
  Cookie,
334
355
  Created,
335
356
  DateTime,
357
+ Delete,
336
358
  ETag,
337
359
  EarlyHints,
338
360
  Expect,
@@ -343,7 +365,9 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
343
365
  Found,
344
366
  From,
345
367
  GatewayTimeout,
368
+ Get,
346
369
  Gone,
370
+ Head,
347
371
  Host,
348
372
  HttpVersionNotSupported,
349
373
  IfMatch,
@@ -376,11 +400,14 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
376
400
  NotImplemented,
377
401
  NotModified,
378
402
  Ok,
403
+ Options,
379
404
  P3P,
380
405
  PartialContent,
406
+ Patch,
381
407
  PayloadTooLarge,
382
408
  PaymentRequired,
383
409
  PermanentRedirect,
410
+ Post,
384
411
  Pragma,
385
412
  PreconditionFailed,
386
413
  PreconditionRequired,
@@ -388,6 +415,7 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
388
415
  ProxyAuthenticate,
389
416
  ProxyAuthenticationRequired,
390
417
  ProxyAuthorization,
418
+ Put,
391
419
  RangeNotSatisfiable,
392
420
  Ranges,
393
421
  Referer,
@@ -407,6 +435,7 @@ var isSuccessHttpStatusCode = (obj) => successHttpStatusCodeSchema.safeParse(obj
407
435
  TemporaryRedirect,
408
436
  TooEarly,
409
437
  TooManyRequests,
438
+ Trace,
410
439
  Trailer,
411
440
  TransferEncodingRequest,
412
441
  TransferEncodingResponse,
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/http/index.ts","../src/http/authorizationToken.ts","../src/http/getQueryParameters.ts","../src/http/httpHeaders.ts","../src/http/httpStatusCodes.ts"],"sourcesContent":["export * from \"./authorizationToken\";\nexport * from \"./getQueryParameters\";\nexport * from \"./httpHeaders\";\nexport * from \"./httpStatusCodes\";\n","export interface AuthorizationToken {\n\texpiresOn: number;\n\ttokenType: string;\n\tvalue: string;\n}\n\nexport const getAuthorizationHeader = (token: AuthorizationToken): string =>\n\t`${token.tokenType} ${token.value}`;\n\nexport const isExpired = (token: AuthorizationToken): boolean =>\n\ttoken.expiresOn < Date.now();\n","export const getQueryParameters = (url: string | URL): URLSearchParams => {\n\tconst urlString = url.toString();\n\n\tconst queryStringIndex = urlString.indexOf(\"?\");\n\tconst queryString =\n\t\tqueryStringIndex >= 0 ? urlString.substring(queryStringIndex) : \"\";\n\tconst query = new URLSearchParams(queryString);\n\n\treturn query;\n};\n","export type HttpRequestHeader =\n\t| \"Accept\"\n\t| \"Accept-Charset\"\n\t| \"Accept-Datetime\"\n\t| \"Accept-Encoding\"\n\t| \"Accept-Language\"\n\t| \"Authorization\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Length\"\n\t| \"Content-MD5\"\n\t| \"Content-Type\"\n\t| \"Cookie\"\n\t| \"Date\"\n\t| \"Expect\"\n\t| \"From\"\n\t| \"Host\"\n\t| \"If-Match\"\n\t| \"If-Modified-Since\"\n\t| \"If-None-Match\"\n\t| \"If-Range\"\n\t| \"If-Unmodified-Since\"\n\t| \"Max-Forwards\"\n\t| \"Pragma\"\n\t| \"Proxy-Authorization\"\n\t| \"Range\"\n\t| \"Referer\"\n\t| \"TE\"\n\t| \"Upgrade\"\n\t| \"User-Agent\"\n\t| \"Via\"\n\t| \"Warning\";\n\nexport type HttpResponseHeader =\n\t| \"Accept-Ranges\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-MD5\"\n\t| \"Content-Range\"\n\t| \"Content-Type\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Link\"\n\t| \"Location\"\n\t| \"P3P\"\n\t| \"Pragma\"\n\t| \"Proxy-Authenticate\"\n\t| \"Refresh\"\n\t| \"Retry-After\"\n\t| \"Server\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Vary\"\n\t| \"Via\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\";\n\nexport const Accept: HttpRequestHeader = \"Accept\";\nexport const AcceptCharset: HttpRequestHeader = \"Accept-Charset\";\nexport const AcceptDatetime: HttpRequestHeader = \"Accept-Datetime\";\nexport const AcceptEncoding: HttpRequestHeader = \"Accept-Encoding\";\nexport const AcceptLanguage: HttpRequestHeader = \"Accept-Language\";\nexport const AcceptRanges: HttpResponseHeader = \"Accept-Ranges\";\nexport const Age: HttpResponseHeader = \"Age\";\nexport const Allow: HttpResponseHeader = \"Allow\";\nexport const Authorization: HttpRequestHeader = \"Authorization\";\nexport const CacheControl: HttpRequestHeader | HttpResponseHeader =\n\t\"Cache-Control\";\nexport const Connection: HttpRequestHeader | HttpResponseHeader = \"Connection\";\nexport const ContentDisposition: HttpResponseHeader = \"Content-Disposition\";\nexport const ContentEncoding: HttpResponseHeader = \"Content-Encoding\";\nexport const ContentLanguage: HttpResponseHeader = \"Content-Language\";\nexport const ContentLength: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Length\";\nexport const ContentLocation: HttpResponseHeader = \"Content-Location\";\nexport const ContentMd5: HttpRequestHeader | HttpResponseHeader = \"Content-MD5\";\nexport const ContentRange: HttpResponseHeader = \"Content-Range\";\nexport const ContentType: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Type\";\nexport const Cookie: HttpRequestHeader = \"Cookie\";\nexport const DateTime: HttpRequestHeader | HttpResponseHeader = \"Date\";\nexport const ETag: HttpResponseHeader = \"ETag\";\nexport const Expect: HttpRequestHeader = \"Expect\";\nexport const Expires: HttpResponseHeader = \"Expires\";\nexport const From: HttpRequestHeader = \"From\";\nexport const Host: HttpRequestHeader = \"Host\";\nexport const IfMatch: HttpRequestHeader = \"If-Match\";\nexport const IfModifiedSince: HttpRequestHeader = \"If-Modified-Since\";\nexport const IfNoneMatch: HttpRequestHeader = \"If-None-Match\";\nexport const IfRange: HttpRequestHeader = \"If-Range\";\nexport const IfunmodifiedSince: HttpRequestHeader = \"If-Unmodified-Since\";\nexport const LastModified: HttpResponseHeader = \"Last-Modified\";\nexport const Link: HttpResponseHeader = \"Link\";\nexport const LocationUri: HttpResponseHeader = \"Location\";\nexport const MaxForwards: HttpRequestHeader = \"Max-Forwards\";\nexport const P3P: HttpResponseHeader = \"P3P\";\nexport const Pragma: HttpRequestHeader | HttpResponseHeader = \"Pragma\";\nexport const ProxyAuthenticate: HttpResponseHeader = \"Proxy-Authenticate\";\nexport const ProxyAuthorization: HttpRequestHeader = \"Proxy-Authorization\";\nexport const Ranges: HttpRequestHeader = \"Range\";\nexport const Referer: HttpRequestHeader = \"Referer\";\nexport const Referrer: HttpRequestHeader = Referer;\nexport const Refresh: HttpResponseHeader = \"Refresh\";\nexport const RetryAfter: HttpResponseHeader = \"Retry-After\";\nexport const Server: HttpResponseHeader = \"Server\";\nexport const SetCookie: HttpResponseHeader = \"Set-Cookie\";\nexport const StrictTransportSecurity: HttpResponseHeader =\n\t\"Strict-Transport-Security\";\nexport const TE: HttpRequestHeader = \"TE\";\nexport const Trailer: HttpResponseHeader = \"Trailer\";\nexport const TransferEncodingRequest: HttpRequestHeader = TE;\nexport const TransferEncodingResponse: HttpResponseHeader = \"Transfer-Encoding\";\nexport const Upgrade: HttpRequestHeader = \"Upgrade\";\nexport const UserAgent: HttpRequestHeader = \"User-Agent\";\nexport const Vary: HttpResponseHeader = \"Vary\";\nexport const Via: HttpRequestHeader | HttpResponseHeader = \"Via\";\nexport const Warning: HttpRequestHeader | HttpResponseHeader = \"Warning\";\nexport const WwwAuthenticate: HttpResponseHeader = \"WWW-Authenticate\";\n","import { z } from \"zod\";\n\nexport type HttpStatusCode =\n\t| 100\n\t| 101\n\t| 102\n\t| 103\n\t| 200\n\t| 201\n\t| 202\n\t| 203\n\t| 204\n\t| 205\n\t| 206\n\t| 207\n\t| 208\n\t| 226\n\t| 300\n\t| 301\n\t| 302\n\t| 303\n\t| 304\n\t| 305\n\t| 307\n\t| 308\n\t| 400\n\t| 401\n\t| 402\n\t| 403\n\t| 404\n\t| 405\n\t| 406\n\t| 407\n\t| 408\n\t| 409\n\t| 410\n\t| 411\n\t| 412\n\t| 413\n\t| 414\n\t| 415\n\t| 416\n\t| 417\n\t| 418\n\t| 421\n\t| 422\n\t| 423\n\t| 424\n\t| 425\n\t| 426\n\t| 428\n\t| 429\n\t| 431\n\t| 451\n\t| 500\n\t| 501\n\t| 502\n\t| 503\n\t| 504\n\t| 505\n\t| 506\n\t| 507\n\t| 508\n\t| 510\n\t| 511;\n\nexport const Continue: HttpStatusCode = 100 as const;\nexport const SwitchingProtocols: HttpStatusCode = 101 as const;\nexport const Processing: HttpStatusCode = 102 as const;\nexport const EarlyHints: HttpStatusCode = 103 as const;\nexport const Ok: HttpStatusCode = 200 as const;\nexport const Created: HttpStatusCode = 201 as const;\nexport const Accepted: HttpStatusCode = 202 as const;\nexport const NonAuthoritativeInformation: HttpStatusCode = 203 as const;\nexport const NoContent: HttpStatusCode = 204 as const;\nexport const ResetContent: HttpStatusCode = 205 as const;\nexport const PartialContent: HttpStatusCode = 206 as const;\nexport const MultiStatus: HttpStatusCode = 207 as const;\nexport const AlreadyReported: HttpStatusCode = 208 as const;\nexport const ImUsed: HttpStatusCode = 226 as const;\nexport const MultipleChoices: HttpStatusCode = 300 as const;\nexport const MovedPermanently: HttpStatusCode = 301 as const;\nexport const Found: HttpStatusCode = 302 as const;\nexport const SeeOther: HttpStatusCode = 303 as const;\nexport const NotModified: HttpStatusCode = 304 as const;\nexport const UseProxyDeprecated: HttpStatusCode = 305 as const;\nexport const TemporaryRedirect: HttpStatusCode = 307 as const;\nexport const PermanentRedirect: HttpStatusCode = 308 as const;\nexport const BadRequest: HttpStatusCode = 400 as const;\nexport const Unauthorized: HttpStatusCode = 401 as const;\nexport const PaymentRequired: HttpStatusCode = 402 as const;\nexport const Forbidden: HttpStatusCode = 403 as const;\nexport const NotFound: HttpStatusCode = 404 as const;\nexport const MethodNotAllowed: HttpStatusCode = 405 as const;\nexport const NotAcceptable: HttpStatusCode = 406 as const;\nexport const ProxyAuthenticationRequired: HttpStatusCode = 407 as const;\nexport const RequestTimeout: HttpStatusCode = 408 as const;\nexport const Conflict: HttpStatusCode = 409 as const;\nexport const Gone: HttpStatusCode = 410 as const;\nexport const LengthRequired: HttpStatusCode = 411 as const;\nexport const PreconditionFailed: HttpStatusCode = 412 as const;\nexport const PayloadTooLarge: HttpStatusCode = 413 as const;\nexport const UriTooLong: HttpStatusCode = 414 as const;\nexport const UnsupportedMediaType: HttpStatusCode = 415 as const;\nexport const RangeNotSatisfiable: HttpStatusCode = 416 as const;\nexport const ExpectationFailed: HttpStatusCode = 417 as const;\nexport const ImATeapot: HttpStatusCode = 418 as const;\nexport const MisdirectedRequest: HttpStatusCode = 421 as const;\nexport const UnprocessableContent: HttpStatusCode = 422 as const;\nexport const Locked: HttpStatusCode = 423 as const;\nexport const FailedDependency: HttpStatusCode = 424 as const;\nexport const TooEarly: HttpStatusCode = 425 as const;\nexport const UpgradeRequired: HttpStatusCode = 426 as const;\nexport const PreconditionRequired: HttpStatusCode = 428 as const;\nexport const TooManyRequests: HttpStatusCode = 429 as const;\nexport const RequestHeaderFieldsTooLarge: HttpStatusCode = 431 as const;\nexport const UnavailableForLegalReasons: HttpStatusCode = 451 as const;\nexport const InternalServerError: HttpStatusCode = 500 as const;\nexport const NotImplemented: HttpStatusCode = 501 as const;\nexport const BadGateway: HttpStatusCode = 502 as const;\nexport const ServiceUnavailable: HttpStatusCode = 503 as const;\nexport const GatewayTimeout: HttpStatusCode = 504 as const;\nexport const HttpVersionNotSupported: HttpStatusCode = 505 as const;\nexport const VariantAlsoNegotiates: HttpStatusCode = 506 as const;\nexport const InsufficientStorage: HttpStatusCode = 507 as const;\nexport const LoopDetected: HttpStatusCode = 508 as const;\nexport const NotExtended: HttpStatusCode = 510 as const;\nexport const NetworkAuthenticationRequired: HttpStatusCode = 511 as const;\n\n// Allow any numbers between 100 and 599 as those are potentially valid.\n// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes\nexport const httpStatusCodeSchema = z.number().int().gte(100).lt(600);\n\nexport const clientErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(400).lt(500),\n);\nexport const serverErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(500).lt(600),\n);\nexport const successHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(100).lt(400),\n);\n\nexport const isHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\thttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isClientErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tclientErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isServerErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tserverErrorHtt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pC,IAAM,gCAAgD;AAItD,IAAM,uBAAuB,aAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAE7D,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,aAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,aAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,8BAA8B,qBAAqB;AAAA,EAC/D,aAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AAEO,IAAM,mBAAmB,CAAC,QAChC,qBAAqB,UAAU,GAAG,EAAE;AAE9B,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,0BAA0B,CAAC,QACvC,4BAA4B,UAAU,GAAG,EAAE;","names":[]}
1
+ {"version":3,"sources":["../src/http/index.ts","../src/http/authorizationToken.ts","../src/http/getQueryParameters.ts","../src/http/httpHeaders.ts","../src/http/httpMethods.ts","../src/http/httpStatusCodes.ts"],"sourcesContent":["export * from \"./authorizationToken\";\nexport * from \"./getQueryParameters\";\nexport * from \"./httpHeaders\";\nexport * from \"./httpMethods\";\nexport * from \"./httpStatusCodes\";\n","export interface AuthorizationToken {\n\texpiresOn: number;\n\ttokenType: string;\n\tvalue: string;\n}\n\nexport const getAuthorizationHeader = (token: AuthorizationToken): string =>\n\t`${token.tokenType} ${token.value}`;\n\nexport const isExpired = (token: AuthorizationToken): boolean =>\n\ttoken.expiresOn < Date.now();\n","export const getQueryParameters = (url: string | URL): URLSearchParams => {\n\tconst urlString = url.toString();\n\n\tconst queryStringIndex = urlString.indexOf(\"?\");\n\tconst queryString =\n\t\tqueryStringIndex >= 0 ? urlString.substring(queryStringIndex) : \"\";\n\tconst query = new URLSearchParams(queryString);\n\n\treturn query;\n};\n","export type HttpRequestHeader =\n\t| \"Accept\"\n\t| \"Accept-Charset\"\n\t| \"Accept-Datetime\"\n\t| \"Accept-Encoding\"\n\t| \"Accept-Language\"\n\t| \"Authorization\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Length\"\n\t| \"Content-MD5\"\n\t| \"Content-Type\"\n\t| \"Cookie\"\n\t| \"Date\"\n\t| \"Expect\"\n\t| \"From\"\n\t| \"Host\"\n\t| \"If-Match\"\n\t| \"If-Modified-Since\"\n\t| \"If-None-Match\"\n\t| \"If-Range\"\n\t| \"If-Unmodified-Since\"\n\t| \"Max-Forwards\"\n\t| \"Pragma\"\n\t| \"Proxy-Authorization\"\n\t| \"Range\"\n\t| \"Referer\"\n\t| \"TE\"\n\t| \"Upgrade\"\n\t| \"User-Agent\"\n\t| \"Via\"\n\t| \"Warning\";\n\nexport type HttpResponseHeader =\n\t| \"Accept-Ranges\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-MD5\"\n\t| \"Content-Range\"\n\t| \"Content-Type\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Link\"\n\t| \"Location\"\n\t| \"P3P\"\n\t| \"Pragma\"\n\t| \"Proxy-Authenticate\"\n\t| \"Refresh\"\n\t| \"Retry-After\"\n\t| \"Server\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Vary\"\n\t| \"Via\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\";\n\nexport const Accept: HttpRequestHeader = \"Accept\";\nexport const AcceptCharset: HttpRequestHeader = \"Accept-Charset\";\nexport const AcceptDatetime: HttpRequestHeader = \"Accept-Datetime\";\nexport const AcceptEncoding: HttpRequestHeader = \"Accept-Encoding\";\nexport const AcceptLanguage: HttpRequestHeader = \"Accept-Language\";\nexport const AcceptRanges: HttpResponseHeader = \"Accept-Ranges\";\nexport const Age: HttpResponseHeader = \"Age\";\nexport const Allow: HttpResponseHeader = \"Allow\";\nexport const Authorization: HttpRequestHeader = \"Authorization\";\nexport const CacheControl: HttpRequestHeader | HttpResponseHeader =\n\t\"Cache-Control\";\nexport const Connection: HttpRequestHeader | HttpResponseHeader = \"Connection\";\nexport const ContentDisposition: HttpResponseHeader = \"Content-Disposition\";\nexport const ContentEncoding: HttpResponseHeader = \"Content-Encoding\";\nexport const ContentLanguage: HttpResponseHeader = \"Content-Language\";\nexport const ContentLength: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Length\";\nexport const ContentLocation: HttpResponseHeader = \"Content-Location\";\nexport const ContentMd5: HttpRequestHeader | HttpResponseHeader = \"Content-MD5\";\nexport const ContentRange: HttpResponseHeader = \"Content-Range\";\nexport const ContentType: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Type\";\nexport const Cookie: HttpRequestHeader = \"Cookie\";\nexport const DateTime: HttpRequestHeader | HttpResponseHeader = \"Date\";\nexport const ETag: HttpResponseHeader = \"ETag\";\nexport const Expect: HttpRequestHeader = \"Expect\";\nexport const Expires: HttpResponseHeader = \"Expires\";\nexport const From: HttpRequestHeader = \"From\";\nexport const Host: HttpRequestHeader = \"Host\";\nexport const IfMatch: HttpRequestHeader = \"If-Match\";\nexport const IfModifiedSince: HttpRequestHeader = \"If-Modified-Since\";\nexport const IfNoneMatch: HttpRequestHeader = \"If-None-Match\";\nexport const IfRange: HttpRequestHeader = \"If-Range\";\nexport const IfunmodifiedSince: HttpRequestHeader = \"If-Unmodified-Since\";\nexport const LastModified: HttpResponseHeader = \"Last-Modified\";\nexport const Link: HttpResponseHeader = \"Link\";\nexport const LocationUri: HttpResponseHeader = \"Location\";\nexport const MaxForwards: HttpRequestHeader = \"Max-Forwards\";\nexport const P3P: HttpResponseHeader = \"P3P\";\nexport const Pragma: HttpRequestHeader | HttpResponseHeader = \"Pragma\";\nexport const ProxyAuthenticate: HttpResponseHeader = \"Proxy-Authenticate\";\nexport const ProxyAuthorization: HttpRequestHeader = \"Proxy-Authorization\";\nexport const Ranges: HttpRequestHeader = \"Range\";\nexport const Referer: HttpRequestHeader = \"Referer\";\nexport const Referrer: HttpRequestHeader = Referer;\nexport const Refresh: HttpResponseHeader = \"Refresh\";\nexport const RetryAfter: HttpResponseHeader = \"Retry-After\";\nexport const Server: HttpResponseHeader = \"Server\";\nexport const SetCookie: HttpResponseHeader = \"Set-Cookie\";\nexport const StrictTransportSecurity: HttpResponseHeader =\n\t\"Strict-Transport-Security\";\nexport const TE: HttpRequestHeader = \"TE\";\nexport const Trailer: HttpResponseHeader = \"Trailer\";\nexport const TransferEncodingRequest: HttpRequestHeader = TE;\nexport const TransferEncodingResponse: HttpResponseHeader = \"Transfer-Encoding\";\nexport const Upgrade: HttpRequestHeader = \"Upgrade\";\nexport const UserAgent: HttpRequestHeader = \"User-Agent\";\nexport const Vary: HttpResponseHeader = \"Vary\";\nexport const Via: HttpRequestHeader | HttpResponseHeader = \"Via\";\nexport const Warning: HttpRequestHeader | HttpResponseHeader = \"Warning\";\nexport const WwwAuthenticate: HttpResponseHeader = \"WWW-Authenticate\";\n","export type HttpMethod =\n\t| \"CONNECT\"\n\t| \"DELETE\"\n\t| \"GET\"\n\t| \"HEAD\"\n\t| \"OPTIONS\"\n\t| \"PATCH\"\n\t| \"POST\"\n\t| \"PUT\"\n\t| \"TRACE\";\n\nexport const Connect: HttpMethod = \"CONNECT\";\nexport const Delete: HttpMethod = \"DELETE\";\nexport const Get: HttpMethod = \"GET\";\nexport const Head: HttpMethod = \"HEAD\";\nexport const Options: HttpMethod = \"OPTIONS\";\nexport const Patch: HttpMethod = \"PATCH\";\nexport const Post: HttpMethod = \"POST\";\nexport const Put: HttpMethod = \"PUT\";\nexport const Trace: HttpMethod = \"TRACE\";\n","import { z } from \"zod\";\n\nexport type HttpStatusCode =\n\t| 100\n\t| 101\n\t| 102\n\t| 103\n\t| 200\n\t| 201\n\t| 202\n\t| 203\n\t| 204\n\t| 205\n\t| 206\n\t| 207\n\t| 208\n\t| 226\n\t| 300\n\t| 301\n\t| 302\n\t| 303\n\t| 304\n\t| 305\n\t| 307\n\t| 308\n\t| 400\n\t| 401\n\t| 402\n\t| 403\n\t| 404\n\t| 405\n\t| 406\n\t| 407\n\t| 408\n\t| 409\n\t| 410\n\t| 411\n\t| 412\n\t| 413\n\t| 414\n\t| 415\n\t| 416\n\t| 417\n\t| 418\n\t| 421\n\t| 422\n\t| 423\n\t| 424\n\t| 425\n\t| 426\n\t| 428\n\t| 429\n\t| 431\n\t| 451\n\t| 500\n\t| 501\n\t| 502\n\t| 503\n\t| 504\n\t| 505\n\t| 506\n\t| 507\n\t| 508\n\t| 510\n\t| 511;\n\nexport const Continue: HttpStatusCode = 100 as const;\nexport const SwitchingProtocols: HttpStatusCode = 101 as const;\nexport const Processing: HttpStatusCode = 102 as const;\nexport const EarlyHints: HttpStatusCode = 103 as const;\nexport const Ok: HttpStatusCode = 200 as const;\nexport const Created: HttpStatusCode = 201 as const;\nexport const Accepted: HttpStatusCode = 202 as const;\nexport const NonAuthoritativeInformation: HttpStatusCode = 203 as const;\nexport const NoContent: HttpStatusCode = 204 as const;\nexport const ResetContent: HttpStatusCode = 205 as const;\nexport const PartialContent: HttpStatusCode = 206 as const;\nexport const MultiStatus: HttpStatusCode = 207 as const;\nexport const AlreadyReported: HttpStatusCode = 208 as const;\nexport const ImUsed: HttpStatusCode = 226 as const;\nexport const MultipleChoices: HttpStatusCode = 300 as const;\nexport const MovedPermanently: HttpStatusCode = 301 as const;\nexport const Found: HttpStatusCode = 302 as const;\nexport const SeeOther: HttpStatusCode = 303 as const;\nexport const NotModified: HttpStatusCode = 304 as const;\nexport const UseProxyDeprecated: HttpStatusCode = 305 as const;\nexport const TemporaryRedirect: HttpStatusCode = 307 as const;\nexport const PermanentRedirect: HttpStatusCode = 308 as const;\nexport const BadRequest: HttpStatusCode = 400 as const;\nexport const Unauthorized: HttpStatusCode = 401 as const;\nexport const PaymentRequired: HttpStatusCode = 402 as const;\nexport const Forbidden: HttpStatusCode = 403 as const;\nexport const NotFound: HttpStatusCode = 404 as const;\nexport const MethodNotAllowed: HttpStatusCode = 405 as const;\nexport const NotAcceptable: HttpStatusCode = 406 as const;\nexport const ProxyAuthenticationRequired: HttpStatusCode = 407 as const;\nexport const RequestTimeout: HttpStatusCode = 408 as const;\nexport const Conflict: HttpStatusCode = 409 as const;\nexport const Gone: HttpStatusCode = 410 as const;\nexport const LengthRequired: HttpStatusCode = 411 as const;\nexport const PreconditionFailed: HttpStatusCode = 412 as const;\nexport const PayloadTooLarge: HttpStatusCode = 413 as const;\nexport const UriTooLong: HttpStatusCode = 414 as const;\nexport const UnsupportedMediaType: HttpStatusCode = 415 as const;\nexport const RangeNotSatisfiable: HttpStatusCode = 416 as const;\nexport const ExpectationFailed: HttpStatusCode = 417 as const;\nexport const ImATeapot: HttpStatusCode = 418 as const;\nexport const MisdirectedRequest: HttpStatusCode = 421 as const;\nexport const UnprocessableContent: HttpStatusCode = 422 as const;\nexport const Locked: HttpStatusCode = 423 as const;\nexport const FailedDependency: HttpStatusCode = 424 as const;\nexport const TooEarly: HttpStatusCode = 425 as const;\nexport const UpgradeRequired: HttpStatusCode = 426 as const;\nexport const PreconditionRequired: HttpStatusCode = 428 as const;\nexport const TooManyRequests: HttpStatusCode = 429 as const;\nexport const RequestHeaderFieldsTooLarge: HttpStatusCode = 431 as const;\nexport const UnavailableForLegalReasons: HttpStatusCode = 451 as const;\nexport const InternalServerError: HttpStatusCode = 500 as const;\nexport const NotImplemented: HttpStatusCode = 501 as const;\nexport const BadGateway: HttpStatusCode = 502 as const;\nexport const ServiceUnavailable: HttpStatusCode = 503 as const;\nexport const GatewayTimeout: HttpStatusCode = 504 as const;\nexport const HttpVersionNotSupported: HttpStatusCode = 505 as const;\nexport const VariantAlsoNegotiates: HttpStatusCode = 506 as const;\nexport const InsufficientStorage: HttpStatusCode = 507 as const;\nexport const LoopDetected: HttpStatusCode = 508 as const;\nexport const NotExtended: HttpStatusCode = 510 as const;\nexport const NetworkAuthenticationRequired: HttpStatusCode = 511 as const;\n\n// Allow any numbers between 100 and 599 as those are potentially valid.\n// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes\nexport const httpStatusCodeSchema = z.number().int().gte(100).lt(600);\n\nexport const clientErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(400).lt(500),\n);\nexport const serverErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(500).lt(600),\n);\nexport const successHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(100).lt(400),\n);\n\nexport const isHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\thttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isClientErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tclientErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isServerErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tserverErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isSuccessHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\tsuccessHttpStatusCodeSchema.safeParse(obj).success;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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ACnE,aAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,8BAA8B,qBAAqB;AAAA,EAC/D,aAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AAEO,IAAM,mBAAmB,CAAC,QAChC,qBAAqB,UAAU,GAAG,EAAE;AAE9B,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,0BAA0B,CAAC,QACvC,4BAA4B,UAAU,GAAG,EAAE;","names":[]}
package/dist/http.mjs CHANGED
@@ -70,6 +70,17 @@ var Via = "Via";
70
70
  var Warning = "Warning";
71
71
  var WwwAuthenticate = "WWW-Authenticate";
72
72
 
73
+ // src/http/httpMethods.ts
74
+ var Connect = "CONNECT";
75
+ var Delete = "DELETE";
76
+ var Get = "GET";
77
+ var Head = "HEAD";
78
+ var Options = "OPTIONS";
79
+ var Patch = "PATCH";
80
+ var Post = "POST";
81
+ var Put = "PUT";
82
+ var Trace = "TRACE";
83
+
73
84
  // src/http/httpStatusCodes.ts
74
85
  import { z } from "zod";
75
86
  var Continue = 100;
@@ -164,6 +175,7 @@ export {
164
175
  BadRequest,
165
176
  CacheControl,
166
177
  Conflict,
178
+ Connect,
167
179
  Connection,
168
180
  ContentDisposition,
169
181
  ContentEncoding,
@@ -177,6 +189,7 @@ export {
177
189
  Cookie,
178
190
  Created,
179
191
  DateTime,
192
+ Delete,
180
193
  ETag,
181
194
  EarlyHints,
182
195
  Expect,
@@ -187,7 +200,9 @@ export {
187
200
  Found,
188
201
  From,
189
202
  GatewayTimeout,
203
+ Get,
190
204
  Gone,
205
+ Head,
191
206
  Host,
192
207
  HttpVersionNotSupported,
193
208
  IfMatch,
@@ -220,11 +235,14 @@ export {
220
235
  NotImplemented,
221
236
  NotModified,
222
237
  Ok,
238
+ Options,
223
239
  P3P,
224
240
  PartialContent,
241
+ Patch,
225
242
  PayloadTooLarge,
226
243
  PaymentRequired,
227
244
  PermanentRedirect,
245
+ Post,
228
246
  Pragma,
229
247
  PreconditionFailed,
230
248
  PreconditionRequired,
@@ -232,6 +250,7 @@ export {
232
250
  ProxyAuthenticate,
233
251
  ProxyAuthenticationRequired,
234
252
  ProxyAuthorization,
253
+ Put,
235
254
  RangeNotSatisfiable,
236
255
  Ranges,
237
256
  Referer,
@@ -251,6 +270,7 @@ export {
251
270
  TemporaryRedirect,
252
271
  TooEarly,
253
272
  TooManyRequests,
273
+ Trace,
254
274
  Trailer,
255
275
  TransferEncodingRequest,
256
276
  TransferEncodingResponse,
package/dist/http.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/http/authorizationToken.ts","../src/http/getQueryParameters.ts","../src/http/httpHeaders.ts","../src/http/httpStatusCodes.ts"],"sourcesContent":["export interface AuthorizationToken {\n\texpiresOn: number;\n\ttokenType: string;\n\tvalue: string;\n}\n\nexport const getAuthorizationHeader = (token: AuthorizationToken): string =>\n\t`${token.tokenType} ${token.value}`;\n\nexport const isExpired = (token: AuthorizationToken): boolean =>\n\ttoken.expiresOn < Date.now();\n","export const getQueryParameters = (url: string | URL): URLSearchParams => {\n\tconst urlString = url.toString();\n\n\tconst queryStringIndex = urlString.indexOf(\"?\");\n\tconst queryString =\n\t\tqueryStringIndex >= 0 ? urlString.substring(queryStringIndex) : \"\";\n\tconst query = new URLSearchParams(queryString);\n\n\treturn query;\n};\n","export type HttpRequestHeader =\n\t| \"Accept\"\n\t| \"Accept-Charset\"\n\t| \"Accept-Datetime\"\n\t| \"Accept-Encoding\"\n\t| \"Accept-Language\"\n\t| \"Authorization\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Length\"\n\t| \"Content-MD5\"\n\t| \"Content-Type\"\n\t| \"Cookie\"\n\t| \"Date\"\n\t| \"Expect\"\n\t| \"From\"\n\t| \"Host\"\n\t| \"If-Match\"\n\t| \"If-Modified-Since\"\n\t| \"If-None-Match\"\n\t| \"If-Range\"\n\t| \"If-Unmodified-Since\"\n\t| \"Max-Forwards\"\n\t| \"Pragma\"\n\t| \"Proxy-Authorization\"\n\t| \"Range\"\n\t| \"Referer\"\n\t| \"TE\"\n\t| \"Upgrade\"\n\t| \"User-Agent\"\n\t| \"Via\"\n\t| \"Warning\";\n\nexport type HttpResponseHeader =\n\t| \"Accept-Ranges\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-MD5\"\n\t| \"Content-Range\"\n\t| \"Content-Type\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Link\"\n\t| \"Location\"\n\t| \"P3P\"\n\t| \"Pragma\"\n\t| \"Proxy-Authenticate\"\n\t| \"Refresh\"\n\t| \"Retry-After\"\n\t| \"Server\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Vary\"\n\t| \"Via\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\";\n\nexport const Accept: HttpRequestHeader = \"Accept\";\nexport const AcceptCharset: HttpRequestHeader = \"Accept-Charset\";\nexport const AcceptDatetime: HttpRequestHeader = \"Accept-Datetime\";\nexport const AcceptEncoding: HttpRequestHeader = \"Accept-Encoding\";\nexport const AcceptLanguage: HttpRequestHeader = \"Accept-Language\";\nexport const AcceptRanges: HttpResponseHeader = \"Accept-Ranges\";\nexport const Age: HttpResponseHeader = \"Age\";\nexport const Allow: HttpResponseHeader = \"Allow\";\nexport const Authorization: HttpRequestHeader = \"Authorization\";\nexport const CacheControl: HttpRequestHeader | HttpResponseHeader =\n\t\"Cache-Control\";\nexport const Connection: HttpRequestHeader | HttpResponseHeader = \"Connection\";\nexport const ContentDisposition: HttpResponseHeader = \"Content-Disposition\";\nexport const ContentEncoding: HttpResponseHeader = \"Content-Encoding\";\nexport const ContentLanguage: HttpResponseHeader = \"Content-Language\";\nexport const ContentLength: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Length\";\nexport const ContentLocation: HttpResponseHeader = \"Content-Location\";\nexport const ContentMd5: HttpRequestHeader | HttpResponseHeader = \"Content-MD5\";\nexport const ContentRange: HttpResponseHeader = \"Content-Range\";\nexport const ContentType: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Type\";\nexport const Cookie: HttpRequestHeader = \"Cookie\";\nexport const DateTime: HttpRequestHeader | HttpResponseHeader = \"Date\";\nexport const ETag: HttpResponseHeader = \"ETag\";\nexport const Expect: HttpRequestHeader = \"Expect\";\nexport const Expires: HttpResponseHeader = \"Expires\";\nexport const From: HttpRequestHeader = \"From\";\nexport const Host: HttpRequestHeader = \"Host\";\nexport const IfMatch: HttpRequestHeader = \"If-Match\";\nexport const IfModifiedSince: HttpRequestHeader = \"If-Modified-Since\";\nexport const IfNoneMatch: HttpRequestHeader = \"If-None-Match\";\nexport const IfRange: HttpRequestHeader = \"If-Range\";\nexport const IfunmodifiedSince: HttpRequestHeader = \"If-Unmodified-Since\";\nexport const LastModified: HttpResponseHeader = \"Last-Modified\";\nexport const Link: HttpResponseHeader = \"Link\";\nexport const LocationUri: HttpResponseHeader = \"Location\";\nexport const MaxForwards: HttpRequestHeader = \"Max-Forwards\";\nexport const P3P: HttpResponseHeader = \"P3P\";\nexport const Pragma: HttpRequestHeader | HttpResponseHeader = \"Pragma\";\nexport const ProxyAuthenticate: HttpResponseHeader = \"Proxy-Authenticate\";\nexport const ProxyAuthorization: HttpRequestHeader = \"Proxy-Authorization\";\nexport const Ranges: HttpRequestHeader = \"Range\";\nexport const Referer: HttpRequestHeader = \"Referer\";\nexport const Referrer: HttpRequestHeader = Referer;\nexport const Refresh: HttpResponseHeader = \"Refresh\";\nexport const RetryAfter: HttpResponseHeader = \"Retry-After\";\nexport const Server: HttpResponseHeader = \"Server\";\nexport const SetCookie: HttpResponseHeader = \"Set-Cookie\";\nexport const StrictTransportSecurity: HttpResponseHeader =\n\t\"Strict-Transport-Security\";\nexport const TE: HttpRequestHeader = \"TE\";\nexport const Trailer: HttpResponseHeader = \"Trailer\";\nexport const TransferEncodingRequest: HttpRequestHeader = TE;\nexport const TransferEncodingResponse: HttpResponseHeader = \"Transfer-Encoding\";\nexport const Upgrade: HttpRequestHeader = \"Upgrade\";\nexport const UserAgent: HttpRequestHeader = \"User-Agent\";\nexport const Vary: HttpResponseHeader = \"Vary\";\nexport const Via: HttpRequestHeader | HttpResponseHeader = \"Via\";\nexport const Warning: HttpRequestHeader | HttpResponseHeader = \"Warning\";\nexport const WwwAuthenticate: HttpResponseHeader = \"WWW-Authenticate\";\n","import { z } from \"zod\";\n\nexport type HttpStatusCode =\n\t| 100\n\t| 101\n\t| 102\n\t| 103\n\t| 200\n\t| 201\n\t| 202\n\t| 203\n\t| 204\n\t| 205\n\t| 206\n\t| 207\n\t| 208\n\t| 226\n\t| 300\n\t| 301\n\t| 302\n\t| 303\n\t| 304\n\t| 305\n\t| 307\n\t| 308\n\t| 400\n\t| 401\n\t| 402\n\t| 403\n\t| 404\n\t| 405\n\t| 406\n\t| 407\n\t| 408\n\t| 409\n\t| 410\n\t| 411\n\t| 412\n\t| 413\n\t| 414\n\t| 415\n\t| 416\n\t| 417\n\t| 418\n\t| 421\n\t| 422\n\t| 423\n\t| 424\n\t| 425\n\t| 426\n\t| 428\n\t| 429\n\t| 431\n\t| 451\n\t| 500\n\t| 501\n\t| 502\n\t| 503\n\t| 504\n\t| 505\n\t| 506\n\t| 507\n\t| 508\n\t| 510\n\t| 511;\n\nexport const Continue: HttpStatusCode = 100 as const;\nexport const SwitchingProtocols: HttpStatusCode = 101 as const;\nexport const Processing: HttpStatusCode = 102 as const;\nexport const EarlyHints: HttpStatusCode = 103 as const;\nexport const Ok: HttpStatusCode = 200 as const;\nexport const Created: HttpStatusCode = 201 as const;\nexport const Accepted: HttpStatusCode = 202 as const;\nexport const NonAuthoritativeInformation: HttpStatusCode = 203 as const;\nexport const NoContent: HttpStatusCode = 204 as const;\nexport const ResetContent: HttpStatusCode = 205 as const;\nexport const PartialContent: HttpStatusCode = 206 as const;\nexport const MultiStatus: HttpStatusCode = 207 as const;\nexport const AlreadyReported: HttpStatusCode = 208 as const;\nexport const ImUsed: HttpStatusCode = 226 as const;\nexport const MultipleChoices: HttpStatusCode = 300 as const;\nexport const MovedPermanently: HttpStatusCode = 301 as const;\nexport const Found: HttpStatusCode = 302 as const;\nexport const SeeOther: HttpStatusCode = 303 as const;\nexport const NotModified: HttpStatusCode = 304 as const;\nexport const UseProxyDeprecated: HttpStatusCode = 305 as const;\nexport const TemporaryRedirect: HttpStatusCode = 307 as const;\nexport const PermanentRedirect: HttpStatusCode = 308 as const;\nexport const BadRequest: HttpStatusCode = 400 as const;\nexport const Unauthorized: HttpStatusCode = 401 as const;\nexport const PaymentRequired: HttpStatusCode = 402 as const;\nexport const Forbidden: HttpStatusCode = 403 as const;\nexport const NotFound: HttpStatusCode = 404 as const;\nexport const MethodNotAllowed: HttpStatusCode = 405 as const;\nexport const NotAcceptable: HttpStatusCode = 406 as const;\nexport const ProxyAuthenticationRequired: HttpStatusCode = 407 as const;\nexport const RequestTimeout: HttpStatusCode = 408 as const;\nexport const Conflict: HttpStatusCode = 409 as const;\nexport const Gone: HttpStatusCode = 410 as const;\nexport const LengthRequired: HttpStatusCode = 411 as const;\nexport const PreconditionFailed: HttpStatusCode = 412 as const;\nexport const PayloadTooLarge: HttpStatusCode = 413 as const;\nexport const UriTooLong: HttpStatusCode = 414 as const;\nexport const UnsupportedMediaType: HttpStatusCode = 415 as const;\nexport const RangeNotSatisfiable: HttpStatusCode = 416 as const;\nexport const ExpectationFailed: HttpStatusCode = 417 as const;\nexport const ImATeapot: HttpStatusCode = 418 as const;\nexport const MisdirectedRequest: HttpStatusCode = 421 as const;\nexport const UnprocessableContent: HttpStatusCode = 422 as const;\nexport const Locked: HttpStatusCode = 423 as const;\nexport const FailedDependency: HttpStatusCode = 424 as const;\nexport const TooEarly: HttpStatusCode = 425 as const;\nexport const UpgradeRequired: HttpStatusCode = 426 as const;\nexport const PreconditionRequired: HttpStatusCode = 428 as const;\nexport const TooManyRequests: HttpStatusCode = 429 as const;\nexport const RequestHeaderFieldsTooLarge: HttpStatusCode = 431 as const;\nexport const UnavailableForLegalReasons: HttpStatusCode = 451 as const;\nexport const InternalServerError: HttpStatusCode = 500 as const;\nexport const NotImplemented: HttpStatusCode = 501 as const;\nexport const BadGateway: HttpStatusCode = 502 as const;\nexport const ServiceUnavailable: HttpStatusCode = 503 as const;\nexport const GatewayTimeout: HttpStatusCode = 504 as const;\nexport const HttpVersionNotSupported: HttpStatusCode = 505 as const;\nexport const VariantAlsoNegotiates: HttpStatusCode = 506 as const;\nexport const InsufficientStorage: HttpStatusCode = 507 as const;\nexport const LoopDetected: HttpStatusCode = 508 as const;\nexport const NotExtended: HttpStatusCode = 510 as const;\nexport const NetworkAuthenticationRequired: HttpStatusCode = 511 as const;\n\n// Allow any numbers between 100 and 599 as those are potentially valid.\n// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes\nexport const httpStatusCodeSchema = z.number().int().gte(100).lt(600);\n\nexport const clientErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(400).lt(500),\n);\nexport const serverErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(500).lt(600),\n);\nexport const successHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(100).lt(400),\n);\n\nexport const isHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\thttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isClientErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tclientErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isServerErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tserverErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isSuccessHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\tsuccessHttpStatusCodeSchema.safeParse(obj).success;\n"],"mappings":";AAMO,IAAM,yBAAyB,CAAC,UACtC,GAAG,MAAM,SAAS,IAAI,MAAM,KAAK;AAE3B,IAAM,YAAY,CAAC,UACzB,MAAM,YAAY,KAAK,IAAI;;;ACVrB,IAAM,qBAAqB,CAAC,QAAuC;AACzE,QAAM,YAAY,IAAI,SAAS;AAE/B,QAAM,mBAAmB,UAAU,QAAQ,GAAG;AAC9C,QAAM,cACL,oBAAoB,IAAI,UAAU,UAAU,gBAAgB,IAAI;AACjE,QAAM,QAAQ,IAAI,gBAAgB,WAAW;AAE7C,SAAO;AACR;;;AC2DO,IAAM,SAA4B;AAClC,IAAM,gBAAmC;AACzC,IAAM,iBAAoC;AAC1C,IAAM,iBAAoC;AAC1C,IAAM,iBAAoC;AAC1C,IAAM,eAAmC;AACzC,IAAM,MAA0B;AAChC,IAAM,QAA4B;AAClC,IAAM,gBAAmC;AACzC,IAAM,eACZ;AACM,IAAM,aAAqD;AAC3D,IAAM,qBAAyC;AAC/C,IAAM,kBAAsC;AAC5C,IAAM,kBAAsC;AAC5C,IAAM,gBACZ;AACM,IAAM,kBAAsC;AAC5C,IAAM,aAAqD;AAC3D,IAAM,eAAmC;AACzC,IAAM,cACZ;AACM,IAAM,SAA4B;AAClC,IAAM,WAAmD;AACzD,IAAM,OAA2B;AACjC,IAAM,SAA4B;AAClC,IAAM,UAA8B;AACpC,IAAM,OAA0B;AAChC,IAAM,OAA0B;AAChC,IAAM,UAA6B;AACnC,IAAM,kBAAqC;AAC3C,IAAM,cAAiC;AACvC,IAAM,UAA6B;AACnC,IAAM,oBAAuC;AAC7C,IAAM,eAAmC;AACzC,IAAM,OAA2B;AACjC,IAAM,cAAkC;AACxC,IAAM,cAAiC;AACvC,IAAM,MAA0B;AAChC,IA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;AAC1C,IAAM,YAA4B;AAClC,IAAM,qBAAqC;AAC3C,IAAM,uBAAuC;AAC7C,IAAM,SAAyB;AAC/B,IAAM,mBAAmC;AACzC,IAAM,WAA2B;AACjC,IAAM,kBAAkC;AACxC,IAAM,uBAAuC;AAC7C,IAAM,kBAAkC;AACxC,IAAM,8BAA8C;AACpD,IAAM,6BAA6C;AACnD,IAAM,sBAAsC;AAC5C,IAAM,iBAAiC;AACvC,IAAM,aAA6B;AACnC,IAAM,qBAAqC;AAC3C,IAAM,iBAAiC;AACvC,IAAM,0BAA0C;AAChD,IAAM,wBAAwC;AAC9C,IAAM,sBAAsC;AAC5C,IAAM,eAA+B;AACrC,IAAM,cAA8B;AACpC,IAAM,gCAAgD;AAItD,IAAM,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAE7D,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,8BAA8B,qBAAqB;AAAA,EAC/D,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AAEO,IAAM,mBAAmB,CAAC,QAChC,qBAAqB,UAAU,GAAG,EAAE;AAE9B,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,0BAA0B,CAAC,QACvC,4BAA4B,UAAU,GAAG,EAAE;","names":[]}
1
+ {"version":3,"sources":["../src/http/authorizationToken.ts","../src/http/getQueryParameters.ts","../src/http/httpHeaders.ts","../src/http/httpMethods.ts","../src/http/httpStatusCodes.ts"],"sourcesContent":["export interface AuthorizationToken {\n\texpiresOn: number;\n\ttokenType: string;\n\tvalue: string;\n}\n\nexport const getAuthorizationHeader = (token: AuthorizationToken): string =>\n\t`${token.tokenType} ${token.value}`;\n\nexport const isExpired = (token: AuthorizationToken): boolean =>\n\ttoken.expiresOn < Date.now();\n","export const getQueryParameters = (url: string | URL): URLSearchParams => {\n\tconst urlString = url.toString();\n\n\tconst queryStringIndex = urlString.indexOf(\"?\");\n\tconst queryString =\n\t\tqueryStringIndex >= 0 ? urlString.substring(queryStringIndex) : \"\";\n\tconst query = new URLSearchParams(queryString);\n\n\treturn query;\n};\n","export type HttpRequestHeader =\n\t| \"Accept\"\n\t| \"Accept-Charset\"\n\t| \"Accept-Datetime\"\n\t| \"Accept-Encoding\"\n\t| \"Accept-Language\"\n\t| \"Authorization\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Length\"\n\t| \"Content-MD5\"\n\t| \"Content-Type\"\n\t| \"Cookie\"\n\t| \"Date\"\n\t| \"Expect\"\n\t| \"From\"\n\t| \"Host\"\n\t| \"If-Match\"\n\t| \"If-Modified-Since\"\n\t| \"If-None-Match\"\n\t| \"If-Range\"\n\t| \"If-Unmodified-Since\"\n\t| \"Max-Forwards\"\n\t| \"Pragma\"\n\t| \"Proxy-Authorization\"\n\t| \"Range\"\n\t| \"Referer\"\n\t| \"TE\"\n\t| \"Upgrade\"\n\t| \"User-Agent\"\n\t| \"Via\"\n\t| \"Warning\";\n\nexport type HttpResponseHeader =\n\t| \"Accept-Ranges\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Connection\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-MD5\"\n\t| \"Content-Range\"\n\t| \"Content-Type\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Link\"\n\t| \"Location\"\n\t| \"P3P\"\n\t| \"Pragma\"\n\t| \"Proxy-Authenticate\"\n\t| \"Refresh\"\n\t| \"Retry-After\"\n\t| \"Server\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Vary\"\n\t| \"Via\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\";\n\nexport const Accept: HttpRequestHeader = \"Accept\";\nexport const AcceptCharset: HttpRequestHeader = \"Accept-Charset\";\nexport const AcceptDatetime: HttpRequestHeader = \"Accept-Datetime\";\nexport const AcceptEncoding: HttpRequestHeader = \"Accept-Encoding\";\nexport const AcceptLanguage: HttpRequestHeader = \"Accept-Language\";\nexport const AcceptRanges: HttpResponseHeader = \"Accept-Ranges\";\nexport const Age: HttpResponseHeader = \"Age\";\nexport const Allow: HttpResponseHeader = \"Allow\";\nexport const Authorization: HttpRequestHeader = \"Authorization\";\nexport const CacheControl: HttpRequestHeader | HttpResponseHeader =\n\t\"Cache-Control\";\nexport const Connection: HttpRequestHeader | HttpResponseHeader = \"Connection\";\nexport const ContentDisposition: HttpResponseHeader = \"Content-Disposition\";\nexport const ContentEncoding: HttpResponseHeader = \"Content-Encoding\";\nexport const ContentLanguage: HttpResponseHeader = \"Content-Language\";\nexport const ContentLength: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Length\";\nexport const ContentLocation: HttpResponseHeader = \"Content-Location\";\nexport const ContentMd5: HttpRequestHeader | HttpResponseHeader = \"Content-MD5\";\nexport const ContentRange: HttpResponseHeader = \"Content-Range\";\nexport const ContentType: HttpRequestHeader | HttpResponseHeader =\n\t\"Content-Type\";\nexport const Cookie: HttpRequestHeader = \"Cookie\";\nexport const DateTime: HttpRequestHeader | HttpResponseHeader = \"Date\";\nexport const ETag: HttpResponseHeader = \"ETag\";\nexport const Expect: HttpRequestHeader = \"Expect\";\nexport const Expires: HttpResponseHeader = \"Expires\";\nexport const From: HttpRequestHeader = \"From\";\nexport const Host: HttpRequestHeader = \"Host\";\nexport const IfMatch: HttpRequestHeader = \"If-Match\";\nexport const IfModifiedSince: HttpRequestHeader = \"If-Modified-Since\";\nexport const IfNoneMatch: HttpRequestHeader = \"If-None-Match\";\nexport const IfRange: HttpRequestHeader = \"If-Range\";\nexport const IfunmodifiedSince: HttpRequestHeader = \"If-Unmodified-Since\";\nexport const LastModified: HttpResponseHeader = \"Last-Modified\";\nexport const Link: HttpResponseHeader = \"Link\";\nexport const LocationUri: HttpResponseHeader = \"Location\";\nexport const MaxForwards: HttpRequestHeader = \"Max-Forwards\";\nexport const P3P: HttpResponseHeader = \"P3P\";\nexport const Pragma: HttpRequestHeader | HttpResponseHeader = \"Pragma\";\nexport const ProxyAuthenticate: HttpResponseHeader = \"Proxy-Authenticate\";\nexport const ProxyAuthorization: HttpRequestHeader = \"Proxy-Authorization\";\nexport const Ranges: HttpRequestHeader = \"Range\";\nexport const Referer: HttpRequestHeader = \"Referer\";\nexport const Referrer: HttpRequestHeader = Referer;\nexport const Refresh: HttpResponseHeader = \"Refresh\";\nexport const RetryAfter: HttpResponseHeader = \"Retry-After\";\nexport const Server: HttpResponseHeader = \"Server\";\nexport const SetCookie: HttpResponseHeader = \"Set-Cookie\";\nexport const StrictTransportSecurity: HttpResponseHeader =\n\t\"Strict-Transport-Security\";\nexport const TE: HttpRequestHeader = \"TE\";\nexport const Trailer: HttpResponseHeader = \"Trailer\";\nexport const TransferEncodingRequest: HttpRequestHeader = TE;\nexport const TransferEncodingResponse: HttpResponseHeader = \"Transfer-Encoding\";\nexport const Upgrade: HttpRequestHeader = \"Upgrade\";\nexport const UserAgent: HttpRequestHeader = \"User-Agent\";\nexport const Vary: HttpResponseHeader = \"Vary\";\nexport const Via: HttpRequestHeader | HttpResponseHeader = \"Via\";\nexport const Warning: HttpRequestHeader | HttpResponseHeader = \"Warning\";\nexport const WwwAuthenticate: HttpResponseHeader = \"WWW-Authenticate\";\n","export type HttpMethod =\n\t| \"CONNECT\"\n\t| \"DELETE\"\n\t| \"GET\"\n\t| \"HEAD\"\n\t| \"OPTIONS\"\n\t| \"PATCH\"\n\t| \"POST\"\n\t| \"PUT\"\n\t| \"TRACE\";\n\nexport const Connect: HttpMethod = \"CONNECT\";\nexport const Delete: HttpMethod = \"DELETE\";\nexport const Get: HttpMethod = \"GET\";\nexport const Head: HttpMethod = \"HEAD\";\nexport const Options: HttpMethod = \"OPTIONS\";\nexport const Patch: HttpMethod = \"PATCH\";\nexport const Post: HttpMethod = \"POST\";\nexport const Put: HttpMethod = \"PUT\";\nexport const Trace: HttpMethod = \"TRACE\";\n","import { z } from \"zod\";\n\nexport type HttpStatusCode =\n\t| 100\n\t| 101\n\t| 102\n\t| 103\n\t| 200\n\t| 201\n\t| 202\n\t| 203\n\t| 204\n\t| 205\n\t| 206\n\t| 207\n\t| 208\n\t| 226\n\t| 300\n\t| 301\n\t| 302\n\t| 303\n\t| 304\n\t| 305\n\t| 307\n\t| 308\n\t| 400\n\t| 401\n\t| 402\n\t| 403\n\t| 404\n\t| 405\n\t| 406\n\t| 407\n\t| 408\n\t| 409\n\t| 410\n\t| 411\n\t| 412\n\t| 413\n\t| 414\n\t| 415\n\t| 416\n\t| 417\n\t| 418\n\t| 421\n\t| 422\n\t| 423\n\t| 424\n\t| 425\n\t| 426\n\t| 428\n\t| 429\n\t| 431\n\t| 451\n\t| 500\n\t| 501\n\t| 502\n\t| 503\n\t| 504\n\t| 505\n\t| 506\n\t| 507\n\t| 508\n\t| 510\n\t| 511;\n\nexport const Continue: HttpStatusCode = 100 as const;\nexport const SwitchingProtocols: HttpStatusCode = 101 as const;\nexport const Processing: HttpStatusCode = 102 as const;\nexport const EarlyHints: HttpStatusCode = 103 as const;\nexport const Ok: HttpStatusCode = 200 as const;\nexport const Created: HttpStatusCode = 201 as const;\nexport const Accepted: HttpStatusCode = 202 as const;\nexport const NonAuthoritativeInformation: HttpStatusCode = 203 as const;\nexport const NoContent: HttpStatusCode = 204 as const;\nexport const ResetContent: HttpStatusCode = 205 as const;\nexport const PartialContent: HttpStatusCode = 206 as const;\nexport const MultiStatus: HttpStatusCode = 207 as const;\nexport const AlreadyReported: HttpStatusCode = 208 as const;\nexport const ImUsed: HttpStatusCode = 226 as const;\nexport const MultipleChoices: HttpStatusCode = 300 as const;\nexport const MovedPermanently: HttpStatusCode = 301 as const;\nexport const Found: HttpStatusCode = 302 as const;\nexport const SeeOther: HttpStatusCode = 303 as const;\nexport const NotModified: HttpStatusCode = 304 as const;\nexport const UseProxyDeprecated: HttpStatusCode = 305 as const;\nexport const TemporaryRedirect: HttpStatusCode = 307 as const;\nexport const PermanentRedirect: HttpStatusCode = 308 as const;\nexport const BadRequest: HttpStatusCode = 400 as const;\nexport const Unauthorized: HttpStatusCode = 401 as const;\nexport const PaymentRequired: HttpStatusCode = 402 as const;\nexport const Forbidden: HttpStatusCode = 403 as const;\nexport const NotFound: HttpStatusCode = 404 as const;\nexport const MethodNotAllowed: HttpStatusCode = 405 as const;\nexport const NotAcceptable: HttpStatusCode = 406 as const;\nexport const ProxyAuthenticationRequired: HttpStatusCode = 407 as const;\nexport const RequestTimeout: HttpStatusCode = 408 as const;\nexport const Conflict: HttpStatusCode = 409 as const;\nexport const Gone: HttpStatusCode = 410 as const;\nexport const LengthRequired: HttpStatusCode = 411 as const;\nexport const PreconditionFailed: HttpStatusCode = 412 as const;\nexport const PayloadTooLarge: HttpStatusCode = 413 as const;\nexport const UriTooLong: HttpStatusCode = 414 as const;\nexport const UnsupportedMediaType: HttpStatusCode = 415 as const;\nexport const RangeNotSatisfiable: HttpStatusCode = 416 as const;\nexport const ExpectationFailed: HttpStatusCode = 417 as const;\nexport const ImATeapot: HttpStatusCode = 418 as const;\nexport const MisdirectedRequest: HttpStatusCode = 421 as const;\nexport const UnprocessableContent: HttpStatusCode = 422 as const;\nexport const Locked: HttpStatusCode = 423 as const;\nexport const FailedDependency: HttpStatusCode = 424 as const;\nexport const TooEarly: HttpStatusCode = 425 as const;\nexport const UpgradeRequired: HttpStatusCode = 426 as const;\nexport const PreconditionRequired: HttpStatusCode = 428 as const;\nexport const TooManyRequests: HttpStatusCode = 429 as const;\nexport const RequestHeaderFieldsTooLarge: HttpStatusCode = 431 as const;\nexport const UnavailableForLegalReasons: HttpStatusCode = 451 as const;\nexport const InternalServerError: HttpStatusCode = 500 as const;\nexport const NotImplemented: HttpStatusCode = 501 as const;\nexport const BadGateway: HttpStatusCode = 502 as const;\nexport const ServiceUnavailable: HttpStatusCode = 503 as const;\nexport const GatewayTimeout: HttpStatusCode = 504 as const;\nexport const HttpVersionNotSupported: HttpStatusCode = 505 as const;\nexport const VariantAlsoNegotiates: HttpStatusCode = 506 as const;\nexport const InsufficientStorage: HttpStatusCode = 507 as const;\nexport const LoopDetected: HttpStatusCode = 508 as const;\nexport const NotExtended: HttpStatusCode = 510 as const;\nexport const NetworkAuthenticationRequired: HttpStatusCode = 511 as const;\n\n// Allow any numbers between 100 and 599 as those are potentially valid.\n// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes\nexport const httpStatusCodeSchema = z.number().int().gte(100).lt(600);\n\nexport const clientErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(400).lt(500),\n);\nexport const serverErrorHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(500).lt(600),\n);\nexport const successHttpStatusCodeSchema = httpStatusCodeSchema.and(\n\tz.number().gte(100).lt(400),\n);\n\nexport const isHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\thttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isClientErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tclientErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isServerErrorHttpStatusCode = (\n\tobj: unknown,\n): obj is HttpStatusCode =>\n\tserverErrorHttpStatusCodeSchema.safeParse(obj).success;\n\nexport const isSuccessHttpStatusCode = (obj: unknown): obj is HttpStatusCode =>\n\tsuccessHttpStatusCodeSchema.safeParse(obj).success;\n"],"mappings":";AAMO,IAAM,yBAAyB,CAAC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oC;AAC1C,IAAM,YAA4B;AAClC,IAAM,qBAAqC;AAC3C,IAAM,uBAAuC;AAC7C,IAAM,SAAyB;AAC/B,IAAM,mBAAmC;AACzC,IAAM,WAA2B;AACjC,IAAM,kBAAkC;AACxC,IAAM,uBAAuC;AAC7C,IAAM,kBAAkC;AACxC,IAAM,8BAA8C;AACpD,IAAM,6BAA6C;AACnD,IAAM,sBAAsC;AAC5C,IAAM,iBAAiC;AACvC,IAAM,aAA6B;AACnC,IAAM,qBAAqC;AAC3C,IAAM,iBAAiC;AACvC,IAAM,0BAA0C;AAChD,IAAM,wBAAwC;AAC9C,IAAM,sBAAsC;AAC5C,IAAM,eAA+B;AACrC,IAAM,cAA8B;AACpC,IAAM,gCAAgD;AAItD,IAAM,uBAAuB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAE7D,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,kCAAkC,qBAAqB;AAAA,EACnE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AACO,IAAM,8BAA8B,qBAAqB;AAAA,EAC/D,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,GAAG,GAAG;AAC3B;AAEO,IAAM,mBAAmB,CAAC,QAChC,qBAAqB,UAAU,GAAG,EAAE;AAE9B,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,8BAA8B,CAC1C,QAEA,gCAAgC,UAAU,GAAG,EAAE;AAEzC,IAAM,0BAA0B,CAAC,QACvC,4BAA4B,UAAU,GAAG,EAAE;","names":[]}
package/dist/values.d.mts CHANGED
@@ -3,6 +3,13 @@ type InvariantAssertion = (value: unknown) => asserts value;
3
3
  type InvariantAssertionWithMessage = (value: unknown, failure?: Failure | (() => Failure)) => asserts value;
4
4
  declare const invariant: InvariantAssertionWithMessage;
5
5
 
6
+ declare class Lazy<T> {
7
+ private readonly factory;
8
+ private instance;
9
+ constructor(factory: () => T);
10
+ get(): T;
11
+ }
12
+
6
13
  declare const unreachable: (_: never) => never;
7
14
 
8
- export { type InvariantAssertion, type InvariantAssertionWithMessage, invariant, unreachable };
15
+ export { type InvariantAssertion, type InvariantAssertionWithMessage, Lazy, invariant, unreachable };
package/dist/values.d.ts CHANGED
@@ -3,6 +3,13 @@ type InvariantAssertion = (value: unknown) => asserts value;
3
3
  type InvariantAssertionWithMessage = (value: unknown, failure?: Failure | (() => Failure)) => asserts value;
4
4
  declare const invariant: InvariantAssertionWithMessage;
5
5
 
6
+ declare class Lazy<T> {
7
+ private readonly factory;
8
+ private instance;
9
+ constructor(factory: () => T);
10
+ get(): T;
11
+ }
12
+
6
13
  declare const unreachable: (_: never) => never;
7
14
 
8
- export { type InvariantAssertion, type InvariantAssertionWithMessage, invariant, unreachable };
15
+ export { type InvariantAssertion, type InvariantAssertionWithMessage, Lazy, invariant, unreachable };
package/dist/values.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/values/index.ts
21
21
  var values_exports = {};
22
22
  __export(values_exports, {
23
+ Lazy: () => Lazy,
23
24
  invariant: () => invariant,
24
25
  unreachable: () => unreachable
25
26
  });
@@ -46,12 +47,31 @@ var invariant = (value, failure) => {
46
47
  }
47
48
  };
48
49
 
50
+ // src/values/lazy.ts
51
+ var Lazy = class {
52
+ constructor(factory) {
53
+ this.factory = factory;
54
+ this.instance = { initialized: false };
55
+ }
56
+ get() {
57
+ const { initialized } = this.instance;
58
+ if (!initialized) {
59
+ this.instance = {
60
+ data: this.factory(),
61
+ initialized: true
62
+ };
63
+ }
64
+ return this.instance.data;
65
+ }
66
+ };
67
+
49
68
  // src/values/unreachable.ts
50
69
  var unreachable = (_) => {
51
70
  throw new Error("Unreachable code was reached at runtime.");
52
71
  };
53
72
  // Annotate the CommonJS export names for ESM import in node:
54
73
  0 && (module.exports = {
74
+ Lazy,
55
75
  invariant,
56
76
  unreachable
57
77
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/values/index.ts","../src/types/guards.ts","../src/values/invariant.ts","../src/values/unreachable.ts"],"sourcesContent":["export * from \"./invariant\";\nexport * from \"./unreachable\";\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 { isFunction, isNullOrUndefined, isString } from \"../types/guards\";\n\ntype Failure = string | Error;\n\nexport type InvariantAssertion = (value: unknown) => asserts value;\n\nexport type InvariantAssertionWithMessage = (\n\tvalue: unknown,\n\tfailure?: Failure | (() => Failure),\n) => asserts value;\n\nexport const invariant: InvariantAssertionWithMessage = (\n\tvalue,\n\tfailure,\n): asserts value => {\n\tif (value === false || isNullOrUndefined(value)) {\n\t\tconst failureOutput = isFunction(failure) ? failure() : failure;\n\n\t\tif (isString(failureOutput)) {\n\t\t\tthrow new Error(\n\t\t\t\tfailureOutput || `Assertion failed on value '${value}'.`,\n\t\t\t);\n\t\t}\n\n\t\tthrow failureOutput;\n\t}\n};\n","export const unreachable = (_: never): never => {\n\tthrow new Error(\"Unreachable code was reached at runtime.\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAQX,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ;AAET,IAAM,SAAS,CAAC,QAA8B,QAAQ;AAEtD,IAAM,oBAAoB,CAAC,QACjC,OAAO,GAAG,KAAK,YAAY,GAAG;AAKxB,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;AAET,IAAM,cAAc,CAAC,QAC3B,OAAO,QAAQ;;;ACZT,IAAM,YAA2C,CACvD,OACA,YACmB;AACnB,MAAI,UAAU,SAAS,kBAAkB,KAAK,GAAG;AAChD,UAAM,gBAAgB,WAAW,OAAO,IAAI,QAAQ,IAAI;AAExD,QAAI,SAAS,aAAa,GAAG;AAC5B,YAAM,IAAI;AAAA,QACT,iBAAiB,8BAA8B,KAAK;AAAA,MACrD;AAAA,IACD;AAEA,UAAM;AAAA,EACP;AACD;;;AC1BO,IAAM,cAAc,CAAC,MAAoB;AAC/C,QAAM,IAAI,MAAM,0CAA0C;AAC3D;","names":[]}
1
+ {"version":3,"sources":["../src/values/index.ts","../src/types/guards.ts","../src/values/invariant.ts","../src/values/lazy.ts","../src/values/unreachable.ts"],"sourcesContent":["export * from \"./invariant\";\nexport * from \"./lazy\";\nexport * from \"./unreachable\";\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 { isFunction, isNullOrUndefined, isString } from \"../types/guards\";\n\ntype Failure = string | Error;\n\nexport type InvariantAssertion = (value: unknown) => asserts value;\n\nexport type InvariantAssertionWithMessage = (\n\tvalue: unknown,\n\tfailure?: Failure | (() => Failure),\n) => asserts value;\n\nexport const invariant: InvariantAssertionWithMessage = (\n\tvalue,\n\tfailure,\n): asserts value => {\n\tif (value === false || isNullOrUndefined(value)) {\n\t\tconst failureOutput = isFunction(failure) ? failure() : failure;\n\n\t\tif (isString(failureOutput)) {\n\t\t\tthrow new Error(\n\t\t\t\tfailureOutput || `Assertion failed on value '${value}'.`,\n\t\t\t);\n\t\t}\n\n\t\tthrow failureOutput;\n\t}\n};\n","interface InitializedLazy<T> {\n\tdata: T;\n\tinitialized: true;\n}\n\ninterface UninitializedLazy {\n\tinitialized: false;\n}\n\ntype LazyInstance<T> = InitializedLazy<T> | UninitializedLazy;\n\nexport class Lazy<T> {\n\tprivate instance: LazyInstance<T>;\n\n\tpublic constructor(private readonly factory: () => T) {\n\t\tthis.instance = { initialized: false };\n\t}\n\n\tpublic get(): T {\n\t\tconst { initialized } = this.instance;\n\n\t\tif (!initialized) {\n\t\t\tthis.instance = {\n\t\t\t\tdata: this.factory(),\n\t\t\t\tinitialized: true,\n\t\t\t};\n\t\t}\n\n\t\treturn this.instance.data;\n\t}\n}\n","export const unreachable = (_: never): never => {\n\tthrow new Error(\"Unreachable code was reached at runtime.\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAQX,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ;AAET,IAAM,SAAS,CAAC,QAA8B,QAAQ;AAEtD,IAAM,oBAAoB,CAAC,QACjC,OAAO,GAAG,KAAK,YAAY,GAAG;AAKxB,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;AAET,IAAM,cAAc,CAAC,QAC3B,OAAO,QAAQ;;;ACZT,IAAM,YAA2C,CACvD,OACA,YACmB;AACnB,MAAI,UAAU,SAAS,kBAAkB,KAAK,GAAG;AAChD,UAAM,gBAAgB,WAAW,OAAO,IAAI,QAAQ,IAAI;AAExD,QAAI,SAAS,aAAa,GAAG;AAC5B,YAAM,IAAI;AAAA,QACT,iBAAiB,8BAA8B,KAAK;AAAA,MACrD;AAAA,IACD;AAEA,UAAM;AAAA,EACP;AACD;;;ACfO,IAAM,OAAN,MAAc;AAAA,EAGb,YAA6B,SAAkB;AAAlB;AACnC,SAAK,WAAW,EAAE,aAAa,MAAM;AAAA,EACtC;AAAA,EAEO,MAAS;AACf,UAAM,EAAE,YAAY,IAAI,KAAK;AAE7B,QAAI,CAAC,aAAa;AACjB,WAAK,WAAW;AAAA,QACf,MAAM,KAAK,QAAQ;AAAA,QACnB,aAAa;AAAA,MACd;AAAA,IACD;AAEA,WAAO,KAAK,SAAS;AAAA,EACtB;AACD;;;AC9BO,IAAM,cAAc,CAAC,MAAoB;AAC/C,QAAM,IAAI,MAAM,0CAA0C;AAC3D;","names":[]}
package/dist/values.mjs CHANGED
@@ -19,11 +19,30 @@ var invariant = (value, failure) => {
19
19
  }
20
20
  };
21
21
 
22
+ // src/values/lazy.ts
23
+ var Lazy = class {
24
+ constructor(factory) {
25
+ this.factory = factory;
26
+ this.instance = { initialized: false };
27
+ }
28
+ get() {
29
+ const { initialized } = this.instance;
30
+ if (!initialized) {
31
+ this.instance = {
32
+ data: this.factory(),
33
+ initialized: true
34
+ };
35
+ }
36
+ return this.instance.data;
37
+ }
38
+ };
39
+
22
40
  // src/values/unreachable.ts
23
41
  var unreachable = (_) => {
24
42
  throw new Error("Unreachable code was reached at runtime.");
25
43
  };
26
44
  export {
45
+ Lazy,
27
46
  invariant,
28
47
  unreachable
29
48
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/guards.ts","../src/values/invariant.ts","../src/values/unreachable.ts"],"sourcesContent":["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 { isFunction, isNullOrUndefined, isString } from \"../types/guards\";\n\ntype Failure = string | Error;\n\nexport type InvariantAssertion = (value: unknown) => asserts value;\n\nexport type InvariantAssertionWithMessage = (\n\tvalue: unknown,\n\tfailure?: Failure | (() => Failure),\n) => asserts value;\n\nexport const invariant: InvariantAssertionWithMessage = (\n\tvalue,\n\tfailure,\n): asserts value => {\n\tif (value === false || isNullOrUndefined(value)) {\n\t\tconst failureOutput = isFunction(failure) ? failure() : failure;\n\n\t\tif (isString(failureOutput)) {\n\t\t\tthrow new Error(\n\t\t\t\tfailureOutput || `Assertion failed on value '${value}'.`,\n\t\t\t);\n\t\t}\n\n\t\tthrow failureOutput;\n\t}\n};\n","export const unreachable = (_: never): never => {\n\tthrow new Error(\"Unreachable code was reached at runtime.\");\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAQX,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ;AAET,IAAM,SAAS,CAAC,QAA8B,QAAQ;AAEtD,IAAM,oBAAoB,CAAC,QACjC,OAAO,GAAG,KAAK,YAAY,GAAG;AAKxB,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;AAET,IAAM,cAAc,CAAC,QAC3B,OAAO,QAAQ;;;ACZT,IAAM,YAA2C,CACvD,OACA,YACmB;AACnB,MAAI,UAAU,SAAS,kBAAkB,KAAK,GAAG;AAChD,UAAM,gBAAgB,WAAW,OAAO,IAAI,QAAQ,IAAI;AAExD,QAAI,SAAS,aAAa,GAAG;AAC5B,YAAM,IAAI;AAAA,QACT,iBAAiB,8BAA8B,KAAK;AAAA,MACrD;AAAA,IACD;AAEA,UAAM;AAAA,EACP;AACD;;;AC1BO,IAAM,cAAc,CAAC,MAAoB;AAC/C,QAAM,IAAI,MAAM,0CAA0C;AAC3D;","names":[]}
1
+ {"version":3,"sources":["../src/types/guards.ts","../src/values/invariant.ts","../src/values/lazy.ts","../src/values/unreachable.ts"],"sourcesContent":["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 { isFunction, isNullOrUndefined, isString } from \"../types/guards\";\n\ntype Failure = string | Error;\n\nexport type InvariantAssertion = (value: unknown) => asserts value;\n\nexport type InvariantAssertionWithMessage = (\n\tvalue: unknown,\n\tfailure?: Failure | (() => Failure),\n) => asserts value;\n\nexport const invariant: InvariantAssertionWithMessage = (\n\tvalue,\n\tfailure,\n): asserts value => {\n\tif (value === false || isNullOrUndefined(value)) {\n\t\tconst failureOutput = isFunction(failure) ? failure() : failure;\n\n\t\tif (isString(failureOutput)) {\n\t\t\tthrow new Error(\n\t\t\t\tfailureOutput || `Assertion failed on value '${value}'.`,\n\t\t\t);\n\t\t}\n\n\t\tthrow failureOutput;\n\t}\n};\n","interface InitializedLazy<T> {\n\tdata: T;\n\tinitialized: true;\n}\n\ninterface UninitializedLazy {\n\tinitialized: false;\n}\n\ntype LazyInstance<T> = InitializedLazy<T> | UninitializedLazy;\n\nexport class Lazy<T> {\n\tprivate instance: LazyInstance<T>;\n\n\tpublic constructor(private readonly factory: () => T) {\n\t\tthis.instance = { initialized: false };\n\t}\n\n\tpublic get(): T {\n\t\tconst { initialized } = this.instance;\n\n\t\tif (!initialized) {\n\t\t\tthis.instance = {\n\t\t\t\tdata: this.factory(),\n\t\t\t\tinitialized: true,\n\t\t\t};\n\t\t}\n\n\t\treturn this.instance.data;\n\t}\n}\n","export const unreachable = (_: never): never => {\n\tthrow new Error(\"Unreachable code was reached at runtime.\");\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAQX,IAAM,aAAa,CAAC,QAC1B,OAAO,QAAQ;AAET,IAAM,SAAS,CAAC,QAA8B,QAAQ;AAEtD,IAAM,oBAAoB,CAAC,QACjC,OAAO,GAAG,KAAK,YAAY,GAAG;AAKxB,IAAM,WAAW,CAAC,QACxB,OAAO,QAAQ;AAET,IAAM,cAAc,CAAC,QAC3B,OAAO,QAAQ;;;ACZT,IAAM,YAA2C,CACvD,OACA,YACmB;AACnB,MAAI,UAAU,SAAS,kBAAkB,KAAK,GAAG;AAChD,UAAM,gBAAgB,WAAW,OAAO,IAAI,QAAQ,IAAI;AAExD,QAAI,SAAS,aAAa,GAAG;AAC5B,YAAM,IAAI;AAAA,QACT,iBAAiB,8BAA8B,KAAK;AAAA,MACrD;AAAA,IACD;AAEA,UAAM;AAAA,EACP;AACD;;;ACfO,IAAM,OAAN,MAAc;AAAA,EAGb,YAA6B,SAAkB;AAAlB;AACnC,SAAK,WAAW,EAAE,aAAa,MAAM;AAAA,EACtC;AAAA,EAEO,MAAS;AACf,UAAM,EAAE,YAAY,IAAI,KAAK;AAE7B,QAAI,CAAC,aAAa;AACjB,WAAK,WAAW;AAAA,QACf,MAAM,KAAK,QAAQ;AAAA,QACnB,aAAa;AAAA,MACd;AAAA,IACD;AAEA,WAAO,KAAK,SAAS;AAAA,EACtB;AACD;;;AC9BO,IAAM,cAAc,CAAC,MAAoB;AAC/C,QAAM,IAAI,MAAM,0CAA0C;AAC3D;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekumlin/typescript-toolkit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": "github:ek68794998/typescript-toolkit.git",
5
5
  "exports": {
6
6
  "./collections": "./dist/collections.js",