@arts-n-crafts/ts 3.19.0 → 5.0.0-rc.2
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 +221 -6
- package/package.json +109 -22
- package/packages/v3/dist/index.cjs +63 -72
- package/packages/v3/dist/index.cjs.map +1 -1
- package/packages/v3/dist/index.d.cts +22 -22
- package/packages/v3/dist/index.d.ts +22 -22
- package/packages/v3/dist/index.js +63 -72
- package/packages/v3/dist/index.js.map +1 -1
- package/packages/v3/package.json +49 -50
- package/packages/v4/dist/index.cjs +71 -126
- package/packages/v4/dist/index.cjs.map +1 -1
- package/packages/v4/dist/index.d.cts +36 -47
- package/packages/v4/dist/index.d.ts +36 -47
- package/packages/v4/dist/index.js +72 -125
- package/packages/v4/dist/index.js.map +1 -1
- package/packages/v4/package.json +49 -50
- package/packages/v5/dist/DomainEvent-CSzUMw46.d.cts +23 -0
- package/packages/v5/dist/DomainEvent-w1jyCjai.d.ts +23 -0
- package/packages/v5/dist/Intent-B6l0bHZU.d.cts +13 -0
- package/packages/v5/dist/Intent-BLNY6RoG.d.ts +13 -0
- package/packages/v5/dist/Message-c9XdBoh4.d.cts +36 -0
- package/packages/v5/dist/Message-c9XdBoh4.d.ts +36 -0
- package/packages/v5/dist/Rejection-D9PlzquK.d.cts +19 -0
- package/packages/v5/dist/Rejection-D9PlzquK.d.ts +19 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.cjs +4 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.cjs.map +1 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.d.cts +77 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.d.ts +77 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.js +3 -0
- package/packages/v5/dist/adapters/outbound/capabilities/index.js.map +1 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.cjs +4 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.cjs.map +1 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.d.cts +68 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.d.ts +68 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.js +3 -0
- package/packages/v5/dist/adapters/outbound/shapes/index.js.map +1 -0
- package/packages/v5/dist/core/capabilities/index.cjs +4 -0
- package/packages/v5/dist/core/capabilities/index.cjs.map +1 -0
- package/packages/v5/dist/core/capabilities/index.d.cts +33 -0
- package/packages/v5/dist/core/capabilities/index.d.ts +33 -0
- package/packages/v5/dist/core/capabilities/index.js +3 -0
- package/packages/v5/dist/core/capabilities/index.js.map +1 -0
- package/packages/v5/dist/core/shapes/index.cjs +4 -0
- package/packages/v5/dist/core/shapes/index.cjs.map +1 -0
- package/packages/v5/dist/core/shapes/index.d.cts +27 -0
- package/packages/v5/dist/core/shapes/index.d.ts +27 -0
- package/packages/v5/dist/core/shapes/index.js +3 -0
- package/packages/v5/dist/core/shapes/index.js.map +1 -0
- package/packages/v5/dist/useCases/command/capabilities/index.cjs +4 -0
- package/packages/v5/dist/useCases/command/capabilities/index.cjs.map +1 -0
- package/packages/v5/dist/useCases/command/capabilities/index.d.cts +27 -0
- package/packages/v5/dist/useCases/command/capabilities/index.d.ts +27 -0
- package/packages/v5/dist/useCases/command/capabilities/index.js +3 -0
- package/packages/v5/dist/useCases/command/capabilities/index.js.map +1 -0
- package/packages/v5/dist/useCases/command/shapes/index.cjs +4 -0
- package/packages/v5/dist/useCases/command/shapes/index.cjs.map +1 -0
- package/packages/v5/dist/useCases/command/shapes/index.d.cts +78 -0
- package/packages/v5/dist/useCases/command/shapes/index.d.ts +78 -0
- package/packages/v5/dist/useCases/command/shapes/index.js +3 -0
- package/packages/v5/dist/useCases/command/shapes/index.js.map +1 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.cjs +4 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.cjs.map +1 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.d.cts +12 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.d.ts +12 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.js +3 -0
- package/packages/v5/dist/useCases/policy/capabilities/index.js.map +1 -0
- package/packages/v5/dist/useCases/query/capabilities/index.cjs +4 -0
- package/packages/v5/dist/useCases/query/capabilities/index.cjs.map +1 -0
- package/packages/v5/dist/useCases/query/capabilities/index.d.cts +8 -0
- package/packages/v5/dist/useCases/query/capabilities/index.d.ts +8 -0
- package/packages/v5/dist/useCases/query/capabilities/index.js +3 -0
- package/packages/v5/dist/useCases/query/capabilities/index.js.map +1 -0
- package/packages/v5/dist/useCases/query/shapes/index.cjs +4 -0
- package/packages/v5/dist/useCases/query/shapes/index.cjs.map +1 -0
- package/packages/v5/dist/useCases/query/shapes/index.d.cts +7 -0
- package/packages/v5/dist/useCases/query/shapes/index.d.ts +7 -0
- package/packages/v5/dist/useCases/query/shapes/index.js +3 -0
- package/packages/v5/dist/useCases/query/shapes/index.js.map +1 -0
- package/packages/v5/package.json +59 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { M as Message } from '../../../Message-c9XdBoh4.js';
|
|
2
|
+
import { D as DomainEvent } from '../../../DomainEvent-w1jyCjai.js';
|
|
3
|
+
import { I as Intent } from '../../../Intent-BLNY6RoG.js';
|
|
4
|
+
import { R as Rejection } from '../../../Rejection-D9PlzquK.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a successful decision made by a decider.
|
|
8
|
+
*
|
|
9
|
+
* An accepted decision is the result of a command passing all business rules.
|
|
10
|
+
* It carries one or more domain events to be appended to the event stream,
|
|
11
|
+
* and zero or more intents to be staged in the outbox.
|
|
12
|
+
*
|
|
13
|
+
* An accepted decision does NOT mean the command has been fully processed —
|
|
14
|
+
* it means the domain has decided what should happen. Infrastructure concerns
|
|
15
|
+
* (persisting events, dispatching intents) are handled by the use case handler.
|
|
16
|
+
*/
|
|
17
|
+
type Accepted<TEvent extends DomainEvent, TIntent extends Intent = never> = {
|
|
18
|
+
readonly accepted: true;
|
|
19
|
+
readonly events: [TEvent, ...TEvent[]];
|
|
20
|
+
readonly intents: TIntent[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Represents a rejection decision made by a decider.
|
|
24
|
+
*
|
|
25
|
+
* A rejection is a first-class business outcome — not an exception or an error.
|
|
26
|
+
* It means the command was valid and understood, but one or more business rules
|
|
27
|
+
* prevented it from being accepted. The domain explicitly said no.
|
|
28
|
+
*
|
|
29
|
+
* Rejections are never appended to the event stream. They may be recorded in
|
|
30
|
+
* an audit log by the use case handler, and can be published as an integration
|
|
31
|
+
* event if other bounded contexts need to know the command did not get through.
|
|
32
|
+
*/
|
|
33
|
+
type Rejected<TRejection extends Rejection> = {
|
|
34
|
+
readonly accepted: false;
|
|
35
|
+
readonly rejection: TRejection;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The return type of a decider's decide() function.
|
|
39
|
+
*
|
|
40
|
+
* A Decision is a discriminated union on `accepted`, enabling exhaustive
|
|
41
|
+
* pattern matching at the use case handler and adapter level.
|
|
42
|
+
*
|
|
43
|
+
* Both `Accepted` and `Rejected` are expected business outcomes and are
|
|
44
|
+
* returned as `Ok` from the use case. Only infrastructure failures such as
|
|
45
|
+
* a unavailable event store are modelled as `Err` via `GatewayFailure`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Use case handler
|
|
49
|
+
* const decision = decider.decide(command, state);
|
|
50
|
+
*
|
|
51
|
+
* if (!decision.accepted) {
|
|
52
|
+
* await auditLog.record(command, decision.rejection);
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* return okAsync(decision);
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Adapter
|
|
59
|
+
* const result = await useCase.execute(command);
|
|
60
|
+
*
|
|
61
|
+
* result.match(
|
|
62
|
+
* (decision) => {
|
|
63
|
+
* if (!decision.accepted) {
|
|
64
|
+
* const status = rejectionCodeToStatus[decision.rejection.code];
|
|
65
|
+
* return reply.status(status).send({ error: decision.rejection.reason });
|
|
66
|
+
* }
|
|
67
|
+
* return reply.status(200).send({ events: decision.events });
|
|
68
|
+
* },
|
|
69
|
+
* (error) => reply.status(503).send({ error: 'Service unavailable' }) // GatewayFailure
|
|
70
|
+
* );
|
|
71
|
+
*/
|
|
72
|
+
type Decision<TEvent extends DomainEvent, TIntent extends Intent = never, TRejection extends Rejection = never> = Accepted<TEvent, TIntent> | Rejected<TRejection>;
|
|
73
|
+
|
|
74
|
+
interface Command<TType = string, TPayload = unknown> extends Message<TType, TPayload> {
|
|
75
|
+
readonly kind: "command";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type { Accepted, Command, Decision, Rejected };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { I as Intent } from '../../../Intent-B6l0bHZU.cjs';
|
|
2
|
+
import '../../../Message-c9XdBoh4.cjs';
|
|
3
|
+
|
|
4
|
+
interface HandleIntent<TIntent extends Intent, TResult = Promise<void>> {
|
|
5
|
+
handle(input: TIntent): TResult;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface RelayPendingIntents<TResult = Promise<void>> {
|
|
9
|
+
relay(): TResult;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { HandleIntent, RelayPendingIntents };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { I as Intent } from '../../../Intent-BLNY6RoG.js';
|
|
2
|
+
import '../../../Message-c9XdBoh4.js';
|
|
3
|
+
|
|
4
|
+
interface HandleIntent<TIntent extends Intent, TResult = Promise<void>> {
|
|
5
|
+
handle(input: TIntent): TResult;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface RelayPendingIntents<TResult = Promise<void>> {
|
|
9
|
+
relay(): TResult;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { HandleIntent, RelayPendingIntents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arts-n-crafts/ts-v5-package",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/arts-n-crafts/typescript.git"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "bun run --hot examples/shell/main.ts",
|
|
17
|
+
"lint": "oxlint src/",
|
|
18
|
+
"lint:fix": "oxlint --fix src/",
|
|
19
|
+
"fmt": "oxfmt src/",
|
|
20
|
+
"fmt:check": "oxfmt --check src/",
|
|
21
|
+
"test": "NODE_ENV=test vitest",
|
|
22
|
+
"test:watch": "NODE_ENV=test vitest --coverage --watch",
|
|
23
|
+
"test:ui": "NODE_ENV=test vitest --watch --coverage --ui",
|
|
24
|
+
"coverage": "NODE_ENV=test vitest --coverage",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"build": "rimraf dist && tsup"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
31
|
+
"@commitlint/cli": "^20.5.0",
|
|
32
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
33
|
+
"@cucumber/cucumber": "^12.8.3",
|
|
34
|
+
"@hono/standard-validator": "^0.2.2",
|
|
35
|
+
"@release-it/bumper": "^7.0.5",
|
|
36
|
+
"@types/bun": "^1.3.12",
|
|
37
|
+
"@vitest/coverage-istanbul": "^4.1.5",
|
|
38
|
+
"@vitest/ui": "^4.1.5",
|
|
39
|
+
"changelogen": "^0.6.2",
|
|
40
|
+
"commitizen": "^4.3.1",
|
|
41
|
+
"countries-list": "^3.3.0",
|
|
42
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
43
|
+
"globals": "^17.5.0",
|
|
44
|
+
"hono": "^4.12.18",
|
|
45
|
+
"husky": "^9.1.7",
|
|
46
|
+
"oxfmt": "^0.46.0",
|
|
47
|
+
"oxide.ts": "^1.1.0",
|
|
48
|
+
"oxlint": "^1.61.0",
|
|
49
|
+
"rimraf": "^6.1.3",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"uuid": "^14.0.0",
|
|
52
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
53
|
+
"vitest": "^4.1.5",
|
|
54
|
+
"zod": "^4.4.2"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"typescript": "^6.0.3"
|
|
58
|
+
}
|
|
59
|
+
}
|