@stryke/http 0.3.1 → 0.4.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <!-- markdownlint-disable -->
4
4
 
5
5
 
6
- <div align="center"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/storm-banner.gif" width="100%" alt="Storm Software" /></div>
6
+ <div align="center"><img src="https://public.storm-cdn.com/storm-banner.gif" width="100%" alt="Storm Software" /></div>
7
7
  <br />
8
8
 
9
9
  <div align="center">
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŸŒŠī¸ Stryke** monorepo. Stryke pac
22
22
 
23
23
  <h3 align="center">đŸ’ģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
24
24
 
25
- [![Version](https://img.shields.io/badge/version-0.1.4-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
+ [![Version](https://img.shields.io/badge/version-0.4.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
26
 
27
27
  > [!IMPORTANT] This repository, and the apps, libraries, and tools contained
28
28
  > within, is still in it's initial development phase. As a result, bugs and
@@ -51,7 +51,6 @@ between processes easier in other packages/applications.
51
51
 
52
52
  <!-- START doctoc -->
53
53
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
54
-
55
54
  ## Table of Contents
56
55
 
57
56
  - [Installing](#installing)
@@ -247,7 +246,7 @@ specification. Contributions of any kind welcome!
247
246
  <br />
248
247
 
249
248
  <div align="center">
250
- <img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-banner.png" width="100%" alt="Storm Software" />
249
+ <img src="https://public.storm-cdn.com/logo-banner.png" width="100%" alt="Storm Software" />
251
250
  </div>
252
251
  <br />
253
252
 
@@ -278,9 +277,9 @@ generation of development tools, please reach out on our
278
277
 
279
278
  <br />
280
279
 
281
- <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
280
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
282
281
  <br />
283
- <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
282
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
284
283
 
285
284
  <br />
286
285
 
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ParsedURL } from "ufo";
2
2
  export type StormURL = ParsedURL & {
3
3
  __typename: "StormURL";
4
- query: Record<string, any>;
4
+ queryParams: Record<string, any>;
5
5
  username?: string;
6
6
  password?: string;
7
7
  hostname?: string;
@@ -27,13 +27,13 @@ export interface CookieSerializeOptions {
27
27
  * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
28
28
  * any that fall outside of the cookie range.
29
29
  */
30
- encode?(value: string): string;
30
+ encode?: (value: string) => string;
31
31
  /**
32
32
  * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1 | `Expires` `Set-Cookie` attribute}. By default,
33
33
  * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
34
34
  * it on a condition like exiting a web browser application.
35
35
  *
36
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
36
+ * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
37
37
  * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
38
38
  * possible not all clients by obey this, so if both are set, they should
39
39
  * point to the same date and time.
@@ -44,7 +44,7 @@ export interface CookieSerializeOptions {
44
44
  * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
45
45
  * default, the `HttpOnly` attribute is not set.
46
46
  *
47
- * *Note* be careful when setting this to true, as compliant clients will
47
+ * Note* be careful when setting this to true, as compliant clients will
48
48
  * not allow client-side JavaScript to see the cookie in `document.cookie`.
49
49
  */
50
50
  httpOnly?: boolean | undefined;
@@ -53,7 +53,7 @@ export interface CookieSerializeOptions {
53
53
  * `Set-Cookie` attribute. The given number will be converted to an integer
54
54
  * by rounding down. By default, no maximum age is set.
55
55
  *
56
- * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
56
+ * Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3 | cookie storage model specification}
57
57
  * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
58
58
  * possible not all clients by obey this, so if both are set, they should
59
59
  * point to the same date and time.
@@ -93,14 +93,14 @@ export interface CookieSerializeOptions {
93
93
  *
94
94
  * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
95
95
  *
96
- * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
96
+ * note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
97
97
  */
98
98
  sameSite?: true | false | "lax" | "strict" | "none" | undefined;
99
99
  /**
100
100
  * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5 | `Secure` `Set-Cookie` attribute}. When truthy, the
101
101
  * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
102
102
  *
103
- * *Note* be careful when setting this to `true`, as compliant clients will
103
+ * Note* be careful when setting this to `true`, as compliant clients will
104
104
  * not send the cookie back to the server in the future if the browser does
105
105
  * not have an HTTPS connection.
106
106
  */
@@ -130,14 +130,14 @@ export interface CookieParseOptions {
130
130
  * The default function is the global `decodeURIComponent`, which will decode
131
131
  * any URL-encoded sequences into their byte representations.
132
132
  *
133
- * *Note* if an error is thrown from this function, the original, non-decoded
133
+ * Note* if an error is thrown from this function, the original, non-decoded
134
134
  * cookie value will be returned as the cookie's value.
135
135
  */
136
- decode?(value: string): string;
136
+ decode?: (value: string) => string;
137
137
  /**
138
138
  * Custom function to filter parsing specific keys.
139
139
  */
140
- filter?(key: string): boolean;
140
+ filter?: (key: string) => boolean;
141
141
  }
142
142
  export interface SetCookieParseOptions {
143
143
  /**
@@ -17,7 +17,7 @@ class StormURLBuilder {
17
17
  n = (0, _isString.isString)(r) ? s ? (0, _ufo.parseURL)((0, _ufo.decode)(r)) : (0, _ufo.parseURL)(r) : r;
18
18
  this.#r = {
19
19
  __typename: "StormURL",
20
- query: {},
20
+ queryParams: {},
21
21
  ...n
22
22
  }, this.#r.host && this.withHost(this.#r.host), this.#r.auth && this.withAuth(this.#r.auth);
23
23
  }
@@ -66,13 +66,13 @@ class StormURLBuilder {
66
66
  return this;
67
67
  }
68
68
  withQuery(r) {
69
- return this.#r.query = {}, this.addQueryParam(r), this;
69
+ return this.#r.queryParams = {}, this.addQueryParam(r), this;
70
70
  }
71
71
  addQueryParam(r) {
72
72
  if ((0, _isString.isString)(r)) {
73
73
  const t = (0, _ufo.parseQuery)(r);
74
- for (const s in Object.entries(t)) s[0] && (this.#r.query[s[0]] = this.parseQueryParamValue(s[1]));
75
- } else if (Array.isArray(r) && r.length === 2) this.#r.query[r[0]] = this.parseQueryParamValue(r[1]);else for (const t in Object.entries(r)) t[0] && (this.#r.query[t[0]] = this.parseQueryParamValue(t[1]));
74
+ for (const s of Object.entries(t)) s[0] && (this.#r.queryParams[s[0]] = this.parseQueryParamValue(s[1]));
75
+ } else if (Array.isArray(r) && r.length === 2) this.#r.queryParams[r[0]] = this.parseQueryParamValue(r[1]);else for (const t of Object.entries(r)) t[0] && (this.#r.queryParams[t[0]] = this.parseQueryParamValue(t[1]));
76
76
  return this;
77
77
  }
78
78
  build() {
@@ -87,7 +87,7 @@ class StormURLBuilder {
87
87
  parseQueryParamValue(r) {
88
88
  if (Array.isArray(r)) {
89
89
  const t = [];
90
- for (const s in r) t.push(this.parseQueryParamValue(s));
90
+ for (const s of r) t.push(this.parseQueryParamValue(s));
91
91
  return t;
92
92
  }
93
93
  return _stormJson.StormJSON.parse(r);
@@ -106,10 +106,10 @@ export declare class StormURLBuilder {
106
106
  /**
107
107
  * Add a query parameter to the URL
108
108
  *
109
- * @param query - The query parameter to add
109
+ * @param queryParam - The query parameter to add
110
110
  * @returns The URL builder
111
111
  */
112
- addQueryParam(query: string | [string, any] | Record<string, any>): StormURLBuilder;
112
+ addQueryParam(queryParam: string | [string, any] | Record<string, any>): StormURLBuilder;
113
113
  /**
114
114
  * Returns the built URL
115
115
  *
@@ -1 +1 @@
1
- import{StormJSON as a}from"@stryke/json/storm-json";import{isString as i}from"@stryke/type-checks/is-string";import{cleanDoubleSlashes as u,decode as h,encode as p,parseAuth as e,parsePath as d,parseQuery as m,parseURL as o,stringifyParsedURL as c}from"ufo";export class StormURLBuilder{#r;static create(r,t){return new StormURLBuilder(r,t)}constructor(r,t){const s=t?.decode??!0,n=i(r)?s?o(h(r)):o(r):r;this.#r={__typename:"StormURL",query:{},...n},this.#r.host&&this.withHost(this.#r.host),this.#r.auth&&this.withAuth(this.#r.auth)}get _url(){return this.#r}withProtocol(r){return this.#r.protocol=r,this}withHostname(r){return this.#r.hostname=r,this}withPort(r){return this.#r.port=String(r),this}withUsername(r){return this.#r.username=r,this}withPassword(r){return this.#r.password=r,this}withHost(r){if(i(r)){this.#r.host=r;const t=e(r);this.#r.username=t.username,this.#r.password=t.password}else this.#r.hostname=r.hostname,this.#r.port=r.port,this.#r.auth=`${r.hostname}${r.port?`:${r.port}`:""}`;return this}withPath(r){const t=d(r);return this.#r={...this.#r,...t},this}withHash(r){return this.#r.hash=r,this}withAuth(r){if(i(r)){this.#r.auth=r;const t=e(r);this.#r.username=t.username,this.#r.password=t.password}else this.#r.username=r.username,this.#r.password=r.password,this.#r.auth=`${r.username}:${r.password}`;return this}withQuery(r){return this.#r.query={},this.addQueryParam(r),this}addQueryParam(r){if(i(r)){const t=m(r);for(const s in Object.entries(t))s[0]&&(this.#r.query[s[0]]=this.parseQueryParamValue(s[1]))}else if(Array.isArray(r)&&r.length===2)this.#r.query[r[0]]=this.parseQueryParamValue(r[1]);else for(const t in Object.entries(r))t[0]&&(this.#r.query[t[0]]=this.parseQueryParamValue(t[1]));return this}build(){return this.#r}toString(){return u(c(this.#r))}toEncoded(){return p(this.toString())}parseQueryParamValue(r){if(Array.isArray(r)){const t=[];for(const s in r)t.push(this.parseQueryParamValue(s));return t}return a.parse(r)}}
1
+ import{StormJSON as a}from"@stryke/json/storm-json";import{isString as i}from"@stryke/type-checks/is-string";import{cleanDoubleSlashes as u,decode as h,encode as p,parseAuth as e,parsePath as d,parseQuery as m,parseURL as o,stringifyParsedURL as c}from"ufo";export class StormURLBuilder{#r;static create(r,t){return new StormURLBuilder(r,t)}constructor(r,t){const s=t?.decode??!0,n=i(r)?s?o(h(r)):o(r):r;this.#r={__typename:"StormURL",queryParams:{},...n},this.#r.host&&this.withHost(this.#r.host),this.#r.auth&&this.withAuth(this.#r.auth)}get _url(){return this.#r}withProtocol(r){return this.#r.protocol=r,this}withHostname(r){return this.#r.hostname=r,this}withPort(r){return this.#r.port=String(r),this}withUsername(r){return this.#r.username=r,this}withPassword(r){return this.#r.password=r,this}withHost(r){if(i(r)){this.#r.host=r;const t=e(r);this.#r.username=t.username,this.#r.password=t.password}else this.#r.hostname=r.hostname,this.#r.port=r.port,this.#r.auth=`${r.hostname}${r.port?`:${r.port}`:""}`;return this}withPath(r){const t=d(r);return this.#r={...this.#r,...t},this}withHash(r){return this.#r.hash=r,this}withAuth(r){if(i(r)){this.#r.auth=r;const t=e(r);this.#r.username=t.username,this.#r.password=t.password}else this.#r.username=r.username,this.#r.password=r.password,this.#r.auth=`${r.username}:${r.password}`;return this}withQuery(r){return this.#r.queryParams={},this.addQueryParam(r),this}addQueryParam(r){if(i(r)){const t=m(r);for(const s of Object.entries(t))s[0]&&(this.#r.queryParams[s[0]]=this.parseQueryParamValue(s[1]))}else if(Array.isArray(r)&&r.length===2)this.#r.queryParams[r[0]]=this.parseQueryParamValue(r[1]);else for(const t of Object.entries(r))t[0]&&(this.#r.queryParams[t[0]]=this.parseQueryParamValue(t[1]));return this}build(){return this.#r}toString(){return u(c(this.#r))}toEncoded(){return p(this.toString())}parseQueryParamValue(r){if(Array.isArray(r)){const t=[];for(const s of r)t.push(this.parseQueryParamValue(s));return t}return a.parse(r)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/http",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "A package containing HTTP communication utilities used by Storm Software.",
6
6
  "repository": {
@@ -11,8 +11,8 @@
11
11
  "private": false,
12
12
  "dependencies": {
13
13
  "ufo": "1.5.4",
14
- "@stryke/json": ">=0.5.1",
15
- "@stryke/type-checks": ">=0.1.1"
14
+ "@stryke/json": ">=0.5.2",
15
+ "@stryke/type-checks": ">=0.1.2"
16
16
  },
17
17
  "devDependencies": { "@types/node": "^22.13.1" },
18
18
  "publishConfig": { "access": "public" },