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 @@ -2,15 +2,17 @@
"name": "@elastic/elasticsearch-serverless",
"version": "0.6.0+20231031",
"description": "The official Node.js Elastic client for the Elasticsearch Serverless service.",
"main": "index.js",
"main": "./index.js",
"types": "index.d.ts",
"type": "commonjs",
"exports": {
"require": "./index.js"
},
"scripts": {
"lint": "ts-standard src",
"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",
"test": "npm run build && npm run lint && tap test/unit/{*,**/*}.test.ts",
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 All @@ -44,17 +45,19 @@ import { RedactionOptions } from '@elastic/transport/lib/Transport'
import BaseConnection, { prepareHeaders } from '@elastic/transport/lib/connection/BaseConnection'
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'
}
const [clientVersionNoMeta, apiVersion] = clientVersion.split('+')
let transportVersion: string = require('@elastic/transport/package.json').version // eslint-disable-line
let transportVersion: string = transportPackageJson.version
/* 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 @@ -162,8 +162,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 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 @@ -956,11 +956,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 @@ -1064,7 +1064,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