@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/classes/alias.js +48 -48
  3. package/lib/classes/asset.js +99 -92
  4. package/lib/classes/author.js +20 -20
  5. package/lib/classes/http-incoming.js +52 -52
  6. package/lib/classes/http-outgoing.js +84 -83
  7. package/lib/classes/meta.js +20 -23
  8. package/lib/classes/package.js +73 -70
  9. package/lib/classes/versions.js +62 -60
  10. package/lib/handlers/alias.delete.js +125 -120
  11. package/lib/handlers/alias.get.js +92 -87
  12. package/lib/handlers/alias.post.js +196 -203
  13. package/lib/handlers/alias.put.js +196 -202
  14. package/lib/handlers/auth.post.js +95 -93
  15. package/lib/handlers/map.get.js +110 -111
  16. package/lib/handlers/map.put.js +256 -231
  17. package/lib/handlers/pkg.get.js +120 -122
  18. package/lib/handlers/pkg.log.js +112 -110
  19. package/lib/handlers/pkg.put.js +223 -213
  20. package/lib/handlers/versions.get.js +92 -101
  21. package/lib/main.js +47 -47
  22. package/lib/multipart/form-field.js +20 -23
  23. package/lib/multipart/form-file.js +22 -24
  24. package/lib/multipart/parser.js +231 -217
  25. package/lib/sinks/mem-entry.js +26 -31
  26. package/lib/sinks/test.js +287 -273
  27. package/lib/utils/defaults.js +11 -11
  28. package/lib/utils/globals.js +5 -5
  29. package/lib/utils/healthcheck.js +131 -108
  30. package/lib/utils/path-builders-fs.js +61 -29
  31. package/lib/utils/path-builders-uri.js +26 -18
  32. package/lib/utils/utils.js +76 -79
  33. package/package.json +22 -17
  34. package/types/classes/alias.d.ts +28 -0
  35. package/types/classes/asset.d.ts +48 -0
  36. package/types/classes/author.d.ts +17 -0
  37. package/types/classes/http-incoming.d.ts +37 -0
  38. package/types/classes/http-outgoing.d.ts +20 -0
  39. package/types/classes/meta.d.ts +17 -0
  40. package/types/classes/package.d.ts +40 -0
  41. package/types/classes/versions.d.ts +28 -0
  42. package/types/handlers/alias.delete.d.ts +33 -0
  43. package/types/handlers/alias.get.d.ts +48 -0
  44. package/types/handlers/alias.post.d.ts +83 -0
  45. package/types/handlers/alias.put.d.ts +83 -0
  46. package/types/handlers/auth.post.d.ts +82 -0
  47. package/types/handlers/map.get.d.ts +51 -0
  48. package/types/handlers/map.put.d.ts +78 -0
  49. package/types/handlers/pkg.get.d.ts +51 -0
  50. package/types/handlers/pkg.log.d.ts +51 -0
  51. package/types/handlers/pkg.put.d.ts +107 -0
  52. package/types/handlers/versions.get.d.ts +48 -0
  53. package/types/main.d.ts +44 -0
  54. package/types/multipart/form-field.d.ts +17 -0
  55. package/types/multipart/form-file.d.ts +17 -0
  56. package/types/multipart/parser.d.ts +52 -0
  57. package/types/sinks/mem-entry.d.ts +15 -0
  58. package/types/sinks/test.d.ts +32 -0
  59. package/types/utils/defaults.d.ts +9 -0
  60. package/types/utils/globals.d.ts +8 -0
  61. package/types/utils/healthcheck.d.ts +24 -0
  62. package/types/utils/path-builders-fs.d.ts +41 -0
  63. package/types/utils/path-builders-uri.d.ts +26 -0
  64. package/types/utils/utils.d.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.3.54](https://github.com/eik-lib/core/compare/v1.3.53...v1.3.54) (2024-08-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @eik/common to v4 ([#434](https://github.com/eik-lib/core/issues/434)) ([1e04d60](https://github.com/eik-lib/core/commit/1e04d6033c9eba8b6892b291803daa2066170e90))
7
+
1
8
  ## [1.3.53](https://github.com/eik-lib/core/compare/v1.3.52...v1.3.53) (2024-07-31)
2
9
 
3
10
 
@@ -1,49 +1,49 @@
1
1
  const Alias = class Alias {
2
- constructor({ name = '', type = '', alias = '', org = '' } = {}) {
3
- this._version = '';
4
- this._alias = alias;
5
- this._name = name;
6
- this._type = type;
7
- this._org = org;
8
- }
9
-
10
- set version(value) {
11
- this._version = value;
12
- }
13
-
14
- get version() {
15
- return this._version;
16
- }
17
-
18
- get alias() {
19
- return this._alias;
20
- }
21
-
22
- get name() {
23
- return this._name;
24
- }
25
-
26
- get type() {
27
- return this._type;
28
- }
29
-
30
- get org() {
31
- return this._org;
32
- }
33
-
34
- toJSON() {
35
- return {
36
- version: this.version,
37
- alias: this.alias,
38
- type: this.type,
39
- name: this.name,
40
- org: this.org,
41
- };
42
- }
43
-
44
- get [Symbol.toStringTag]() {
45
- return 'Alias';
46
- }
47
- }
48
-
49
- export default Alias;
2
+ constructor({ name = "", type = "", alias = "", org = "" } = {}) {
3
+ this._version = "";
4
+ this._alias = alias;
5
+ this._name = name;
6
+ this._type = type;
7
+ this._org = org;
8
+ }
9
+
10
+ set version(value) {
11
+ this._version = value;
12
+ }
13
+
14
+ get version() {
15
+ return this._version;
16
+ }
17
+
18
+ get alias() {
19
+ return this._alias;
20
+ }
21
+
22
+ get name() {
23
+ return this._name;
24
+ }
25
+
26
+ get type() {
27
+ return this._type;
28
+ }
29
+
30
+ get org() {
31
+ return this._org;
32
+ }
33
+
34
+ toJSON() {
35
+ return {
36
+ version: this.version,
37
+ alias: this.alias,
38
+ type: this.type,
39
+ name: this.name,
40
+ org: this.org,
41
+ };
42
+ }
43
+
44
+ get [Symbol.toStringTag]() {
45
+ return "Alias";
46
+ }
47
+ };
48
+
49
+ export default Alias;
@@ -1,97 +1,104 @@
1
- import mime from 'mime';
2
- import path from 'node:path';
1
+ import mime from "mime";
2
+ import path from "node:path";
3
+
4
+ /**
5
+ * @typedef {object} AssetOptions
6
+ * @property {string} [pathname]
7
+ * @property {string} [version]
8
+ * @property {string} [name]
9
+ * @property {string} [type]
10
+ * @property {string} [org]
11
+ */
3
12
 
