@tstdl/base 0.84.14 → 0.84.16
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.
|
@@ -7,8 +7,7 @@ export declare class Application {
|
|
|
7
7
|
private static _instance;
|
|
8
8
|
private static get instance();
|
|
9
9
|
private readonly logger;
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly moduleInstances;
|
|
10
|
+
private readonly moduleTypesAndInstances;
|
|
12
11
|
private readonly shutdownPromise;
|
|
13
12
|
private readonly _shutdownToken;
|
|
14
13
|
get shutdownToken(): ReadonlyCancellationToken;
|
|
@@ -16,14 +15,12 @@ export declare class Application {
|
|
|
16
15
|
constructor(logger: Logger);
|
|
17
16
|
static registerModule(moduleType: Type<Module>): void;
|
|
18
17
|
static registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
19
|
-
static registerModuleInstance(module: Module): void;
|
|
20
18
|
static run(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): void;
|
|
21
19
|
static waitForShutdown(): Promise<void>;
|
|
22
20
|
static shutdown(): Promise<void>;
|
|
23
21
|
static requestShutdown(): void;
|
|
24
|
-
registerModule(moduleType: Type<Module>): void;
|
|
22
|
+
registerModule(moduleType: Module | Type<Module>): void;
|
|
25
23
|
registerModuleFunction(fn: FunctionModuleFunction): void;
|
|
26
|
-
registerModuleInstance(module: Module): void;
|
|
27
24
|
run(...functionsAndModules: OneOrMany<FunctionModuleFunction | Type<Module>>[]): void;
|
|
28
25
|
shutdown(): Promise<void>;
|
|
29
26
|
requestShutdown(): void;
|
|
@@ -63,8 +63,7 @@ let Application = Application_1 = class Application2 {
|
|
|
63
63
|
return this._instance;
|
|
64
64
|
}
|
|
65
65
|
logger;
|
|
66
|
-
|
|
67
|
-
moduleInstances;
|
|
66
|
+
moduleTypesAndInstances;
|
|
68
67
|
shutdownPromise;
|
|
69
68
|
_shutdownToken;
|
|
70
69
|
get shutdownToken() {
|
|
@@ -75,8 +74,7 @@ let Application = Application_1 = class Application2 {
|
|
|
75
74
|
}
|
|
76
75
|
constructor(logger) {
|
|
77
76
|
this.logger = logger;
|
|
78
|
-
this.
|
|
79
|
-
this.moduleInstances = /* @__PURE__ */ new Set();
|
|
77
|
+
this.moduleTypesAndInstances = /* @__PURE__ */ new Set();
|
|
80
78
|
this.shutdownPromise = new import_deferred_promise.DeferredPromise();
|
|
81
79
|
this._shutdownToken = import_process_shutdown.shutdownToken.createChild();
|
|
82
80
|
}
|
|
@@ -86,9 +84,6 @@ let Application = Application_1 = class Application2 {
|
|
|
86
84
|
static registerModuleFunction(fn) {
|
|
87
85
|
Application_1.instance.registerModuleFunction(fn);
|
|
88
86
|
}
|
|
89
|
-
static registerModuleInstance(module2) {
|
|
90
|
-
Application_1.instance.registerModuleInstance(module2);
|
|
91
|
-
}
|
|
92
87
|
static run(...functionsAndModules) {
|
|
93
88
|
Application_1.instance.run(...functionsAndModules);
|
|
94
89
|
}
|
|
@@ -102,14 +97,11 @@ let Application = Application_1 = class Application2 {
|
|
|
102
97
|
Application_1.instance.requestShutdown();
|
|
103
98
|
}
|
|
104
99
|
registerModule(moduleType) {
|
|
105
|
-
this.
|
|
100
|
+
this.moduleTypesAndInstances.add(moduleType);
|
|
106
101
|
}
|
|
107
102
|
registerModuleFunction(fn) {
|
|
108
103
|
const module2 = new import_function_module.FunctionModule(fn);
|
|
109
|
-
this.
|
|
110
|
-
}
|
|
111
|
-
registerModuleInstance(module2) {
|
|
112
|
-
this.moduleInstances.add(module2);
|
|
104
|
+
this.registerModule(module2);
|
|
113
105
|
}
|
|
114
106
|
run(...functionsAndModules) {
|
|
115
107
|
void this._run(...functionsAndModules);
|
|
@@ -135,8 +127,7 @@ let Application = Application_1 = class Application2 {
|
|
|
135
127
|
this.registerModuleFunction(fnOrModule);
|
|
136
128
|
}
|
|
137
129
|
}
|
|
138
|
-
const
|
|
139
|
-
const modules = [...this.moduleInstances, ...resolvedModules];
|
|
130
|
+
const modules = await (0, import_to_array.toArrayAsync)((0, import_map.mapAsync)(this.moduleTypesAndInstances, async (instanceOrType) => (0, import_type_guards.isFunction)(instanceOrType) ? import_container.container.resolveAsync(instanceOrType) : instanceOrType));
|
|
140
131
|
try {
|
|
141
132
|
await Promise.race([
|
|
142
133
|
this.runModules(modules),
|
package/package.json
CHANGED
package/process-shutdown.js
CHANGED
|
@@ -63,7 +63,7 @@ function initializeSignals() {
|
|
|
63
63
|
let quitReason;
|
|
64
64
|
process.on("beforeExit", () => {
|
|
65
65
|
if ((0, import_type_guards.isDefined)(quitReason)) {
|
|
66
|
-
console.info("
|
|
66
|
+
console.info("\nquit reason:", ...quitReason);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
for (const event of quitEvents) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { JsonPath } from '../../json-path/json-path.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Schema } from '../schema.js';
|
|
3
|
+
import type { CoerceResult, CoercerContext } from '../types/index.js';
|
|
3
4
|
import { SchemaValueCoercer } from '../types/index.js';
|
|
4
5
|
export declare class Uint8ArrayCoercer extends SchemaValueCoercer {
|
|
6
|
+
static readonly byteNumberArraySchema: Schema<number[]>;
|
|
5
7
|
readonly sourceType: ArrayConstructor;
|
|
6
8
|
readonly targetType: Uint8ArrayConstructor;
|
|
7
9
|
coerce(value: any[], path: JsonPath, { options }: CoercerContext): CoerceResult;
|
|
@@ -22,17 +22,21 @@ __export(uint8_array_coercer_exports, {
|
|
|
22
22
|
uint8ArrayCoercer: () => uint8ArrayCoercer
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(uint8_array_coercer_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_lazy_property = require("../../utils/object/lazy-property.js");
|
|
26
26
|
var import_schema_error = require("../schema.error.js");
|
|
27
|
+
var import_schema = require("../schema.js");
|
|
27
28
|
var import_array = require("../schemas/array.js");
|
|
28
29
|
var import_number = require("../schemas/number.js");
|
|
29
30
|
var import_types = require("../types/index.js");
|
|
30
|
-
const byteNumberArraySchema = (0, import_array.array)((0, import_number.number)({ integer: true, minimum: 0, maximum: 255 }));
|
|
31
31
|
class Uint8ArrayCoercer extends import_types.SchemaValueCoercer {
|
|
32
|
+
static byteNumberArraySchema;
|
|
33
|
+
static {
|
|
34
|
+
(0, import_lazy_property.lazyProperty)(this, "byteNumberArraySchema", () => (0, import_array.array)((0, import_number.number)({ integer: true, minimum: 0, maximum: 255 })));
|
|
35
|
+
}
|
|
32
36
|
sourceType = Array;
|
|
33
37
|
targetType = Uint8Array;
|
|
34
38
|
coerce(value, path, { options }) {
|
|
35
|
-
const testResult = (0, import_schema.testSchema)(byteNumberArraySchema, value, options, path);
|
|
39
|
+
const testResult = (0, import_schema.testSchema)(Uint8ArrayCoercer.byteNumberArraySchema, value, options, path);
|
|
36
40
|
if (!testResult.valid) {
|
|
37
41
|
return { success: false, error: import_schema_error.SchemaError.couldNotCoerce(Uint8Array, Array, path, { inner: testResult.error, fast: options.fastErrors }) };
|
|
38
42
|
}
|
package/schema/schemas/number.js
CHANGED
|
@@ -27,7 +27,7 @@ var import_type_guards = require("../../utils/type-guards.js");
|
|
|
27
27
|
var import_integer = require("../constraints/integer.js");
|
|
28
28
|
var import_maximum = require("../constraints/maximum.js");
|
|
29
29
|
var import_minimum = require("../constraints/minimum.js");
|
|
30
|
-
var
|
|
30
|
+
var import_utils = require("../decorators/utils.js");
|
|
31
31
|
var import_types = require("../types/types.js");
|
|
32
32
|
function number(options = {}) {
|
|
33
33
|
const valueConstraints = (0, import_array.toArrayCopy)(options.valueConstraints ?? []);
|
|
@@ -46,5 +46,5 @@ function number(options = {}) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function NumberProperty(options) {
|
|
49
|
-
return (0,
|
|
49
|
+
return (0, import_utils.createSchemaPropertyDecoratorFromSchema)(number(options));
|
|
50
50
|
}
|