jitar 0.3.9 → 0.4.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/CHANGELOG.md +1 -94
- package/dist/client.js +1 -24
- package/dist/globals-d516de70.js +1 -0
- package/dist/lib.d.ts +309 -35
- package/dist/lib.js +1 -29
- package/dist/server.js +1 -0
- package/package.json +19 -12
- package/LICENCE +0 -23
- package/dist/client.d.ts +0 -3
- package/dist/core/Context.d.ts +0 -5
- package/dist/core/Context.js +0 -7
- package/dist/core/ErrorManager.d.ts +0 -3
- package/dist/core/ErrorManager.js +0 -11
- package/dist/core/Implementation.d.ts +0 -10
- package/dist/core/Implementation.js +0 -44
- package/dist/core/Procedure.d.ts +0 -13
- package/dist/core/Procedure.js +0 -58
- package/dist/core/Segment.d.ts +0 -13
- package/dist/core/Segment.js +0 -36
- package/dist/core/SegmentBuilder.d.ts +0 -6
- package/dist/core/SegmentBuilder.js +0 -32
- package/dist/core/Version.d.ts +0 -13
- package/dist/core/Version.js +0 -50
- package/dist/core/definitions/AccessLevel.d.ts +0 -2
- package/dist/core/definitions/AccessLevel.js +0 -2
- package/dist/core/errors/BadRequest.d.ts +0 -3
- package/dist/core/errors/BadRequest.js +0 -6
- package/dist/core/errors/Forbidden.d.ts +0 -3
- package/dist/core/errors/Forbidden.js +0 -6
- package/dist/core/errors/ImplementationNotFound.d.ts +0 -4
- package/dist/core/errors/ImplementationNotFound.js +0 -7
- package/dist/core/errors/InvalidVersionNumber.d.ts +0 -4
- package/dist/core/errors/InvalidVersionNumber.js +0 -7
- package/dist/core/errors/MissingParameterValue.d.ts +0 -4
- package/dist/core/errors/MissingParameterValue.js +0 -7
- package/dist/core/errors/NotFound.d.ts +0 -3
- package/dist/core/errors/NotFound.js +0 -6
- package/dist/core/errors/NotImplemented.d.ts +0 -3
- package/dist/core/errors/NotImplemented.js +0 -6
- package/dist/core/errors/PaymentRequired.d.ts +0 -3
- package/dist/core/errors/PaymentRequired.js +0 -6
- package/dist/core/errors/ProcedureNotFound.d.ts +0 -4
- package/dist/core/errors/ProcedureNotFound.js +0 -7
- package/dist/core/errors/Teapot.d.ts +0 -3
- package/dist/core/errors/Teapot.js +0 -6
- package/dist/core/errors/Unauthorized.d.ts +0 -3
- package/dist/core/errors/Unauthorized.js +0 -6
- package/dist/core/errors/UnknownParameter.d.ts +0 -4
- package/dist/core/errors/UnknownParameter.js +0 -7
- package/dist/core/interfaces/Runner.d.ts +0 -4
- package/dist/core/interfaces/Runner.js +0 -1
- package/dist/core/reflection/ParameterParser.d.ts +0 -5
- package/dist/core/reflection/ParameterParser.js +0 -51
- package/dist/core/reflection/ReflectionHelper.d.ts +0 -13
- package/dist/core/reflection/ReflectionHelper.js +0 -69
- package/dist/core/reflection/models/ReflectionField.d.ts +0 -8
- package/dist/core/reflection/models/ReflectionField.js +0 -14
- package/dist/core/reflection/models/ReflectionParameter.d.ts +0 -7
- package/dist/core/reflection/models/ReflectionParameter.js +0 -11
- package/dist/core/types/Component.d.ts +0 -5
- package/dist/core/types/Component.js +0 -1
- package/dist/core/types/FlexObject.d.ts +0 -4
- package/dist/core/types/FlexObject.js +0 -1
- package/dist/core/types/Module.d.ts +0 -3
- package/dist/core/types/Module.js +0 -1
- package/dist/core/types/SegmentImplementation.d.ts +0 -6
- package/dist/core/types/SegmentImplementation.js +0 -1
- package/dist/core/types/SegmentModule.d.ts +0 -5
- package/dist/core/types/SegmentModule.js +0 -1
- package/dist/core/types/SegmentProcedure.d.ts +0 -7
- package/dist/core/types/SegmentProcedure.js +0 -1
- package/dist/core/utils/FqnBuilder.d.ts +0 -3
- package/dist/core/utils/FqnBuilder.js +0 -5
- package/dist/hooks.d.ts +0 -2
- package/dist/hooks.js +0 -2
- package/dist/runtime/ClientId.d.ts +0 -4
- package/dist/runtime/ClientId.js +0 -11
- package/dist/runtime/Gateway.d.ts +0 -5
- package/dist/runtime/Gateway.js +0 -3
- package/dist/runtime/LocalGateway.d.ts +0 -14
- package/dist/runtime/LocalGateway.js +0 -61
- package/dist/runtime/LocalNode.d.ts +0 -18
- package/dist/runtime/LocalNode.js +0 -75
- package/dist/runtime/LocalRepository.d.ts +0 -17
- package/dist/runtime/LocalRepository.js +0 -94
- package/dist/runtime/Node.d.ts +0 -3
- package/dist/runtime/Node.js +0 -3
- package/dist/runtime/NodeBalancer.d.ts +0 -9
- package/dist/runtime/NodeBalancer.js +0 -34
- package/dist/runtime/NodeMonitor.d.ts +0 -7
- package/dist/runtime/NodeMonitor.js +0 -38
- package/dist/runtime/ProcedureRunner.d.ts +0 -9
- package/dist/runtime/ProcedureRunner.js +0 -11
- package/dist/runtime/ProcedureRuntime.d.ts +0 -14
- package/dist/runtime/ProcedureRuntime.js +0 -28
- package/dist/runtime/Proxy.d.ts +0 -18
- package/dist/runtime/Proxy.js +0 -33
- package/dist/runtime/Remote.d.ts +0 -15
- package/dist/runtime/Remote.js +0 -102
- package/dist/runtime/RemoteGateway.d.ts +0 -11
- package/dist/runtime/RemoteGateway.js +0 -22
- package/dist/runtime/RemoteNode.d.ts +0 -12
- package/dist/runtime/RemoteNode.js +0 -29
- package/dist/runtime/RemoteRepository.d.ts +0 -14
- package/dist/runtime/RemoteRepository.js +0 -34
- package/dist/runtime/Repository.d.ts +0 -11
- package/dist/runtime/Repository.js +0 -3
- package/dist/runtime/Runtime.d.ts +0 -9
- package/dist/runtime/Runtime.js +0 -27
- package/dist/runtime/caching/CacheBuilder.d.ts +0 -6
- package/dist/runtime/caching/CacheBuilder.js +0 -246
- package/dist/runtime/caching/ImportRewriter.d.ts +0 -4
- package/dist/runtime/caching/ImportRewriter.js +0 -58
- package/dist/runtime/caching/RemoteBuilder.d.ts +0 -5
- package/dist/runtime/caching/RemoteBuilder.js +0 -31
- package/dist/runtime/caching/SourceAppender.d.ts +0 -5
- package/dist/runtime/caching/SourceAppender.js +0 -30
- package/dist/runtime/caching/definitions/Keywords.d.ts +0 -2
- package/dist/runtime/caching/definitions/Keywords.js +0 -2
- package/dist/runtime/caching/errors/InvalidSegmentFilename.d.ts +0 -3
- package/dist/runtime/caching/errors/InvalidSegmentFilename.js +0 -5
- package/dist/runtime/caching/errors/MissingModuleExport.d.ts +0 -3
- package/dist/runtime/caching/errors/MissingModuleExport.js +0 -5
- package/dist/runtime/caching/errors/SegmentFileNotLoaded.d.ts +0 -3
- package/dist/runtime/caching/errors/SegmentFileNotLoaded.js +0 -5
- package/dist/runtime/caching/errors/SegmentModuleNotLoaded.d.ts +0 -3
- package/dist/runtime/caching/errors/SegmentModuleNotLoaded.js +0 -5
- package/dist/runtime/caching/models/ApplicationModule.d.ts +0 -10
- package/dist/runtime/caching/models/ApplicationModule.js +0 -19
- package/dist/runtime/caching/models/Implementation.d.ts +0 -12
- package/dist/runtime/caching/models/Implementation.js +0 -27
- package/dist/runtime/caching/models/Procedure.d.ts +0 -9
- package/dist/runtime/caching/models/Procedure.js +0 -15
- package/dist/runtime/caching/models/Segment.d.ts +0 -10
- package/dist/runtime/caching/models/Segment.js +0 -16
- package/dist/runtime/caching/models/SegmentModule.d.ts +0 -10
- package/dist/runtime/caching/models/SegmentModule.js +0 -14
- package/dist/runtime/caching/types/SegmentFile.d.ts +0 -5
- package/dist/runtime/caching/types/SegmentFile.js +0 -1
- package/dist/runtime/caching/types/SegmentImportProperties.d.ts +0 -6
- package/dist/runtime/caching/types/SegmentImportProperties.js +0 -1
- package/dist/runtime/caching/types/SegmentImports.d.ts +0 -5
- package/dist/runtime/caching/types/SegmentImports.js +0 -1
- package/dist/runtime/errors/ClientNotFound.d.ts +0 -3
- package/dist/runtime/errors/ClientNotFound.js +0 -6
- package/dist/runtime/errors/FileNotFound.d.ts +0 -3
- package/dist/runtime/errors/FileNotFound.js +0 -6
- package/dist/runtime/errors/InvalidClientId.d.ts +0 -3
- package/dist/runtime/errors/InvalidClientId.js +0 -6
- package/dist/runtime/errors/InvalidJitarHooks.d.ts +0 -3
- package/dist/runtime/errors/InvalidJitarHooks.js +0 -6
- package/dist/runtime/errors/InvalidSegmentFile.d.ts +0 -3
- package/dist/runtime/errors/InvalidSegmentFile.js +0 -6
- package/dist/runtime/errors/ModuleNotLoaded.d.ts +0 -3
- package/dist/runtime/errors/ModuleNotLoaded.js +0 -6
- package/dist/runtime/errors/NoNodeAvailable.d.ts +0 -3
- package/dist/runtime/errors/NoNodeAvailable.js +0 -6
- package/dist/runtime/errors/RepositoryNotAvaiable.d.ts +0 -3
- package/dist/runtime/errors/RepositoryNotAvaiable.js +0 -6
- package/dist/runtime/errors/RuntimeNotAvailable.d.ts +0 -3
- package/dist/runtime/errors/RuntimeNotAvailable.js +0 -6
- package/dist/runtime/errors/SegmentNotFound.d.ts +0 -3
- package/dist/runtime/errors/SegmentNotFound.js +0 -6
- package/dist/runtime/hooks/dependencies.d.ts +0 -2
- package/dist/runtime/hooks/dependencies.js +0 -9
- package/dist/runtime/hooks/runtime.d.ts +0 -3
- package/dist/runtime/hooks/runtime.js +0 -16
- package/dist/runtime/interfaces/FileManager.d.ts +0 -11
- package/dist/runtime/interfaces/FileManager.js +0 -1
- package/dist/runtime/interfaces/HealthCheck.d.ts +0 -3
- package/dist/runtime/interfaces/HealthCheck.js +0 -1
- package/dist/runtime/interfaces/Middleware.d.ts +0 -5
- package/dist/runtime/interfaces/Middleware.js +0 -1
- package/dist/runtime/middleware/CorsMiddleware.d.ts +0 -11
- package/dist/runtime/middleware/CorsMiddleware.js +0 -22
- package/dist/runtime/models/File.d.ts +0 -9
- package/dist/runtime/models/File.js +0 -14
- package/dist/runtime/serialization/ArrayBufferSerializer.d.ts +0 -10
- package/dist/runtime/serialization/ArrayBufferSerializer.js +0 -54
- package/dist/runtime/serialization/ArraySerializer.d.ts +0 -7
- package/dist/runtime/serialization/ArraySerializer.js +0 -15
- package/dist/runtime/serialization/ClassSerializer.d.ts +0 -10
- package/dist/runtime/serialization/ClassSerializer.js +0 -74
- package/dist/runtime/serialization/DateSerializer.d.ts +0 -9
- package/dist/runtime/serialization/DateSerializer.js +0 -21
- package/dist/runtime/serialization/MapSerializer.d.ts +0 -9
- package/dist/runtime/serialization/MapSerializer.js +0 -35
- package/dist/runtime/serialization/ObjectSerializer.d.ts +0 -9
- package/dist/runtime/serialization/ObjectSerializer.js +0 -21
- package/dist/runtime/serialization/SetSerializer.d.ts +0 -9
- package/dist/runtime/serialization/SetSerializer.js +0 -23
- package/dist/runtime/serialization/ValueSerializer.d.ts +0 -8
- package/dist/runtime/serialization/ValueSerializer.js +0 -69
- package/dist/runtime/serialization/errors/ClassNotFound.d.ts +0 -3
- package/dist/runtime/serialization/errors/ClassNotFound.js +0 -6
- package/dist/runtime/serialization/errors/InvalidClass.d.ts +0 -3
- package/dist/runtime/serialization/errors/InvalidClass.js +0 -6
- package/dist/runtime/serialization/errors/InvalidPropertyType.d.ts +0 -4
- package/dist/runtime/serialization/errors/InvalidPropertyType.js +0 -7
- package/dist/runtime/serialization/interfaces/Serializer.d.ts +0 -4
- package/dist/runtime/serialization/interfaces/Serializer.js +0 -1
- package/dist/runtime/serialization/types/SerializableObject.d.ts +0 -3
- package/dist/runtime/serialization/types/SerializableObject.js +0 -1
- package/dist/runtime/serialization/types/Serialized.d.ts +0 -5
- package/dist/runtime/serialization/types/Serialized.js +0 -1
- package/dist/runtime/serialization/types/SerializedArrayBuffer.d.ts +0 -6
- package/dist/runtime/serialization/types/SerializedArrayBuffer.js +0 -1
- package/dist/runtime/serialization/types/SerializedClass.d.ts +0 -8
- package/dist/runtime/serialization/types/SerializedClass.js +0 -1
- package/dist/runtime/serialization/types/SerializedDate.d.ts +0 -5
- package/dist/runtime/serialization/types/SerializedDate.js +0 -1
- package/dist/runtime/serialization/types/SerializedMap.d.ts +0 -8
- package/dist/runtime/serialization/types/SerializedMap.js +0 -1
- package/dist/runtime/serialization/types/SerializedObject.d.ts +0 -4
- package/dist/runtime/serialization/types/SerializedObject.js +0 -1
- package/dist/runtime/serialization/types/SerializedSet.d.ts +0 -5
- package/dist/runtime/serialization/types/SerializedSet.js +0 -1
- package/dist/runtime/serialization/types/TypedArray.d.ts +0 -2
- package/dist/runtime/serialization/types/TypedArray.js +0 -1
- package/dist/runtime/types/JitarHooks.d.ts +0 -6
- package/dist/runtime/types/JitarHooks.js +0 -1
- package/dist/runtime/types/ModuleImporter.d.ts +0 -3
- package/dist/runtime/types/ModuleImporter.js +0 -1
- package/dist/runtime/types/NextHandler.d.ts +0 -2
- package/dist/runtime/types/NextHandler.js +0 -1
- package/dist/runtime/utils/ModuleAnalyser.d.ts +0 -7
- package/dist/runtime/utils/ModuleAnalyser.js +0 -23
- package/dist/runtime/utils/ModuleLoader.d.ts +0 -8
- package/dist/runtime/utils/ModuleLoader.js +0 -30
- package/dist/runtime/utils/UrlRewriter.d.ts +0 -4
- package/dist/runtime/utils/UrlRewriter.js +0 -36
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import BadRequest from './BadRequest.js';
|
|
2
|
-
export default class MissingParameterValue extends BadRequest {
|
|
3
|
-
constructor(parameterName) {
|
|
4
|
-
super(`Missing value for parameter '${parameterName}'`);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
MissingParameterValue.source = '/jitar/core/errors/MissingParameterValue.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import ReflectionParameter from './models/ReflectionParameter.js';
|
|
2
|
-
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
|
|
3
|
-
export default class ParameterParser {
|
|
4
|
-
static parse(code, functionIndicator) {
|
|
5
|
-
const pureCode = this.#removeComments(code);
|
|
6
|
-
const parameterString = this.#extractParameterString(pureCode, functionIndicator);
|
|
7
|
-
const parameterList = this.#parseParamaterString(parameterString);
|
|
8
|
-
return parameterList.map(parameter => this.#extractParameter(parameter));
|
|
9
|
-
}
|
|
10
|
-
static #removeComments(code) {
|
|
11
|
-
return code.replace(STRIP_COMMENTS, '');
|
|
12
|
-
}
|
|
13
|
-
static #extractParameterString(code, functionIndicator) {
|
|
14
|
-
const indicatorPosition = code.indexOf(functionIndicator);
|
|
15
|
-
const bodyStart = code.indexOf('{', indicatorPosition);
|
|
16
|
-
const definition = code.substring(indicatorPosition, bodyStart).trim();
|
|
17
|
-
const startPosition = definition.indexOf('(') + 1;
|
|
18
|
-
const endPosition = definition.lastIndexOf(')', startPosition);
|
|
19
|
-
return definition.slice(startPosition, endPosition);
|
|
20
|
-
}
|
|
21
|
-
static #parseParamaterString(parameterString) {
|
|
22
|
-
const parameters = [];
|
|
23
|
-
let level = 0;
|
|
24
|
-
let buffer = '';
|
|
25
|
-
for (let character of parameterString) {
|
|
26
|
-
switch (character) {
|
|
27
|
-
case '(':
|
|
28
|
-
level++;
|
|
29
|
-
break;
|
|
30
|
-
case ')':
|
|
31
|
-
level--;
|
|
32
|
-
break;
|
|
33
|
-
case ',':
|
|
34
|
-
if (level === 0) {
|
|
35
|
-
parameters.push(buffer);
|
|
36
|
-
character = '';
|
|
37
|
-
buffer = '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
buffer += character;
|
|
41
|
-
}
|
|
42
|
-
if (buffer !== '') {
|
|
43
|
-
parameters.push(buffer);
|
|
44
|
-
}
|
|
45
|
-
return parameters;
|
|
46
|
-
}
|
|
47
|
-
static #extractParameter(parameter) {
|
|
48
|
-
const [name, defaultValue] = parameter.split('=').map(part => part.trim());
|
|
49
|
-
return new ReflectionParameter(name, defaultValue);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ReflectionField from './models/ReflectionField.js';
|
|
2
|
-
import ReflectionParameter from './models/ReflectionParameter.js';
|
|
3
|
-
export default class ReflectionHelper {
|
|
4
|
-
#private;
|
|
5
|
-
static createInstance(clazz: Function, args?: unknown[]): object;
|
|
6
|
-
static isClassObject(object: object): boolean;
|
|
7
|
-
static getObjectClass(object: object): Function;
|
|
8
|
-
static getParentClass(clazz: Function): Function;
|
|
9
|
-
static getFields(clazz: Function): ReflectionField[];
|
|
10
|
-
static getObjectFields(object: object): ReflectionField[];
|
|
11
|
-
static getConstructorParameters(clazz: Function): ReflectionParameter[];
|
|
12
|
-
static getFunctionParameters(funktion: Function): ReflectionParameter[];
|
|
13
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import ReflectionField from './models/ReflectionField.js';
|
|
2
|
-
import ParameterParser from './ParameterParser.js';
|
|
3
|
-
const CONSTRUCTOR_NAME = 'constructor';
|
|
4
|
-
const FUNCTION_NAME = 'function';
|
|
5
|
-
export default class ReflectionHelper {
|
|
6
|
-
static createInstance(clazz, args = []) {
|
|
7
|
-
return new clazz(...args);
|
|
8
|
-
}
|
|
9
|
-
static isClassObject(object) {
|
|
10
|
-
return object.constructor.toString().startsWith('class');
|
|
11
|
-
}
|
|
12
|
-
static getObjectClass(object) {
|
|
13
|
-
return object.constructor;
|
|
14
|
-
}
|
|
15
|
-
static getParentClass(clazz) {
|
|
16
|
-
return Object.getPrototypeOf(clazz);
|
|
17
|
-
}
|
|
18
|
-
static getFields(clazz) {
|
|
19
|
-
const object = this.createInstance(clazz);
|
|
20
|
-
const publicFields = this.#getPublicFields(object);
|
|
21
|
-
const propertyFields = this.#getPropertyFields(clazz);
|
|
22
|
-
return [...publicFields, ...propertyFields];
|
|
23
|
-
}
|
|
24
|
-
static getObjectFields(object) {
|
|
25
|
-
const clazz = this.getObjectClass(object);
|
|
26
|
-
const publicFields = this.#getPublicFields(object);
|
|
27
|
-
const propertyFields = this.#getPropertyFields(clazz);
|
|
28
|
-
return [...publicFields, ...propertyFields];
|
|
29
|
-
}
|
|
30
|
-
static #getPublicFields(object) {
|
|
31
|
-
const fieldNames = Object.getOwnPropertyNames(object);
|
|
32
|
-
return fieldNames.map(fieldName => new ReflectionField(fieldName, true, true));
|
|
33
|
-
}
|
|
34
|
-
static #getPropertyFields(clazz) {
|
|
35
|
-
const methods = Object.getOwnPropertyDescriptors(clazz.prototype);
|
|
36
|
-
const fields = [];
|
|
37
|
-
for (const name in methods) {
|
|
38
|
-
const description = methods[name];
|
|
39
|
-
const hasGetter = description.get !== undefined;
|
|
40
|
-
const hasSetter = description.set !== undefined;
|
|
41
|
-
if (hasGetter === false && hasSetter === false) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
fields.push(new ReflectionField(name, hasGetter, hasSetter));
|
|
45
|
-
}
|
|
46
|
-
const parentClazz = this.getParentClass(clazz);
|
|
47
|
-
if (parentClazz.name !== '') {
|
|
48
|
-
const parentFields = this.#getPropertyFields(parentClazz);
|
|
49
|
-
return [...fields, ...parentFields];
|
|
50
|
-
}
|
|
51
|
-
return fields;
|
|
52
|
-
}
|
|
53
|
-
static getConstructorParameters(clazz) {
|
|
54
|
-
const code = clazz.toString();
|
|
55
|
-
const hasConstructor = code.includes(CONSTRUCTOR_NAME);
|
|
56
|
-
if (hasConstructor === false) {
|
|
57
|
-
const parentClazz = this.getParentClass(clazz);
|
|
58
|
-
if (parentClazz.name === '') {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
return this.getConstructorParameters(parentClazz);
|
|
62
|
-
}
|
|
63
|
-
return ParameterParser.parse(code, CONSTRUCTOR_NAME);
|
|
64
|
-
}
|
|
65
|
-
static getFunctionParameters(funktion) {
|
|
66
|
-
const code = funktion.toString();
|
|
67
|
-
return ParameterParser.parse(code, FUNCTION_NAME);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default class ReflectionField {
|
|
2
|
-
#name;
|
|
3
|
-
#canGet;
|
|
4
|
-
#canSet;
|
|
5
|
-
constructor(name, canGet, canSet) {
|
|
6
|
-
this.#name = name;
|
|
7
|
-
this.#canGet = canGet;
|
|
8
|
-
this.#canSet = canSet;
|
|
9
|
-
}
|
|
10
|
-
get name() { return this.#name; }
|
|
11
|
-
get canGet() { return this.#canGet; }
|
|
12
|
-
get canSet() { return this.#canSet; }
|
|
13
|
-
get canGetAndSet() { return this.#canGet && this.#canSet; }
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default class ReflectionParameter {
|
|
2
|
-
#name;
|
|
3
|
-
#defaultValue;
|
|
4
|
-
constructor(name, defaultValue) {
|
|
5
|
-
this.#name = name;
|
|
6
|
-
this.#defaultValue = defaultValue;
|
|
7
|
-
}
|
|
8
|
-
get name() { return this.#name; }
|
|
9
|
-
get defaultValue() { return this.#defaultValue; }
|
|
10
|
-
get isOptional() { return this.#defaultValue !== undefined; }
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/hooks.d.ts
DELETED
package/dist/hooks.js
DELETED
package/dist/runtime/ClientId.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const CLIENT_ID_PREFIX = 'CLIENT_';
|
|
2
|
-
const CLIENT_ID_REGEX = /^CLIENT_\d+$/;
|
|
3
|
-
let lastClientId = 0;
|
|
4
|
-
export default class ClientId {
|
|
5
|
-
static generate() {
|
|
6
|
-
return `${CLIENT_ID_PREFIX}${lastClientId++}`;
|
|
7
|
-
}
|
|
8
|
-
static validate(clientId) {
|
|
9
|
-
return CLIENT_ID_REGEX.test(clientId);
|
|
10
|
-
}
|
|
11
|
-
}
|
package/dist/runtime/Gateway.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Version from '../core/Version.js';
|
|
2
|
-
import Gateway from './Gateway.js';
|
|
3
|
-
import Node from './Node.js';
|
|
4
|
-
import Repository from './Repository.js';
|
|
5
|
-
export default class LocalGateway extends Gateway {
|
|
6
|
-
#private;
|
|
7
|
-
get nodes(): Node[];
|
|
8
|
-
getProcedureNames(): string[];
|
|
9
|
-
hasProcedure(fqn: string): boolean;
|
|
10
|
-
addNode(node: Node): Promise<void>;
|
|
11
|
-
removeNode(node: Node): void;
|
|
12
|
-
setBaseUrl(repository: Repository): Promise<void>;
|
|
13
|
-
run(fqn: string, version: Version, args: Map<string, unknown>, headers: Map<string, string>): Promise<unknown>;
|
|
14
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import ProcedureNotFound from '../core/errors/ProcedureNotFound.js';
|
|
2
|
-
import Gateway from './Gateway.js';
|
|
3
|
-
import NodeBalancer from './NodeBalancer.js';
|
|
4
|
-
import ModuleLoader from './utils/ModuleLoader.js';
|
|
5
|
-
const NO_SEGMENTS = [];
|
|
6
|
-
export default class LocalGateway extends Gateway {
|
|
7
|
-
#nodes = new Set();
|
|
8
|
-
#balancers = new Map();
|
|
9
|
-
get nodes() {
|
|
10
|
-
return [...this.#nodes.values()];
|
|
11
|
-
}
|
|
12
|
-
getProcedureNames() {
|
|
13
|
-
const procedureNames = this.nodes.map(node => node.getProcedureNames());
|
|
14
|
-
const uniqueNames = new Set(procedureNames.flat());
|
|
15
|
-
return [...uniqueNames.values()];
|
|
16
|
-
}
|
|
17
|
-
hasProcedure(fqn) {
|
|
18
|
-
const procedureNames = this.getProcedureNames();
|
|
19
|
-
return procedureNames.includes(fqn);
|
|
20
|
-
}
|
|
21
|
-
async addNode(node) {
|
|
22
|
-
this.#nodes.add(node);
|
|
23
|
-
for (const name of node.getProcedureNames()) {
|
|
24
|
-
const balancer = this.#getOrCreateBalancer(name);
|
|
25
|
-
balancer.addNode(node);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
removeNode(node) {
|
|
29
|
-
this.#nodes.delete(node);
|
|
30
|
-
for (const name of node.getProcedureNames()) {
|
|
31
|
-
const balancer = this.#getBalancer(name);
|
|
32
|
-
if (balancer === undefined) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
balancer.removeNode(node);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async setBaseUrl(repository) {
|
|
39
|
-
const clientId = await repository.registerClient(NO_SEGMENTS);
|
|
40
|
-
const moduleLocation = await repository.getModuleLocation(clientId);
|
|
41
|
-
ModuleLoader.setBaseUrl(moduleLocation);
|
|
42
|
-
}
|
|
43
|
-
#getBalancer(fqn) {
|
|
44
|
-
return this.#balancers.get(fqn);
|
|
45
|
-
}
|
|
46
|
-
#getOrCreateBalancer(fqn) {
|
|
47
|
-
let balancer = this.#getBalancer(fqn);
|
|
48
|
-
if (balancer === undefined) {
|
|
49
|
-
balancer = new NodeBalancer();
|
|
50
|
-
this.#balancers.set(fqn, balancer);
|
|
51
|
-
}
|
|
52
|
-
return balancer;
|
|
53
|
-
}
|
|
54
|
-
async run(fqn, version, args, headers) {
|
|
55
|
-
const balancer = this.#getBalancer(fqn);
|
|
56
|
-
if (balancer === undefined) {
|
|
57
|
-
throw new ProcedureNotFound(fqn);
|
|
58
|
-
}
|
|
59
|
-
return balancer.run(fqn, version, args, headers);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Segment from '../core/Segment.js';
|
|
2
|
-
import Version from '../core/Version.js';
|
|
3
|
-
import Module from '../core/types/Module.js';
|
|
4
|
-
import Gateway from './Gateway.js';
|
|
5
|
-
import Node from './Node.js';
|
|
6
|
-
import Repository from './Repository.js';
|
|
7
|
-
export default class LocalNode extends Node {
|
|
8
|
-
#private;
|
|
9
|
-
getProcedureNames(): string[];
|
|
10
|
-
loadSegment(name: string): Promise<void>;
|
|
11
|
-
addSegment(segment: Segment): void;
|
|
12
|
-
getSegment(id: string): Segment | undefined;
|
|
13
|
-
hasProcedure(fqn: string): boolean;
|
|
14
|
-
setGateway(gateway: Gateway): Promise<void>;
|
|
15
|
-
setRepository(repository: Repository, segmentNames: string[]): Promise<void>;
|
|
16
|
-
import(url: string, base?: string): Promise<Module>;
|
|
17
|
-
run(fqn: string, version: Version, args: Map<string, unknown>, headers: Map<string, string>): Promise<unknown>;
|
|
18
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import ProcedureNotFound from '../core/errors/ProcedureNotFound.js';
|
|
2
|
-
import SegmentBuilder from '../core/SegmentBuilder.js';
|
|
3
|
-
import RepositoryNotAvailable from './errors/RepositoryNotAvaiable.js';
|
|
4
|
-
import LocalGateway from './LocalGateway.js';
|
|
5
|
-
import Node from './Node.js';
|
|
6
|
-
import ModuleLoader from './utils/ModuleLoader.js';
|
|
7
|
-
import UrlRewriter from './utils/UrlRewriter.js';
|
|
8
|
-
export default class LocalNode extends Node {
|
|
9
|
-
#segments = new Map();
|
|
10
|
-
#gateway;
|
|
11
|
-
#repository;
|
|
12
|
-
#clientId = '';
|
|
13
|
-
getProcedureNames() {
|
|
14
|
-
const names = new Set();
|
|
15
|
-
for (const segment of this.#segments.values()) {
|
|
16
|
-
const procedures = segment.getPublicProcedures();
|
|
17
|
-
procedures.forEach(procedure => names.add(procedure.fqn));
|
|
18
|
-
}
|
|
19
|
-
return [...names.values()];
|
|
20
|
-
}
|
|
21
|
-
async loadSegment(name) {
|
|
22
|
-
const segmentFile = `${name}.segment.local.js`;
|
|
23
|
-
const module = await this.import(segmentFile);
|
|
24
|
-
const segment = SegmentBuilder.build(name, module);
|
|
25
|
-
this.addSegment(segment);
|
|
26
|
-
}
|
|
27
|
-
addSegment(segment) {
|
|
28
|
-
this.#segments.set(segment.id, segment);
|
|
29
|
-
}
|
|
30
|
-
getSegment(id) {
|
|
31
|
-
return this.#segments.get(id);
|
|
32
|
-
}
|
|
33
|
-
hasProcedure(fqn) {
|
|
34
|
-
const procedureNames = this.getProcedureNames();
|
|
35
|
-
return procedureNames.includes(fqn);
|
|
36
|
-
}
|
|
37
|
-
#getProcedureSegment(fqn) {
|
|
38
|
-
for (const segment of this.#segments.values()) {
|
|
39
|
-
if (segment.hasProcedure(fqn)) {
|
|
40
|
-
return segment;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
async setGateway(gateway) {
|
|
46
|
-
if (gateway instanceof LocalGateway || this.url !== undefined) {
|
|
47
|
-
await gateway.addNode(this);
|
|
48
|
-
}
|
|
49
|
-
this.#gateway = gateway;
|
|
50
|
-
}
|
|
51
|
-
async setRepository(repository, segmentNames) {
|
|
52
|
-
this.#clientId = await repository.registerClient(segmentNames);
|
|
53
|
-
await repository.setRuntime(this);
|
|
54
|
-
const moduleLocation = await repository.getModuleLocation(this.#clientId);
|
|
55
|
-
ModuleLoader.setBaseUrl(moduleLocation);
|
|
56
|
-
this.#repository = repository;
|
|
57
|
-
}
|
|
58
|
-
async import(url, base) {
|
|
59
|
-
if (this.#repository === undefined) {
|
|
60
|
-
throw new RepositoryNotAvailable();
|
|
61
|
-
}
|
|
62
|
-
if (base !== undefined) {
|
|
63
|
-
url = UrlRewriter.addBase(url, base);
|
|
64
|
-
}
|
|
65
|
-
return this.#repository.importModule(this.#clientId, url);
|
|
66
|
-
}
|
|
67
|
-
async run(fqn, version, args, headers) {
|
|
68
|
-
const segment = this.#getProcedureSegment(fqn);
|
|
69
|
-
const runner = segment ?? this.#gateway;
|
|
70
|
-
if (runner === undefined) {
|
|
71
|
-
throw new ProcedureNotFound(fqn);
|
|
72
|
-
}
|
|
73
|
-
return runner.run(fqn, version, args, headers);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Module from '../core/types/Module.js';
|
|
2
|
-
import LocalNode from './LocalNode.js';
|
|
3
|
-
import Repository from './Repository.js';
|
|
4
|
-
import FileManager from './interfaces/FileManager.js';
|
|
5
|
-
import File from './models/File.js';
|
|
6
|
-
export default class LocalRepository extends Repository {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(fileManager: FileManager, assets: string[], url?: string);
|
|
9
|
-
loadSegment(name: string): Promise<void>;
|
|
10
|
-
registerSegment(name: string, files: string[]): Promise<void>;
|
|
11
|
-
registerClient(segmentFilenames: string[]): Promise<string>;
|
|
12
|
-
setRuntime(runtime: LocalNode): Promise<void>;
|
|
13
|
-
loadAsset(filename: string): Promise<File>;
|
|
14
|
-
getModuleLocation(clientId: string): Promise<string>;
|
|
15
|
-
loadModule(clientId: string, filename: string): Promise<File>;
|
|
16
|
-
importModule(clientId: string, filename: string): Promise<Module>;
|
|
17
|
-
}
|