4
13
  /**
5
14
  * Meta information about an Asset.
6
- * @class Asset
7
15
  */
8
16
  const Asset = class Asset {
9
- /**
10
- * Creates an instance of Asset.
11
- * @param {string} [base=''] Base file path. Should contain the extension of the asset.
12
- * @param {string} [dir=''] Directory path to the asset. Will be prefixed to "base".
13
- * @memberof Asset
14
- */
15
- constructor({
16
- pathname = '',
17
- version = '',
18
- name = '',
19
- type = '',
20
- org = '',
21
- } = {}) {
22
- this._mimeType = mime.getType(pathname) || 'application/octet-stream';
23
- this._type = type.toLowerCase();
24
- this._size = -1;
25
-
26
- this._integrity = '';
27
- this._pathname = path.join('/', pathname);;
28
- this._version = version;
29
- this._name = name;
30
- this._org = org;
31
- }
32
-
33
- get integrity() {
34
- return this._integrity;
35
- }
36
-
37
- set integrity(value) {
38
- this._integrity = value;
39
- }
40
-
41
- get pathname() {
42
- return this._pathname;
43
- }
44
-
45
- get mimeType() {
46
- return this._mimeType;
47
- }
48
-
49
- get version() {
50
- return this._version;
51
- }
52
-
53
- // Alias for pathname
54
- get asset() {
55
- return this._pathname;
56
- }
57
-
58
- get name() {
59
- return this._name;
60
- }
61
-
62
- get type() {
63
- return this._type;
64
- }
65
-
66
- set type(value) {
67
- this._type = value.toLowerCase();
68
- }
69
-
70
- get size() {
71
- return this._size;
72
- }
73
-
74
- set size(value) {
75
- this._size = value;
76
- }
77
-
78
- get org() {
79
- return this._org;
80
- }
81
-
82
- toJSON() {
83
- return {
84
- integrity: this.integrity,
85
- pathname: this.pathname,
86
- mimeType: this._mimeType,
87
- type: this.type,
88
- size: this.size,
89
- };
90
- }
91
-
92
- get [Symbol.toStringTag]() {
93
- return 'Asset';
94
- }
95
- }
96
-
97
- export default Asset;
17
+ /**
18
+ * @param {AssetOptions} options
19
+ */
20
+ constructor({
21
+ pathname = "",
22
+ version = "",
23
+ name = "",
24
+ type = "",
25
+ org = "",
26
+ } = {}) {
27
+ this._mimeType =
28
+ /** @type {string} */ (mime.getType(pathname)) ||
29
+ "application/octet-stream";
30
+ this._type = type.toLowerCase();
31
+ this._size = -1;
32
+
33
+ this._integrity = "";
34
+ this._pathname = path.join("/", pathname);
35
+ this._version = version;
36
+ this._name = name;
37
+ this._org = org;
38
+ }
39
+
40
+ get integrity() {
41
+ return this._integrity;
42
+ }
43
+
44
+ set integrity(value) {
45
+ this._integrity = value;
46
+ }
47
+
48
+ get pathname() {
49
+ return this._pathname;
50
+ }
51
+
52
+ get mimeType() {
53
+ return this._mimeType;
54
+ }
55
+
56
+ get version() {
57
+ return this._version;
58
+ }
59
+
60
+ // Alias for pathname
61
+ get asset() {
62
+ return this._pathname;
63
+ }
64
+
65
+ get name() {
66
+ return this._name;
67
+ }
68
+
69
+ get type() {
70
+ return this._type;
71
+ }
72
+
73
+ set type(value) {
74
+ this._type = value.toLowerCase();
75
+ }
76
+
77
+ get size() {
78
+ return this._size;
79
+ }
80
+
81
+ set size(value) {
82
+ this._size = value;
83
+ }
84
+
85
+ get org() {
86
+ return this._org;
87
+ }
88
+
89
+ toJSON() {
90
+ return {
91
+ integrity: this.integrity,
92
+ pathname: this.pathname,
93
+ mimeType: this.mimeType,
94
+ type: this.type,
95
+ size: this.size,
96
+ };
97
+ }
98
+
99
+ get [Symbol.toStringTag]() {
100
+ return "Asset";
101
+ }
102
+ };
103
+
104
+ export default Asset;
@@ -1,27 +1,27 @@
1
1
  const Author = class Author {
2
- constructor({ name = '', user = '' } = {}) {
3
- this._name = name;
4
- this._user = user;
5
- }
2
+ constructor({ name = "", user = "" } = {}) {
3
+ this._name = name;
4
+ this._user = user;
5
+ }
6
6
 
7
- get name() {
8
- return this._name;
9
- }
7
+ get name() {
8
+ return this._name;
9
+ }
10
10
 
11
- get user() {
12
- return this._user;
13
- }
11
+ get user() {
12
+ return this._user;
13
+ }
14
14
 
15
- toJSON() {
16
- return {
17
- name: this.name,
18
- user: this.user,
19
- };
20
- }
15
+ toJSON() {
16
+ return {
17
+ name: this.name,
18
+ user: this.user,
19
+ };
20
+ }
21
21
 
22
- get [Symbol.toStringTag]() {
23
- return 'Author';
24
- }
25
- }
22
+ get [Symbol.toStringTag]() {
23
+ return "Author";
24
+ }
25
+ };
26
26
 
