@fastify/elasticsearch 4.0.1 → 4.0.3

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.
@@ -2,12 +2,52 @@ version: 2
2
2
  updates:
3
3
  - package-ecosystem: "github-actions"
4
4
  directory: "/"
5
+ commit-message:
6
+ # Prefix all commit messages with "chore: "
7
+ prefix: "chore"
5
8
  schedule:
6
- interval: "monthly"
9
+ interval: "weekly"
10
+ cooldown:
11
+ default-days: 7
12
+ allow:
13
+ - dependency-name: "*"
14
+ update-types:
15
+ - "version-update:semver-major"
7
16
  open-pull-requests-limit: 10
8
17
 
9
18
  - package-ecosystem: "npm"
10
19
  directory: "/"
20
+ commit-message:
21
+ # Prefix all commit messages with "chore: "
22
+ prefix: "chore"
11
23
  schedule:
12
24
  interval: "weekly"
25
+ cooldown:
26
+ default-days: 7
27
+ versioning-strategy: "increase-if-necessary"
28
+ allow:
29
+ - dependency-name: "*"
30
+ update-types:
31
+ - "version-update:semver-major"
32
+ ignore:
33
+ # TODO: remove ignore until neostandard support ESLint 10
34
+ - dependency-name: "eslint"
35
+ - dependency-name: "neostandard"
36
+ - dependency-name: "@stylistic/*"
13
37
  open-pull-requests-limit: 10
38
+ groups:
39
+ # Production dependencies with breaking changes
40
+ dependencies:
41
+ dependency-type: "production"
42
+ # ESLint related dependencies
43
+ dev-dependencies-eslint:
44
+ patterns:
45
+ - "eslint"
46
+ - "neostandard"
47
+ - "@stylistic/*"
48
+ # TypeScript related dependencies
49
+ dev-dependencies-typescript:
50
+ patterns:
51
+ - "@types/*"
52
+ - "tstyche"
53
+ - "typescript"
@@ -4,7 +4,6 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
- - master
8
7
  - next
9
8
  - 'v*'
10
9
  paths-ignore:
@@ -15,9 +14,21 @@ on:
15
14
  - 'docs/**'
16
15
  - '*.md'
17
16
 
17
+ # This allows a subsequently queued workflow run to interrupt previous runs
18
+ concurrency:
19
+ group: "${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
20
+ cancel-in-progress: true
21
+
22
+ permissions:
23
+ contents: read
24
+
18
25
  jobs:
19
26
  test:
20
- uses: fastify/workflows/.github/workflows/plugins-ci-elasticsearch.yml@v4.2.0
27
+ permissions:
28
+ contents: write
29
+ pull-requests: write
30
+ uses: fastify/workflows/.github/workflows/plugins-ci-elasticsearch.yml@ef591e2186785d5ab36b9fe6a79c7ce2f1d94e57 # v7.0.0
21
31
  with:
22
32
  lint: true
23
33
  license-check: true
34
+ elasticsearch-version: 8.15.2
@@ -0,0 +1,19 @@
1
+ name: Lock Threads
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 0 1 * *'
6
+ workflow_dispatch:
7
+
8
+ concurrency:
9
+ group: lock
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ lock-threads:
16
+ permissions:
17
+ issues: write
18
+ pull-requests: write
19
+ uses: fastify/workflows/.github/workflows/lock-threads.yml@ef591e2186785d5ab36b9fe6a79c7ce2f1d94e57 # v7.0.0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018-2019 Fastify
3
+ Copyright (c) 2018-present The Fastify team <https://github.com/fastify/fastify#team>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @fastify/elasticsearch
2
2
 
