@angular-devkit/core 13.0.0-next.4 → 13.0.0-next.8
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/node/cli-logger.js +1 -1
- package/node/experimental/jobs/job-registry.js +3 -3
- package/node/fs.js +2 -2
- package/node/host.js +41 -41
- package/node/testing/index.js +4 -4
- package/package.json +2 -2
- package/src/experimental/jobs/create-job-handler.js +7 -7
- package/src/experimental/jobs/dispatcher.js +1 -1
- package/src/experimental/jobs/fallback-registry.js +1 -1
- package/src/experimental/jobs/simple-registry.js +3 -3
- package/src/experimental/jobs/simple-scheduler.js +32 -32
- package/src/experimental/jobs/strategy.js +7 -7
- package/src/json/schema/registry.js +13 -13
- package/src/json/schema/schema.js +1 -1
- package/src/json/schema/transforms.js +10 -10
- package/src/json/schema/utility.js +2 -2
- package/src/json/schema/visitor.js +14 -14
- package/src/logger/indent.js +1 -1
- package/src/logger/logger.js +1 -1
- package/src/virtual-fs/host/alias.js +3 -3
- package/src/virtual-fs/host/empty.js +6 -6
- package/src/virtual-fs/host/memory.js +13 -13
- package/src/virtual-fs/host/record.js +27 -27
- package/src/virtual-fs/host/safe.js +4 -4
- package/src/virtual-fs/host/scoped.js +1 -1
- package/src/virtual-fs/host/test.js +9 -9
- package/src/workspace/core.js +5 -5
- package/src/workspace/host.js +4 -4
- package/src/workspace/json/reader.js +7 -7
- package/src/workspace/json/writer.js +1 -1
package/node/cli-logger.js
CHANGED
|
@@ -15,7 +15,7 @@ const src_1 = require("../src");
|
|
|
15
15
|
*/
|
|
16
16
|
function createConsoleLogger(verbose = false, stdout = process.stdout, stderr = process.stderr, colors) {
|
|
17
17
|
const logger = new src_1.logging.IndentLogger('cling');
|
|
18
|
-
logger.pipe(operators_1.filter((entry) => entry.level !== 'debug' || verbose)).subscribe((entry) => {
|
|
18
|
+
logger.pipe((0, operators_1.filter)((entry) => entry.level !== 'debug' || verbose)).subscribe((entry) => {
|
|
19
19
|
const color = colors && colors[entry.level];
|
|
20
20
|
let output = stdout;
|
|
21
21
|
switch (entry.level) {
|
|
@@ -32,12 +32,12 @@ class NodeModuleJobRegistry {
|
|
|
32
32
|
const [moduleName, exportName] = name.split(/#/, 2);
|
|
33
33
|
const resolvedPath = this._resolve(moduleName);
|
|
34
34
|
if (!resolvedPath) {
|
|
35
|
-
return rxjs_1.of(null);
|
|
35
|
+
return (0, rxjs_1.of)(null);
|
|
36
36
|
}
|
|
37
37
|
const pkg = require(resolvedPath);
|
|
38
38
|
const handler = pkg[exportName || 'default'];
|
|
39
39
|
if (!handler) {
|
|
40
|
-
return rxjs_1.of(null);
|
|
40
|
+
return (0, rxjs_1.of)(null);
|
|
41
41
|
}
|
|
42
42
|
function _getValue(...fields) {
|
|
43
43
|
return fields.find((x) => src_1.schema.isJsonSchema(x)) || true;
|
|
@@ -46,7 +46,7 @@ class NodeModuleJobRegistry {
|
|
|
46
46
|
const input = _getValue(pkg.input, handler.input);
|
|
47
47
|
const output = _getValue(pkg.output, handler.output);
|
|
48
48
|
const channels = _getValue(pkg.channels, handler.channels);
|
|
49
|
-
return rxjs_1.of(Object.assign(handler.bind(undefined), {
|
|
49
|
+
return (0, rxjs_1.of)(Object.assign(handler.bind(undefined), {
|
|
50
50
|
jobDescription: {
|
|
51
51
|
argument,
|
|
52
52
|
input,
|
package/node/fs.js
CHANGED
|
@@ -13,7 +13,7 @@ const fs_1 = require("fs");
|
|
|
13
13
|
function isFile(filePath) {
|
|
14
14
|
let stat;
|
|
15
15
|
try {
|
|
16
|
-
stat = fs_1.statSync(filePath);
|
|
16
|
+
stat = (0, fs_1.statSync)(filePath);
|
|
17
17
|
}
|
|
18
18
|
catch (e) {
|
|
19
19
|
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
|
|
@@ -28,7 +28,7 @@ exports.isFile = isFile;
|
|
|
28
28
|
function isDirectory(filePath) {
|
|
29
29
|
let stat;
|
|
30
30
|
try {
|
|
31
|
-
stat = fs_1.statSync(filePath);
|
|
31
|
+
stat = (0, fs_1.statSync)(filePath);
|
|
32
32
|
}
|
|
33
33
|
catch (e) {
|
|
34
34
|
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
|
package/node/host.js
CHANGED
|
@@ -50,17 +50,17 @@ class NodeJsAsyncHost {
|
|
|
50
50
|
return { synchronous: false };
|
|
51
51
|
}
|
|
52
52
|
write(path, content) {
|
|
53
|
-
return rxjs_1.from(fs_1.promises.mkdir(src_1.getSystemPath(src_1.dirname(path)), { recursive: true })).pipe(operators_1.mergeMap(() => fs_1.promises.writeFile(src_1.getSystemPath(path), new Uint8Array(content))));
|
|
53
|
+
return (0, rxjs_1.from)(fs_1.promises.mkdir((0, src_1.getSystemPath)((0, src_1.dirname)(path)), { recursive: true })).pipe((0, operators_1.mergeMap)(() => fs_1.promises.writeFile((0, src_1.getSystemPath)(path), new Uint8Array(content))));
|
|
54
54
|
}
|
|
55
55
|
read(path) {
|
|
56
|
-
return rxjs_1.from(fs_1.promises.readFile(src_1.getSystemPath(path))).pipe(operators_1.map((buffer) => new Uint8Array(buffer).buffer));
|
|
56
|
+
return (0, rxjs_1.from)(fs_1.promises.readFile((0, src_1.getSystemPath)(path))).pipe((0, operators_1.map)((buffer) => new Uint8Array(buffer).buffer));
|
|
57
57
|
}
|
|
58
58
|
delete(path) {
|
|
59
|
-
return this.isDirectory(path).pipe(operators_1.mergeMap(async (isDirectory) => {
|
|
59
|
+
return this.isDirectory(path).pipe((0, operators_1.mergeMap)(async (isDirectory) => {
|
|
60
60
|
if (isDirectory) {
|
|
61
61
|
const recursiveDelete = async (dirPath) => {
|
|
62
62
|
for (const fragment of await fs_1.promises.readdir(dirPath)) {
|
|
63
|
-
const sysPath = path_1.join(dirPath, fragment);
|
|
63
|
+
const sysPath = (0, path_1.join)(dirPath, fragment);
|
|
64
64
|
const stats = await fs_1.promises.stat(sysPath);
|
|
65
65
|
if (stats.isDirectory()) {
|
|
66
66
|
await recursiveDelete(sysPath);
|
|
@@ -71,61 +71,61 @@ class NodeJsAsyncHost {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
await recursiveDelete(src_1.getSystemPath(path));
|
|
74
|
+
await recursiveDelete((0, src_1.getSystemPath)(path));
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
-
await fs_1.promises.unlink(src_1.getSystemPath(path));
|
|
77
|
+
await fs_1.promises.unlink((0, src_1.getSystemPath)(path));
|
|
78
78
|
}
|
|
79
79
|
}));
|
|
80
80
|
}
|
|
81
81
|
rename(from, to) {
|
|
82
|
-
return rxjs_1.from(fs_1.promises.rename(src_1.getSystemPath(from), src_1.getSystemPath(to)));
|
|
82
|
+
return (0, rxjs_1.from)(fs_1.promises.rename((0, src_1.getSystemPath)(from), (0, src_1.getSystemPath)(to)));
|
|
83
83
|
}
|
|
84
84
|
list(path) {
|
|
85
|
-
return rxjs_1.from(fs_1.promises.readdir(src_1.getSystemPath(path))).pipe(operators_1.map((names) => names.map((name) => src_1.fragment(name))));
|
|
85
|
+
return (0, rxjs_1.from)(fs_1.promises.readdir((0, src_1.getSystemPath)(path))).pipe((0, operators_1.map)((names) => names.map((name) => (0, src_1.fragment)(name))));
|
|
86
86
|
}
|
|
87
87
|
exists(path) {
|
|
88
|
-
return rxjs_1.from(exists(src_1.getSystemPath(path)));
|
|
88
|
+
return (0, rxjs_1.from)(exists((0, src_1.getSystemPath)(path)));
|
|
89
89
|
}
|
|
90
90
|
isDirectory(path) {
|
|
91
|
-
return this.stat(path).pipe(operators_1.map((stat) => stat.isDirectory()));
|
|
91
|
+
return this.stat(path).pipe((0, operators_1.map)((stat) => stat.isDirectory()));
|
|
92
92
|
}
|
|
93
93
|
isFile(path) {
|
|
94
|
-
return this.stat(path).pipe(operators_1.map((stat) => stat.isFile()));
|
|
94
|
+
return this.stat(path).pipe((0, operators_1.map)((stat) => stat.isFile()));
|
|
95
95
|
}
|
|
96
96
|
// Some hosts may not support stat.
|
|
97
97
|
stat(path) {
|
|
98
|
-
return rxjs_1.from(fs_1.promises.stat(src_1.getSystemPath(path)));
|
|
98
|
+
return (0, rxjs_1.from)(fs_1.promises.stat((0, src_1.getSystemPath)(path)));
|
|
99
99
|
}
|
|
100
100
|
// Some hosts may not support watching.
|
|
101
101
|
watch(path, _options) {
|
|
102
102
|
return new rxjs_1.Observable((obs) => {
|
|
103
103
|
loadFSWatcher();
|
|
104
|
-
const watcher = new FSWatcher({ persistent: true }).add(src_1.getSystemPath(path));
|
|
104
|
+
const watcher = new FSWatcher({ persistent: true }).add((0, src_1.getSystemPath)(path));
|
|
105
105
|
watcher
|
|
106
106
|
.on('change', (path) => {
|
|
107
107
|
obs.next({
|
|
108
|
-
path: src_1.normalize(path),
|
|
108
|
+
path: (0, src_1.normalize)(path),
|
|
109
109
|
time: new Date(),
|
|
110
110
|
type: 0 /* Changed */,
|
|
111
111
|
});
|
|
112
112
|
})
|
|
113
113
|
.on('add', (path) => {
|
|
114
114
|
obs.next({
|
|
115
|
-
path: src_1.normalize(path),
|
|
115
|
+
path: (0, src_1.normalize)(path),
|
|
116
116
|
time: new Date(),
|
|
117
117
|
type: 1 /* Created */,
|
|
118
118
|
});
|
|
119
119
|
})
|
|
120
120
|
.on('unlink', (path) => {
|
|
121
121
|
obs.next({
|
|
122
|
-
path: src_1.normalize(path),
|
|
122
|
+
path: (0, src_1.normalize)(path),
|
|
123
123
|
time: new Date(),
|
|
124
124
|
type: 2 /* Deleted */,
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
return () => watcher.close();
|
|
128
|
-
}).pipe(operators_1.publish(), operators_1.refCount());
|
|
128
|
+
}).pipe((0, operators_1.publish)(), (0, operators_1.refCount)());
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
exports.NodeJsAsyncHost = NodeJsAsyncHost;
|
|
@@ -138,74 +138,74 @@ class NodeJsSyncHost {
|
|
|
138
138
|
}
|
|
139
139
|
write(path, content) {
|
|
140
140
|
return new rxjs_1.Observable((obs) => {
|
|
141
|
-
fs_1.mkdirSync(src_1.getSystemPath(src_1.dirname(path)), { recursive: true });
|
|
142
|
-
fs_1.writeFileSync(src_1.getSystemPath(path), new Uint8Array(content));
|
|
141
|
+
(0, fs_1.mkdirSync)((0, src_1.getSystemPath)((0, src_1.dirname)(path)), { recursive: true });
|
|
142
|
+
(0, fs_1.writeFileSync)((0, src_1.getSystemPath)(path), new Uint8Array(content));
|
|
143
143
|
obs.next();
|
|
144
144
|
obs.complete();
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
read(path) {
|
|
148
148
|
return new rxjs_1.Observable((obs) => {
|
|
149
|
-
const buffer = fs_1.readFileSync(src_1.getSystemPath(path));
|
|
149
|
+
const buffer = (0, fs_1.readFileSync)((0, src_1.getSystemPath)(path));
|
|
150
150
|
obs.next(new Uint8Array(buffer).buffer);
|
|
151
151
|
obs.complete();
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
delete(path) {
|
|
155
|
-
return this.isDirectory(path).pipe(operators_1.concatMap((isDir) => {
|
|
155
|
+
return this.isDirectory(path).pipe((0, operators_1.concatMap)((isDir) => {
|
|
156
156
|
if (isDir) {
|
|
157
|
-
const dirPaths = fs_1.readdirSync(src_1.getSystemPath(path));
|
|
157
|
+
const dirPaths = (0, fs_1.readdirSync)((0, src_1.getSystemPath)(path));
|
|
158
158
|
const rmDirComplete = new rxjs_1.Observable((obs) => {
|
|
159
|
-
fs_1.rmdirSync(src_1.getSystemPath(path));
|
|
159
|
+
(0, fs_1.rmdirSync)((0, src_1.getSystemPath)(path));
|
|
160
160
|
obs.complete();
|
|
161
161
|
});
|
|
162
|
-
return rxjs_1.concat(...dirPaths.map((name) => this.delete(src_1.join(path, name))), rmDirComplete);
|
|
162
|
+
return (0, rxjs_1.concat)(...dirPaths.map((name) => this.delete((0, src_1.join)(path, name))), rmDirComplete);
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
165
|
try {
|
|
166
|
-
fs_1.unlinkSync(src_1.getSystemPath(path));
|
|
166
|
+
(0, fs_1.unlinkSync)((0, src_1.getSystemPath)(path));
|
|
167
167
|
}
|
|
168
168
|
catch (err) {
|
|
169
|
-
return rxjs_1.throwError(err);
|
|
169
|
+
return (0, rxjs_1.throwError)(err);
|
|
170
170
|
}
|
|
171
|
-
return rxjs_1.of(undefined);
|
|
171
|
+
return (0, rxjs_1.of)(undefined);
|
|
172
172
|
}
|
|
173
173
|
}));
|
|
174
174
|
}
|
|
175
175
|
rename(from, to) {
|
|
176
176
|
return new rxjs_1.Observable((obs) => {
|
|
177
|
-
const toSystemPath = src_1.getSystemPath(to);
|
|
178
|
-
fs_1.mkdirSync(path_1.dirname(toSystemPath), { recursive: true });
|
|
179
|
-
fs_1.renameSync(src_1.getSystemPath(from), toSystemPath);
|
|
177
|
+
const toSystemPath = (0, src_1.getSystemPath)(to);
|
|
178
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(toSystemPath), { recursive: true });
|
|
179
|
+
(0, fs_1.renameSync)((0, src_1.getSystemPath)(from), toSystemPath);
|
|
180
180
|
obs.next();
|
|
181
181
|
obs.complete();
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
list(path) {
|
|
185
185
|
return new rxjs_1.Observable((obs) => {
|
|
186
|
-
const names = fs_1.readdirSync(src_1.getSystemPath(path));
|
|
187
|
-
obs.next(names.map((name) => src_1.fragment(name)));
|
|
186
|
+
const names = (0, fs_1.readdirSync)((0, src_1.getSystemPath)(path));
|
|
187
|
+
obs.next(names.map((name) => (0, src_1.fragment)(name)));
|
|
188
188
|
obs.complete();
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
191
|
exists(path) {
|
|
192
192
|
return new rxjs_1.Observable((obs) => {
|
|
193
|
-
obs.next(fs_1.existsSync(src_1.getSystemPath(path)));
|
|
193
|
+
obs.next((0, fs_1.existsSync)((0, src_1.getSystemPath)(path)));
|
|
194
194
|
obs.complete();
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
isDirectory(path) {
|
|
198
198
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
199
|
-
return this.stat(path).pipe(operators_1.map((stat) => stat.isDirectory()));
|
|
199
|
+
return this.stat(path).pipe((0, operators_1.map)((stat) => stat.isDirectory()));
|
|
200
200
|
}
|
|
201
201
|
isFile(path) {
|
|
202
202
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
203
|
-
return this.stat(path).pipe(operators_1.map((stat) => stat.isFile()));
|
|
203
|
+
return this.stat(path).pipe((0, operators_1.map)((stat) => stat.isFile()));
|
|
204
204
|
}
|
|
205
205
|
// Some hosts may not support stat.
|
|
206
206
|
stat(path) {
|
|
207
207
|
return new rxjs_1.Observable((obs) => {
|
|
208
|
-
obs.next(fs_1.statSync(src_1.getSystemPath(path)));
|
|
208
|
+
obs.next((0, fs_1.statSync)((0, src_1.getSystemPath)(path)));
|
|
209
209
|
obs.complete();
|
|
210
210
|
});
|
|
211
211
|
}
|
|
@@ -214,31 +214,31 @@ class NodeJsSyncHost {
|
|
|
214
214
|
return new rxjs_1.Observable((obs) => {
|
|
215
215
|
const opts = { persistent: false };
|
|
216
216
|
loadFSWatcher();
|
|
217
|
-
const watcher = new FSWatcher(opts).add(src_1.getSystemPath(path));
|
|
217
|
+
const watcher = new FSWatcher(opts).add((0, src_1.getSystemPath)(path));
|
|
218
218
|
watcher
|
|
219
219
|
.on('change', (path) => {
|
|
220
220
|
obs.next({
|
|
221
|
-
path: src_1.normalize(path),
|
|
221
|
+
path: (0, src_1.normalize)(path),
|
|
222
222
|
time: new Date(),
|
|
223
223
|
type: 0 /* Changed */,
|
|
224
224
|
});
|
|
225
225
|
})
|
|
226
226
|
.on('add', (path) => {
|
|
227
227
|
obs.next({
|
|
228
|
-
path: src_1.normalize(path),
|
|
228
|
+
path: (0, src_1.normalize)(path),
|
|
229
229
|
time: new Date(),
|
|
230
230
|
type: 1 /* Created */,
|
|
231
231
|
});
|
|
232
232
|
})
|
|
233
233
|
.on('unlink', (path) => {
|
|
234
234
|
obs.next({
|
|
235
|
-
path: src_1.normalize(path),
|
|
235
|
+
path: (0, src_1.normalize)(path),
|
|
236
236
|
time: new Date(),
|
|
237
237
|
type: 2 /* Deleted */,
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
return () => watcher.close();
|
|
241
|
-
}).pipe(operators_1.publish(), operators_1.refCount());
|
|
241
|
+
}).pipe((0, operators_1.publish)(), (0, operators_1.refCount)());
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
exports.NodeJsSyncHost = NodeJsSyncHost;
|
package/node/testing/index.js
CHANGED
|
@@ -37,8 +37,8 @@ const host_1 = require("../host");
|
|
|
37
37
|
*/
|
|
38
38
|
class TempScopedNodeJsSyncHost extends src_1.virtualFs.ScopedHost {
|
|
39
39
|
constructor() {
|
|
40
|
-
const root = src_1.normalize(path.join(os.tmpdir(), `devkit-host-${+Date.now()}-${process.pid}`));
|
|
41
|
-
fs.mkdirSync(src_1.getSystemPath(root));
|
|
40
|
+
const root = (0, src_1.normalize)(path.join(os.tmpdir(), `devkit-host-${+Date.now()}-${process.pid}`));
|
|
41
|
+
fs.mkdirSync((0, src_1.getSystemPath)(root));
|
|
42
42
|
super(new host_1.NodeJsSyncHost(), root);
|
|
43
43
|
this._root = root;
|
|
44
44
|
}
|
|
@@ -47,7 +47,7 @@ class TempScopedNodeJsSyncHost extends src_1.virtualFs.ScopedHost {
|
|
|
47
47
|
function _visit(p) {
|
|
48
48
|
return sync
|
|
49
49
|
.list(p)
|
|
50
|
-
.map((fragment) => src_1.join(p, fragment))
|
|
50
|
+
.map((fragment) => (0, src_1.join)(p, fragment))
|
|
51
51
|
.reduce((files, path) => {
|
|
52
52
|
if (sync.isDirectory(path)) {
|
|
53
53
|
return files.concat(_visit(path));
|
|
@@ -57,7 +57,7 @@ class TempScopedNodeJsSyncHost extends src_1.virtualFs.ScopedHost {
|
|
|
57
57
|
}
|
|
58
58
|
}, []);
|
|
59
59
|
}
|
|
60
|
-
return _visit(src_1.normalize('/'));
|
|
60
|
+
return _visit((0, src_1.normalize)('/'));
|
|
61
61
|
}
|
|
62
62
|
get root() {
|
|
63
63
|
return this._root;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/core",
|
|
3
|
-
"version": "13.0.0-next.
|
|
3
|
+
"version": "13.0.0-next.8",
|
|
4
4
|
"description": "Angular DevKit - Core Utility Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"ajv-formats": "2.1.1",
|
|
17
|
-
"ajv": "8.6.
|
|
17
|
+
"ajv": "8.6.3",
|
|
18
18
|
"fast-json-stable-stringify": "2.1.0",
|
|
19
19
|
"magic-string": "0.25.7",
|
|
20
20
|
"rxjs": "6.6.7",
|
|
@@ -93,11 +93,11 @@ function createJobHandler(fn, options = {}) {
|
|
|
93
93
|
subject.next({ kind: api_1.JobOutboundMessageKind.Start, description });
|
|
94
94
|
let result = fn(argument, newContext);
|
|
95
95
|
// If the result is a promise, simply wait for it to complete before reporting the result.
|
|
96
|
-
if (index_2.isPromise(result)) {
|
|
97
|
-
result = rxjs_1.from(result);
|
|
96
|
+
if ((0, index_2.isPromise)(result)) {
|
|
97
|
+
result = (0, rxjs_1.from)(result);
|
|
98
98
|
}
|
|
99
|
-
else if (!rxjs_1.isObservable(result)) {
|
|
100
|
-
result = rxjs_1.of(result);
|
|
99
|
+
else if (!(0, rxjs_1.isObservable)(result)) {
|
|
100
|
+
result = (0, rxjs_1.of)(result);
|
|
101
101
|
}
|
|
102
102
|
subscription = result.subscribe((value) => subject.next({ kind: api_1.JobOutboundMessageKind.Output, description, value }), (error) => subject.error(error), () => complete());
|
|
103
103
|
subscription.add(inboundSub);
|
|
@@ -114,7 +114,7 @@ exports.createJobHandler = createJobHandler;
|
|
|
114
114
|
*/
|
|
115
115
|
function createJobFactory(loader, options = {}) {
|
|
116
116
|
const handler = (argument, context) => {
|
|
117
|
-
return rxjs_1.from(loader()).pipe(operators_1.switchMap((fn) => fn(argument, context)));
|
|
117
|
+
return (0, rxjs_1.from)(loader()).pipe((0, operators_1.switchMap)((fn) => fn(argument, context)));
|
|
118
118
|
};
|
|
119
119
|
return Object.assign(handler, { jobDescription: options });
|
|
120
120
|
}
|
|
@@ -126,9 +126,9 @@ exports.createJobFactory = createJobFactory;
|
|
|
126
126
|
function createLoggerJob(job, logger) {
|
|
127
127
|
const handler = (argument, context) => {
|
|
128
128
|
context.inboundBus
|
|
129
|
-
.pipe(operators_1.tap((message) => logger.info(`Input: ${JSON.stringify(message)}`)))
|
|
129
|
+
.pipe((0, operators_1.tap)((message) => logger.info(`Input: ${JSON.stringify(message)}`)))
|
|
130
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`)));
|
|
131
|
+
return job(argument, context).pipe((0, operators_1.tap)((message) => logger.info(`Message: ${JSON.stringify(message)}`), (error) => logger.warn(`Error: ${JSON.stringify(error)}`), () => logger.info(`Completed`)));
|
|
132
132
|
};
|
|
133
133
|
return Object.assign(handler, job);
|
|
134
134
|
}
|
|
@@ -36,7 +36,7 @@ function createDispatcher(options = {}) {
|
|
|
36
36
|
});
|
|
37
37
|
return Object.assign(job, {
|
|
38
38
|
setDefaultJob(name) {
|
|
39
|
-
if (api_1.isJobHandler(name)) {
|
|
39
|
+
if ((0, api_1.isJobHandler)(name)) {
|
|
40
40
|
name = name.jobDescription.name === undefined ? null : name.jobDescription.name;
|
|
41
41
|
}
|
|
42
42
|
defaultDelegate = name;
|
|
@@ -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 (0, rxjs_1.from)(this._fallbacks).pipe((0, operators_1.concatMap)((fb) => fb.get(name)), (0, operators_1.first)((x) => x !== null, null));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.FallbackRegistry = FallbackRegistry;
|
|
@@ -20,18 +20,18 @@ class SimpleJobRegistry {
|
|
|
20
20
|
this._jobNames = new Map();
|
|
21
21
|
}
|
|
22
22
|
get(name) {
|
|
23
|
-
return rxjs_1.of(this._jobNames.get(name) || null);
|
|
23
|
+
return (0, rxjs_1.of)(this._jobNames.get(name) || null);
|
|
24
24
|
}
|
|
25
25
|
register(nameOrHandler, handlerOrOptions = {}, options = {}) {
|
|
26
26
|
// Switch on the arguments.
|
|
27
27
|
if (typeof nameOrHandler == 'string') {
|
|
28
|
-
if (!api_1.isJobHandler(handlerOrOptions)) {
|
|
28
|
+
if (!(0, api_1.isJobHandler)(handlerOrOptions)) {
|
|
29
29
|
// This is an error.
|
|
30
30
|
throw new TypeError('Expected a JobHandler as second argument.');
|
|
31
31
|
}
|
|
32
32
|
this._register(nameOrHandler, handlerOrOptions, options);
|
|
33
33
|
}
|
|
34
|
-
else if (api_1.isJobHandler(nameOrHandler)) {
|
|
34
|
+
else if ((0, api_1.isJobHandler)(nameOrHandler)) {
|
|
35
35
|
if (typeof handlerOrOptions !== 'object') {
|
|
36
36
|
// This is an error.
|
|
37
37
|
throw new TypeError('Expected an object options as second argument.');
|
|
@@ -87,12 +87,12 @@ class SimpleScheduler {
|
|
|
87
87
|
_getInternalDescription(name) {
|
|
88
88
|
const maybeHandler = this._internalJobDescriptionMap.get(name);
|
|
89
89
|
if (maybeHandler !== undefined) {
|
|
90
|
-
return rxjs_1.of(maybeHandler);
|
|
90
|
+
return (0, rxjs_1.of)(maybeHandler);
|
|
91
91
|
}
|
|
92
92
|
const handler = this._jobRegistry.get(name);
|
|
93
|
-
return handler.pipe(operators_1.switchMap((handler) => {
|
|
93
|
+
return handler.pipe((0, operators_1.switchMap)((handler) => {
|
|
94
94
|
if (handler === null) {
|
|
95
|
-
return rxjs_1.of(null);
|
|
95
|
+
return (0, rxjs_1.of)(null);
|
|
96
96
|
}
|
|
97
97
|
const description = {
|
|
98
98
|
// Make a copy of it to be sure it's proper JSON.
|
|
@@ -105,12 +105,12 @@ class SimpleScheduler {
|
|
|
105
105
|
};
|
|
106
106
|
const handlerWithExtra = Object.assign(handler.bind(undefined), {
|
|
107
107
|
jobDescription: description,
|
|
108
|
-
argumentV: this._schemaRegistry.compile(description.argument).pipe(operators_1.shareReplay(1)),
|
|
109
|
-
inputV: this._schemaRegistry.compile(description.input).pipe(operators_1.shareReplay(1)),
|
|
110
|
-
outputV: this._schemaRegistry.compile(description.output).pipe(operators_1.shareReplay(1)),
|
|
108
|
+
argumentV: this._schemaRegistry.compile(description.argument).pipe((0, operators_1.shareReplay)(1)),
|
|
109
|
+
inputV: this._schemaRegistry.compile(description.input).pipe((0, operators_1.shareReplay)(1)),
|
|
110
|
+
outputV: this._schemaRegistry.compile(description.output).pipe((0, operators_1.shareReplay)(1)),
|
|
111
111
|
});
|
|
112
112
|
this._internalJobDescriptionMap.set(name, handlerWithExtra);
|
|
113
|
-
return rxjs_1.of(handlerWithExtra);
|
|
113
|
+
return (0, rxjs_1.of)(handlerWithExtra);
|
|
114
114
|
}));
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
@@ -120,7 +120,7 @@ class SimpleScheduler {
|
|
|
120
120
|
* @returns A description, or null if the job is not registered.
|
|
121
121
|
*/
|
|
122
122
|
getDescription(name) {
|
|
123
|
-
return rxjs_1.concat(this._getInternalDescription(name).pipe(operators_1.map((x) => x && x.jobDescription)), rxjs_1.of(null)).pipe(operators_1.first());
|
|
123
|
+
return (0, rxjs_1.concat)(this._getInternalDescription(name).pipe((0, operators_1.map)((x) => x && x.jobDescription)), (0, rxjs_1.of)(null)).pipe((0, operators_1.first)());
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Returns true if the job name has been registered.
|
|
@@ -128,7 +128,7 @@ class SimpleScheduler {
|
|
|
128
128
|
* @returns True if the job exists, false otherwise.
|
|
129
129
|
*/
|
|
130
130
|
has(name) {
|
|
131
|
-
return this.getDescription(name).pipe(operators_1.map((x) => x !== null));
|
|
131
|
+
return this.getDescription(name).pipe((0, operators_1.map)((x) => x !== null));
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Pause the scheduler, temporary queueing _new_ jobs. Returns a resume function that should be
|
|
@@ -211,21 +211,21 @@ class SimpleScheduler {
|
|
|
211
211
|
// Create the input channel by having a filter.
|
|
212
212
|
const input = new rxjs_1.Subject();
|
|
213
213
|
input
|
|
214
|
-
.pipe(operators_1.concatMap((message) => handler.pipe(operators_1.switchMap((handler) => {
|
|
214
|
+
.pipe((0, operators_1.concatMap)((message) => handler.pipe((0, operators_1.switchMap)((handler) => {
|
|
215
215
|
if (handler === null) {
|
|
216
216
|
throw new exception_1.JobDoesNotExistException(name);
|
|
217
217
|
}
|
|
218
218
|
else {
|
|
219
|
-
return handler.inputV.pipe(operators_1.switchMap((validate) => validate(message)));
|
|
219
|
+
return handler.inputV.pipe((0, operators_1.switchMap)((validate) => validate(message)));
|
|
220
220
|
}
|
|
221
|
-
}))), operators_1.filter((result) => result.success), operators_1.map((result) => result.data))
|
|
221
|
+
}))), (0, operators_1.filter)((result) => result.success), (0, operators_1.map)((result) => result.data))
|
|
222
222
|
.subscribe((value) => inboundBus.next({ kind: api_1.JobInboundMessageKind.Input, value }));
|
|
223
|
-
outboundBus = rxjs_1.concat(outboundBus,
|
|
223
|
+
outboundBus = (0, rxjs_1.concat)(outboundBus,
|
|
224
224
|
// Add an End message at completion. This will be filtered out if the job actually send an
|
|
225
225
|
// End.
|
|
226
|
-
handler.pipe(operators_1.switchMap((handler) => {
|
|
226
|
+
handler.pipe((0, operators_1.switchMap)((handler) => {
|
|
227
227
|
if (handler) {
|
|
228
|
-
return rxjs_1.of({
|
|
228
|
+
return (0, rxjs_1.of)({
|
|
229
229
|
kind: api_1.JobOutboundMessageKind.End,
|
|
230
230
|
description: handler.jobDescription,
|
|
231
231
|
});
|
|
@@ -233,9 +233,9 @@ class SimpleScheduler {
|
|
|
233
233
|
else {
|
|
234
234
|
return rxjs_1.EMPTY;
|
|
235
235
|
}
|
|
236
|
-
}))).pipe(operators_1.filter((message) => this._filterJobOutboundMessages(message, state)),
|
|
236
|
+
}))).pipe((0, operators_1.filter)((message) => this._filterJobOutboundMessages(message, state)),
|
|
237
237
|
// Update internal logic and Job<> members.
|
|
238
|
-
operators_1.tap((message) => {
|
|
238
|
+
(0, operators_1.tap)((message) => {
|
|
239
239
|
// Update the state.
|
|
240
240
|
state = this._updateState(message, state);
|
|
241
241
|
switch (message.kind) {
|
|
@@ -278,20 +278,20 @@ class SimpleScheduler {
|
|
|
278
278
|
}),
|
|
279
279
|
// Do output validation (might include default values so this might have side
|
|
280
280
|
// effects). We keep all messages in order.
|
|
281
|
-
operators_1.concatMap((message) => {
|
|
281
|
+
(0, operators_1.concatMap)((message) => {
|
|
282
282
|
if (message.kind !== api_1.JobOutboundMessageKind.Output) {
|
|
283
|
-
return rxjs_1.of(message);
|
|
283
|
+
return (0, rxjs_1.of)(message);
|
|
284
284
|
}
|
|
285
|
-
return handler.pipe(operators_1.switchMap((handler) => {
|
|
285
|
+
return handler.pipe((0, operators_1.switchMap)((handler) => {
|
|
286
286
|
if (handler === null) {
|
|
287
287
|
throw new exception_1.JobDoesNotExistException(name);
|
|
288
288
|
}
|
|
289
289
|
else {
|
|
290
|
-
return handler.outputV.pipe(operators_1.switchMap((validate) => validate(message.value)), operators_1.switchMap((output) => {
|
|
290
|
+
return handler.outputV.pipe((0, operators_1.switchMap)((validate) => validate(message.value)), (0, operators_1.switchMap)((output) => {
|
|
291
291
|
if (!output.success) {
|
|
292
292
|
throw new JobOutputSchemaValidationError(output.errors);
|
|
293
293
|
}
|
|
294
|
-
return rxjs_1.of({
|
|
294
|
+
return (0, rxjs_1.of)({
|
|
295
295
|
...message,
|
|
296
296
|
output: output.data,
|
|
297
297
|
});
|
|
@@ -299,19 +299,19 @@ class SimpleScheduler {
|
|
|
299
299
|
}
|
|
300
300
|
}));
|
|
301
301
|
}), _jobShare());
|
|
302
|
-
const output = outboundBus.pipe(operators_1.filter((x) => x.kind == api_1.JobOutboundMessageKind.Output), operators_1.map((x) => x.value), operators_1.shareReplay(1));
|
|
302
|
+
const output = outboundBus.pipe((0, operators_1.filter)((x) => x.kind == api_1.JobOutboundMessageKind.Output), (0, operators_1.map)((x) => x.value), (0, operators_1.shareReplay)(1));
|
|
303
303
|
// Return the Job.
|
|
304
304
|
return {
|
|
305
305
|
get state() {
|
|
306
306
|
return state;
|
|
307
307
|
},
|
|
308
308
|
argument,
|
|
309
|
-
description: handler.pipe(operators_1.switchMap((handler) => {
|
|
309
|
+
description: handler.pipe((0, operators_1.switchMap)((handler) => {
|
|
310
310
|
if (handler === null) {
|
|
311
311
|
throw new exception_1.JobDoesNotExistException(name);
|
|
312
312
|
}
|
|
313
313
|
else {
|
|
314
|
-
return rxjs_1.of(handler.jobDescription);
|
|
314
|
+
return (0, rxjs_1.of)(handler.jobDescription);
|
|
315
315
|
}
|
|
316
316
|
})),
|
|
317
317
|
output,
|
|
@@ -325,14 +325,14 @@ class SimpleScheduler {
|
|
|
325
325
|
}
|
|
326
326
|
return maybeObservable.pipe(
|
|
327
327
|
// Keep the order of messages.
|
|
328
|
-
operators_1.concatMap((message) => {
|
|
329
|
-
return schemaRegistry.compile(schema).pipe(operators_1.switchMap((validate) => validate(message)), operators_1.filter((x) => x.success), operators_1.map((x) => x.data));
|
|
328
|
+
(0, operators_1.concatMap)((message) => {
|
|
329
|
+
return schemaRegistry.compile(schema).pipe((0, operators_1.switchMap)((validate) => validate(message)), (0, operators_1.filter)((x) => x.success), (0, operators_1.map)((x) => x.data));
|
|
330
330
|
}));
|
|
331
331
|
},
|
|
332
332
|
ping() {
|
|
333
333
|
const id = pingId++;
|
|
334
334
|
inboundBus.next({ kind: api_1.JobInboundMessageKind.Ping, id });
|
|
335
|
-
return outboundBus.pipe(operators_1.filter((x) => x.kind === api_1.JobOutboundMessageKind.Pong && x.id == id), operators_1.first(), operators_1.ignoreElements());
|
|
335
|
+
return outboundBus.pipe((0, operators_1.filter)((x) => x.kind === api_1.JobOutboundMessageKind.Pong && x.id == id), (0, operators_1.first)(), (0, operators_1.ignoreElements)());
|
|
336
336
|
},
|
|
337
337
|
stop() {
|
|
338
338
|
inboundBus.next({ kind: api_1.JobInboundMessageKind.Stop });
|
|
@@ -348,18 +348,18 @@ class SimpleScheduler {
|
|
|
348
348
|
const optionsDeps = (options && options.dependencies) || [];
|
|
349
349
|
const dependencies = Array.isArray(optionsDeps) ? optionsDeps : [optionsDeps];
|
|
350
350
|
const inboundBus = new rxjs_1.Subject();
|
|
351
|
-
const outboundBus = rxjs_1.concat(
|
|
351
|
+
const outboundBus = (0, rxjs_1.concat)(
|
|
352
352
|
// Wait for dependencies, make sure to not report messages from dependencies. Subscribe to
|
|
353
353
|
// all dependencies at the same time so they run concurrently.
|
|
354
|
-
rxjs_1.merge(...dependencies.map((x) => x.outboundBus)).pipe(operators_1.ignoreElements()),
|
|
354
|
+
(0, rxjs_1.merge)(...dependencies.map((x) => x.outboundBus)).pipe((0, operators_1.ignoreElements)()),
|
|
355
355
|
// Wait for pause() to clear (if necessary).
|
|
356
|
-
waitable, rxjs_1.from(handler).pipe(operators_1.switchMap((handler) => new rxjs_1.Observable((subscriber) => {
|
|
356
|
+
waitable, (0, rxjs_1.from)(handler).pipe((0, operators_1.switchMap)((handler) => new rxjs_1.Observable((subscriber) => {
|
|
357
357
|
if (!handler) {
|
|
358
358
|
throw new exception_1.JobDoesNotExistException(name);
|
|
359
359
|
}
|
|
360
360
|
// Validate the argument.
|
|
361
361
|
return handler.argumentV
|
|
362
|
-
.pipe(operators_1.switchMap((validate) => validate(argument)), operators_1.switchMap((output) => {
|
|
362
|
+
.pipe((0, operators_1.switchMap)((validate) => validate(argument)), (0, operators_1.switchMap)((output) => {
|
|
363
363
|
if (!output.success) {
|
|
364
364
|
throw new JobArgumentSchemaValidationError(output.errors);
|
|
365
365
|
}
|
|
@@ -19,11 +19,11 @@ var strategy;
|
|
|
19
19
|
* Creates a JobStrategy that serializes every call. This strategy can be mixed between jobs.
|
|
20
20
|
*/
|
|
21
21
|
function serialize() {
|
|
22
|
-
let latest = rxjs_1.of();
|
|
22
|
+
let latest = (0, rxjs_1.of)();
|
|
23
23
|
return (handler, options) => {
|
|
24
24
|
const newHandler = (argument, context) => {
|
|
25
25
|
const previous = latest;
|
|
26
|
-
latest = rxjs_1.concat(previous.pipe(operators_1.ignoreElements()), new rxjs_1.Observable((o) => handler(argument, context).subscribe(o))).pipe(operators_1.shareReplay(0));
|
|
26
|
+
latest = (0, rxjs_1.concat)(previous.pipe((0, operators_1.ignoreElements)()), new rxjs_1.Observable((o) => handler(argument, context).subscribe(o))).pipe((0, operators_1.shareReplay)(0));
|
|
27
27
|
return latest;
|
|
28
28
|
};
|
|
29
29
|
return Object.assign(newHandler, {
|
|
@@ -46,11 +46,11 @@ var strategy;
|
|
|
46
46
|
// Forward inputs.
|
|
47
47
|
const subscription = context.inboundBus.subscribe(inboundBus);
|
|
48
48
|
if (run) {
|
|
49
|
-
return rxjs_1.concat(
|
|
49
|
+
return (0, rxjs_1.concat)(
|
|
50
50
|
// Update state.
|
|
51
|
-
rxjs_1.of(state), run).pipe(operators_1.finalize(() => subscription.unsubscribe()));
|
|
51
|
+
(0, rxjs_1.of)(state), run).pipe((0, operators_1.finalize)(() => subscription.unsubscribe()));
|
|
52
52
|
}
|
|
53
|
-
run = handler(argument, { ...context, inboundBus: inboundBus.asObservable() }).pipe(operators_1.tap((message) => {
|
|
53
|
+
run = handler(argument, { ...context, inboundBus: inboundBus.asObservable() }).pipe((0, operators_1.tap)((message) => {
|
|
54
54
|
if (message.kind == api_1.JobOutboundMessageKind.Start ||
|
|
55
55
|
message.kind == api_1.JobOutboundMessageKind.OnReady ||
|
|
56
56
|
message.kind == api_1.JobOutboundMessageKind.End) {
|
|
@@ -60,7 +60,7 @@ var strategy;
|
|
|
60
60
|
subscription.unsubscribe();
|
|
61
61
|
inboundBus = new rxjs_1.Subject();
|
|
62
62
|
run = null;
|
|
63
|
-
}), replayMessages ? operators_1.shareReplay() : operators_1.share());
|
|
63
|
+
}), replayMessages ? (0, operators_1.shareReplay)() : (0, operators_1.share)());
|
|
64
64
|
return run;
|
|
65
65
|
};
|
|
66
66
|
return Object.assign(newHandler, handler, options || {});
|
|
@@ -81,7 +81,7 @@ var strategy;
|
|
|
81
81
|
if (maybeJob) {
|
|
82
82
|
return maybeJob;
|
|
83
83
|
}
|
|
84
|
-
const run = handler(argument, context).pipe(replayMessages ? operators_1.shareReplay() : operators_1.share());
|
|
84
|
+
const run = handler(argument, context).pipe(replayMessages ? (0, operators_1.shareReplay)() : (0, operators_1.share)());
|
|
85
85
|
runs.set(argumentJson, run);
|
|
86
86
|
return run;
|
|
87
87
|
};
|