UNPKG

2.82 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.isJobHandler = exports.JobState = exports.JobOutboundMessageKind = exports.JobInboundMessageKind = void 0;
11/**
12 * Messages that can be sent TO a job. The job needs to listen to those.
13 */
14var JobInboundMessageKind;
15(function (JobInboundMessageKind) {
16 JobInboundMessageKind["Ping"] = "ip";
17 JobInboundMessageKind["Stop"] = "is";
18 // Channel specific messages.
19 JobInboundMessageKind["Input"] = "in";
20 // Input channel does not allow completion / error. Erroring this will just close the Subject
21 // but not notify the job.
22})(JobInboundMessageKind = exports.JobInboundMessageKind || (exports.JobInboundMessageKind = {}));
23/**
24 * Kind of messages that can be outputted from a job.
25 */
26var JobOutboundMessageKind;
27(function (JobOutboundMessageKind) {
28 // Lifecycle specific messages.
29 JobOutboundMessageKind["OnReady"] = "c";
30 JobOutboundMessageKind["Start"] = "s";
31 JobOutboundMessageKind["End"] = "e";
32 JobOutboundMessageKind["Pong"] = "p";
33 // Feedback messages.
34 JobOutboundMessageKind["Output"] = "o";
35 // Channel specific messages.
36 JobOutboundMessageKind["ChannelCreate"] = "cn";
37 JobOutboundMessageKind["ChannelMessage"] = "cm";
38 JobOutboundMessageKind["ChannelError"] = "ce";
39 JobOutboundMessageKind["ChannelComplete"] = "cc";
40})(JobOutboundMessageKind = exports.JobOutboundMessageKind || (exports.JobOutboundMessageKind = {}));
41/**
42 * The state of a job. These are changed as the job reports a new state through its messages.
43 */
44var JobState;
45(function (JobState) {
46 /**
47 * The job was queued and is waiting to start.
48 */
49 JobState["Queued"] = "queued";
50 /**
51 * The job description was found, its dependencies (see "Synchronizing and Dependencies")
52 * are done running, and the job's argument is validated and the job's code will be executed.
53 */
54 JobState["Ready"] = "ready";
55 /**
56 * The job has been started. The job implementation is expected to send this as soon as its
57 * work is starting.
58 */
59 JobState["Started"] = "started";
60 /**
61 * The job has ended and is done running.
62 */
63 JobState["Ended"] = "ended";
64 /**
65 * An error occured and the job stopped because of internal state.
66 */
67 JobState["Errored"] = "errored";
68})(JobState = exports.JobState || (exports.JobState = {}));
69function isJobHandler(value) {
70 const job = value;
71 return (typeof job == 'function' && typeof job.jobDescription == 'object' && job.jobDescription !== null);
72}
73exports.isJobHandler = isJobHandler;