@stryke/http 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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.5.2-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.7.1-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
package/dist/index.cjs CHANGED
@@ -25,17 +25,6 @@ Object.keys(_formatDataUri).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
- var _helpers = require("./helpers.cjs");
29
- Object.keys(_helpers).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _helpers[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _helpers[key];
36
- }
37
- });
38
- });
39
28
  var _types = require("./types.cjs");
40
29
  Object.keys(_types).forEach(function (key) {
41
30
  if (key === "default" || key === "__esModule") return;
@@ -46,15 +35,4 @@ Object.keys(_types).forEach(function (key) {
46
35
  return _types[key];
47
36
  }
48
37
  });
49
- });
50
- var _url = require("./url.cjs");
51
- Object.keys(_url).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _url[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _url[key];
58
- }
59
- });
60
38
  });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  export * from "./cookie";
2
2
  export * from "./format-data-uri";
3
- export * from "./helpers";
4
3
  export * from "./types";
5
- export * from "./url";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./cookie";export*from"./format-data-uri";export*from"./helpers";export*from"./types";export*from"./url";
1
+ export*from"./cookie";export*from"./format-data-uri";export*from"./types";
package/dist/types.cjs CHANGED
@@ -1,7 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PROTOCOL_RELATIVE_SYMBOL = void 0;
7
- const PROTOCOL_RELATIVE_SYMBOL = exports.PROTOCOL_RELATIVE_SYMBOL = Symbol("protocol-relative");
1
+ "use strict";
package/dist/types.d.ts CHANGED
@@ -1,95 +1,5 @@
1
- export interface StormURLOptions {
2
- /**
3
- * Should the URL be decoded
4
- *
5
- * @defaultValue `true`
6
- */
7
- decode?: boolean;
8
- /**
9
- * Should the URL include a locale path segment
10
- */
11
- locale?: string | true;
12
- /**
13
- * The default protocol to use
14
- *
15
- * @defaultValue "https"
16
- */
17
- defaultProtocol?: string;
18
- }
19
- export declare const PROTOCOL_RELATIVE_SYMBOL: unique symbol;
20
- export interface IStormURL {
21
- /**
22
- * A string containing the username and password specified before the domain name.
23
- */
24
- auth: string;
25
- /**
26
- * A string containing the username specified before the domain name.
27
- */
28
- username?: string;
29
- /**
30
- * A string containing the password specified before the domain name.
31
- */
32
- password?: string;
33
- /**
34
- * A string containing the domain (that is the hostname) followed by (if a port was specified) a `:` and the port of the URL.
35
- */
36
- host: string;
37
- /**
38
- * A string containing the domain of the URL.
39
- */
40
- hostname?: string;
41
- /**
42
- * A string containing the port number of the URL.
43
- */
44
- port?: string;
45
- /**
46
- * A string containing the protocol scheme of the URL, including the final `:`.
47
- */
48
- protocol?: string;
49
- /**
50
- * A stringified value that returns the whole URL.
51
- */
52
- href: string;
53
- /**
54
- * A string containing an initial `/` followed by the path of the URL, not including the query string or fragment.
55
- */
56
- pathname: string;
57
- /**
58
- * The paths of the URL
59
- */
60
- paths: any[];
61
- /**
62
- * A string containing a `#` followed by the fragment identifier of the URL.
63
- */
64
- hash: string;
65
- /**
66
- * A string indicating the URL's parameter string; if any parameters are provided, this string includes all of them, beginning with the leading `?` character.
67
- */
68
- search: string;
69
- /**
70
- * The search parameters of the URL
71
- *
72
- * @remarks
73
- * This is a `URLSearchParams` object that contains the search parameters of the URL.
74
- */
75
- searchParams: URLSearchParams;
76
- /**
77
- * The search parameters of the URL
78
- *
79
- * @remarks
80
- * This is a Record\<string, any\> object that contains the search parameters of the URL.
81
- */
82
- params: Record<string, any>;
83
- /**
84
- * An optional symbol to indicate that the URL is protocol-relative
85
- *
86
- * @remarks
87
- * This is used when the URL is protocol-relative (e.g. //example.com)
88
- */
89
- [PROTOCOL_RELATIVE_SYMBOL]?: boolean;
90
- }
91
1
  /**
92
- * Additional serialization options
2
+ * Cookie serialization options
93
3
  */