27
27
  export default Author;
@@ -4,69 +4,69 @@
4
4
  * @class HttpIncoming
5
5
  */
6
6
  const HttpIncoming = class HttpIncoming {
7
- constructor(
8
- request,
9
- {
10
- version = '',
11
- extras = '',
12
- author = {},
13
- alias = '',
14
- type = '',
15
- name = '',
16
- org = '',
17
- } = {},
18
- ) {
19
- this._version = version;
20
- this._extras = extras;
21
- this._author = author;
22
- this._alias = alias;
23
- this._type = type;
24
- this._name = name;
25
- this._org = org;
7
+ constructor(
8
+ request,
9
+ {
10
+ version = "",
11
+ extras = "",
12
+ author = {},
13
+ alias = "",
14
+ type = "",
15
+ name = "",
16
+ org = "",
17
+ } = {},
18
+ ) {
19
+ this._version = version;
20
+ this._extras = extras;
21
+ this._author = author;
22
+ this._alias = alias;
23
+ this._type = type;
24
+ this._name = name;
25
+ this._org = org;
26
26
 
27
- this._request = request;
28
- this._headers = request ? request.headers : {};
29
- }
27
+ this._request = request;
28
+ this._headers = request ? request.headers : {};
29
+ }
30
30
 
31
- get version() {
32
- return this._version;
33
- }
31
+ get version() {
32
+ return this._version;
33
+ }
34
34
 
35
- get extras() {
36
- return this._extras;
37
- }
35
+ get extras() {
36
+ return this._extras;
37
+ }
38
38
 
39
- get author() {
40
- return this._author;
41
- }
39
+ get author() {
40
+ return this._author;
41
+ }
42
42
 
43
- get alias() {
44
- return this._alias;
45
- }
43
+ get alias() {
44
+ return this._alias;
45
+ }
46
46
 
47
- get name() {
48
- return this._name;
49
- }
47
+ get name() {
48
+ return this._name;
49
+ }
50
50
 
51
- get type() {
52
- return this._type;
53
- }
51
+ get type() {
52
+ return this._type;
53
+ }
54
54
 
55
- get org() {
56
- return this._org;
57
- }
55
+ get org() {
56
+ return this._org;
57
+ }
58
58
 
59
- get request() {
60
- return this._request;
61
- }
59
+ get request() {
60
+ return this._request;
61
+ }
62
62
 
63
- get headers() {
64
- return this._headers;
65
- }
63
+ get headers() {
64
+ return this._headers;
65
+ }
66
66
 
67
- get [Symbol.toStringTag]() {
68
- return 'HttpIncoming';
69
- }
67
+ get [Symbol.toStringTag]() {
68
+ return "HttpIncoming";
69
+ }
70
70
  };
