teraslice-client-js 0.55.1 → 0.57.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.
Files changed (57) hide show
  1. package/dist/src/assets.d.ts +7 -6
  2. package/dist/src/assets.d.ts.map +1 -1
  3. package/dist/src/assets.js +15 -15
  4. package/dist/src/assets.js.map +1 -1
  5. package/dist/src/client.d.ts +1 -1
  6. package/dist/src/client.d.ts.map +1 -1
  7. package/dist/src/client.js +14 -15
  8. package/dist/src/client.js.map +1 -1
  9. package/dist/src/cluster.d.ts +7 -7
  10. package/dist/src/cluster.d.ts.map +1 -1
  11. package/dist/src/cluster.js +2 -2
  12. package/dist/src/cluster.js.map +1 -1
  13. package/dist/src/ex.d.ts +14 -13
  14. package/dist/src/ex.d.ts.map +1 -1
  15. package/dist/src/ex.js +18 -17
  16. package/dist/src/ex.js.map +1 -1
  17. package/dist/src/executions.d.ts +6 -6
  18. package/dist/src/executions.d.ts.map +1 -1
  19. package/dist/src/executions.js +7 -7
  20. package/dist/src/executions.js.map +1 -1
  21. package/dist/src/interfaces.d.ts +1 -218
  22. package/dist/src/interfaces.d.ts.map +1 -1
  23. package/dist/src/interfaces.js +0 -20
  24. package/dist/src/interfaces.js.map +1 -1
  25. package/dist/src/job.d.ts +19 -19
  26. package/dist/src/job.d.ts.map +1 -1
  27. package/dist/src/job.js +23 -21
  28. package/dist/src/job.js.map +1 -1
  29. package/dist/src/jobs.d.ts +4 -4
  30. package/dist/src/jobs.d.ts.map +1 -1
  31. package/dist/src/jobs.js +3 -3
  32. package/dist/src/jobs.js.map +1 -1
  33. package/dist/test/assets-spec.js +7 -1
  34. package/dist/test/assets-spec.js.map +1 -1
  35. package/dist/test/cluster-spec.js +0 -2
  36. package/dist/test/cluster-spec.js.map +1 -1
  37. package/dist/test/ex-spec.js +25 -25
  38. package/dist/test/ex-spec.js.map +1 -1
  39. package/dist/test/job-spec.js +79 -52
  40. package/dist/test/job-spec.js.map +1 -1
  41. package/dist/test/jobs-spec.js +4 -4
  42. package/dist/test/jobs-spec.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +3 -2
  45. package/src/assets.ts +24 -19
  46. package/src/client.ts +9 -11
  47. package/src/cluster.ts +10 -16
  48. package/src/ex.ts +44 -54
  49. package/src/executions.ts +15 -21
  50. package/src/interfaces.ts +1 -334
  51. package/src/job.ts +65 -64
  52. package/src/jobs.ts +10 -14
  53. package/test/assets-spec.ts +11 -5
  54. package/test/cluster-spec.ts +0 -2
  55. package/test/ex-spec.ts +32 -32
  56. package/test/job-spec.ts +87 -61
  57. package/test/jobs-spec.ts +5 -5
@@ -142,7 +142,6 @@ describe('Teraslice Cluster', () => {
142
142
  });
143
143
 
144
144
  it('should resolve the plain test results from Teraslice', async () => {
145
- // @ts-expect-error TODO: fixme
146
145
  const results = await cluster.txt('assets/assetName');
147
146
  expect(results).toEqual('assets-txt-response');
148
147
  });
