@declaro/core 2.0.0-y.0 → 2.1.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/{LICENSE → LICENSE.md} +1 -1
- package/README.md +203 -0
- package/dist/browser/index.js +28 -0
- package/dist/browser/index.js.map +133 -0
- package/dist/browser/scope/index.js +3 -0
- package/dist/browser/scope/index.js.map +9 -0
- package/dist/bun/index.js +19011 -0
- package/dist/bun/index.js.map +132 -0
- package/dist/bun/scope/index.js +4 -0
- package/dist/bun/scope/index.js.map +9 -0
- package/dist/node/index.cjs +19039 -0
- package/dist/node/index.cjs.map +132 -0
- package/dist/node/index.js +19010 -0
- package/dist/node/index.js.map +132 -0
- package/dist/node/scope/index.cjs +69 -0
- package/dist/node/scope/index.cjs.map +9 -0
- package/dist/node/scope/index.js +3 -0
- package/dist/node/scope/index.js.map +9 -0
- package/dist/ts/app/app-context.d.ts +9 -0
- package/dist/ts/app/app-context.d.ts.map +1 -0
- package/dist/ts/app/app-lifecycle.d.ts +6 -0
- package/dist/ts/app/app-lifecycle.d.ts.map +1 -0
- package/dist/ts/app/app.d.ts +24 -0
- package/dist/ts/app/app.d.ts.map +1 -0
- package/dist/{app → ts/app}/index.d.ts +1 -0
- package/dist/ts/app/index.d.ts.map +1 -0
- package/dist/ts/application/create-request-context.d.ts +4 -0
- package/dist/ts/application/create-request-context.d.ts.map +1 -0
- package/dist/ts/application/create-request-context.test.d.ts +2 -0
- package/dist/ts/application/create-request-context.test.d.ts.map +1 -0
- package/dist/ts/application/use-declaro.d.ts +3 -0
- package/dist/ts/application/use-declaro.d.ts.map +1 -0
- package/dist/{auth → ts/auth}/permission-validator.d.ts +1 -0
- package/dist/ts/auth/permission-validator.d.ts.map +1 -0
- package/dist/ts/auth/permission-validator.test.d.ts +2 -0
- package/dist/ts/auth/permission-validator.test.d.ts.map +1 -0
- package/dist/ts/context/async-context.d.ts +54 -0
- package/dist/ts/context/async-context.d.ts.map +1 -0
- package/dist/ts/context/async-context.test.d.ts +2 -0
- package/dist/ts/context/async-context.test.d.ts.map +1 -0
- package/dist/{context → ts/context}/context-consumer.d.ts +4 -0
- package/dist/ts/context/context-consumer.d.ts.map +1 -0
- package/dist/ts/context/context.circular-deps.test.d.ts +2 -0
- package/dist/ts/context/context.circular-deps.test.d.ts.map +1 -0
- package/dist/ts/context/context.d.ts +452 -0
- package/dist/ts/context/context.d.ts.map +1 -0
- package/dist/ts/context/context.test.d.ts +2 -0
- package/dist/ts/context/context.test.d.ts.map +1 -0
- package/dist/ts/context/legacy-context.test.d.ts +2 -0
- package/dist/ts/context/legacy-context.test.d.ts.map +1 -0
- package/dist/{context → ts/context}/validators.d.ts +2 -1
- package/dist/ts/context/validators.d.ts.map +1 -0
- package/dist/ts/dataflow/index.d.ts +2 -0
- package/dist/ts/dataflow/index.d.ts.map +1 -0
- package/dist/ts/dataflow/objects.d.ts +7 -0
- package/dist/ts/dataflow/objects.d.ts.map +1 -0
- package/dist/ts/dataflow/objects.test.d.ts +2 -0
- package/dist/ts/dataflow/objects.test.d.ts.map +1 -0
- package/dist/{errors → ts/errors}/errors.d.ts +16 -3
- package/dist/ts/errors/errors.d.ts.map +1 -0
- package/dist/ts/events/event-manager.d.ts +19 -0
- package/dist/ts/events/event-manager.d.ts.map +1 -0
- package/dist/ts/events/event-manager.spec.d.ts +2 -0
- package/dist/ts/events/event-manager.spec.d.ts.map +1 -0
- package/dist/ts/events/index.d.ts +2 -0
- package/dist/ts/events/index.d.ts.map +1 -0
- package/dist/ts/http/headers.d.ts +21 -0
- package/dist/ts/http/headers.d.ts.map +1 -0
- package/dist/ts/http/headers.spec.d.ts +2 -0
- package/dist/ts/http/headers.spec.d.ts.map +1 -0
- package/dist/ts/http/request-context.d.ts +17 -0
- package/dist/ts/http/request-context.d.ts.map +1 -0
- package/dist/ts/http/request-context.spec.d.ts +2 -0
- package/dist/ts/http/request-context.spec.d.ts.map +1 -0
- package/dist/ts/http/request.d.ts +31 -0
- package/dist/ts/http/request.d.ts.map +1 -0
- package/dist/ts/http/request.spec.d.ts +2 -0
- package/dist/ts/http/request.spec.d.ts.map +1 -0
- package/dist/{http → ts/http}/url.d.ts +5 -4
- package/dist/ts/http/url.d.ts.map +1 -0
- package/dist/ts/http/url.spec.d.ts +2 -0
- package/dist/ts/http/url.spec.d.ts.map +1 -0
- package/dist/ts/index.d.ts +47 -0
- package/dist/ts/index.d.ts.map +1 -0
- package/dist/{pipelines → ts/pipelines}/index.d.ts +1 -0
- package/dist/ts/pipelines/index.d.ts.map +1 -0
- package/dist/{pipelines → ts/pipelines}/pipeline-action.d.ts +1 -0
- package/dist/ts/pipelines/pipeline-action.d.ts.map +1 -0
- package/dist/ts/pipelines/pipeline-action.test.d.ts +2 -0
- package/dist/ts/pipelines/pipeline-action.test.d.ts.map +1 -0
- package/dist/{pipelines → ts/pipelines}/pipeline.d.ts +3 -2
- package/dist/ts/pipelines/pipeline.d.ts.map +1 -0
- package/dist/ts/pipelines/pipeline.test.d.ts +2 -0
- package/dist/ts/pipelines/pipeline.test.d.ts.map +1 -0
- package/dist/ts/schema/json-schema.d.ts +12 -0
- package/dist/ts/schema/json-schema.d.ts.map +1 -0
- package/dist/ts/schema/labels.d.ts +14 -0
- package/dist/ts/schema/labels.d.ts.map +1 -0
- package/dist/ts/schema/model-schema.d.ts +75 -0
- package/dist/ts/schema/model-schema.d.ts.map +1 -0
- package/dist/ts/schema/model-schema.test.d.ts +2 -0
- package/dist/ts/schema/model-schema.test.d.ts.map +1 -0
- package/dist/ts/schema/model.d.ts +35 -0
- package/dist/ts/schema/model.d.ts.map +1 -0
- package/dist/ts/schema/schema-mixin.d.ts +24 -0
- package/dist/ts/schema/schema-mixin.d.ts.map +1 -0
- package/dist/ts/schema/test/mock-model.d.ts +8 -0
- package/dist/ts/schema/test/mock-model.d.ts.map +1 -0
- package/dist/ts/scope/index.d.ts +34 -0
- package/dist/ts/scope/index.d.ts.map +1 -0
- package/dist/ts/shared/utils/action-descriptor.d.ts +28 -0
- package/dist/ts/shared/utils/action-descriptor.d.ts.map +1 -0
- package/dist/ts/shared/utils/action-descriptor.test.d.ts +2 -0
- package/dist/ts/shared/utils/action-descriptor.test.d.ts.map +1 -0
- package/dist/ts/shared/utils/schema-utils.d.ts +3 -0
- package/dist/ts/shared/utils/schema-utils.d.ts.map +1 -0
- package/dist/ts/shared/utils/schema-utils.test.d.ts +2 -0
- package/dist/ts/shared/utils/schema-utils.test.d.ts.map +1 -0
- package/dist/ts/shims/async-local-storage.d.ts +36 -0
- package/dist/ts/shims/async-local-storage.d.ts.map +1 -0
- package/dist/ts/shims/async-local-storage.test.d.ts +2 -0
- package/dist/ts/shims/async-local-storage.test.d.ts.map +1 -0
- package/dist/{timing.d.ts → ts/timing.d.ts} +1 -0
- package/dist/ts/timing.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/arrays.d.ts +1 -0
- package/dist/ts/typescript/arrays.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/baseModel.d.ts +1 -0
- package/dist/ts/typescript/baseModel.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/classes.d.ts +1 -0
- package/dist/ts/typescript/classes.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/constant-manipulation/snake-case.d.ts +1 -0
- package/dist/ts/typescript/constant-manipulation/snake-case.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/errors.d.ts +1 -0
- package/dist/ts/typescript/errors.d.ts.map +1 -0
- package/dist/ts/typescript/fetch.d.ts +3 -0
- package/dist/ts/typescript/fetch.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/generics.d.ts +1 -0
- package/dist/ts/typescript/generics.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/index.d.ts +1 -0
- package/dist/ts/typescript/index.d.ts.map +1 -0
- package/dist/ts/typescript/objects.d.ts +26 -0
- package/dist/ts/typescript/objects.d.ts.map +1 -0
- package/dist/{typescript → ts/typescript}/promises.d.ts +1 -0
- package/dist/ts/typescript/promises.d.ts.map +1 -0
- package/dist/{validation → ts/validation}/index.d.ts +1 -0
- package/dist/ts/validation/index.d.ts.map +1 -0
- package/dist/{validation → ts/validation}/validation.d.ts +1 -0
- package/dist/ts/validation/validation.d.ts.map +1 -0
- package/dist/{validation → ts/validation}/validator.d.ts +1 -0
- package/dist/ts/validation/validator.d.ts.map +1 -0
- package/dist/ts/validation/validator.test.d.ts +2 -0
- package/dist/ts/validation/validator.test.d.ts.map +1 -0
- package/package.json +46 -13
- package/src/app/app-context.ts +4 -5
- package/src/app/app-lifecycle.ts +4 -3
- package/src/app/app.ts +7 -5
- package/src/application/create-request-context.test.ts +345 -0
- package/src/application/create-request-context.ts +19 -0
- package/src/application/use-declaro.ts +27 -0
- package/src/auth/permission-validator.test.ts +238 -2
- package/src/auth/permission-validator.ts +3 -3
- package/src/context/async-context.test.ts +348 -0
- package/src/context/async-context.ts +129 -0
- package/src/context/context-consumer.ts +4 -4
- package/src/context/context.circular-deps.test.ts +1047 -0
- package/src/context/context.test.ts +420 -3
- package/src/context/context.ts +590 -87
- package/src/context/legacy-context.test.ts +9 -9
- package/src/dataflow/objects.test.ts +7 -7
- package/src/dataflow/objects.ts +10 -9
- package/src/errors/errors.ts +19 -3
- package/src/events/event-manager.spec.ts +129 -0
- package/src/events/event-manager.ts +25 -14
- package/src/http/headers.ts +17 -2
- package/src/http/request-context.ts +24 -15
- package/src/http/request.ts +27 -6
- package/src/http/url.ts +3 -3
- package/src/index.ts +34 -3
- package/src/pipelines/pipeline.test.ts +11 -9
- package/src/schema/json-schema.ts +16 -0
- package/src/schema/labels.ts +23 -23
- package/src/schema/model-schema.test.ts +282 -0
- package/src/schema/model-schema.ts +197 -0
- package/src/schema/model.ts +143 -0
- package/src/schema/schema-mixin.ts +51 -0
- package/src/schema/test/mock-model.ts +19 -0
- package/src/scope/index.ts +33 -0
- package/src/shared/utils/action-descriptor.test.ts +182 -0
- package/src/shared/utils/action-descriptor.ts +102 -0
- package/src/shared/utils/schema-utils.test.ts +33 -0
- package/src/shared/utils/schema-utils.ts +17 -0
- package/src/shims/async-local-storage.test.ts +258 -0
- package/src/shims/async-local-storage.ts +82 -0
- package/src/typescript/objects.ts +32 -1
- package/src/validation/validator.test.ts +12 -20
- package/dist/app/app-context.d.ts +0 -8
- package/dist/app/app-lifecycle.d.ts +0 -4
- package/dist/app/app.d.ts +0 -22
- package/dist/auth/permission-validator.test.d.ts +0 -1
- package/dist/context/context.d.ts +0 -161
- package/dist/context/context.test.d.ts +0 -1
- package/dist/context/legacy-context.test.d.ts +0 -1
- package/dist/dataflow/index.d.ts +0 -1
- package/dist/dataflow/objects.d.ts +0 -5
- package/dist/dataflow/objects.test.d.ts +0 -1
- package/dist/events/event-manager.d.ts +0 -16
- package/dist/events/event-manager.spec.d.ts +0 -1
- package/dist/events/index.d.ts +0 -1
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/ucfirst.d.ts +0 -1
- package/dist/http/headers.d.ts +0 -4
- package/dist/http/headers.spec.d.ts +0 -1
- package/dist/http/request-context.d.ts +0 -12
- package/dist/http/request-context.spec.d.ts +0 -1
- package/dist/http/request.d.ts +0 -8
- package/dist/http/request.spec.d.ts +0 -1
- package/dist/http/url.spec.d.ts +0 -1
- package/dist/index.d.ts +0 -19
- package/dist/pipelines/pipeline-action.test.d.ts +0 -1
- package/dist/pipelines/pipeline.test.d.ts +0 -1
- package/dist/pkg.cjs +0 -30
- package/dist/pkg.mjs +0 -56612
- package/dist/schema/application.d.ts +0 -83
- package/dist/schema/application.test.d.ts +0 -1
- package/dist/schema/define-model.d.ts +0 -10
- package/dist/schema/define-model.test.d.ts +0 -1
- package/dist/schema/formats.d.ts +0 -10
- package/dist/schema/index.d.ts +0 -10
- package/dist/schema/labels.d.ts +0 -13
- package/dist/schema/labels.test.d.ts +0 -1
- package/dist/schema/module.d.ts +0 -7
- package/dist/schema/module.test.d.ts +0 -1
- package/dist/schema/properties.d.ts +0 -19
- package/dist/schema/response.d.ts +0 -31
- package/dist/schema/response.test.d.ts +0 -1
- package/dist/schema/supported-types.d.ts +0 -12
- package/dist/schema/supported-types.test.d.ts +0 -1
- package/dist/schema/transform-model.d.ts +0 -4
- package/dist/schema/transform-model.test.d.ts +0 -1
- package/dist/schema/types.d.ts +0 -95
- package/dist/schema/types.test.d.ts +0 -1
- package/dist/typescript/fetch.d.ts +0 -2
- package/dist/typescript/objects.d.ts +0 -12
- package/dist/validation/validator.test.d.ts +0 -1
- package/src/helpers/index.ts +0 -1
- package/src/helpers/ucfirst.ts +0 -3
- package/src/schema/application.test.ts +0 -286
- package/src/schema/application.ts +0 -150
- package/src/schema/define-model.test.ts +0 -81
- package/src/schema/define-model.ts +0 -50
- package/src/schema/formats.ts +0 -23
- package/src/schema/index.ts +0 -10
- package/src/schema/labels.test.ts +0 -60
- package/src/schema/module.test.ts +0 -39
- package/src/schema/module.ts +0 -6
- package/src/schema/properties.ts +0 -40
- package/src/schema/response.test.ts +0 -101
- package/src/schema/response.ts +0 -93
- package/src/schema/supported-types.test.ts +0 -20
- package/src/schema/supported-types.ts +0 -15
- package/src/schema/transform-model.test.ts +0 -31
- package/src/schema/transform-model.ts +0 -24
- package/src/schema/types.test.ts +0 -28
- package/src/schema/types.ts +0 -163
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -24
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { type IncomingHttpHeaders } from 'http';
|
|
2
|
+
import { EventManager, type IEvent } from '../events/event-manager';
|
|
3
|
+
import type { Request } from '../http/request';
|
|
4
|
+
import type { AllNodeMiddleware } from '../http/request-context';
|
|
5
|
+
import type { Class, PromiseOrValue, UnwrapPromise } from '../typescript';
|
|
6
|
+
import { type Validator } from '../validation';
|
|
7
|
+
import { ContextConsumer } from './context-consumer';
|
|
8
|
+
/**
|
|
9
|
+
* Global interface for declaring dependencies available across all contexts.
|
|
10
|
+
* Extend this interface using declaration merging to add type-safe dependencies.
|
|
11
|
+
*/
|
|
12
|
+
export interface DeclaroDependencies {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base scope interface for contexts with request and node middleware.
|
|
16
|
+
*/
|
|
17
|
+
export interface DeclaroScope {
|
|
18
|
+
/** Middleware that runs on request contexts */
|
|
19
|
+
requestMiddleware: ContextMiddleware<Context>[];
|
|
20
|
+
/** Node.js-compatible middleware */
|
|
21
|
+
nodeMiddleware: AllNodeMiddleware[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Scope interface for request-specific contexts, extending the base scope with request data.
|
|
25
|
+
*/
|
|
26
|
+
export interface DeclaroRequestScope extends DeclaroScope {
|
|
27
|
+
/** The HTTP request object */
|
|
28
|
+
request: Request;
|
|
29
|
+
/** Incoming HTTP headers */
|
|
30
|
+
headers: IncomingHttpHeaders;
|
|
31
|
+
/** Helper function to retrieve a specific header value */
|
|
32
|
+
header: <K extends keyof IncomingHttpHeaders>(header: K) => IncomingHttpHeaders[K] | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extracts the scope type from a Context type.
|
|
36
|
+
*/
|
|
37
|
+
export type ExtractScope<T extends Context<any>> = T extends Context<infer S> ? S : never;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a context type that narrows the scope to a subset.
|
|
40
|
+
* This allows using a context with more dependencies where fewer are expected.
|
|
41
|
+
*/
|
|
42
|
+
export type NarrowContext<TContext extends Context<any>, TNarrowScope extends object> = TContext extends Context<infer TFullScope> ? TNarrowScope extends Partial<TFullScope> ? Context<TNarrowScope> : never : never;
|
|
43
|
+
/**
|
|
44
|
+
* Middleware function that can modify or extend a context.
|
|
45
|
+
*/
|
|
46
|
+
export type ContextMiddleware<C extends Context = Context> = (context: Context<ExtractScope<C>>) => any | Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* Represents the state storage for a context, mapping keys to their attributes.
|
|
49
|
+
*/
|
|
50
|
+
export type ContextState<TContext extends Context> = Record<PropertyKey, ContextAttribute<TContext, StateValue<any>>>;
|
|
51
|
+
/**
|
|
52
|
+
* Function that resolves a value from a context.
|
|
53
|
+
*/
|
|
54
|
+
export type ContextResolver<T> = (context: Context) => StateValue<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Wrapper type for state values.
|
|
57
|
+
*/
|
|
58
|
+
export type StateValue<T> = T;
|
|
59
|
+
/**
|
|
60
|
+
* Types of dependencies that can be registered in a context.
|
|
61
|
+
*/
|
|
62
|
+
export declare enum DependencyType {
|
|
63
|
+
/** A literal value dependency */
|
|
64
|
+
VALUE = "VALUE",
|
|
65
|
+
/** A factory function that creates the dependency */
|
|
66
|
+
FACTORY = "FACTORY",
|
|
67
|
+
/** A class constructor that instantiates the dependency */
|
|
68
|
+
CLASS = "CLASS"
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Factory function type that takes arguments and returns a value.
|
|
72
|
+
*/
|
|
73
|
+
export type FactoryFn<T, A extends any[]> = (...args: A) => T;
|
|
74
|
+
/**
|
|
75
|
+
* Function that loads a value from a context with optional resolution options.
|
|
76
|
+
*/
|
|
77
|
+
export type ValueLoader<C extends Context, T> = (context: C, resolutionOptions?: ResolveOptions) => T;
|
|
78
|
+
/**
|
|
79
|
+
* Filters object keys to only those whose values match a specific type.
|
|
80
|
+
*/
|
|
81
|
+
export type FilterKeysByType<TScope, TValue> = {
|
|
82
|
+
[Key in keyof TScope]: TScope[Key] extends TValue ? Key : never;
|
|
83
|
+
}[keyof TScope];
|
|
84
|
+
/**
|
|
85
|
+
* Filters object keys to only those whose values match a specific type or Promise of that type.
|
|
86
|
+
*/
|
|
87
|
+
export type FilterKeysByAsyncType<TScope, TValue> = {
|
|
88
|
+
[Key in keyof TScope]: TScope[Key] extends PromiseOrValue<TValue> ? Key : never;
|
|
89
|
+
}[keyof TScope];
|
|
90
|
+
/**
|
|
91
|
+
* Maps an array of argument types to their corresponding scope keys.
|
|
92
|
+
*/
|
|
93
|
+
export type FilterArgsByType<TScope, TArgs extends any[]> = {
|
|
94
|
+
[Key in keyof TArgs]: FilterKeysByType<TScope, TArgs[Key]>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Maps an array of argument types to their corresponding scope keys for async values.
|
|
98
|
+
*/
|
|
99
|
+
export type FilterAsyncArgsByType<TScope, TArgs extends any[]> = {
|
|
100
|
+
[Key in keyof TArgs]: FilterKeysByAsyncType<TScope, TArgs[Key]>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Metadata describing how a dependency is registered and resolved in a context.
|
|
104
|
+
*/
|
|
105
|
+
export type ContextAttribute<TContext extends Context<any>, TValue> = {
|
|
106
|
+
/** The key under which this dependency is registered */
|
|
107
|
+
key: PropertyKey;
|
|
108
|
+
/** Function that loads the value from the context */
|
|
109
|
+
value?: ValueLoader<TContext, TValue>;
|
|
110
|
+
/** The type of dependency (value, factory, or class) */
|
|
111
|
+
type: DependencyType;
|
|
112
|
+
/** Options controlling how this dependency is resolved */
|
|
113
|
+
resolveOptions?: ResolveOptions;
|
|
114
|
+
/** Cached value for singleton or eager dependencies */
|
|
115
|
+
cachedValue?: TValue;
|
|
116
|
+
/** Keys of other dependencies that this dependency requires */
|
|
117
|
+
inject: PropertyKey[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Type-safe scope key extraction.
|
|
121
|
+
*/
|
|
122
|
+
export type ScopeKey<S extends object> = keyof S;
|
|
123
|
+
/**
|
|
124
|
+
* Listener function that responds to events in a context.
|
|
125
|
+
*/
|
|
126
|
+
export type ContextListener<C extends Context, E extends IEvent> = (context: C, event: E) => any;
|
|
127
|
+
/**
|
|
128
|
+
* Interface for circular dependency proxies that defer to a real target once resolved.
|
|
129
|
+
* These proxies are created during circular dependency resolution to allow references
|
|
130
|
+
* to objects that haven't been fully constructed yet.
|
|
131
|
+
*/
|
|
132
|
+
export interface ResolveProxy<T = any> {
|
|
133
|
+
/**
|
|
134
|
+
* Identifies this object as a circular proxy.
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
readonly __isProxy: true;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the real target object that this proxy should delegate to.
|
|
140
|
+
* Called internally once the circular dependency is resolved.
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
readonly __resolve: (target: T) => void;
|
|
144
|
+
/** Indicates whether the proxy has been resolved to a real target. */
|
|
145
|
+
readonly __isResolved: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the real target object if resolved, otherwise returns the proxy itself.
|
|
148
|
+
* This allows using the proxy transparently before and after resolution.
|
|
149
|
+
*/
|
|
150
|
+
readonly valueOf: () => T;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Type guard to check if a value is a circular dependency proxy.
|
|
154
|
+
*
|
|
155
|
+
* @param value - The value to check
|
|
156
|
+
* @returns True if the value is a ResolveProxy
|
|
157
|
+
*/
|
|
158
|
+
export declare function isProxy(value: any): value is ResolveProxy;
|
|
159
|
+
export interface ResolveOptions {
|
|
160
|
+
/**
|
|
161
|
+
* If true, an error will be thrown if the dependency is not found. If false, undefined will be returned if the dependency is not found.
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
strict?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* If true, the dependency will be resolved immediately when the context is initialized. This is useful for dependencies that need to perform setup work.
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
eager?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* If true, the dependency will be a singleton, and the same instance will be returned for every request. If false, a new instance will be created each time the dependency is resolved.
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
singleton?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* An optional resolution context that can be used to track resolution state across multiple `resolve` calls. This is primarily used internally to track circular dependencies, but can be useful for advanced use cases.
|
|
177
|
+
*/
|
|
178
|
+
resolutionContext?: Map<PropertyKey, any>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Extracts nested resolution options, preserving resolution state across calls.
|
|
182
|
+
*
|
|
183
|
+
* @param options - The resolve options to extract from
|
|
184
|
+
* @returns Internal resolution options with resolution stack and context
|
|
185
|
+
*/
|
|
186
|
+
export declare function getNestedResolveOptions(options?: ResolveOptions | InternalResolveOptions): InternalResolveOptions;
|
|
187
|
+
/**
|
|
188
|
+
* Internal interface extending ResolveOptions with resolution tracking.
|
|
189
|
+
*/
|
|
190
|
+
export interface InternalResolveOptions extends ResolveOptions {
|
|
191
|
+
/** Stack tracking the current resolution chain to detect circular dependencies */
|
|
192
|
+
resolutionStack: Set<PropertyKey>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Returns the default resolution options for dependencies.
|
|
196
|
+
*
|
|
197
|
+
* @returns Default resolve options with strict, eager, and singleton all set to false
|
|
198
|
+
*/
|
|
199
|
+
export declare function defaultResolveOptions(): ResolveOptions;
|
|
200
|
+
/**
|
|
201
|
+
* Helper function to define type-safe context middleware.
|
|
202
|
+
*
|
|
203
|
+
* @param middleware - The middleware function to define
|
|
204
|
+
* @returns The same middleware function with proper typing
|
|
205
|
+
*/
|
|
206
|
+
export declare function defineContextMiddleware<C extends Context>(middleware: ContextMiddleware<C>): ContextMiddleware<C>;
|
|
207
|
+
/**
|
|
208
|
+
* Configuration options for creating a context.
|
|
209
|
+
*/
|
|
210
|
+
export type ContextOptions = {
|
|
211
|
+
/** Default options to use when resolving dependencies */
|
|
212
|
+
defaultResolveOptions?: ResolveOptions;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Core dependency injection container that manages application dependencies and their lifecycle.
|
|
216
|
+
* Supports values, factories, and classes with automatic dependency resolution and circular dependency handling.
|
|
217
|
+
*/
|
|
218
|
+
export declare class Context<Scope extends object = any> {
|
|
219
|
+
private readonly state;
|
|
220
|
+
private readonly emitter;
|
|
221
|
+
/** The scope object providing typed access to all registered dependencies */
|
|
222
|
+
readonly scope: Scope;
|
|
223
|
+
/** Default options used when resolving dependencies if not overridden */
|
|
224
|
+
protected readonly defaultResolveOptions: ResolveOptions;
|
|
225
|
+
/**
|
|
226
|
+
* Creates a new context instance.
|
|
227
|
+
*
|
|
228
|
+
* @param options - Configuration options for the context
|
|
229
|
+
*/
|
|
230
|
+
constructor(options?: ContextOptions);
|
|
231
|
+
/**
|
|
232
|
+
* Gets the event manager for this context.
|
|
233
|
+
*
|
|
234
|
+
* @returns The event manager instance
|
|
235
|
+
*/
|
|
236
|
+
get events(): EventManager<IEvent>;
|
|
237
|
+
/**
|
|
238
|
+
* Initializes all dependencies marked as eager.
|
|
239
|
+
* Should be called after all dependencies are registered to trigger eager initialization.
|
|
240
|
+
*/
|
|
241
|
+
initializeEagerDependencies(): Promise<void>;
|
|
242
|
+
/**
|
|
243
|
+
* Set a value in context, to be injected later.
|
|
244
|
+
*
|
|
245
|
+
* @param key - The scope key to register the value under
|
|
246
|
+
* @param payload - The value to register
|
|
247
|
+
* @deprecated Use `provideValue` instead, or you can register the same dependency as a factory with `provideFactory` or class with `provideClass`.
|
|
248
|
+
*/
|
|
249
|
+
provide<K extends ScopeKey<Scope>>(key: K, payload: Scope[K]): void;
|
|
250
|
+
/**
|
|
251
|
+
* Manually register a dependency. This should normally be used by utils or integrations that need to register dependencies in creative ways. For normal use cases, using `provideValue`, `provideFactory`, or `provideClass` is sufficient.
|
|
252
|
+
*
|
|
253
|
+
* @param key The key to register the dependency under
|
|
254
|
+
* @param dep The dependency record
|
|
255
|
+
*/
|
|
256
|
+
register<K extends ScopeKey<Scope>>(key: K, dep: ContextAttribute<this, Scope[K]>): void;
|
|
257
|
+
/**
|
|
258
|
+
* Add a dependency to the context.
|
|
259
|
+
*
|
|
260
|
+
* @param key - The scope key to register under
|
|
261
|
+
* @param dep - The dependency attribute to add
|
|
262
|
+
* @returns The registered dependency attribute
|
|
263
|
+
*/
|
|
264
|
+
protected addDep<K extends ScopeKey<Scope>>(key: K, dep: ContextAttribute<this, Scope[K]>): ContextAttribute<this, Scope[K]>;
|
|
265
|
+
/**
|
|
266
|
+
* Register a value in context scope.
|
|
267
|
+
*
|
|
268
|
+
* @param key - The key to register the dependency under
|
|
269
|
+
* @param value - The value to register
|
|
270
|
+
* @param defaultResolveOptions - Optional resolution options
|
|
271
|
+
* @returns The context instance for chaining
|
|
272
|
+
*/
|
|
273
|
+
registerValue<K extends ScopeKey<Scope>>(key: K, value: Scope[K], defaultResolveOptions?: ResolveOptions): this;
|
|
274
|
+
/**
|
|
275
|
+
* Register a dependency as a factory in context scope.
|
|
276
|
+
*
|
|
277
|
+
* @param key - The key to register the dependency under
|
|
278
|
+
* @param factory - A factory function that will be called to generate the value when it is requested
|
|
279
|
+
* @param inject - An array of keys to use when injecting factory args
|
|
280
|
+
* @param defaultResolveOptions - Optional resolution options
|
|
281
|
+
* @returns A chainable instance of context
|
|
282
|
+
*/
|
|
283
|
+
registerFactory<K extends ScopeKey<Scope>, A extends any[]>(key: K, factory: FactoryFn<Scope[K], A>, inject?: FilterArgsByType<Scope, A>, defaultResolveOptions?: ResolveOptions): this;
|
|
284
|
+
/**
|
|
285
|
+
* Register an async factory in context scope.
|
|
286
|
+
* The factory function and its dependencies can be asynchronous.
|
|
287
|
+
*
|
|
288
|
+
* @param key - The key to register the dependency under
|
|
289
|
+
* @param factory - An async factory function that will be called to generate the value
|
|
290
|
+
* @param inject - An array of keys to use when injecting factory args
|
|
291
|
+
* @param defaultResolveOptions - Optional resolution options
|
|
292
|
+
* @returns A chainable instance of context
|
|
293
|
+
*/
|
|
294
|
+
registerAsyncFactory<K extends FilterKeysByType<Scope, Promise<any>>, A extends any[]>(key: K, factory: FactoryFn<Scope[K], A>, inject?: FilterAsyncArgsByType<Scope, A>, defaultResolveOptions?: ResolveOptions): this;
|
|
295
|
+
/**
|
|
296
|
+
* Register a class constructor in context scope.
|
|
297
|
+
* The class will be instantiated with the specified dependencies.
|
|
298
|
+
*
|
|
299
|
+
* @param key - The key to register the dependency under
|
|
300
|
+
* @param Class - The class constructor
|
|
301
|
+
* @param inject - An array of keys to use when injecting constructor arguments
|
|
302
|
+
* @param defaultResolveOptions - Optional resolution options
|
|
303
|
+
* @returns A chainable instance of context
|
|
304
|
+
*/
|
|
305
|
+
registerClass<K extends FilterKeysByType<Scope, InstanceType<T>>, T extends Class<Scope[K] extends {} ? Scope[K] : never>>(key: K, Class: T, inject?: FilterArgsByType<Scope, ConstructorParameters<T>>, defaultResolveOptions?: ResolveOptions): this;
|
|
306
|
+
/**
|
|
307
|
+
* Register an async class constructor in context scope.
|
|
308
|
+
* The class constructor can have async dependencies.
|
|
309
|
+
*
|
|
310
|
+
* @param key - The key to register the dependency under
|
|
311
|
+
* @param Class - The class constructor
|
|
312
|
+
* @param inject - An array of keys to use when injecting constructor arguments
|
|
313
|
+
* @param defaultResolveOptions - Optional resolution options
|
|
314
|
+
* @returns A chainable instance of context
|
|
315
|
+
*/
|
|
316
|
+
registerAsyncClass<K extends FilterKeysByType<Scope, InstanceType<any>>, T extends Class<UnwrapPromise<Scope[K]> extends {} ? UnwrapPromise<Scope[K]> : never>>(key: K, Class: T, inject?: FilterAsyncArgsByType<Scope, ConstructorParameters<T>>, defaultResolveOptions?: ResolveOptions): this;
|
|
317
|
+
/**
|
|
318
|
+
* Gets all dependencies required by a specific dependency.
|
|
319
|
+
*
|
|
320
|
+
* @param key - The key of the dependency to inspect
|
|
321
|
+
* @returns Array of all direct and transitive dependencies
|
|
322
|
+
*/
|
|
323
|
+
getAllDependencies<K extends ScopeKey<Scope>>(key: K): ContextAttribute<this, any>[];
|
|
324
|
+
/**
|
|
325
|
+
* Gets all dependencies that depend on a specific dependency.
|
|
326
|
+
* Useful for cache invalidation when a dependency changes.
|
|
327
|
+
*
|
|
328
|
+
* @param key - The key of the dependency to inspect
|
|
329
|
+
* @param visited - Internal tracking set to prevent infinite recursion
|
|
330
|
+
* @returns Array of all direct and transitive dependents
|
|
331
|
+
*/
|
|
332
|
+
getAllDependents<K extends ScopeKey<Scope>>(key: K, visited?: Set<any>): ContextAttribute<this, any>[];
|
|
333
|
+
/**
|
|
334
|
+
* Introspects a dependency to get its metadata.
|
|
335
|
+
*
|
|
336
|
+
* @param key - The key of the dependency to inspect
|
|
337
|
+
* @returns The context attribute for the dependency, or undefined if not found
|
|
338
|
+
*/
|
|
339
|
+
introspect<K extends ScopeKey<Scope>>(key: K): ContextState<this>[K];
|
|
340
|
+
/**
|
|
341
|
+
* Checks if a cached value is still valid for a dependency.
|
|
342
|
+
* A cache is invalid if the dependency or any of its transitive dependencies have been invalidated.
|
|
343
|
+
*
|
|
344
|
+
* @param key - The key of the dependency to check
|
|
345
|
+
* @param visited - Internal tracking set to prevent infinite recursion in circular dependencies
|
|
346
|
+
* @returns True if the cache is valid, false otherwise
|
|
347
|
+
*/
|
|
348
|
+
protected _cacheIsValid<K extends ScopeKey<Scope>>(key: K, visited?: Set<PropertyKey>): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Creates a proxy object for handling circular dependencies.
|
|
351
|
+
* The proxy initially acts as a placeholder and is later resolved to the real target.
|
|
352
|
+
*
|
|
353
|
+
* @returns A proxy that can be resolved later
|
|
354
|
+
*/
|
|
355
|
+
protected createProxy<T>(): ResolveProxy<T>;
|
|
356
|
+
/**
|
|
357
|
+
* Internal method to resolve a dependency value with circular dependency handling.
|
|
358
|
+
* This is the core resolution logic that handles caching, proxies, and dependency injection.
|
|
359
|
+
*
|
|
360
|
+
* @param key - The key of the dependency to resolve
|
|
361
|
+
* @param resolveOptions - Options controlling the resolution behavior
|
|
362
|
+
* @returns The resolved dependency value
|
|
363
|
+
*/
|
|
364
|
+
protected _resolveValue<K extends ScopeKey<Scope>>(key: K, resolveOptions?: InternalResolveOptions): Scope[K];
|
|
365
|
+
/**
|
|
366
|
+
* Extract a value from context.
|
|
367
|
+
*
|
|
368
|
+
* @param key - The scope key to resolve
|
|
369
|
+
* @returns The resolved value or undefined if not found
|
|
370
|
+
* @deprecated Use `resolve` instead
|
|
371
|
+
*/
|
|
372
|
+
inject<T = any>(key: ScopeKey<Scope>): T | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Resolves a dependency from the context.
|
|
375
|
+
* This is the primary method for retrieving registered dependencies.
|
|
376
|
+
*
|
|
377
|
+
* @param key - The scope key to resolve
|
|
378
|
+
* @param resolveOptions - Options controlling resolution behavior
|
|
379
|
+
* @returns The resolved dependency value
|
|
380
|
+
*/
|
|
381
|
+
resolve<K extends ScopeKey<Scope>>(key: K, resolveOptions?: ResolveOptions): Scope[K];
|
|
382
|
+
/**
|
|
383
|
+
* Ensure that only one copy of this instance exists in this context. Provides the instance if it doesn't exist yet, otherwise inject the cached instance.
|
|
384
|
+
*
|
|
385
|
+
* @param key - The scope key to register under
|
|
386
|
+
* @param instance - The instance to register as a singleton
|
|
387
|
+
* @returns The singleton instance (either the provided one or the existing one)
|
|
388
|
+
*/
|
|
389
|
+
singleton<T = any>(key: ScopeKey<Scope>, instance: T): T;
|
|
390
|
+
/**
|
|
391
|
+
* Instantiate a ContextConsumer class.
|
|
392
|
+
* ContextConsumer classes have automatic access to the context instance.
|
|
393
|
+
*
|
|
394
|
+
* @param Consumer - The ContextConsumer class to instantiate
|
|
395
|
+
* @param args - Additional arguments to pass to the constructor
|
|
396
|
+
* @returns A new instance of the ContextConsumer
|
|
397
|
+
*/
|
|
398
|
+
hydrate<T extends ContextConsumer<this, any[]>, A extends any[]>(Consumer: new (context: this, ...args: A) => T, ...args: A): T;
|
|
399
|
+
/**
|
|
400
|
+
* Create a new context from other instance(s) of Context.
|
|
401
|
+
* Dependencies and event listeners from the provided contexts will be merged into this context.
|
|
402
|
+
*
|
|
403
|
+
* @param contexts - One or more contexts to extend from
|
|
404
|
+
* @returns The current context instance for chaining
|
|
405
|
+
*/
|
|
406
|
+
extend(...contexts: Context[]): this;
|
|
407
|
+
/**
|
|
408
|
+
* Modify context with middleware.
|
|
409
|
+
* Middleware can register dependencies, modify configuration, or perform other setup tasks.
|
|
410
|
+
*
|
|
411
|
+
* @param middleware - One or more middleware functions to apply
|
|
412
|
+
*/
|
|
413
|
+
use<TNarrowScope extends Partial<Scope>>(...middleware: ContextMiddleware<Context<TNarrowScope>>[]): Promise<void>;
|
|
414
|
+
use(...middleware: ContextMiddleware[]): Promise<void>;
|
|
415
|
+
/**
|
|
416
|
+
* Validate context ensuring all validators are valid.
|
|
417
|
+
*
|
|
418
|
+
* @param validators - One or more validator functions to run
|
|
419
|
+
* @returns The validation result
|
|
420
|
+
*/
|
|
421
|
+
validate(...validators: Validator<Context>[]): import("..").Validation<this>;
|
|
422
|
+
/**
|
|
423
|
+
* Validate context ensuring at least one validator is valid.
|
|
424
|
+
*
|
|
425
|
+
* @param validators - One or more validator functions to run
|
|
426
|
+
* @returns The validation result
|
|
427
|
+
*/
|
|
428
|
+
validateAny(...validators: Validator<Context>[]): import("..").Validation<any>;
|
|
429
|
+
/**
|
|
430
|
+
* Add a callback to listen for an event in this context.
|
|
431
|
+
*
|
|
432
|
+
* @param type - The event type to listen for
|
|
433
|
+
* @param listener - The callback function to invoke when the event is emitted
|
|
434
|
+
* @returns A function to unregister the listener
|
|
435
|
+
*/
|
|
436
|
+
on<E extends IEvent = IEvent>(type: IEvent['type'], listener: ContextListener<this, E>): () => void;
|
|
437
|
+
/**
|
|
438
|
+
* Emit an event in this context.
|
|
439
|
+
*
|
|
440
|
+
* @param event - The event type string or event object to emit
|
|
441
|
+
* @returns A promise that resolves when all event listeners have completed
|
|
442
|
+
*/
|
|
443
|
+
emit(event: string | IEvent): Promise<void>;
|
|
444
|
+
/**
|
|
445
|
+
* Narrow the context to a subset of its scope type.
|
|
446
|
+
* This is a type-only operation - it returns the same instance with a narrower type.
|
|
447
|
+
*
|
|
448
|
+
* @returns A context with a narrower scope type that shares the same underlying state
|
|
449
|
+
*/
|
|
450
|
+
narrow<TNarrowScope extends Partial<Scope>>(): NarrowContext<this, TNarrowScope>;
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context/context.ts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F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../../src/context/context.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-context.test.d.ts","sourceRoot":"","sources":["../../../src/context/legacy-context.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Context } from '../context/context';
|
|
2
|
-
import { Validator } from '../validation';
|
|
2
|
+
import { type Validator } from '../validation';
|
|
3
3
|
export declare class ContextValidator {
|
|
4
4
|
static all(...validators: Validator<Context>[]): (context: Context) => Promise<boolean>;
|
|
5
5
|
static any(...validators: Validator<Context>[]): (context: Context) => Promise<boolean>;
|
|
6
6
|
}
|
|
7
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/context/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,eAAe,CAAA;AAErE,qBAAa,gBAAgB;IACzB,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,IAC5B,SAAS,OAAO;IAIlC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,IAC5B,SAAS,OAAO;CAGrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dataflow/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Merge } from '../typescript';
|
|
2
|
+
export declare function merge<T, Source1>(target: T, source1: Source1): Merge<T, Source1>;
|
|
3
|
+
export declare function merge<T, Source1, Source2>(target: T, source1: Source1, source2: Source2): Merge<Merge<T, Source1>, Source2>;
|
|
4
|
+
export declare function merge<T, Source1, Source2, Source3>(target: T, source1: Source1, source2: Source2, source3: Source3): Merge<Merge<Merge<T, Source1>, Source2>, Source3>;
|
|
5
|
+
export declare function merge<T, Source1, Source2, Source3, Source4>(target: T, source1: Source1, source2: Source2, source3: Source3, source4: Source4): Merge<Merge<Merge<Merge<T, Source1>, Source2>, Source3>, Source4>;
|
|
6
|
+
export declare function merge<T, Source1, Source2, Source3, Source4, Source5>(target: T, source1: Source1, source2: Source2, source3: Source3, source4: Source4, source5: Source5): Merge<Merge<Merge<Merge<Merge<T, Source1>, Source2>, Source3>, Source4>, Source5>;
|
|
7
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/dataflow/objects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AACjF,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EACrC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACjB,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;AACpC,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAC9C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACjB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;AACpD,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACjB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;AACpE,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAChE,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACjB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.test.d.ts","sourceRoot":"","sources":["../../../src/dataflow/objects.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
export interface IError {
|
|
2
3
|
code: number;
|
|
3
4
|
message: string;
|
|
4
|
-
meta
|
|
5
|
+
meta?: any;
|
|
5
6
|
}
|
|
6
7
|
export declare abstract class BaseError extends Error implements IError {
|
|
7
|
-
readonly meta
|
|
8
|
+
readonly meta?: any;
|
|
8
9
|
readonly code: number;
|
|
9
10
|
constructor(message: string, meta?: any);
|
|
10
11
|
toJSON(): {
|
|
@@ -18,9 +19,20 @@ export declare class SystemError extends BaseError {
|
|
|
18
19
|
readonly code: number;
|
|
19
20
|
constructor(message: string, meta?: any);
|
|
20
21
|
}
|
|
22
|
+
export interface ValidationErrorMeta {
|
|
23
|
+
result: StandardSchemaV1.Result<any>;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
21
26
|
export declare class ValidationError extends BaseError {
|
|
22
27
|
readonly code: number;
|
|
23
|
-
|
|
28
|
+
readonly meta?: ValidationErrorMeta;
|
|
29
|
+
constructor(message: string, meta?: ValidationErrorMeta);
|
|
30
|
+
toJSON(): {
|
|
31
|
+
result: StandardSchemaV1.Result<any> | undefined;
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
meta: any;
|
|
35
|
+
};
|
|
24
36
|
}
|
|
25
37
|
export declare class NotFoundError extends BaseError {
|
|
26
38
|
readonly code: number;
|
|
@@ -34,3 +46,4 @@ export declare class ForbiddenError extends BaseError {
|
|
|
34
46
|
readonly code: number;
|
|
35
47
|
constructor(message: string, meta?: any);
|
|
36
48
|
}
|
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,GAAG,CAAA;CACb;AAED,8BAAsB,SAAU,SAAQ,KAAM,YAAW,MAAM;IAC3D,SAAgB,IAAI,CAAC,EAAE,GAAG,CAAA;IAC1B,SAAgB,IAAI,EAAE,MAAM,CAAM;gBAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAMhC,MAAM;;;;;IAQN,QAAQ;CAGlB;AAED,qBAAa,WAAY,SAAQ,SAAS;IACtC,SAAgB,IAAI,EAAE,MAAM,CAAM;gBAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAI1C;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB;AAED,qBAAa,eAAgB,SAAQ,SAAS;IAC1C,SAAgB,IAAI,EAAE,MAAM,CAAM;IAClC,SAAgB,IAAI,CAAC,EAAE,mBAAmB,CAAA;gBAE9B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,mBAAmB;IAMhD,MAAM;;;;;;CAMhB;AAED,qBAAa,aAAc,SAAQ,SAAS;IACxC,SAAgB,IAAI,EAAE,MAAM,CAAM;gBAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAI1C;AAED,qBAAa,iBAAkB,SAAQ,SAAS;IAC5C,SAAgB,IAAI,EAAE,MAAM,CAAM;gBAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAI1C;AAED,qBAAa,cAAe,SAAQ,SAAS;IACzC,SAAgB,IAAI,EAAE,MAAM,CAAM;gBAEtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAI1C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface IEvent {
|
|
2
|
+
type: Readonly<string>;
|
|
3
|
+
}
|
|
4
|
+
export type Listener<E extends IEvent> = (event: E) => any;
|
|
5
|
+
export declare class EventManager<E extends IEvent = IEvent> {
|
|
6
|
+
protected readonly listeners: {
|
|
7
|
+
[key: string]: Listener<E>[];
|
|
8
|
+
};
|
|
9
|
+
getListeners(event: string): Listener<E>[];
|
|
10
|
+
getEvents(): string[];
|
|
11
|
+
extend(eventManager: EventManager): void;
|
|
12
|
+
forwardTo(eventManager: EventManager): () => void;
|
|
13
|
+
on<Event extends E>(event: Event['type'] | Event['type'][], listener: Listener<Event>): () => void;
|
|
14
|
+
emitAsync(event: E): Promise<void>;
|
|
15
|
+
emitAll(event: E): Promise<void>;
|
|
16
|
+
emit(event: E): void;
|
|
17
|
+
protected getListenerArray(event: string): Listener<E>[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=event-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-manager.d.ts","sourceRoot":"","sources":["../../../src/events/event-manager.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CACzB;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAA;AAE1D,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC/C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE;QAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;KAC/B,CAAK;IAEN,YAAY,CAAC,KAAK,EAAE,MAAM;IAO1B,SAAS;IAIT,MAAM,CAAC,YAAY,EAAE,YAAY;IAOjC,SAAS,CAAC,YAAY,EAAE,YAAY;IAQpC,EAAE,CAAC,KAAK,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;IAiB/E,SAAS,CAAC,KAAK,EAAE,CAAC;IAOlB,OAAO,CAAC,KAAK,EAAE,CAAC;IAItB,IAAI,CAAC,KAAK,EAAE,CAAC;IAIb,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM;CAO3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-manager.spec.d.ts","sourceRoot":"","sources":["../../../src/events/event-manager.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context } from '../context/context';
|
|
2
|
+
/**
|
|
3
|
+
* Get the headers from the request.
|
|
4
|
+
*
|
|
5
|
+
* @deprecated You can now inject headers directly from Context<RequestScope>.
|
|
6
|
+
* This function will be removed in a future version.
|
|
7
|
+
* @param context The context to use for the request.
|
|
8
|
+
* @returns The headers of the request, or an empty object if not available.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useHeaders(context: Context): any;
|
|
11
|
+
/**
|
|
12
|
+
* Get a specific header from the request.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated You can now inject headers directly from Context<RequestScope>.
|
|
15
|
+
* This function will be removed in a future version.
|
|
16
|
+
* @param context The context to use for the request.
|
|
17
|
+
* @param header The name of the header to retrieve.
|
|
18
|
+
* @returns The value of the specified header, or undefined if not available.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useHeader(context: Context, header: string): any;
|
|
21
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/http/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,OAI1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAIzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.spec.d.ts","sourceRoot":"","sources":["../../../src/http/headers.spec.ts"],"names":[],"mappings":""}
|