@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.
Files changed (79) hide show
  1. package/README.md +221 -6
  2. package/package.json +109 -22
  3. package/packages/v3/dist/index.cjs +63 -72
  4. package/packages/v3/dist/index.cjs.map +1 -1
  5. package/packages/v3/dist/index.d.cts +22 -22
  6. package/packages/v3/dist/index.d.ts +22 -22
  7. package/packages/v3/dist/index.js +63 -72
  8. package/packages/v3/dist/index.js.map +1 -1
  9. package/packages/v3/package.json +49 -50
  10. package/packages/v4/dist/index.cjs +71 -126
  11. package/packages/v4/dist/index.cjs.map +1 -1
  12. package/packages/v4/dist/index.d.cts +36 -47
  13. package/packages/v4/dist/index.d.ts +36 -47
  14. package/packages/v4/dist/index.js +72 -125
  15. package/packages/v4/dist/index.js.map +1 -1
  16. package/packages/v4/package.json +49 -50
  17. package/packages/v5/dist/DomainEvent-CSzUMw46.d.cts +23 -0
  18. package/packages/v5/dist/DomainEvent-w1jyCjai.d.ts +23 -0
  19. package/packages/v5/dist/Intent-B6l0bHZU.d.cts +13 -0
  20. package/packages/v5/dist/Intent-BLNY6RoG.d.ts +13 -0
  21. package/packages/v5/dist/Message-c9XdBoh4.d.cts +36 -0
  22. package/packages/v5/dist/Message-c9XdBoh4.d.ts +36 -0
  23. package/packages/v5/dist/Rejection-D9PlzquK.d.cts +19 -0
  24. package/packages/v5/dist/Rejection-D9PlzquK.d.ts +19 -0
  25. package/packages/v5/dist/adapters/outbound/capabilities/index.cjs +4 -0
  26. package/packages/v5/dist/adapters/outbound/capabilities/index.cjs.map +1 -0
  27. package/packages/v5/dist/adapters/outbound/capabilities/index.d.cts +77 -0
  28. package/packages/v5/dist/adapters/outbound/capabilities/index.d.ts +77 -0
  29. package/packages/v5/dist/adapters/outbound/capabilities/index.js +3 -0
  30. package/packages/v5/dist/adapters/outbound/capabilities/index.js.map +1 -0
  31. package/packages/v5/dist/adapters/outbound/shapes/index.cjs +4 -0
  32. package/packages/v5/dist/adapters/outbound/shapes/index.cjs.map +1 -0
  33. package/packages/v5/dist/adapters/outbound/shapes/index.d.cts +68 -0
  34. package/packages/v5/dist/adapters/outbound/shapes/index.d.ts +68 -0
  35. package/packages/v5/dist/adapters/outbound/shapes/index.js +3 -0
  36. package/packages/v5/dist/adapters/outbound/shapes/index.js.map +1 -0
  37. package/packages/v5/dist/core/capabilities/index.cjs +4 -0
  38. package/packages/v5/dist/core/capabilities/index.cjs.map +1 -0
  39. package/packages/v5/dist/core/capabilities/index.d.cts +33 -0
  40. package/packages/v5/dist/core/capabilities/index.d.ts +33 -0
  41. package/packages/v5/dist/core/capabilities/index.js +3 -0
  42. package/packages/v5/dist/core/capabilities/index.js.map +1 -0
  43. package/packages/v5/dist/core/shapes/index.cjs +4 -0
  44. package/packages/v5/dist/core/shapes/index.cjs.map +1 -0
  45. package/packages/v5/dist/core/shapes/index.d.cts +27 -0
  46. package/packages/v5/dist/core/shapes/index.d.ts +27 -0
  47. package/packages/v5/dist/core/shapes/index.js +3 -0
  48. package/packages/v5/dist/core/shapes/index.js.map +1 -0
  49. package/packages/v5/dist/useCases/command/capabilities/index.cjs +4 -0
  50. package/packages/v5/dist/useCases/command/capabilities/index.cjs.map +1 -0
  51. package/packages/v5/dist/useCases/command/capabilities/index.d.cts +27 -0
  52. package/packages/v5/dist/useCases/command/capabilities/index.d.ts +27 -0
  53. package/packages/v5/dist/useCases/command/capabilities/index.js +3 -0
  54. package/packages/v5/dist/useCases/command/capabilities/index.js.map +1 -0
  55. package/packages/v5/dist/useCases/command/shapes/index.cjs +4 -0
  56. package/packages/v5/dist/useCases/command/shapes/index.cjs.map +1 -0
  57. package/packages/v5/dist/useCases/command/shapes/index.d.cts +78 -0
  58. package/packages/v5/dist/useCases/command/shapes/index.d.ts +78 -0
  59. package/packages/v5/dist/useCases/command/shapes/index.js +3 -0
  60. package/packages/v5/dist/useCases/command/shapes/index.js.map +1 -0
  61. package/packages/v5/dist/useCases/policy/capabilities/index.cjs +4 -0
  62. package/packages/v5/dist/useCases/policy/capabilities/index.cjs.map +1 -0
  63. package/packages/v5/dist/useCases/policy/capabilities/index.d.cts +12 -0
  64. package/packages/v5/dist/useCases/policy/capabilities/index.d.ts +12 -0
  65. package/packages/v5/dist/useCases/policy/capabilities/index.js +3 -0
  66. package/packages/v5/dist/useCases/policy/capabilities/index.js.map +1 -0
  67. package/packages/v5/dist/useCases/query/capabilities/index.cjs +4 -0
  68. package/packages/v5/dist/useCases/query/capabilities/index.cjs.map +1 -0
  69. package/packages/v5/dist/useCases/query/capabilities/index.d.cts +8 -0
  70. package/packages/v5/dist/useCases/query/capabilities/index.d.ts +8 -0
  71. package/packages/v5/dist/useCases/query/capabilities/index.js +3 -0
  72. package/packages/v5/dist/useCases/query/capabilities/index.js.map +1 -0
  73. package/packages/v5/dist/useCases/query/shapes/index.cjs +4 -0
  74. package/packages/v5/dist/useCases/query/shapes/index.cjs.map +1 -0
  75. package/packages/v5/dist/useCases/query/shapes/index.d.cts +7 -0
  76. package/packages/v5/dist/useCases/query/shapes/index.d.ts +7 -0
  77. package/packages/v5/dist/useCases/query/shapes/index.js +3 -0
  78. package/packages/v5/dist/useCases/query/shapes/index.js.map +1 -0
  79. 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,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -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,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,8 @@
