@nxtedition/lib 19.0.10 → 19.0.11

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 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.0.10",
3
+ "version": "19.0.11",
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
- linux: {
4
- 129: 'SIGHUP', // 1
5
- 130: 'SIGINT', // 2
6
- 131: 'SIGQUIT', // 3
7
- 132: 'SIGILL', // 4
8
- 133: 'SIGTRAP', // 5
9
- 134: 'SIGABRT', // 6
10
- 135: 'SIGBUS', // 7
11
- 136: 'SIGFPE', // 8
12
- 137: 'SIGKILL', // 9
13
- 138: 'SIGUSR1', // 10
14
- 139: 'SIGSEGV', // 11
15
- 140: 'SIGUSR2', // 12
16
- 141: 'SIGPIPE', // 13
17
- 142: 'SIGALRM', // 14
18
- 143: 'SIGTERM', // 15
19
- 144: 'SIGSTKFLT', // 16
20
- 145: 'SIGCHLD', // 17
21
- 146: 'SIGCONT', // 18
22
- 147: 'SIGSTOP', // 19
23
- 148: 'SIGTSTP', // 20
24
- 149: 'SIGTTIN', // 21
25
- 150: 'SIGTTOU', // 22
26
- 151: 'SIGURG', // 23
27
- 152: 'SIGXCPU', // 24
28
- 153: 'SIGXFSZ', // 25
29
- 154: 'SIGVTALRM', // 26
30
- 155: 'SIGPROF', // 27
31
- 156: 'SIGWINCH', // 28
32
- 157: 'SIGIO', // 29
33
- 158: 'SIGPWR', // 30
34
- 159: 'SIGSYS', // 31
35
- },
36
- }[process.platform] ?? {}
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 rxjs from 'rxjs'
1
+ import { Observable, from } from 'rxjs'
2
2
 
3
3
  function auditMapImpl(project) {
4
- return new rxjs.Observable((o) => {
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' ? rxjs.from(result) : result
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
- rxjs.Observable.prototype.auditMap = auditMapImpl
81
+ Observable.prototype.auditMap = auditMapImpl
82
82
 
83
83
  export default function auditMap(project) {
84
84
  return (o) => auditMapImpl.call(o, project)
@@ -1,10 +1,10 @@
1
- import rxjs from 'rxjs'
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 rxjs.Observable((o) => {
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 = rxjs.from(project(keys[n]))
78
+ observable = from(project(keys[n]))
79
79
  } catch (err) {
80
- observable = rxjs.throwError(() => err)
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
- rxjs.Observable.prototype.combineMap = combineMapImpl
149
+ Observable.prototype.combineMap = combineMapImpl
150
150
 
151
151
  export default function combineMap(project, equals) {
152
152
  return (o) => combineMapImpl.call(o, project, equals)
@@ -1,4 +1,4 @@
1
- import rx from 'rxjs/operators'
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(rx.timeout(timeout))
14
+ x$ = x$.pipe(rxTimeout(timeout))
15
15
  }
16
16
 
17
- return x$.pipe(rx.first(hasConfig ? config.defaultValue : undefined)).toPromise()
17
+ return x$.pipe(first(hasConfig ? config.defaultValue : undefined)).toPromise()
18
18
  }
@@ -1,5 +1,4 @@
1
- import rxjs from 'rxjs'
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 ? rxjs.EMPTY : x$.pipe(rx.takeUntil(rxjs.fromEvent(signal, 'abort')))
11
- x$ = x$.pipe(rx.throwIfEmpty(() => new AbortError()))
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(rx.last(hasConfig ? config.defaultValue : undefined)).toPromise()
13
+ return x$.pipe(last(hasConfig ? config.defaultValue : undefined)).toPromise()
15
14
  }
@@ -1,8 +1,8 @@
1
- import rxjs from 'rxjs'
1
+ import { Observable } from 'rxjs'
2
2
  import { AbortError } from '../errors.js'
3
3
 
4
4
  function withAbortSignalImpl(signal) {
5
- return new rxjs.Observable((o) => {
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
- rxjs.Observable.prototype.withAbortSignal = withAbortSignalImpl
27
+ Observable.prototype.withAbortSignal = withAbortSignalImpl
28
28
 
29
29
  export default function withAbortSignal(signal) {
30
30
  return (o) => withAbortSignalImpl.call(o, signal)
@@ -1,5 +1,4 @@
1
- import rx from 'rxjs/operators'
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
- rx.map((values) => {
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
- rx.map((values) => {
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
- rx.map(([pre, body, post]) => (pre || post ? `${pre}${stringify(body)}${post}` : body)),
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
- rx.switchMap((body) => onResolveTemplate(`${pre}${stringify(body, true)}${post}`, args$)),
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,6 @@
1
1
  import assert from 'node:assert'
2
2
  import { makeWeakCache } from '../../weakCache.js'
3
- import rxjs from 'rxjs'
3
+ import * as rxjs from 'rxjs'
4
4
  import vm from 'node:vm'
5
5
  import objectHash from 'object-hash'
6
6
  import * as datefns from 'date-fns'
@@ -1,6 +1,5 @@
1
1
  import moment from 'moment-timezone'
2
- import rx from 'rxjs/operators'
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 Observable.of(path ? undefined : {})
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
- ? Observable.combineLatest(value.map((id) => observe(id, options)))
215
- : Observable.of([])
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
- rx.map(({ state, data }) => ({
264
+ rxjs.map(({ state, data }) => ({
266
265
  state,
267
266
  data: fp.includes(type, data.value),
268
267
  })),
269
- rx.filter(({ state, data }) => data || state >= ds.record.PROVIDER),
270
- rx.pluck('data'),
271
- rx.distinctUntilChanged(),
272
- rx.map((isType) => (isType ? value : _return ? RETURN : null)),
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 Observable.timer(dueTime, period).pipe(
494
- rx.map(() => moment()),
495
- rx.startWith(null),
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 Observable.isObservable(value) ? value : Observable.of(value)
539
+ return rxjs.isObservable(value) ? value : rxjs.of(value)
541
540
  } else {
542
- return Observable.isObservable(value)
541
+ return rxjs.isObservable(value)
543
542
  ? value.pipe(
544
- rx.switchMap((value) => getValue(value[path], rest)),
545
- rx.distinctUntilChanged(),
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 Observable.of(null)
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 Observable.of(null)
559
+ return rxjs.of(null)
561
560
  }
562
561
 
563
- if (Observable.isObservable(value)) {
562
+ if (rxjs.isObservable(value)) {
564
563
  return value.pipe(
565
- rx.switchMap((value) => reduceValue(value, index, filters, options)),
566
- rx.distinctUntilChanged(),
564
+ rxjs.switchMap((value) => reduceValue(value, index, filters, options)),
565
+ rxjs.distinctUntilChanged(),
567
566
  // TODO (fix): better error handling...
568
- rx.catchError(() => Observable.of(null)),
567
+ rxjs.catchError(() => rxjs.of(null)),
569
568
  )
570
569
  }
571
570
  }
572
571
 
573
- return Observable.of(value)
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
- rx.switchMap((value) => reduceValue(value, 0, filters, options)),
589
- rx.distinctUntilChanged(),
590
- rx.catchError((err) => {
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 Observable.of(null)
594
+ return rxjs.of(null)
596
595
  }),
597
596
  )
598
597
  } catch (err) {