@hkdigital/lib-sveltekit 0.0.71 → 0.0.73

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.
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Make GET request
9
9
  *
10
- * @paramm {object} _
10
+ * @param {object} _
11
11
  *
12
12
  * @param {string|URL} _.url - Url string or URL object
13
13
  *
@@ -25,13 +25,19 @@
25
25
  * If defined, this request will abort after the specified number of
26
26
  * milliseconds. Values above the the built-in request timeout won't work.
27
27
  *
28
- * @returns {Promise<*>} responsePromise
28
+ * @returns {Promise<Response>} responsePromise
29
29
  */
30
- export function httpGet({ url, urlSearchParams, headers, requestHandler, timeoutMs }: string | URL): Promise<any>;
30
+ export function httpGet({ url, urlSearchParams, headers, requestHandler, timeoutMs }: {
31
+ url: string | URL;
32
+ urlSearchParams?: object;
33
+ headers?: object;
34
+ requestHandler?: requestHandler;
35
+ timeoutMs?: number;
36
+ }): Promise<Response>;
31
37
  /**
32
38
  * Make POST request
33
39
  *
34
- * @paramm {object} _
40
+ * @param {object} _
35
41
  *
36
42
  * @param {string|URL} _.url - Url string or URL object
37
43
  *
@@ -48,15 +54,21 @@ export function httpGet({ url, urlSearchParams, headers, requestHandler, timeout
48
54
  * If defined, this request will abort after the specified number of
49
55
  * milliseconds. Values above the the built-in request timeout won't work.
50
56
  *
51
- * @returns {Promise<*>} responsePromise
57
+ * @returns {Promise<Response>} responsePromise
52
58
  */
53
- export function httpPost({ url, body, headers, requestHandler, timeoutMs }: string | URL): Promise<any>;
59
+ export function httpPost({ url, body, headers, requestHandler, timeoutMs }: {
60
+ url: string | URL;
61
+ body?: any;
62
+ headers?: object;
63
+ requestHandler?: requestHandler;
64
+ timeoutMs?: number;
65
+ }): Promise<Response>;
54
66
  /**
55
67
  * Make an HTTP request
56
68
  * - This is a low level function, consider using
57
69
  * httpGet, httpPost, jsonGet or jsonPost instead
58
70
  *
59
- * @paramm {object} _
71
+ * @param {object} _
60
72
  *
61
73
  * @param {string|URL} _.url - Url string or URL object
62
74
  *
@@ -84,5 +96,13 @@ export function httpPost({ url, body, headers, requestHandler, timeoutMs }: stri
84
96
  *
85
97
  * @returns {Promise<Response>} responsePromise
86
98
  */
87
- export function httpRequest({ method, url, urlSearchParams, body, headers, requestHandler, timeoutMs }: string | URL): Promise<Response>;
99
+ export function httpRequest({ method, url, urlSearchParams, body, headers, requestHandler, timeoutMs }: {
100
+ url: string | URL;
101
+ method: string;
102
+ urlSearchParams?: object;
103
+ body?: any;
104
+ headers?: object;
105
+ requestHandler?: requestHandler;
106
+ timeoutMs?: number;
107
+ }): Promise<Response>;
88
108
  export type requestHandler = (controller: AbortController, abort: (reason?: Error) => void, timeout: (delayMs: number) => void) => any;
@@ -1,7 +1,7 @@
1
1
  import { METHOD_GET, METHOD_POST } from '../../constants/http/methods.js';
2
2
 
3
3
  import { APPLICATION_JSON } from '../../constants/mime/application.js';
4
- import { CONTENT_TYPE, CONTENT_LENGTH } from '../../constants/http/headers.js';
4
+ import { CONTENT_TYPE } from '../../constants/http/headers.js';
5
5
 
6
6
  import { AbortError, TimeoutError } from '../../constants/errors/api.js';
7
7
 
@@ -21,7 +21,7 @@ import { waitForAndCheckResponse } from './response.js';
21
21
  /**
22
22
  * Make GET request
23
23
  *
24
- * @paramm {object} _
24
+ * @param {object} _
25
25
  *
26
26
  * @param {string|URL} _.url - Url string or URL object
27
27
  *
@@ -39,7 +39,7 @@ import { waitForAndCheckResponse } from './response.js';
39
39
  * If defined, this request will abort after the specified number of
40
40
  * milliseconds. Values above the the built-in request timeout won't work.
41
41
  *
42
- * @returns {Promise<*>} responsePromise
42
+ * @returns {Promise<Response>} responsePromise
43
43
  */