@@ -158,7 +157,6 @@ describe('Teraslice Cluster', () => {
158
157
  expect.hasAssertions();
159
158
  const errMsg = '"invalid" is not a valid type. Must be one of ["assets","slicers","ex","jobs","nodes","workers"]';
160
159
  try {
161
- // @ts-expect-error
162
160
  await cluster.txt('invalid');
163
161
  } catch (err) {
164
162
  expect(err.message).toEqual(errMsg);
package/test/ex-spec.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import nock from 'nock';
2
- import { RecoveryCleanupType } from '@terascope/job-components';
2
+ import { Teraslice } from '@terascope/types';
3
3
  import Ex from '../src/ex';
4
- import {
5
- ExecutionStatus,
6
- ClusterStateNative,
7
- WorkerJobProcesses
8
- } from '../src/interfaces';
9
4
 
10
5
  describe('Teraslice Ex', () => {
11
6
  let scope: nock.Scope;
@@ -18,7 +13,7 @@ describe('Teraslice Ex', () => {
18
13
 
19
14
  const requestOptions = { headers: { 'Random-Header': 'true' } };
20
15
 
21
- const clusterState: ClusterStateNative = {
16
+ const clusterState: any = {
22
17
  'some-node-id': {
23
18
  hostname: 'host',
24
19
  pid: 111,
@@ -223,7 +218,7 @@ describe('Teraslice Ex', () => {
223
218
  describe('when called with a query', () => {
224
219
  beforeEach(() => {
225
220
  scope.post('/ex/some-ex-id/_recover')
226
- .query({ cleanup: RecoveryCleanupType.errors })
221
+ .query({ cleanup: Teraslice.RecoveryCleanupType.errors })
227
222
  .reply(200, {
228
223
  job_id: 'some-job-key',
229
224
  ex_id: 'some-ex-key'
@@ -232,7 +227,9 @@ describe('Teraslice Ex', () => {
232
227
 
233
228
  it('should resolve json results from Teraslice', async () => {
234
229
  const ex = new Ex({ baseUrl }, 'some-ex-id');
235
- const instance = await ex.recover({ cleanup: RecoveryCleanupType.errors });
230
+ const instance = await ex.recover({
231
+ cleanup: Teraslice.RecoveryCleanupType.errors
232
+ });
236
233
 
237
234
  expect(instance).toBeInstanceOf(Ex);
238
235
  expect(instance.id()).toEqual('some-ex-key');
@@ -253,7 +250,7 @@ describe('Teraslice Ex', () => {
253
250
  it('should resolve json results from Teraslice', async () => {
254
251
  const ex = new Ex({ baseUrl }, 'some-ex-id');
255
252
  const instance = await ex.recover({
256
- cleanup: RecoveryCleanupType.errors
253
+ cleanup: Teraslice.RecoveryCleanupType.errors
257
254
  }, requestOptions);
258
255
 
259
256
  expect(instance).toBeInstanceOf(Ex);
@@ -364,15 +361,14 @@ describe('Teraslice Ex', () => {
364
361
  });
365
362
 
366
363
  describe('->workers', () => {
367
- const workerData: WorkerJobProcesses[] = [];
364
+ const workerData: Teraslice.WorkerNode[] = [];
368
365
 
369
366
  const exId = 'some-ex-id';
370
367
  for (const [nodeName, node] of Object.entries(clusterState)) {
371
- node.active.forEach((child) => {
368
+ // @ts-expect-error TODO: fixme
369
+ node.active.forEach((child: any) => {
372
370
  if (child.assignment === 'worker' && child.ex_id === exId) {
373
- // @ts-expect-error
374
371
  child.node_id = nodeName;
375
- // @ts-expect-error
376
372
  workerData.push(child);
377
373
  }
378
374
  });
@@ -502,14 +498,14 @@ describe('Teraslice Ex', () => {
502
498
  .reply(200, {
503
499
  ex_id: 'example-ex-id',
504
500
  job_id: 'example-job-id',
505
- _status: ExecutionStatus.running
501
+ _status: Teraslice.ExecutionStatusEnum.running
506
502
  });
507
503
  });
508
504
 
509
505
  it('should resolve json results from Teraslice', async () => {
510
506
  const ex = new Ex({ baseUrl }, 'example-ex-id');
511
- const results = await ex.waitForStatus(ExecutionStatus.running);
512
- expect(results).toEqual(ExecutionStatus.running);
507
+ const results = await ex.waitForStatus(Teraslice.ExecutionStatusEnum.running);
508
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
513
509
  });
514
510
  });
515
511
 
@@ -522,19 +518,19 @@ describe('Teraslice Ex', () => {
522
518
  .reply(200, {
523
519
  ex_id: 'example-ex-id',
524
520
  job_id: 'example-job-id',
525
- _status: ExecutionStatus.running
521
+ _status: Teraslice.ExecutionStatusEnum.running
526
522
  });
527
523
  });
528
524
 
529
525
  it('should resolve json results from Teraslice', async () => {
530
526
  const ex = new Ex({ baseUrl }, 'example-ex-id');
531
527
  const results = await ex.waitForStatus(
532
- ExecutionStatus.running,
528
+ Teraslice.ExecutionStatusEnum.running,
533
529
  1000,
534
530
  0,
535
531
  searchOptions
536
532
  );
537
- expect(results).toEqual(ExecutionStatus.running);
533
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
538
534
  });
539
535
  });
540
536
 
@@ -543,20 +539,20 @@ describe('Teraslice Ex', () => {
543
539
  scope.get('/ex/other-ex-id')
544
540
  .reply(200, {
545
541
  ex_id: 'other-ex-id',
546
- _status: ExecutionStatus.running
542
+ _status: Teraslice.ExecutionStatusEnum.running
547
543
  });
548
544
 
549
545
  scope.get('/ex/other-ex-id')
550
546
  .reply(200, {
551
547
  ex_id: 'other-ex-id',
552
- _status: ExecutionStatus.completed
548
+ _status: Teraslice.ExecutionStatusEnum.completed
553
549
  });
554
550
  });
555
551
 
556
552
  it('should resolve json results from Teraslice', async () => {
557
553
  const ex = new Ex({ baseUrl }, 'other-ex-id');
558
- const results = await ex.waitForStatus(ExecutionStatus.completed);
559
- expect(results).toEqual(ExecutionStatus.completed);
554
+ const results = await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed);
555
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.completed);
560
556
  });
561
557
  });
562
558
 
@@ -566,7 +562,7 @@ describe('Teraslice Ex', () => {
566
562
  .times(12)
567
563
  .reply(200, {
568
564
  ex_id: 'foo-bar-ex-id',
569
- _status: ExecutionStatus.running
565
+ _status: Teraslice.ExecutionStatusEnum.running
570
566
  });
571
567
  });
572
568
 
@@ -574,7 +570,7 @@ describe('Teraslice Ex', () => {
574
570
  expect.hasAssertions();
575
571
  const ex = new Ex({ baseUrl }, 'foo-bar-ex-id');
576
572
  try {
577
- await ex.waitForStatus(ExecutionStatus.completed, 100, 1000);
573
+ await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
578
574
  } catch (err) {
579
575
  expect(err.message).toEqual('Execution status failed to change from status "running" to "completed" within 1000ms');
580
576
  }
@@ -587,20 +583,24 @@ describe('Teraslice Ex', () => {
587
583
  .delay(1100)
588
584
  .reply(200, {
589
585
  ex_id: 'example-ex-id',
590
- _status: ExecutionStatus.initializing
586
+ _status: Teraslice.ExecutionStatusEnum.initializing
591
587
  });
592
588
 
593
589
  scope.get('/ex/some-job-id')
594
590
  .reply(200, {
595
591
  ex_id: 'example-ex-id',
596
- _status: ExecutionStatus.running
592
+ _status: Teraslice.ExecutionStatusEnum.running
597
593
  });
598
594
  });
599
595
 
600
596
  it('should resolve with the correct status', async () => {
601
597
  const ex = new Ex({ baseUrl }, 'some-job-id');
602
- const status = await ex.waitForStatus(ExecutionStatus.running, 100, 1500);
603
- expect(status).toEqual(ExecutionStatus.running);
598
+ const status = await ex.waitForStatus(
599
+ Teraslice.ExecutionStatusEnum.running,
600
+ 100,
601
+ 1500
602
+ );
603
+ expect(status).toEqual(Teraslice.ExecutionStatusEnum.running);
604
604
  });
605
605
  });
606
606
 
@@ -609,7 +609,7 @@ describe('Teraslice Ex', () => {
609
609
  scope.get('/ex/example-ex-id')
610
610
  .reply(200, {
611
611
  ex_id: 'example-ex-id',
612
- _status: ExecutionStatus.failed
612
+ _status: Teraslice.ExecutionStatusEnum.failed
613
613
  });
614
614
  });
615
615
 
@@ -617,7 +617,7 @@ describe('Teraslice Ex', () => {
617
617
  expect.hasAssertions();
618
618
  const ex = new Ex({ baseUrl }, 'example-ex-id');
619
619
  try {
620
- await ex.waitForStatus(ExecutionStatus.completed, 100, 1000);
620
+ await ex.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
621
621
  } catch (err) {
622
622
  const errMsg = 'Execution cannot reach the target status, "completed", because it is in the terminal state, "failed"';
623
623
  expect(err.message).toEqual(errMsg);
package/test/job-spec.ts CHANGED
@@ -1,13 +1,6 @@
1
1
  import nock from 'nock';
2
- import { RecoveryCleanupType, newTestJobConfig } from '@terascope/job-components';
2
+ import { Teraslice } from '@terascope/types';
3
3
  import Job from '../src/job';
4
- import {
5
- ExecutionStatus,
6
- Execution,
7
- ClusterStateNative,
8
- WorkerJobProcesses,
9
- JobConfiguration
10
- } from '../src/interfaces';
11
4
 
12
5
  describe('Teraslice Job', () => {
13
6
  let scope: nock.Scope;
@@ -20,7 +13,7 @@ describe('Teraslice Job', () => {
20
13
 
21
14
  const requestOptions = { headers: { 'Some-Header': 'yes' } };
22
15
 
23
- const clusterState: ClusterStateNative = {
16
+ const clusterState: any = {
24
17
  'some-node-id': {
25
18
  hostname: 'host',
26
19
  pid: 111,
@@ -83,7 +76,7 @@ describe('Teraslice Job', () => {
83
76
  };
84
77
  const date = new Date().toISOString();
85
78
 
86
- const executionResults: Execution[] = [
79
+ const executionResults: Teraslice.ExecutionRecord[] = [
87
80
  {
88
81
  active: true,
89
82
  analytics: false,
@@ -103,11 +96,14 @@ describe('Teraslice Job', () => {
103
96
  _created: date,
104
97
  _updated: date,
105
98
  _context: 'ex',
106
- _status: ExecutionStatus.running,
99
+ _status: Teraslice.ExecutionStatusEnum.running,
107
100
  ex_id: '123456789',
108
101
  job_id: '123456789',
109
102
  slicer_hostname: 'hostname',
110
- slicer_port: 5673
103
+ slicer_port: 5673,
104
+ _has_errors: false,
105
+ _slicer_stats: {},
106
+ _failureReason: ''
111
107
  },
112
108
  ];
113
109
 
@@ -252,7 +248,7 @@ describe('Teraslice Job', () => {
252
248
  it('should resolve json results from Teraslice', async () => {
253
249
  const job = new Job({ baseUrl }, 'foo-bar');
254
250
  const results = await job.recover({
255
- cleanup: RecoveryCleanupType.errors
251
+ cleanup: Teraslice.RecoveryCleanupType.errors
256
252
  });
257
253
  expect(results).toEqual({ job_id: 'foo-bar' });
258
254
  });
@@ -271,7 +267,7 @@ describe('Teraslice Job', () => {
271
267
  it('should resolve json results from Teraslice', async () => {
272
268
  const job = new Job({ baseUrl }, 'some-job-id');
273
269
  const results = await job.recover({
274
- cleanup: RecoveryCleanupType.errors
270
+ cleanup: Teraslice.RecoveryCleanupType.errors
275
271
  }, requestOptions);
276
272
  expect(results).toEqual({
277
273
  key: 'some-other-key'
@@ -312,12 +308,25 @@ describe('Teraslice Job', () => {
312
308
 
313
309
  describe('->update', () => {
314
310
  describe('when updating the whole config', () => {
315
- const body = newTestJobConfig({
311
+ const body: Teraslice.JobRecord = {
316
312
  name: 'hello',
317
- }) as JobConfiguration;
318
- body.job_id = 'some-job-id';
319
- body._created = 'hello';
320
- body._updated = 'hello';
313
+ apis: [],
314
+ operations: [],
315
+ active: true,
316
+ analytics: false,
317
+ autorecover: false,
318
+ assets: [],
319
+ lifecycle: 'once',
320
+ max_retries: 0,
321
+ probation_window: 30000,
322
+ slicers: 1,
323
+ workers: 1,
324
+ env_vars: {},
325
+ _context: 'job',
326
+ job_id: 'some-job-id',
327
+ _created: 'hello',
328
+ _updated: 'hello',
329
+ };
321
330
 
322
331
  beforeEach(() => {
323
332
  scope.put('/jobs/some-job-id', body as any)
@@ -334,12 +343,26 @@ describe('Teraslice Job', () => {
334
343
 
335
344
  describe('->updatePartial', () => {
336
345
  describe('when updating a partial config', () => {
337
- const body = newTestJobConfig({
346
+ const body: Teraslice.JobRecord = {
338
347
  name: 'hello',
339
- }) as JobConfiguration;
340
- body.job_id = 'some-job-id';
341
- body._created = 'hello';
342
- body._updated = 'hello';
348
+ apis: [],
349
+ operations: [],
350
+ active: true,
351
+ analytics: false,
352
+ autorecover: false,
353
+ assets: [],
354
+ lifecycle: 'once',
355
+ max_retries: 0,
356
+ probation_window: 30000,
357
+ slicers: 1,
358
+ workers: 1,
359
+ env_vars: {},
360
+ _context: 'job',
361
+ job_id: 'some-job-id',
362
+ _created: 'hello',
363
+ _updated: 'hello',
364
+ };
365
+
343
366
  const expected = {
344
367
  ...body,
345
368
  name: 'howdy'
@@ -489,15 +512,14 @@ describe('Teraslice Job', () => {
489
512
  });
490
513
 
491
514
  describe('->workers', () => {
492
- const workerData: WorkerJobProcesses[] = [];
515
+ const workerData: Teraslice.WorkerNode[] = [];
493
516
 
494
517
  const jobId = 'some-job-id';
495
518
  for (const [nodeName, node] of Object.entries(clusterState)) {
519
+ // @ts-expect-error TODO: fixme
496
520
  node.active.forEach((child) => {
497
521
  if (child.assignment === 'worker' && child.job_id === jobId) {
498
- // @ts-expect-error
499
522
  child.node_id = nodeName;
500
- // @ts-expect-error
501
523
  workerData.push(child);
502
524
  }
503
525
  });
@@ -626,14 +648,14 @@ describe('Teraslice Job', () => {
626
648
  scope.get('/jobs/some-job-id/ex')
627
649
  .reply(200, {
628
650
  ex_id: 'example-ex-id',
629
- _status: ExecutionStatus.running
651
+ _status: Teraslice.ExecutionStatusEnum.running
630
652
  });
631
653
  });
632
654
 
633
655
  it('should resolve json results from Teraslice', async () => {
634
656
  const job = new Job({ baseUrl }, 'some-job-id');
635
- const results = await job.waitForStatus(ExecutionStatus.running);
636
- expect(results).toEqual(ExecutionStatus.running);
657
+ const results = await job.waitForStatus(Teraslice.ExecutionStatusEnum.running);
658
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
637
659
  });
638
660
  });
639
661
 
@@ -642,18 +664,18 @@ describe('Teraslice Job', () => {
642
664
  scope.get('/jobs/some-job-id/ex')
643
665
  .reply(200, {
644
666
  ex_id: 'example-ex-id',
645
- _status: ExecutionStatus.running
667
+ _status: Teraslice.ExecutionStatusEnum.running
646
668
  });
647
669
  });
648
670
 
649
671
  it('should resolve json results from Teraslice', async () => {
650
672
  const job = new Job({ baseUrl }, 'some-job-id');
651
673
  const results = await job.waitForStatus([
652
- ExecutionStatus.failing,
653
- ExecutionStatus.running
674
+ Teraslice.ExecutionStatusEnum.failing,
675
+ Teraslice.ExecutionStatusEnum.running
654
676
  ]);
655
677
 
656
- expect(results).toEqual(ExecutionStatus.running);
678
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
657
679
  });
658
680
  });
659
681
 
@@ -665,19 +687,19 @@ describe('Teraslice Job', () => {
665
687
  .matchHeader('Some-Header', 'yes')
666
688
  .reply(200, {
667
689
  ex_id: 'example-ex-id',
668
- _status: ExecutionStatus.running
690
+ _status: Teraslice.ExecutionStatusEnum.running
669
691
  });
670
692
  });
671
693
 
672
694
  it('should resolve json results from Teraslice', async () => {
673
695
  const job = new Job({ baseUrl }, 'some-job-id');
674
696
  const results = await job.waitForStatus(
675
- ExecutionStatus.running,
697
+ Teraslice.ExecutionStatusEnum.running,
676
698
  1000,
677
699
  0,
678
700
  searchOptions
679
701
  );
680
- expect(results).toEqual(ExecutionStatus.running);
702
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.running);
681
703
  });
682
704
  });
683
705
 
@@ -686,20 +708,20 @@ describe('Teraslice Job', () => {
686
708
  scope.get('/jobs/some-job-id/ex')
687
709
  .reply(200, {
688
710
  ex_id: 'example-ex-id',
689
- _status: ExecutionStatus.running
711
+ _status: Teraslice.ExecutionStatusEnum.running
690
712
  });
691
713
 
692
714
  scope.get('/jobs/some-job-id/ex')
693
715
  .reply(200, {
694
716
  ex_id: 'example-ex-id',
695
- _status: ExecutionStatus.completed
717
+ _status: Teraslice.ExecutionStatusEnum.completed
696
718
  });
697
719
  });
698
720
 
699
721
  it('should resolve json results from Teraslice', async () => {
700
722
  const job = new Job({ baseUrl }, 'some-job-id');
701
- const results = await job.waitForStatus(ExecutionStatus.completed);
702
- expect(results).toEqual(ExecutionStatus.completed);
723
+ const results = await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed);
724
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.completed);
703
725
  });
704
726
  });
705
727
 
@@ -708,25 +730,25 @@ describe('Teraslice Job', () => {
708
730
  scope.get('/jobs/some-job-id/ex')
709
731
  .reply(200, {
710
732
  ex_id: 'example-ex-id',
711
- _status: ExecutionStatus.running
733
+ _status: Teraslice.ExecutionStatusEnum.running
712
734
  });
713
735
 
714
736
  scope.get('/jobs/some-job-id/ex')
715
737
  .reply(200, {
716
738
  ex_id: 'example-ex-id',
717
- _status: ExecutionStatus.terminated
739
+ _status: Teraslice.ExecutionStatusEnum.terminated
718
740
  });
719
741
  });
720
742
 
721
743
  it('should resolve json results from Teraslice', async () => {
722
744
  const job = new Job({ baseUrl }, 'some-job-id');
723
745
  const results = await job.waitForStatus([
724
- ExecutionStatus.completed,
725
- ExecutionStatus.failed,
726
- ExecutionStatus.terminated
746
+ Teraslice.ExecutionStatusEnum.completed,
747
+ Teraslice.ExecutionStatusEnum.failed,
748
+ Teraslice.ExecutionStatusEnum.terminated
727
749
  ]);
728
750
 
729
- expect(results).toEqual(ExecutionStatus.terminated);
751
+ expect(results).toEqual(Teraslice.ExecutionStatusEnum.terminated);
730
752
  });
731
753
  });
732
754
 
@@ -736,14 +758,14 @@ describe('Teraslice Job', () => {
736
758
  .times(1)
737
759
  .reply(200, {
738
760
  ex_id: 'example-ex-id',
739
- _status: ExecutionStatus.initializing
761
+ _status: Teraslice.ExecutionStatusEnum.initializing
740
762
  });
741
763
 
742
764
  scope.get('/jobs/some-job-id/ex')
743
765
  .times(11)
744
766
  .reply(200, {
745
767
  ex_id: 'example-ex-id',
746
- _status: ExecutionStatus.running
768
+ _status: Teraslice.ExecutionStatusEnum.running
747
769
  });
748
770
  });
749
771
 
@@ -751,7 +773,7 @@ describe('Teraslice Job', () => {
751
773
  expect.hasAssertions();
752
774
  const job = new Job({ baseUrl }, 'some-job-id');
753
775
  try {
754
- await job.waitForStatus(ExecutionStatus.completed, 100, 1000);
776
+ await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
755
777
  } catch (err) {
756
778
  expect(err.message).toEqual('Job status failed to change from status "running" to "completed" within 1000ms');
757
779
  }
@@ -764,14 +786,14 @@ describe('Teraslice Job', () => {
764
786
  .times(1)
765
787
  .reply(200, {
766
788
  ex_id: 'example-ex-id',
767
- _status: ExecutionStatus.initializing
789
+ _status: Teraslice.ExecutionStatusEnum.initializing
768
790
  });
769
791
 
770
792
  scope.get('/jobs/some-job-id/ex')
771
793
  .times(11)
772
794
  .reply(200, {
773
795
  ex_id: 'example-ex-id',
774
- _status: ExecutionStatus.running
796
+ _status: Teraslice.ExecutionStatusEnum.running
775
797
  });
776
798
  });
777
799
 
@@ -780,9 +802,9 @@ describe('Teraslice Job', () => {
780
802
  const job = new Job({ baseUrl }, 'some-job-id');
781
803
  try {
782
804
  await job.waitForStatus([
783
- ExecutionStatus.completed,
784
- ExecutionStatus.failed,
785
- ExecutionStatus.stopped
805
+ Teraslice.ExecutionStatusEnum.completed,
806
+ Teraslice.ExecutionStatusEnum.failed,
807
+ Teraslice.ExecutionStatusEnum.stopped
786
808
  ], 100, 1000);
787
809
  } catch (err) {
788
810
  expect(err.message).toEqual('Job status failed to change from status "running" to "completed,failed,stopped" within 1000ms');
@@ -796,20 +818,24 @@ describe('Teraslice Job', () => {
796
818
  .delay(1100)
797
819
  .reply(200, {
798
820
  ex_id: 'example-ex-id',
799
- _status: ExecutionStatus.initializing
821
+ _status: Teraslice.ExecutionStatusEnum.initializing
800
822
  });
801
823
 
802
824
  scope.get('/jobs/some-job-id/ex')
803
825
  .reply(200, {
804
826
  ex_id: 'example-ex-id',
805
- _status: ExecutionStatus.running
827
+ _status: Teraslice.ExecutionStatusEnum.running
806
828
  });
807
829
  });
808
830
 
809
831
  it('should resolve with the correct status', async () => {
810
832
  const job = new Job({ baseUrl }, 'some-job-id');
811
- const status = await job.waitForStatus(ExecutionStatus.running, 100, 1500);
812
- expect(status).toEqual(ExecutionStatus.running);
833
+ const status = await job.waitForStatus(
834
+ Teraslice.ExecutionStatusEnum.running,
835
+ 100,
836
+ 1500
837
+ );
838
+ expect(status).toEqual(Teraslice.ExecutionStatusEnum.running);
813
839
  });
814
840
  });
815
841
 
@@ -818,7 +844,7 @@ describe('Teraslice Job', () => {
818
844
  scope.get('/jobs/other-job-id/ex')
819
845
  .reply(200, {
820
846
  ex_id: 'example-ex-id',
821
- _status: ExecutionStatus.failed
847
+ _status: Teraslice.ExecutionStatusEnum.failed
822
848
  });
823
849
  });
824
850
 
@@ -826,7 +852,7 @@ describe('Teraslice Job', () => {
826
852
  expect.hasAssertions();
827
853
  const job = new Job({ baseUrl }, 'other-job-id');
828
854
  try {
829
- await job.waitForStatus(ExecutionStatus.completed, 100, 1000);
855
+ await job.waitForStatus(Teraslice.ExecutionStatusEnum.completed, 100, 1000);
830
856
  } catch (err) {
831
857
  const errMsg = 'Job cannot reach the target status, "completed", because it is in the terminal state, "failed"';
832
858
  expect(err.message).toEqual(errMsg);
package/test/jobs-spec.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'jest-extended';
2
2
  import nock from 'nock';
3
+ import { Teraslice } from '@terascope/types';
3
4
  import Job from '../src/job';
4
5
  import Jobs from '../src/jobs';
5
- import { ExecutionStatus, JobConfiguration } from '../src/interfaces';
6
6
 
7
7
  describe('Teraslice Jobs', () => {
8
8
  let jobs: Jobs;
@@ -22,7 +22,7 @@ describe('Teraslice Jobs', () => {
22
22
 
23
23
  const date = new Date().toISOString();
24
24
 
25
- const list: JobConfiguration[] = [
25
+ const list: Teraslice.JobRecord[] = [
26
26
  {
27
27
  job_id: 'some-random-job-id',
28
28
  active: true,
@@ -183,19 +183,19 @@ describe('Teraslice Jobs', () => {
183
183
  describe('when called with a string', () => {
184
184
  beforeEach(() => {
185
185
  scope.get('/jobs')
186
- .query({ status: ExecutionStatus.running })
186
+ .query({ status: Teraslice.ExecutionStatusEnum.running })
187
187
  .reply(200, list);
188
188
  });
189
189
 
190
190
  it('should resolve json result from Teraslice', async () => {
191
- const results = await jobs.list(ExecutionStatus.running);
191
+ const results = await jobs.list(Teraslice.ExecutionStatusEnum.running);
192
192
  expect(results).toEqual(list);
193
193
  });
194
194
  });
195
195
 
196
196
  describe('when called with an object', () => {
197
197
  const searchOptions = { headers: { 'Some-Header': 'yes' } };
198
- const queryOptions = { status: ExecutionStatus.running, size: 10 };
198
+ const queryOptions = { status: Teraslice.ExecutionStatusEnum.running, size: 10 };
199
199
 
200
200
  beforeEach(() => {
201
201
  scope.get('/jobs')