+7
-3
@@ -8,3 +8,2 @@ declare class AlsToken<T = any> { | ||
| declare function createAlsToken<T = any>(key: string): AlsToken<T>; | ||
| declare const INJECTIONS: unique symbol; | ||
@@ -49,2 +48,3 @@ declare enum Scope { | ||
| interface MetadataQuery { | ||
| $sort?: Record<string, 'asc' | 'desc'>; | ||
| [key: string]: any | ((value: any) => boolean); | ||
@@ -112,3 +112,3 @@ } | ||
| getInjectionsFor<T>(type: string, target: Constructor, methodName?: string): T[]; | ||
| hasInjection(type: any, target: Constructor, methodName?: string): boolean; | ||
| hasInjection(type: string, target: Constructor, methodName?: string): boolean; | ||
| private getRequestId; | ||
@@ -294,2 +294,6 @@ private resolveToken; | ||
| /** | ||
| * Clear all metadata indexes (used during full container reset) | ||
| */ | ||
| clearMetadataIndexes(): void; | ||
| /** | ||
| * Find tokens by metadata query | ||
@@ -854,2 +858,2 @@ * @example | ||
| export { AlsStore, AlsToken, type AsyncFactory, BaseError, CLASS_TYPE, CONTROLLER, CONTROLLER_PATH, type Constructor, Container, Controller, type ControllerOptions, type CreateInjectOptions, DATABASE, DESIGN_PARAMTYPES, DESIGN_RETURNTYPE, DESIGN_TYPE, DI, DIError, DI_CODES, type DecoratorMetadata, Deleter, type Factory, FactoryWrapper, INJECTABLE, INJECTIONS, INJECT_PARAMS, INJECT_PROPS, Inject, Injectable, type InjectableOptions, type InjectableType, type InjectionDefinition, Instantiator, METADATA, Meta, MetaHelper, type Metadata, MetadataManager, type MetadataQuery, type NextFunction, type OnBootComplete, type OnDestroy, type OnInit, type Options, type PropertyInjection, type PropsInject, REPOSITORY, type RegEntryOpts, Register, type Registration, type RegistryEntry, Repository, type RepositoryOptions, Resolver, SCAN_PROPS, SCOPE, SERVICE, Scope, Service, type ServiceOptions, Store, type TStore, type Token, Value, alias, boot, container, createAlsToken, createInject, findAll, get, getAll, getClassType, getClasses, getDatabase, getDecoratorMetadata, getDecoratorMetadataValue, getParamTypes, getParameterInjections, getPath, getPropertyInjections, getPropertyType, getReflectType, getReturnType, getScope, has, hasDecoratorMetadata, hasOnBootComplete, hasOnDestroy, hasOnInit, hasSingletonInstance, hasSingletonPending, isAlsToken, isArrayToken, isConstructor, isController, isInjectable, isNamedToken, isRegistryEntry, isRepository, isReqScope, isService, mergeMetadata, reset, resolve, set, setClassType, setInjectable, setScope }; | ||
| export { AlsStore, AlsToken, type AsyncFactory, BaseError, CLASS_TYPE, CONTROLLER, CONTROLLER_PATH, type Constructor, Container, Controller, type ControllerOptions, type CreateInjectOptions, DATABASE, DESIGN_PARAMTYPES, DESIGN_RETURNTYPE, DESIGN_TYPE, DI, DIError, DI_CODES, type DecoratorMetadata, Deleter, type Factory, FactoryWrapper, INJECTABLE, INJECT_PARAMS, INJECT_PROPS, Inject, Injectable, type InjectableOptions, type InjectableType, type InjectionDefinition, Instantiator, METADATA, Meta, MetaHelper, type Metadata, MetadataManager, type MetadataQuery, type NextFunction, type OnBootComplete, type OnDestroy, type OnInit, type Options, type PropertyInjection, type PropsInject, REPOSITORY, type RegEntryOpts, Register, type Registration, type RegistryEntry, Repository, type RepositoryOptions, Resolver, SCAN_PROPS, SCOPE, SERVICE, Scope, Service, type ServiceOptions, Store, type TStore, type Token, Value, alias, boot, container, createAlsToken, createInject, findAll, get, getAll, getClassType, getClasses, getDatabase, getDecoratorMetadata, getDecoratorMetadataValue, getParamTypes, getParameterInjections, getPath, getPropertyInjections, getPropertyType, getReflectType, getReturnType, getScope, has, hasDecoratorMetadata, hasOnBootComplete, hasOnDestroy, hasOnInit, hasSingletonInstance, hasSingletonPending, isAlsToken, isArrayToken, isConstructor, isController, isInjectable, isNamedToken, isRegistryEntry, isRepository, isReqScope, isService, mergeMetadata, reset, resolve, set, setClassType, setInjectable, setScope }; |
+29
-20
@@ -39,3 +39,2 @@ var __defProp = Object.defineProperty; | ||
| __name(createAlsToken, "createAlsToken"); | ||
| var INJECTIONS = /* @__PURE__ */ Symbol.for("diject:injections"); | ||
@@ -610,6 +609,10 @@ // src/container/helpers.ts | ||
| for (const [key, value] of Object.entries(query)) { | ||
| if (value === "asc" || value === "desc") { | ||
| sortKey = key; | ||
| sortDir = value; | ||
| } else { | ||
| if (key === "$sort" && typeof value === "object" && value !== null) { | ||
| const sortObj = value; | ||
| const sortEntry = Object.entries(sortObj)[0]; | ||
| if (sortEntry) { | ||
| sortKey = sortEntry[0]; | ||
| sortDir = sortEntry[1] === "desc" ? "desc" : "asc"; | ||
| } | ||
| } else if (key !== "$sort") { | ||
| filters[key] = value; | ||
@@ -759,6 +762,3 @@ } | ||
| // Add default metadata configuration | ||
| defaultMetadata = { | ||
| layer: "app", | ||
| priority: 0 | ||
| }; | ||
| defaultMetadata = {}; | ||
| constructor(container2) { | ||
@@ -1042,3 +1042,3 @@ this.container = container2; | ||
| getRequestId(requestId) { | ||
| return requestId; | ||
| return requestId ?? this.store.get("requestId"); | ||
| } | ||
@@ -1216,4 +1216,7 @@ // ============================================ | ||
| async destroy(instance) { | ||
| if (hasOnDestroy(instance)) { | ||
| if (!hasOnDestroy(instance)) | ||
| return; | ||
| try { | ||
| await instance.onDestroy(); | ||
| } catch { | ||
| } | ||
@@ -1415,3 +1418,3 @@ } | ||
| await Promise.all(destroyPromises); | ||
| this.container["register"].metadata.clearIndexes(); | ||
| this.container.clearMetadataIndexes(); | ||
| this.clearAllMaps(); | ||
@@ -1556,3 +1559,6 @@ } | ||
| // src/container/AlsStore.ts | ||
| var _AsyncLocalStorageImpl = null; | ||
| var resolveAsyncLocalStorage = /* @__PURE__ */ __name(() => { | ||
| if (_AsyncLocalStorageImpl) | ||
| return _AsyncLocalStorageImpl; | ||
| const runtimeProcess = process; | ||
@@ -1563,5 +1569,5 @@ const AsyncLocalStorage = runtimeProcess.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage ?? runtimeProcess.getBuiltinModule?.("async_hooks")?.AsyncLocalStorage; | ||
| } | ||
| return AsyncLocalStorage; | ||
| _AsyncLocalStorageImpl = AsyncLocalStorage; | ||
| return _AsyncLocalStorageImpl; | ||
| }, "resolveAsyncLocalStorage"); | ||
| var AsyncLocalStorageImpl = resolveAsyncLocalStorage(); | ||
| var AlsStore = class { | ||
@@ -1571,3 +1577,3 @@ static { | ||
| } | ||
| als = new AsyncLocalStorageImpl(); | ||
| als = new (resolveAsyncLocalStorage())(); | ||
| run(data, fn) { | ||
@@ -1684,3 +1690,3 @@ const currentStore = this.als.getStore(); | ||
| await instance.clear(); | ||
| instance.register.metadata.clearIndexes(); | ||
| instance.clearMetadataIndexes(); | ||
| instance.registry.clear(); | ||
@@ -1832,2 +1838,8 @@ instance.nameToToken.clear(); | ||
| /** | ||
| * Clear all metadata indexes (used during full container reset) | ||
| */ | ||
| clearMetadataIndexes() { | ||
| this.register.metadata.clearIndexes(); | ||
| } | ||
| /** | ||
| * Find tokens by metadata query | ||
@@ -1963,5 +1975,3 @@ * @example | ||
| if (hasOnBootComplete(entry.instance)) { | ||
| promises.push(Promise.resolve(entry.instance.onBootComplete()).catch((err) => { | ||
| throw err; | ||
| })); | ||
| promises.push(Promise.resolve(entry.instance.onBootComplete())); | ||
| } | ||
@@ -2073,3 +2083,2 @@ } | ||
| INJECTABLE, | ||
| INJECTIONS, | ||
| INJECT_PARAMS, | ||
@@ -2076,0 +2085,0 @@ INJECT_PROPS, |
+1
-1
| { | ||
| "name": "diject", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "description": "Lightweight TypeScript DI container with decorators, scopes, metadata queries, and AsyncLocalStorage support.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
109986
0.42%2945
0.44%