@norskvideo/norsk-manager-sdk 1.0.367 → 1.0.370

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/lib/src/sdk.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Version as CommonVersion } from "@norskvideo/norsk-api/lib/shared/common_pb";
2
1
  /** @public */
3
2
  export declare type JobId = string;
4
3
  /** @public */
@@ -12,6 +11,22 @@ export declare type DockerContainer = {
12
11
  };
13
12
  /** @public */
14
13
  export declare type ClientCode = DockerContainer;
14
+ /**
15
+ * @public
16
+ * Norsk Manager Version information
17
+ */
18
+ export interface VersionInfo {
19
+ /** Major version */
20
+ majorVersion: number;
21
+ /** Minor version */
22
+ minorVersion: number;
23
+ /** Build number for this version */
24
+ buildNumber: number;
25
+ /** Git branch at time of build */
26
+ branchName: string;
27
+ /** Unique identifier for this build */
28
+ label: string;
29
+ }
15
30
  /** @public */
16
31
  export declare type JobHistoryJobCreated = {
17
32
  event: "created";
@@ -128,33 +143,51 @@ export declare type Service = {
128
143
  parameters?: ServiceParameters;
129
144
  };
130
145
  /** @public */
131
- export declare type Job = {
146
+ export interface Job {
132
147
  jobId: JobId;
133
148
  cloud: Cloud;
134
149
  description: string;
150
+ /**
151
+ * Tags to associate with the job
152
+ */
135
153
  tags: {
136
154
  [key: string]: string;
137
155
  };
156
+ /**
157
+ * Date and time for when the job should be started
158
+ */
138
159
  startDateTime: Date;
139
160
  currentHash: bigint;
161
+ /**
162
+ * Additional services to be run as part of the job
163
+ */
140
164
  services: Service[];
141
165
  volumes?: string[];
166
+ /**
167
+ * JSON configuration to be passed to the manager and stored with the job
168
+ */
142
169
  managerConfiguration?: string;
143
- norskMediaVersion: Version;
170
+ norskMediaVersion: NorskVersion;
171
+ /**
172
+ * Service parameters to be passed to the Norsk Media container when it is started
173
+ */
144
174
  norskServiceParameters?: ServiceParameters;
145
175
  state: JobState;
146
176
  shape: string;
147
177
  availabilityDomain: string;
148
178
  subnet: string;
149
179
  architecture: string;
150
- };
180
+ }
151
181
  /** @public */
152
182
  export declare type CreateJob = Omit<Job, "state" | "currentHash">;
153
183
  /** @public */
154
- export declare type JobWithHistory = {
184
+ export interface JobWithHistory {
155
185
  job: Job;
186
+ /**
187
+ * All the events related to this job
188
+ * */
156
189
  history: JobHistoryEntry[];
157
- };
190
+ }
158
191
  /** @public */
159
192
  export declare type AwsNodeId = string;
160
193
  /** @public */
@@ -162,7 +195,7 @@ export declare type PhysicalNodeId = string;
162
195
  /** @public */
163
196
  export declare type NodeId = string;
164
197
  /** @public */
165
- export declare type Version = "latest" | "recommended" | "previousRecommended" | "LTS";
198
+ export declare type NorskVersion = "latest" | "recommended" | "previousRecommended" | "LTS";
166
199
  /** @public */
167
200
  export declare type Cloud = "aws" | "oci";
168
201
  /** @public */
@@ -171,34 +204,44 @@ export declare type AwsInstanceId = string;
171
204
  export declare type AwsInstanceType = string;
172
205
  /** @public */
173
206
  export declare type AwsRegion = string;
207
+ /** @public */
174
208
  export declare type OciRegion = string;
175
209
  /** @public */
176
- export declare class AwsLaunchTemplateName {
210
+ export interface AwsLaunchTemplateName {
177
211
  name: string;
178
212
  version?: string;
179
213
  }
180
214
  /** @public */
181
- export declare class AwsLaunchTemplateId {
215
+ export interface AwsLaunchTemplateId {
182
216
  id: string;
183
217
  version?: string;
184
218
  }
185
219
  /** @public */
186
220
  export declare type DaemonVersion = string;
187
221
  /** @public */
188
- export declare type AwsNodeCreate = {
222
+ export interface AwsNodeCreate {
189
223
  nodeId: NodeId;
224
+ /**
225
+ * Tags to associate with the node
226
+ */
190
227
  tags: {
191
228
  [key: string]: string;
192
229
  };
193
230
  region: AwsRegion;
194
231
  instanceType: string;
232
+ /**
233
+ * Launch template to use for the node
234
+ */
195
235
  template?: AwsLaunchTemplateName | AwsLaunchTemplateId;
196
- workerImageVersion?: Version;
197
- workerDaemonVersion?: Version;
198
- };
236
+ workerImageVersion?: NorskVersion;
237
+ workerDaemonVersion?: NorskVersion;
238
+ }
199
239
  /** @public */
200
- export declare type OciNodeCreate = {
240
+ export interface OciNodeCreate {
201
241
  nodeId: NodeId;
242
+ /**
243
+ * Tags to associate with the node
244
+ */
202
245
  tags: {
203
246
  [key: string]: string;
204
247
  };
@@ -206,9 +249,9 @@ export declare type OciNodeCreate = {
206
249
  architecture: string;
207
250
  shape: string;
208
251
  subnet: string;
209
- workerImageVersion?: Version;
210
- workerDaemonVersion?: Version;
211
- };
252
+ workerImageVersion?: NorskVersion;
253
+ workerDaemonVersion?: NorskVersion;
254
+ }
212
255
  /** @public */
213
256
  export declare type RunningAwsMetadata = {
214
257
  provider: "aws";
@@ -270,16 +313,39 @@ export declare type Log = {
270
313
  */
271
314
  export interface NorskSettings {
272
315
  /**
273
- * Callback URL to listen on for gRPC session with Norsk Media
316
+ * Callback URL to listen on for gRPC session with Norsk Manager
274
317
  *
275
318
  */
276
319
  url?: string;
320
+ /**
321
+ * Called when attempting a connection to the Norsk Manager
322
+ */
277
323
  onAttemptingToConnect?: () => void;
324
+ /**
325
+ * Called when a connection to the Norsk Manager is being established
326
+ */
278
327
  onConnecting?: () => void;
328
+ /**
329
+ * Called when a connection to the Norsk Manager is ready
330
+ */
279
331
  onReady?: () => void;
332
+ /**
333
+ * Called when a connection to the Norsk Manager has failed
334
+ */
280
335
  onFailedToConnect?: () => void;
336
+ /**
337
+ * Called when Norsk Manager is shutting down the connection
338
+ */
281
339
  onShutdown?: () => void;
282
- onHello?: (version: CommonVersion) => void;
340
+ /**
341
+ * Called when receiving the version information from the Norsk Manager
342
+ * @param version - Version information
343
+ * */
344
+ onHello?: (version: VersionInfo) => void;
345
+ /**
346
+ * Called whenever a log event is received from the Norsk Manager
347
+ * @param log - Log event
348
+ * */
283
349
  onLogEvent?: (log: Log) => void;
284
350
  }
285
351
  /** @public */
@@ -293,34 +359,34 @@ export declare type RunningJob = {
293
359
  * Job is almost ready to start - "almost" defined by property passed into
294
360
  * the list functions - todo, sort out this description
295
361
  * */
296
- export declare type JobPending = {
362
+ export interface JobPending {
297
363
  event: "jobPending";
298
364
  jobWithHistory: JobWithHistory;
299
- };
365
+ }
300
366
  /**
301
367
  * @public
302
368
  * Job details have been updated
303
369
  * */
304
- export declare type JobUpdated = {
370
+ export interface JobUpdated {
305
371
  event: "jobUpdated";
306
372
  jobWithHistory: JobWithHistory;
307
- };
373
+ }
308
374
  /**
309
375
  * @public
310
376
  * A job has been updated such that it no longer matches the search criteria
311
377
  * */
312
- export declare type JobOutOfWindow = {
378
+ export interface JobOutOfWindow {
313
379
  event: "jobOutOfWindow";
314
380
  jobWithHistory: JobWithHistory;
315
- };
381
+ }
316
382
  /**
317
383
  * @public
318
384
  * A job has been deleted
319
385
  * */
320
- export declare type JobDeleted = {
386
+ export interface JobDeleted {
321
387
  event: "jobDeleted";
322
388
  jobId: JobId;
323
- };
389
+ }
324
390
  /** @public */
325
391
  declare type JobInfoServiceStarted = {
326
392
  type: "serviceStarted";
@@ -351,21 +417,21 @@ declare type JobInfoMessage = JobInfoServiceStarted | JobInfoServiceRestarting |
351
417
  * @public
352
418
  * Informational messages about a job
353
419
  * */
354
- export declare type JobInfo = {
420
+ export interface JobInfo {
355
421
  event: "jobInfo";
356
422
  jobId: JobId;
357
423
  role: Role;
358
424
  timestamp: Date;
359
425
  message: JobInfoMessage;
360
- };
426
+ }
361
427
  /**
362
428
  * @public
363
429
  * A node is starting
364
430
  * */
365
- export declare type NodeStarting = {
431
+ export interface NodeStarting {
366
432
  event: "nodeStarting";
367
433
  nodeMetadata: NodeMetadata;
368
- };
434
+ }
369
435
  /**
370
436
  * @public
371
437
  * A node has started
@@ -379,53 +445,54 @@ export declare type NodeStarted = {
379
445
  * @public
380
446
  * A node is stopping
381
447
  * */
382
- export declare type NodeStopping = {
448
+ export interface NodeStopping {
383
449
  event: "nodeStopping";
384
450
  nodeId: NodeId;
385
451
  reason: "createFailed" | "pendingTimeExceeded" | "startupTimeExceeded" | "initialisationHealthPingTimeExceeded" | "healthPingTimeExceeded" | "duplicateJob" | "providerStop" | "providerTerminate" | "userRequested" | "unknownNode";
386
- };
387
- /** @public
452
+ }
453
+ /**
454
+ * @public
388
455
  * A node has stopped
389
456
  * */
390
- export declare type NodeStopped = {
457
+ export interface NodeStopped {
391
458
  event: "nodeStopped";
392
459
  nodeId: NodeId;
393
- };
460
+ }
394
461
  /**
395
462
  * @public
396
463
  * A node is running - used in initial state messages
397
464
  * */
398
- export declare type NodeRunning = {
465
+ export interface NodeRunning {
399
466
  event: "nodeRunning";
400
467
  nodeMetadata: NodeMetadata;
401
468
  runningNodeMetadata: RunningNodeMetadata;
402
469
  instances: RunningJob[];
403
- };
470
+ }
404
471
  /**
405
472
  * @public
406
473
  * A physical node has connected
407
474
  * */
408
- export declare type PhysicalNodeConnected = {
475
+ export interface PhysicalNodeConnected {
409
476
  event: "physicalNodeConnected";
410
477
  node: PhysicalNode;
411
478
  instances: RunningJob[];
412
- };
479
+ }
413
480
  /**
414
481
  * @public
415
482
  * The health status of a provider has changed
416
483
  * */
417
- export declare type ProviderHealthChange = {
484
+ export interface ProviderHealthChange {
418
485
  event: "providerHealthChange";
419
486
  health: ProviderHealth;
420
- };
487
+ }
421
488
  /**
422
489
  * @public
423
490
  * The manager activity stream has closed
424
491
  * */
425
- export declare type EventStreamClosed = {
492
+ export interface EventStreamClosed {
426
493
  event: "eventStreamClosed";
427
494
  error?: Error;
428
- };
495
+ }
429
496
  /** @public */
430
497
  export declare type TagComparison = {
431
498
  comparison: "eq";
@@ -441,11 +508,11 @@ export declare type TagComparison = {
441
508
  value: boolean;
442
509
  };
443
510
  /** @public */
444
- export declare type TagFilter = {
511
+ export interface TagFilter {
445
512
  filterType: "tag";
446
513
  tagName: string;
447
514
  comparison: TagComparison;
448
- };
515
+ }
449
516
  /** @public */
450
517
  export declare type IdComparison = {
451
518
  comparison: "eq";
@@ -458,10 +525,10 @@ export declare type IdComparison = {
458
525
  value: string;
459
526
  };
460
527
  /** @public */
461
- export declare type IdFilter = {
528
+ export interface IdFilter {
462
529
  filterType: "id";
463
530
  comparison: IdComparison;
464
- };
531
+ }
465
532
  /** @public */
466
533
  export declare type DateComparison = {
467
534
  comparison: "eq";
@@ -484,31 +551,40 @@ export declare type DateComparison = {
484
551
  to: Date;
485
552
  };
486
553
  /** @public */
487
- export declare type DateFilter = {
554
+ export interface DateFilter {
488
555
  filterType: "date";
489
556
  dateType: "start" | "end";
490
557
  comparison: DateComparison;
491
- };
558
+ }
492
559
  /** @public */
493
560
  export declare type JobFilter = TagFilter | IdFilter | DateFilter;
494
561
  /**
495
562
  * @public
496
563
  * Configuration for creating an event stream
497
564
  */
498
- export declare type EventStreamSettings = {
565
+ export interface EventStreamSettings {
566
+ /**
567
+ * The number of seconds in the future to consider jobs as pending.
568
+ * Jobs that are further in the future will not surface in the event stream,
569
+ * and instead be only reachable through the search API.
570
+ */
499
571
  pendingWindow: number;
572
+ /**
573
+ * Callback for handling events from the event stream
574
+ * @param event - Event from the Manager
575
+ */
500
576
  onEvent: (event: EventStreamEvent) => void;
501
- };
577
+ }
502
578
  /**
503
579
  * @public
504
580
  */
505
- export declare type EventStreamInitialState = {
581
+ export interface EventStreamInitialState {
506
582
  nodesStarting: NodeStarting[];
507
583
  nodesRunning: NodeRunning[];
508
584
  activeJobs: JobWithHistory[];
509
585
  health: ProviderHealth[];
510
586
  closeStream: () => void;
511
- };
587
+ }
512
588
  /**
513
589
  * @public
514
590
  */
@@ -516,16 +592,16 @@ export declare type EventStreamEvent = JobUpdated | JobPending | JobOutOfWindow
516
592
  /**
517
593
  * @public
518
594
  */
519
- export declare type JobSearchSettings = {
595
+ export interface JobSearchSettings {
520
596
  filter: JobFilter[];
521
- };
597
+ }
522
598
  /**
523
599
  * @public
524
600
  */
525
- export declare type CurrentJob = {
601
+ export interface CurrentJob {
526
602
  job: Job;
527
603
  instances: RunningJob[];
528
- };
604
+ }
529
605
  /**
530
606
  * @public
531
607
  * List of events that can be raised by the jobList API - TODO - link
@@ -538,18 +614,18 @@ export declare type Health = "healthy" | "unstable" | "failed";
538
614
  /**
539
615
  * @public
540
616
  */
541
- export declare type AwsHealth = {
617
+ export interface AwsHealth {
542
618
  provider: "aws";
543
619
  regions: {
544
620
  [key: AwsRegion]: Health;
545
621
  };
546
- };
622
+ }
547
623
  /**
548
624
  * @public
549
625
  */
550
- export declare type OciHealth = {
626
+ export interface OciHealth {
551
627
  provider: "oci";
552
- };
628
+ }
553
629
  /**
554
630
  * @public
555
631
  */
@@ -560,83 +636,100 @@ export declare type ProviderHealth = AwsHealth | OciHealth;
560
636
  *
561
637
  * @example
562
638
  * ```ts
563
- * const norsk = await Norsk.connect({ url: "localhost:6790" });
639
+ * const norsk = await NorskManager.connect({ url: "localhost:6790" });
564
640
  * ```
565
641
  */
566
642
  export declare class NorskManager {
567
- nextEventStreamId: number;
568
- /** @public */
643
+ /** @public
644
+ * Connect to the Norsk Manager
645
+ */
569
646
  static connect(settings: NorskSettings): Promise<NorskManager>;
570
647
  /**
571
648
  * @public
572
649
  * Norsk Runtime version information
573
650
  */
574
- version: CommonVersion;
651
+ version: VersionInfo;
575
652
  /**
576
653
  * @public
577
654
  * Close down the Norsk connection
578
655
  */
579
656
  close(): void;
580
657
  /**
581
- * @public - TODO - this can fail (duplicate id etc)
658
+ * @public
659
+ * Create a new job
582
660
  */
583
661
  createJob(job: CreateJob): Promise<Job>;
584
662
  /**
585
- * @public - TODO - this can fail (version check etc)
663
+ * @public
664
+ * Update a job
586
665
  */
587
666
  updateJob(job: Job): Promise<Job>;
588
667
  /**
589
- * @public - TODO - can it fail?
668
+ * @public
669
+ * Deletes a job
590
670
  */
591
671
  deleteJob(jobId: JobId): Promise<void>;
592
672
  /**
593
- * @public - TODO - can it fail?
673
+ * @public
674
+ * Stops a running job
594
675
  */
595
676
  completeJob(jobId: JobId): Promise<void>;
596
677
  /**
597
- * @public - TODO
678
+ * @public
679
+ * Spawn a new EC2 instance running the worker image, and make it available for picking up jobs
598
680
  */
599
681
  createAwsNode(node: AwsNodeCreate): Promise<void>;
600
682
  /**
601
- * @public - TODO
683
+ * @public
684
+ * Spawn a new OCI instance running the worker image, and make it available for picking up jobs
602
685
  */
603
686
  createOciNode(node: OciNodeCreate): Promise<void>;
604
687
  /**
605
- * @public - TODO
688
+ * @private
606
689
  */
607
- updatePhysicalNode(nodeId: PhysicalNodeId, daemonVersion: string): Promise<void>;
690
+ private updatePhysicalNode;
608
691
  /**
609
- * @public - TODO
692
+ * @public
693
+ * Forcibly stop a node
610
694
  */
611
695
  terminateNode(nodeId: NodeId): Promise<void>;
612
696
  /**
613
- * @public - TODO
697
+ * @public
698
+ * Start a job on a node
699
+ * @param jobId - The job to start
700
+ * @param role - The role for this node, such as e.g. "primary" or "backup"
701
+ * @param nodeId - The node to start the job on
614
702
  */
615
703
  startJob(jobId: JobId, role: Role, nodeId: NodeId): Promise<void>;
616
704
  /**
617
- * @public - TODO
618
- */
705
+ * @public
706
+ * Stop a job running on a node
707
+ * @param jobId - The job to stop
708
+ * @param role - The role for this node, such as e.g. "primary" or "backup"
709
+ * @param nodeId - The node to stop the job on
710
+ */
619
711
  stopJob(jobId: JobId, role: Role, nodeId: NodeId): Promise<void>;
620
712
  /**
621
- * @public - TODO - check name
622
- * provides a stream of activity that is essential for the creation of client-side
623
- * management logic.
713
+ * @public
714
+ * Provides a stream of the activity that is happening on the server-side.
715
+ * Reacting to these events is essential for the creation of client-side management logic.
624
716
  */
625
717
  eventStream(settings: EventStreamSettings): Promise<[EventStreamInitialState, () => void]>;
626
718
  /**
627
719
  * @public
628
- * search for jobs by id
720
+ * Search for jobs by id
629
721
  */
630
722
  jobById(id: JobId): Promise<CurrentJob | undefined>;
631
723
  /**
632
724
  * @public
633
- * search for jobs by tag / date etc
725
+ * Search for jobs by tag/date/etc. See {@link JobSearchSettings}
634
726
  */
635
727
  jobSearch(settings: JobSearchSettings): Promise<CurrentJob[]>;
636
728
  }
637
729
  interface EventStreamAsyncIterable {
638
730
  [Symbol.asyncIterator](): AsyncIterator<EventStreamEvent, EventStreamEvent>;
639
731
  }
732
+ /** @public */
640
733
  export declare function eventStream(norsk: NorskManager, options: {
641
734
  pendingWindow: number;
642
735
  }): Promise<[EventStreamInitialState, EventStreamAsyncIterable]>;