teraslice-client-js 1.0.0 → 1.1.0

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.
package/jest.config.js CHANGED
@@ -8,37 +8,4 @@ const module = await import(configModulePath);
8
8
 
9
9
  const config = module.default(dirPath);
10
10
 
11
- config.extensionsToTreatAsEsm = ['.ts'];
12
- config.moduleNameMapper = {
13
- '^(\\.{1,2}/.*)\\.js$': '$1',
14
- };
15
- config.testTimeout = 60 * 1000;
16
-
17
- // using swc for some reason throws rust file not found errors,
18
- // seems like a bug on their end, hope to change back later
19
- config.transform = {};
20
- config.transform['^.+\\.(t|j)sx?$'] = ['@swc/jest', {
21
- jsc: {
22
- loose: true,
23
- parser: {
24
- syntax: 'typescript',
25
- tsx: false,
26
- decorators: true
27
- },
28
- transform: {
29
- legacyDecorator: true,
30
- decoratorMetadata: true
31
- },
32
- target: 'esnext'
33
- },
34
- module: {
35
- type: 'es6',
36
- strictMode: false,
37
- noInterop: false,
38
- ignoreDynamic: true
39
- }
40
- }];
41
-
42
- config.transformIgnorePatterns = [];
43
- config.preset = '';
44
11
  export default config;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "teraslice-client-js",
3
3
  "displayName": "Teraslice Client (JavaScript)",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "description": "A Node.js client for teraslice jobs, assets, and cluster references.",
6
6
  "keywords": [
7
7
  "elasticsearch",
@@ -32,17 +32,17 @@
32
32
  "test:watch": "ts-scripts test --watch . --"
33
33
  },
34
34
  "dependencies": {
35
- "@terascope/types": "^1.0.0",
36
- "@terascope/utils": "^1.0.0",
35
+ "@terascope/types": "^1.1.0",
36
+ "@terascope/utils": "^1.1.0",
37
37
  "auto-bind": "^4.0.0",
38
38
  "got": "^11.8.3"
39
39
  },
40
40
  "devDependencies": {
41
- "nock": "^13.5.1"
41
+ "nock": "^13.5.5"
42
42
  },
43
43
  "engines": {
44
- "node": ">=14.17.0",
45
- "yarn": ">=1.16.0"
44
+ "node": ">=18.18.0",
45
+ "yarn": ">=1.22.19"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
package/src/job.ts CHANGED
@@ -101,6 +101,10 @@ export default class Job extends Client {
101
101
  return this.update(body);
102
102
  }
103
103
 
104
+ async deleteJob(): Promise<Teraslice.JobConfig> {
105
+ return this.delete(`/jobs/${this._jobId}`);
106
+ }
107
+
104
108
  async execution(requestOptions: RequestOptions = {}): Promise<Teraslice.ExecutionConfig> {
105
109
  return this.get(`/jobs/${this._jobId}/ex`, requestOptions);
106
110
  }
package/src/jobs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { isString, TSError } from '@terascope/utils';
1
+ import { TSError } from '@terascope/utils';
2
2
  import { Teraslice } from '@terascope/types';
3
3
  import autoBind from 'auto-bind';
4
4
  import Client from './client.js';
@@ -26,10 +26,9 @@ export default class Jobs extends Client {
26
26
  }
27
27
 
28
28
  async list(
29
- status?: Teraslice.JobListStatusQuery,
29
+ query?: Teraslice.JobSearchParams,
30
30
  searchOptions: SearchOptions = {}
31
31
  ): Promise<Teraslice.JobConfig[]> {
32
- const query = _parseListOptions(status);
33
32
  return this.get('/jobs', this.makeOptions(query, searchOptions));
34
33
  }
35
34
 
@@ -41,10 +40,3 @@ export default class Jobs extends Client {
41
40
  return new Job(this._config, jobId);
42
41
  }
43
42
  }
