@angular-devkit/core 12.0.0-rc.0 → 12.0.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.
- package/README.md +36 -34
- package/node/_golden-api.d.ts +1 -1
- package/node/_golden-api.js +1 -1
- package/node/cli-logger.d.ts +7 -0
- package/node/cli-logger.js +4 -6
- package/node/experimental/index.d.ts +2 -2
- package/node/experimental/index.js +3 -3
- package/node/experimental/jobs/index.d.ts +1 -1
- package/node/experimental/jobs/index.js +7 -7
- package/node/experimental/jobs/job-registry.d.ts +1 -1
- package/node/experimental/jobs/job-registry.js +4 -4
- package/node/fs.d.ts +7 -0
- package/node/fs.js +3 -3
- package/node/host.d.ts +2 -2
- package/node/host.js +31 -33
- package/node/index.d.ts +2 -2
- package/node/index.js +1 -1
- package/node/testing/index.d.ts +2 -2
- package/node/testing/index.js +8 -5
- package/package.json +3 -3
- package/src/_golden-api.d.ts +1 -1
- package/src/_golden-api.js +1 -1
- package/src/analytics/api.d.ts +1 -1
- package/src/analytics/api.js +7 -0
- package/src/analytics/forwarder.d.ts +1 -1
- package/src/analytics/forwarder.js +7 -0
- package/src/analytics/index.d.ts +1 -1
- package/src/analytics/index.js +7 -7
- package/src/analytics/logging.d.ts +1 -1
- package/src/analytics/logging.js +7 -0
- package/src/analytics/multi.d.ts +1 -1
- package/src/analytics/multi.js +6 -6
- package/src/analytics/noop.d.ts +1 -1
- package/src/analytics/noop.js +10 -1
- package/src/exception/exception.d.ts +1 -1
- package/src/exception/exception.js +25 -9
- package/src/exception/index.d.ts +1 -1
- package/src/exception/index.js +1 -1
- package/src/experimental/jobs/README.md +133 -112
- package/src/experimental/jobs/api.d.ts +1 -1
- package/src/experimental/jobs/api.js +8 -3
- package/src/experimental/jobs/architecture.md +43 -38
- package/src/experimental/jobs/create-job-handler.d.ts +1 -2
- package/src/experimental/jobs/create-job-handler.js +17 -14
- package/src/experimental/jobs/dispatcher.d.ts +1 -2
- package/src/experimental/jobs/dispatcher.js +7 -0
- package/src/experimental/jobs/exception.d.ts +1 -1
- package/src/experimental/jobs/exception.js +3 -3
- package/src/experimental/jobs/fallback-registry.d.ts +1 -1
- package/src/experimental/jobs/fallback-registry.js +4 -4
- package/src/experimental/jobs/index.d.ts +1 -1
- package/src/experimental/jobs/index.js +7 -7
- package/src/experimental/jobs/simple-registry.d.ts +1 -1
- package/src/experimental/jobs/simple-registry.js +6 -4
- package/src/experimental/jobs/simple-scheduler.d.ts +1 -1
- package/src/experimental/jobs/simple-scheduler.js +38 -29
- package/src/experimental/jobs/strategy.d.ts +7 -0
- package/src/experimental/jobs/strategy.js +10 -9
- package/src/experimental.d.ts +2 -2
- package/src/experimental.js +3 -3
- package/src/index.d.ts +2 -2
- package/src/index.js +7 -7
- package/src/json/index.d.ts +2 -2
- package/src/json/index.js +9 -9
- package/src/json/interface.d.ts +1 -1
- package/src/json/interface.js +7 -0
- package/src/json/parser.d.ts +1 -1
- package/src/json/parser.js +39 -22
- package/src/json/schema/index.d.ts +2 -2
- package/src/json/schema/index.js +9 -9
- package/src/json/schema/interface.d.ts +1 -1
- package/src/json/schema/interface.js +7 -0
- package/src/json/schema/pointer.d.ts +1 -1
- package/src/json/schema/pointer.js +17 -5
- package/src/json/schema/registry.d.ts +1 -1
- package/src/json/schema/registry.js +28 -47
- package/src/json/schema/schema.d.ts +1 -1
- package/src/json/schema/schema.js +3 -3
- package/src/json/schema/transforms.d.ts +1 -1
- package/src/json/schema/transforms.js +14 -13
- package/src/json/schema/utility.d.ts +7 -0
- package/src/json/schema/utility.js +7 -7
- package/src/json/schema/visitor.d.ts +1 -1
- package/src/json/schema/visitor.js +8 -7
- package/src/logger/indent.d.ts +7 -0
- package/src/logger/indent.js +5 -5
- package/src/logger/index.d.ts +1 -1
- package/src/logger/index.js +7 -7
- package/src/logger/level.d.ts +1 -1
- package/src/logger/level.js +7 -0
- package/src/logger/logger.d.ts +1 -1
- package/src/logger/logger.js +13 -6
- package/src/logger/null-logger.d.ts +7 -0
- package/src/logger/null-logger.js +3 -3
- package/src/logger/transform-logger.d.ts +1 -1
- package/src/logger/transform-logger.js +7 -0
- package/src/utils/array.d.ts +1 -1
- package/src/utils/array.js +2 -2
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.js +7 -7
- package/src/utils/lang.d.ts +1 -1
- package/src/utils/lang.js +3 -3
- package/src/utils/literals.d.ts +1 -1
- package/src/utils/literals.js +15 -8
- package/src/utils/object.d.ts +1 -1
- package/src/utils/object.js +3 -3
- package/src/utils/partially-ordered-set.d.ts +2 -2
- package/src/utils/partially-ordered-set.js +12 -8
- package/src/utils/priority-queue.d.ts +1 -1
- package/src/utils/priority-queue.js +2 -2
- package/src/utils/strings.d.ts +7 -0
- package/src/utils/strings.js +12 -9
- package/src/utils/template.d.ts +1 -1
- package/src/utils/template.js +24 -30
- package/src/virtual-fs/host/alias.d.ts +1 -1
- package/src/virtual-fs/host/alias.js +7 -5
- package/src/virtual-fs/host/buffer.d.ts +1 -1
- package/src/virtual-fs/host/buffer.js +7 -0
- package/src/virtual-fs/host/create.d.ts +7 -0
- package/src/virtual-fs/host/create.js +3 -3
- package/src/virtual-fs/host/empty.d.ts +1 -1
- package/src/virtual-fs/host/empty.js +3 -3
- package/src/virtual-fs/host/index.d.ts +1 -1
- package/src/virtual-fs/host/index.js +1 -1
- package/src/virtual-fs/host/interface.d.ts +1 -1
- package/src/virtual-fs/host/interface.js +7 -0
- package/src/virtual-fs/host/memory.d.ts +1 -1
- package/src/virtual-fs/host/memory.js +32 -20
- package/src/virtual-fs/host/pattern.d.ts +1 -1
- package/src/virtual-fs/host/pattern.js +17 -8
- package/src/virtual-fs/host/record.d.ts +1 -1
- package/src/virtual-fs/host/record.js +45 -28
- package/src/virtual-fs/host/resolver.d.ts +1 -1
- package/src/virtual-fs/host/resolver.js +10 -1
- package/src/virtual-fs/host/safe.d.ts +1 -1
- package/src/virtual-fs/host/safe.js +3 -3
- package/src/virtual-fs/host/scoped.d.ts +1 -1
- package/src/virtual-fs/host/scoped.js +3 -3
- package/src/virtual-fs/host/sync.d.ts +1 -1
- package/src/virtual-fs/host/sync.js +12 -3
- package/src/virtual-fs/host/test.d.ts +1 -1
- package/src/virtual-fs/host/test.js +11 -2
- package/src/virtual-fs/index.d.ts +2 -2
- package/src/virtual-fs/index.js +8 -8
- package/src/virtual-fs/path.d.ts +1 -1
- package/src/virtual-fs/path.js +17 -8
- package/src/workspace/core.d.ts +7 -0
- package/src/workspace/core.js +3 -3
- package/src/workspace/definitions.d.ts +1 -1
- package/src/workspace/definitions.js +7 -0
- package/src/workspace/host.d.ts +1 -1
- package/src/workspace/host.js +3 -3
- package/src/workspace/index.d.ts +1 -1
- package/src/workspace/index.js +7 -7
- package/src/workspace/json/metadata.d.ts +1 -1
- package/src/workspace/json/metadata.js +8 -1
- package/src/workspace/json/reader.d.ts +7 -0
- package/src/workspace/json/reader.js +4 -4
- package/src/workspace/json/utilities.d.ts +1 -1
- package/src/workspace/json/utilities.js +12 -5
- package/src/workspace/json/writer.d.ts +7 -0
- package/src/workspace/json/writer.js +4 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
# Overview
|
|
2
|
+
|
|
3
3
|
Jobs is a high-order API that adds inputs, runtime type checking, sequencing, and other
|
|
4
4
|
functionality on top of RxJS' `Observable`s.
|
|
5
5
|
|
|
6
6
|
# Background
|
|
7
|
+
|
|
7
8
|
An `Observable` (at a higher level) is a function that receives a `Subscriber`, and outputs
|
|
8
9
|
multiple values, and finishes once it calls the `Subscriber.prototype.complete()` method (in
|
|
9
10
|
JavaScript):
|
|
@@ -23,17 +24,18 @@ const output1To10EverySecond = function (subscriber) {
|
|
|
23
24
|
|
|
24
25
|
const stream$ = new Observable(output1To10EverySecond);
|
|
25
26
|
// Start the function, and output 1 to 100, once per line.
|
|
26
|
-
stream$.subscribe(x => console.log(x));
|
|
27
|
+
stream$.subscribe((x) => console.log(x));
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
This, of course, can be typed in TypeScript, but those types are not enforced at runtime.
|
|
30
31
|
|
|
31
32
|
# Glossary
|
|
33
|
+
|
|
32
34
|
- `job handler`. The function that implements the job's logic.
|
|
33
35
|
- `raw input`. The input observable sending messages to the job. These messages are of type
|
|
34
|
-
|
|
36
|
+
`JobInboundMessage`.
|
|
35
37
|
- `raw output`. The output observer returned from the `job handler`. Messages on this observable
|
|
36
|
-
|
|
38
|
+
are of type `JobOutboundMessage`.
|
|
37
39
|
|
|
38
40
|
# Description
|
|
39
41
|
|
|
@@ -43,7 +45,7 @@ Json Schema):
|
|
|
43
45
|
|
|
44
46
|
```javascript
|
|
45
47
|
const output1ToXEverySecond = function (x, context) {
|
|
46
|
-
return new Observable(subscriber => {
|
|
48
|
+
return new Observable((subscriber) => {
|
|
47
49
|
let t = 0;
|
|
48
50
|
|
|
49
51
|
// Notify our users that the actual work is started.
|
|
@@ -60,7 +62,7 @@ const output1ToXEverySecond = function (x, context) {
|
|
|
60
62
|
return () => {
|
|
61
63
|
clearInterval(i);
|
|
62
64
|
};
|
|
63
|
-
})
|
|
65
|
+
});
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
// For now, jobs can not be called without a registry and scheduler.
|
|
@@ -76,7 +78,7 @@ const scheduler = new SimpleScheduler(registry);
|
|
|
76
78
|
const job = scheduler.schedule('output-from-1-to-x', 10);
|
|
77
79
|
|
|
78
80
|
// A Job<> instance has more members, but we only want the output values here.
|
|
79
|
-
job.output.subscribe(x => console.log(x));
|
|
81
|
+
job.output.subscribe((x) => console.log(x));
|
|
80
82
|
```
|
|
81
83
|
|
|
82
84
|
This seems like a lot of boilerplate in comparison, but there are a few advantages;
|
|
@@ -84,11 +86,12 @@ This seems like a lot of boilerplate in comparison, but there are a few advantag
|
|
|
84
86
|
1. lifecycle. Jobs can tell when they start doing work and when work is done.
|
|
85
87
|
1. everything is typed, even at runtime.
|
|
86
88
|
1. the context also contains an input Observable that receives typed input messages, including
|
|
87
|
-
|
|
89
|
+
input values, and stop requests.
|
|
88
90
|
1. jobs can also schedule other jobs and wait for them, even if they don't know if a job is
|
|
89
|
-
|
|
91
|
+
implemented in the system.
|
|
90
92
|
|
|
91
93
|
## Diagram
|
|
94
|
+
|
|
92
95
|
A simpler way to think about jobs in contrast to observables is that job are closer to a Unix
|
|
93
96
|
process. It has an argument (command line flags), receive inputs (STDIN and interrupt signals),
|
|
94
97
|
and output values (STDOUT) as well as diagnostic (STDERR). They can be plugged one into another
|
|
@@ -99,7 +102,7 @@ and output values (STDOUT) as well as diagnostic (STDERR). They can be plugged o
|
|
|
99
102
|
- given I the type of the input
|
|
100
103
|
- given O the type of the output
|
|
101
104
|
|
|
102
|
-
,______________________
|
|
105
|
+
,______________________
|
|
103
106
|
JobInboundMessage<I> --> | handler(argument: A) | --> JobOutboundMessage<O>
|
|
104
107
|
- JobOutboundMessageKind.Output
|
|
105
108
|
- ...
|
|
@@ -108,37 +111,38 @@ and output values (STDOUT) as well as diagnostic (STDERR). They can be plugged o
|
|
|
108
111
|
`JobInboundMessage` includes:
|
|
109
112
|
|
|
110
113
|
1. `JobInboundMessageKind.Ping`. A simple message that should be answered with
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
`JobOutboundMessageKind.Pong` when the job is responsive. The `id` field of the message should
|
|
115
|
+
be used when returning `Pong`.
|
|
113
116
|
1. `JobInboundMessageKind.Stop`. The job should be stopped. This is used when
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
cancelling/unsubscribing from the `output` (or by calling `stop()`). Any inputs or outputs
|
|
118
|
+
after this message will be ignored.
|
|
116
119
|
1. `JobInboundMessageKind.Input` is used when sending inputs to a job. These correspond to the
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
`next` methods of an `Observer` and are reported to the job through its `context.input`
|
|
121
|
+
Observable. There is no way to communicate an error to the job.
|
|
119
122
|
|
|
120
123
|
`JobOutboundMessage` includes:
|
|
121
124
|
|
|
122
125
|
1. `JobOutboundMessageKind.Ready`. The `Job<>` was created, its dependencies are done, and the
|
|
123
|
-
|
|
126
|
+
library is validating Argument and calling the internal job code.
|
|
124
127
|
1. `JobOutboundMessageKind.Start`. The job code itself should send that message when started.
|
|
125
|
-
|
|
128
|
+
`createJobHandler()` will do it automatically.
|
|
126
129
|
1. `JobOutboundMessageKind.End`. The job has ended. This is done by the job itself and should
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
always be sent when completed. The scheduler will listen to this message to set the state and
|
|
131
|
+
unblock dependent jobs. `createJobHandler()` automatically send this message.
|
|
129
132
|
1. `JobOutboundMessageKind.Pong`. The job should answer a `JobInboundMessageKind.Ping` message with
|
|
130
|
-
|
|
133
|
+
this. Automatically done by `createJobHandler()`.
|
|
131
134
|
1. `JobOutboundMessageKind.Output`. An `Output` has been generated by the job.
|
|
132
135
|
1. `JobOutboundMessageKind.ChannelMessage`, `JobOutboundMessageKind.ChannelError` and
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
`JobOutboundMessageKind.ChannelComplete` are used for output channels. These correspond to
|
|
137
|
+
the `next`, `error` and `complete` methods of an `Observer` and are available to the callee
|
|
138
|
+
through the `job.channels` map of Observable.
|
|
136
139
|
|
|
137
140
|
Utilities should have some filtering and dispatching to separate observables, as a convenience for
|
|
138
141
|
the user. An example of this would be the `Job.prototype.output` observable which only contains
|
|
139
142
|
the value contained by messages of type `JobOutboundMessageKind.Output`.
|
|
140
143
|
|
|
141
144
|
# Higher Order Jobs
|
|
145
|
+
|
|
142
146
|
Because jobs are expected to be pure functions, they can be composed or transformed to create
|
|
143
147
|
more complex behaviour, similar to how RxJS operators can transform observables.
|
|
144
148
|
|
|
@@ -146,31 +150,31 @@ more complex behaviour, similar to how RxJS operators can transform observables.
|
|
|
146
150
|
// Runs a job on the hour, every hour, regardless of how long the job takes.
|
|
147
151
|
// This creates a job function that can be registered by itself.
|
|
148
152
|
function scheduleJobOnTheHour(jobFunction) {
|
|
149
|
-
return function(argument, context) {
|
|
150
|
-
return new Observable(observer => {
|
|
153
|
+
return function (argument, context) {
|
|
154
|
+
return new Observable((observer) => {
|
|
151
155
|
let timeout = 0;
|
|
152
|
-
|
|
156
|
+
|
|
153
157
|
function _timeoutToNextHour() {
|
|
154
158
|
// Just wait until the next hour.
|
|
155
159
|
const t = new Date();
|
|
156
160
|
const secondsToNextHour = 3600 - t.getSeconds() - t.getMinutes() * 60;
|
|
157
161
|
timeout = setTimeout(_scheduleJobAndWaitAnHour, secondsToNextHour);
|
|
158
162
|
}
|
|
159
|
-
|
|
163
|
+
|
|
160
164
|
function _scheduleJobAndWaitAnHour() {
|
|
161
165
|
jobFunction(argument, context).subscribe(
|
|
162
|
-
message => observer.next(message),
|
|
163
|
-
error => observer.error(error),
|
|
166
|
+
(message) => observer.next(message),
|
|
167
|
+
(error) => observer.error(error),
|
|
164
168
|
// Do not forward completion, but use it to schedule the next job run.
|
|
165
169
|
() => {
|
|
166
170
|
_timeoutToNextHour();
|
|
167
171
|
},
|
|
168
172
|
);
|
|
169
173
|
}
|
|
170
|
-
|
|
174
|
+
|
|
171
175
|
// Kick off by waiting for next hour.
|
|
172
176
|
_timeoutToNextHour();
|
|
173
|
-
|
|
177
|
+
|
|
174
178
|
return () => clearTimeout(timeout);
|
|
175
179
|
});
|
|
176
180
|
};
|
|
@@ -184,9 +188,9 @@ Another way to compose jobs is to schedule jobs based on their name, from other
|
|
|
184
188
|
// This creates a high order job by getting a job name and an argument, and scheduling the job
|
|
185
189
|
// every hour.
|
|
186
190
|
function scheduleJobOnTheHour(job, context) {
|
|
187
|
-
const { name, argument } = job;
|
|
191
|
+
const { name, argument } = job; // Destructure our input.
|
|
188
192
|
|
|
189
|
-
return new Observable(observer => {
|
|
193
|
+
return new Observable((observer) => {
|
|
190
194
|
let timeout = 0;
|
|
191
195
|
|
|
192
196
|
function _timeoutToNextHour() {
|
|
@@ -200,8 +204,8 @@ function scheduleJobOnTheHour(job, context) {
|
|
|
200
204
|
const subJob = context.scheduler.schedule(name, argument);
|
|
201
205
|
// We do not forward the input to the sub-job but that would be a valid example as well.
|
|
202
206
|
subJob.outboundBus.subscribe(
|
|
203
|
-
message => observer.next(message),
|
|
204
|
-
error => observer.error(error),
|
|
207
|
+
(message) => observer.next(message),
|
|
208
|
+
(error) => observer.error(error),
|
|
205
209
|
// Do not forward completion, but use it to schedule the next job run.
|
|
206
210
|
() => {
|
|
207
211
|
_timeoutToNextHour();
|
|
@@ -239,15 +243,16 @@ const job = scheduler.schedule('schedule-job-on-the-hour', {
|
|
|
239
243
|
to: '/volumes/usb-key',
|
|
240
244
|
},
|
|
241
245
|
});
|
|
242
|
-
job.output.subscribe(x => console.log(x));
|
|
246
|
+
job.output.subscribe((x) => console.log(x));
|
|
243
247
|
```
|
|
244
248
|
|
|
245
249
|
# Limitations
|
|
250
|
+
|
|
246
251
|
Jobs input, output and argument must be serializable to JSONs. This is a big limitation in usage,
|
|
247
252
|
but comes with the benefit that jobs can be serialized and called across memory boundaries. An
|
|
248
253
|
example would be an operator that takes a module path and run the job from that path in a separate
|
|
249
254
|
process. Or even a separate server, using HTTP calls.
|
|
250
|
-
|
|
255
|
+
|
|
251
256
|
Another limitation is that the boilerplate is complex. Manually managing start/end life cycle, and
|
|
252
257
|
other messages such as ping/pong, etc. is tedious and requires a lot of code. A good way to keep
|
|
253
258
|
this limitation under control is to provide helpers to create `JobHandler`s which manage those
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*
|
|
8
7
|
*/
|
|
9
8
|
import { Observable, Observer } from 'rxjs';
|
|
10
9
|
import { BaseException } from '../../exception/index';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLoggerJob = exports.createJobFactory = exports.createJobHandler = exports.ChannelAlreadyExistException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*
|
|
11
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createLoggerJob = exports.createJobFactory = exports.createJobHandler = exports.ChannelAlreadyExistException = void 0;
|
|
12
11
|
const rxjs_1 = require("rxjs");
|
|
13
12
|
const operators_1 = require("rxjs/operators");
|
|
14
13
|
const index_1 = require("../../exception/index");
|
|
@@ -33,7 +32,7 @@ function createJobHandler(fn, options = {}) {
|
|
|
33
32
|
const inboundBus = context.inboundBus;
|
|
34
33
|
const inputChannel = new rxjs_1.Subject();
|
|
35
34
|
let subscription;
|
|
36
|
-
return new rxjs_1.Observable(subject => {
|
|
35
|
+
return new rxjs_1.Observable((subject) => {
|
|
37
36
|
function complete() {
|
|
38
37
|
if (subscription) {
|
|
39
38
|
subscription.unsubscribe();
|
|
@@ -43,7 +42,7 @@ function createJobHandler(fn, options = {}) {
|
|
|
43
42
|
inputChannel.complete();
|
|
44
43
|
}
|
|
45
44
|
// Handle input.
|
|
46
|
-
const inboundSub = inboundBus.subscribe(message => {
|
|
45
|
+
const inboundSub = inboundBus.subscribe((message) => {
|
|
47
46
|
switch (message.kind) {
|
|
48
47
|
case api_1.JobInboundMessageKind.Ping:
|
|
49
48
|
subject.next({ kind: api_1.JobOutboundMessageKind.Pong, description, id: message.id });
|
|
@@ -68,11 +67,14 @@ function createJobHandler(fn, options = {}) {
|
|
|
68
67
|
throw new ChannelAlreadyExistException(name);
|
|
69
68
|
}
|
|
70
69
|
const channelSubject = new rxjs_1.Subject();
|
|
71
|
-
const channelSub = channelSubject.subscribe(message => {
|
|
70
|
+
const channelSub = channelSubject.subscribe((message) => {
|
|
72
71
|
subject.next({
|
|
73
|
-
kind: api_1.JobOutboundMessageKind.ChannelMessage,
|
|
72
|
+
kind: api_1.JobOutboundMessageKind.ChannelMessage,
|
|
73
|
+
description,
|
|
74
|
+
name,
|
|
75
|
+
message,
|
|
74
76
|
});
|
|
75
|
-
}, error => {
|
|
77
|
+
}, (error) => {
|
|
76
78
|
subject.next({ kind: api_1.JobOutboundMessageKind.ChannelError, description, name, error });
|
|
77
79
|
// This can be reopened.
|
|
78
80
|
channels.delete(name);
|
|
@@ -97,7 +99,7 @@ function createJobHandler(fn, options = {}) {
|
|
|
97
99
|
else if (!rxjs_1.isObservable(result)) {
|
|
98
100
|
result = rxjs_1.of(result);
|
|
99
101
|
}
|
|
100
|
-
subscription = result.subscribe((value) => subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value }), error => subject.error(error), () => complete());
|
|
102
|
+
subscription = result.subscribe((value) => subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value }), (error) => subject.error(error), () => complete());
|
|
101
103
|
subscription.add(inboundSub);
|
|
102
104
|
return subscription;
|
|
103
105
|
});
|
|
@@ -112,8 +114,7 @@ exports.createJobHandler = createJobHandler;
|
|
|
112
114
|
*/
|
|
113
115
|
function createJobFactory(loader, options = {}) {
|
|
114
116
|
const handler = (argument, context) => {
|
|
115
|
-
return rxjs_1.from(loader())
|
|
116
|
-
.pipe(operators_1.switchMap(fn => fn(argument, context)));
|
|
117
|
+
return rxjs_1.from(loader()).pipe(operators_1.switchMap((fn) => fn(argument, context)));
|
|
117
118
|
};
|
|
118
119
|
return Object.assign(handler, { jobDescription: options });
|
|
119
120
|
}
|
|
@@ -124,8 +125,10 @@ exports.createJobFactory = createJobFactory;
|
|
|
124
125
|
*/
|
|
125
126
|
function createLoggerJob(job, logger) {
|
|
126
127
|
const handler = (argument, context) => {
|
|
127
|
-
context.inboundBus
|
|
128
|
-
|
|
128
|
+
context.inboundBus
|
|
129
|
+
.pipe(operators_1.tap((message) => logger.info(`Input: ${JSON.stringify(message)}`)))
|
|
130
|
+
.subscribe();
|
|
131
|
+
return job(argument, context).pipe(operators_1.tap((message) => logger.info(`Message: ${JSON.stringify(message)}`), (error) => logger.warn(`Error: ${JSON.stringify(error)}`), () => logger.info(`Completed`)));
|
|
129
132
|
};
|
|
130
133
|
return Object.assign(handler, job);
|
|
131
134
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*
|
|
8
7
|
*/
|
|
9
8
|
import { JsonValue } from '../../json/index';
|
|
10
9
|
import { Readwrite } from '../../utils/index';
|
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.createDispatcher = void 0;
|
|
4
11
|
const api_1 = require("./api");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JobDoesNotExistException = exports.JobNameAlreadyRegisteredException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.JobDoesNotExistException = exports.JobNameAlreadyRegisteredException = void 0;
|
|
11
11
|
const index_1 = require("../../exception/index");
|
|
12
12
|
class JobNameAlreadyRegisteredException extends index_1.BaseException {
|
|
13
13
|
constructor(name) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FallbackRegistry = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.FallbackRegistry = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const operators_1 = require("rxjs/operators");
|
|
13
13
|
/**
|
|
@@ -21,7 +21,7 @@ class FallbackRegistry {
|
|
|
21
21
|
this._fallbacks.push(registry);
|
|
22
22
|
}
|
|
23
23
|
get(name) {
|
|
24
|
-
return rxjs_1.from(this._fallbacks).pipe(operators_1.concatMap(fb => fb.get(name)), operators_1.first(x => x !== null, null));
|
|
24
|
+
return rxjs_1.from(this._fallbacks).pipe(operators_1.concatMap((fb) => fb.get(name)), operators_1.first((x) => x !== null, null));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.FallbackRegistry = FallbackRegistry;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
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
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -10,13 +17,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
/**
|
|
14
|
-
* @license
|
|
15
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
16
|
-
*
|
|
17
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
18
|
-
* found in the LICENSE file at https://angular.io/license
|
|
19
|
-
*/
|
|
20
20
|
__exportStar(require("./api"), exports);
|
|
21
21
|
__exportStar(require("./create-job-handler"), exports);
|
|
22
22
|
__exportStar(require("./exception"), exports);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleJobRegistry = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SimpleJobRegistry = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const json_1 = require("../../json");
|
|
13
13
|
const api_1 = require("./api");
|
|
@@ -62,7 +62,9 @@ class SimpleJobRegistry {
|
|
|
62
62
|
output,
|
|
63
63
|
input,
|
|
64
64
|
};
|
|
65
|
-
const jobHandler = Object.assign(handler.bind(undefined), {
|
|
65
|
+
const jobHandler = Object.assign(handler.bind(undefined), {
|
|
66
|
+
jobDescription,
|
|
67
|
+
});
|
|
66
68
|
this._jobNames.set(name, jobHandler);
|
|
67
69
|
}
|
|
68
70
|
/**
|