@standardserver/core 0.0.6 → 0.0.8
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/event-stream/index.d.mts +1 -1
- package/dist/event-stream/index.d.ts +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +35 -2
- package/package.json +2 -2
|
@@ -14,7 +14,7 @@ interface EventStreamMessageMeta {
|
|
|
14
14
|
*
|
|
15
15
|
* @warning Comments must not contain newline characters (`\n`).
|
|
16
16
|
*/
|
|
17
|
-
comments?:
|
|
17
|
+
comments?: string[] | undefined;
|
|
18
18
|
}
|
|
19
19
|
interface EventStreamMessage extends EventStreamMessageMeta {
|
|
20
20
|
/**
|
|
@@ -14,7 +14,7 @@ interface EventStreamMessageMeta {
|
|
|
14
14
|
*
|
|
15
15
|
* @warning Comments must not contain newline characters (`\n`).
|
|
16
16
|
*/
|
|
17
|
-
comments?:
|
|
17
|
+
comments?: string[] | undefined;
|
|
18
18
|
}
|
|
19
19
|
interface EventStreamMessage extends EventStreamMessageMeta {
|
|
20
20
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -74,5 +74,11 @@ declare function parseStandardUrl(url: StandardUrl): [
|
|
|
74
74
|
hash: `#${string}` | undefined
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
declare function isStandardMethod(maybe: unknown): maybe is StandardMethod;
|
|
78
|
+
declare function isStandardUrl(maybe: unknown): maybe is StandardUrl;
|
|
79
|
+
declare function isStandardHeaders(maybe: unknown): maybe is StandardHeaders;
|
|
80
|
+
declare function isStandardRequest(maybe: unknown): maybe is StandardRequest;
|
|
81
|
+
declare function isStandardResponse(maybe: unknown): maybe is StandardResponse;
|
|
82
|
+
|
|
83
|
+
export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl };
|
|
78
84
|
export type { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -74,5 +74,11 @@ declare function parseStandardUrl(url: StandardUrl): [
|
|
|
74
74
|
hash: `#${string}` | undefined
|
|
75
75
|
];
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
declare function isStandardMethod(maybe: unknown): maybe is StandardMethod;
|
|
78
|
+
declare function isStandardUrl(maybe: unknown): maybe is StandardUrl;
|
|
79
|
+
declare function isStandardHeaders(maybe: unknown): maybe is StandardHeaders;
|
|
80
|
+
declare function isStandardRequest(maybe: unknown): maybe is StandardRequest;
|
|
81
|
+
declare function isStandardResponse(maybe: unknown): maybe is StandardResponse;
|
|
82
|
+
|
|
83
|
+
export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl };
|
|
78
84
|
export type { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tryDecodeURIComponent, toArray } from '@standardserver/shared';
|
|
1
|
+
import { tryDecodeURIComponent, toArray, isTypescriptObject } from '@standardserver/shared';
|
|
2
2
|
|
|
3
3
|
function generateContentDisposition(filename) {
|
|
4
4
|
const escapedFileName = filename.replace(/"/g, '\\"');
|
|
@@ -53,4 +53,37 @@ function parseStandardUrl(url) {
|
|
|
53
53
|
return [pathname, search, hash];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
function isStandardMethod(maybe) {
|
|
57
|
+
return typeof maybe === "string";
|
|
58
|
+
}
|
|
59
|
+
function isStandardUrl(maybe) {
|
|
60
|
+
return typeof maybe === "string" && maybe.startsWith("/");
|
|
61
|
+
}
|
|
62
|
+
function isStandardHeaders(maybe) {
|
|
63
|
+
if (!isTypescriptObject(maybe)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return Object.values(maybe).every(
|
|
67
|
+
(value) => value === void 0 || typeof value === "string" || Array.isArray(value) && value.every((v) => typeof v === "string")
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function isStandardRequest(maybe) {
|
|
71
|
+
if (!isTypescriptObject(maybe)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (maybe.signal !== void 0 && !(maybe.signal instanceof AbortSignal)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return isStandardMethod(maybe.method) && isStandardUrl(maybe.url) && isStandardHeaders(maybe.headers);
|
|
78
|
+
}
|
|
79
|
+
function isStandardResponse(maybe) {
|
|
80
|
+
if (!isTypescriptObject(maybe)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!Number.isInteger(maybe.status)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return isStandardHeaders(maybe.headers);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, isStandardHeaders, isStandardMethod, isStandardRequest, isStandardResponse, isStandardUrl, mergeStandardHeaders, parseStandardUrl };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardserver/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://standardserver.dev",
|
|
7
7
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@standardserver/shared": "0.0.
|
|
28
|
+
"@standardserver/shared": "0.0.8"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "unbuild",
|