44
-
45
- function _parseListOptions(options?: Teraslice.JobListStatusQuery): Teraslice.JobSearchParams {
46
- // support legacy
47
- if (!options) return { status: '*' };
48
- if (isString(options)) return { status: options };
49
- return options;
50
- }
package/test/job-spec.ts CHANGED
@@ -325,7 +325,7 @@ describe('Teraslice Job', () => {
325
325
  _context: 'job',
326
326
  job_id: 'some-job-id',
327
327
  _created: 'hello',
328
- _updated: 'hello',
328
+ _updated: 'hello'
329
329
  };
330
330
 
331
331
  beforeEach(() => {
@@ -360,7 +360,7 @@ describe('Teraslice Job', () => {
360
360
  _context: 'job',
361
361
  job_id: 'some-job-id',
362
362
  _created: 'hello',
363
- _updated: 'hello',
363
+ _updated: 'hello'
364
364
  };
365
365
 
366
366
  const expected = {
@@ -383,6 +383,21 @@ describe('Teraslice Job', () => {
383
383
  });
384
384
  });
385
385
 
386
+ describe('->deleteJob', () => {
387
+ describe('when called', () => {
388
+ beforeEach(() => {
389
+ scope.delete('/jobs/some-other-job-id')
390
+ .reply(200, { job_id: 'some-other-job-id', _deleted: true });
391
+ });
392
+
393
+ it('should resolve json results from Teraslice', async () => {
394
+ const job = new Job({ baseUrl }, 'some-other-job-id');
395
+ const results = await job.deleteJob();
396
+ expect(results).toEqual({ job_id: 'some-other-job-id', _deleted: true });
397
+ });
398
+ });
399
+ });
400
+
386
401
  describe('->exId', () => {
387
402
  describe('when called with nothing', () => {
388
403
  beforeEach(() => {
package/test/jobs-spec.ts CHANGED
@@ -170,7 +170,6 @@ describe('Teraslice Jobs', () => {
170
170
  describe('when called with nothing', () => {
171
171
  beforeEach(() => {
172
172
  scope.get('/jobs')
173
- .query({ status: '*' })
174
173
  .reply(200, list);
175
174
  });
176
175
 
@@ -180,22 +179,9 @@ describe('Teraslice Jobs', () => {
180
179
  });
181
180
  });
182
181
 
183
- describe('when called with a string', () => {
184
- beforeEach(() => {
185
- scope.get('/jobs')
186
- .query({ status: Teraslice.ExecutionStatusEnum.running })
187
- .reply(200, list);
188
- });
189
-
190
- it('should resolve json result from Teraslice', async () => {
191
- const results = await jobs.list(Teraslice.ExecutionStatusEnum.running);
192
- expect(results).toEqual(list);
193
- });
194
- });
195
-
196
- describe('when called with an object', () => {
182
+ describe('when called with an query and search objects', () => {
197
183
  const searchOptions = { headers: { 'Some-Header': 'yes' } };
198
- const queryOptions = { status: Teraslice.ExecutionStatusEnum.running, size: 10 };
184
+ const queryOptions = { active: true } as const;
199
185
 
200
186
  beforeEach(() => {
201
187
  scope.get('/jobs')
package/tsconfig.json CHANGED
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "extends": "../../tsconfig",
3
3
  "compilerOptions": {
4
- "target": "ESNext",
5
- "module": "ESNext",
6
4
  "outDir": "dist",
7
5
  "rootDir": "."
8
6
  },
package/.eslintrc.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@terascope",
3
- "parserOptions": {
4
- "ecmaVersion": "latest",
5
- "sourceType": "module"
6
- },
7
- "rules": {
8
- "@typescript-eslint/naming-convention": "off",
9
- "@typescript-eslint/no-duplicate-enum-values": "warn",
10
- "import/extensions": "off",
11
- "import/no-import-module-exports": "off"
12
- },
13
- "ignorePatterns":[]
14
- }