1 | import { Tunnel } from "../tunnel/tunnel";
|
2 | import { Nest } from "../nest/nest";
|
3 | import { Environment } from "../environment/environment";
|
4 | import { LifeEvent } from "../environment/lifeEvent";
|
5 | import { EmailOptions } from "../environment/emailOptions";
|
6 | export declare abstract class Job {
|
7 | protected name: string;
|
8 | protected tunnel: Tunnel;
|
9 | protected nest: Nest;
|
10 | protected e: Environment;
|
11 | protected locallyAvailable: boolean;
|
12 | protected lifeCycle: LifeEvent[];
|
13 | protected id: string;
|
14 | /**
|
15 | * Job constructor
|
16 | * @param e
|
17 | * @param name
|
18 | */
|
19 | constructor(e: Environment, name: string);
|
20 | /**
|
21 | * Class name for logging.
|
22 | * @returns {string}
|
23 | */
|
24 | toString(): string;
|
25 | /**
|
26 | * Check if job is locally available.
|
27 | * @returns {boolean}
|
28 | */
|
29 | isLocallyAvailable(): boolean;
|
30 | /**
|
31 | * Set if the job is locally available.
|
32 | * @param available
|
33 | */
|
34 | setLocallyAvailable(available: boolean): void;
|
35 | /**
|
36 | * Get the life cycle object.
|
37 | * @returns {LifeEvent[]}
|
38 | */
|
39 | getLifeCycle(): LifeEvent[];
|
40 | /**
|
41 | * Create a new life event.
|
42 | * @param verb
|
43 | * @param start
|
44 | * @param finish
|
45 | */
|
46 | protected createLifeEvent(verb: string, start: string, finish: string): void;
|
47 | /**
|
48 | * Set a new name.
|
49 | * @param name
|
50 | */
|
51 | setName(name: string): void;
|
52 | /**
|
53 | * Get the name.
|
54 | * @returns {string}
|
55 | */
|
56 | getName(): string;
|
57 | /**
|
58 | * Get the ID.
|
59 | * @returns {string}
|
60 | */
|
61 | getId(): string;
|
62 | /**
|
63 | * Get the name proper.
|
64 | * @returns {string}
|
65 | */
|
66 | getNameProper(): string;
|
67 | /**
|
68 | * Set the nest.
|
69 | * @param nest
|
70 | */
|
71 | setNest(nest: Nest): void;
|
72 | /**
|
73 | * Get the nest.
|
74 | * @returns {Nest}
|
75 | */
|
76 | getNest(): Nest;
|
77 | /**
|
78 | * Set the tunnel.
|
79 | * @param tunnel
|
80 | */
|
81 | setTunnel(tunnel: Tunnel): void;
|
82 | /**
|
83 | * Get the tunnel.
|
84 | * @returns {Tunnel}
|
85 | */
|
86 | getTunnel(): Tunnel;
|
87 | /**
|
88 | * Function to call to fail a job while in a tunnel.
|
89 | * @param reason
|
90 | */
|
91 | fail(reason: string): void;
|
92 | /**
|
93 | * Transfer a job to another tunnel directly.
|
94 | * @param tunnel
|
95 | */
|
96 | transfer(tunnel: Tunnel): void;
|
97 | /**
|
98 | * Move function error.
|
99 | */
|
100 | move(destinationNest: any, callback: any): void;
|
101 | /**
|
102 | * Sends an email.
|
103 | * @param emailOptions Email options
|
104 | * #### Sending pug template email example
|
105 | * ```js
|
106 | * // my_tunnel.js
|
107 | * tunnel.run(function (job, nest) {
|
108 | * job.email({
|
109 | * subject: "Test email from pug template",
|
110 | * to: "john.smith@example.com",
|
111 | * template: "./template_files/my_email.pug"
|
112 | * });
|
113 | * });
|
114 | * ```
|
115 | *
|
116 | * ```js
|
117 | * // template_files/my_email.pug
|
118 | * h1="Example email!"
|
119 | * p="Got job ID " + job.getId()
|
120 | * ```
|
121 | * #### Sending plain-text email
|
122 | * ```js
|
123 | * tunnel.run(function (job, nest) {
|
124 | * job.email({
|
125 | * subject: "Test email with hard-coded plain-text",
|
126 | * to: "john.smith@example.com",
|
127 | * text: "My email body!"
|
128 | * });
|
129 | * });
|
130 | * ```
|
131 | * #### Sending html email
|
132 | * ```js
|
133 | * tunnel.run(function (job, nest) {
|
134 | * job.email({
|
135 | * subject: "Test email with hard-coded html",
|
136 | * to: "john.smith@example.com",
|
137 | * html: "<h1>My email body!</h1>"
|
138 | * });
|
139 | * });
|
140 | * ```
|
141 | */
|
142 | email(emailOptions: EmailOptions): void;
|
143 | }
|