3
- ![CI](https://github.com/fastify/fastify-elasticsearch/workflows/CI/badge.svg)
3
+ [![CI](https://github.com/fastify/fastify-elasticsearch/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-elasticsearch/actions/workflows/ci.yml)
4
4
  [![NPM version](https://img.shields.io/npm/v/@fastify/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@fastify/elasticsearch)
5
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5
+ [![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
6
6
 
7
- Fastify plugin for [Elasticsearch](https://www.elastic.co/elasticsearch/) for sharing the same ES client in every part of your server.
7
+ Fastify plugin for [Elasticsearch](https://www.elastic.co/elasticsearch/) for sharing the same ES client in every part of your server.
8
8
  Under the hood, the official [elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) module is used.
9
9
 
10
10
 
@@ -14,9 +14,23 @@ Under the hood, the official [elasticsearch](https://www.npmjs.com/package/@elas
14
14
  npm i @fastify/elasticsearch
15
15
  ```
16
16
 
17
+ ### Compatibility
18
+ | Plugin version | Fastify version |
19
+ | ---------------|-----------------|
20
+ | `>=4.x` | `^5.x` |
21
+ | `^3.x` | `^4.x` |
22
+ | `^2.x` | `^3.x` |
23
+ | `^1.x` | `^2.x` |
24
+ | `^1.x` | `^1.x` |
25
+
26
+
27
+ Please note that if a Fastify version is out of support, then so are the corresponding versions of this plugin
28
+ in the table above.
29
+ See [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Reference/LTS.md) for more details.
30
+
17
31
  ## Usage
18
- Add it to your project with `register` and you are done!
19
- The plugin accepts the [same options](https://github.com/elastic/elasticsearch-js#client-options) as the client.
32
+ Add it to your project with `register` and you are done!
33
+ The plugin accepts the [same options](https://github.com/elastic/elasticsearch-js) as the client.
20
34
 
21
35
  ```js
22
36
  const fastify = require('fastify')()
@@ -78,7 +92,7 @@ fastify.listen({ port: 3000 }, err => {
78
92
  ```
79
93
 
80
94
  ## Versioning
81
- By default the latest and greatest version of the Elasticsearch client is used, see the [compatibility](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html#_compatibility) table to understand if the embedded client is correct for you.
95
+ By default the latest and greatest version of the Elasticsearch client is used, see the [compatibility](https://www.elastic.co/docs/reference/elasticsearch/clients/javascript/installation#nodejs-support) table to understand if the embedded client is correct for you.
82
96
  If it is not, you can pass a custom client via the `client` option.
83
97
  ```js
84
98
  const fastify = require('fastify')()
package/es-docker.sh CHANGED
@@ -8,4 +8,4 @@ exec docker run \
8
8
  -e "discovery.type=single-node" \
9
9
  -e "xpack.security.enabled=false" \
10
10
  -p 9200:9200 \
11
- docker.elastic.co/elasticsearch/elasticsearch:8.3.2
11
+ docker.elastic.co/elasticsearch/elasticsearch:8.15.2
@@ -0,0 +1,6 @@
1
+ 'use strict'
2
+
3
+ module.exports = require('neostandard')({
4
+ ignores: require('neostandard').resolveIgnoresFromGitignore(),
5
+ ts: true
6
+ })
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@fastify/elasticsearch",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Fastify plugin for elastic search",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
7
7
  "types": "types/index.d.ts",
8
8
  "scripts": {
9
- "lint": "standard",
9
+ "lint": "eslint",
10
+ "lint:fix": "eslint --fix",
10
11
  "test": "npm run test:unit && npm run test:typescript",
11
- "test:unit": "tap",
12
- "test:typescript": "tsd"
12
+ "test:unit": "c8 --100 node --test",
13
+ "test:typescript": "tstyche"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -23,22 +24,51 @@
23
24
  "ES"
24
25
  ],
25
26
  "author": "Tommaso Allevi - @allevo",
27
+ "contributors": [
28
+ {
29
+ "name": "Matteo Collina",
30
+ "email": "hello@matteocollina.com"
31
+ },
32
+ {
33
+ "name": "James Sumners",
34
+ "url": "https://james.sumners.info"
35
+ },
36
+ {
37
+ "name": "Tomas Della Vedova",
38
+ "url": "https://delvedor.dev"
39
+ },
40
+ {
41
+ "name": "Frazer Smith",
42
+ "email": "frazer.dev@icloud.com",
43
+ "url": "https://github.com/fdawgs"
44
+ }
45
+ ],
26
46
  "license": "MIT",
27
47
  "bugs": {
28
48
  "url": "https://github.com/fastify/fastify-elasticsearch/issues"
29
49
  },
30
50
  "homepage": "https://github.com/fastify/fastify-elasticsearch#readme",
51
+ "funding": [
52
+ {
53
+ "type": "github",
54
+ "url": "https://github.com/sponsors/fastify"
55
+ },
56
+ {
57
+ "type": "opencollective",
58
+ "url": "https://opencollective.com/fastify"
59
+ }
60
+ ],
31
61
  "dependencies": {
32
- "@elastic/elasticsearch": "^8.13.1",
33
- "fastify-plugin": "^5.0.0"
62
+ "@elastic/elasticsearch": "^9.0.2",
63
+ "fastify-plugin": "^6.0.0"
34
64
  },
35
65
  "devDependencies": {
36
- "@types/node": "^22.0.0",
37
- "@fastify/pre-commit": "^2.1.0",
66
+ "@types/node": "^26.0.1",
67
+ "c8": "^12.0.0",
68
+ "eslint": "^9.17.0",
38
69
  "fastify": "^5.0.0",
39
- "standard": "^17.1.0",
40
- "tap": "^18.7.2",
41
- "tsd": "^0.31.0"
70
+ "neostandard": "^0.13.0",
71
+ "tstyche": "^7.0.0"
42
72
  },
43
73
  "publishConfig": {
44
74
  "access": "public"
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { test } = require('node:test')
4
4
  const { Client } = require('@elastic/elasticsearch')
5
5
  const Fastify = require('fastify')
6
6
  const fastifyElasticsearch = require('..')
@@ -8,29 +8,29 @@ const isElasticsearchClient = require('..').isElasticsearchClient
8
8
 
9
9
  test('with reachable cluster', async t => {
10
10
  const fastify = Fastify()
11
- t.teardown(() => fastify.close())
11
+ t.after(() => fastify.close())
12
12
  fastify.register(fastifyElasticsearch, { node: 'http://localhost:9200' })
13
13
 
14
14
  await fastify.ready()
15
- t.equal(fastify.elastic.name, 'elasticsearch-js')
15
+ t.assert.equal(fastify.elastic.name, 'elasticsearch-js')
16
16
  })
17
17
 
18
18
  test('with unreachable cluster', async t => {
19
19
  const fastify = Fastify()
20
- t.teardown(() => fastify.close())
20
+ t.after(() => fastify.close())
21
21
  fastify.register(fastifyElasticsearch, { node: 'http://localhost:9201' })
22
22
 
23
23
  try {
24
24
  await fastify.ready()
25
- t.fail('should not boot successfully')
25
+ t.assert.fail('should not boot successfully')
26
26
  } catch (err) {
27
- t.ok(err)
27
+ t.assert.ok(err)
28
28
  }
29
29
  })
30
30
 
31
31
  test('with unreachable cluster and healthcheck disabled', async t => {
32
32
  const fastify = Fastify()
33
- t.teardown(() => fastify.close())
33
+ t.after(() => fastify.close())
34
34
  fastify.register(fastifyElasticsearch, {
35
35
  node: 'http://localhost:9201',
36
36
  healthcheck: false
@@ -38,30 +38,30 @@ test('with unreachable cluster and healthcheck disabled', async t => {
38
38
 
39
39
  try {
40
40
  await fastify.ready()
41
- t.equal(fastify.elastic.name, 'elasticsearch-js')
42
- } catch (err) {
43
- t.fail('should not error')
41
+ t.assert.equal(fastify.elastic.name, 'elasticsearch-js')
42
+ } catch {
43
+ t.assert.fail('should not error')
44
44
  }
45
45
  })
46
46
 
47
47
  test('namespaced', async t => {
48
48
  const fastify = Fastify()
49
- t.teardown(() => fastify.close())
49
+ t.after(() => fastify.close())
50
50
  fastify.register(fastifyElasticsearch, {
51
51
  node: 'http://localhost:9200',
52
52
  namespace: 'cluster'
53
53
  })
54
54
 
55
55
  await fastify.ready()
56
- t.equal(fastify.elastic.cluster.name, 'elasticsearch-js')
57
- t.equal(isElasticsearchClient(fastify.elastic), false)
58
- t.equal(isElasticsearchClient(fastify.elastic.cluster), true)
56
+ t.assert.equal(fastify.elastic.cluster.name, 'elasticsearch-js')
57
+ t.assert.equal(isElasticsearchClient(fastify.elastic), false)
58
+ t.assert.equal(isElasticsearchClient(fastify.elastic.cluster), true)
59
59
  await fastify.close()
60
60
  })
61
61
 
62
62
  test('namespaced (errored)', async t => {
63
63
  const fastify = Fastify()
64
- t.teardown(() => fastify.close())
64
+ t.after(() => fastify.close())
65
65
  fastify.register(fastifyElasticsearch, {
66
66
  node: 'http://localhost:9200',
67
67
  namespace: 'cluster'
@@ -74,9 +74,9 @@ test('namespaced (errored)', async t => {
74
74
 
75
75
  try {
76
76
  await fastify.ready()
77
- t.fail('should not boot successfully')
77
+ t.assert.fail('should not boot successfully')
78
78
  } catch (err) {
79
- t.ok(err)
79
+ t.assert.ok(err)
80
80
  }
81
81
  })
82
82
 
@@ -87,24 +87,24 @@ test('custom client', async t => {
87
87
  })
88
88
 
89
89
  const fastify = Fastify()
90
- t.teardown(() => fastify.close())
90
+ t.after(() => fastify.close())
91
91
  fastify.register(fastifyElasticsearch, { client })
92
92
 
93
93
  await fastify.ready()
94
- t.equal(isElasticsearchClient(fastify.elastic), true)
95
- t.equal(fastify.elastic.name, 'custom')
94
+ t.assert.equal(isElasticsearchClient(fastify.elastic), true)
95
+ t.assert.equal(fastify.elastic.name, 'custom')
96
96
  await fastify.close()
97
97
  })
98
98
 
99
99
  test('Missing configuration', async t => {
100
100
  const fastify = Fastify()
101
- t.teardown(() => fastify.close())
101
+ t.after(() => fastify.close())
102
102
  fastify.register(fastifyElasticsearch)
103
103
 
104
104
  try {
105
105
  await fastify.ready()
106
- t.fail('should not boot successfully')
106
+ t.assert.fail('should not boot successfully')
107
107
  } catch (err) {
108
- t.ok(err)
108
+ t.assert.ok(err)
109
109
  }
110
110
  })
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { FastifyPluginAsync } from 'fastify';
2
- import type { Client, ClientOptions } from '@elastic/elasticsearch';
1
+ import type { FastifyPluginAsync } from 'fastify'
2
+ import type { Client, ClientOptions } from '@elastic/elasticsearch'
3
3
 
4
4
  declare module 'fastify' {
5
5
  interface FastifyInstance {
@@ -23,5 +23,5 @@ declare namespace fastifyElasticsearch {
23
23
  export { fastifyElasticsearch as default }
24
24
  }
25
25
 
26
- declare function fastifyElasticsearch(...params: Parameters<FastifyElasticsearch>): ReturnType<FastifyElasticsearch>
26
+ declare function fastifyElasticsearch (...params: Parameters<FastifyElasticsearch>): ReturnType<FastifyElasticsearch>
27
27
  export = fastifyElasticsearch
@@ -0,0 +1,19 @@
1
+ import fastifyElasticsearch from '.'
2
+ import Fastify from 'fastify'
3
+ import { expect } from 'tstyche'
4
+ import { Client } from '@elastic/elasticsearch'
5
+
6
+ const fastify = Fastify()
7
+ fastify.register(fastifyElasticsearch, { node: 'http://localhost:9200' })
8
+
9
+ expect(fastify.isElasticsearchClient(fastify.elastic)).type.toBe<boolean>()
10
+ expect(
11
+ fastify.isElasticsearchClient(fastify.elastic.asyncSearch)
12
+ ).type.toBe<boolean>()
13
+ expect(
14
+ fastify.isElasticsearchClient(fastify.elastic.aasdf)
15
+ ).type.toBe<boolean>()
16
+
17
+ expect(fastifyElasticsearch.isElasticsearchClient).type.toBeAssignableTo<
18
+ (value: any) => value is Client
19
+ >()
package/.taprc DELETED
@@ -1,2 +0,0 @@
1
- files:
2
- - test/**/*.test.js
@@ -1,13 +0,0 @@
1
- import fastifyElasticsearch from '..';
2
- import Fastify from 'fastify';
3
- import { expectAssignable, expectType } from 'tsd';
4
- import { Client } from '@elastic/elasticsearch';
5
-
6
-
7
- const fastify = Fastify()
8
- fastify.register(fastifyElasticsearch, { node: 'http://localhost:9200' })
9
-
10
- expectType<boolean>(fastify.isElasticsearchClient(fastify.elastic))
11
- expectType<boolean>(fastify.isElasticsearchClient(fastify.elastic.asyncSearch))
12
- expectType<boolean>(fastify.isElasticsearchClient(fastify.elastic.aasdf))
13
- expectAssignable<(value: any) => value is Client>(fastifyElasticsearch.isElasticsearchClient)