71
71
 
72
72
  export default HttpIncoming;
@@ -1,89 +1,90 @@
1
- import { stream } from '@eik/common';
1
+ import { stream } from "@eik/common";
2
2
 
3
3
  const STATUS_CODES = [
4
- 100, 101, 102, 103,
5
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
6
- 300, 301, 302, 303, 304, 305, 306, 307, 308,
7
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
8
- 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511,
4
+ 100, 101, 102, 103, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300,
5
+ 301, 302, 303, 304, 305, 306, 307, 308, 400, 401, 402, 403, 404, 405, 406,
6
+ 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423,
7
+ 424, 425, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507,
8
+ 508, 509, 510, 511,
9
9
  ];
10
10
 
11
11
  const HttpOutgoing = class HttpOutgoing {
12
- constructor() {
13
- this._cacheControl = 'no-store';
14
- this._statusCode = 200;
15
- this._mimeType = 'text/plain';
16
- this._location = '';
17
- this._stream = undefined;
18
- this._body = undefined;
19
- this._etag = '';
20
- }
21
-
22
- set cacheControl(value) {
23
- if (value) {
24
- this._cacheControl = value;
25
- }
26
- }
27
-
28
- get cacheControl() {
29
- return this._cacheControl;
30
- }
31
-
32
- set statusCode(value) {
33
- if (Number.isInteger(value) && STATUS_CODES.includes(value)) {
34
- this._statusCode = value;
35
- return;
36
- }
37
- throw new Error('Value is not a legal http status code');
38
- }
39
-
40
- get statusCode() {
41
- return this._statusCode;
42
- }
43
-
44
- set location(value) {
45
- this._location = value;
46
- }
47
-
48
- get location() {
49
- return this._location;
50
- }
51
-
52
- set mimeType(value) {
53
- this._mimeType = value;
54
- }
55
-
56
- get mimeType() {
57
- return this._mimeType;
58
- }
59
-
60
- set stream(value) {
61
- if (!stream.isReadableStream(value)) throw new Error('Value is not a Readable stream');
62
- this._stream = value;
63
- }
64
-
65
- get stream() {
66
- return this._stream;
67
- }
68
-
69
- set body(value) {
70
- this._body = value;
71
- }
72
-
73
- get body() {
74
- return this._body;
75
- }
76
-
77
- set etag(value) {
78
- this._etag = value;
79
- }
80
-
81
- get etag() {
82
- return this._etag;
83
- }
84
-
85
- get [Symbol.toStringTag]() {
86
- return 'HttpOutgoing';
87
- }
88
- }
12
+ constructor() {
13
+ this._cacheControl = "no-store";
14
+ this._statusCode = 200;
15
+ this._mimeType = "text/plain";
16
+ this._location = "";
17
+ this._stream = undefined;
18
+ this._body = undefined;
19
+ this._etag = "";
20
+ }
21
+
22
+ set cacheControl(value) {
23
+ if (value) {
24
+ this._cacheControl = value;
25
+ }
26
+ }
27
+
28
+ get cacheControl() {
29
+ return this._cacheControl;
30
+ }
31
+
32
+ set statusCode(value) {
33
+ if (Number.isInteger(value) && STATUS_CODES.includes(value)) {
34
+ this._statusCode = value;
35
+ return;
36
+ }
37
+ throw new Error("Value is not a legal http status code");
38
+ }
39
+
40
+ get statusCode() {
41
+ return this._statusCode;
42
+ }
43
+
44
+ set location(value) {
45
+ this._location = value;
46
+ }
47
+
48
+ get location() {
49
+ return this._location;
50
+ }
51
+
52
+ set mimeType(value) {
53
+ this._mimeType = value;
54
+ }
55
+
56
+ get mimeType() {
57
+ return this._mimeType;
58
+ }
59
+
60
+ set stream(value) {
61
+ if (!stream.isReadableStream(value))
62
+ throw new Error("Value is not a Readable stream");
63
+ this._stream = value;
64
+ }
65
+
66
+ get stream() {
67
+ return this._stream;
68
+ }
69
+
70
+ set body(value) {
71
+ this._body = value;
72
+ }
73
+
74
+ get body() {
75
+ return this._body;
76
+ }
77
+
78
+ set etag(value) {
79
+ this._etag = value;
80
+ }
81
+
82
+ get etag() {
83
+ return this._etag;
84
+ }
85
+
86
+ get [Symbol.toStringTag]() {
87
+ return "HttpOutgoing";
88
+ }
89
+ };
89
90
  export default HttpOutgoing;