44
44
  export async function httpGet({ url, urlSearchParams, headers, requestHandler, timeoutMs }) {
45
45
  const responsePromise = httpRequest({
@@ -57,7 +57,7 @@ export async function httpGet({ url, urlSearchParams, headers, requestHandler, t
57
57
  /**
58
58
  * Make POST request
59
59
  *
60
- * @paramm {object} _
60
+ * @param {object} _
61
61
  *
62
62
  * @param {string|URL} _.url - Url string or URL object
63
63
  *
@@ -74,7 +74,7 @@ export async function httpGet({ url, urlSearchParams, headers, requestHandler, t
74
74
  * If defined, this request will abort after the specified number of
75
75
  * milliseconds. Values above the the built-in request timeout won't work.
76
76
  *
77
- * @returns {Promise<*>} responsePromise
77
+ * @returns {Promise<Response>} responsePromise
78
78
  */
79
79
  export async function httpPost({ url, body = null, headers, requestHandler, timeoutMs }) {
80
80
  const responsePromise = httpRequest({
@@ -96,7 +96,7 @@ export async function httpPost({ url, body = null, headers, requestHandler, time
96
96
  * - This is a low level function, consider using
97
97
  * httpGet, httpPost, jsonGet or jsonPost instead
98
98
  *
99
- * @paramm {object} _
99
+ * @param {object} _
100
100
  *
101
101
  * @param {string|URL} _.url - Url string or URL object
102
102
  *
@@ -229,7 +229,10 @@ export async function httpRequest({
229
229
  const promise = fetch(request, { signal });
230
230
 
231
231
  if (requestHandler || timeoutMs) {
232
- const abort = (/** @type {Error?} */ reason) => {
232
+ /**
233
+ * @type {(any?: reason) => void}
234
+ */
235
+ const abort = (reason) => {
233
236
  if (!reason) {
234
237
  reason = new AbortError(`Request [${url.href}] aborted`);
235
238
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {
@@ -45,158 +45,7 @@
45
45
  "types": "./dist/index.d.ts",
46
46
  "type": "module",
47
47
  "exports": {
48
- ".": {
49
- "types": "./dist/index.d.ts",
50
- "svelte": "./dist/index.js"
51
- },
52
- "./classes": {
53
- "types": "./dist/classes/index.d.ts",
54
- "svelte": "./dist/classes/index.js"
55
- },
56
- "./classes/data": {
57
- "types": "./dist/classes/data/index.d.ts",
58
- "svelte": "./dist/classes/data/index.js"
59
- },
60
- "./classes/promise": {
61
- "types": "./dist/classes/promise/index.d.ts",
62
- "svelte": "./dist/classes/promise/index.js"
63
- },
64
- "./classes/streams": {
65
- "types": "./dist/classes/streams/index.d.ts",
66
- "svelte": "./dist/classes/streams/index.js"
67
- },
68
- "./classes/stores": {
69
- "types": "./dist/classes/stores/index.d.ts",
70
- "svelte": "./dist/classes/stores/index.js"
71
- },
72
- "./components": {
73
- "types": "./dist/components/index.d.ts",
74
- "svelte": "./dist/components/index.js"
75
- },
76
- "./components/area": {
77
- "types": "./dist/components/area/index.d.ts",
78
- "svelte": "./dist/components/area/index.js"
79
- },
80
- "./components/icon": {
81
- "types": "./dist/components/icon/index.d.ts",
82
- "svelte": "./dist/components/icon/index.js"
83
- },
84
- "./components/image": {
85
- "types": "./dist/components/image/index.d.ts",
86
- "svelte": "./dist/components/image/index.js"
87
- },
88
- "./components/input": {
89
- "types": "./dist/components/input/index.d.ts",
90
- "svelte": "./dist/components/input/index.js"
91
- },
92
- "./components/layout": {
93
- "types": "./dist/components/layout/index.d.ts",
94
- "svelte": "./dist/components/layout/index.js"
95
- },
96
- "./components/tab-bar": {
97
- "types": "./dist/components/tab-bar/index.d.ts",
98
- "svelte": "./dist/components/tab-bar/index.js"
99
- },
100
- "./constants": {
101
- "types": "./dist/constants/index.d.ts",
102
- "svelte": "./dist/constants/index.js"
103
- },
104
- "./constants/errors": {
105
- "types": "./dist/constants/errors/index.d.ts",
106
- "svelte": "./dist/constants/errors/index.js"
107
- },
108
- "./constants/http": {
109
- "types": "./dist/constants/http/index.d.ts",
110
- "svelte": "./dist/constants/http/index.js"
111
- },
112
- "./constants/mime": {
113
- "types": "./dist/constants/mime/index.d.ts",
114
- "svelte": "./dist/constants/mime/index.js"
115
- },
116
- "./constants/regexp": {
117
- "types": "./dist/constants/regexp/index.d.ts",
118
- "svelte": "./dist/constants/regexp/index.js"
119
- },
120
- "./schemas": {
121
- "types": "./dist/schemas/index.d.ts",
122
- "svelte": "./dist/schemas/index.js"
123
- },
124
- "./server": {
125
- "types": "./dist/server/index.d.ts",
126
- "svelte": "./dist/server/index.js"
127
- },
128
- "./states": {
129
- "types": "./dist/states/index.d.ts",
130
- "svelte": "./dist/states/index.js"
131
- },
132
- "./stores": {
133
- "types": "./dist/stores/index.d.ts",
134
- "svelte": "./dist/stores/index.js"
135
- },
136
- "./util": {
137
- "types": "./dist/util/index.d.ts",
138
- "svelte": "./dist/util/index.js"
139
- },
140
- "./util/array": {
141
- "types": "./dist/util/array/index.d.ts",
142
- "svelte": "./dist/util/array/index.js"
143
- },
144
- "./util/compare": {
145
- "types": "./dist/util/compare/index.d.ts",
146
- "svelte": "./dist/util/compare/index.js"
147
- },
148
- "./util/expect": {
149
- "types": "./dist/util/expect/index.d.ts",
150
- "svelte": "./dist/util/expect/index.js"
151
- },
152
- "./util/function": {
153
- "types": "./dist/util/function/index.d.ts",
154
- "svelte": "./dist/util/function/index.js"
155
- },
156
- "./util/http": {
157
- "types": "./dist/util/http/index.d.ts",
158
- "svelte": "./dist/util/http/index.js"
159
- },
160
- "./util/is": {
161
- "types": "./dist/util/is/index.d.ts",
162
- "svelte": "./dist/util/is/index.js"
163
- },
164
- "./util/iterate": {
165
- "types": "./dist/util/iterate/index.d.ts",
166
- "svelte": "./dist/util/iterate/index.js"
167
- },
168
- "./util/object": {
169
- "types": "./dist/util/object/index.d.ts",
170
- "svelte": "./dist/util/object/index.js"
171
- },
172
- "./util/singleton": {
173
- "types": "./dist/util/singleton/index.d.ts",
174
- "svelte": "./dist/util/singleton/index.js"
175
- },
176
- "./util/string": {
177
- "types": "./dist/util/string/index.d.ts",
178
- "svelte": "./dist/util/string/index.js"
179
- },
180
- "./util/svelte": {
181
- "types": "./dist/util/svelte/index.d.ts",
182
- "svelte": "./dist/util/svelte/index.js"
183
- },
184
- "./util/time": {
185
- "types": "./dist/util/time/index.d.ts",
186
- "svelte": "./dist/util/time/index.js"
187
- },
188
- "./util/svelte/observe": {
189
- "types": "./dist/util/svelte/observe/index.d.ts",
190
- "svelte": "./dist/util/svelte/observe/index.js"
191
- },
192
- "./util/svelte/state-context": {
193
- "types": "./dist/util/svelte/state-context/index.d.ts",
194
- "svelte": "./dist/util/svelte/state-context/index.js"
195
- },
196
- "./valibot": {
197
- "types": "./dist/valibot/index.d.ts",
198
- "svelte": "./dist/valibot/index.js"
199
- }
48
+ "./*": "./dist/*"
200
49
  },
201
50
  "peerDependencies": {
202
51
  "svelte": "^5.0.0"