1
+ import { Query } from '../shapes/index.cjs';
2
+ import '../../../Message-c9XdBoh4.cjs';
3
+
4
+ interface HandleQuery<TQuery extends Query, TData = Promise<object>> {
5
+ handle(input: TQuery): TData;
6
+ }
7
+
8
+ export type { HandleQuery };
@@ -0,0 +1,8 @@
1
+ import { Query } from '../shapes/index.js';
2
+ import '../../../Message-c9XdBoh4.js';
3
+
4
+ interface HandleQuery<TQuery extends Query, TData = Promise<object>> {
5
+ handle(input: TQuery): TData;
6
+ }
7
+
8
+ export type { HandleQuery };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,7 @@
1
+ import { M as Message } from '../../../Message-c9XdBoh4.cjs';
2
+
3
+ interface Query<TType = string, TPayload = unknown> extends Message<TType, TPayload> {
4
+ readonly kind: "query";
5
+ }
6
+
7
+ export type { Query };
@@ -0,0 +1,7 @@
1
+ import { M as Message } from '../../../Message-c9XdBoh4.js';
2
+
3
+ interface Query<TType = string, TPayload = unknown> extends Message<TType, TPayload> {
4
+ readonly kind: "query";
5
+ }
6
+
7
+ export type { Query };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -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
+ }