94
4
  export interface CookieSerializeOptions {
95
5
  /**
package/dist/types.mjs CHANGED
@@ -1 +0,0 @@
1
- export const PROTOCOL_RELATIVE_SYMBOL=Symbol("protocol-relative");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/http",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "A package containing HTTP communication utilities used by Storm Software.",
6
6
  "repository": {
@@ -9,14 +9,9 @@
9
9
  "directory": "packages/http"
10
10
  },
11
11
  "private": false,
12
- "dependencies": {
13
- "ufo": "1.5.4",
14
- "@stryke/json": "^0.7.0",
15
- "@stryke/path": "^0.4.7",
16
- "@stryke/type-checks": "^0.2.0"
17
- },
18
12
  "devDependencies": { "@types/node": "^22.13.1" },
19
13
  "publishConfig": { "access": "public" },
14
+ "dependencies": { "@stryke/type-checks": "^0.3.2" },
20
15
  "sideEffects": false,
21
16
  "files": ["dist/**/*"],
22
17
  "homepage": "https://stormsoftware.com",
@@ -60,11 +55,6 @@
60
55
  }
61
56
  ],
62
57
  "exports": {
63
- "./url": {
64
- "import": { "types": "./dist/url.d.ts", "default": "./dist/url.mjs" },
65
- "require": { "types": "./dist/url.d.ts", "default": "./dist/url.cjs" },
66
- "default": { "types": "./dist/url.d.ts", "default": "./dist/url.mjs" }
67
- },
68
58
  "./types": {
69
59
  "import": { "types": "./dist/types.d.ts", "default": "./dist/types.mjs" },
70
60
  "require": {
@@ -81,20 +71,6 @@
81
71
  },
82
72
  "default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
83
73
  },
84
- "./helpers": {
85
- "import": {
86
- "types": "./dist/helpers.d.ts",
87
- "default": "./dist/helpers.mjs"
88
- },
89
- "require": {
90
- "types": "./dist/helpers.d.ts",
91
- "default": "./dist/helpers.cjs"
92
- },
93
- "default": {
94
- "types": "./dist/helpers.d.ts",
95
- "default": "./dist/helpers.mjs"
96
- }
97
- },
98
74
  "./format-data-uri": {
99
75
  "import": {
100
76
  "types": "./dist/format-data-uri.d.ts",
package/dist/helpers.cjs DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.formatLocalePath = formatLocalePath;
7
- function formatLocalePath(o) {
8
- let t = o;
9
- if (t.includes("_") && (t = t.replace(/_/g, "-")), t.includes("-")) {
10
- const e = t.split("-");
11
- if (e.length > 1) {
12
- const n = e[0],
13
- i = e[1];
14
- n && i && (t = `${n}-${i}`);
15
- }
16
- }
17
- return t.toLowerCase();
18
- }
package/dist/helpers.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function formatLocalePath(locale: string): string;
package/dist/helpers.mjs DELETED
@@ -1 +0,0 @@
1
- export function formatLocalePath(o){let t=o;if(t.includes("_")&&(t=t.replace(/_/g,"-")),t.includes("-")){const e=t.split("-");if(e.length>1){const n=e[0],i=e[1];n&&i&&(t=`${n}-${i}`)}}return t.toLowerCase()}
package/dist/url.cjs DELETED
@@ -1,168 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StormURL = void 0;
7
- var _stormJson = require("@stryke/json/storm-json");
8
- var _joinPaths = require("@stryke/path/join-paths");
9
- var _isInteger = require("@stryke/type-checks/is-integer");
10
- var _isSetString = require("@stryke/type-checks/is-set-string");
11
- var _isUndefined = require("@stryke/type-checks/is-undefined");
12
- var _ufo = require("ufo");
13
- var _helpers = require("./helpers.cjs");
14
- class StormURL {
15
- #a;
16
- #i;
17
- #r;
18
- #t;
19
- #s;
20
- #o;
21
- #e = [];
22
- #h;
23
- #n;
24
- constructor(t, s = {
25
- decode: !0
26
- }) {
27
- this.#a = s;
28
- const i = (0, _ufo.parseURL)(this.#a.decode ? (0, _ufo.decode)(t) : t),
29
- h = (0, _ufo.parseAuth)(i.auth);
30
- this.#i = h.username, this.#r = h.password;
31
- const a = (0, _ufo.parseHost)(i.host);
32
- this.#t = a.hostname, this.#s = a.port, this.#o = i.protocol, this.#h = i.hash || "", this.#n = (0, _ufo.parseQuery)(i.search), this.#e = i.pathname ? i.pathname.split("/").filter(Boolean) : [], s.locale && this.#e.unshift((0, _helpers.formatLocalePath)(((0, _isSetString.isSetString)(s.locale) ? s.locale : process.env.DEFAULT_LOCALE) || "en-us"));
33
- }
34
- set params(t) {
35
- this.#n = t;
36
- }
37
- get params() {
38
- return this.#n;
39
- }
40
- get searchParams() {
41
- const t = new URLSearchParams();
42
- for (const [s, i] of Object.entries(this.params)) t.append(s, i);
43
- return t;
44
- }
45
- set searchParams(t) {
46
- this.params = Object.fromEntries(t.entries());
47
- }
48
- set search(t) {
49
- this.params = (0, _ufo.parseQuery)(t);
50
- }
51
- get search() {
52
- const t = (0, _ufo.stringifyQuery)(this.params);
53
- return t ? t.startsWith("?") ? t : `?${t}` : "";
54
- }
55
- set hash(t) {
56
- this.#h = t.startsWith("#") ? t : `#${t}`;
57
- }
58
- get hash() {
59
- return this.#h;
60
- }
61
- set port(t) {
62
- this.#s = !(0, _isUndefined.isUndefined)(t) && (0, _isInteger.isInteger)(t) ? `${t}` : void 0;
63
- }
64
- get port() {
65
- return this.#s;
66
- }
67
- set auth(t) {
68
- const s = (0, _ufo.parseAuth)(t);
69
- this.#i = s.username, this.#r = s.password;
70
- }
71
- get auth() {
72
- return this.#i && this.#r ? `${this.#i}:${this.#r}` : this.#i ? this.#i : this.#r ? this.#r : "";
73
- }
74
- set protocol(t) {
75
- this.#o = t.endsWith(":") ? t : t.endsWith("://") ? t.slice(0, -2) : `${t}:`;
76
- }
77
- get protocol() {
78
- return this.#o || this.#a.defaultProtocol || "https:";
79
- }
80
- set hostname(t) {
81
- this.#t = t;
82
- }
83
- get hostname() {
84
- return this.#t;
85
- }
86
- set host(t) {
87
- const s = (0, _ufo.parseHost)(t);
88
- this.#t = s.hostname, this.#s = s.port;
89
- }
90
- get host() {
91
- return this.#t && this.#s ? `${this.#t}:${this.#s}` : this.#t ? this.#t : this.#s ? this.#s : "";
92
- }
93
- set paths(t) {
94
- this.#e = t.filter(Boolean);
95
- }
96
- get paths() {
97
- return this.#e;
98
- }
99
- set pathname(t) {
100
- this.paths = (0, _ufo.cleanDoubleSlashes)(t).split("/");
101
- }
102
- get pathname() {
103
- return `/${this.paths ? (0, _joinPaths.joinPaths)(...this.paths.map(t => _stormJson.StormJSON.stringify(t))) : ""}`;
104
- }
105
- set path(t) {
106
- const s = (0, _ufo.parsePath)(t);
107
- this.pathname = s.pathname, this.search = s.search, this.#h = s.hash;
108
- }
109
- get path() {
110
- return (0, _ufo.stringifyParsedURL)({
111
- pathname: this.pathname,
112
- search: this.search,
113
- hash: this.hash
114
- });
115
- }
116
- get href() {
117
- return this.toString();
118
- }
119
- set href(t) {
120
- const s = (0, _ufo.parseURL)(t);
121
- this.protocol = s.protocol || this.protocol, this.auth = s.auth || this.auth, this.host = s.host || this.host, this.pathname = s.pathname || this.pathname, this.search = s.search || this.search, this.hash = s.hash || this.hash;
122
- }
123
- get origin() {
124
- return `${this.protocol}//${this.host}`;
125
- }
126
- get isScriptProtocol() {
127
- return (0, _ufo.isScriptProtocol)(this.protocol);
128
- }
129
- get isRelative() {
130
- return (0, _ufo.isRelative)(this.toString());
131
- }
132
- get isNonEmptyURL() {
133
- return (0, _ufo.isNonEmptyURL)(this.toString());
134
- }
135
- get __typename() {
136
- return "StormURL";
137
- }
138
- isSamePath(t) {
139
- return (0, _ufo.isSamePath)(this.path, t);
140
- }
141
- isEqual(t) {
142
- return (0, _ufo.isEqual)(this.toString(), typeof t == "string" ? t : t instanceof StormURL ? t.toString() : (0, _ufo.stringifyParsedURL)(t));
143
- }
144
- toParsed() {
145
- return {
146
- protocol: this.protocol,
147
- auth: this.auth,
148
- host: this.host,
149
- pathname: this.pathname,
150
- search: this.search,
151
- hash: this.hash
152
- };
153
- }
154
- toString() {
155
- return (0, _ufo.stringifyParsedURL)(this.toParsed());
156
- }
157
- toEncoded() {
158
- return (0, _ufo.normalizeURL)(this.toString());
159
- }
160
- }
161
- exports.StormURL = StormURL;
162
- _stormJson.StormJSON.instance.registerCustom({
163
- isApplicable: r => r.__typename === "StormURL",
164
- serialize: r => r.toEncoded(),
165
- deserialize: r => new StormURL(r, {
166
- decode: !0
167
- })
168
- }, "StormURL");
package/dist/url.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import type { ParsedURL } from "ufo";
2
- import type { IStormURL, StormURLOptions } from "./types";
3
- /**
4
- * A class used to build URLs
5
- *
6
- * @remarks
7
- * This class is used to build URLs with a fluent API.
8
- *
9
- * The [UFO](https://github.com/unjs/ufo) library is used under the hood to parse and stringify URLs.
10
- */
11
- export declare class StormURL implements IStormURL, Partial<URL> {
12
- #private;
13
- constructor(initialURL: string, options?: StormURLOptions);
14
- set params(value: Record<string, any>);
15
- get params(): Record<string, any>;
16
- get searchParams(): URLSearchParams;
17
- set searchParams(value: URLSearchParams);
18
- set search(value: string);
19
- get search(): string;
20
- set hash(value: string);
21
- get hash(): string;
22
- set port(value: string | number | undefined);
23
- get port(): string | undefined;
24
- set auth(value: string | undefined);
25
- get auth(): string;
26
- set protocol(value: string);
27
- get protocol(): string;
28
- set hostname(value: string);
29
- get hostname(): string;
30
- set host(value: string | undefined);
31
- get host(): string;
32
- set paths(value: any[]);
33
- get paths(): any[];
34
- set pathname(value: string);
35
- get pathname(): string;
36
- set path(value: string);
37
- get path(): string;
38
- get href(): string;
39
- set href(value: string);
40
- get origin(): string;
41
- get isScriptProtocol(): boolean;
42
- get isRelative(): boolean;
43
- get isNonEmptyURL(): boolean;
44
- get __typename(): string;
45
- isSamePath(path: string): boolean;
46
- isEqual(url: string | ParsedURL | StormURL): boolean;
47
- toParsed(): ParsedURL;
48
- toString(): string;
49
- toEncoded(): string;
50
- }
package/dist/url.mjs DELETED
@@ -1 +0,0 @@
1
- import{StormJSON as o}from"@stryke/json/storm-json";import{joinPaths as m}from"@stryke/path/join-paths";import{isInteger as l}from"@stryke/type-checks/is-integer";import{isSetString as g}from"@stryke/type-checks/is-set-string";import{isUndefined as d}from"@stryke/type-checks/is-undefined";import{cleanDoubleSlashes as b,decode as f,isEqual as R,isNonEmptyURL as S,isRelative as L,isSamePath as U,isScriptProtocol as P,normalizeURL as y,parseAuth as n,parseHost as p,parsePath as $,parseQuery as c,parseURL as u,stringifyParsedURL as e,stringifyQuery as E}from"ufo";import{formatLocalePath as O}from"./helpers";export class StormURL{#a;#i;#r;#t;#s;#o;#e=[];#h;#n;constructor(t,s={decode:!0}){this.#a=s;const i=u(this.#a.decode?f(t):t),h=n(i.auth);this.#i=h.username,this.#r=h.password;const a=p(i.host);this.#t=a.hostname,this.#s=a.port,this.#o=i.protocol,this.#h=i.hash||"",this.#n=c(i.search),this.#e=i.pathname?i.pathname.split("/").filter(Boolean):[],s.locale&&this.#e.unshift(O((g(s.locale)?s.locale:process.env.DEFAULT_LOCALE)||"en-us"))}set params(t){this.#n=t}get params(){return this.#n}get searchParams(){const t=new URLSearchParams;for(const[s,i]of Object.entries(this.params))t.append(s,i);return t}set searchParams(t){this.params=Object.fromEntries(t.entries())}set search(t){this.params=c(t)}get search(){const t=E(this.params);return t?t.startsWith("?")?t:`?${t}`:""}set hash(t){this.#h=t.startsWith("#")?t:`#${t}`}get hash(){return this.#h}set port(t){this.#s=!d(t)&&l(t)?`${t}`:void 0}get port(){return this.#s}set auth(t){const s=n(t);this.#i=s.username,this.#r=s.password}get auth(){return this.#i&&this.#r?`${this.#i}:${this.#r}`:this.#i?this.#i:this.#r?this.#r:""}set protocol(t){this.#o=t.endsWith(":")?t:t.endsWith("://")?t.slice(0,-2):`${t}:`}get protocol(){return this.#o||this.#a.defaultProtocol||"https:"}set hostname(t){this.#t=t}get hostname(){return this.#t}set host(t){const s=p(t);this.#t=s.hostname,this.#s=s.port}get host(){return this.#t&&this.#s?`${this.#t}:${this.#s}`:this.#t?this.#t:this.#s?this.#s:""}set paths(t){this.#e=t.filter(Boolean)}get paths(){return this.#e}set pathname(t){this.paths=b(t).split("/")}get pathname(){return`/${this.paths?m(...this.paths.map(t=>o.stringify(t))):""}`}set path(t){const s=$(t);this.pathname=s.pathname,this.search=s.search,this.#h=s.hash}get path(){return e({pathname:this.pathname,search:this.search,hash:this.hash})}get href(){return this.toString()}set href(t){const s=u(t);this.protocol=s.protocol||this.protocol,this.auth=s.auth||this.auth,this.host=s.host||this.host,this.pathname=s.pathname||this.pathname,this.search=s.search||this.search,this.hash=s.hash||this.hash}get origin(){return`${this.protocol}//${this.host}`}get isScriptProtocol(){return P(this.protocol)}get isRelative(){return L(this.toString())}get isNonEmptyURL(){return S(this.toString())}get __typename(){return"StormURL"}isSamePath(t){return U(this.path,t)}isEqual(t){return R(this.toString(),typeof t=="string"?t:t instanceof StormURL?t.toString():e(t))}toParsed(){return{protocol:this.protocol,auth:this.auth,host:this.host,pathname:this.pathname,search:this.search,hash:this.hash}}toString(){return e(this.toParsed())}toEncoded(){return y(this.toString())}}o.instance.registerCustom({isApplicable:r=>r.__typename==="StormURL",serialize:r=>r.toEncoded(),deserialize:r=>new StormURL(r,{decode:!0})},"StormURL");