@nxtedition/lib 15.0.58 → 15.1.1
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/package.json +6 -5
- package/serializers.js +8 -0
- package/util/template/javascript.js +44 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"files": [
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"/__tests__"
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
|
+
"@nxtedition/nxt-undici": "^1.4.3",
|
|
75
76
|
"date-fns": "^2.29.3",
|
|
76
77
|
"fast-querystring": "^1.1.1",
|
|
77
78
|
"hasha": "^5.2.2",
|
|
@@ -90,16 +91,16 @@
|
|
|
90
91
|
"smpte-timecode": "^1.3.3",
|
|
91
92
|
"split-string": "^6.0.0",
|
|
92
93
|
"toobusy-js": "^0.5.1",
|
|
93
|
-
"undici": "^5.27.
|
|
94
|
+
"undici": "^5.27.2",
|
|
94
95
|
"url-join": "^4.0.0"
|
|
95
96
|
},
|
|
96
97
|
"devDependencies": {
|
|
97
98
|
"@types/node": "^20.8.10",
|
|
98
|
-
"eslint": "^8.
|
|
99
|
+
"eslint": "^8.53.0",
|
|
99
100
|
"eslint-config-prettier": "^9.0.0",
|
|
100
101
|
"eslint-config-standard": "^17.0.0",
|
|
101
102
|
"eslint-plugin-import": "^2.29.0",
|
|
102
|
-
"eslint-plugin-n": "^16.
|
|
103
|
+
"eslint-plugin-n": "^16.3.0",
|
|
103
104
|
"eslint-plugin-node": "^11.1.0",
|
|
104
105
|
"eslint-plugin-promise": "^6.0.0",
|
|
105
106
|
"husky": "^8.0.3",
|
|
@@ -108,7 +109,7 @@
|
|
|
108
109
|
"prettier": "^3.0.3",
|
|
109
110
|
"rxjs": "^7.5.6",
|
|
110
111
|
"send": "^0.18.0",
|
|
111
|
-
"tap": "^18.5.
|
|
112
|
+
"tap": "^18.5.7"
|
|
112
113
|
},
|
|
113
114
|
"peerDependencies": {
|
|
114
115
|
"@elastic/elasticsearch": "^8.6.0",
|
package/serializers.js
CHANGED
|
@@ -40,8 +40,16 @@ module.exports = {
|
|
|
40
40
|
err = err.length === 1 ? err[0] : new AggregateError(err)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
if (err == null) {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
const ret = serializers.err(err)
|
|
44
48
|
|
|
49
|
+
if (ret == null) {
|
|
50
|
+
return undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
if (ret.data !== null && typeof ret.data === 'object') {
|
|
46
54
|
ret.data = JSON.stringify(ret.data)
|
|
47
55
|
}
|
|
@@ -5,6 +5,7 @@ const vm = require('node:vm')
|
|
|
5
5
|
const objectHash = require('object-hash')
|
|
6
6
|
const datefns = require('date-fns')
|
|
7
7
|
const JSON5 = require('json5')
|
|
8
|
+
const { request } = require('@nxtedition/nxt-undici')
|
|
8
9
|
const undici = require('undici')
|
|
9
10
|
|
|
10
11
|
const kSuspend = Symbol('kSuspend')
|
|
@@ -14,7 +15,7 @@ const maxInt = 2147483647
|
|
|
14
15
|
class TimerEntry {
|
|
15
16
|
constructor(key, refresh, delay) {
|
|
16
17
|
this.key = key
|
|
17
|
-
this.counter =
|
|
18
|
+
this.counter = -1
|
|
18
19
|
|
|
19
20
|
this.timer = setTimeout(refresh, delay)
|
|
20
21
|
}
|
|
@@ -26,39 +27,53 @@ class TimerEntry {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
const fetchClient = new undici.Agent({
|
|
31
|
+
connections: 128,
|
|
32
|
+
pipelining: 8,
|
|
33
|
+
})
|
|
34
|
+
|
|
29
35
|
class FetchEntry {
|
|
30
36
|
constructor(key, refresh, { resource, options }) {
|
|
31
37
|
this.key = key
|
|
32
|
-
this.counter =
|
|
38
|
+
this.counter = -1
|
|
39
|
+
this.ac = new AbortController()
|
|
33
40
|
|
|
34
41
|
this.refresh = refresh
|
|
35
|
-
this.ac = new AbortController()
|
|
36
|
-
this.signal = this.ac.signal
|
|
37
42
|
this.body = null
|
|
38
43
|
this.status = null
|
|
39
44
|
this.error = null
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.fetch(resource, { ...options, signal: this.signal })
|
|
47
|
-
.then(async (res) => {
|
|
48
|
-
if (this.refresh) {
|
|
49
|
-
// TODO (fix): max size...
|
|
50
|
-
this.body = Buffer.from(await res.arrayBuffer())
|
|
51
|
-
this.status = res.status
|
|
52
|
-
this.headers = res.headers
|
|
53
|
-
this.refresh()
|
|
54
|
-
}
|
|
46
|
+
try {
|
|
47
|
+
request(resource, {
|
|
48
|
+
...options,
|
|
49
|
+
signal: this.ac.signal,
|
|
50
|
+
dispatcher: fetchClient,
|
|
55
51
|
})
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
.then(async (res) => {
|
|
53
|
+
try {
|
|
54
|
+
// TODO (fix): max size...
|
|
55
|
+
this.status = res.statusCode
|
|
56
|
+
this.headers = res.headers
|
|
57
|
+
this.body = await res.text()
|
|
58
|
+
} catch (err) {
|
|
59
|
+
this.error = err
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (this.refresh) {
|
|
63
|
+
this.refresh()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
58
67
|
this.error = err
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
|
|
69
|
+
if (this.refresh) {
|
|
70
|
+
this.refresh()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
} catch (err) {
|
|
74
|
+
this.error = err
|
|
75
|
+
this.refresh()
|
|
76
|
+
}
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
dispose() {
|
|
@@ -72,7 +87,7 @@ class FetchEntry {
|
|
|
72
87
|
class RecordEntry {
|
|
73
88
|
constructor(key, refresh, ds) {
|
|
74
89
|
this.key = key
|
|
75
|
-
this.counter =
|
|
90
|
+
this.counter = -1
|
|
76
91
|
|
|
77
92
|
this.refresh = refresh
|
|
78
93
|
this.record = ds.record.getRecord(key)
|
|
@@ -100,7 +115,7 @@ class RecordEntry {
|
|
|
100
115
|
class ObservableEntry {
|
|
101
116
|
constructor(key, refresh, observable) {
|
|
102
117
|
this.key = key
|
|
103
|
-
this.counter =
|
|
118
|
+
this.counter = -1
|
|
104
119
|
this.value = kEmpty
|
|
105
120
|
this.error = null
|
|
106
121
|
this.refresh = refresh
|
|
@@ -126,7 +141,7 @@ class ObservableEntry {
|
|
|
126
141
|
class PromiseEntry {
|
|
127
142
|
constructor(key, refresh, promise) {
|
|
128
143
|
this.key = key
|
|
129
|
-
this.counter =
|
|
144
|
+
this.counter = -1
|
|
130
145
|
this.value = kEmpty
|
|
131
146
|
this.error = null
|
|
132
147
|
this.refresh = refresh
|
|
@@ -143,7 +158,7 @@ class PromiseEntry {
|
|
|
143
158
|
this.error = err
|
|
144
159
|
this.refresh()
|
|
145
160
|
}
|
|
146
|
-
}
|
|
161
|
+
},
|
|
147
162
|
)
|
|
148
163
|
}
|
|
149
164
|
|
|
@@ -342,7 +357,7 @@ module.exports = ({ ds, proxify, compiler }) => {
|
|
|
342
357
|
Object.assign(new Error('expression failed'), {
|
|
343
358
|
cause: err,
|
|
344
359
|
data: self._expression,
|
|
345
|
-
})
|
|
360
|
+
}),
|
|
346
361
|
)
|
|
347
362
|
} finally {
|
|
348
363
|
compiler.current = previous
|
|
@@ -518,7 +533,7 @@ module.exports = ({ ds, proxify, compiler }) => {
|
|
|
518
533
|
const data = this._getRecord(
|
|
519
534
|
id + ':asset.rawTypes?',
|
|
520
535
|
state ?? ds.record.PROVIDER,
|
|
521
|
-
suspend ?? true
|
|
536
|
+
suspend ?? true,
|
|
522
537
|
)
|
|
523
538
|
return data && Array.isArray(data.value) && data.value.includes(type) ? id : null
|
|
524
539
|
}
|