moost 0.2.3 → 0.2.5
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/dist/index.cjs +36 -25
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +35 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -208,30 +208,6 @@ function getMoostMate() {
|
|
|
208
208
|
return moostMate;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
function getInstanceOwnMethods(instance) {
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
213
|
-
const proto = Object.getPrototypeOf(instance);
|
|
214
|
-
return [
|
|
215
|
-
...Object.getOwnPropertyNames(proto),
|
|
216
|
-
...Object.getOwnPropertyNames(instance),
|
|
217
|
-
].filter(m => typeof instance[m] === 'function');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const banner = () => `[${"moost"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
221
|
-
|
|
222
|
-
/* istanbul ignore file */
|
|
223
|
-
function log(text) {
|
|
224
|
-
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
225
|
-
}
|
|
226
|
-
function logError(error) {
|
|
227
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function panic(error) {
|
|
231
|
-
logError(error);
|
|
232
|
-
return new Error(error);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
211
|
function runPipes(pipes, meta, restoreCtx) {
|
|
236
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
213
|
let v = undefined;
|
|
@@ -297,6 +273,30 @@ function getNewMoostInfact() {
|
|
|
297
273
|
});
|
|
298
274
|
}
|
|
299
275
|
|
|
276
|
+
function getInstanceOwnMethods(instance) {
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
278
|
+
const proto = Object.getPrototypeOf(instance);
|
|
279
|
+
return [
|
|
280
|
+
...Object.getOwnPropertyNames(proto),
|
|
281
|
+
...Object.getOwnPropertyNames(instance),
|
|
282
|
+
].filter(m => typeof instance[m] === 'function');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const banner = () => `[${"moost"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
286
|
+
|
|
287
|
+
/* istanbul ignore file */
|
|
288
|
+
function log(text) {
|
|
289
|
+
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
290
|
+
}
|
|
291
|
+
function logError(error) {
|
|
292
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function panic(error) {
|
|
296
|
+
logError(error);
|
|
297
|
+
return new Error(error);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
300
|
function getCallableFn(targetInstance, fn, restoreCtx) {
|
|
301
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
302
302
|
const mate$1 = getMoostMate();
|
|
@@ -660,6 +660,15 @@ class Moost {
|
|
|
660
660
|
init() {
|
|
661
661
|
return __awaiter(this, void 0, void 0, function* () {
|
|
662
662
|
this.setProvideRegistry(infact.createProvideRegistry([Moost, () => this]));
|
|
663
|
+
for (const a of this.adapters) {
|
|
664
|
+
const constructor = mate.getConstructor(a);
|
|
665
|
+
if (constructor) {
|
|
666
|
+
this.setProvideRegistry(infact.createProvideRegistry([constructor, () => a]));
|
|
667
|
+
}
|
|
668
|
+
if (typeof a.getProvideRegistry === 'function') {
|
|
669
|
+
this.setProvideRegistry(a.getProvideRegistry());
|
|
670
|
+
}
|
|
671
|
+
}
|
|
663
672
|
this.unregisteredControllers.unshift(this);
|
|
664
673
|
yield this.bindControllers();
|
|
665
674
|
for (const a of this.adapters) {
|
|
@@ -687,7 +696,7 @@ class Moost {
|
|
|
687
696
|
const infact = getMoostInfact();
|
|
688
697
|
const isControllerConsructor = mate.isConstructor(controller);
|
|
689
698
|
let instance;
|
|
690
|
-
if (isControllerConsructor && (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON') {
|
|
699
|
+
if (isControllerConsructor && ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON' || (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === true)) {
|
|
691
700
|
instance = (yield infact.get(controller, provide));
|
|
692
701
|
}
|
|
693
702
|
else if (!isControllerConsructor) {
|
|
@@ -907,7 +916,9 @@ exports.Required = Required;
|
|
|
907
916
|
exports.Resolve = Resolve;
|
|
908
917
|
exports.Validate = Validate;
|
|
909
918
|
exports.genericTypesCastPipe = genericTypesCastPipe;
|
|
919
|
+
exports.getMoostInfact = getMoostInfact;
|
|
910
920
|
exports.getMoostMate = getMoostMate;
|
|
921
|
+
exports.getNewMoostInfact = getNewMoostInfact;
|
|
911
922
|
exports.resolvePipe = resolvePipe;
|
|
912
923
|
exports.useControllerMeta = useControllerMeta;
|
|
913
924
|
exports.validatePipe = validatePipe;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Infact } from '@prostojs/infact';
|
|
1
2
|
import { Mate } from '@prostojs/mate';
|
|
3
|
+
import { TInfactClassMeta } from '@prostojs/infact';
|
|
4
|
+
import { TInfactConstructorParamMeta } from '@prostojs/infact';
|
|
2
5
|
import { TProstoMetadata } from '@prostojs/mate';
|
|
3
6
|
import { TProstoParamsMetadata } from '@prostojs/mate';
|
|
4
7
|
import { TProvideFn } from '@prostojs/infact';
|
|
@@ -31,8 +34,12 @@ export declare function Dto(dtoOptions?: TValidoDtoOptions): ClassDecorator;
|
|
|
31
34
|
|
|
32
35
|
export declare const genericTypesCastPipe: (strict?: boolean) => TPipeFn;
|
|
33
36
|
|
|
37
|
+
export declare function getMoostInfact(): Infact<TInfactMoostMeta>;
|
|
38
|
+
|
|
34
39
|
export declare function getMoostMate(): Mate<TMoostMetadata>;
|
|
35
40
|
|
|
41
|
+
export declare function getNewMoostInfact(): Infact<TInfactMoostMeta>;
|
|
42
|
+
|
|
36
43
|
export declare function Id(value: string): MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
37
44
|
|
|
38
45
|
/**
|
|
@@ -184,6 +191,8 @@ declare interface TCommonMoostMeta {
|
|
|
184
191
|
|
|
185
192
|
declare type TFunction = Function;
|
|
186
193
|
|
|
194
|
+
declare type TInfactMoostMeta = TInfactClassMeta<TMoostParamsMetadata & TInfactConstructorParamMeta>;
|
|
195
|
+
|
|
187
196
|
export declare type TInjectableScope = 'FOR_EVENT' | 'SINGLETON';
|
|
188
197
|
|
|
189
198
|
export declare type TInterceptorAfter = (response: TAny, reply: (response: TAny) => void) => void | Promise<void>;
|
|
@@ -215,6 +224,7 @@ export declare enum TInterceptorPriority {
|
|
|
215
224
|
export declare interface TMoostAdapter<H extends object> {
|
|
216
225
|
bindHandler<T extends TObject = TObject>(options: TMoostAdapterOptions<H, T>): void | Promise<void>;
|
|
217
226
|
onInit?: () => void | Promise<void>;
|
|
227
|
+
getProvideRegistry?: () => TProvideRegistry;
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
export declare interface TMoostAdapterOptions<H extends object, T extends object> {
|
package/dist/index.mjs
CHANGED
|
@@ -206,30 +206,6 @@ function getMoostMate() {
|
|
|
206
206
|
return moostMate;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
function getInstanceOwnMethods(instance) {
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
211
|
-
const proto = Object.getPrototypeOf(instance);
|
|
212
|
-
return [
|
|
213
|
-
...Object.getOwnPropertyNames(proto),
|
|
214
|
-
...Object.getOwnPropertyNames(instance),
|
|
215
|
-
].filter(m => typeof instance[m] === 'function');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const banner = () => `[${"moost"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
219
|
-
|
|
220
|
-
/* istanbul ignore file */
|
|
221
|
-
function log(text) {
|
|
222
|
-
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
223
|
-
}
|
|
224
|
-
function logError(error) {
|
|
225
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function panic(error) {
|
|
229
|
-
logError(error);
|
|
230
|
-
return new Error(error);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
209
|
function runPipes(pipes, meta, restoreCtx) {
|
|
234
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
235
211
|
let v = undefined;
|
|
@@ -295,6 +271,30 @@ function getNewMoostInfact() {
|
|
|
295
271
|
});
|
|
296
272
|
}
|
|
297
273
|
|
|
274
|
+
function getInstanceOwnMethods(instance) {
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
276
|
+
const proto = Object.getPrototypeOf(instance);
|
|
277
|
+
return [
|
|
278
|
+
...Object.getOwnPropertyNames(proto),
|
|
279
|
+
...Object.getOwnPropertyNames(instance),
|
|
280
|
+
].filter(m => typeof instance[m] === 'function');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const banner = () => `[${"moost"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
284
|
+
|
|
285
|
+
/* istanbul ignore file */
|
|
286
|
+
function log(text) {
|
|
287
|
+
console.log('[32m' + '[2m' + banner() + text + '[0m');
|
|
288
|
+
}
|
|
289
|
+
function logError(error) {
|
|
290
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function panic(error) {
|
|
294
|
+
logError(error);
|
|
295
|
+
return new Error(error);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
298
|
function getCallableFn(targetInstance, fn, restoreCtx) {
|
|
299
299
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
300
|
const mate = getMoostMate();
|
|
@@ -658,6 +658,15 @@ class Moost {
|
|
|
658
658
|
init() {
|
|
659
659
|
return __awaiter(this, void 0, void 0, function* () {
|
|
660
660
|
this.setProvideRegistry(createProvideRegistry([Moost, () => this]));
|
|
661
|
+
for (const a of this.adapters) {
|
|
662
|
+
const constructor = getConstructor(a);
|
|
663
|
+
if (constructor) {
|
|
664
|
+
this.setProvideRegistry(createProvideRegistry([constructor, () => a]));
|
|
665
|
+
}
|
|
666
|
+
if (typeof a.getProvideRegistry === 'function') {
|
|
667
|
+
this.setProvideRegistry(a.getProvideRegistry());
|
|
668
|
+
}
|
|
669
|
+
}
|
|
661
670
|
this.unregisteredControllers.unshift(this);
|
|
662
671
|
yield this.bindControllers();
|
|
663
672
|
for (const a of this.adapters) {
|
|
@@ -685,7 +694,7 @@ class Moost {
|
|
|
685
694
|
const infact = getMoostInfact();
|
|
686
695
|
const isControllerConsructor = isConstructor(controller);
|
|
687
696
|
let instance;
|
|
688
|
-
if (isControllerConsructor && (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON') {
|
|
697
|
+
if (isControllerConsructor && ((classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === 'SINGLETON' || (classMeta === null || classMeta === void 0 ? void 0 : classMeta.injectable) === true)) {
|
|
689
698
|
instance = (yield infact.get(controller, provide));
|
|
690
699
|
}
|
|
691
700
|
else if (!isControllerConsructor) {
|
|
@@ -880,4 +889,4 @@ const validatePipe = (opts) => {
|
|
|
880
889
|
return pipe;
|
|
881
890
|
};
|
|
882
891
|
|
|
883
|
-
export { Circular, Const, Controller, Dto, Id, ImportController, Inject, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostMate, resolvePipe, useControllerMeta, validatePipe };
|
|
892
|
+
export { Circular, Const, Controller, Dto, Id, ImportController, Inject, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostInfact, getMoostMate, getNewMoostInfact, resolvePipe, useControllerMeta, validatePipe };
|