@nxtedition/lib 19.0.10 → 19.0.12
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/app.js +1 -1
- package/couch.js +2 -0
- package/package.json +3 -2
- package/platform.js +37 -35
- package/rxjs/auditMap.js +4 -4
- package/rxjs/combineMap.js +5 -5
- package/rxjs/firstValueFrom.js +3 -3
- package/rxjs/lastValueFrom.js +4 -5
- package/rxjs/withAbortSignal.js +3 -3
- package/util/template/index.js +9 -6
- package/util/template/javascript.js +1 -1
- package/util/template/nextpressions.js +27 -28
package/app.js
CHANGED
|
@@ -13,7 +13,7 @@ import { makeCouch } from './couch.js'
|
|
|
13
13
|
import { makeTemplateCompiler } from './util/template/index.js'
|
|
14
14
|
import { makeDeepstream } from './deepstream.js'
|
|
15
15
|
import v8 from 'v8'
|
|
16
|
-
import rxjs from 'rxjs'
|
|
16
|
+
import * as rxjs from 'rxjs'
|
|
17
17
|
import rx from 'rxjs/operators'
|
|
18
18
|
import { performance } from 'perf_hooks'
|
|
19
19
|
import hashString from './hash.js'
|
package/couch.js
CHANGED
|
@@ -258,11 +258,13 @@ export function makeCouch(opts) {
|
|
|
258
258
|
})
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
// TODO (perf): Avoid stream pipeline
|
|
261
262
|
return stream.pipeline(
|
|
262
263
|
res.body,
|
|
263
264
|
split2(),
|
|
264
265
|
new stream.Transform({
|
|
265
266
|
objectMode: true,
|
|
267
|
+
readableHighWaterMark: 256, // TODO (fix): We would like to limit this to bytes and not elements...
|
|
266
268
|
construct(callback) {
|
|
267
269
|
this.state = 0
|
|
268
270
|
callback(null)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -116,7 +116,8 @@
|
|
|
116
116
|
"pinst": "^3.0.0",
|
|
117
117
|
"prettier": "^3.2.5",
|
|
118
118
|
"rxjs": "^7.5.6",
|
|
119
|
-
"send": "^0.18.0"
|
|
119
|
+
"send": "^0.18.0",
|
|
120
|
+
"tap": "^18.7.1"
|
|
120
121
|
},
|
|
121
122
|
"peerDependencies": {
|
|
122
123
|
"@elastic/elasticsearch": "^8.6.0",
|
package/platform.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
export const SIGNALS =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
+
typeof process === 'object'
|
|
3
|
+
? {
|
|
4
|
+
linux: {
|
|
5
|
+
129: 'SIGHUP', // 1
|
|
6
|
+
130: 'SIGINT', // 2
|
|
7
|
+
131: 'SIGQUIT', // 3
|
|
8
|
+
132: 'SIGILL', // 4
|
|
9
|
+
133: 'SIGTRAP', // 5
|
|
10
|
+
134: 'SIGABRT', // 6
|
|
11
|
+
135: 'SIGBUS', // 7
|
|
12
|
+
136: 'SIGFPE', // 8
|
|
13
|
+
137: 'SIGKILL', // 9
|
|
14
|
+
138: 'SIGUSR1', // 10
|
|
15
|
+
139: 'SIGSEGV', // 11
|
|
16
|
+
140: 'SIGUSR2', // 12
|
|
17
|
+
141: 'SIGPIPE', // 13
|
|
18
|
+
142: 'SIGALRM', // 14
|
|
19
|
+
143: 'SIGTERM', // 15
|
|
20
|
+
144: 'SIGSTKFLT', // 16
|
|
21
|
+
145: 'SIGCHLD', // 17
|
|
22
|
+
146: 'SIGCONT', // 18
|
|
23
|
+
147: 'SIGSTOP', // 19
|
|
24
|
+
148: 'SIGTSTP', // 20
|
|
25
|
+
149: 'SIGTTIN', // 21
|
|
26
|
+
150: 'SIGTTOU', // 22
|
|
27
|
+
151: 'SIGURG', // 23
|
|
28
|
+
152: 'SIGXCPU', // 24
|
|
29
|
+
153: 'SIGXFSZ', // 25
|
|
30
|
+
154: 'SIGVTALRM', // 26
|
|
31
|
+
155: 'SIGPROF', // 27
|
|
32
|
+
156: 'SIGWINCH', // 28
|
|
33
|
+
157: 'SIGIO', // 29
|
|
34
|
+
158: 'SIGPWR', // 30
|
|
35
|
+
159: 'SIGSYS', // 31
|
|
36
|
+
},
|
|
37
|
+
}[process.platform] ?? {}
|
|
38
|
+
: {}
|
package/rxjs/auditMap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Observable, from } from 'rxjs'
|
|
2
2
|
|
|
3
3
|
function auditMapImpl(project) {
|
|
4
|
-
return new
|
|
4
|
+
return new Observable((o) => {
|
|
5
5
|
let pendingValue = null
|
|
6
6
|
let hasPendingValue = false
|
|
7
7
|
let isComplete = false
|
|
@@ -33,7 +33,7 @@ function auditMapImpl(project) {
|
|
|
33
33
|
function _tryNext(value) {
|
|
34
34
|
try {
|
|
35
35
|
const result = project(value)
|
|
36
|
-
const observable = typeof result.then === 'function' ?
|
|
36
|
+
const observable = typeof result.then === 'function' ? from(result) : result
|
|
37
37
|
innerSubscription = observable.subscribe({
|
|
38
38
|
next: _innerNext,
|
|
39
39
|
error: _error,
|
|
@@ -78,7 +78,7 @@ function auditMapImpl(project) {
|
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Observable.prototype.auditMap = auditMapImpl
|
|
82
82
|
|
|
83
83
|
export default function auditMap(project) {
|
|
84
84
|
return (o) => auditMapImpl.call(o, project)
|
package/rxjs/combineMap.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Observable, from, throwError } from 'rxjs'
|
|
2
2
|
|
|
3
3
|
const EMPTY = Object.freeze([])
|
|
4
4
|
|
|
5
5
|
function combineMapImpl(project, equals = (a, b) => a === b) {
|
|
6
6
|
const self = this
|
|
7
|
-
return new
|
|
7
|
+
return new Observable((o) => {
|
|
8
8
|
let curr = EMPTY
|
|
9
9
|
let scheduled = false
|
|
10
10
|
let disposed = false
|
|
@@ -75,9 +75,9 @@ function combineMapImpl(project, equals = (a, b) => a === b) {
|
|
|
75
75
|
} else {
|
|
76
76
|
let observable
|
|
77
77
|
try {
|
|
78
|
-
observable =
|
|
78
|
+
observable = from(project(keys[n]))
|
|
79
79
|
} catch (err) {
|
|
80
|
-
observable =
|
|
80
|
+
observable = throwError(() => err)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const entry = {
|
|
@@ -146,7 +146,7 @@ function combineMapImpl(project, equals = (a, b) => a === b) {
|
|
|
146
146
|
})
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
Observable.prototype.combineMap = combineMapImpl
|
|
150
150
|
|
|
151
151
|
export default function combineMap(project, equals) {
|
|
152
152
|
return (o) => combineMapImpl.call(o, project, equals)
|
package/rxjs/firstValueFrom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { first, timeout as rxTimeout } from 'rxjs'
|
|
2
2
|
import withAbortSignal from './withAbortSignal.js'
|
|
3
3
|
|
|
4
4
|
export default function firstValueFrom(x$, config) {
|
|
@@ -11,8 +11,8 @@ export default function firstValueFrom(x$, config) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (timeout) {
|
|
14
|
-
x$ = x$.pipe(
|
|
14
|
+
x$ = x$.pipe(rxTimeout(timeout))
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return x$.pipe(
|
|
17
|
+
return x$.pipe(first(hasConfig ? config.defaultValue : undefined)).toPromise()
|
|
18
18
|
}
|
package/rxjs/lastValueFrom.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import rx from 'rxjs/operators'
|
|
1
|
+
import { EMPTY, fromEvent, takeUntil, throwIfEmpty, last } from 'rxjs'
|
|
3
2
|
import { AbortError } from '../errors'
|
|
4
3
|
|
|
5
4
|
export default function lastValueFrom(x$, config) {
|
|
@@ -7,9 +6,9 @@ export default function lastValueFrom(x$, config) {
|
|
|
7
6
|
const signal = hasConfig ? config.signal : undefined
|
|
8
7
|
|
|
9
8
|
if (signal) {
|
|
10
|
-
x$ = signal.aborted ?
|
|
11
|
-
x$ = x$.pipe(
|
|
9
|
+
x$ = signal.aborted ? EMPTY : x$.pipe(takeUntil(fromEvent(signal, 'abort')))
|
|
10
|
+
x$ = x$.pipe(throwIfEmpty(() => new AbortError()))
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
return x$.pipe(
|
|
13
|
+
return x$.pipe(last(hasConfig ? config.defaultValue : undefined)).toPromise()
|
|
15
14
|
}
|
package/rxjs/withAbortSignal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Observable } from 'rxjs'
|
|
2
2
|
import { AbortError } from '../errors.js'
|
|
3
3
|
|
|
4
4
|
function withAbortSignalImpl(signal) {
|
|
5
|
-
return new
|
|
5
|
+
return new Observable((o) => {
|
|
6
6
|
o.add(this.subscribe(o))
|
|
7
7
|
|
|
8
8
|
if (!signal) {
|
|
@@ -24,7 +24,7 @@ function withAbortSignalImpl(signal) {
|
|
|
24
24
|
})
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Observable.prototype.withAbortSignal = withAbortSignalImpl
|
|
28
28
|
|
|
29
29
|
export default function withAbortSignal(signal) {
|
|
30
30
|
return (o) => withAbortSignalImpl.call(o, signal)
|
package/util/template/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import rxjs from 'rxjs'
|
|
1
|
+
import * as rxjs from 'rxjs'
|
|
3
2
|
import fp from 'lodash/fp.js'
|
|
4
3
|
import getNxtpressionsCompiler from './nextpressions.js'
|
|
5
4
|
import getJavascriptCompiler from './javascript.js'
|
|
@@ -102,7 +101,7 @@ export function makeTemplateCompiler({ ds, proxify }) {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
return rxjs.combineLatest(values).pipe(
|
|
105
|
-
|
|
104
|
+
rxjs.map((values) => {
|
|
106
105
|
const ret = [...arr]
|
|
107
106
|
for (let n = 0; n < values.length; n++) {
|
|
108
107
|
ret[indices[n]] = values[n]
|
|
@@ -139,7 +138,7 @@ export function makeTemplateCompiler({ ds, proxify }) {
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
return rxjs.combineLatest(values).pipe(
|
|
142
|
-
|
|
141
|
+
rxjs.map((values) => {
|
|
143
142
|
const ret = { ...obj }
|
|
144
143
|
for (let n = 0; n < values.length; n++) {
|
|
145
144
|
ret[indices[n]] = values[n]
|
|
@@ -174,7 +173,9 @@ export function makeTemplateCompiler({ ds, proxify }) {
|
|
|
174
173
|
compileStringTemplate(post)?.(str, args$) ?? rxjs.of(post),
|
|
175
174
|
])
|
|
176
175
|
.pipe(
|
|
177
|
-
|
|
176
|
+
rxjs.map(([pre, body, post]) =>
|
|
177
|
+
pre || post ? `${pre}${stringify(body)}${post}` : body,
|
|
178
|
+
),
|
|
178
179
|
)
|
|
179
180
|
} else if (type === 'nxt') {
|
|
180
181
|
const expr = compilers.nxt(body)
|
|
@@ -185,7 +186,9 @@ export function makeTemplateCompiler({ ds, proxify }) {
|
|
|
185
186
|
|
|
186
187
|
return (str, args$) =>
|
|
187
188
|
expr(args$).pipe(
|
|
188
|
-
|
|
189
|
+
rxjs.switchMap((body) =>
|
|
190
|
+
onResolveTemplate(`${pre}${stringify(body, true)}${post}`, args$),
|
|
191
|
+
),
|
|
189
192
|
)
|
|
190
193
|
} else {
|
|
191
194
|
throw new Error('unknown expression type: ' + type)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import moment from 'moment-timezone'
|
|
2
|
-
import
|
|
3
|
-
import Observable from 'rxjs'
|
|
2
|
+
import * as rxjs from 'rxjs'
|
|
4
3
|
import JSON5 from 'json5'
|
|
5
4
|
import fp from 'lodash/fp.js'
|
|
6
5
|
import NestedError from 'nested-error-stacks'
|
|
@@ -189,7 +188,7 @@ export default function ({ ds } = {}) {
|
|
|
189
188
|
|
|
190
189
|
function observe(id, options) {
|
|
191
190
|
if (id == null) {
|
|
192
|
-
return
|
|
191
|
+
return rxjs.of(path ? undefined : {})
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
const name = (id || '') + (postfix || '')
|
|
@@ -211,8 +210,8 @@ export default function ({ ds } = {}) {
|
|
|
211
210
|
if (Array.isArray(value)) {
|
|
212
211
|
value = value.filter((x) => x && fp.isString(x))
|
|
213
212
|
return value.length
|
|
214
|
-
?
|
|
215
|
-
:
|
|
213
|
+
? rxjs.combineLatest(value.map((id) => observe(id, options)))
|
|
214
|
+
: rxjs.of([])
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
return null
|
|
@@ -262,14 +261,14 @@ export default function ({ ds } = {}) {
|
|
|
262
261
|
return (value) =>
|
|
263
262
|
value
|
|
264
263
|
? ds.record.observe2(`${value}:asset.rawTypes?`).pipe(
|
|
265
|
-
|
|
264
|
+
rxjs.map(({ state, data }) => ({
|
|
266
265
|
state,
|
|
267
266
|
data: fp.includes(type, data.value),
|
|
268
267
|
})),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
rxjs.filter(({ state, data }) => data || state >= ds.record.PROVIDER),
|
|
269
|
+
rxjs.pluck('data'),
|
|
270
|
+
rxjs.distinctUntilChanged(),
|
|
271
|
+
rxjs.map((isType) => (isType ? value : _return ? RETURN : null)),
|
|
273
272
|
)
|
|
274
273
|
: null
|
|
275
274
|
},
|
|
@@ -490,9 +489,9 @@ export default function ({ ds } = {}) {
|
|
|
490
489
|
return null
|
|
491
490
|
}
|
|
492
491
|
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
|
|
492
|
+
return rxjs.timer(dueTime, period).pipe(
|
|
493
|
+
rxjs.map(() => moment()),
|
|
494
|
+
rxjs.startWith(null),
|
|
496
495
|
)
|
|
497
496
|
},
|
|
498
497
|
}),
|
|
@@ -537,12 +536,12 @@ export default function ({ ds } = {}) {
|
|
|
537
536
|
|
|
538
537
|
const getValue = (value, [path, ...rest]) => {
|
|
539
538
|
if (!path || !value || typeof value !== 'object') {
|
|
540
|
-
return
|
|
539
|
+
return rxjs.isObservable(value) ? value : rxjs.of(value)
|
|
541
540
|
} else {
|
|
542
|
-
return
|
|
541
|
+
return rxjs.isObservable(value)
|
|
543
542
|
? value.pipe(
|
|
544
|
-
|
|
545
|
-
|
|
543
|
+
rxjs.switchMap((value) => getValue(value[path], rest)),
|
|
544
|
+
rxjs.distinctUntilChanged(),
|
|
546
545
|
)
|
|
547
546
|
: getValue(value[path], rest)
|
|
548
547
|
}
|
|
@@ -550,27 +549,27 @@ export default function ({ ds } = {}) {
|
|
|
550
549
|
|
|
551
550
|
const reduceValue = (value, index, filters, options) => {
|
|
552
551
|
if (value === RETURN) {
|
|
553
|
-
return
|
|
552
|
+
return rxjs.of(null)
|
|
554
553
|
}
|
|
555
554
|
|
|
556
555
|
while (index < filters.length) {
|
|
557
556
|
value = filters[index++](value, options)
|
|
558
557
|
|
|
559
558
|
if (value === RETURN) {
|
|
560
|
-
return
|
|
559
|
+
return rxjs.of(null)
|
|
561
560
|
}
|
|
562
561
|
|
|
563
|
-
if (
|
|
562
|
+
if (rxjs.isObservable(value)) {
|
|
564
563
|
return value.pipe(
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
rxjs.switchMap((value) => reduceValue(value, index, filters, options)),
|
|
565
|
+
rxjs.distinctUntilChanged(),
|
|
567
566
|
// TODO (fix): better error handling...
|
|
568
|
-
|
|
567
|
+
rxjs.catchError(() => rxjs.of(null)),
|
|
569
568
|
)
|
|
570
569
|
}
|
|
571
570
|
}
|
|
572
571
|
|
|
573
|
-
return
|
|
572
|
+
return rxjs.of(value)
|
|
574
573
|
}
|
|
575
574
|
|
|
576
575
|
return makeWeakCache((expression) => {
|
|
@@ -585,14 +584,14 @@ export default function ({ ds } = {}) {
|
|
|
585
584
|
|
|
586
585
|
return (context, options) =>
|
|
587
586
|
getValue(context, basePath).pipe(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
587
|
+
rxjs.switchMap((value) => reduceValue(value, 0, filters, options)),
|
|
588
|
+
rxjs.distinctUntilChanged(),
|
|
589
|
+
rxjs.catchError((err) => {
|
|
591
590
|
options?.logger?.error(
|
|
592
591
|
{ err, expression: { expression, context: JSON.stringify(context) } },
|
|
593
592
|
'expression failed',
|
|
594
593
|
)
|
|
595
|
-
return
|
|
594
|
+
return rxjs.of(null)
|
|
596
595
|
}),
|
|
597
596
|
)
|
|
598
597
|
} catch (err) {
|