@eik/core 1.3.53 → 1.3.55
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/CHANGELOG.md +7 -0
- package/lib/classes/alias.js +48 -48
- package/lib/classes/asset.js +99 -92
- package/lib/classes/author.js +20 -20
- package/lib/classes/http-incoming.js +52 -52
- package/lib/classes/http-outgoing.js +84 -83
- package/lib/classes/meta.js +20 -23
- package/lib/classes/package.js +73 -70
- package/lib/classes/versions.js +62 -60
- package/lib/handlers/alias.delete.js +125 -120
- package/lib/handlers/alias.get.js +92 -87
- package/lib/handlers/alias.post.js +196 -203
- package/lib/handlers/alias.put.js +196 -202
- package/lib/handlers/auth.post.js +95 -93
- package/lib/handlers/map.get.js +110 -111
- package/lib/handlers/map.put.js +256 -231
- package/lib/handlers/pkg.get.js +120 -122
- package/lib/handlers/pkg.log.js +112 -110
- package/lib/handlers/pkg.put.js +223 -213
- package/lib/handlers/versions.get.js +92 -101
- package/lib/main.js +47 -47
- package/lib/multipart/form-field.js +20 -23
- package/lib/multipart/form-file.js +22 -24
- package/lib/multipart/parser.js +231 -217
- package/lib/sinks/mem-entry.js +26 -31
- package/lib/sinks/test.js +287 -273
- package/lib/utils/defaults.js +11 -11
- package/lib/utils/globals.js +5 -5
- package/lib/utils/healthcheck.js +131 -108
- package/lib/utils/path-builders-fs.js +61 -29
- package/lib/utils/path-builders-uri.js +26 -18
- package/lib/utils/utils.js +76 -79
- package/package.json +22 -17
- package/types/classes/alias.d.ts +28 -0
- package/types/classes/asset.d.ts +48 -0
- package/types/classes/author.d.ts +17 -0
- package/types/classes/http-incoming.d.ts +37 -0
- package/types/classes/http-outgoing.d.ts +20 -0
- package/types/classes/meta.d.ts +17 -0
- package/types/classes/package.d.ts +40 -0
- package/types/classes/versions.d.ts +28 -0
- package/types/handlers/alias.delete.d.ts +33 -0
- package/types/handlers/alias.get.d.ts +48 -0
- package/types/handlers/alias.post.d.ts +83 -0
- package/types/handlers/alias.put.d.ts +83 -0
- package/types/handlers/auth.post.d.ts +82 -0
- package/types/handlers/map.get.d.ts +51 -0
- package/types/handlers/map.put.d.ts +78 -0
- package/types/handlers/pkg.get.d.ts +51 -0
- package/types/handlers/pkg.log.d.ts +51 -0
- package/types/handlers/pkg.put.d.ts +107 -0
- package/types/handlers/versions.get.d.ts +48 -0
- package/types/main.d.ts +44 -0
- package/types/multipart/form-field.d.ts +17 -0
- package/types/multipart/form-file.d.ts +17 -0
- package/types/multipart/parser.d.ts +52 -0
- package/types/sinks/mem-entry.d.ts +15 -0
- package/types/sinks/test.d.ts +32 -0
- package/types/utils/defaults.d.ts +9 -0
- package/types/utils/globals.d.ts +8 -0
- package/types/utils/healthcheck.d.ts +24 -0
- package/types/utils/path-builders-fs.d.ts +41 -0
- package/types/utils/path-builders-uri.d.ts +26 -0
- package/types/utils/utils.d.ts +6 -0
package/lib/utils/healthcheck.js
CHANGED
|
@@ -1,111 +1,134 @@
|
|
|
1
|
-
import { Writable, pipeline } from
|
|
2
|
-
import { URL } from
|
|
3
|
-
import abslog from
|
|
4
|
-
import slug from
|
|
5
|
-
import fs from
|
|
1
|
+
import { Writable, pipeline } from "node:stream";
|
|
2
|
+
import { URL } from "node:url";
|
|
3
|
+
import abslog from "abslog";
|
|
4
|
+
import slug from "unique-slug";
|
|
5
|
+
import fs from "node:fs";
|
|
6
6
|
|
|
7
|
-
const fileReader = (file =
|
|
7
|
+
const fileReader = (file = "../../README.md") =>
|
|
8
|
+
fs.createReadStream(new URL(file, import.meta.url));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} HealthCheckOptions
|
|
12
|
+
* @property {import("@eik/sink").default} [sink]
|
|
13
|
+
* @property {import("abslog").AbstractLoggerOptions} [logger]
|
|
14
|
+
*/
|
|
8
15
|
|
|
9
16
|
const HealthCheck = class HealthCheck {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @param {HealthCheckOptions} options
|
|
19
|
+
*/
|
|
20
|
+
constructor({ sink, logger } = {}) {
|
|
21
|
+
this._sink = sink;
|
|
22
|
+
this._name = `./system/tmp/health_${slug()}.txt`;
|
|
23
|
+
this._log = abslog(logger);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_write() {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
this._sink
|
|
29
|
+
.write(this._name, "text/plain")
|
|
30
|
+
.then((destination) => {
|
|
31
|
+
const source = fileReader();
|
|
32
|
+
pipeline(source, destination, (error) => {
|
|
33
|
+
if (error) return reject(error);
|
|
34
|
+
return resolve();
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
.catch((error) => {
|
|
38
|
+
reject(error);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_read() {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
this._sink
|
|
46
|
+
.read(this._name)
|
|
47
|
+
.then((source) => {
|
|
48
|
+
const buffer = [];
|
|
49
|
+
const destination = new Writable({
|
|
50
|
+
objectMode: false,
|
|
51
|
+
write(chunk, encoding, callback) {
|
|
52
|
+
buffer.push(chunk);
|
|
53
|
+
callback();
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
pipeline(source.stream, destination, (error) => {
|
|
58
|
+
if (error) return reject(error);
|
|
59
|
+
return resolve();
|
|
60
|
+
});
|
|
61
|
+
})
|
|
62
|
+
.catch((error) => {
|
|
63
|
+
reject(error);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_delete() {
|
|
69
|
+
return this._sink.delete(this._name);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_exist() {
|
|
73
|
+
return this._sink.exist(this._name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async check() {
|
|
77
|
+
this._log.info(
|
|
78
|
+
`Sink health check started - testing with file ${this._name}`,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await this._write();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
this._log.warn("Sink health check errored during write");
|
|
85
|
+
this._log.error(error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await this._exist();
|
|
91
|
+
} catch (error) {
|
|
92
|
+
this._log.warn(
|
|
93
|
+
"Sink health check errored when checking content written by sink.write(). Content was probably not written to sink.",
|
|
94
|
+
);
|
|
95
|
+
this._log.error(error);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
await this._read();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
this._log.warn("Sink health check errored during read");
|
|
103
|
+
this._log.error(error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
await this._delete();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
this._log.warn("Sink health check errored during deletion");
|
|
111
|
+
this._log.error(error);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
await this._exist();
|
|
117
|
+
this._log.warn(
|
|
118
|
+
"Sink health check successfully read file after deletion. It should not. Content was probably not deleted by sink.delete().",
|
|
119
|
+
);
|
|
120
|
+
throw new Error("File exist in sink");
|
|
121
|
+
// eslint-disable-next-line no-unused-vars
|
|
122
|
+
} catch (error) {
|
|
123
|
+
this._log.info("Sink health check ended successfully. Sink is healthy");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get [Symbol.toStringTag]() {
|
|
130
|
+
return "HealthCheck";
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default HealthCheck;
|
|
@@ -1,47 +1,79 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import globals from
|
|
3
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import globals from "./globals.js";
|
|
4
3
|
|
|
5
4
|
// Build file system path to a package file
|
|
6
5
|
|
|
7
|
-
const createFilePathToPackage = ({
|
|
8
|
-
|
|
6
|
+
const createFilePathToPackage = ({
|
|
7
|
+
org = "",
|
|
8
|
+
type = "",
|
|
9
|
+
name = "",
|
|
10
|
+
version = "",
|
|
11
|
+
} = {}) => path.join(globals.ROOT, org, type, name, `${version}.package.json`);
|
|
9
12
|
|
|
10
13
|
// Build file system path to an asset in a package
|
|
11
14
|
// pkgAsset
|
|
12
|
-
const createFilePathToAsset = ({
|
|
13
|
-
|
|
15
|
+
const createFilePathToAsset = ({
|
|
16
|
+
org = "",
|
|
17
|
+
type = "",
|
|
18
|
+
name = "",
|
|
19
|
+
version = "",
|
|
20
|
+
asset = "",
|
|
21
|
+
} = {}) => path.join(globals.ROOT, org, type, name, version, asset);
|
|
14
22
|
|
|
15
23
|
// Build file system path to an import map
|
|
16
24
|
|
|
17
|
-
const createFilePathToImportMap = ({
|
|
18
|
-
|
|
25
|
+
const createFilePathToImportMap = ({
|
|
26
|
+
org = "",
|
|
27
|
+
name = "",
|
|
28
|
+
version = "",
|
|
29
|
+
} = {}) =>
|
|
30
|
+
path.join(
|
|
31
|
+
globals.ROOT,
|
|
32
|
+
org,
|
|
33
|
+
globals.BASE_IMPORT_MAPS,
|
|
34
|
+
name,
|
|
35
|
+
`${version}.import-map.json`,
|
|
36
|
+
);
|
|
19
37
|
|
|
20
38
|
// Build file system path to an alias file
|
|
21
39
|
|
|
22
|
-
const createFilePathToAlias = ({
|
|
23
|
-
|
|
40
|
+
const createFilePathToAlias = ({
|
|
41
|
+
org = "",
|
|
42
|
+
type = "",
|
|
43
|
+
name = "",
|
|
44
|
+
alias = "",
|
|
45
|
+
} = {}) => path.join(globals.ROOT, org, type, name, `${alias}.alias.json`);
|
|
24
46
|
|
|
25
47
|
// Build file system path to an version file
|
|
26
48
|
|
|
27
|
-
const createFilePathToVersion = ({ org =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
const createFilePathToVersion = ({ org = "", type = "", name = "" } = {}) =>
|
|
50
|
+
path.join(globals.ROOT, org, type, name, "versions.json");
|
|
51
|
+
|
|
52
|
+
const createFilePathToEikJson = ({
|
|
53
|
+
org = "",
|
|
54
|
+
type = "",
|
|
55
|
+
name = "",
|
|
56
|
+
version = "",
|
|
57
|
+
} = {}) => path.join(globals.ROOT, org, type, name, version, "eik.json");
|
|
58
|
+
|
|
59
|
+
const createFilePathToAliasOrigin = ({
|
|
60
|
+
org = "",
|
|
61
|
+
type = "",
|
|
62
|
+
name = "",
|
|
63
|
+
version = "",
|
|
64
|
+
} = {}) => {
|
|
65
|
+
if (type === "map") {
|
|
66
|
+
return createFilePathToImportMap({ org, name, version });
|
|
67
|
+
}
|
|
68
|
+
return createFilePathToPackage({ org, type, name, version });
|
|
36
69
|
};
|
|
37
70
|
|
|
38
|
-
|
|
39
71
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
72
|
+
createFilePathToPackage,
|
|
73
|
+
createFilePathToAsset,
|
|
74
|
+
createFilePathToImportMap,
|
|
75
|
+
createFilePathToAlias,
|
|
76
|
+
createFilePathToVersion,
|
|
77
|
+
createFilePathToAliasOrigin,
|
|
78
|
+
createFilePathToEikJson,
|
|
79
|
+
};
|
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import globals from
|
|
3
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import globals from "./globals.js";
|
|
4
3
|
|
|
5
4
|
// Build URL pathname to a package log file
|
|
6
5
|
|
|
7
|
-
const createURIPathToPkgLog = ({ type =
|
|
8
|
-
|
|
6
|
+
const createURIPathToPkgLog = ({ type = "", name = "", version = "" } = {}) =>
|
|
7
|
+
path.join(globals.ROOT, type, name, version);
|
|
9
8
|
|
|
10
9
|
// Build URL pathname to an asset in a package
|
|
11
10
|
|
|
12
|
-
const createURIPathToAsset = ({
|
|
13
|
-
|
|
11
|
+
const createURIPathToAsset = ({
|
|
12
|
+
type = "",
|
|
13
|
+
name = "",
|
|
14
|
+
version = "",
|
|
15
|
+
asset = "",
|
|
16
|
+
} = {}) => path.join(globals.ROOT, type, name, version, asset);
|
|
14
17
|
|
|
15
18
|
// Build URL pathname to an import map
|
|
16
19
|
|
|
17
|
-
const createURIPathToImportMap = ({ name =
|
|
18
|
-
|
|
20
|
+
const createURIPathToImportMap = ({ name = "", version = "" } = {}) =>
|
|
21
|
+
path.join(globals.ROOT, globals.BASE_IMPORT_MAPS, name, version);
|
|
19
22
|
|
|
20
23
|
// Build URL pathname to an alias source
|
|
21
24
|
|
|
22
|
-
const createURIToAlias = ({ type =
|
|
23
|
-
|
|
25
|
+
const createURIToAlias = ({ type = "", name = "", alias = "" } = {}) =>
|
|
26
|
+
path.join(globals.ROOT, type, name, `v${alias}`);
|
|
24
27
|
|
|
25
28
|
// Build URL pathname to an alias target destination
|
|
26
29
|
|
|
27
|
-
const createURIToTargetOfAlias = ({
|
|
30
|
+
const createURIToTargetOfAlias = ({
|
|
31
|
+
type = "",
|
|
32
|
+
name = "",
|
|
33
|
+
version = "",
|
|
34
|
+
extra = "",
|
|
35
|
+
} = {}) => path.join(globals.ROOT, type, name, version, extra);
|
|
28
36
|
|
|
29
37
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
38
|
+
createURIPathToPkgLog,
|
|
39
|
+
createURIPathToAsset,
|
|
40
|
+
createURIPathToImportMap,
|
|
41
|
+
createURIToAlias,
|
|
42
|
+
createURIToTargetOfAlias,
|
|
43
|
+
};
|
package/lib/utils/utils.js
CHANGED
|
@@ -1,95 +1,92 @@
|
|
|
1
|
-
import { Writable, Readable, pipeline } from
|
|
1
|
+
import { Writable, Readable, pipeline } from "node:stream";
|
|
2
2
|
|
|
3
|
-
const readJSON = (sink, path) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const readJSON = (sink, path) =>
|
|
4
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
5
|
+
new Promise(async (resolve, reject) => {
|
|
6
|
+
try {
|
|
7
|
+
const buffer = [];
|
|
8
|
+
const from = await sink.read(path);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
pipeline(from.stream, to, error => {
|
|
19
|
-
if (error) return reject(error);
|
|
20
|
-
const str = buffer.join('').toString();
|
|
21
|
-
try {
|
|
22
|
-
const obj = JSON.parse(str);
|
|
23
|
-
return resolve(obj);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
return reject(err);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
} catch (error) {
|
|
29
|
-
reject(error);
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
;
|
|
10
|
+
const to = new Writable({
|
|
11
|
+
objectMode: false,
|
|
12
|
+
write(chunk, encoding, callback) {
|
|
13
|
+
buffer.push(chunk);
|
|
14
|
+
callback();
|
|
15
|
+
},
|
|
16
|
+
});
|
|
33
17
|
|
|
18
|
+
pipeline(from.stream, to, (error) => {
|
|
19
|
+
if (error) return reject(error);
|
|
20
|
+
const str = buffer.join("").toString();
|
|
21
|
+
try {
|
|
22
|
+
const obj = JSON.parse(str);
|
|
23
|
+
return resolve(obj);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
return reject(err);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
reject(error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
34
32
|
const readEikJson = (sink, path) => sink.exist(path);
|
|
35
33
|
|
|
36
|
-
const writeJSON = (sink, path, obj, contentType) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const from = new Readable({
|
|
43
|
-
objectMode: false,
|
|
44
|
-
read() {
|
|
45
|
-
this.push(buffer);
|
|
46
|
-
this.push(null);
|
|
47
|
-
},
|
|
48
|
-
});
|
|
34
|
+
const writeJSON = (sink, path, obj, contentType) =>
|
|
35
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
36
|
+
new Promise(async (resolve, reject) => {
|
|
37
|
+
try {
|
|
38
|
+
const buffer = Buffer.from(JSON.stringify(obj));
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
const from = new Readable({
|
|
41
|
+
objectMode: false,
|
|
42
|
+
read() {
|
|
43
|
+
this.push(buffer);
|
|
44
|
+
this.push(null);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
if (error) return reject(error);
|
|
54
|
-
return resolve(buffer);
|
|
55
|
-
});
|
|
56
|
-
} catch (error) {
|
|
57
|
-
reject(error);
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
;
|
|
48
|
+
const to = await sink.write(path, contentType);
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
pipeline(from, to, (error) => {
|
|
51
|
+
if (error) return reject(error);
|
|
52
|
+
return resolve(buffer);
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
reject(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const streamCollector = (from) =>
|
|
59
|
+
new Promise((resolve, reject) => {
|
|
60
|
+
const buffer = [];
|
|
61
|
+
const to = new Writable({
|
|
62
|
+
write(chunk, encoding, cb) {
|
|
63
|
+
buffer.push(chunk);
|
|
64
|
+
cb();
|
|
65
|
+
},
|
|
66
|
+
});
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
pipeline(from, to, (error) => {
|
|
69
|
+
if (error) return reject(error);
|
|
70
|
+
return resolve(buffer.join("").toString());
|
|
71
|
+
});
|
|
72
|
+
});
|
|
76
73
|
|
|
77
74
|
const etagFromFsStat = (stat) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const mtime = stat.mtime.getTime().toString(16);
|
|
76
|
+
const size = stat.size.toString(16);
|
|
77
|
+
return `W/"${size}-${mtime}"`;
|
|
81
78
|
};
|
|
82
79
|
|
|
83
80
|
const decodeUriComponent = (value) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
81
|
+
if (value === null || value === undefined) return value;
|
|
82
|
+
return decodeURIComponent(value);
|
|
83
|
+
};
|
|
87
84
|
|
|
88
85
|
export {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
86
|
+
readJSON,
|
|
87
|
+
writeJSON,
|
|
88
|
+
streamCollector,
|
|
89
|
+
etagFromFsStat,
|
|
90
|
+
decodeUriComponent,
|
|
91
|
+
readEikJson,
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.55",
|
|
4
4
|
"description": "Core server package",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
|
+
"types": "./types/main.d.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"files": [
|
|
8
9
|
"CHANGELOG.md",
|
|
9
10
|
"package.json",
|
|
10
|
-
"lib"
|
|
11
|
+
"lib",
|
|
12
|
+
"types"
|
|
11
13
|
],
|
|
12
14
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
+
"clean": "rimraf node_modules .tap types",
|
|
16
|
+
"lint": "eslint .",
|
|
15
17
|
"lint:fix": "eslint --fix .",
|
|
16
|
-
"
|
|
18
|
+
"test": "tap --disable-coverage --allow-empty-coverage",
|
|
19
|
+
"test:snapshots": "tap --snapshot",
|
|
20
|
+
"types": "run-s types:module types:test",
|
|
21
|
+
"types:module": "tsc",
|
|
22
|
+
"types:test": "tsc --project tsconfig.test.json"
|
|
17
23
|
},
|
|
18
24
|
"keywords": [],
|
|
19
25
|
"author": "",
|
|
20
26
|
"license": "MIT",
|
|
21
27
|
"dependencies": {
|
|
22
|
-
"@eik/common": "
|
|
28
|
+
"@eik/common": "4.0.6",
|
|
23
29
|
"@eik/sink": "1.2.5",
|
|
24
30
|
"@eik/sink-file-system": "1.0.1",
|
|
25
31
|
"@eik/sink-memory": "1.1.1",
|
|
@@ -36,20 +42,19 @@
|
|
|
36
42
|
"unique-slug": "4.0.0"
|
|
37
43
|
},
|
|
38
44
|
"devDependencies": {
|
|
39
|
-
"@
|
|
45
|
+
"@eik/eslint-config": "1.0.2",
|
|
46
|
+
"@eik/prettier-config": "1.0.1",
|
|
40
47
|
"@eik/semantic-release-config": "1.0.0",
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"eslint": "8.
|
|
44
|
-
"eslint-config-airbnb-base": "15.0.0",
|
|
45
|
-
"eslint-config-prettier": "9.1.0",
|
|
46
|
-
"eslint-plugin-import": "2.29.1",
|
|
47
|
-
"eslint-plugin-prettier": "5.1.3",
|
|
48
|
+
"@eik/typescript-config": "1.0.0",
|
|
49
|
+
"@types/readable-stream": "4.0.15",
|
|
50
|
+
"eslint": "9.8.0",
|
|
48
51
|
"form-data": "4.0.0",
|
|
49
52
|
"mkdirp": "3.0.1",
|
|
50
53
|
"node-fetch": "3.3.2",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
+
"npm-run-all": "4.1.5",
|
|
55
|
+
"prettier": "3.3.3",
|
|
56
|
+
"semantic-release": "24.0.0",
|
|
57
|
+
"tap": "18.8.0",
|
|
58
|
+
"typescript": "5.5.4"
|
|
54
59
|
}
|
|
55
60
|
}
|