Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "8.15.0",
"versionCanary": "8.15.0-canary.0",
"description": "The official Elasticsearch client for Node.js",
"main": "index.js",
"main": "./index.js",
"types": "index.d.ts",
"type": "commonjs",
"exports": {
"require": "./index.js"
},
"scripts": {
"test": "npm run build && npm run lint && tap test/unit/{*,**/*}.test.ts",
"test:unit": "npm run build && tap test/unit/{*,**/*}.test.ts",
Expand All @@ -17,7 +19,7 @@
"lint:fix": "ts-standard --fix src",
"license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause;0BSD'",
"prebuild": "npm run clean-build && npm run lint",
"build": "tsc",
"build": "tsc && rm lib/package.json && mv lib/src/* lib/ && rm -rf lib/src",
"clean-build": "rimraf ./lib && mkdir lib",
"prepublishOnly": "npm run build"
},
Expand Down
15 changes: 9 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/

import { ConnectionOptions as TlsConnectionOptions } from 'tls'
import { URL } from 'url'
import buffer from 'buffer'
import os from 'os'
import process from 'node:process'
import { ConnectionOptions as TlsConnectionOptions } from 'node:tls'
import { URL } from 'node:url'
import buffer from 'node:buffer'
import os from 'node:os'
import {
Transport,
UndiciConnection,
Expand Down Expand Up @@ -48,16 +49,18 @@ import BaseConnection, { prepareHeaders, ConnectionOptions } from '@elastic/tran
import SniffingTransport from './sniffingTransport'
import Helpers from './helpers'
import API from './api'
import packageJson from '../package.json'
import transportPackageJson from '@elastic/transport/package.json'

const kChild = Symbol('elasticsearchjs-child')
const kInitialOptions = Symbol('elasticsearchjs-initial-options')
let clientVersion: string = require('../package.json').version // eslint-disable-line
let clientVersion: string = packageJson.version
/* istanbul ignore next */
if (clientVersion.includes('-')) {
// clean prerelease
clientVersion = clientVersion.slice(0, clientVersion.indexOf('-')) + 'p'
}
let transportVersion: string = require('@elastic/transport/package.json').version // eslint-disable-line
let transportVersion: string = transportPackageJson.version // eslint-disable-line
/* istanbul ignore next */
if (transportVersion.includes('-')) {
// clean prerelease
Expand Down
10 changes: 5 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
/* eslint-disable @typescript-eslint/promise-function-async */
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */

import assert from 'assert'
import { promisify } from 'util'
import { Readable } from 'stream'
import assert from 'node:assert'
import * as timersPromises from 'node:timers/promises'
import { Readable } from 'node:stream'
import { errors, TransportResult, TransportRequestOptions, TransportRequestOptionsWithMeta } from '@elastic/transport'
import Client from './client'
import * as T from './api/types'
Expand Down Expand Up @@ -163,8 +163,8 @@ export interface EsqlToRecords<TDocument> {
}

const { ResponseError, ConfigurationError } = errors
const sleep = promisify(setTimeout)
const pImmediate = promisify(setImmediate)
const sleep = timersPromises.setTimeout
const pImmediate = timersPromises.setImmediate
/* istanbul ignore next */
const noop = (): void => {}
const kClient = Symbol('elasticsearch-client')
Expand Down
2 changes: 1 addition & 1 deletion src/sniffingTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import assert from 'assert'
import assert from 'node:assert'
import { Transport, SniffOptions } from '@elastic/transport'

export default class SniffingTransport extends Transport {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

'use strict'

const assert = require('assert')
const assert = require('node:assert')
const fetch = require('node-fetch')

function runInParallel (client, operation, options, clientOptions) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/helpers/bulk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

'use strict'

const { createReadStream } = require('fs')
const { join } = require('path')
const { createReadStream } = require('node:fs')
const { join } = require('node:path')
const split = require('split2')
const { test, beforeEach, afterEach } = require('tap')
const { waitCluster } = require('../../utils')
Expand Down
4 changes: 2 additions & 2 deletions test/integration/helpers/msearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

'use strict'

const { createReadStream } = require('fs')
const { join } = require('path')
const { createReadStream } = require('node:fs')
const { join } = require('node:path')
const split = require('split2')
const { test, beforeEach, afterEach } = require('tap')
const { waitCluster } = require('../../utils')
Expand Down
4 changes: 2 additions & 2 deletions test/integration/helpers/scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

'use strict'

const { createReadStream } = require('fs')
const { join } = require('path')
const { createReadStream } = require('node:fs')
const { join } = require('node:path')
const split = require('split2')
const { test, beforeEach, afterEach } = require('tap')
const { waitCluster } = require('../../utils')
Expand Down
4 changes: 2 additions & 2 deletions test/integration/helpers/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

'use strict'

const { createReadStream } = require('fs')
const { join } = require('path')
const { createReadStream } = require('node:fs')
const { join } = require('node:path')
const split = require('split2')
const { test, beforeEach, afterEach } = require('tap')
const { waitCluster } = require('../../utils')
Expand Down
2 changes: 1 addition & 1 deletion test/integration/reporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const assert = require('assert')
const assert = require('node:assert')
const { create } = require('xmlbuilder2')

function createJunitReporter () {
Expand Down
22 changes: 11 additions & 11 deletions test/unit/helpers/bulk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import FakeTimers from '@sinonjs/fake-timers'
import { AssertionError } from 'assert'
import { createReadStream } from 'fs'
import * as http from 'http'
import { join } from 'path'
import { AssertionError } from 'node:assert'
import { createReadStream } from 'node:fs'
import * as http from 'node:http'
import { join } from 'node:path'
import split from 'split2'
import { Readable } from 'stream'
import { Readable } from 'node:stream'
import { test } from 'tap'
import { Client, errors } from '../../../'
import { buildServer, connection } from '../../utils'
Expand Down Expand Up @@ -936,11 +936,11 @@ test('bulk index', t => {
onDocument (doc) {
t.type(doc.user, 'string') // testing that doc is type of Document
return [
{
index: {
_index: 'test'
}
},
{
index: {
_index: 'test'
}
},
{ ...doc, updatedAt }
]
},
Expand Down Expand Up @@ -1042,7 +1042,7 @@ test('bulk create', t => {
_index: 'test',
_id: String(id++)
}
},
},
{ ...doc, updatedAt }
]
},
Expand Down
3 changes: 2 additions & 1 deletion test/unit/helpers/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ test('Merge filter paths (snake_case)', async t => {
{ two: 'two' },
{ three: 'three' }
])
})
})

2 changes: 1 addition & 1 deletion test/utils/buildCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import Debug from 'debug'
import * as http from 'http'
import * as http from 'node:http'
import buildServer, { ServerHandler } from './buildServer'
import { StoppableServer } from 'stoppable'

Expand Down