Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

5 packages

Sort by
elasticsearch/8/migration-recipe

This recipe is a set of codemods that will help migrate to Elasticsearch 8. The recipe includes the following codemods: - elasticsearch/8/migrate-plugins-extended - elasticsearch/8/move-client-configurations - elasticsearch/8/rename-query-string - elasticsearch/8/unify-return-value

  • migration
  • elasticsearch
335c4n0r
v1.0.4
0
2 years ago
elasticsearch/8/unify-return-value

This codemod updates the API response structure for search calls, replacing the previous body-only return with an object containing additional fields like `statusCode`, `headers`, and `warnings` ## What Changed Previously, the return value of search calls differed based on whether a callback or promise was used: - For promises, only the body was returned. - For callbacks, body, statusCode, and headers were returned separately. Now, both callbacks and promises return an object containing body, statusCode, headers, warnings, and meta. ## Before ```jsx // Promise const body = await client.search({ index: 'my-index', body: { foo: 'bar' } }); // Callback client.search({ index: 'my-index', body: { foo: 'bar' } }, (err, body, statusCode, headers) => { if (err) console.log(err); }); ``` ## After ```jsx // Promise const { body, statusCode, headers, warnings } = await client.search({ index: 'my-index', body: { foo: 'bar' } }); // Callback client.search({ index: 'my-index', body: { foo: 'bar' } }, (err, { body, statusCode, headers, warnings }) => { if (err) console.log(err); }); ```

  • elasticsearch
  • 8
  • +1
335c4n0r
v1.0.1
0
2 years ago
elasticsearch/8/rename-query-string

This codemod renames the query key to querystring and changes the body key to bulkBody in client.transport.request. ## What Changed Previously, the query key was used for query parameters and body was used for the request body in client.transport.request. Now, you need to use querystring for query parameters and bulkBody for the request body. ## Before ```jsx const body = await client.transport.request({ method: 'GET', path: '/my-index/_search', body: { foo: 'bar' }, query: { bar: 'baz' } }); client.transport.request({ method: 'GET', path: '/my-index/_search', body: { foo: 'bar' }, query: { bar: 'baz' } }, (err, body, statusCode, headers) => { if (err) console.log(err); }); ``` ## After ```jsx const { body, statusCode, headers, warnings } = await client.transport.request({ method: 'GET', path: '/my-index/_search', bulkBody: { foo: 'bar' }, querystring: { bar: 'baz' } }); client.transport.request({ method: 'GET', path: '/my-index/_search', bulkBody: { foo: 'bar' }, querystring: { bar: 'baz' } }, (err, { body, statusCode, headers, warnings }) => { if (err) console.log(err); }); ```

  • elasticsearch
  • 8
  • +1
335c4n0r
v1.0.1
0
2 years ago
elasticsearch/8/migrate-plugins-extended

This codemod migrates the plugins option to client.extend() calls. ## What Changed Previously, you could pass plugins as an option to the Client constructor. Now, plugins need to be added using the client.extend() method. ## Before ```jsx const { Client } = require('elasticsearch'); const client = new Client({ node: 'http://localhost:9200', plugins: ['pluginA', 'pluginB'] }); ``` ## After ```jsx const { Client } = require('@elastic/elasticsearch'); const client = new Client({ node: 'http://localhost:9200' }); client.extend('pluginA'); client.extend('pluginB'); ```

  • elasticsearch
  • 8
  • +1
335c4n0r
v1.0.1
0
2 years ago
elasticsearch/8/move-client-configurations

This codemod moves the client-related configuration parameters (ignore, headers, requestTimeout, and maxRetries) from the API object to the second options object. ## What Changed Previously, ignore, headers, requestTimeout, and maxRetries could be passed directly inside the API object. Now, these parameters need to be specified in a second options object. Now, both callbacks and promises return an object containing body, statusCode, headers, warnings, and meta. ## Before ```jsx const body = await client.search({ index: 'my-index', body: { foo: 'bar' }, ignore: [404] }); client.search({ index: 'my-index', body: { foo: 'bar' }, ignore: [404] }, (err, body, statusCode, headers) => { if (err) console.log(err); }); ``` ## After ```jsx const { body, statusCode, headers, warnings } = await client.search({ index: 'my-index', body: { foo: 'bar' } }, { ignore: [404] }); client.search({ index: 'my-index', body: { foo: 'bar' } }, { ignore: [404] }, (err, { body, statusCode, headers, warnings }) => { if (err) console.log(err); }); ```

  • elasticsearch
  • 8
  • +1
335c4n0r
v1.0.1
0
2 years ago

Build your own codemod!

Describe the migration you need and Codemod Agent will create a codemod for you.

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.