@entifix/service-shell 0.13.0 → 0.14.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 +7 -7
- package/dist/auth/failures.d.ts +0 -12
- package/dist/auth/failures.d.ts.map +1 -1
- package/dist/auth/failures.js +0 -10
- package/dist/auth/failures.js.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +0 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/require-principal.d.ts +0 -16
- package/dist/auth/require-principal.d.ts.map +1 -1
- package/dist/auth/require-principal.js +1 -38
- package/dist/auth/require-principal.js.map +1 -1
- package/dist/auth/require-service-crossing.d.ts +2 -73
- package/dist/auth/require-service-crossing.d.ts.map +1 -1
- package/dist/auth/require-service-crossing.js +2 -117
- package/dist/auth/require-service-crossing.js.map +1 -1
- package/dist/auth/shared-token.d.ts +0 -15
- package/dist/auth/shared-token.d.ts.map +1 -1
- package/dist/auth/shared-token.js +0 -25
- package/dist/auth/shared-token.js.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/load-remote-configuration.d.ts +4 -4
- package/dist/load-remote-configuration.d.ts.map +1 -1
- package/dist/load-remote-configuration.js +7 -14
- package/dist/load-remote-configuration.js.map +1 -1
- package/dist/observability.d.ts +2 -2
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js.map +1 -1
- package/dist/push/index.d.ts +9 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +9 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/server-push.d.ts +82 -0
- package/dist/push/server-push.d.ts.map +1 -0
- package/dist/push/server-push.js +48 -0
- package/dist/push/server-push.js.map +1 -0
- package/dist/push/sse.d.ts +62 -0
- package/dist/push/sse.d.ts.map +1 -0
- package/dist/push/sse.js +120 -0
- package/dist/push/sse.js.map +1 -0
- package/dist/respond.d.ts +1 -7
- package/dist/respond.d.ts.map +1 -1
- package/dist/respond.js +1 -8
- package/dist/respond.js.map +1 -1
- package/package.json +23 -13
- package/dist/auth/require-organization.d.ts +0 -32
- package/dist/auth/require-organization.d.ts.map +0 -1
- package/dist/auth/require-organization.js +0 -52
- package/dist/auth/require-organization.js.map +0 -1
- package/dist/entity-facet-routes.d.ts +0 -44
- package/dist/entity-facet-routes.d.ts.map +0 -1
- package/dist/entity-facet-routes.js +0 -70
- package/dist/entity-facet-routes.js.map +0 -1
- package/dist/entity-metadata-route.d.ts +0 -25
- package/dist/entity-metadata-route.d.ts.map +0 -1
- package/dist/entity-metadata-route.js +0 -102
- package/dist/entity-metadata-route.js.map +0 -1
- package/dist/entity-route-guard.d.ts +0 -62
- package/dist/entity-route-guard.d.ts.map +0 -1
- package/dist/entity-route-guard.js +0 -35
- package/dist/entity-route-guard.js.map +0 -1
- package/dist/entity-routes.d.ts +0 -76
- package/dist/entity-routes.d.ts.map +0 -1
- package/dist/entity-routes.js +0 -267
- package/dist/entity-routes.js.map +0 -1
- package/dist/route-responses.d.ts +0 -44
- package/dist/route-responses.d.ts.map +0 -1
- package/dist/route-responses.js +0 -104
- package/dist/route-responses.js.map +0 -1
package/dist/entity-routes.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
-
import { deleteUCFactory, EntityIdTag, EntityLoadRequestTag, EntityRepositoryFactoryTag, EntityRepositoryTag, EntityTag, getUCFactory, loadUCFactory, saveUCFactory } from '@entifix/business';
|
|
3
|
-
import { envelopeEntityName, extractMetaEntity, makeEntityEnvelope, makeEntityPageEnvelope, NotFound, parseLoadRequestParams, readEntityEnvelope } from '@entifix/core';
|
|
4
|
-
import { Effect } from 'effect';
|
|
5
|
-
import { HttpRouter, HttpServerRequest, HttpServerResponse } from 'effect/http';
|
|
6
|
-
import { entityMetadataRoute } from './entity-metadata-route.js';
|
|
7
|
-
import { guardRoute } from './entity-route-guard.js';
|
|
8
|
-
import { narrowedByIdRequest, narrowingFor, narrowLoadRequest } from './narrowing.js';
|
|
9
|
-
import { defaultFailurePolicy, respond } from './respond.js';
|
|
10
|
-
import { legacyAnswer, routeFailure } from './route-responses.js';
|
|
11
|
-
export { EntityRouteRefusal } from './route-responses.js';
|
|
12
|
-
const ACTION = {
|
|
13
|
-
list: 'read',
|
|
14
|
-
get: 'read',
|
|
15
|
-
create: 'write',
|
|
16
|
-
update: 'write',
|
|
17
|
-
delete: 'delete'
|
|
18
|
-
};
|
|
19
|
-
const READS = new Set([
|
|
20
|
-
'list',
|
|
21
|
-
'get'
|
|
22
|
-
]);
|
|
23
|
-
/**
|
|
24
|
-
* The generic routes for one entity — list, read, create, update, delete and
|
|
25
|
-
* its `$metadata` — derived from the entity and bound to storage through the
|
|
26
|
-
* host's {@link EntityRepositoryFactoryTag}.
|
|
27
|
-
*
|
|
28
|
-
* What a route set varies on is stated, not written: which verbs exist, who may
|
|
29
|
-
* reach them, which records a reader sees, and what a save must pass. What it
|
|
30
|
-
* never varies on is the wire: the load request is parsed against the entity's
|
|
31
|
-
* own metadata (so a query can only name a member the entity declared
|
|
32
|
-
* filterable or sortable), every answer is an envelope, and the links name
|
|
33
|
-
* exactly the verbs mounted — never one that would `404`.
|
|
34
|
-
*
|
|
35
|
-
* A path that is not one of these verbs is written by hand beside it, and a
|
|
36
|
-
* verb whose generic form does not fit is replaced with `override`.
|
|
37
|
-
*/ const deriveEntityRoutes = (entityConstructor, options)=>{
|
|
38
|
-
var _options_basePath, _options_compositions;
|
|
39
|
-
const key = envelopeEntityName(entityConstructor);
|
|
40
|
-
const base = (_options_basePath = options.basePath) != null ? _options_basePath : `/api/${key}`;
|
|
41
|
-
const mounted = new Set(options.verbs);
|
|
42
|
-
const links = {
|
|
43
|
-
record: (id)=>{
|
|
44
|
-
const href = `${base}/${String(id)}`;
|
|
45
|
-
return [
|
|
46
|
-
...mounted.has('get') ? [
|
|
47
|
-
{
|
|
48
|
-
rel: 'self',
|
|
49
|
-
href,
|
|
50
|
-
method: 'GET'
|
|
51
|
-
}
|
|
52
|
-
] : [],
|
|
53
|
-
...mounted.has('list') ? [
|
|
54
|
-
{
|
|
55
|
-
rel: 'list',
|
|
56
|
-
href: base,
|
|
57
|
-
method: 'GET'
|
|
58
|
-
}
|
|
59
|
-
] : [],
|
|
60
|
-
...mounted.has('update') ? [
|
|
61
|
-
{
|
|
62
|
-
rel: 'update',
|
|
63
|
-
href,
|
|
64
|
-
method: 'PUT'
|
|
65
|
-
}
|
|
66
|
-
] : [],
|
|
67
|
-
...mounted.has('delete') ? [
|
|
68
|
-
{
|
|
69
|
-
rel: 'delete',
|
|
70
|
-
href,
|
|
71
|
-
method: 'DELETE'
|
|
72
|
-
}
|
|
73
|
-
] : []
|
|
74
|
-
];
|
|
75
|
-
},
|
|
76
|
-
collection: ()=>[
|
|
77
|
-
...mounted.has('list') ? [
|
|
78
|
-
{
|
|
79
|
-
rel: 'self',
|
|
80
|
-
href: base,
|
|
81
|
-
method: 'GET'
|
|
82
|
-
}
|
|
83
|
-
] : [],
|
|
84
|
-
...mounted.has('create') ? [
|
|
85
|
-
{
|
|
86
|
-
rel: 'create',
|
|
87
|
-
href: base,
|
|
88
|
-
method: 'POST'
|
|
89
|
-
}
|
|
90
|
-
] : []
|
|
91
|
-
]
|
|
92
|
-
};
|
|
93
|
-
const guardFor = (verb)=>{
|
|
94
|
-
const guard = options.guard;
|
|
95
|
-
return 'kind' in guard ? guard : READS.has(verb) ? guard.read : guard.write;
|
|
96
|
-
};
|
|
97
|
-
const guarded = (verb, use)=>guardRoute(entityConstructor, guardFor(verb), ACTION[verb], use);
|
|
98
|
-
const repository = (context)=>Effect.gen(function*() {
|
|
99
|
-
const factory = yield* EntityRepositoryFactoryTag;
|
|
100
|
-
return yield* factory.for(entityConstructor, _extends({}, context.organizationId === undefined ? {} : {
|
|
101
|
-
organizationId: context.organizationId
|
|
102
|
-
}));
|
|
103
|
-
});
|
|
104
|
-
if (options.narrowing !== undefined && options.scope !== undefined) throw new Error(`the routes for '${extractMetaEntity(entityConstructor).key}' name both ` + '`narrowing` and `scope`; `narrowing` replaces `scope`, so name one.');
|
|
105
|
-
const scopeOf = (context)=>options.scope ? options.scope(context) : Effect.succeed('all');
|
|
106
|
-
/** The narrowing rules choose for this caller, or `undefined` without rules. */ const narrowingOf = (context)=>options.narrowing === undefined || context.verified === undefined ? undefined : narrowingFor(options.narrowing, context.verified);
|
|
107
|
-
const readLoadRequest = Effect.gen(function*() {
|
|
108
|
-
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
109
|
-
const search = new URL(request.url, 'http://localhost').searchParams;
|
|
110
|
-
return yield* Effect.try({
|
|
111
|
-
try: ()=>parseLoadRequestParams(entityConstructor, search),
|
|
112
|
-
catch: (error)=>error
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
const notFound = Effect.fail(new NotFound({
|
|
116
|
-
entity: extractMetaEntity(entityConstructor).key
|
|
117
|
-
}));
|
|
118
|
-
const list = (context)=>Effect.gen(function*() {
|
|
119
|
-
var _parsed_filtering;
|
|
120
|
-
const parsed = yield* readLoadRequest;
|
|
121
|
-
const narrowing = narrowingOf(context);
|
|
122
|
-
const scope = narrowing === undefined ? yield* scopeOf(context) : narrowing === 'nothing' ? 'none' : 'all';
|
|
123
|
-
if (scope === 'none') {
|
|
124
|
-
// Still parsed: whether a query is well-formed must not depend on who
|
|
125
|
-
// asked. `nothing` answers here without a query.
|
|
126
|
-
return yield* HttpServerResponse.json(makeEntityPageEnvelope(entityConstructor, {
|
|
127
|
-
items: [],
|
|
128
|
-
total: 0,
|
|
129
|
-
request: parsed
|
|
130
|
-
}, links.collection()));
|
|
131
|
-
}
|
|
132
|
-
// Conjoined, never substituted: the translator `$and`s every top-level
|
|
133
|
-
// element, so an added element can only narrow, and no `or` in a query
|
|
134
|
-
// string can escape it.
|
|
135
|
-
const request = narrowing !== undefined && narrowing !== 'nothing' ? narrowLoadRequest(parsed, narrowing) : scope === 'all' ? parsed : _extends({}, parsed, {
|
|
136
|
-
filtering: [
|
|
137
|
-
...(_parsed_filtering = parsed.filtering) != null ? _parsed_filtering : [],
|
|
138
|
-
scope.filter
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
const page = yield* loadUCFactory().pipe(Effect.provideService(EntityRepositoryTag, (yield* repository(context))), Effect.provideService(EntityLoadRequestTag, request));
|
|
142
|
-
return yield* HttpServerResponse.json(makeEntityPageEnvelope(entityConstructor, page, links.collection()));
|
|
143
|
-
}).pipe(Effect.catch(legacyAnswer('invalidQuery')));
|
|
144
|
-
const get = (context)=>Effect.gen(function*() {
|
|
145
|
-
const params = yield* HttpRouter.params;
|
|
146
|
-
const narrowing = narrowingOf(context);
|
|
147
|
-
if (narrowing === 'nothing') return yield* notFound;
|
|
148
|
-
// A filter narrowing reads by id as a narrowed load, so the read and the
|
|
149
|
-
// list apply one rule: there is no second, in-memory predicate to drift.
|
|
150
|
-
if (narrowing !== undefined && narrowing !== 'unscoped') {
|
|
151
|
-
const page = yield* loadUCFactory().pipe(Effect.provideService(EntityRepositoryTag, (yield* repository(context))), Effect.provideService(EntityLoadRequestTag, narrowedByIdRequest(narrowing, params.id)));
|
|
152
|
-
const [only] = page.items;
|
|
153
|
-
if (only === undefined) return yield* notFound;
|
|
154
|
-
return yield* HttpServerResponse.json(makeEntityEnvelope(entityConstructor, only, links.record(params.id)));
|
|
155
|
-
}
|
|
156
|
-
const scope = narrowing === undefined ? yield* scopeOf(context) : 'all';
|
|
157
|
-
if (scope === 'none') return yield* notFound;
|
|
158
|
-
const found = yield* getUCFactory().pipe(Effect.provideService(EntityRepositoryTag, (yield* repository(context))), Effect.provideService(EntityIdTag, params.id), Effect.option);
|
|
159
|
-
// Out of scope answers exactly as absent does: a `403` would confirm the
|
|
160
|
-
// record exists to somebody who may not read it.
|
|
161
|
-
if (found._tag === 'None' || scope !== 'all' && !scope.includes(found.value)) {
|
|
162
|
-
return yield* notFound;
|
|
163
|
-
}
|
|
164
|
-
return yield* HttpServerResponse.json(makeEntityEnvelope(entityConstructor, found.value, links.record(params.id)));
|
|
165
|
-
}).pipe(Effect.catch(legacyAnswer('invalid')));
|
|
166
|
-
const save = (verb)=>(context)=>Effect.gen(function*() {
|
|
167
|
-
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
168
|
-
const body = yield* request.json;
|
|
169
|
-
let entity = yield* readEntityEnvelope(entityConstructor, body);
|
|
170
|
-
// On update the URL is authoritative, so a record cannot be renamed
|
|
171
|
-
// onto another one by editing its payload.
|
|
172
|
-
if (verb === 'update') {
|
|
173
|
-
const params = yield* HttpRouter.params;
|
|
174
|
-
entity.id = params.id;
|
|
175
|
-
}
|
|
176
|
-
if (options.prepare) {
|
|
177
|
-
entity = yield* options.prepare(entity, _extends({}, context, {
|
|
178
|
-
verb
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
const saved = yield* saveUCFactory().pipe(Effect.provideService(EntityRepositoryTag, (yield* repository(context))), Effect.provideService(EntityTag, entity));
|
|
182
|
-
return yield* HttpServerResponse.json(makeEntityEnvelope(entityConstructor, saved, links.record(saved.id)));
|
|
183
|
-
}).pipe(Effect.catch(legacyAnswer('invalidBody')));
|
|
184
|
-
/**
|
|
185
|
-
* Answers with an envelope rather than a bare `204`: every message between
|
|
186
|
-
* entifix artifacts is one, and the fetch client parses every response as
|
|
187
|
-
* JSON.
|
|
188
|
-
*/ const remove = (context)=>Effect.gen(function*() {
|
|
189
|
-
const params = yield* HttpRouter.params;
|
|
190
|
-
yield* deleteUCFactory().pipe(Effect.provideService(EntityRepositoryTag, (yield* repository(context))), Effect.provideService(EntityIdTag, params.id));
|
|
191
|
-
return yield* HttpServerResponse.json({
|
|
192
|
-
meta: {
|
|
193
|
-
type: 'entity',
|
|
194
|
-
entity: key,
|
|
195
|
-
links: links.collection()
|
|
196
|
-
},
|
|
197
|
-
data: {
|
|
198
|
-
id: params.id
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}).pipe(Effect.catch(legacyAnswer('invalid')));
|
|
202
|
-
const generic = (verb, context)=>{
|
|
203
|
-
switch(verb){
|
|
204
|
-
case 'list':
|
|
205
|
-
return list(context);
|
|
206
|
-
case 'get':
|
|
207
|
-
return get(context);
|
|
208
|
-
case 'create':
|
|
209
|
-
return save('create')(context);
|
|
210
|
-
case 'update':
|
|
211
|
-
return save('update')(context);
|
|
212
|
-
case 'delete':
|
|
213
|
-
return remove(context);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Each guard asks for different services, so the branches do not unify on
|
|
218
|
-
* their own; the cast states the union every guard this set can reach
|
|
219
|
-
* actually needs.
|
|
220
|
-
*/ const handlerFor = (verb)=>{
|
|
221
|
-
var _options_policy;
|
|
222
|
-
return respond(guarded(verb, (context)=>{
|
|
223
|
-
var _options_override;
|
|
224
|
-
const override = (_options_override = options.override) == null ? void 0 : _options_override[verb];
|
|
225
|
-
return override ? override(context, links) : generic(verb, context);
|
|
226
|
-
}).pipe(Effect.catch(legacyAnswer('invalid'))), (_options_policy = options.policy) != null ? _options_policy : defaultFailurePolicy);
|
|
227
|
-
};
|
|
228
|
-
const ROUTES = {
|
|
229
|
-
list: {
|
|
230
|
-
method: 'GET',
|
|
231
|
-
path: base
|
|
232
|
-
},
|
|
233
|
-
get: {
|
|
234
|
-
method: 'GET',
|
|
235
|
-
path: `${base}/:id`
|
|
236
|
-
},
|
|
237
|
-
create: {
|
|
238
|
-
method: 'POST',
|
|
239
|
-
path: base
|
|
240
|
-
},
|
|
241
|
-
update: {
|
|
242
|
-
method: 'PUT',
|
|
243
|
-
path: `${base}/:id`
|
|
244
|
-
},
|
|
245
|
-
delete: {
|
|
246
|
-
method: 'DELETE',
|
|
247
|
-
path: `${base}/:id`
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
return HttpRouter.addAll([
|
|
251
|
-
// A literal, so it wins over `/:id` regardless of order.
|
|
252
|
-
HttpRouter.route('GET', `${base}/$metadata`, entityMetadataRoute(entityConstructor, (_options_compositions = options.compositions) != null ? _options_compositions : {})),
|
|
253
|
-
...options.verbs.map((verb)=>HttpRouter.route(ROUTES[verb].method, ROUTES[verb].path, handlerFor(verb)))
|
|
254
|
-
]);
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* {@link deriveEntityRoutes}, with a curried form for a caller that has to
|
|
258
|
-
* name the services its `override`, `scope` or `prepare` handlers need:
|
|
259
|
-
* `makeEntityRoutes.for<R>()(Entity, options)` names `R` and still infers the
|
|
260
|
-
* entity and the guard from the value, which a single call with explicit type
|
|
261
|
-
* arguments cannot do.
|
|
262
|
-
*/ export { routeFailure };
|
|
263
|
-
export const makeEntityRoutes = Object.assign(deriveEntityRoutes, {
|
|
264
|
-
for: ()=>(entityConstructor, options)=>deriveEntityRoutes(entityConstructor, options)
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
//# sourceMappingURL=entity-routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entity-routes.ts"],"sourcesContent":["import type { Action } from '@entifix/authz';\nimport type { NarrowingRules } from '@entifix/business';\nimport {\n deleteUCFactory,\n EntityIdTag,\n EntityLoadRequestTag,\n EntityRepositoryFactoryTag,\n EntityRepositoryTag,\n EntityTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n type EntifixBuildError,\n type EntifixEnvelopeLink,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityLoadRequest,\n envelopeEntityName,\n extractMetaEntity,\n makeEntityEnvelope,\n makeEntityPageEnvelope,\n NotFound,\n parseLoadRequestParams,\n readEntityEnvelope,\n} from '@entifix/core';\nimport { Effect } from 'effect';\nimport { HttpRouter, HttpServerRequest, HttpServerResponse } from 'effect/http';\n\nimport { entityMetadataRoute } from './entity-metadata-route.js';\nimport {\n type EntityReadScope,\n type EntityRouteContext,\n type EntityRouteGuard,\n guardRoute,\n type GuardServices,\n} from './entity-route-guard.js';\nimport type { MetadataCompositions } from './metadata-composition.js';\nimport {\n narrowedByIdRequest,\n narrowingFor,\n narrowLoadRequest,\n} from './narrowing.js';\nimport {\n defaultFailurePolicy,\n type FailurePolicy,\n respond,\n} from './respond.js';\nimport {\n type EntityRouteRefusal,\n legacyAnswer,\n routeFailure,\n} from './route-responses.js';\n\n/** The five generic verbs a route set can mount. */\nexport type EntityVerb = 'list' | 'get' | 'create' | 'update' | 'delete';\n\nexport {\n type EntityReadScope,\n type EntityRouteContext,\n type EntityRouteGuard,\n} from './entity-route-guard.js';\nexport { EntityRouteRefusal } from './route-responses.js';\n\n/** A hand-written handler for one verb, mounted under the derived guard. */\nexport type EntityRouteOverride<R> = (\n context: EntityRouteContext,\n links: EntityRouteLinks,\n) => Effect.Effect<HttpServerResponse.HttpServerResponse, unknown, R>;\n\n/** The affordances a route set derives from the verbs it mounts. */\nexport interface EntityRouteLinks {\n readonly record: (id: EntityId) => EntifixEnvelopeLink[];\n readonly collection: () => EntifixEnvelopeLink[];\n}\n\nexport interface EntityRoutesOptions<\n T extends Entity,\n R,\n G extends EntityRouteGuard = EntityRouteGuard,\n> {\n readonly verbs: readonly EntityVerb[];\n /** One guard for every verb, or one for the reads and one for the writes. */\n readonly guard: G | { readonly read: G; readonly write: G };\n /** Defaults to `/api/<entity key>`. */\n readonly basePath?: `/${string}`;\n /**\n * Narrows the reads to what this caller may see, as resolver rules over the\n * verified context. Replaces `scope`; a route set naming both throws.\n */\n readonly narrowing?: NarrowingRules<T>;\n /**\n * The variant rules, recipes and catalog the entity's `@useCase()` verbs\n * name, so `$metadata` can report what each resolves to for the caller.\n */\n readonly compositions?: MetadataCompositions;\n /** Narrows the reads to what this caller may see. Superseded by `narrowing`. */\n readonly scope?: (\n context: EntityRouteContext,\n ) => Effect.Effect<EntityReadScope<T>, never, R>;\n /**\n * Runs on every create and update, after the body is read and before the\n * save — and may change what is saved, or refuse it.\n */\n readonly prepare?: (\n entity: T,\n context: EntityRouteContext & { readonly verb: 'create' | 'update' },\n ) => Effect.Effect<T, EntityRouteRefusal | EntifixBuildError, R>;\n /**\n * A hand-written handler in place of the generic one for a verb. It keeps\n * the derived guard and receives the derived links, so the escape hatch\n * cannot drift from the rest of the set.\n */\n readonly override?: Partial<Record<EntityVerb, EntityRouteOverride<R>>>;\n /**\n * How every verb's failures are answered and logged. Defaults to\n * {@link defaultFailurePolicy}; a host passes its fleet policy.\n */\n readonly policy?: FailurePolicy;\n}\n\nconst ACTION: Record<EntityVerb, Action> = {\n list: 'read',\n get: 'read',\n create: 'write',\n update: 'write',\n delete: 'delete',\n};\n\nconst READS: ReadonlySet<EntityVerb> = new Set(['list', 'get']);\n\n/**\n * The generic routes for one entity — list, read, create, update, delete and\n * its `$metadata` — derived from the entity and bound to storage through the\n * host's {@link EntityRepositoryFactoryTag}.\n *\n * What a route set varies on is stated, not written: which verbs exist, who may\n * reach them, which records a reader sees, and what a save must pass. What it\n * never varies on is the wire: the load request is parsed against the entity's\n * own metadata (so a query can only name a member the entity declared\n * filterable or sortable), every answer is an envelope, and the links name\n * exactly the verbs mounted — never one that would `404`.\n *\n * A path that is not one of these verbs is written by hand beside it, and a\n * verb whose generic form does not fit is replaced with `override`.\n */\nconst deriveEntityRoutes = <\n T extends Entity,\n R = never,\n // `never`, not the whole union: TypeScript infers no type argument once a\n // caller names one, so `makeEntityRoutes<T, R>(…)` used to default `G` to\n // every guard. Then the crossing tags became requirements of a route that\n // guards on a session, and the error surfaced at the host's `Layer.provide`\n // instead of here. Defaulting to `never` refuses that call at the guard\n // itself; `makeEntityRoutes.for<R>()` is the way to name `R` alone.\n const G extends EntityRouteGuard = never,\n>(\n entityConstructor: EntityConstructor<T>,\n options: EntityRoutesOptions<T, R, G>,\n) => {\n const key = envelopeEntityName(entityConstructor);\n const base: `/${string}` = options.basePath ?? `/api/${key}`;\n const mounted = new Set(options.verbs);\n\n const links: EntityRouteLinks = {\n record: id => {\n const href = `${base}/${String(id)}`;\n return [\n ...(mounted.has('get')\n ? [{ rel: 'self', href, method: 'GET' } as const]\n : []),\n ...(mounted.has('list')\n ? [{ rel: 'list', href: base, method: 'GET' } as const]\n : []),\n ...(mounted.has('update')\n ? [{ rel: 'update', href, method: 'PUT' } as const]\n : []),\n ...(mounted.has('delete')\n ? [{ rel: 'delete', href, method: 'DELETE' } as const]\n : []),\n ];\n },\n collection: () => [\n ...(mounted.has('list')\n ? [{ rel: 'self', href: base, method: 'GET' } as const]\n : []),\n ...(mounted.has('create')\n ? [{ rel: 'create', href: base, method: 'POST' } as const]\n : []),\n ],\n };\n\n const guardFor = (verb: EntityVerb): EntityRouteGuard => {\n const guard = options.guard as\n | EntityRouteGuard\n | { readonly read: EntityRouteGuard; readonly write: EntityRouteGuard };\n return 'kind' in guard ? guard : READS.has(verb) ? guard.read : guard.write;\n };\n\n const guarded = <A, E, RR>(\n verb: EntityVerb,\n use: (context: EntityRouteContext) => Effect.Effect<A, E, RR>,\n ) => guardRoute(entityConstructor, guardFor(verb), ACTION[verb], use);\n\n const repository = (context: EntityRouteContext) =>\n Effect.gen(function* () {\n const factory = yield* EntityRepositoryFactoryTag;\n return yield* factory.for(entityConstructor, {\n ...(context.organizationId === undefined\n ? {}\n : { organizationId: context.organizationId }),\n });\n });\n\n if (options.narrowing !== undefined && options.scope !== undefined)\n throw new Error(\n `the routes for '${extractMetaEntity(entityConstructor).key}' name both ` +\n '`narrowing` and `scope`; `narrowing` replaces `scope`, so name one.',\n );\n\n const scopeOf = (context: EntityRouteContext) =>\n options.scope ? options.scope(context) : Effect.succeed('all' as const);\n\n /** The narrowing rules choose for this caller, or `undefined` without rules. */\n const narrowingOf = (context: EntityRouteContext) =>\n options.narrowing === undefined || context.verified === undefined\n ? undefined\n : narrowingFor(options.narrowing, context.verified);\n\n const readLoadRequest = Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const search = new URL(request.url, 'http://localhost').searchParams;\n return yield* Effect.try({\n try: () =>\n parseLoadRequestParams(\n entityConstructor,\n search,\n ) as unknown as EntityLoadRequest<T>,\n catch: error => error as EntifixBuildError,\n });\n });\n\n const notFound = Effect.fail(\n new NotFound({ entity: extractMetaEntity(entityConstructor).key }),\n );\n\n const list = (context: EntityRouteContext) =>\n Effect.gen(function* () {\n const parsed = yield* readLoadRequest;\n const narrowing = narrowingOf(context);\n const scope =\n narrowing === undefined\n ? yield* scopeOf(context)\n : narrowing === 'nothing'\n ? ('none' as const)\n : ('all' as const);\n if (scope === 'none') {\n // Still parsed: whether a query is well-formed must not depend on who\n // asked. `nothing` answers here without a query.\n return yield* HttpServerResponse.json(\n makeEntityPageEnvelope(\n entityConstructor,\n { items: [], total: 0, request: parsed },\n links.collection(),\n ),\n );\n }\n // Conjoined, never substituted: the translator `$and`s every top-level\n // element, so an added element can only narrow, and no `or` in a query\n // string can escape it.\n const request: EntityLoadRequest<T> =\n narrowing !== undefined && narrowing !== 'nothing'\n ? narrowLoadRequest(parsed, narrowing)\n : scope === 'all'\n ? parsed\n : {\n ...parsed,\n filtering: [...(parsed.filtering ?? []), scope.filter],\n };\n const page = yield* loadUCFactory<T>().pipe(\n Effect.provideService(EntityRepositoryTag, yield* repository(context)),\n Effect.provideService(\n EntityLoadRequestTag,\n request as unknown as EntityLoadRequest,\n ),\n );\n return yield* HttpServerResponse.json(\n makeEntityPageEnvelope(entityConstructor, page, links.collection()),\n );\n }).pipe(Effect.catch(legacyAnswer('invalidQuery')));\n\n const get = (context: EntityRouteContext) =>\n Effect.gen(function* () {\n const params = yield* HttpRouter.params;\n const narrowing = narrowingOf(context);\n if (narrowing === 'nothing') return yield* notFound;\n // A filter narrowing reads by id as a narrowed load, so the read and the\n // list apply one rule: there is no second, in-memory predicate to drift.\n if (narrowing !== undefined && narrowing !== 'unscoped') {\n const page = yield* loadUCFactory<T>().pipe(\n Effect.provideService(\n EntityRepositoryTag,\n yield* repository(context),\n ),\n Effect.provideService(\n EntityLoadRequestTag,\n narrowedByIdRequest<T>(\n narrowing,\n params.id,\n ) as unknown as EntityLoadRequest,\n ),\n );\n const [only] = page.items;\n if (only === undefined) return yield* notFound;\n return yield* HttpServerResponse.json(\n makeEntityEnvelope(entityConstructor, only, links.record(params.id)),\n );\n }\n const scope = narrowing === undefined ? yield* scopeOf(context) : 'all';\n if (scope === 'none') return yield* notFound;\n const found = yield* getUCFactory<T>().pipe(\n Effect.provideService(EntityRepositoryTag, yield* repository(context)),\n Effect.provideService(EntityIdTag, params.id),\n Effect.option,\n );\n // Out of scope answers exactly as absent does: a `403` would confirm the\n // record exists to somebody who may not read it.\n if (\n found._tag === 'None' ||\n (scope !== 'all' && !scope.includes(found.value))\n ) {\n return yield* notFound;\n }\n return yield* HttpServerResponse.json(\n makeEntityEnvelope(\n entityConstructor,\n found.value,\n links.record(params.id),\n ),\n );\n }).pipe(Effect.catch(legacyAnswer('invalid')));\n\n const save = (verb: 'create' | 'update') => (context: EntityRouteContext) =>\n Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const body = yield* request.json;\n let entity = yield* readEntityEnvelope(entityConstructor, body);\n\n // On update the URL is authoritative, so a record cannot be renamed\n // onto another one by editing its payload.\n if (verb === 'update') {\n const params = yield* HttpRouter.params;\n entity.id = params.id;\n }\n if (options.prepare) {\n entity = yield* options.prepare(entity, { ...context, verb });\n }\n\n const saved = yield* saveUCFactory<T>().pipe(\n Effect.provideService(EntityRepositoryTag, yield* repository(context)),\n Effect.provideService(EntityTag, entity),\n );\n return yield* HttpServerResponse.json(\n makeEntityEnvelope(entityConstructor, saved, links.record(saved.id)),\n );\n }).pipe(Effect.catch(legacyAnswer('invalidBody')));\n\n /**\n * Answers with an envelope rather than a bare `204`: every message between\n * entifix artifacts is one, and the fetch client parses every response as\n * JSON.\n */\n const remove = (context: EntityRouteContext) =>\n Effect.gen(function* () {\n const params = yield* HttpRouter.params;\n yield* deleteUCFactory<T>().pipe(\n Effect.provideService(EntityRepositoryTag, yield* repository(context)),\n Effect.provideService(EntityIdTag, params.id),\n );\n return yield* HttpServerResponse.json({\n meta: { type: 'entity', entity: key, links: links.collection() },\n data: { id: params.id },\n });\n }).pipe(Effect.catch(legacyAnswer('invalid')));\n\n const generic = (verb: EntityVerb, context: EntityRouteContext) => {\n switch (verb) {\n case 'list':\n return list(context);\n case 'get':\n return get(context);\n case 'create':\n return save('create')(context);\n case 'update':\n return save('update')(context);\n case 'delete':\n return remove(context);\n }\n };\n\n /**\n * Each guard asks for different services, so the branches do not unify on\n * their own; the cast states the union every guard this set can reach\n * actually needs.\n */\n const handlerFor = (verb: EntityVerb) =>\n respond(\n (\n guarded(verb, context => {\n const override = options.override?.[verb];\n return override ? override(context, links) : generic(verb, context);\n }) as Effect.Effect<\n HttpServerResponse.HttpServerResponse,\n unknown,\n | R\n | EntityRepositoryFactoryTag\n | GuardServices<G>\n | HttpServerRequest.HttpServerRequest\n | HttpRouter.RouteContext\n >\n ).pipe(Effect.catch(legacyAnswer('invalid'))),\n options.policy ?? defaultFailurePolicy,\n );\n\n const ROUTES: Record<\n EntityVerb,\n { method: 'GET' | 'POST' | 'PUT' | 'DELETE'; path: `/${string}` }\n > = {\n list: { method: 'GET', path: base },\n get: { method: 'GET', path: `${base}/:id` },\n create: { method: 'POST', path: base },\n update: { method: 'PUT', path: `${base}/:id` },\n delete: { method: 'DELETE', path: `${base}/:id` },\n };\n\n return HttpRouter.addAll([\n // A literal, so it wins over `/:id` regardless of order.\n HttpRouter.route(\n 'GET',\n `${base}/$metadata`,\n entityMetadataRoute(entityConstructor, options.compositions ?? {}),\n ),\n ...options.verbs.map(verb =>\n HttpRouter.route(\n ROUTES[verb].method,\n ROUTES[verb].path,\n handlerFor(verb),\n ),\n ),\n ]);\n};\n\n/**\n * {@link deriveEntityRoutes}, with a curried form for a caller that has to\n * name the services its `override`, `scope` or `prepare` handlers need:\n * `makeEntityRoutes.for<R>()(Entity, options)` names `R` and still infers the\n * entity and the guard from the value, which a single call with explicit type\n * arguments cannot do.\n */\nexport { routeFailure };\n\nexport const makeEntityRoutes = Object.assign(deriveEntityRoutes, {\n for:\n <R>() =>\n <T extends Entity, const G extends EntityRouteGuard>(\n entityConstructor: EntityConstructor<T>,\n options: EntityRoutesOptions<T, R, G>,\n ) =>\n deriveEntityRoutes<T, R, G>(entityConstructor, options),\n});\n"],"names":["deleteUCFactory","EntityIdTag","EntityLoadRequestTag","EntityRepositoryFactoryTag","EntityRepositoryTag","EntityTag","getUCFactory","loadUCFactory","saveUCFactory","envelopeEntityName","extractMetaEntity","makeEntityEnvelope","makeEntityPageEnvelope","NotFound","parseLoadRequestParams","readEntityEnvelope","Effect","HttpRouter","HttpServerRequest","HttpServerResponse","entityMetadataRoute","guardRoute","narrowedByIdRequest","narrowingFor","narrowLoadRequest","defaultFailurePolicy","respond","legacyAnswer","routeFailure","EntityRouteRefusal","ACTION","list","get","create","update","delete","READS","Set","deriveEntityRoutes","entityConstructor","options","key","base","basePath","mounted","verbs","links","record","id","href","String","has","rel","method","collection","guardFor","verb","guard","read","write","guarded","use","repository","context","gen","factory","for","organizationId","undefined","narrowing","scope","Error","scopeOf","succeed","narrowingOf","verified","readLoadRequest","request","search","URL","url","searchParams","try","catch","error","notFound","fail","entity","parsed","json","items","total","filtering","filter","page","pipe","provideService","params","only","found","option","_tag","includes","value","save","body","prepare","saved","remove","meta","type","data","generic","handlerFor","override","policy","ROUTES","path","addAll","route","compositions","map","makeEntityRoutes","Object","assign"],"mappings":";AAEA,SACEA,eAAe,EACfC,WAAW,EACXC,oBAAoB,EACpBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,aAAa,QACR,oBAAoB;AAC3B,SAOEC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,EAClBC,sBAAsB,EACtBC,QAAQ,EACRC,sBAAsB,EACtBC,kBAAkB,QACb,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,UAAU,EAAEC,iBAAiB,EAAEC,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,oBAAoBmB,oBAAmBC,wBAAAA,QAAQgF,YAAY,YAApBhF,wBAAwB,CAAC;WAE/DA,QAAQK,KAAK,CAAC4E,GAAG,CAACjE,CAAAA,OACnBvC,WAAWsG,KAAK,CACdH,MAAM,CAAC5D,KAAK,CAACH,MAAM,EACnB+D,MAAM,CAAC5D,KAAK,CAAC6D,IAAI,EACjBJ,WAAWzD;KAGhB;AACH;AAEA;;;;;;CAMC,GACD,SAAS5B,YAAY,GAAG;AAExB,OAAO,MAAM8F,mBAAmBC,OAAOC,MAAM,CAACtF,oBAAoB;IAChE4B,KACE,IACA,CACE3B,mBACAC,UAEAF,mBAA4BC,mBAAmBC;AACrD,GAAG"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type EntifixFailure } from '@entifix/core';
|
|
2
|
-
import { Effect } from 'effect';
|
|
3
|
-
import { HttpServerResponse } from 'effect/http';
|
|
4
|
-
/**
|
|
5
|
-
* A save refused by a rule the entity's own deserializer does not make — a
|
|
6
|
-
* closed set, a rule over the other records — answered as `status` with
|
|
7
|
-
* `code`, which is what a client translates.
|
|
8
|
-
*/
|
|
9
|
-
export declare class EntityRouteRefusal {
|
|
10
|
-
readonly status: 400 | 409 | 422;
|
|
11
|
-
readonly code: string;
|
|
12
|
-
readonly detail?: string | undefined;
|
|
13
|
-
readonly _tag = "EntityRouteRefusal";
|
|
14
|
-
constructor(status: 400 | 409 | 422, code: string, detail?: string | undefined);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The `500` for anything a route did not anticipate.
|
|
18
|
-
*
|
|
19
|
-
* @deprecated A route mounted through `mountRoutes` answers through `respond`,
|
|
20
|
-
* which never writes `String(error)`. Kept for a host's unmigrated routes and
|
|
21
|
-
* removed with the class tree.
|
|
22
|
-
*/
|
|
23
|
-
export declare const routeFailure: (error: unknown) => Effect.Effect<HttpServerResponse.HttpServerResponse, import("effect/http/HttpBody").HttpBodyError, never>;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated A route mounted through `mountRoutes` fails with typed failures
|
|
26
|
-
* and lets `respond` answer them. Kept for a host's unmigrated routes and
|
|
27
|
-
* removed with the class tree.
|
|
28
|
-
*
|
|
29
|
-
* The answer to a request the route refused: a `400` for what the client sent
|
|
30
|
-
* wrong, the refusal's own status for a rule a save broke, a business-family
|
|
31
|
-
* failure's category status, and a `500` for anything else.
|
|
32
|
-
*/
|
|
33
|
-
export declare const invalid: (error: unknown, label: string, code: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, import("effect/http/HttpBody").HttpBodyError, never>;
|
|
34
|
-
/**
|
|
35
|
-
* What a framework route's errors mean, while some still arrive as the old
|
|
36
|
-
* class tree: a typed failure passes through to `respond`, a refusal answers
|
|
37
|
-
* as its own problem body, an unreachable store becomes `Unavailable`, and
|
|
38
|
-
* anything else is a defect — the opaque `500`, logged where `respond`
|
|
39
|
-
* catches it.
|
|
40
|
-
*
|
|
41
|
-
* @param fallbackCode the code a domain error carrying none answers with.
|
|
42
|
-
*/
|
|
43
|
-
export declare const legacyAnswer: (fallbackCode: string) => (error: unknown) => Effect.Effect<HttpServerResponse.HttpServerResponse, EntifixFailure>;
|
|
44
|
-
//# sourceMappingURL=route-responses.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-responses.d.ts","sourceRoot":"","sources":["../src/route-responses.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,kBAAkB;IAI3B,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAL1B,QAAQ,CAAC,IAAI,wBAAwB;gBAG1B,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA;CAE3B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,8GAIxC,CAAC;AASJ;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,EAAE,MAAM,MAAM,8GA8BtC,CAAC;AAmC9B;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACtB,cAAc,MAAM,MAEnB,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,cAAc,CAezC,CAAC"}
|
package/dist/route-responses.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
-
import { defaultStatus, EntifixBuildError, EntifixConnError, failureTypeUri, isFailure, PROBLEM_CONTENT_TYPE, Unavailable } from '@entifix/core';
|
|
3
|
-
import { Effect } from 'effect';
|
|
4
|
-
import { HttpServerResponse } from 'effect/http';
|
|
5
|
-
/**
|
|
6
|
-
* A save refused by a rule the entity's own deserializer does not make — a
|
|
7
|
-
* closed set, a rule over the other records — answered as `status` with
|
|
8
|
-
* `code`, which is what a client translates.
|
|
9
|
-
*/ export class EntityRouteRefusal {
|
|
10
|
-
constructor(status, code, detail){
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.detail = detail;
|
|
14
|
-
this._tag = 'EntityRouteRefusal';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The `500` for anything a route did not anticipate.
|
|
19
|
-
*
|
|
20
|
-
* @deprecated A route mounted through `mountRoutes` answers through `respond`,
|
|
21
|
-
* which never writes `String(error)`. Kept for a host's unmigrated routes and
|
|
22
|
-
* removed with the class tree.
|
|
23
|
-
*/ export const routeFailure = (error)=>HttpServerResponse.json({
|
|
24
|
-
error: 'request failed',
|
|
25
|
-
code: 'unexpected',
|
|
26
|
-
detail: String(error)
|
|
27
|
-
}, {
|
|
28
|
-
status: 500
|
|
29
|
-
});
|
|
30
|
-
/**
|
|
31
|
-
* A domain error may carry its own code (`mediaNotHttps`), so the client can
|
|
32
|
-
* say which rule failed rather than "invalid body".
|
|
33
|
-
*/ const refusalCode = (error)=>'code' in error && typeof error.code === 'string' ? error.code : undefined;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated A route mounted through `mountRoutes` fails with typed failures
|
|
36
|
-
* and lets `respond` answer them. Kept for a host's unmigrated routes and
|
|
37
|
-
* removed with the class tree.
|
|
38
|
-
*
|
|
39
|
-
* The answer to a request the route refused: a `400` for what the client sent
|
|
40
|
-
* wrong, the refusal's own status for a rule a save broke, a business-family
|
|
41
|
-
* failure's category status, and a `500` for anything else.
|
|
42
|
-
*/ export const invalid = (error, label, code)=>{
|
|
43
|
-
var _refusalCode;
|
|
44
|
-
return isFailure(error) && error.family === 'business' ? HttpServerResponse.json(_extends({
|
|
45
|
-
error: label,
|
|
46
|
-
// A body that is not an envelope is the route's own refusal, named
|
|
47
|
-
// by the route as it always was; any other failure names itself.
|
|
48
|
-
code: error._tag === 'InvalidEnvelope' ? code : error.code
|
|
49
|
-
}, error.message === '' ? {} : {
|
|
50
|
-
detail: error.message
|
|
51
|
-
}), {
|
|
52
|
-
status: defaultStatus(error.category)
|
|
53
|
-
}) : error instanceof EntifixBuildError ? HttpServerResponse.json({
|
|
54
|
-
error: label,
|
|
55
|
-
code: (_refusalCode = refusalCode(error)) != null ? _refusalCode : code,
|
|
56
|
-
detail: error.message
|
|
57
|
-
}, {
|
|
58
|
-
status: 400
|
|
59
|
-
}) : error instanceof EntityRouteRefusal ? HttpServerResponse.json(_extends({
|
|
60
|
-
error: 'the record cannot be saved',
|
|
61
|
-
code: error.code
|
|
62
|
-
}, error.detail === undefined ? {} : {
|
|
63
|
-
detail: error.detail
|
|
64
|
-
}), {
|
|
65
|
-
status: error.status
|
|
66
|
-
}) : routeFailure(error);
|
|
67
|
-
};
|
|
68
|
-
const LEGACY_CATEGORY = {
|
|
69
|
-
400: 'invalid',
|
|
70
|
-
409: 'conflict',
|
|
71
|
-
422: 'declined'
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* A problem body for a refusal whose code no failure class registered — a
|
|
75
|
-
* host's `EntityRouteRefusal`, a domain `EntifixBuildError` carrying its own
|
|
76
|
-
* code. Written by hand because there is no class to encode it through; a
|
|
77
|
-
* client that decodes it sees an unknown code until the refusal becomes a
|
|
78
|
-
* failure of its own.
|
|
79
|
-
*/ const legacyProblem = (status, code, detail)=>HttpServerResponse.text(JSON.stringify(_extends({
|
|
80
|
-
type: failureTypeUri(code),
|
|
81
|
-
title: code,
|
|
82
|
-
status,
|
|
83
|
-
code,
|
|
84
|
-
category: LEGACY_CATEGORY[status]
|
|
85
|
-
}, detail === undefined ? {} : {
|
|
86
|
-
detail
|
|
87
|
-
})), {
|
|
88
|
-
status,
|
|
89
|
-
contentType: PROBLEM_CONTENT_TYPE
|
|
90
|
-
});
|
|
91
|
-
/**
|
|
92
|
-
* What a framework route's errors mean, while some still arrive as the old
|
|
93
|
-
* class tree: a typed failure passes through to `respond`, a refusal answers
|
|
94
|
-
* as its own problem body, an unreachable store becomes `Unavailable`, and
|
|
95
|
-
* anything else is a defect — the opaque `500`, logged where `respond`
|
|
96
|
-
* catches it.
|
|
97
|
-
*
|
|
98
|
-
* @param fallbackCode the code a domain error carrying none answers with.
|
|
99
|
-
*/ export const legacyAnswer = (fallbackCode)=>(error)=>{
|
|
100
|
-
var _refusalCode;
|
|
101
|
-
return isFailure(error) ? Effect.fail(error) : error instanceof EntityRouteRefusal ? Effect.succeed(legacyProblem(error.status, error.code, error.detail)) : error instanceof EntifixBuildError ? Effect.succeed(legacyProblem(400, (_refusalCode = refusalCode(error)) != null ? _refusalCode : fallbackCode, error.message)) : error instanceof EntifixConnError ? Effect.fail(new Unavailable({})) : Effect.die(error);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
//# sourceMappingURL=route-responses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/route-responses.ts"],"sourcesContent":["import {\n defaultStatus,\n EntifixBuildError,\n EntifixConnError,\n type EntifixFailure,\n failureTypeUri,\n isFailure,\n PROBLEM_CONTENT_TYPE,\n Unavailable,\n} from '@entifix/core';\nimport { Effect } from 'effect';\nimport { HttpServerResponse } from 'effect/http';\n\n/**\n * A save refused by a rule the entity's own deserializer does not make — a\n * closed set, a rule over the other records — answered as `status` with\n * `code`, which is what a client translates.\n */\nexport class EntityRouteRefusal {\n readonly _tag = 'EntityRouteRefusal';\n\n constructor(\n readonly status: 400 | 409 | 422,\n readonly code: string,\n readonly detail?: string,\n ) {}\n}\n\n/**\n * The `500` for anything a route did not anticipate.\n *\n * @deprecated A route mounted through `mountRoutes` answers through `respond`,\n * which never writes `String(error)`. Kept for a host's unmigrated routes and\n * removed with the class tree.\n */\nexport const routeFailure = (error: unknown) =>\n HttpServerResponse.json(\n { error: 'request failed', code: 'unexpected', detail: String(error) },\n { status: 500 },\n );\n\n/**\n * A domain error may carry its own code (`mediaNotHttps`), so the client can\n * say which rule failed rather than \"invalid body\".\n */\nconst refusalCode = (error: EntifixBuildError): string | undefined =>\n 'code' in error && typeof error.code === 'string' ? error.code : undefined;\n\n/**\n * @deprecated A route mounted through `mountRoutes` fails with typed failures\n * and lets `respond` answer them. Kept for a host's unmigrated routes and\n * removed with the class tree.\n *\n * The answer to a request the route refused: a `400` for what the client sent\n * wrong, the refusal's own status for a rule a save broke, a business-family\n * failure's category status, and a `500` for anything else.\n */\nexport const invalid = (error: unknown, label: string, code: string) =>\n isFailure(error) && error.family === 'business'\n ? HttpServerResponse.json(\n {\n error: label,\n // A body that is not an envelope is the route's own refusal, named\n // by the route as it always was; any other failure names itself.\n code: error._tag === 'InvalidEnvelope' ? code : error.code,\n ...(error.message === '' ? {} : { detail: error.message }),\n },\n { status: defaultStatus(error.category) },\n )\n : error instanceof EntifixBuildError\n ? HttpServerResponse.json(\n {\n error: label,\n code: refusalCode(error) ?? code,\n detail: error.message,\n },\n { status: 400 },\n )\n : error instanceof EntityRouteRefusal\n ? HttpServerResponse.json(\n {\n error: 'the record cannot be saved',\n code: error.code,\n ...(error.detail === undefined ? {} : { detail: error.detail }),\n },\n { status: error.status },\n )\n : routeFailure(error);\n\nconst LEGACY_CATEGORY: Record<\n EntityRouteRefusal['status'],\n 'invalid' | 'conflict' | 'declined'\n> = {\n 400: 'invalid',\n 409: 'conflict',\n 422: 'declined',\n};\n\n/**\n * A problem body for a refusal whose code no failure class registered — a\n * host's `EntityRouteRefusal`, a domain `EntifixBuildError` carrying its own\n * code. Written by hand because there is no class to encode it through; a\n * client that decodes it sees an unknown code until the refusal becomes a\n * failure of its own.\n */\nconst legacyProblem = (\n status: EntityRouteRefusal['status'],\n code: string,\n detail?: string,\n) =>\n HttpServerResponse.text(\n JSON.stringify({\n type: failureTypeUri(code),\n title: code,\n status,\n code,\n category: LEGACY_CATEGORY[status],\n ...(detail === undefined ? {} : { detail }),\n }),\n { status, contentType: PROBLEM_CONTENT_TYPE },\n );\n\n/**\n * What a framework route's errors mean, while some still arrive as the old\n * class tree: a typed failure passes through to `respond`, a refusal answers\n * as its own problem body, an unreachable store becomes `Unavailable`, and\n * anything else is a defect — the opaque `500`, logged where `respond`\n * catches it.\n *\n * @param fallbackCode the code a domain error carrying none answers with.\n */\nexport const legacyAnswer =\n (fallbackCode: string) =>\n (\n error: unknown,\n ): Effect.Effect<HttpServerResponse.HttpServerResponse, EntifixFailure> =>\n isFailure(error)\n ? Effect.fail(error)\n : error instanceof EntityRouteRefusal\n ? Effect.succeed(legacyProblem(error.status, error.code, error.detail))\n : error instanceof EntifixBuildError\n ? Effect.succeed(\n legacyProblem(\n 400,\n refusalCode(error) ?? fallbackCode,\n error.message,\n ),\n )\n : error instanceof EntifixConnError\n ? Effect.fail(new Unavailable({}))\n : Effect.die(error);\n"],"names":["defaultStatus","EntifixBuildError","EntifixConnError","failureTypeUri","isFailure","PROBLEM_CONTENT_TYPE","Unavailable","Effect","HttpServerResponse","EntityRouteRefusal","status","code","detail","_tag","routeFailure","error","json","String","refusalCode","undefined","invalid","label","family","message","category","LEGACY_CATEGORY","legacyProblem","text","JSON","stringify","type","title","contentType","legacyAnswer","fallbackCode","fail","succeed","die"],"mappings":";AAAA,SACEA,aAAa,EACbC,iBAAiB,EACjBC,gBAAgB,EAEhBC,cAAc,EACdC,SAAS,EACTC,oBAAoB,EACpBC,WAAW,QACN,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,kBAAkB,QAAQ,cAAc;AAEjD;;;;CAIC,GACD,OAAO,MAAMC;IAGX,YACE,AAASC,MAAuB,EAChC,AAASC,IAAY,EACrB,AAASC,MAAe,CACxB;aAHSF,SAAAA;aACAC,OAAAA;aACAC,SAAAA;aALFC,OAAO;IAMb;AACL;AAEA;;;;;;CAMC,GACD,OAAO,MAAMC,eAAe,CAACC,QAC3BP,mBAAmBQ,IAAI,CACrB;QAAED,OAAO;QAAkBJ,MAAM;QAAcC,QAAQK,OAAOF;IAAO,GACrE;QAAEL,QAAQ;IAAI,GACd;AAEJ;;;CAGC,GACD,MAAMQ,cAAc,CAACH,QACnB,UAAUA,SAAS,OAAOA,MAAMJ,IAAI,KAAK,WAAWI,MAAMJ,IAAI,GAAGQ;AAEnE;;;;;;;;CAQC,GACD,OAAO,MAAMC,UAAU,CAACL,OAAgBM,OAAeV;QAgBrCO;WAfhBd,UAAUW,UAAUA,MAAMO,MAAM,KAAK,aACjCd,mBAAmBQ,IAAI,CACrB;QACED,OAAOM;QACP,mEAAmE;QACnE,iEAAiE;QACjEV,MAAMI,MAAMF,IAAI,KAAK,oBAAoBF,OAAOI,MAAMJ,IAAI;OACtDI,MAAMQ,OAAO,KAAK,KAAK,CAAC,IAAI;QAAEX,QAAQG,MAA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