@norskvideo/norsk-manager-sdk 1.0.356

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.
@@ -0,0 +1,629 @@
1
+ import { Version as CommonVersion } from "@norskvideo/norsk-api/lib/shared/common_pb";
2
+ /** @public */
3
+ export declare type JobId = string;
4
+ /** @public */
5
+ export declare type Role = string;
6
+ /** @public */
7
+ export declare type ContainerUrl = string;
8
+ /** @public */
9
+ export declare type DockerContainer = {
10
+ codeType: "docker";
11
+ url: ContainerUrl;
12
+ };
13
+ /** @public */
14
+ export declare type ClientCode = DockerContainer;
15
+ /** @public */
16
+ export declare type JobHistoryJobCreated = {
17
+ event: "created";
18
+ timestamp: Date;
19
+ };
20
+ /** @public */
21
+ export declare type JobHistoryJobUpdated = {
22
+ event: "updated";
23
+ timestamp: Date;
24
+ previousJob: Job;
25
+ };
26
+ /** @public */
27
+ export declare type JobHistoryJobProvisioned = {
28
+ event: "provisioned";
29
+ timestamp: Date;
30
+ role: Role;
31
+ nodeMetadata: NodeMetadata;
32
+ };
33
+ /** @public */
34
+ export declare type JobHistoryJobRunning = {
35
+ event: "running";
36
+ timestamp: Date;
37
+ role: Role;
38
+ nodeMetadata: NodeMetadata;
39
+ runningNodeMetadata: RunningNodeMetadata;
40
+ };
41
+ /** @public */
42
+ export declare type JobHistoryJobStopping = {
43
+ event: "stopping";
44
+ timestamp: Date;
45
+ role: Role;
46
+ nodeMetadata: NodeMetadata;
47
+ runningNodeMetadata?: RunningNodeMetadata;
48
+ reason: "nodeStopped" | "nodeTerminated" | "userRequested" | "unknownJob" | "jobFailed";
49
+ };
50
+ /** @public */
51
+ export declare type JobHistoryJobStopped = {
52
+ event: "stopped";
53
+ timestamp: Date;
54
+ role: Role;
55
+ nodeMetadata: NodeMetadata;
56
+ runningNodeMetadata?: RunningNodeMetadata;
57
+ };
58
+ /** @public */
59
+ export declare type JobHistoryJobCompleted = {
60
+ event: "completed";
61
+ timestamp: Date;
62
+ };
63
+ /** @public */
64
+ export declare type JobHistoryEntry = JobHistoryJobCreated | JobHistoryJobUpdated | JobHistoryJobProvisioned | JobHistoryJobRunning | JobHistoryJobStopping | JobHistoryJobStopped | JobHistoryJobCompleted;
65
+ /** @public */
66
+ export declare type JobState = "pre" | "active" | "post";
67
+ /** @public */
68
+ export declare type ServiceRestart = "never" | "onFailure" | "always";
69
+ /** @public */
70
+ export declare type RestartIntensity = {
71
+ count: number;
72
+ period: number;
73
+ };
74
+ /** @public */
75
+ export declare type EphemeralHostPort = {
76
+ type: "ephemeral";
77
+ };
78
+ /** @public */
79
+ export declare type RangeHostPort = {
80
+ type: "range";
81
+ minPort: number;
82
+ maxPort: number;
83
+ };
84
+ /** @public */
85
+ export declare type SpecificHostPort = {
86
+ type: "specific";
87
+ port: number;
88
+ };
89
+ /** @public */
90
+ export declare type HostPort = EphemeralHostPort | RangeHostPort | SpecificHostPort;
91
+ /** @public */
92
+ export declare type PortMapping = {
93
+ containerPort: number;
94
+ protocol?: "tcp" | "udp";
95
+ hostPort: HostPort;
96
+ hostAddress?: string;
97
+ };
98
+ /** @public */
99
+ export declare type EnvironmentVariable = {
100
+ name: string;
101
+ value: string;
102
+ };
103
+ /** @public */
104
+ export declare type VolumeMount = {
105
+ volumeName: string;
106
+ containerPath: string;
107
+ readOnly: boolean;
108
+ };
109
+ /** @public */
110
+ export declare type ServiceParameters = {
111
+ portMappings?: PortMapping[];
112
+ environmentVariables?: EnvironmentVariable[];
113
+ sharedMemorySize?: bigint;
114
+ cpuSet?: number[];
115
+ volumeMounts?: VolumeMount[];
116
+ };
117
+ /** @public */
118
+ export declare type Service = {
119
+ name: string;
120
+ container: ClientCode;
121
+ restart?: ServiceRestart;
122
+ dependsOn?: Set<string>;
123
+ configuration?: string;
124
+ restartIntensity?: RestartIntensity;
125
+ command?: string;
126
+ parameters?: ServiceParameters;
127
+ };
128
+ /** @public */
129
+ export declare type Job = {
130
+ jobId: JobId;
131
+ cloud: Cloud;
132
+ description: string;
133
+ tags: Map<string, string>;
134
+ startDateTime: Date;
135
+ currentHash: bigint;
136
+ services: Service[];
137
+ volumes?: string[];
138
+ managerConfiguration?: string;
139
+ norskMediaVersion: Version;
140
+ norskServiceParameters?: ServiceParameters;
141
+ state: JobState;
142
+ shape: string;
143
+ availabilityDomain: string;
144
+ subnet: string;
145
+ architecture: string;
146
+ };
147
+ /** @public */
148
+ export declare type CreateJob = Omit<Job, "state" | "currentHash">;
149
+ /** @public */
150
+ export declare type JobWithHistory = {
151
+ job: Job;
152
+ history: JobHistoryEntry[];
153
+ };
154
+ /** @public */
155
+ export declare type AwsNodeId = string;
156
+ /** @public */
157
+ export declare type PhysicalNodeId = string;
158
+ /** @public */
159
+ export declare type NodeId = string;
160
+ /** @public */
161
+ export declare type Version = "latest" | "recommended" | "previousRecommended" | "LTS";
162
+ /** @public */
163
+ export declare type Cloud = "aws" | "oci";
164
+ /** @public */
165
+ export declare type AwsInstanceId = string;
166
+ /** @public */
167
+ export declare type AwsInstanceType = string;
168
+ /** @public */
169
+ export declare type AwsRegion = string;
170
+ export declare type OciRegion = string;
171
+ /** @public */
172
+ export declare class AwsLaunchTemplateName {
173
+ name: string;
174
+ version?: string;
175
+ }
176
+ /** @public */
177
+ export declare class AwsLaunchTemplateId {
178
+ id: string;
179
+ version?: string;
180
+ }
181
+ /** @public */
182
+ export declare type DaemonVersion = string;
183
+ /** @public */
184
+ export declare type AwsNodeCreate = {
185
+ nodeId: NodeId;
186
+ tags: Map<string, string>;
187
+ region: AwsRegion;
188
+ instanceType: string;
189
+ template?: AwsLaunchTemplateName | AwsLaunchTemplateId;
190
+ workerImageVersion?: Version;
191
+ workerDaemonVersion?: Version;
192
+ };
193
+ /** @public */
194
+ export declare type OciNodeCreate = {
195
+ nodeId: NodeId;
196
+ tags: Map<string, string>;
197
+ availabilityDomain: OciRegion;
198
+ architecture: string;
199
+ shape: string;
200
+ subnet: string;
201
+ workerImageVersion?: Version;
202
+ workerDaemonVersion?: Version;
203
+ };
204
+ /** @public */
205
+ export declare type RunningAwsMetadata = {
206
+ provider: "aws";
207
+ instanceId: AwsInstanceId;
208
+ };
209
+ /** @public */
210
+ export declare type RunningOciMetadata = {
211
+ provider: "oci";
212
+ };
213
+ /** @public */
214
+ export declare type RunningNodeProviderMetadata = RunningAwsMetadata | RunningOciMetadata;
215
+ /** @public */
216
+ export declare type RunningNodeMetadata = {
217
+ publicDnsName?: string;
218
+ privateDnsName: string;
219
+ privateIpAddress: string;
220
+ providerMetadata: RunningNodeProviderMetadata;
221
+ };
222
+ /** @public */
223
+ export declare type AwsMetadata = {
224
+ provider: "aws";
225
+ instanceType: AwsInstanceType;
226
+ region: AwsRegion;
227
+ };
228
+ /** @public */
229
+ export declare type OciMetadata = {
230
+ provider: "oci";
231
+ };
232
+ /** @public */
233
+ export declare type ProviderMetadata = AwsMetadata | OciMetadata;
234
+ /** @public */
235
+ export declare type NodeMetadata = {
236
+ nodeId: NodeId;
237
+ tags: Map<string, string>;
238
+ createdAt?: Date;
239
+ providerMetadata: ProviderMetadata;
240
+ };
241
+ /** @public */
242
+ export declare type PhysicalNode = {
243
+ nodeType: "physical";
244
+ id: PhysicalNodeId;
245
+ tags: Map<string, string>;
246
+ ipAddress: string;
247
+ };
248
+ /** @public */
249
+ export declare type Log = {
250
+ level: "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
251
+ timestamp: Date;
252
+ message: string;
253
+ };
254
+ /**
255
+ * @public
256
+ * Top level Norsk configuration
257
+ */
258
+ export interface NorskSettings {
259
+ /**
260
+ * Callback URL to listen on for gRPC session with Norsk Media
261
+ *
262
+ */
263
+ url?: string;
264
+ onAttemptingToConnect?: () => void;
265
+ onConnecting?: () => void;
266
+ onReady?: () => void;
267
+ onFailedToConnect?: () => void;
268
+ onShutdown?: () => void;
269
+ onHello?: (version: CommonVersion) => void;
270
+ onLogEvent?: (log: Log) => void;
271
+ }
272
+ /** @public */
273
+ export declare type RunningJob = {
274
+ jobId: JobId;
275
+ role: Role;
276
+ nodeId: NodeId;
277
+ };
278
+ /**
279
+ * @public
280
+ * Job is almost ready to start - "almost" defined by property passed into
281
+ * the list functions - todo, sort out this description
282
+ * */
283
+ export declare type JobPending = {
284
+ event: "jobPending";
285
+ jobWithHistory: JobWithHistory;
286
+ };
287
+ /**
288
+ * @public
289
+ * Job details have been updated
290
+ * */
291
+ export declare type JobUpdated = {
292
+ event: "jobUpdated";
293
+ jobWithHistory: JobWithHistory;
294
+ };
295
+ /**
296
+ * @public
297
+ * A job has been updated such that it no longer matches the search criteria
298
+ * */
299
+ export declare type JobOutOfWindow = {
300
+ event: "jobOutOfWindow";
301
+ jobWithHistory: JobWithHistory;
302
+ };
303
+ /**
304
+ * @public
305
+ * A job has been deleted
306
+ * */
307
+ export declare type JobDeleted = {
308
+ event: "jobDeleted";
309
+ jobId: JobId;
310
+ };
311
+ /** @public */
312
+ declare type JobInfoServiceStarted = {
313
+ type: "serviceStarted";
314
+ serviceName: string;
315
+ };
316
+ /** @public */
317
+ declare type JobInfoServiceRestarting = {
318
+ type: "serviceRestarting";
319
+ serviceName: string;
320
+ };
321
+ /** @public */
322
+ declare type JobInfoContainerEvent = {
323
+ type: "containerEvent";
324
+ serviceName: string;
325
+ text: string;
326
+ };
327
+ /** @public */
328
+ declare type JobInfoComposeStage = "build" | "create" | "start" | "stop" | "down";
329
+ /** @public */
330
+ declare type JobInfoComponseMessage = {
331
+ type: "composeMessage";
332
+ stage: JobInfoComposeStage;
333
+ text: string;
334
+ };
335
+ /** @public */
336
+ declare type JobInfoMessage = JobInfoServiceStarted | JobInfoServiceRestarting | JobInfoContainerEvent | JobInfoComponseMessage;
337
+ /**
338
+ * @public
339
+ * Informational messages about a job
340
+ * */
341
+ export declare type JobInfo = {
342
+ event: "jobInfo";
343
+ jobId: JobId;
344
+ role: Role;
345
+ timestamp: Date;
346
+ message: JobInfoMessage;
347
+ };
348
+ /**
349
+ * @public
350
+ * A node is starting
351
+ * */
352
+ export declare type NodeStarting = {
353
+ event: "nodeStarting";
354
+ nodeMetadata: NodeMetadata;
355
+ };
356
+ /**
357
+ * @public
358
+ * A node has started
359
+ * */
360
+ export declare type NodeStarted = {
361
+ event: "nodeStarted";
362
+ nodeMetadata: NodeMetadata;
363
+ runningNodeMetadata: RunningNodeMetadata;
364
+ };
365
+ /**
366
+ * @public
367
+ * A node is stopping
368
+ * */
369
+ export declare type NodeStopping = {
370
+ event: "nodeStopping";
371
+ nodeId: NodeId;
372
+ reason: "createFailed" | "pendingTimeExceeded" | "startupTimeExceeded" | "initialisationHealthPingTimeExceeded" | "healthPingTimeExceeded" | "duplicateJob" | "providerStop" | "providerTerminate" | "userRequested" | "unknownNode";
373
+ };
374
+ /** @public
375
+ * A node has stopped
376
+ * */
377
+ export declare type NodeStopped = {
378
+ event: "nodeStopped";
379
+ nodeId: NodeId;
380
+ };
381
+ /**
382
+ * @public
383
+ * A node is running - used in initial state messages
384
+ * */
385
+ export declare type NodeRunning = {
386
+ event: "nodeRunning";
387
+ nodeMetadata: NodeMetadata;
388
+ runningNodeMetadata: RunningNodeMetadata;
389
+ instances: RunningJob[];
390
+ };
391
+ /**
392
+ * @public
393
+ * A physical node has connected
394
+ * */
395
+ export declare type PhysicalNodeConnected = {
396
+ event: "physicalNodeConnected";
397
+ node: PhysicalNode;
398
+ instances: RunningJob[];
399
+ };
400
+ /**
401
+ * @public
402
+ * The health status of a provider has changed
403
+ * */
404
+ export declare type ProviderHealthChange = {
405
+ event: "providerHealthChange";
406
+ health: ProviderHealth;
407
+ };
408
+ /**
409
+ * @public
410
+ * The manager activity stream has closed
411
+ * */
412
+ export declare type EventStreamClosed = {
413
+ event: "eventStreamClosed";
414
+ error?: Error;
415
+ };
416
+ /** @public */
417
+ export declare type TagComparison = {
418
+ comparison: "eq";
419
+ value: string;
420
+ } | {
421
+ comparison: "neq";
422
+ value: string;
423
+ } | {
424
+ comparison: "re";
425
+ value: string;
426
+ } | {
427
+ comparison: "exists";
428
+ value: boolean;
429
+ };
430
+ /** @public */
431
+ export declare type TagFilter = {
432
+ filterType: "tag";
433
+ tagName: string;
434
+ comparison: TagComparison;
435
+ };
436
+ /** @public */
437
+ export declare type IdComparison = {
438
+ comparison: "eq";
439
+ value: string;
440
+ } | {
441
+ comparison: "neq";
442
+ value: string;
443
+ } | {
444
+ comparison: "re";
445
+ value: string;
446
+ };
447
+ /** @public */
448
+ export declare type IdFilter = {
449
+ filterType: "id";
450
+ comparison: IdComparison;
451
+ };
452
+ /** @public */
453
+ export declare type DateComparison = {
454
+ comparison: "eq";
455
+ value: Date;
456
+ } | {
457
+ comparison: "lt";
458
+ value: Date;
459
+ } | {
460
+ comparison: "lte";
461
+ value: Date;
462
+ } | {
463
+ comparison: "gt";
464
+ value: Date;
465
+ } | {
466
+ comparison: "gte";
467
+ value: Date;
468
+ } | {
469
+ comparison: "between";
470
+ from: Date;
471
+ to: Date;
472
+ };
473
+ /** @public */
474
+ export declare type DateFilter = {
475
+ filterType: "date";
476
+ dateType: "start" | "end";
477
+ comparison: DateComparison;
478
+ };
479
+ /** @public */
480
+ export declare type JobFilter = TagFilter | IdFilter | DateFilter;
481
+ /**
482
+ * @public
483
+ * Configuration for creating an event stream
484
+ */
485
+ export declare type EventStreamSettings = {
486
+ pendingWindow: number;
487
+ onEvent: (event: EventStreamEvent) => void;
488
+ };
489
+ /**
490
+ * @public
491
+ */
492
+ export declare type EventStreamInitialState = {
493
+ nodesStarting: NodeStarting[];
494
+ nodesRunning: NodeRunning[];
495
+ activeJobs: JobWithHistory[];
496
+ health: ProviderHealth[];
497
+ closeStream: () => void;
498
+ };
499
+ /**
500
+ * @public
501
+ */
502
+ export declare type EventStreamEvent = JobUpdated | JobPending | JobOutOfWindow | JobDeleted | JobInfo | NodeStarting | NodeStarted | NodeStopping | NodeStopped | PhysicalNodeConnected | ProviderHealthChange | EventStreamClosed;
503
+ /**
504
+ * @public
505
+ */
506
+ export declare type JobSearchSettings = {
507
+ filter: JobFilter[];
508
+ };
509
+ /**
510
+ * @public
511
+ */
512
+ export declare type CurrentJob = {
513
+ job: Job;
514
+ instances: RunningJob[];
515
+ };
516
+ /**
517
+ * @public
518
+ * List of events that can be raised by the jobList API - TODO - link
519
+ */
520
+ export declare type JobListEvent = JobUpdated | JobPending;
521
+ /**
522
+ * @public
523
+ */
524
+ export declare type Health = "healthy" | "unstable" | "failed";
525
+ /**
526
+ * @public
527
+ */
528
+ export declare type AwsHealth = {
529
+ provider: "aws";
530
+ regions: Map<AwsRegion, Health>;
531
+ };
532
+ /**
533
+ * @public
534
+ */
535
+ export declare type OciHealth = {
536
+ provider: "oci";
537
+ };
538
+ /**
539
+ * @public
540
+ */
541
+ export declare type ProviderHealth = AwsHealth | OciHealth;
542
+ /**
543
+ * @public
544
+ * The entrypoint for all Norsk Manager applications
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * const norsk = await Norsk.connect({ url: "localhost:6790" });
549
+ * ```
550
+ */
551
+ export declare class NorskManager {
552
+ nextEventStreamId: number;
553
+ /** @public */
554
+ static connect(settings: NorskSettings): Promise<NorskManager>;
555
+ /**
556
+ * @public
557
+ * Norsk Runtime version information
558
+ */
559
+ version: CommonVersion;
560
+ /**
561
+ * @public
562
+ * Close down the Norsk connection
563
+ */
564
+ close(): void;
565
+ /**
566
+ * @public - TODO - this can fail (duplicate id etc)
567
+ */
568
+ createJob(job: CreateJob): Promise<Job>;
569
+ /**
570
+ * @public - TODO - this can fail (version check etc)
571
+ */
572
+ updateJob(job: Job): Promise<Job>;
573
+ /**
574
+ * @public - TODO - can it fail?
575
+ */
576
+ deleteJob(jobId: JobId): Promise<void>;
577
+ /**
578
+ * @public - TODO - can it fail?
579
+ */
580
+ completeJob(jobId: JobId): Promise<void>;
581
+ /**
582
+ * @public - TODO
583
+ */
584
+ createAwsNode(node: AwsNodeCreate): Promise<void>;
585
+ /**
586
+ * @public - TODO
587
+ */
588
+ createOciNode(node: OciNodeCreate): Promise<void>;
589
+ /**
590
+ * @public - TODO
591
+ */
592
+ updatePhysicalNode(nodeId: PhysicalNodeId, daemonVersion: string): Promise<void>;
593
+ /**
594
+ * @public - TODO
595
+ */
596
+ terminateNode(nodeId: NodeId): Promise<void>;
597
+ /**
598
+ * @public - TODO
599
+ */
600
+ startJob(jobId: JobId, role: Role, nodeId: NodeId): Promise<void>;
601
+ /**
602
+ * @public - TODO
603
+ */
604
+ stopJob(jobId: JobId, role: Role, nodeId: NodeId): Promise<void>;
605
+ /**
606
+ * @public - TODO - check name
607
+ * provides a stream of activity that is essential for the creation of client-side
608
+ * management logic.
609
+ */
610
+ eventStream(settings: EventStreamSettings): Promise<[EventStreamInitialState, () => void]>;
611
+ /**
612
+ * @public
613
+ * search for jobs by id
614
+ */
615
+ jobById(id: JobId): Promise<CurrentJob | undefined>;
616
+ /**
617
+ * @public
618
+ * search for jobs by tag / date etc
619
+ */
620
+ jobSearch(settings: JobSearchSettings): Promise<CurrentJob[]>;
621
+ }
622
+ interface EventStreamAsyncIterable {
623
+ [Symbol.asyncIterator](): AsyncIterator<EventStreamEvent, EventStreamEvent>;
624
+ }
625
+ export declare function eventStream(norsk: NorskManager, options: {
626
+ pendingWindow: number;
627
+ }): Promise<[EventStreamInitialState, EventStreamAsyncIterable]>;
628
+ export {};
629
+ //# sourceMappingURL=sdk.d.ts.map