@afora/core 0.0.2 → 0.0.3
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/README.md +220 -733
- package/dist/core/application/application.d.ts +9 -1
- package/dist/core/application/exceptions.d.ts +28 -0
- package/dist/core/application/registry.d.ts +33 -0
- package/dist/core/application/start.d.ts +51 -0
- package/dist/core/application/types/application.interface.d.ts +186 -7
- package/dist/core/blueprint/types/blueprint.interface.d.ts +66 -11
- package/dist/core/blueprint/types/slice.interface.d.ts +7 -2
- package/dist/core/command/command.d.ts +25 -0
- package/dist/core/command/exceptions.d.ts +33 -0
- package/dist/core/command/types/command.interface.d.ts +102 -0
- package/dist/core/environment/environment.d.ts +4 -1
- package/dist/core/exception/exception.d.ts +4 -0
- package/dist/core/exception/exported.d.ts +4 -0
- package/dist/core/json.d.ts +10 -0
- package/dist/core/output/exceptions.d.ts +8 -0
- package/dist/core/output/openapi-sink.d.ts +83 -0
- package/dist/core/output/output.d.ts +19 -0
- package/dist/core/output/problem.d.ts +15 -0
- package/dist/core/output/select.d.ts +14 -0
- package/dist/core/output/stage.d.ts +24 -0
- package/dist/core/output/status.d.ts +17 -0
- package/dist/core/output/types/output.interface.d.ts +171 -0
- package/dist/core/property/abstract-property.d.ts +8 -7
- package/dist/core/property/define-property.d.ts +8 -7
- package/dist/core/property/property.d.ts +26 -15
- package/dist/core/property/types/abstract-property-constructor.type.d.ts +8 -7
- package/dist/core/property/types/define-property.interface.d.ts +5 -4
- package/dist/core/property/types/optional-property.type.d.ts +5 -5
- package/dist/core/property/types/property-collection.type.d.ts +2 -2
- package/dist/core/property/types/property-constructor.type.d.ts +5 -1
- package/dist/core/property/types/property-options.interface.d.ts +17 -8
- package/dist/core/property/types/property-type.interface.d.ts +7 -3
- package/dist/core/property/types/property.interface.d.ts +5 -4
- package/dist/core/record/abstract-record.d.ts +12 -4
- package/dist/core/record/types/plugin.interface.d.ts +13 -3
- package/dist/core/record/types/record.interface.d.ts +20 -8
- package/dist/core/repository/exceptions.d.ts +4 -0
- package/dist/core/repository/in-memory.d.ts +3 -0
- package/dist/core/repository/provider.d.ts +6 -0
- package/dist/core/repository/query.d.ts +9 -0
- package/dist/core/repository/references.d.ts +4 -2
- package/dist/core/repository/repository.d.ts +4 -2
- package/dist/core/repository/state.d.ts +4 -0
- package/dist/core/repository/types/query.interface.d.ts +67 -0
- package/dist/core/repository/types/repository.interface.d.ts +13 -13
- package/dist/core/schema/types/schema.interface.d.ts +11 -4
- package/dist/core/symbols/meta.d.ts +2 -0
- package/dist/core/use-case/exceptions.d.ts +10 -0
- package/dist/core/use-case/scope.d.ts +21 -0
- package/dist/core/use-case/steps/describe.d.ts +13 -0
- package/dist/core/use-case/steps/references.d.ts +27 -0
- package/dist/core/use-case/steps/run.d.ts +20 -0
- package/dist/core/use-case/steps/types/steps.interface.d.ts +153 -0
- package/dist/core/use-case/steps/validate.d.ts +17 -0
- package/dist/core/use-case/use-case.d.ts +74 -9
- package/dist/experimental.d.ts +6 -0
- package/dist/experimental.js +123 -0
- package/dist/index-hn82hm31.js +1651 -0
- package/dist/index-sw2b9ehx.js +5019 -0
- package/dist/index.d.ts +30 -11
- package/dist/index.js +325 -4142
- package/dist/std/blueprint-plugin.d.ts +10 -10
- package/dist/std/blueprint.d.ts +10 -10
- package/dist/std/entity.d.ts +2 -2
- package/dist/std/properties/contact.d.ts +4 -4
- package/dist/std/properties/enum.d.ts +1 -1
- package/dist/std/properties/headless.d.ts +1 -1
- package/dist/std/properties/identity.d.ts +2 -2
- package/dist/std/properties/password.d.ts +1 -1
- package/dist/std/properties/primitives.d.ts +5 -5
- package/dist/std/properties/time.d.ts +2 -2
- package/dist/std/record-plugins.d.ts +12 -12
- package/dist/std/record.d.ts +1 -1
- package/dist/std/stages.d.ts +2 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.js +502 -0
- package/dist/testing/provider-contract.d.ts +22 -0
- package/package.json +28 -8
|
@@ -16,13 +16,17 @@ export declare function isApplication(value: unknown): value is AnyApplication;
|
|
|
16
16
|
* `describe()` gives the graph. With a `provider` (or that of the last
|
|
17
17
|
* application extended that has one), `repositories` are bound to it.
|
|
18
18
|
*/
|
|
19
|
-
export declare function applicationOf<const Name extends string, const Extended extends readonly AnyApplication[] = readonly [], const Properties extends ApplicationCollections["properties"] = Record<never, never>, const Blueprints extends ApplicationCollections["blueprints"] = Record<never, never>, const Records extends ApplicationCollections["records"] = Record<never, never>, const Entities extends ApplicationCollections["entities"] = Record<never, never>, const Environments extends ApplicationCollections["environments"] = Record<never, never>, const Repositories extends ApplicationCollections["repositories"] = Record<never, never>>(settings: ApplicationSettings<Name, Extended, {
|
|
19
|
+
export declare function applicationOf<const Name extends string, const Extended extends readonly AnyApplication[] = readonly [], const Properties extends ApplicationCollections["properties"] = Record<never, never>, const Blueprints extends ApplicationCollections["blueprints"] = Record<never, never>, const Records extends ApplicationCollections["records"] = Record<never, never>, const Entities extends ApplicationCollections["entities"] = Record<never, never>, const Environments extends ApplicationCollections["environments"] = Record<never, never>, const Repositories extends ApplicationCollections["repositories"] = Record<never, never>, const UseCases extends ApplicationCollections["useCases"] = Record<never, never>, const Commands extends ApplicationCollections["commands"] = Record<never, never>, const Outputs extends ApplicationCollections["outputs"] = Record<never, never>, const Exceptions extends ApplicationCollections["exceptions"] = Record<never, never>>(settings: ApplicationSettings<Name, Extended, {
|
|
20
20
|
properties: Properties;
|
|
21
21
|
blueprints: Blueprints;
|
|
22
22
|
records: Records;
|
|
23
23
|
entities: Entities;
|
|
24
24
|
environments: Environments;
|
|
25
25
|
repositories: Repositories;
|
|
26
|
+
useCases: UseCases;
|
|
27
|
+
commands: Commands;
|
|
28
|
+
outputs: Outputs;
|
|
29
|
+
exceptions: Exceptions;
|
|
26
30
|
}>): IApplication<Name, MergedCollections<{
|
|
27
31
|
properties: Properties;
|
|
28
32
|
blueprints: Blueprints;
|
|
@@ -30,4 +34,8 @@ export declare function applicationOf<const Name extends string, const Extended
|
|
|
30
34
|
entities: Entities;
|
|
31
35
|
environments: Environments;
|
|
32
36
|
repositories: Repositories;
|
|
37
|
+
useCases: UseCases;
|
|
38
|
+
commands: Commands;
|
|
39
|
+
outputs: Outputs;
|
|
40
|
+
exceptions: Exceptions;
|
|
33
41
|
}, Extended>>;
|
|
@@ -27,3 +27,31 @@ export declare const UnregisteredRepositoryDependency: import("../../index.js").
|
|
|
27
27
|
readonly repository: string;
|
|
28
28
|
readonly dependency: string;
|
|
29
29
|
}>;
|
|
30
|
+
/** A dependency of a use case of the application (a use case, repository or environment) is not registered in it. */
|
|
31
|
+
export declare const UnregisteredUseCaseDependency: import("../../index.js").DeclaredExceptionClass<{
|
|
32
|
+
readonly useCase: string;
|
|
33
|
+
readonly dependency: string;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* The application provider is made by `providerFrom` and the application has
|
|
37
|
+
* not been started: `await app.start()` creates it.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ApplicationNotStarted: import("../../index.js").DeclaredExceptionClass<{
|
|
40
|
+
/** The application, or none when `useApplication()` found none started. */
|
|
41
|
+
readonly application?: string;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* `app.start()` was called while another application is the started one of
|
|
45
|
+
* the process; `start({ replace: true })` stops it and takes its place.
|
|
46
|
+
*/
|
|
47
|
+
export declare const ApplicationAlreadyStarted: import("../../index.js").DeclaredExceptionClass<{
|
|
48
|
+
readonly current: string;
|
|
49
|
+
readonly attempted: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* `app.start()` found environments whose variables are missing or rejected;
|
|
53
|
+
* `details.environments` gives the keys of each, by name.
|
|
54
|
+
*/
|
|
55
|
+
export declare const InvalidApplicationEnvironment: import("../../index.js").DeclaredExceptionClass<{
|
|
56
|
+
readonly environments: Readonly<Record<string, readonly string[]>>;
|
|
57
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AnyApplication } from "./types/application.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Declares the type of the application `useApplication()` gives, by module
|
|
4
|
+
* augmentation, once per project:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* declare module "@afora/core" {
|
|
8
|
+
* interface Register { application: typeof App }
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export interface Register {
|
|
13
|
+
}
|
|
14
|
+
/** The application declared in `Register`, or any application. */
|
|
15
|
+
export type RegisteredApplication = Register extends {
|
|
16
|
+
readonly application: infer Application extends AnyApplication;
|
|
17
|
+
} ? Application : AnyApplication;
|
|
18
|
+
/**
|
|
19
|
+
* The application started in this process, from anywhere, without importing
|
|
20
|
+
* it (so a hand-written use case or handler that the application imports can
|
|
21
|
+
* reach it without an import cycle). Throws `ApplicationNotStarted` when none
|
|
22
|
+
* is. Typed by `Register`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useApplication(): RegisteredApplication;
|
|
25
|
+
/**
|
|
26
|
+
* Forgets the started application without stopping it, e.g. between tests,
|
|
27
|
+
* so that another one can start.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resetApplication(): void;
|
|
30
|
+
/** The started application of the process, if any. @internal */
|
|
31
|
+
export declare function startedApplication(): AnyApplication | undefined;
|
|
32
|
+
/** Makes `application` the started one. @internal */
|
|
33
|
+
export declare function setStartedApplication(application: AnyApplication | undefined): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type AnyEnvironment, type EnvironmentDependencies, type MergedEnvironment } from "../environment/environment.js";
|
|
2
|
+
import type { IRepositoryProvider } from "../repository/types/repository.interface.js";
|
|
3
|
+
import { Kind } from "../symbols/kind.js";
|
|
4
|
+
/**
|
|
5
|
+
* A provider an application creates when it starts, from the variables of
|
|
6
|
+
* its environments: what `providerFrom` makes.
|
|
7
|
+
*/
|
|
8
|
+
export interface ProviderFactory<Environment extends EnvironmentDependencies = EnvironmentDependencies> {
|
|
9
|
+
readonly [Kind]: "provider-factory";
|
|
10
|
+
/** The environments whose variables `create` gets, as a list. */
|
|
11
|
+
readonly environments: readonly AnyEnvironment[];
|
|
12
|
+
readonly create: (env: MergedEnvironment<Environment>) => IRepositoryProvider | Promise<IRepositoryProvider>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A provider made on `app.start()`: `create` gets the variables of
|
|
16
|
+
* `environmentDependencies` (one environment or a list, merged in order),
|
|
17
|
+
* read and validated then, e.g.
|
|
18
|
+
* `providerFrom(Database, (env) => drizzleProvider({ db: connect(env.DATABASE_URL), tables }))`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function providerFrom<const Environment extends EnvironmentDependencies>(environmentDependencies: Environment, create: (env: MergedEnvironment<Environment>) => IRepositoryProvider | Promise<IRepositoryProvider>): ProviderFactory<Environment>;
|
|
21
|
+
/** Whether `value` was made by `providerFrom`. */
|
|
22
|
+
export declare function isProviderFactory(value: unknown): value is ProviderFactory;
|
|
23
|
+
/**
|
|
24
|
+
* The provider the repositories of an application are bound to when it was
|
|
25
|
+
* declared with `providerFrom`: each call goes to the provider made on start,
|
|
26
|
+
* and throws `ApplicationNotStarted` before it.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function deferredProvider(factory: ProviderFactory, application: string): IRepositoryProvider;
|
|
30
|
+
/** Whether `provider` was made by `deferredProvider`. @internal */
|
|
31
|
+
export declare function isDeferredProvider(provider: unknown): boolean;
|
|
32
|
+
/** The environments the factory behind `provider` reads, if it is deferred. @internal */
|
|
33
|
+
export declare function deferredEnvironments(provider: unknown): readonly AnyEnvironment[];
|
|
34
|
+
/**
|
|
35
|
+
* Makes the provider behind `provider` once, from the variables of its
|
|
36
|
+
* environments (already validated by the caller); later calls give the same.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function startDeferred(provider: IRepositoryProvider): Promise<IRepositoryProvider> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Closes the provider made on start and forgets it, so that calls throw
|
|
42
|
+
* `ApplicationNotStarted` again; a provider that is not deferred is closed.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function stopProvider(provider: IRepositoryProvider): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Throws `InvalidCommandDeclaration` when `provider` cannot run the
|
|
48
|
+
* transactions of `commands` (it has no `transaction`, or says it has none).
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function checkTransactions(source: string, provider: IRepositoryProvider, commands: readonly string[]): void;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyCommand } from "../../command/types/command.interface.js";
|
|
2
|
+
import type { AnyEnvironment, EnvironmentValue } from "../../environment/environment.js";
|
|
3
|
+
import type { ExceptionLayers } from "../../exception/enums/exception-layers.js";
|
|
4
|
+
import type { AnyOutput, StageDescription } from "../../output/types/output.interface.js";
|
|
2
5
|
import type { RecordPluginDescriptor } from "../../record/types/plugin.interface.js";
|
|
6
|
+
import type { ProviderDescription } from "../../repository/types/query.interface.js";
|
|
3
7
|
import type { AnyRepository, IRepositoryProvider } from "../../repository/types/repository.interface.js";
|
|
4
8
|
import type { Kind } from "../../symbols/kind.js";
|
|
9
|
+
import type { UseCaseStepDescription } from "../../use-case/steps/types/steps.interface.js";
|
|
10
|
+
import type { AnyExceptionClass, AnyUseCaseClass } from "../../use-case/use-case.js";
|
|
11
|
+
import type { ProviderFactory } from "../start.js";
|
|
5
12
|
type Named<Value> = Readonly<Record<string, Value>>;
|
|
6
13
|
/** The declarations of an application, by name, one collection for each kind. */
|
|
7
14
|
export interface ApplicationCollections {
|
|
@@ -11,8 +18,15 @@ export interface ApplicationCollections {
|
|
|
11
18
|
readonly entities: Named<unknown>;
|
|
12
19
|
readonly environments: Named<AnyEnvironment>;
|
|
13
20
|
readonly repositories: Named<AnyRepository>;
|
|
21
|
+
readonly useCases: Named<AnyUseCaseClass>;
|
|
22
|
+
readonly commands: Named<AnyCommand>;
|
|
23
|
+
readonly outputs: Named<AnyOutput>;
|
|
24
|
+
readonly exceptions: Named<AnyExceptionClass>;
|
|
14
25
|
}
|
|
15
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The keys of `ApplicationCollections`.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
16
30
|
export type ApplicationCollectionKey = keyof ApplicationCollections;
|
|
17
31
|
/** What `applicationOf` takes. */
|
|
18
32
|
export interface ApplicationSettings<Name extends string, Extended extends readonly AnyApplication[], Collections extends ApplicationCollections> {
|
|
@@ -26,14 +40,27 @@ export interface ApplicationSettings<Name extends string, Extended extends reado
|
|
|
26
40
|
readonly entities?: Collections["entities"];
|
|
27
41
|
readonly environments?: Collections["environments"];
|
|
28
42
|
readonly repositories?: Collections["repositories"];
|
|
43
|
+
/** Use cases, keyed by their `useCaseName`. */
|
|
44
|
+
readonly useCases?: Collections["useCases"];
|
|
45
|
+
/** Commands, keyed by their `commandName`; every use case of each must be in `useCases`. */
|
|
46
|
+
readonly commands?: Collections["commands"];
|
|
47
|
+
/** Outputs, keyed by their `outputName`; every command of each must be in `commands`. */
|
|
48
|
+
readonly outputs?: Collections["outputs"];
|
|
49
|
+
/** Exceptions made by `exceptionOf`, keyed by their `name`. */
|
|
50
|
+
readonly exceptions?: Collections["exceptions"];
|
|
29
51
|
/**
|
|
30
52
|
* The provider of the repositories that did not declare one; the
|
|
31
|
-
* repositories of the application read and write through it.
|
|
53
|
+
* repositories of the application read and write through it. With
|
|
54
|
+
* `providerFrom`, it is made by `app.start()` from the variables of its
|
|
55
|
+
* environments, and calls before that throw `ApplicationNotStarted`.
|
|
32
56
|
*/
|
|
33
|
-
readonly provider?: IRepositoryProvider;
|
|
57
|
+
readonly provider?: IRepositoryProvider | ProviderFactory;
|
|
34
58
|
}
|
|
35
59
|
type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
|
|
36
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* `Own` with the declarations of `Extended` merged in.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
37
64
|
export type MergedCollections<Own extends ApplicationCollections, Extended extends readonly AnyApplication[]> = {
|
|
38
65
|
readonly [Key in ApplicationCollectionKey]: Own[Key] & UnionToIntersection<Extended[number][Key]>;
|
|
39
66
|
};
|
|
@@ -56,12 +83,72 @@ export interface IApplication<Name extends string, Collections extends Applicati
|
|
|
56
83
|
* write through that provider (unless they declared their own).
|
|
57
84
|
*/
|
|
58
85
|
readonly repositories: Collections["repositories"];
|
|
86
|
+
/**
|
|
87
|
+
* Its use cases. With a `provider` they are subclasses whose repositories
|
|
88
|
+
* are the bound ones, through child use cases too; the same subclass every
|
|
89
|
+
* time. Without one they are the declared classes.
|
|
90
|
+
*/
|
|
91
|
+
readonly useCases: Collections["useCases"];
|
|
92
|
+
/**
|
|
93
|
+
* Its commands. With a `provider` they are rebuilt over the bound use
|
|
94
|
+
* cases (same settings), memoized; without one, the declared commands.
|
|
95
|
+
*/
|
|
96
|
+
readonly commands: Collections["commands"];
|
|
97
|
+
/**
|
|
98
|
+
* Its outputs. With a `provider` they are rebuilt over the bound commands
|
|
99
|
+
* (same name, statuses and stages), memoized; without one, the declared outputs.
|
|
100
|
+
*/
|
|
101
|
+
readonly outputs: Collections["outputs"];
|
|
102
|
+
/** Its exceptions. */
|
|
103
|
+
readonly exceptions: Collections["exceptions"];
|
|
59
104
|
/** The bound version of a repository registered in the application. */
|
|
60
105
|
repository<Repository extends AnyRepository>(repository: Repository): Repository;
|
|
106
|
+
/** The bound version of a use case registered in the application. */
|
|
107
|
+
useCase<UseCase extends AnyUseCaseClass>(useCase: UseCase): UseCase;
|
|
108
|
+
/** The bound version of a command registered in the application. */
|
|
109
|
+
command<Command extends AnyCommand>(command: Command): Command;
|
|
110
|
+
/** The bound version of an output registered in the application. */
|
|
111
|
+
output<Output extends AnyOutput>(output: Output): Output;
|
|
61
112
|
/** A new application with the declarations of `others` too; this one is left as it is. */
|
|
62
113
|
extend<const Others extends readonly AnyApplication[]>(...others: Others): IApplication<Name, MergedCollections<Collections, Others>>;
|
|
63
114
|
/** A format-neutral, JSON-serializable graph of its declarations. */
|
|
64
115
|
describe(): ApplicationDescription;
|
|
116
|
+
/**
|
|
117
|
+
* Validates every environment it registers at once
|
|
118
|
+
* (`InvalidApplicationEnvironment`), makes the provider of `providerFrom`
|
|
119
|
+
* and checks the transactions of its commands against it. Idempotent: the
|
|
120
|
+
* same promise until it fails or `stop()` is called.
|
|
121
|
+
*/
|
|
122
|
+
start(options?: ApplicationStartOptions): Promise<IApplication<Name, Collections>>;
|
|
123
|
+
/**
|
|
124
|
+
* Closes its provider (`close`, if it has one); a provider of
|
|
125
|
+
* `providerFrom` is made again by the next `start()`. It stops being the
|
|
126
|
+
* started application of the process.
|
|
127
|
+
*/
|
|
128
|
+
stop(): Promise<void>;
|
|
129
|
+
/** The variables of an environment registered in the application. */
|
|
130
|
+
get<Environment extends AnyEnvironment>(environment: Environment): EnvironmentValue<Environment>;
|
|
131
|
+
/** The bound version of a command registered in the application. */
|
|
132
|
+
get<Command extends AnyCommand>(command: Command): Command;
|
|
133
|
+
/** The bound version of an output registered in the application. */
|
|
134
|
+
get<Output extends AnyOutput>(output: Output): Output;
|
|
135
|
+
/** The bound version of a use case registered in the application. */
|
|
136
|
+
get<UseCase extends AnyUseCaseClass>(useCase: UseCase): UseCase;
|
|
137
|
+
/** The bound version of a repository registered in the application. */
|
|
138
|
+
get<Repository extends AnyRepository>(repository: Repository): Repository;
|
|
139
|
+
/** Whether `start()` completed and `stop()` was not called since. */
|
|
140
|
+
readonly started: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** What `app.start()` takes. */
|
|
143
|
+
export interface ApplicationStartOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Become the started application of the process (what `useApplication()`
|
|
146
|
+
* gives). Default `true`; another one already started throws
|
|
147
|
+
* `ApplicationAlreadyStarted`.
|
|
148
|
+
*/
|
|
149
|
+
readonly register?: boolean;
|
|
150
|
+
/** Stop the started application of the process and take its place, e.g. on hot reload. Default `false`. */
|
|
151
|
+
readonly replace?: boolean;
|
|
65
152
|
}
|
|
66
153
|
/** Any application. */
|
|
67
154
|
export type AnyApplication = IApplication<string, any>;
|
|
@@ -134,11 +221,98 @@ export interface RecordDescription {
|
|
|
134
221
|
};
|
|
135
222
|
readonly plugins: readonly RecordPluginDescriptor[];
|
|
136
223
|
}
|
|
224
|
+
/** What a use case depends on, by the name it has in the application. */
|
|
225
|
+
export interface UseCaseDependencyDescription {
|
|
226
|
+
readonly kind: "use-case" | "repository" | "environment";
|
|
227
|
+
readonly ref: string;
|
|
228
|
+
}
|
|
229
|
+
/** A use case: its metadata, fields and what it depends on. */
|
|
230
|
+
export interface UseCaseDescription {
|
|
231
|
+
readonly from: string;
|
|
232
|
+
/** The `useCaseName`, equal to its key. */
|
|
233
|
+
readonly name: string;
|
|
234
|
+
readonly description?: string;
|
|
235
|
+
readonly tags: readonly string[];
|
|
236
|
+
readonly deprecated: boolean;
|
|
237
|
+
readonly input: FieldsDescription;
|
|
238
|
+
readonly response: FieldsDescription;
|
|
239
|
+
readonly context?: FieldsDescription;
|
|
240
|
+
/**
|
|
241
|
+
* The names of the registered blueprints that are the `input`, `response`
|
|
242
|
+
* or `context` (their fields stay described above). Absent for the ones
|
|
243
|
+
* that are not registered.
|
|
244
|
+
*/
|
|
245
|
+
readonly refs?: {
|
|
246
|
+
readonly input?: string;
|
|
247
|
+
readonly response?: string;
|
|
248
|
+
readonly context?: string;
|
|
249
|
+
};
|
|
250
|
+
/** A registered exception, or one exported by the package, by name. */
|
|
251
|
+
readonly errors: readonly ({
|
|
252
|
+
readonly kind: "exception";
|
|
253
|
+
readonly ref: string;
|
|
254
|
+
} | {
|
|
255
|
+
readonly kind: "core";
|
|
256
|
+
readonly name: string;
|
|
257
|
+
})[];
|
|
258
|
+
readonly dependencies: Readonly<Record<string, UseCaseDependencyDescription>>;
|
|
259
|
+
/**
|
|
260
|
+
* How it runs: `steps` when `execute` is the interpreter of the declared
|
|
261
|
+
* steps, `opaque` for a hand-written `execute`.
|
|
262
|
+
*/
|
|
263
|
+
readonly implementation: {
|
|
264
|
+
readonly kind: "steps";
|
|
265
|
+
readonly steps: readonly UseCaseStepDescription[];
|
|
266
|
+
} | {
|
|
267
|
+
readonly kind: "opaque";
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/** A command: its metadata, context, operations and policies. */
|
|
271
|
+
export interface CommandDescription {
|
|
272
|
+
readonly from: string;
|
|
273
|
+
readonly name: string;
|
|
274
|
+
readonly description?: string;
|
|
275
|
+
readonly tags: readonly string[];
|
|
276
|
+
readonly context?: FieldsDescription;
|
|
277
|
+
/** The name of the registered blueprint that is the `context`, if it is one. */
|
|
278
|
+
readonly refs?: {
|
|
279
|
+
readonly context?: string;
|
|
280
|
+
};
|
|
281
|
+
/** Each operation and the name of its use case in the application. */
|
|
282
|
+
readonly operations: Readonly<Record<string, {
|
|
283
|
+
readonly ref: string;
|
|
284
|
+
}>>;
|
|
285
|
+
readonly transaction: boolean;
|
|
286
|
+
/** The names of its environments, when it declares any. */
|
|
287
|
+
readonly environments?: readonly string[];
|
|
288
|
+
readonly events: "after-commit" | "manual" | {
|
|
289
|
+
readonly kind: "opaque";
|
|
290
|
+
};
|
|
291
|
+
readonly onEventError?: {
|
|
292
|
+
readonly kind: "opaque";
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/** An output: its commands, statuses and pipe. */
|
|
296
|
+
export interface OutputDescription {
|
|
297
|
+
readonly from: string;
|
|
298
|
+
readonly name: string;
|
|
299
|
+
readonly commands: readonly string[];
|
|
300
|
+
readonly statuses: Readonly<Record<string, number>>;
|
|
301
|
+
readonly pipe: readonly StageDescription[];
|
|
302
|
+
}
|
|
303
|
+
/** An exception: its layer and, when declared as a string, its message. */
|
|
304
|
+
export interface ExceptionDescription {
|
|
305
|
+
readonly from: string;
|
|
306
|
+
readonly layer: ExceptionLayers;
|
|
307
|
+
readonly message?: string;
|
|
308
|
+
}
|
|
137
309
|
/** The graph `describe` gives: every declaration by name, with its origin in `from`. */
|
|
138
310
|
export interface ApplicationDescription {
|
|
139
311
|
readonly name: string;
|
|
140
312
|
/** The names of the applications it extends directly. */
|
|
141
313
|
readonly extends: readonly string[];
|
|
314
|
+
/** The provider of the application (or of the last extended one), present only when configured. */
|
|
315
|
+
readonly provider?: ProviderDescription;
|
|
142
316
|
readonly properties: Readonly<Record<string, PropertyDescription & {
|
|
143
317
|
readonly from: string;
|
|
144
318
|
}>>;
|
|
@@ -156,12 +330,17 @@ export interface ApplicationDescription {
|
|
|
156
330
|
readonly from: string;
|
|
157
331
|
readonly entity: string;
|
|
158
332
|
readonly actions: readonly string[];
|
|
333
|
+
readonly deletion: "hard" | "soft";
|
|
159
334
|
/** The names of the repositories of the entities its entity holds. */
|
|
160
335
|
readonly relations: readonly string[];
|
|
161
336
|
/** The names of its `environmentDependencies`. */
|
|
162
337
|
readonly environments: readonly string[];
|
|
163
|
-
/**
|
|
164
|
-
readonly provider
|
|
338
|
+
/** Its own provider, present only when it declared one. */
|
|
339
|
+
readonly provider?: ProviderDescription;
|
|
165
340
|
}>>;
|
|
341
|
+
readonly useCases: Readonly<Record<string, UseCaseDescription>>;
|
|
342
|
+
readonly commands: Readonly<Record<string, CommandDescription>>;
|
|
343
|
+
readonly outputs: Readonly<Record<string, OutputDescription>>;
|
|
344
|
+
readonly exceptions: Readonly<Record<string, ExceptionDescription>>;
|
|
166
345
|
}
|
|
167
346
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Static, TArray, TObject, TOptional, TSchema, TUnsafe } from "typebox";
|
|
1
|
+
import type { Static, TArray, TObject, TOptional, TReadonly, TSchema, TUnsafe } from "typebox";
|
|
2
2
|
import type { ParseResult } from "../../parse/types/parse.interface.js";
|
|
3
3
|
import type { propertyOf } from "../../property/property.js";
|
|
4
4
|
import type { OptionalProperty } from "../../property/types/optional-property.type.js";
|
|
@@ -59,7 +59,7 @@ type FieldMode = "data" | "value" | "input";
|
|
|
59
59
|
* recurse into `AnyBlueprint` endlessly.
|
|
60
60
|
*/
|
|
61
61
|
type FieldSchema<Field, Mode extends FieldMode> = 0 extends 1 & Field ? TSchema : Field extends {
|
|
62
|
-
readonly type: IPropertyType<infer SchemaType extends TSchema>;
|
|
62
|
+
readonly type: IPropertyType<infer SchemaType extends TSchema, any>;
|
|
63
63
|
} ? SchemaType : Field extends AnyRecordClass ? RecordSchema<Field, Mode> : Field extends OptionalRecord<infer Record> ? TOptional<RecordSchema<Record, Mode>> : Field extends {
|
|
64
64
|
readonly properties: infer Properties extends IBlueprintCollection;
|
|
65
65
|
readonly optional: infer Optional;
|
|
@@ -83,26 +83,70 @@ type RecordInput<Record extends AnyRecordClass> = ConstructorParameters<Record>[
|
|
|
83
83
|
type CollectionSchema<Properties extends IBlueprintCollection, Mode extends FieldMode> = TObject<{
|
|
84
84
|
[Key in keyof Properties]: FieldSchema<Properties[Key], Mode>;
|
|
85
85
|
}>;
|
|
86
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* The schema of a single field of a blueprint; a record is its blueprint's object.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
87
90
|
export type BlueprintPropertySchema<Field> = FieldSchema<Field, "data">;
|
|
88
91
|
/** The object schema described by a collection, one key per field. */
|
|
89
92
|
export type BlueprintSchema<Properties extends IBlueprintCollection> = CollectionSchema<Properties, "data">;
|
|
93
|
+
/**
|
|
94
|
+
* The value of a single field of a blueprint, its records as `Mode` says:
|
|
95
|
+
* `Static` of its `FieldSchema`, read from the fields themselves. A property
|
|
96
|
+
* gives the value its type carries, so `Static` is never measured on a
|
|
97
|
+
* generic schema, which costs TypeScript about a second on every check.
|
|
98
|
+
*/
|
|
99
|
+
type FieldValue<Field, Mode extends FieldMode> = 0 extends 1 & Field ? Static<TSchema> : Field extends {
|
|
100
|
+
readonly type: IPropertyType<infer SchemaType, infer Value>;
|
|
101
|
+
} ? 0 extends 1 & SchemaType ? Static<TSchema> : Value : Field extends AnyRecordClass ? RecordValueOf<Field, Mode> : Field extends OptionalRecord<infer Record> ? RecordValueOf<Record, Mode> : Field extends {
|
|
102
|
+
readonly properties: infer Properties extends IBlueprintCollection;
|
|
103
|
+
} ? CollectionValue<Properties, Mode> : Field extends {
|
|
104
|
+
readonly item: infer Item;
|
|
105
|
+
} ? FieldValue<Item, Mode>[] : never;
|
|
106
|
+
/** The value of a record field, as `RecordSchema` describes it. */
|
|
107
|
+
type RecordValueOf<Record extends AnyRecordClass, Mode extends FieldMode> = Mode extends "value" ? InstanceType<Record> : Mode extends "input" ? InstanceType<Record> | RecordInput<Record> | AcceptedBy<Record> : Record["blueprint"] extends IBlueprint<infer Properties, boolean> ? CollectionValue<Properties, "data"> : never;
|
|
108
|
+
type ReadonlyOptionalKeys<Schemas> = {
|
|
109
|
+
[Key in keyof Schemas]: Schemas[Key] extends TReadonly<TSchema> ? Schemas[Key] extends TOptional<Schemas[Key]> ? Key : never : never;
|
|
110
|
+
}[keyof Schemas];
|
|
111
|
+
type ReadonlyKeys<Schemas> = {
|
|
112
|
+
[Key in keyof Schemas]: Schemas[Key] extends TReadonly<TSchema> ? Schemas[Key] extends TOptional<Schemas[Key]> ? never : Key : never;
|
|
113
|
+
}[keyof Schemas];
|
|
114
|
+
type OptionalKeys<Schemas> = {
|
|
115
|
+
[Key in keyof Schemas]: Schemas[Key] extends TOptional<TSchema> ? Schemas[Key] extends TReadonly<Schemas[Key]> ? never : Key : never;
|
|
116
|
+
}[keyof Schemas];
|
|
117
|
+
type RequiredKeys<Schemas> = keyof Omit<Schemas, ReadonlyOptionalKeys<Schemas> | ReadonlyKeys<Schemas> | OptionalKeys<Schemas>>;
|
|
118
|
+
/**
|
|
119
|
+
* `Static` of `CollectionSchema`, built as TypeBox builds the value of an
|
|
120
|
+
* object (the same keys and modifiers, in the same order, so it displays the
|
|
121
|
+
* same), but from the value of each field. `Result` is a parameter so that no
|
|
122
|
+
* alias names the object.
|
|
123
|
+
*/
|
|
124
|
+
type CollectionValue<Properties extends IBlueprintCollection, Mode extends FieldMode, Schemas = {
|
|
125
|
+
[Key in keyof Properties]: FieldSchema<Properties[Key], Mode>;
|
|
126
|
+
}, Values extends Record<PropertyKey, unknown> = {
|
|
127
|
+
[Key in keyof Properties]: FieldValue<Properties[Key], Mode>;
|
|
128
|
+
}, WithModifiers extends Record<PropertyKey, unknown> = Evaluate<Readonly<Partial<Pick<Values, ReadonlyOptionalKeys<Schemas>>>> & Readonly<Pick<Values, ReadonlyKeys<Schemas>>> & Partial<Pick<Values, OptionalKeys<Schemas>>> & Required<Pick<Values, RequiredKeys<Schemas>>>>, Result = keyof Properties extends never ? object : {
|
|
129
|
+
[Key in keyof WithModifiers]: WithModifiers[Key];
|
|
130
|
+
}> = Result;
|
|
131
|
+
type Evaluate<Type> = {
|
|
132
|
+
[Key in keyof Type]: Type[Key];
|
|
133
|
+
} & {};
|
|
90
134
|
/**
|
|
91
135
|
* The value accepted by a collection; optional fields become optional keys,
|
|
92
136
|
* and a record field takes an instance of its class, e.g. `{ author: User }`.
|
|
93
137
|
*/
|
|
94
|
-
export type BlueprintValue<Properties extends IBlueprintCollection> =
|
|
138
|
+
export type BlueprintValue<Properties extends IBlueprintCollection> = CollectionValue<Properties, "value">;
|
|
95
139
|
/**
|
|
96
140
|
* What a blueprint accepts to build its value: as `BlueprintValue`, but a
|
|
97
141
|
* record field also takes the plain input of its blueprint, which becomes an
|
|
98
142
|
* instance of the record, e.g. `{ author: { name: "Jane" } }`.
|
|
99
143
|
*/
|
|
100
|
-
export type BlueprintInput<Properties extends IBlueprintCollection> =
|
|
144
|
+
export type BlueprintInput<Properties extends IBlueprintCollection> = CollectionValue<Properties, "input">;
|
|
101
145
|
/**
|
|
102
146
|
* The plain value of a collection, as its schema describes it: a record
|
|
103
147
|
* field is the object of the record's blueprint, as its `toJSON` gives.
|
|
104
148
|
*/
|
|
105
|
-
export type BlueprintData<Properties extends IBlueprintCollection> =
|
|
149
|
+
export type BlueprintData<Properties extends IBlueprintCollection> = CollectionValue<Properties, "data">;
|
|
106
150
|
type Override<Base, Overrides> = {
|
|
107
151
|
[Key in keyof Base | keyof Overrides]: Key extends keyof Overrides ? Overrides[Key] : Key extends keyof Base ? Base[Key] : never;
|
|
108
152
|
};
|
|
@@ -123,6 +167,7 @@ export type BlueprintPluginContext<Sources extends readonly {
|
|
|
123
167
|
/**
|
|
124
168
|
* The field factories of every plugin source, in order; a later source
|
|
125
169
|
* replaces a factory of an earlier one with the same name.
|
|
170
|
+
* @internal
|
|
126
171
|
*/
|
|
127
172
|
export type BlueprintFactoryContext<Sources extends readonly BlueprintSource[]> = Sources extends readonly [
|
|
128
173
|
infer Head,
|
|
@@ -130,11 +175,17 @@ export type BlueprintFactoryContext<Sources extends readonly BlueprintSource[]>
|
|
|
130
175
|
] ? Override<Head extends {
|
|
131
176
|
readonly factories?: infer Factories;
|
|
132
177
|
} ? NonNullable<Factories> extends infer Defined extends IBlueprintFactories ? string extends keyof Defined ? Record<never, never> : Defined : Record<never, never> : Record<never, never>, BlueprintFactoryContext<Tail>> : Record<never, never>;
|
|
133
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* The fields of the joined blueprints; a later one replaces a key of an earlier one.
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
134
182
|
export type JoinedProperties<Blueprints extends readonly {
|
|
135
183
|
readonly properties: IBlueprintCollection;
|
|
136
184
|
}[]> = BlueprintPluginContext<Blueprints> extends infer Properties extends IBlueprintCollection ? Properties : never;
|
|
137
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* A list of every field of a collection, e.g. `{ tags: IBlueprintList<Tag> }`.
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
138
189
|
export type ListProperties<Properties> = {
|
|
139
190
|
readonly [Key in keyof Properties]: Properties[Key] extends BlueprintField ? IBlueprintList<Properties[Key]> : never;
|
|
140
191
|
};
|
|
@@ -162,11 +213,15 @@ export type BlueprintContext<Sources extends readonly BlueprintSource[]> = Calla
|
|
|
162
213
|
/**
|
|
163
214
|
* Every field of a collection, its properties callable with options, as
|
|
164
215
|
* `ctx.number({ min: 1 })`.
|
|
216
|
+
* @internal
|
|
165
217
|
*/
|
|
166
218
|
export type CallableProperties<Fields> = {
|
|
167
219
|
readonly [Key in keyof Fields]: Fields[Key] extends AnyPropertyConstructor ? CallableProperty<Fields[Key]> : Fields[Key];
|
|
168
220
|
};
|
|
169
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* The optional version of every field of a collection, blueprints and records included.
|
|
223
|
+
* @internal
|
|
224
|
+
*/
|
|
170
225
|
export type OptionalProperties<Properties> = {
|
|
171
226
|
readonly [Key in keyof Properties]: Properties[Key] extends AnyPropertyConstructor ? OptionalProperty<Properties[Key]> : Properties[Key] extends AnyBlueprint ? OptionalBlueprint<Properties[Key]> : Properties[Key] extends AnyBlueprintList ? OptionalBlueprintList<Properties[Key]> : Properties[Key] extends AnyRecordClass ? OptionalRecord<Properties[Key]> : Properties[Key] extends AnyOptionalRecord ? Properties[Key] : never;
|
|
172
227
|
};
|
|
@@ -178,7 +233,7 @@ export interface IBlueprint<Properties extends IBlueprintCollection, Optional ex
|
|
|
178
233
|
/** The fields picked by the blueprint's definition. */
|
|
179
234
|
readonly properties: Properties;
|
|
180
235
|
/** The general schema of every field of the blueprint. */
|
|
181
|
-
readonly schema: ISchema<BlueprintSchema<Properties>>;
|
|
236
|
+
readonly schema: ISchema<BlueprintSchema<Properties>, BlueprintData<Properties>>;
|
|
182
237
|
/** Whether, as a field of another blueprint, it accepts `undefined`. */
|
|
183
238
|
readonly optional: Optional;
|
|
184
239
|
/**
|
|
@@ -232,7 +287,7 @@ export interface IBlueprintList<Item extends BlueprintField, Optional extends bo
|
|
|
232
287
|
*/
|
|
233
288
|
readonly "~standard": StandardSchemaV1.Props<ListShape<Item, "input", Optional>, ListShape<Item, "value", Optional>>;
|
|
234
289
|
}
|
|
235
|
-
type ListShape<Item, Mode extends FieldMode, Optional extends boolean> = Optional extends true ?
|
|
290
|
+
type ListShape<Item, Mode extends FieldMode, Optional extends boolean> = Optional extends true ? FieldValue<Item, Mode>[] | undefined : FieldValue<Item, Mode>[];
|
|
236
291
|
/** `List` as a field that accepts `undefined`. */
|
|
237
292
|
export type OptionalBlueprintList<List extends AnyBlueprintList> = List extends IBlueprintList<infer Item, boolean> ? IBlueprintList<Item, true> : never;
|
|
238
293
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RecordUniqueKeys } from "../../record/types/plugin.interface.js";
|
|
2
2
|
import type { RecordConstructor } from "../../record/types/record.interface.js";
|
|
3
|
+
import type { Meta } from "../../symbols/meta.js";
|
|
3
4
|
import type { AnyBlueprint, AnyBlueprintList, AnyOptionalRecord, AnyRecordClass, BlueprintData, BlueprintField, IBlueprint, IBlueprintCollection, IBlueprintList, OptionalRecord } from "./blueprint.interface.js";
|
|
4
5
|
/** What a mask of a field is: the mask of its item, of its keys, or nothing for a property. */
|
|
5
6
|
type FieldMask<Field> = 0 extends 1 & Field ? object : Field extends AnyBlueprintList ? FieldMask<Field["item"]> : Field extends AnyBlueprint ? SliceMask<Field["properties"]> : Field extends AnyRecordClass ? SliceMask<Field["blueprint"]["properties"]> : Field extends AnyOptionalRecord ? SliceMask<Field["record"]["blueprint"]["properties"]> : never;
|
|
@@ -33,7 +34,9 @@ type SliceField<Field, Mask> = 0 extends 1 & Field ? never : Field extends AnyBl
|
|
|
33
34
|
* `change` keys among them. A plain record, not an entity.
|
|
34
35
|
*/
|
|
35
36
|
type SlicedRecord<Original extends AnyRecordClass, Mask> = SlicedProperties<Original["blueprint"]["properties"], Mask> extends infer Properties extends IBlueprintCollection ? RecordConstructor<Properties, KeptChange<InstanceType<Original>, keyof Properties>[], KeptUnique<Original, keyof Properties>, unknown, {
|
|
36
|
-
readonly
|
|
37
|
+
readonly [Meta]: {
|
|
38
|
+
readonly blueprint: Original["blueprint"];
|
|
39
|
+
};
|
|
37
40
|
}> : never;
|
|
38
41
|
type KeptChange<Instance, Keys> = Instance extends {
|
|
39
42
|
readonly change: infer Change;
|
|
@@ -50,7 +53,9 @@ export type SlicedBlueprint<Properties, Mask> = AsBlueprint<SlicedProperties<Pro
|
|
|
50
53
|
* the keys their blueprint requires) and lists.
|
|
51
54
|
*/
|
|
52
55
|
export type SlicedValue<Value, Mask> = Value extends readonly (infer Item)[] ? SlicedValue<Item, Mask>[] : Value extends {
|
|
53
|
-
readonly
|
|
56
|
+
readonly [Meta]: {
|
|
57
|
+
readonly blueprint: IBlueprint<infer Properties, boolean>;
|
|
58
|
+
};
|
|
54
59
|
toJSON(): unknown;
|
|
55
60
|
} ? SlicedValue<BlueprintData<Properties>, Mask> : Value extends {
|
|
56
61
|
toJSON(): infer Json;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IBlueprintCollection } from "../blueprint/types/blueprint.interface.js";
|
|
2
|
+
import { type EnvironmentDependencies } from "../environment/environment.js";
|
|
3
|
+
import type { IRepositoryProvider } from "../repository/types/repository.interface.js";
|
|
4
|
+
import type { AnyCommand, CommandOf, CommandSettings, CommandUseCases } from "./types/command.interface.js";
|
|
5
|
+
/**
|
|
6
|
+
* Checks now that the repositories of `command` share a provider that has
|
|
7
|
+
* `transaction`, as its first call would; an application calls it when it
|
|
8
|
+
* binds the command to its provider.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function verifyCommand(command: object): void;
|
|
12
|
+
/**
|
|
13
|
+
* The provider whose transaction runs the calls of `command`, or `undefined`
|
|
14
|
+
* without a transaction or a repository.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function commandTransactionProvider(command: object): IRepositoryProvider | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Groups use cases under operation names and is the boundary of a call: the
|
|
20
|
+
* context is validated once, a transaction can wrap the use case, and the
|
|
21
|
+
* events it raised are handled by a policy once it succeeded.
|
|
22
|
+
*/
|
|
23
|
+
export declare function commandOf<const UseCases extends CommandUseCases, Context extends IBlueprintCollection | undefined = undefined, Environment extends EnvironmentDependencies | undefined = undefined>(settings: CommandSettings<UseCases, Context, Environment>): CommandOf<UseCases, Context, Environment>;
|
|
24
|
+
/** Whether `value` is a command made by `commandOf`. */
|
|
25
|
+
export declare function isCommand(value: unknown): value is AnyCommand;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Issue } from "../parse/types/parse.interface.js";
|
|
2
|
+
/** `commandOf` got a setting it cannot use; `details.reason` says which. */
|
|
3
|
+
export declare const InvalidCommandDeclaration: import("../../index.js").DeclaredExceptionClass<{
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
}>;
|
|
6
|
+
/** A command was asked for an operation it does not declare. */
|
|
7
|
+
export declare const UnknownCommandOperation: import("../../index.js").DeclaredExceptionClass<{
|
|
8
|
+
readonly operation: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** The context of a call does not fit the context blueprint of the command. */
|
|
11
|
+
export declare const InvalidCommandContext: import("../../index.js").DeclaredExceptionClass<{
|
|
12
|
+
readonly issues: readonly Issue[];
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* The `env` of a call holds a key no environment of the command declares, or
|
|
16
|
+
* a value its blueprint rejects. It is configuration, not input.
|
|
17
|
+
*/
|
|
18
|
+
export declare const InvalidCommandEnvironment: import("../../index.js").DeclaredExceptionClass<{
|
|
19
|
+
readonly keys: readonly string[];
|
|
20
|
+
readonly issues: readonly Issue[];
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* An event handler failed after the call succeeded (and, with a
|
|
24
|
+
* transaction, committed). `handled` events ran before the failure and
|
|
25
|
+
* `remaining` events after it were not handled.
|
|
26
|
+
*/
|
|
27
|
+
export declare const CommandEventFailed: import("../../index.js").DeclaredExceptionClass<{
|
|
28
|
+
readonly operation: string;
|
|
29
|
+
/** The failed event; absent when a handler policy failed. */
|
|
30
|
+
readonly event?: string;
|
|
31
|
+
readonly handled: number;
|
|
32
|
+
readonly remaining: number;
|
|
33
|
+
}>;
|