Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Sep 4, 2024
1 parent d7fe4b1 commit f99ac5c
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 130 deletions.
6 changes: 3 additions & 3 deletions lib/OpenSearchAPI.d.ts → api/OpenSearchAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* modify the API generator.
*/

import * as Global from '../api/_types/_global';
import * as API from '../api';
import * as Global from './_types/_global';
import * as API from './index';
import {
ApiError,
ApiResponse,
TransportRequestOptions,
TransportRequestCallback,
TransportRequestPromise,
} from './Transport';
} from '../lib/Transport';

declare type callbackFn<TResponse> = (err: ApiError, result: TResponse) => void;

Expand Down
117 changes: 117 additions & 0 deletions api/OpenSearchAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* This file was generated from the OpenSearch API Spec. Do NOT edit it
* manually. If you want to make changes, either update the spec or
* modify the API generator.
*/

'use strict';

const { kConfigErr } = require('./utils')
const kApiModules = Symbol('api modules')

class OpenSearchAPI {
constructor (opts) {
this[kConfigErr] = opts.ConfigurationError
this[kApiModules] = {
cat: new(require('./cat/_api'))(this),
cluster: new(require('./cluster/_api'))(this),
danglingIndices: new(require('./danglingIndices/_api'))(this),
http: new(require('./http/_api'))(this),
indices: new(require('./indices/_api'))(this),
ingest: new(require('./ingest/_api'))(this),
knn: new(require('./knn/_api'))(this),
ml: new(require('./ml/_api'))(this),
nodes: new(require('./nodes/_api'))(this),
notifications: new(require('./notifications/_api'))(this),
ppl: new(require('./ppl/_api'))(this),
remoteStore: new(require('./remoteStore/_api'))(this),
rollups: new(require('./rollups/_api'))(this),
searchPipeline: new(require('./searchPipeline/_api'))(this),
security: new(require('./security/_api'))(this),
snapshot: new(require('./snapshot/_api'))(this),
sql: new(require('./sql/_api'))(this),
tasks: new(require('./tasks/_api'))(this),
transforms: new(require('./transforms/_api'))(this),
}

// Setup Root API Functions
/** @namespace API-Core */
const cache = {}
this.bulk = require('./_core/bulk').bind(this)
this.clearScroll = require('./_core/clearScroll').bind(this)
this.count = require('./_core/count').bind(this)
this.create = require('./_core/create').bind(this)
this.createPit = require('./_core/createPit').bind(this)
this.delete = require('./_core/delete').bind(this)
this.deleteAllPits = require('./_core/deleteAllPits').bind(this)
this.deleteByQuery = require('./_core/deleteByQuery').bind(this)
this.deleteByQueryRethrottle = require('./_core/deleteByQueryRethrottle').bind(this)
this.deletePit = require('./_core/deletePit').bind(this)
this.deleteScript = require('./_core/deleteScript').bind(this)
this.exists = require('./_core/exists').bind(this)
this.existsSource = require('./_core/existsSource').bind(this)
this.explain = require('./_core/explain').bind(this)
this.fieldCaps = require('./_core/fieldCaps').bind(this)
this.get = require('./_core/get').bind(this)
this.getAllPits = require('./_core/getAllPits').bind(this)
this.getScript = require('./_core/getScript').bind(this)
this.getScriptContext = require('./_core/getScriptContext').bind(this)
this.getScriptLanguages = require('./_core/getScriptLanguages').bind(this)
this.getSource = require('./_core/getSource').bind(this)
this.index = require('./_core').bind(this)
this.info = require('./_core/info').bind(this)
this.mget = require('./_core/mget').bind(this)
this.msearch = require('./_core/msearch').bind(this)
this.msearchTemplate = require('./_core/msearchTemplate').bind(this)
this.mtermvectors = require('./_core/mtermvectors').bind(this)
this.ping = require('./_core/ping').bind(this)
this.putScript = require('./_core/putScript').bind(this)
this.rankEval = require('./_core/rankEval').bind(this)
this.reindex = require('./_core/reindex').bind(this)
this.reindexRethrottle = require('./_core/reindexRethrottle').bind(this)
this.renderSearchTemplate = require('./_core/renderSearchTemplate').bind(this)
this.scriptsPainlessExecute = require('./_core/scriptsPainlessExecute').bind(this)
this.scroll = require('./_core/scroll').bind(this)
this.search = require('./_core/search').bind(this)
this.searchShards = require('./_core/searchShards').bind(this)
this.searchTemplate = require('./_core/searchTemplate').bind(this)
this.termvectors = require('./_core/termvectors').bind(this)
this.update = require('./_core/update').bind(this)
this.updateByQuery = require('./_core/updateByQuery').bind(this)
this.updateByQueryRethrottle = require('./_core/updateByQueryRethrottle').bind(this)

// Setup API Modules
Object.defineProperties(this, {
cat: { get() { return this[kApiModules].cat } },
cluster: { get() { return this[kApiModules].cluster } },
danglingIndices: { get() { return this[kApiModules].danglingIndices } },
http: { get() { return this[kApiModules].http } },
indices: { get() { return this[kApiModules].indices } },
ingest: { get() { return this[kApiModules].ingest } },
knn: { get() { return this[kApiModules].knn } },
ml: { get() { return this[kApiModules].ml } },
nodes: { get() { return this[kApiModules].nodes } },
notifications: { get() { return this[kApiModules].notifications } },
ppl: { get() { return this[kApiModules].ppl } },
remoteStore: { get() { return this[kApiModules].remoteStore } },
rollups: { get() { return this[kApiModules].rollups } },
searchPipeline: { get() { return this[kApiModules].searchPipeline } },
security: { get() { return this[kApiModules].security } },
snapshot: { get() { return this[kApiModules].snapshot } },
sql: { get() { return this[kApiModules].sql } },
tasks: { get() { return this[kApiModules].tasks } },
transforms: { get() { return this[kApiModules].transforms } },
})
}
}

