jitar 0.1.3 → 0.2.1
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/CHANGELOG.md +49 -0
- package/dist/core/types/Component.d.ts +1 -1
- package/dist/core/types/FlexObject.d.ts +1 -1
- package/dist/core/types/Module.d.ts +1 -1
- package/dist/core/types/SegmentImplementation.d.ts +1 -1
- package/dist/core/types/SegmentModule.d.ts +1 -1
- package/dist/core/types/SegmentProcedure.d.ts +1 -1
- package/dist/lib.d.ts +28 -1
- package/dist/lib.js +25 -1
- package/dist/runtime/LocalGateway.d.ts +2 -0
- package/dist/runtime/LocalGateway.js +7 -0
- package/dist/runtime/caching/types/SegmentFile.d.ts +1 -1
- package/dist/runtime/caching/types/SegmentImportProperties.d.ts +1 -1
- package/dist/runtime/caching/types/SegmentImports.d.ts +1 -1
- package/dist/runtime/serialization/ArrayBufferSerializer.d.ts +10 -0
- package/dist/runtime/serialization/ArrayBufferSerializer.js +54 -0
- package/dist/runtime/serialization/DateSerializer.d.ts +9 -0
- package/dist/runtime/serialization/DateSerializer.js +21 -0
- package/dist/runtime/serialization/ValueSerializer.d.ts +1 -0
- package/dist/runtime/serialization/ValueSerializer.js +24 -1
- package/dist/runtime/serialization/types/SerializableObject.d.ts +1 -1
- package/dist/runtime/serialization/types/Serialized.d.ts +1 -1
- package/dist/runtime/serialization/types/SerializedArrayBuffer.d.ts +6 -0
- package/dist/runtime/serialization/types/SerializedArrayBuffer.js +1 -0
- package/dist/runtime/serialization/types/SerializedClass.d.ts +1 -1
- package/dist/runtime/serialization/types/SerializedDate.d.ts +5 -0
- package/dist/runtime/serialization/types/SerializedDate.js +1 -0
- package/dist/runtime/serialization/types/SerializedMap.d.ts +1 -1
- package/dist/runtime/serialization/types/SerializedObject.d.ts +1 -1
- package/dist/runtime/serialization/types/SerializedSet.d.ts +1 -1
- package/dist/runtime/serialization/types/TypedArray.d.ts +2 -0
- package/dist/runtime/serialization/types/TypedArray.js +1 -0
- package/dist/runtime/types/JitarHooks.d.ts +1 -1
- package/dist/runtime/types/ModuleImporter.d.ts +1 -1
- package/dist/runtime/utils/ModuleLoader.js +1 -1
- package/package.json +4 -22
- package/dist/server/JitarServer.d.ts +0 -8
- package/dist/server/JitarServer.js +0 -109
- package/dist/server/configuration/GatewayConfiguration.d.ts +0 -3
- package/dist/server/configuration/GatewayConfiguration.js +0 -18
- package/dist/server/configuration/NodeConfiguration.d.ts +0 -5
- package/dist/server/configuration/NodeConfiguration.js +0 -28
- package/dist/server/configuration/ProxyConfiguration.d.ts +0 -5
- package/dist/server/configuration/ProxyConfiguration.js +0 -29
- package/dist/server/configuration/RepositoryConfiguration.d.ts +0 -6
- package/dist/server/configuration/RepositoryConfiguration.js +0 -36
- package/dist/server/configuration/RuntimeConfiguration.d.ts +0 -13
- package/dist/server/configuration/RuntimeConfiguration.js +0 -48
- package/dist/server/configuration/ServerOptions.d.ts +0 -4
- package/dist/server/configuration/ServerOptions.js +0 -25
- package/dist/server/configuration/StandaloneConfiguration.d.ts +0 -7
- package/dist/server/configuration/StandaloneConfiguration.js +0 -42
- package/dist/server/controllers/AssetsController.d.ts +0 -8
- package/dist/server/controllers/AssetsController.js +0 -50
- package/dist/server/controllers/HealthController.d.ts +0 -10
- package/dist/server/controllers/HealthController.js +0 -47
- package/dist/server/controllers/JitarController.d.ts +0 -4
- package/dist/server/controllers/JitarController.js +0 -26
- package/dist/server/controllers/ModulesController.d.ts +0 -10
- package/dist/server/controllers/ModulesController.js +0 -68
- package/dist/server/controllers/NodesController.d.ts +0 -9
- package/dist/server/controllers/NodesController.js +0 -60
- package/dist/server/controllers/ProceduresController.d.ts +0 -10
- package/dist/server/controllers/ProceduresController.js +0 -35
- package/dist/server/controllers/ProxyController.d.ts +0 -7
- package/dist/server/controllers/ProxyController.js +0 -37
- package/dist/server/controllers/RPCController.d.ts +0 -9
- package/dist/server/controllers/RPCController.js +0 -146
- package/dist/server/definitions/RuntimeDefaults.d.ts +0 -7
- package/dist/server/definitions/RuntimeDefaults.js +0 -8
- package/dist/server/errors/MissingConfigurationValue.d.ts +0 -3
- package/dist/server/errors/MissingConfigurationValue.js +0 -5
- package/dist/server/errors/RuntimeNotAvaiable.d.ts +0 -3
- package/dist/server/errors/RuntimeNotAvaiable.js +0 -5
- package/dist/server/errors/UnknownRuntimeMode.d.ts +0 -3
- package/dist/server/errors/UnknownRuntimeMode.js +0 -5
- package/dist/server/models/HealthDto.d.ts +0 -4
- package/dist/server/models/HealthDto.js +0 -22
- package/dist/server/models/NodeDto.d.ts +0 -4
- package/dist/server/models/NodeDto.js +0 -22
- package/dist/server/utils/DataConverter.d.ts +0 -4
- package/dist/server/utils/DataConverter.js +0 -9
- package/dist/server/utils/LocalFileManager.d.ts +0 -21
- package/dist/server/utils/LocalFileManager.js +0 -81
- package/dist/server/utils/RuntimeConfigurationLoader.d.ts +0 -4
- package/dist/server/utils/RuntimeConfigurationLoader.js +0 -11
- package/dist/server/utils/RuntimeConfigurator.d.ts +0 -6
- package/dist/server/utils/RuntimeConfigurator.js +0 -135
- package/dist/server/utils/ServerOptionsReader.d.ts +0 -4
- package/dist/server/utils/ServerOptionsReader.js +0 -10
- package/dist/server.d.ts +0 -3
- package/dist/server.js +0 -8
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import CacheBuilder from '../../runtime/caching/CacheBuilder.js';
|
|
2
|
-
import LocalGateway from '../../runtime/LocalGateway.js';
|
|
3
|
-
import LocalNode from '../../runtime/LocalNode.js';
|
|
4
|
-
import LocalRepository from '../../runtime/LocalRepository.js';
|
|
5
|
-
import NodeMonitor from '../../runtime/NodeMonitor.js';
|
|
6
|
-
import Proxy from '../../runtime/Proxy.js';
|
|
7
|
-
import RemoteGateway from '../../runtime/RemoteGateway.js';
|
|
8
|
-
import RemoteNode from '../../runtime/RemoteNode.js';
|
|
9
|
-
import RemoteRepository from '../../runtime/RemoteRepository.js';
|
|
10
|
-
import LocalFileManager from './LocalFileManager.js';
|
|
11
|
-
import RuntimeDefaults from '../definitions/RuntimeDefaults.js';
|
|
12
|
-
import MissingConfigurationValue from '../errors/MissingConfigurationValue.js';
|
|
13
|
-
import UnknownRuntimeMode from '../errors/UnknownRuntimeMode.js';
|
|
14
|
-
export default class RuntimeConfigurator {
|
|
15
|
-
static async configure(configuration) {
|
|
16
|
-
const url = configuration.url ?? RuntimeDefaults.URL;
|
|
17
|
-
if (configuration.standalone !== undefined)
|
|
18
|
-
return this.#configureStandAlone(url, configuration.standalone);
|
|
19
|
-
if (configuration.repository !== undefined)
|
|
20
|
-
return this.#configureRepository(url, configuration.repository);
|
|
21
|
-
if (configuration.gateway !== undefined)
|
|
22
|
-
return this.#configureGateway(url, configuration.gateway);
|
|
23
|
-
if (configuration.node !== undefined)
|
|
24
|
-
return this.#configureNode(url, configuration.node);
|
|
25
|
-
if (configuration.proxy !== undefined)
|
|
26
|
-
return this.#configureProxy(url, configuration.proxy);
|
|
27
|
-
throw new UnknownRuntimeMode();
|
|
28
|
-
}
|
|
29
|
-
static async #configureStandAlone(url, configuration) {
|
|
30
|
-
const sourceLocation = configuration.source ?? RuntimeDefaults.SOURCE;
|
|
31
|
-
const cacheLocation = configuration.cache ?? RuntimeDefaults.CACHE;
|
|
32
|
-
const assetFilePatterns = configuration.assets;
|
|
33
|
-
await this.#buildCache(sourceLocation, cacheLocation);
|
|
34
|
-
const segmentNames = configuration.segments === undefined
|
|
35
|
-
? await this.#getSegmentNames(cacheLocation)
|
|
36
|
-
: configuration.segments;
|
|
37
|
-
const repository = await this.#buildRepository(url, cacheLocation, assetFilePatterns);
|
|
38
|
-
const node = await this.#buildNode(url, segmentNames, repository);
|
|
39
|
-
return this.#buildProxy(url, repository, node);
|
|
40
|
-
}
|
|
41
|
-
static async #configureRepository(url, configuration) {
|
|
42
|
-
const sourceLocation = configuration.source ?? RuntimeDefaults.SOURCE;
|
|
43
|
-
const cacheLocation = configuration.cache ?? RuntimeDefaults.CACHE;
|
|
44
|
-
const assetFilePatterns = configuration.assets ?? [];
|
|
45
|
-
await this.#buildCache(sourceLocation, cacheLocation);
|
|
46
|
-
return this.#buildRepository(url, cacheLocation, assetFilePatterns);
|
|
47
|
-
}
|
|
48
|
-
static async #configureGateway(url, configuration) {
|
|
49
|
-
return this.#buildGateway(url, configuration.monitor);
|
|
50
|
-
}
|
|
51
|
-
static async #configureNode(url, configuration) {
|
|
52
|
-
const segmentNames = configuration.segments ?? [];
|
|
53
|
-
const repository = configuration.repository !== undefined
|
|
54
|
-
? new RemoteRepository(configuration.repository)
|
|
55
|
-
: undefined;
|
|
56
|
-
const gateway = configuration.gateway !== undefined
|
|
57
|
-
? new RemoteGateway(configuration.gateway)
|
|
58
|
-
: undefined;
|
|
59
|
-
return this.#buildNode(url, segmentNames, repository, gateway);
|
|
60
|
-
}
|
|
61
|
-
static async #configureProxy(url, configuration) {
|
|
62
|
-
if (configuration.repository === undefined) {
|
|
63
|
-
throw new MissingConfigurationValue('proxy.repository');
|
|
64
|
-
}
|
|
65
|
-
const repository = new RemoteRepository(configuration.repository);
|
|
66
|
-
const gateway = configuration.gateway !== undefined
|
|
67
|
-
? new RemoteGateway(configuration.gateway)
|
|
68
|
-
: undefined;
|
|
69
|
-
const node = configuration.node !== undefined
|
|
70
|
-
? new RemoteNode(configuration.node, [])
|
|
71
|
-
: undefined;
|
|
72
|
-
const runner = gateway ?? node;
|
|
73
|
-
if (runner === undefined) {
|
|
74
|
-
throw new MissingConfigurationValue('proxy.gateway or proxy.node');
|
|
75
|
-
}
|
|
76
|
-
return this.#buildProxy(url, repository, runner);
|
|
77
|
-
}
|
|
78
|
-
static async #buildCache(sourceLocation, cacheLocation) {
|
|
79
|
-
const rootManager = new LocalFileManager('./');
|
|
80
|
-
await rootManager.remove(cacheLocation);
|
|
81
|
-
await rootManager.copy(sourceLocation, cacheLocation);
|
|
82
|
-
const sourceManager = new LocalFileManager(sourceLocation);
|
|
83
|
-
const cacheManager = new LocalFileManager(cacheLocation);
|
|
84
|
-
const segmentFiles = await rootManager.getSegmentFiles();
|
|
85
|
-
const moduleFiles = await sourceManager.getModuleFileNames();
|
|
86
|
-
const cacheBuilder = new CacheBuilder(sourceManager, cacheManager);
|
|
87
|
-
await cacheBuilder.build(segmentFiles, moduleFiles);
|
|
88
|
-
return cacheManager;
|
|
89
|
-
}
|
|
90
|
-
static async #getSegmentNames(cacheLocation) {
|
|
91
|
-
const fileManager = new LocalFileManager(cacheLocation);
|
|
92
|
-
const segmentFilenames = await fileManager.getNodeSegmentFiles();
|
|
93
|
-
return segmentFilenames.map(filename => this.#extractSegmentName(filename));
|
|
94
|
-
}
|
|
95
|
-
static #extractSegmentName(filename) {
|
|
96
|
-
const name = filename.split('/').pop() ?? '';
|
|
97
|
-
const endIndex = name.indexOf('.segment');
|
|
98
|
-
return name.substring(0, endIndex);
|
|
99
|
-
}
|
|
100
|
-
static async #buildRepository(url, cacheLocation, assetFilePatterns) {
|
|
101
|
-
const fileManager = new LocalFileManager(cacheLocation);
|
|
102
|
-
const assetFiles = assetFilePatterns !== undefined
|
|
103
|
-
? await fileManager.getAssetFiles(assetFilePatterns)
|
|
104
|
-
: [];
|
|
105
|
-
const repository = new LocalRepository(fileManager, assetFiles, url);
|
|
106
|
-
const segmentFilenames = await fileManager.getRepositorySegmentFiles();
|
|
107
|
-
const segmentNames = segmentFilenames.map(filename => this.#extractSegmentName(filename));
|
|
108
|
-
for (const name of segmentNames) {
|
|
109
|
-
await repository.loadSegment(name);
|
|
110
|
-
}
|
|
111
|
-
return repository;
|
|
112
|
-
}
|
|
113
|
-
static async #buildGateway(url, monitorInterval) {
|
|
114
|
-
const gateway = new LocalGateway(url);
|
|
115
|
-
const monitor = new NodeMonitor(gateway, monitorInterval);
|
|
116
|
-
monitor.start();
|
|
117
|
-
return gateway;
|
|
118
|
-
}
|
|
119
|
-
static async #buildNode(url, segmentNames, repository, gateway) {
|
|
120
|
-
const node = new LocalNode(url);
|
|
121
|
-
if (repository !== undefined) {
|
|
122
|
-
await node.setRepository(repository, segmentNames);
|
|
123
|
-
}
|
|
124
|
-
for (const segmentName of segmentNames) {
|
|
125
|
-
await node.loadSegment(segmentName);
|
|
126
|
-
}
|
|
127
|
-
if (gateway !== undefined) {
|
|
128
|
-
node.setGateway(gateway);
|
|
129
|
-
}
|
|
130
|
-
return node;
|
|
131
|
-
}
|
|
132
|
-
static async #buildProxy(url, repository, runner) {
|
|
133
|
-
return new Proxy(repository, runner, url);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import yargs from 'yargs';
|
|
2
|
-
import ServerOptions from '../configuration/ServerOptions.js';
|
|
3
|
-
import DataConverter from './DataConverter.js';
|
|
4
|
-
export default class ServerOptionsReader {
|
|
5
|
-
static async read() {
|
|
6
|
-
const args = yargs(process.argv).argv;
|
|
7
|
-
const options = await DataConverter.convert(ServerOptions, args);
|
|
8
|
-
return options;
|
|
9
|
-
}
|
|
10
|
-
}
|
package/dist/server.d.ts
DELETED
package/dist/server.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import ModuleLoader from './runtime/utils/ModuleLoader.js';
|
|
2
|
-
import JitarServer from './server/JitarServer.js';
|
|
3
|
-
export async function startServer(moduleImporter) {
|
|
4
|
-
ModuleLoader.setImporter(moduleImporter);
|
|
5
|
-
const server = new JitarServer();
|
|
6
|
-
await server.start();
|
|
7
|
-
return server;
|
|
8
|
-
}
|