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.
Files changed (92) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/core/types/Component.d.ts +1 -1
  3. package/dist/core/types/FlexObject.d.ts +1 -1
  4. package/dist/core/types/Module.d.ts +1 -1
  5. package/dist/core/types/SegmentImplementation.d.ts +1 -1
  6. package/dist/core/types/SegmentModule.d.ts +1 -1
  7. package/dist/core/types/SegmentProcedure.d.ts +1 -1
  8. package/dist/lib.d.ts +28 -1
  9. package/dist/lib.js +25 -1
  10. package/dist/runtime/LocalGateway.d.ts +2 -0
  11. package/dist/runtime/LocalGateway.js +7 -0
  12. package/dist/runtime/caching/types/SegmentFile.d.ts +1 -1
  13. package/dist/runtime/caching/types/SegmentImportProperties.d.ts +1 -1
  14. package/dist/runtime/caching/types/SegmentImports.d.ts +1 -1
  15. package/dist/runtime/serialization/ArrayBufferSerializer.d.ts +10 -0
  16. package/dist/runtime/serialization/ArrayBufferSerializer.js +54 -0
  17. package/dist/runtime/serialization/DateSerializer.d.ts +9 -0
  18. package/dist/runtime/serialization/DateSerializer.js +21 -0
  19. package/dist/runtime/serialization/ValueSerializer.d.ts +1 -0
  20. package/dist/runtime/serialization/ValueSerializer.js +24 -1
  21. package/dist/runtime/serialization/types/SerializableObject.d.ts +1 -1
  22. package/dist/runtime/serialization/types/Serialized.d.ts +1 -1
  23. package/dist/runtime/serialization/types/SerializedArrayBuffer.d.ts +6 -0
  24. package/dist/runtime/serialization/types/SerializedArrayBuffer.js +1 -0
  25. package/dist/runtime/serialization/types/SerializedClass.d.ts +1 -1
  26. package/dist/runtime/serialization/types/SerializedDate.d.ts +5 -0
  27. package/dist/runtime/serialization/types/SerializedDate.js +1 -0
  28. package/dist/runtime/serialization/types/SerializedMap.d.ts +1 -1
  29. package/dist/runtime/serialization/types/SerializedObject.d.ts +1 -1
  30. package/dist/runtime/serialization/types/SerializedSet.d.ts +1 -1
  31. package/dist/runtime/serialization/types/TypedArray.d.ts +2 -0
  32. package/dist/runtime/serialization/types/TypedArray.js +1 -0
  33. package/dist/runtime/types/JitarHooks.d.ts +1 -1
  34. package/dist/runtime/types/ModuleImporter.d.ts +1 -1
  35. package/dist/runtime/utils/ModuleLoader.js +1 -1
  36. package/package.json +4 -22
  37. package/dist/server/JitarServer.d.ts +0 -8
  38. package/dist/server/JitarServer.js +0 -109
  39. package/dist/server/configuration/GatewayConfiguration.d.ts +0 -3
  40. package/dist/server/configuration/GatewayConfiguration.js +0 -18
  41. package/dist/server/configuration/NodeConfiguration.d.ts +0 -5
  42. package/dist/server/configuration/NodeConfiguration.js +0 -28
  43. package/dist/server/configuration/ProxyConfiguration.d.ts +0 -5
  44. package/dist/server/configuration/ProxyConfiguration.js +0 -29
  45. package/dist/server/configuration/RepositoryConfiguration.d.ts +0 -6
  46. package/dist/server/configuration/RepositoryConfiguration.js +0 -36
  47. package/dist/server/configuration/RuntimeConfiguration.d.ts +0 -13
  48. package/dist/server/configuration/RuntimeConfiguration.js +0 -48
  49. package/dist/server/configuration/ServerOptions.d.ts +0 -4
  50. package/dist/server/configuration/ServerOptions.js +0 -25
  51. package/dist/server/configuration/StandaloneConfiguration.d.ts +0 -7
  52. package/dist/server/configuration/StandaloneConfiguration.js +0 -42
  53. package/dist/server/controllers/AssetsController.d.ts +0 -8
  54. package/dist/server/controllers/AssetsController.js +0 -50
  55. package/dist/server/controllers/HealthController.d.ts +0 -10
  56. package/dist/server/controllers/HealthController.js +0 -47
  57. package/dist/server/controllers/JitarController.d.ts +0 -4
  58. package/dist/server/controllers/JitarController.js +0 -26
  59. package/dist/server/controllers/ModulesController.d.ts +0 -10
  60. package/dist/server/controllers/ModulesController.js +0 -68
  61. package/dist/server/controllers/NodesController.d.ts +0 -9
  62. package/dist/server/controllers/NodesController.js +0 -60
  63. package/dist/server/controllers/ProceduresController.d.ts +0 -10
  64. package/dist/server/controllers/ProceduresController.js +0 -35
  65. package/dist/server/controllers/ProxyController.d.ts +0 -7
  66. package/dist/server/controllers/ProxyController.js +0 -37
  67. package/dist/server/controllers/RPCController.d.ts +0 -9
  68. package/dist/server/controllers/RPCController.js +0 -146
  69. package/dist/server/definitions/RuntimeDefaults.d.ts +0 -7
  70. package/dist/server/definitions/RuntimeDefaults.js +0 -8
  71. package/dist/server/errors/MissingConfigurationValue.d.ts +0 -3
  72. package/dist/server/errors/MissingConfigurationValue.js +0 -5
  73. package/dist/server/errors/RuntimeNotAvaiable.d.ts +0 -3
  74. package/dist/server/errors/RuntimeNotAvaiable.js +0 -5
  75. package/dist/server/errors/UnknownRuntimeMode.d.ts +0 -3
  76. package/dist/server/errors/UnknownRuntimeMode.js +0 -5
  77. package/dist/server/models/HealthDto.d.ts +0 -4
  78. package/dist/server/models/HealthDto.js +0 -22
  79. package/dist/server/models/NodeDto.d.ts +0 -4
  80. package/dist/server/models/NodeDto.js +0 -22
  81. package/dist/server/utils/DataConverter.d.ts +0 -4
  82. package/dist/server/utils/DataConverter.js +0 -9
  83. package/dist/server/utils/LocalFileManager.d.ts +0 -21
  84. package/dist/server/utils/LocalFileManager.js +0 -81
  85. package/dist/server/utils/RuntimeConfigurationLoader.d.ts +0 -4
  86. package/dist/server/utils/RuntimeConfigurationLoader.js +0 -11
  87. package/dist/server/utils/RuntimeConfigurator.d.ts +0 -6
  88. package/dist/server/utils/RuntimeConfigurator.js +0 -135
  89. package/dist/server/utils/ServerOptionsReader.d.ts +0 -4
  90. package/dist/server/utils/ServerOptionsReader.js +0 -10
  91. package/dist/server.d.ts +0 -3
  92. 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,4 +0,0 @@
1
- import ServerOptions from '../configuration/ServerOptions.js';
2
- export default class ServerOptionsReader {
3
- static read(): Promise<ServerOptions>;
4
- }
@@ -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
@@ -1,3 +0,0 @@
1
- import ModuleImporter from './runtime/types/ModuleImporter.js';
2
- import JitarServer from './server/JitarServer.js';
3
- export declare function startServer(moduleImporter: ModuleImporter): Promise<JitarServer>;
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
- }