module.exports = OpenSearchAPI;
2 changes: 1 addition & 1 deletion lib/Client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { ConnectionOptions as TlsConnectionOptions } from 'tls';
import { URL } from 'url';
import OpenSearchAPI from './OpenSearchAPI';
import OpenSearchAPI from '../api/OpenSearchAPI';
import Serializer from './Serializer';
import Helpers from './Helpers';
import Connection, { AgentOptions, agentFn } from './Connection';
Expand Down
2 changes: 1 addition & 1 deletion lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const kChild = Symbol('opensearchjs-child');
const kExtensions = Symbol('opensearchjs-extensions');
const kEventEmitter = Symbol('opensearchjs-event-emitter');

const OpenSearchAPI = require('./OpenSearchAPI');
const OpenSearchAPI = require('../api/OpenSearchAPI');

class Client extends OpenSearchAPI {
constructor(opts = {}) {
Expand Down
117 changes: 0 additions & 117 deletions lib/OpenSearchAPI.js

This file was deleted.

10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"test:integration:helpers": "tap test/integration/helpers/*.test.js",
"test:integration:helpers-secure": "tap test/integration/helpers-secure/*.test.js",
"test:types": "tsd",
"test:coverage-90": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --branches=90 --functions=90 --lines=90 --statements=90",
"test:coverage-report": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --branches=90 --functions=90 --lines=90 --statements=90 && nyc report --reporter=text-lcov > coverage.lcov",
"test:coverage-90": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --branches=90 --functions=90 --lines=90 --statements=90 --nyc-arg=\"--exclude=api\"",
"test:coverage-report": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --branches=90 --functions=90 --lines=90 --statements=90 --nyc-arg=\"--exclude=api\" && nyc report --reporter=text-lcov > coverage.lcov",
"test:coverage-ui": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --coverage-report=html --nyc-arg=\"--exclude=api\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand Down Expand Up @@ -136,11 +136,5 @@
"flow": false,
"coverage": false,
"jobs-auto": true
},
"nyc": {
"exclude": [
"api/**",
"lib/OpenSearchAPI.js"
]
}
}

0 comments on commit f99ac5c

Please sign in to comment.