hexok 1.0.0 → 2.0.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/README.md +9 -0
- package/dist/adapter.d.ts +18 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +21 -0
- package/dist/adapter.js.map +1 -0
- package/dist/catalog.d.ts +88 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +79 -0
- package/dist/catalog.js.map +1 -0
- package/dist/{core/coded-error.d.ts → coded-error.d.ts} +9 -4
- package/dist/coded-error.d.ts.map +1 -0
- package/dist/{core/coded-error.js → coded-error.js} +9 -4
- package/dist/coded-error.js.map +1 -0
- package/dist/cow-draft.d.ts.map +1 -0
- package/dist/cow-draft.js.map +1 -0
- package/dist/entity.d.ts +63 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/{domain/entity.js → entity.js} +52 -80
- package/dist/entity.js.map +1 -0
- package/dist/error-map.d.ts +22 -0
- package/dist/error-map.d.ts.map +1 -0
- package/dist/error-map.js +2 -0
- package/dist/error-map.js.map +1 -0
- package/dist/errors.d.ts +85 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +85 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-handler.d.ts +31 -0
- package/dist/event-handler.d.ts.map +1 -0
- package/dist/event-handler.js +28 -0
- package/dist/event-handler.js.map +1 -0
- package/dist/event.d.ts +37 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +44 -0
- package/dist/event.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/mapper.d.ts +100 -0
- package/dist/mapper.d.ts.map +1 -0
- package/dist/mapper.js +167 -0
- package/dist/mapper.js.map +1 -0
- package/dist/port.d.ts +20 -0
- package/dist/port.d.ts.map +1 -0
- package/dist/port.js +25 -0
- package/dist/port.js.map +1 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js.map +1 -0
- package/dist/schema.d.ts +37 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +50 -0
- package/dist/schema.js.map +1 -0
- package/dist/{core/standard-schema.d.ts → standard-schema.d.ts} +1 -1
- package/dist/standard-schema.d.ts.map +1 -0
- package/dist/standard-schema.js.map +1 -0
- package/dist/use-case.d.ts +183 -0
- package/dist/use-case.d.ts.map +1 -0
- package/dist/use-case.js +221 -0
- package/dist/use-case.js.map +1 -0
- package/dist/{core/schema.d.ts → validate.d.ts} +1 -1
- package/dist/validate.d.ts.map +1 -0
- package/dist/{core/schema.js → validate.js} +1 -1
- package/dist/validate.js.map +1 -0
- package/package.json +16 -26
- package/dist/app/api-use-case.d.ts +0 -52
- package/dist/app/api-use-case.d.ts.map +0 -1
- package/dist/app/api-use-case.js +0 -59
- package/dist/app/api-use-case.js.map +0 -1
- package/dist/app/callable-use-case.d.ts +0 -34
- package/dist/app/callable-use-case.d.ts.map +0 -1
- package/dist/app/callable-use-case.js +0 -41
- package/dist/app/callable-use-case.js.map +0 -1
- package/dist/app/contract.d.ts +0 -46
- package/dist/app/contract.d.ts.map +0 -1
- package/dist/app/contract.js +0 -28
- package/dist/app/contract.js.map +0 -1
- package/dist/app/error-factory.d.ts +0 -9
- package/dist/app/error-factory.d.ts.map +0 -1
- package/dist/app/error-factory.js +0 -30
- package/dist/app/error-factory.js.map +0 -1
- package/dist/app/event-channel.d.ts +0 -133
- package/dist/app/event-channel.d.ts.map +0 -1
- package/dist/app/event-channel.js +0 -49
- package/dist/app/event-channel.js.map +0 -1
- package/dist/app/event-use-case.d.ts +0 -47
- package/dist/app/event-use-case.d.ts.map +0 -1
- package/dist/app/event-use-case.js +0 -54
- package/dist/app/event-use-case.js.map +0 -1
- package/dist/app/execute-ctx.d.ts +0 -92
- package/dist/app/execute-ctx.d.ts.map +0 -1
- package/dist/app/execute-ctx.js +0 -2
- package/dist/app/execute-ctx.js.map +0 -1
- package/dist/app/external-use-case.d.ts +0 -25
- package/dist/app/external-use-case.d.ts.map +0 -1
- package/dist/app/external-use-case.js +0 -25
- package/dist/app/external-use-case.js.map +0 -1
- package/dist/app/index.d.ts +0 -9
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -8
- package/dist/app/index.js.map +0 -1
- package/dist/app/internal-use-case.d.ts +0 -26
- package/dist/app/internal-use-case.d.ts.map +0 -1
- package/dist/app/internal-use-case.js +0 -26
- package/dist/app/internal-use-case.js.map +0 -1
- package/dist/app/nest.d.ts +0 -9
- package/dist/app/nest.d.ts.map +0 -1
- package/dist/app/nest.js +0 -28
- package/dist/app/nest.js.map +0 -1
- package/dist/app/types.d.ts +0 -153
- package/dist/app/types.d.ts.map +0 -1
- package/dist/app/types.js +0 -17
- package/dist/app/types.js.map +0 -1
- package/dist/core/coded-error.d.ts.map +0 -1
- package/dist/core/coded-error.js.map +0 -1
- package/dist/core/error-map.d.ts +0 -21
- package/dist/core/error-map.d.ts.map +0 -1
- package/dist/core/error-map.js +0 -5
- package/dist/core/error-map.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -5
- package/dist/core/index.js.map +0 -1
- package/dist/core/result.d.ts.map +0 -1
- package/dist/core/result.js.map +0 -1
- package/dist/core/schema.d.ts.map +0 -1
- package/dist/core/schema.js.map +0 -1
- package/dist/core/standard-schema.d.ts.map +0 -1
- package/dist/core/standard-schema.js.map +0 -1
- package/dist/domain/capabilities.d.ts +0 -42
- package/dist/domain/capabilities.d.ts.map +0 -1
- package/dist/domain/capabilities.js +0 -2
- package/dist/domain/capabilities.js.map +0 -1
- package/dist/domain/catalog.d.ts +0 -46
- package/dist/domain/catalog.d.ts.map +0 -1
- package/dist/domain/catalog.js +0 -114
- package/dist/domain/catalog.js.map +0 -1
- package/dist/domain/channel.d.ts +0 -36
- package/dist/domain/channel.d.ts.map +0 -1
- package/dist/domain/channel.js +0 -2
- package/dist/domain/channel.js.map +0 -1
- package/dist/domain/cow-draft.d.ts.map +0 -1
- package/dist/domain/cow-draft.js.map +0 -1
- package/dist/domain/entity.d.ts +0 -120
- package/dist/domain/entity.d.ts.map +0 -1
- package/dist/domain/entity.js.map +0 -1
- package/dist/domain/envelope.d.ts +0 -59
- package/dist/domain/envelope.d.ts.map +0 -1
- package/dist/domain/envelope.js +0 -2
- package/dist/domain/envelope.js.map +0 -1
- package/dist/domain/event.d.ts +0 -44
- package/dist/domain/event.d.ts.map +0 -1
- package/dist/domain/event.js +0 -21
- package/dist/domain/event.js.map +0 -1
- package/dist/domain/index.d.ts +0 -8
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -5
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/port.d.ts +0 -45
- package/dist/domain/port.d.ts.map +0 -1
- package/dist/domain/port.js +0 -41
- package/dist/domain/port.js.map +0 -1
- package/dist/infra/adapter.d.ts +0 -22
- package/dist/infra/adapter.d.ts.map +0 -1
- package/dist/infra/adapter.js +0 -18
- package/dist/infra/adapter.js.map +0 -1
- package/dist/infra/index.d.ts +0 -3
- package/dist/infra/index.d.ts.map +0 -1
- package/dist/infra/index.js +0 -3
- package/dist/infra/index.js.map +0 -1
- package/dist/infra/mapper.d.ts +0 -48
- package/dist/infra/mapper.d.ts.map +0 -1
- package/dist/infra/mapper.js +0 -77
- package/dist/infra/mapper.js.map +0 -1
- package/dist/runtime/app.d.ts +0 -100
- package/dist/runtime/app.d.ts.map +0 -1
- package/dist/runtime/app.js +0 -292
- package/dist/runtime/app.js.map +0 -1
- package/dist/runtime/channel.d.ts +0 -34
- package/dist/runtime/channel.d.ts.map +0 -1
- package/dist/runtime/channel.js +0 -110
- package/dist/runtime/channel.js.map +0 -1
- package/dist/runtime/client.d.ts +0 -21
- package/dist/runtime/client.d.ts.map +0 -1
- package/dist/runtime/client.js +0 -2
- package/dist/runtime/client.js.map +0 -1
- package/dist/runtime/completeness.d.ts +0 -89
- package/dist/runtime/completeness.d.ts.map +0 -1
- package/dist/runtime/completeness.js +0 -2
- package/dist/runtime/completeness.js.map +0 -1
- package/dist/runtime/envelope.d.ts +0 -7
- package/dist/runtime/envelope.d.ts.map +0 -1
- package/dist/runtime/envelope.js +0 -69
- package/dist/runtime/envelope.js.map +0 -1
- package/dist/runtime/events.d.ts +0 -6
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/events.js +0 -48
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/http-status.d.ts +0 -3
- package/dist/runtime/http-status.d.ts.map +0 -1
- package/dist/runtime/http-status.js +0 -11
- package/dist/runtime/http-status.js.map +0 -1
- package/dist/runtime/http.d.ts +0 -4
- package/dist/runtime/http.d.ts.map +0 -1
- package/dist/runtime/http.js +0 -58
- package/dist/runtime/http.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -10
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -6
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/interceptor.d.ts +0 -61
- package/dist/runtime/interceptor.d.ts.map +0 -1
- package/dist/runtime/interceptor.js +0 -7
- package/dist/runtime/interceptor.js.map +0 -1
- package/dist/runtime/invoke.d.ts +0 -34
- package/dist/runtime/invoke.d.ts.map +0 -1
- package/dist/runtime/invoke.js +0 -235
- package/dist/runtime/invoke.js.map +0 -1
- package/dist/runtime/middleware.d.ts +0 -20
- package/dist/runtime/middleware.d.ts.map +0 -1
- package/dist/runtime/middleware.js +0 -2
- package/dist/runtime/middleware.js.map +0 -1
- package/dist/runtime/rpc.d.ts +0 -24
- package/dist/runtime/rpc.d.ts.map +0 -1
- package/dist/runtime/rpc.js +0 -16
- package/dist/runtime/rpc.js.map +0 -1
- package/dist/testing/app-test.d.ts +0 -77
- package/dist/testing/app-test.d.ts.map +0 -1
- package/dist/testing/app-test.js +0 -109
- package/dist/testing/app-test.js.map +0 -1
- package/dist/testing/in-memory-broker.d.ts +0 -18
- package/dist/testing/in-memory-broker.d.ts.map +0 -1
- package/dist/testing/in-memory-broker.js +0 -42
- package/dist/testing/in-memory-broker.js.map +0 -1
- package/dist/testing/in-memory-bus.d.ts +0 -19
- package/dist/testing/in-memory-bus.d.ts.map +0 -1
- package/dist/testing/in-memory-bus.js +0 -31
- package/dist/testing/in-memory-bus.js.map +0 -1
- package/dist/testing/in-memory-channel.d.ts +0 -32
- package/dist/testing/in-memory-channel.d.ts.map +0 -1
- package/dist/testing/in-memory-channel.js +0 -65
- package/dist/testing/in-memory-channel.js.map +0 -1
- package/dist/testing/in-memory-queue.d.ts +0 -24
- package/dist/testing/in-memory-queue.d.ts.map +0 -1
- package/dist/testing/in-memory-queue.js +0 -66
- package/dist/testing/in-memory-queue.js.map +0 -1
- package/dist/testing/in-memory-repository.d.ts +0 -44
- package/dist/testing/in-memory-repository.d.ts.map +0 -1
- package/dist/testing/in-memory-repository.js +0 -60
- package/dist/testing/in-memory-repository.js.map +0 -1
- package/dist/testing/index.d.ts +0 -6
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js +0 -6
- package/dist/testing/index.js.map +0 -1
- /package/dist/{domain/cow-draft.d.ts → cow-draft.d.ts} +0 -0
- /package/dist/{domain/cow-draft.js → cow-draft.js} +0 -0
- /package/dist/{core/result.d.ts → result.d.ts} +0 -0
- /package/dist/{core/result.js → result.js} +0 -0
- /package/dist/{core/standard-schema.js → standard-schema.js} +0 -0
package/dist/mapper.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { validationError } from './coded-error.js';
|
|
2
|
+
import { schemaDefinition, } from './schema.js';
|
|
3
|
+
import { validate } from './validate.js';
|
|
4
|
+
const sourceKindKey = Symbol('hexok.mapper.source');
|
|
5
|
+
const validateKey = Symbol('hexok.mapper.validate');
|
|
6
|
+
/**
|
|
7
|
+
* Instance base of {@link Mapper}. Exported so declaration emit can name it.
|
|
8
|
+
* An anonymous base cannot publish protected `fromSource` or `toSource` (TS4094).
|
|
9
|
+
* Extend {@link Mapper}, not this class.
|
|
10
|
+
*/
|
|
11
|
+
export class MapperClass {
|
|
12
|
+
/** Mapper name. Literal type of the string passed to {@link Mapper}. */
|
|
13
|
+
static token;
|
|
14
|
+
/** Stored Standard Schema. A Schema class is stored as its definition. */
|
|
15
|
+
static schema;
|
|
16
|
+
/** Entity, Schema class, or Standard Schema this mapper reads and builds. */
|
|
17
|
+
static source;
|
|
18
|
+
/** Nominal marker. Each `Mapper(...)` call is a distinct class. */
|
|
19
|
+
#brand;
|
|
20
|
+
constructor(brand) {
|
|
21
|
+
this.#brand = brand;
|
|
22
|
+
void this.#brand;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run `fromSource`. With `{ validate: true }`, check the draft against the model schema.
|
|
26
|
+
* A failure throws `CodedError` `VALIDATION` using this mapper's token.
|
|
27
|
+
* Do not override.
|
|
28
|
+
*/
|
|
29
|
+
toModel(source, options) {
|
|
30
|
+
const ctor = runtimeOf(this);
|
|
31
|
+
const draft = this.fromSource(source);
|
|
32
|
+
if (!checking(ctor, options))
|
|
33
|
+
return draft;
|
|
34
|
+
const parsed = validate(ctor.schema, draft);
|
|
35
|
+
if (!parsed.ok) {
|
|
36
|
+
throw validationError(`hexok: ${ctor.token} validation failed`, parsed.issues);
|
|
37
|
+
}
|
|
38
|
+
return parsed.value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run `toSource` and build the source.
|
|
42
|
+
* With `{ validate: true }`, check `value` against the model schema first.
|
|
43
|
+
* An entity is then `parse`d. Otherwise an entity is `restore`d.
|
|
44
|
+
* Do not override.
|
|
45
|
+
*/
|
|
46
|
+
fromModel(value, options) {
|
|
47
|
+
const ctor = runtimeOf(this);
|
|
48
|
+
const check = checking(ctor, options);
|
|
49
|
+
const model = check ? modelOutput(ctor, value) : value;
|
|
50
|
+
return buildSource(ctor[sourceKindKey], ctor.source, ctor.token, this.toSource(model), check);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Persistence translator. An adapter maps the source a port speaks — an
|
|
55
|
+
* entity, a Schema class, or a Standard Schema — to the shape that adapter
|
|
56
|
+
* stores. Domain code does not import the stored schema. The mapper is
|
|
57
|
+
* stateless; do not `commit()` inside it. The adapter commits after the
|
|
58
|
+
* driver succeeds.
|
|
59
|
+
*
|
|
60
|
+
* The subclass writes `fromSource` and `toSource`. Adapters call `toModel` and
|
|
61
|
+
* `fromModel` and do not override them. Checks are off. Pass
|
|
62
|
+
* `{ validate: true }` to the factory or to a call to run the model schema.
|
|
63
|
+
* A checked `fromModel` uses `parse`. The default restores an entity.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* class MongoUser extends Mapper('mongo.User', User, mongoUserSchema) {
|
|
67
|
+
* protected fromSource(user: User) {
|
|
68
|
+
* const props = user.toProps()
|
|
69
|
+
* const [lat, lng] = props.location
|
|
70
|
+
* return {
|
|
71
|
+
* _id: props.id,
|
|
72
|
+
* name: props.name,
|
|
73
|
+
* location: { type: 'Point' as const, coordinates: [lng, lat] },
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* protected toSource(doc: MongoUserDoc) {
|
|
78
|
+
* const [lng, lat] = doc.location.coordinates
|
|
79
|
+
* return { id: doc._id, name: doc.name, location: [lat, lng] }
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function Mapper(token, source, storedSchema, options) {
|
|
85
|
+
const kind = sourceKind(token, source);
|
|
86
|
+
const stored = schemaDefinition(storedSchema);
|
|
87
|
+
const check = options?.validate === true;
|
|
88
|
+
class Runtime extends MapperClass {
|
|
89
|
+
static token = token;
|
|
90
|
+
static schema = stored;
|
|
91
|
+
static source = source;
|
|
92
|
+
static [sourceKindKey] = kind;
|
|
93
|
+
static [validateKey] = check;
|
|
94
|
+
constructor() {
|
|
95
|
+
super(token);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return Runtime;
|
|
99
|
+
}
|
|
100
|
+
function checking(ctor, options) {
|
|
101
|
+
return options?.validate ?? ctor[validateKey];
|
|
102
|
+
}
|
|
103
|
+
function modelOutput(ctor, value) {
|
|
104
|
+
const parsed = validate(ctor.schema, value);
|
|
105
|
+
if (!parsed.ok) {
|
|
106
|
+
throw validationError(`hexok: ${ctor.token} validation failed`, parsed.issues);
|
|
107
|
+
}
|
|
108
|
+
return parsed.value;
|
|
109
|
+
}
|
|
110
|
+
function runtimeOf(instance) {
|
|
111
|
+
return instance.constructor;
|
|
112
|
+
}
|
|
113
|
+
function sourceKind(token, source) {
|
|
114
|
+
if (isObjectLike(source)) {
|
|
115
|
+
if (isEntitySource(source))
|
|
116
|
+
return 'entity';
|
|
117
|
+
if (isSchemaClassSource(source))
|
|
118
|
+
return 'schema';
|
|
119
|
+
if (isStandardSchema(source))
|
|
120
|
+
return 'raw';
|
|
121
|
+
}
|
|
122
|
+
throw new Error(`hexok: ${token} source is not an entity or a schema`);
|
|
123
|
+
}
|
|
124
|
+
function isObjectLike(value) {
|
|
125
|
+
return ((typeof value === 'object' && value !== null) || typeof value === 'function');
|
|
126
|
+
}
|
|
127
|
+
function isStandardSchema(value) {
|
|
128
|
+
if (typeof value !== 'object' || value === null || !('~standard' in value)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
const standard = value['~standard'];
|
|
132
|
+
return typeof standard === 'object' && standard !== null;
|
|
133
|
+
}
|
|
134
|
+
function isEntitySource(value) {
|
|
135
|
+
if (!('create' in value) ||
|
|
136
|
+
!('restore' in value) ||
|
|
137
|
+
!('parse' in value) ||
|
|
138
|
+
!('schema' in value)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return (typeof value.create === 'function' &&
|
|
142
|
+
typeof value.restore === 'function' &&
|
|
143
|
+
typeof value.parse === 'function' &&
|
|
144
|
+
isStandardSchema(value.schema));
|
|
145
|
+
}
|
|
146
|
+
function isSchemaClassSource(value) {
|
|
147
|
+
if (!('definition' in value) || !('parse' in value))
|
|
148
|
+
return false;
|
|
149
|
+
return (typeof value.parse === 'function' && isStandardSchema(value.definition));
|
|
150
|
+
}
|
|
151
|
+
function buildSource(kind, source, token, draft, check) {
|
|
152
|
+
if (!check) {
|
|
153
|
+
if (kind === 'entity') {
|
|
154
|
+
return source.restore(draft);
|
|
155
|
+
}
|
|
156
|
+
return draft;
|
|
157
|
+
}
|
|
158
|
+
if (kind === 'raw') {
|
|
159
|
+
const parsed = validate(source, draft);
|
|
160
|
+
if (!parsed.ok) {
|
|
161
|
+
throw validationError(`hexok: ${token} validation failed`, parsed.issues);
|
|
162
|
+
}
|
|
163
|
+
return parsed.value;
|
|
164
|
+
}
|
|
165
|
+
return source.parse(draft);
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.js","sourceRoot":"","sources":["../src/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAIL,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAsCzC,MAAM,aAAa,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACnE,MAAM,WAAW,GAAkB,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAcnE;;;;GAIG;AACH,MAAM,OAAgB,WAAW;IAK/B,wEAAwE;IACxE,MAAM,CAAU,KAAK,CAAS;IAC9B,0EAA0E;IAC1E,MAAM,CAAU,MAAM,CAAmB;IACzC,6EAA6E;IAC7E,MAAM,CAAU,MAAM,CAAU;IAChC,mEAAmE;IAC1D,MAAM,CAAQ;IAEvB,YAAsB,KAAY;QAChC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,IAAI,CAAC,MAAM,CAAC;IACnB,CAAC;IAcD;;;;OAIG;IACH,OAAO,CACL,MAA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CAAC,UAAU,CAAC,CACxE,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAClB,IAAgB,EAChB,MAAe,EACf,KAAa,EACb,KAAc,EACd,KAAc;IAEd,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAQ,MAA+C,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,QAAQ,CAAC,MAA0B,EAAE,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,eAAe,CAAC,UAAU,KAAK,oBAAoB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,OAAQ,MAA6C,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/port.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A port is the contract an adapter implements.
|
|
3
|
+
* Extend the returned class and declare the abstract methods of the seam.
|
|
4
|
+
* Each call has its own private brand, so a structural lookalike is not a port.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* abstract class UserRepository extends Port('UserRepository') {
|
|
8
|
+
* abstract get(id: string): Promise<User | null>
|
|
9
|
+
* abstract save(user: User): Promise<void>
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function Port<const Token extends string>(token: Token): (abstract new () => {
|
|
14
|
+
/** Nominal marker. Each `Port(...)` call is a distinct class. */
|
|
15
|
+
readonly "__#private@#brand": true;
|
|
16
|
+
}) & {
|
|
17
|
+
/** Port name. Literal type of the string passed to {@link Port}. */
|
|
18
|
+
readonly token: Token;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK;IAIzD,iEAAiE;kCAC/C,IAAI;;IAHtB,oEAAoE;oBAC7C,KAAK;EAU/B"}
|
package/dist/port.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A port is the contract an adapter implements.
|
|
3
|
+
* Extend the returned class and declare the abstract methods of the seam.
|
|
4
|
+
* Each call has its own private brand, so a structural lookalike is not a port.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* abstract class UserRepository extends Port('UserRepository') {
|
|
8
|
+
* abstract get(id: string): Promise<User | null>
|
|
9
|
+
* abstract save(user: User): Promise<void>
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function Port(token) {
|
|
14
|
+
class PortClass {
|
|
15
|
+
/** Port name. Literal type of the string passed to {@link Port}. */
|
|
16
|
+
static token = token;
|
|
17
|
+
/** Nominal marker. Each `Port(...)` call is a distinct class. */
|
|
18
|
+
#brand = true;
|
|
19
|
+
constructor() {
|
|
20
|
+
void this.#brand;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return PortClass;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=port.js.map
|
package/dist/port.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port.js","sourceRoot":"","sources":["../src/port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,IAAI,CAA6B,KAAY;IAC3D,MAAe,SAAS;QACtB,oEAAoE;QACpE,MAAM,CAAU,KAAK,GAAU,KAAK,CAAC;QACrC,iEAAiE;QACxD,MAAM,GAAG,IAAI,CAAC;QAEvB;YACE,KAAK,IAAI,CAAC,MAAM,CAAC;QACnB,CAAC;;IAGH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,IAC3C;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACtB;IACE,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,SAAS,gBAAgB,CAAC,KAAK,EAAE,CAAC;CAC5C,CAAC;AAEN,2FAA2F;AAC3F,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAEhD;AAED,sGAAsG;AACtG,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EACnC,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,SAAS,gBAAgB,CAAC,KAAK,EAAE,GACzC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAIlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAmBA,2FAA2F;AAC3F,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,IAAI,CAClB,IAAO,EACP,MAA0C;IAE1C,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;QAC7B,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from './standard-schema.js';
|
|
2
|
+
import { type Infer } from './validate.js';
|
|
3
|
+
/** A Standard Schema value, or a {@link Schema} class that wraps one. */
|
|
4
|
+
export type SchemaSource = StandardSchemaV1 | {
|
|
5
|
+
readonly definition: StandardSchemaV1;
|
|
6
|
+
};
|
|
7
|
+
/** The Standard Schema inside `S`, or `S` itself when it already is one. */
|
|
8
|
+
export type ResolvedSchema<S> = S extends {
|
|
9
|
+
readonly definition: infer D extends StandardSchemaV1;
|
|
10
|
+
} ? D : S extends StandardSchemaV1 ? S : never;
|
|
11
|
+
/** Output of a schema value or a Schema class. */
|
|
12
|
+
export type InferSchema<S extends SchemaSource> = Infer<ResolvedSchema<S>>;
|
|
13
|
+
/** Read the Standard Schema from a schema value or a Schema class. */
|
|
14
|
+
export declare function schemaDefinition<S extends SchemaSource>(schema: S): ResolvedSchema<S>;
|
|
15
|
+
/**
|
|
16
|
+
* Named schema. The token and the Standard Schema are arguments, so neither
|
|
17
|
+
* can be omitted. Override `parse` or `check` to customize.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* class UserSchema extends Schema('User', z.object({ id: z.string() })) {}
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function Schema<const Token extends string, S extends StandardSchemaV1>(token: Token, definition: S): (abstract new () => {}) & {
|
|
24
|
+
/** Schema name. Literal type of the string passed to {@link Schema}. */
|
|
25
|
+
readonly token: Token;
|
|
26
|
+
/** The Standard Schema this class wraps. */
|
|
27
|
+
readonly definition: S;
|
|
28
|
+
/**
|
|
29
|
+
* Validate `value` and return the schema output.
|
|
30
|
+
* Throws `CodedError` `VALIDATION` when the schema rejects it.
|
|
31
|
+
* Override to preprocess or postprocess.
|
|
32
|
+
*/
|
|
33
|
+
parse(value: unknown): Infer<S>;
|
|
34
|
+
/** Same as {@link parse}, but returns the schema output for overrides that call `super`. */
|
|
35
|
+
check(value: unknown): Infer<S>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,eAAe,CAAC;AAErD,yEAAyE;AACzE,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB;IAAE,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,gBAAgB,CAAC;CACvD,GACG,CAAC,GACD,CAAC,SAAS,gBAAgB,GACxB,CAAC,GACD,KAAK,CAAC;AAEZ,kDAAkD;AAClD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,YAAY,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAc3E,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,YAAY,EACrD,MAAM,EAAE,CAAC,GACR,cAAc,CAAC,CAAC,CAAC,CAGnB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,CAAC,SAAS,gBAAgB,EAC3E,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC;IAGX,wEAAwE;oBACjD,KAAK;IAC5B,4CAA4C;yBAChB,CAAC;IAE7B;;;;OAIG;iBACiB,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAItC,4FAA4F;iBACxE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;EAazC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { validationError } from './coded-error.js';
|
|
2
|
+
import { validate } from './validate.js';
|
|
3
|
+
function isSchemaClass(value) {
|
|
4
|
+
if (!('definition' in value))
|
|
5
|
+
return false;
|
|
6
|
+
const definition = value.definition;
|
|
7
|
+
return (typeof definition === 'object' &&
|
|
8
|
+
definition !== null &&
|
|
9
|
+
'~standard' in definition);
|
|
10
|
+
}
|
|
11
|
+
/** Read the Standard Schema from a schema value or a Schema class. */
|
|
12
|
+
export function schemaDefinition(schema) {
|
|
13
|
+
if (isSchemaClass(schema))
|
|
14
|
+
return schema.definition;
|
|
15
|
+
return schema;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Named schema. The token and the Standard Schema are arguments, so neither
|
|
19
|
+
* can be omitted. Override `parse` or `check` to customize.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* class UserSchema extends Schema('User', z.object({ id: z.string() })) {}
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function Schema(token, definition) {
|
|
26
|
+
class SchemaClass {
|
|
27
|
+
/** Schema name. Literal type of the string passed to {@link Schema}. */
|
|
28
|
+
static token = token;
|
|
29
|
+
/** The Standard Schema this class wraps. */
|
|
30
|
+
static definition = definition;
|
|
31
|
+
/**
|
|
32
|
+
* Validate `value` and return the schema output.
|
|
33
|
+
* Throws `CodedError` `VALIDATION` when the schema rejects it.
|
|
34
|
+
* Override to preprocess or postprocess.
|
|
35
|
+
*/
|
|
36
|
+
static parse(value) {
|
|
37
|
+
return SchemaClass.check(value);
|
|
38
|
+
}
|
|
39
|
+
/** Same as {@link parse}, but returns the schema output for overrides that call `super`. */
|
|
40
|
+
static check(value) {
|
|
41
|
+
const parsed = validate(definition, value);
|
|
42
|
+
if (!parsed.ok) {
|
|
43
|
+
throw validationError(`hexok: ${token} validation failed`, parsed.issues);
|
|
44
|
+
}
|
|
45
|
+
return parsed.value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return SchemaClass;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAc,QAAQ,EAAE,MAAM,eAAe,CAAC;AAmBrD,SAAS,aAAa,CACpB,KAAmB;IAEnB,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACpC,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,KAAK,IAAI;QACnB,WAAW,IAAI,UAAU,CAC1B,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAC9B,MAAS;IAET,IAAI,aAAa,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,UAA+B,CAAC;IACzE,OAAO,MAA2B,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CACpB,KAAY,EACZ,UAAa;IAEb,MAAe,WAAW;QACxB,wEAAwE;QACxE,MAAM,CAAU,KAAK,GAAU,KAAK,CAAC;QACrC,4CAA4C;QAC5C,MAAM,CAAU,UAAU,GAAM,UAAU,CAAC;QAE3C;;;;WAIG;QACH,MAAM,CAAC,KAAK,CAAC,KAAc;YACzB,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,4FAA4F;QAC5F,MAAM,CAAC,KAAK,CAAC,KAAc;YACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBACf,MAAM,eAAe,CACnB,UAAU,KAAK,oBAAoB,EACnC,MAAM,CAAC,MAAM,CACd,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;;IAGH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vendored Standard Schema V1. Copy of https://standardschema.dev
|
|
3
|
-
* so
|
|
3
|
+
* so hexok has zero runtime dependencies.
|
|
4
4
|
*/
|
|
5
5
|
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
6
6
|
/** Spec bag: version, vendor, validate, optional inferred types. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;IAC/D,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC7D;AAED,MAAM,CAAC,OAAO,WAAW,gBAAgB,CAAC;IACxC,oEAAoE;IACpE,UAAiB,KAAK,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;QACpD,gCAAgC;QAChC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,yCAAyC;QACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,wEAAwE;QACxE,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,KACX,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9C,gDAAgD;Q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ema.js","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application service. Pass ports through the constructor.
|
|
3
|
+
* `execute` is required; the compiler errors on the class when it is missing.
|
|
4
|
+
* Declare the input and output on `execute` — those are the types callers see.
|
|
5
|
+
* A refusal throws an {@link Errors} catalog member. The application catches it.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* class CreateUser extends UseCase('user.create') {
|
|
9
|
+
* constructor(private readonly users: UserRepository) { super() }
|
|
10
|
+
* async execute(input: { email: string }): Promise<{ id: string }> {
|
|
11
|
+
* return { id: input.email }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function UseCase<const Token extends string>(token: Token): (abstract new () => {
|
|
17
|
+
/** Nominal marker. Each `UseCase(...)` call is a distinct class. */
|
|
18
|
+
readonly "__#private@#brand": true;
|
|
19
|
+
/**
|
|
20
|
+
* Required. Annotate `input` and the return type on the subclass;
|
|
21
|
+
* callers of the subclass see those types.
|
|
22
|
+
*/
|
|
23
|
+
execute(input: unknown): Promise<unknown>;
|
|
24
|
+
}) & {
|
|
25
|
+
/** Use-case name. Literal type of the string passed to {@link UseCase}. */
|
|
26
|
+
readonly token: Token;
|
|
27
|
+
};
|
|
28
|
+
type ReservedKey = 'token' | 'prototype' | 'name' | 'length';
|
|
29
|
+
/** A bag that uses a reserved class static fails on that property. */
|
|
30
|
+
type ReservedOk<S> = {
|
|
31
|
+
[K in keyof S]: K extends ReservedKey ? never : S[K];
|
|
32
|
+
};
|
|
33
|
+
type NoStatics = Record<never, never>;
|
|
34
|
+
/** Static bag minus names that would overwrite the class constructor. */
|
|
35
|
+
type Statics<S> = Omit<S, ReservedKey>;
|
|
36
|
+
/**
|
|
37
|
+
* Family of use cases that receive a caller context on `execute`.
|
|
38
|
+
* Returns a factory: a token, or a token and statics when `Spec` has keys.
|
|
39
|
+
* `execute` is required; annotate it on the subclass — callers see those types.
|
|
40
|
+
* A guard and hooks, when set, run around that method.
|
|
41
|
+
* Statics are application data copied onto the class. The application validates `input`.
|
|
42
|
+
* {@link UseCase.GuardParameters} reads the guard's call off the factory.
|
|
43
|
+
* {@link UseCase.Ctx} reads that call's context type.
|
|
44
|
+
* {@link context} returns that factory. {@link ContextFactory.guard} and
|
|
45
|
+
* {@link ContextFactory.hooks} return it again.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* const ApiUseCase = UseCase.context<
|
|
49
|
+
* ApiContext,
|
|
50
|
+
* { input: StandardSchemaV1; permission: string }
|
|
51
|
+
* >()
|
|
52
|
+
* .guard((call) => {
|
|
53
|
+
* if (call.ctx.sessionId.length < 1 || call.spec.permission.length < 1) {
|
|
54
|
+
* throw new Error('unauthorized')
|
|
55
|
+
* }
|
|
56
|
+
* })
|
|
57
|
+
* .hooks({
|
|
58
|
+
* preExecute: () => ({ started: Date.now() }),
|
|
59
|
+
* postExecute(_call, state) {
|
|
60
|
+
* void state.started
|
|
61
|
+
* },
|
|
62
|
+
* })
|
|
63
|
+
*
|
|
64
|
+
* class FindUsers extends ApiUseCase('user.find', {
|
|
65
|
+
* input: z.object({ query: z.string() }),
|
|
66
|
+
* permission: 'users.read',
|
|
67
|
+
* }) {
|
|
68
|
+
* constructor(private readonly users: UserRepository) { super() }
|
|
69
|
+
* async execute(
|
|
70
|
+
* ctx: UseCase.Ctx<typeof ApiUseCase>,
|
|
71
|
+
* input: { query: string },
|
|
72
|
+
* ): Promise<User[]> {
|
|
73
|
+
* return this.users.search(input.query)
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare namespace UseCase {
|
|
79
|
+
/**
|
|
80
|
+
* Call passed to a {@link context} guard.
|
|
81
|
+
* `ctx` is the per-call context. `spec` is the static contract.
|
|
82
|
+
* `token` is the use-case name. `input` is the argument passed to `execute`.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* type Call = UseCase.GuardParameters<typeof ApiUseCase>
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
type GuardParameters<Factory> = Factory extends GuardParametersSlot<infer Ctx, infer Spec> ? Call<Ctx, Spec> : never;
|
|
89
|
+
/**
|
|
90
|
+
* Context type of a {@link context} factory.
|
|
91
|
+
* Pass the factory. A subclass, and a plain {@link UseCase} class, are `never`.
|
|
92
|
+
*
|
|
93
|
+
* ```ts
|
|
94
|
+
* async execute(
|
|
95
|
+
* ctx: UseCase.Ctx<typeof ApiUseCase>,
|
|
96
|
+
* input: { query: string },
|
|
97
|
+
* ): Promise<User[]> {}
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
type Ctx<Factory> = GuardParameters<Factory>['ctx'];
|
|
101
|
+
/**
|
|
102
|
+
* Factory returned by {@link context}.
|
|
103
|
+
* An exported const infers this type.
|
|
104
|
+
* `guard` and `hooks` return the same factory.
|
|
105
|
+
*/
|
|
106
|
+
interface ContextFactory<Ctx, Spec = NoStatics> extends ReturnType<typeof buildContext<Ctx, Spec>> {
|
|
107
|
+
/**
|
|
108
|
+
* Runs after guards already registered, and before `execute`.
|
|
109
|
+
* Returns the same factory.
|
|
110
|
+
*/
|
|
111
|
+
guard(guard: (call: Call<Ctx, Spec>) => void | Promise<void>): ContextFactory<Ctx, Spec>;
|
|
112
|
+
/**
|
|
113
|
+
* Lifecycle around `execute`. The value returned from `preExecute` is the
|
|
114
|
+
* `state` argument of `postExecute`, `onCatch`, and `onFinally`.
|
|
115
|
+
* A second call throws when this factory already has hooks.
|
|
116
|
+
*/
|
|
117
|
+
hooks<State = void>(definition: HookDefinition<Ctx, Spec, State>): ContextFactory<Ctx, Spec>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Family factory. Pass the context type.
|
|
121
|
+
* The argument is a settings object with no keys yet.
|
|
122
|
+
*/
|
|
123
|
+
function context<Ctx, Spec = NoStatics>(config?: ContextConfig): unknown extends Ctx ? 'Pass a type argument: UseCase.context<Ctx>()' : ContextFactory<Ctx, Spec>;
|
|
124
|
+
}
|
|
125
|
+
/** Values a guard and the hooks share for one invocation. */
|
|
126
|
+
type Call<Ctx, Spec> = {
|
|
127
|
+
readonly ctx: Ctx;
|
|
128
|
+
readonly spec: Spec;
|
|
129
|
+
readonly token: string;
|
|
130
|
+
/** The `input` argument the caller passed to `execute`. */
|
|
131
|
+
readonly input: unknown;
|
|
132
|
+
};
|
|
133
|
+
type Performed<Ctx, Spec> = Call<Ctx, Spec> & {
|
|
134
|
+
readonly result: unknown;
|
|
135
|
+
};
|
|
136
|
+
type Caught<Ctx, Spec> = Call<Ctx, Spec> & {
|
|
137
|
+
readonly error: unknown;
|
|
138
|
+
};
|
|
139
|
+
type Settled<Ctx, Spec> = (Call<Ctx, Spec> & {
|
|
140
|
+
readonly status: 'success';
|
|
141
|
+
readonly result: unknown;
|
|
142
|
+
}) | (Call<Ctx, Spec> & {
|
|
143
|
+
readonly status: 'failure';
|
|
144
|
+
readonly error: unknown;
|
|
145
|
+
});
|
|
146
|
+
/** Settings for {@link UseCase.context}. There are none yet. */
|
|
147
|
+
type ContextConfig = Record<string, never>;
|
|
148
|
+
type ContextGuard<Ctx, Spec> = (call: Call<Ctx, Spec>) => void | Promise<void>;
|
|
149
|
+
type HookDefinition<Ctx, Spec, State> = {
|
|
150
|
+
preExecute?: (call: Call<Ctx, Spec>) => State | Promise<State>;
|
|
151
|
+
postExecute?: (call: Performed<Ctx, Spec>, state: Awaited<State>) => void | Promise<void>;
|
|
152
|
+
onCatch?: (call: Caught<Ctx, Spec>, state: Awaited<State> | undefined) => void | Promise<void>;
|
|
153
|
+
onFinally?: (call: Settled<Ctx, Spec>, state: Awaited<State> | undefined) => void | Promise<void>;
|
|
154
|
+
};
|
|
155
|
+
/** Hooks stored on one factory. State is erased after `.hooks()` checks it. */
|
|
156
|
+
type StoredHooks<Ctx, Spec> = {
|
|
157
|
+
preExecute?: (call: Call<Ctx, Spec>) => unknown;
|
|
158
|
+
postExecute?: (call: Performed<Ctx, Spec>, state: unknown) => void | Promise<void>;
|
|
159
|
+
onCatch?: (call: Caught<Ctx, Spec>, state: unknown) => void | Promise<void>;
|
|
160
|
+
onFinally?: (call: Settled<Ctx, Spec>, state: unknown) => void | Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
/** Type-only mark. Absent at runtime. Same symbol in {@link UseCase.GuardParameters}. */
|
|
163
|
+
declare const guardParameters: unique symbol;
|
|
164
|
+
type GuardParametersSlot<Ctx, Spec> = {
|
|
165
|
+
readonly [guardParameters]?: (call: Call<Ctx, Spec>) => void;
|
|
166
|
+
};
|
|
167
|
+
declare function buildContext<Ctx, Spec = NoStatics>(options?: {
|
|
168
|
+
guard?: ContextGuard<Ctx, Spec>;
|
|
169
|
+
hooks?: StoredHooks<Ctx, Spec>;
|
|
170
|
+
}): (<const Token extends string, const S extends [keyof Spec] extends [never] ? NoStatics : Spec>(token: Token, ...args: [keyof Spec] extends [never] ? [] : [statics: ReservedOk<S> & Spec]) => ((abstract new () => {
|
|
171
|
+
/** Nominal marker. Each factory call is a distinct class. */
|
|
172
|
+
readonly "__#private@#brand": true;
|
|
173
|
+
/**
|
|
174
|
+
* Required. Annotate `ctx`, `input`, and the return type on the subclass.
|
|
175
|
+
* A guard and hooks run around this method when set.
|
|
176
|
+
*/
|
|
177
|
+
execute(ctx: Ctx, input: unknown): Promise<unknown>;
|
|
178
|
+
}) & {
|
|
179
|
+
/** Use-case name. Literal type of the string passed to the factory. */
|
|
180
|
+
readonly token: Token;
|
|
181
|
+
}) & ([keyof Spec] extends [never] ? NoStatics : Statics<S>)) & GuardParametersSlot<Ctx, Spec>;
|
|
182
|
+
export {};
|
|
183
|
+
//# sourceMappingURL=use-case.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-case.d.ts","sourceRoot":"","sources":["../src/use-case.ts"],"names":[],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