@trebired/result 0.2.1 → 1.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/CHANGELOG.md +8 -0
- package/README.md +121 -260
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/responder.d.ts +4 -3
- package/dist/responder.d.ts.map +1 -1
- package/dist/responder.js +25 -103
- package/dist/responder.js.map +1 -1
- package/dist/responder_support.d.ts +11 -9
- package/dist/responder_support.d.ts.map +1 -1
- package/dist/responder_support.js +123 -60
- package/dist/responder_support.js.map +1 -1
- package/dist/result.d.ts +10 -10
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +22 -31
- package/dist/result.js.map +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -2
- package/dist/shared.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/responder.d.ts +4 -3
- package/dist/src/responder.d.ts.map +1 -1
- package/dist/src/responder.js +25 -103
- package/dist/src/responder.js.map +1 -1
- package/dist/src/responder_support.d.ts +11 -9
- package/dist/src/responder_support.d.ts.map +1 -1
- package/dist/src/responder_support.js +123 -60
- package/dist/src/responder_support.js.map +1 -1
- package/dist/src/result.d.ts +10 -10
- package/dist/src/result.d.ts.map +1 -1
- package/dist/src/result.js +22 -31
- package/dist/src/result.js.map +1 -1
- package/dist/src/shared.d.ts.map +1 -1
- package/dist/src/shared.js +4 -2
- package/dist/src/shared.js.map +1 -1
- package/dist/src/types.d.ts +16 -45
- package/dist/src/types.d.ts.map +1 -1
- package/dist/types.d.ts +16 -45
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- Added first-class generic responder support with caller-provided JSON, text, render, and language callbacks.
|
|
6
|
+
- Made result builders key-first, with metadata objects used for interpolation variables and payload metadata.
|
|
7
|
+
- Added explicit local i18n bundle lookup with nested dot keys, Czech/selected-language resolution, English fallback from the provided bundle, and missing-key fallback to the key string.
|
|
8
|
+
- Kept localized payload messages separate from stable normalized result/error codes.
|
|
9
|
+
- Migrated the package to Code Discipline 4.7 alias-map mode without package.json imports.
|
|
10
|
+
|
|
3
11
|
## 0.2.1
|
|
4
12
|
|
|
5
13
|
- Moved package-owned result tracing and responder diagnostics under the `trebired.result` group root while leaving caller-supplied trace labels intact.
|
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# @trebired/result
|
|
2
2
|
|
|
3
|
-
Shared result builders,
|
|
3
|
+
Shared result builders, backend/system responder helpers, local i18n lookup, and failure tracing for Bun and Node.js packages.
|
|
4
4
|
|
|
5
|
-
`@trebired/result`
|
|
6
|
-
|
|
7
|
-
It does not know about Express, React, route names, page names, logger group wording, or a fixed runtime layout. Hosts bring their own adapters and decide which advanced tracing surfaces to enable.
|
|
5
|
+
`@trebired/result` is transport-agnostic. It does not import web frameworks, route files, frontend code, app registries, global dictionaries, or generated i18n state. Callers provide the delivery callbacks and local translation bundles.
|
|
8
6
|
|
|
9
7
|
## Install
|
|
10
8
|
|
|
@@ -16,80 +14,55 @@ npm install @trebired/result
|
|
|
16
14
|
|
|
17
15
|
## Quick Start
|
|
18
16
|
|
|
19
|
-
Build
|
|
17
|
+
Build keyed results:
|
|
20
18
|
|
|
21
19
|
```ts
|
|
22
20
|
import { result } from "@trebired/result";
|
|
23
21
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
id: "project_42",
|
|
27
|
-
},
|
|
22
|
+
const missingPassword = result.badRequest("missingPassword", {
|
|
23
|
+
min: 8,
|
|
28
24
|
});
|
|
29
25
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
id: "project_42",
|
|
33
|
-
},
|
|
26
|
+
const writeFailed = result.internal("writeFailed", {
|
|
27
|
+
filePath: "/var/data/output.json",
|
|
34
28
|
});
|
|
35
29
|
```
|
|
36
30
|
|
|
37
|
-
Wire a responder with
|
|
31
|
+
Wire a responder with caller-owned callbacks:
|
|
38
32
|
|
|
39
33
|
```ts
|
|
40
|
-
import {
|
|
34
|
+
import { createResponder, result } from "@trebired/result";
|
|
35
|
+
import en from "./i18n/en";
|
|
36
|
+
import cs from "./i18n/cs";
|
|
41
37
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
text({ res, model, text }) {
|
|
50
|
-
return res.status(model.status).type("text/plain").send(text);
|
|
51
|
-
},
|
|
52
|
-
getRenderModePath({ res }) {
|
|
53
|
-
return res.locals.renderModePath;
|
|
54
|
-
},
|
|
38
|
+
const authI18n = { en, cs };
|
|
39
|
+
|
|
40
|
+
const respond = createResponder({
|
|
41
|
+
getLanguage: (ctx) => ctx.lang,
|
|
42
|
+
sendJson: (ctx, payload) => ctx.reply.json(payload.status, payload),
|
|
43
|
+
sendText: (ctx, status, text) => ctx.reply.text(status, text),
|
|
44
|
+
render: (ctx, model) => ctx.reply.render(model),
|
|
55
45
|
});
|
|
56
46
|
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
result: result.notFound("project-not-found", "Project not found."),
|
|
61
|
-
render: true,
|
|
62
|
-
type: "app.project",
|
|
47
|
+
return respond(ctx, result.badRequest("missingPassword", { min: 8 }), {
|
|
48
|
+
i18n: authI18n,
|
|
49
|
+
render: "auto",
|
|
63
50
|
});
|
|
64
51
|
```
|
|
65
52
|
|
|
66
|
-
|
|
53
|
+
## Result Builders
|
|
67
54
|
|
|
68
|
-
|
|
69
|
-
import { createResultTracer, result } from "@trebired/result";
|
|
70
|
-
|
|
71
|
-
const tracer = createResultTracer({
|
|
72
|
-
failedResultSeverity: "warn",
|
|
73
|
-
logger: console,
|
|
74
|
-
onTrace(record) {
|
|
75
|
-
console.error(record.label, record.message, record.traceStack);
|
|
76
|
-
},
|
|
77
|
-
});
|
|
55
|
+
The normal builder shape is key-first:
|
|
78
56
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
throw new Error("Database offline");
|
|
85
|
-
}, {
|
|
86
|
-
label: "project.load",
|
|
87
|
-
});
|
|
57
|
+
```ts
|
|
58
|
+
result.unauthorized("authRequired");
|
|
59
|
+
result.badRequest("missingPassword");
|
|
60
|
+
result.internal("writeFailed", { filePath });
|
|
88
61
|
```
|
|
89
62
|
|
|
90
|
-
|
|
63
|
+
The second argument is metadata. The responder uses it as interpolation variables and keeps it on `payload.meta`.
|
|
91
64
|
|
|
92
|
-
The shared result envelope
|
|
65
|
+
The shared result envelope is:
|
|
93
66
|
|
|
94
67
|
```ts
|
|
95
68
|
type ResultLike = {
|
|
@@ -106,72 +79,81 @@ type ResultLike = {
|
|
|
106
79
|
};
|
|
107
80
|
```
|
|
108
81
|
|
|
82
|
+
`message` is the stable local key on the raw result. `error_code` is the normalized stable code, for example `missingPassword` becomes `missing-password`. Responder payloads localize `message` while preserving `error_code`.
|
|
83
|
+
|
|
109
84
|
Builder helpers:
|
|
110
85
|
|
|
111
|
-
- `result.ok(
|
|
112
|
-
- `result.noop(
|
|
113
|
-
- `result.error(status?,
|
|
114
|
-
- `result.badRequest(
|
|
115
|
-
- `result.unauthorized(
|
|
116
|
-
- `result.forbidden(
|
|
117
|
-
- `result.notFound(
|
|
118
|
-
- `result.conflict(
|
|
119
|
-
- `result.internal(
|
|
86
|
+
- `result.ok(messageKey?, metadata?)`
|
|
87
|
+
- `result.noop(messageKey?, metadata?)`
|
|
88
|
+
- `result.error(status?, messageKey?, metadata?)`
|
|
89
|
+
- `result.badRequest(messageKey?, metadata?)`
|
|
90
|
+
- `result.unauthorized(messageKey?, metadata?)`
|
|
91
|
+
- `result.forbidden(messageKey?, metadata?)`
|
|
92
|
+
- `result.notFound(messageKey?, metadata?)`
|
|
93
|
+
- `result.conflict(messageKey?, metadata?)`
|
|
94
|
+
- `result.internal(messageKey?, metadata?)`
|
|
120
95
|
|
|
121
|
-
|
|
96
|
+
## Local I18n
|
|
122
97
|
|
|
123
|
-
|
|
98
|
+
Pass local bundles at respond time:
|
|
124
99
|
|
|
125
|
-
|
|
100
|
+
```ts
|
|
101
|
+
const authI18n = {
|
|
102
|
+
en: {
|
|
103
|
+
authRequired: "Authentication required.",
|
|
104
|
+
missingPassword: "Password must be at least {min} characters.",
|
|
105
|
+
protect: {
|
|
106
|
+
missingMode: "Missing protect mode.",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
cs: {
|
|
110
|
+
authRequired: "Je vyzadovano prihlaseni.",
|
|
111
|
+
missingPassword: "Heslo musi mit alespon {min} znaku.",
|
|
112
|
+
},
|
|
113
|
+
};
|
|
126
114
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
await respond(ctx, result.badRequest("protect.missingMode"), {
|
|
116
|
+
i18n: authI18n,
|
|
117
|
+
});
|
|
118
|
+
```
|
|
131
119
|
|
|
132
|
-
|
|
120
|
+
Translation rules:
|
|
133
121
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
- language comes from `getLanguage(ctx)`
|
|
123
|
+
- lookup uses the explicit `i18n` object passed to `respond`
|
|
124
|
+
- nested dot keys are supported
|
|
125
|
+
- metadata is available for `{name}` and `{{ name }}` interpolation
|
|
126
|
+
- the selected language wins when it has the key
|
|
127
|
+
- missing selected-language keys fall back to `en` in the same local bundle
|
|
128
|
+
- missing keys in all bundles return the key itself
|
|
137
129
|
|
|
138
|
-
|
|
130
|
+
There is no global registry, generated dictionary source, or `globalThis` lookup.
|
|
139
131
|
|
|
140
|
-
##
|
|
132
|
+
## Responder
|
|
141
133
|
|
|
142
|
-
|
|
134
|
+
`createResponder(config)` returns a callable responder:
|
|
143
135
|
|
|
144
136
|
```ts
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const presets = mergeResultPresets(DEFAULT_RESULT_PRESETS, {
|
|
152
|
-
error: {
|
|
153
|
-
types: {
|
|
154
|
-
"app.project": {
|
|
155
|
-
statuses: {
|
|
156
|
-
404: {
|
|
157
|
-
title: "Project not found",
|
|
158
|
-
message: "The requested project does not exist.",
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
137
|
+
const respond = createResponder({
|
|
138
|
+
getLanguage: (ctx) => ctx.lang,
|
|
139
|
+
sendJson: (ctx, payload) => ctx.send(payload.status, payload),
|
|
140
|
+
sendText: (ctx, status, text) => ctx.sendText(status, text),
|
|
141
|
+
render: (ctx, model) => ctx.render(model),
|
|
164
142
|
});
|
|
165
143
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
level: "error",
|
|
169
|
-
status: 404,
|
|
170
|
-
type: "app.project.branch",
|
|
144
|
+
await respond(ctx, result.unauthorized("authRequired"), {
|
|
145
|
+
i18n,
|
|
171
146
|
});
|
|
172
147
|
```
|
|
173
148
|
|
|
174
|
-
|
|
149
|
+
Dispatch options:
|
|
150
|
+
|
|
151
|
+
- default or `render: "json"` calls `sendJson(ctx, payload)`
|
|
152
|
+
- `render: "text"` calls `sendText(ctx, status, message)`
|
|
153
|
+
- `render: "auto"` calls `render(ctx, model)` when configured, otherwise JSON
|
|
154
|
+
- `render: true` calls `render(ctx, model)` when configured, otherwise text
|
|
155
|
+
|
|
156
|
+
The package also exports `respond(ctx, result, options, config)` for callers that want a one-shot helper instead of a preconfigured responder.
|
|
175
157
|
|
|
176
158
|
## Tracing Toolkit
|
|
177
159
|
|
|
@@ -179,49 +161,27 @@ Tracing is fully opt-in. Nothing patches the runtime unless you call a tracing A
|
|
|
179
161
|
|
|
180
162
|
Logger delivery uses `@trebired/logger-adapter`, so package code can keep Trebired-style `group/message/metadata` logging while still accepting `console`, pino-style loggers, sink functions, or a custom `loggerAdapter` writer.
|
|
181
163
|
|
|
182
|
-
`createResultTracer()` gives you one runtime with:
|
|
183
|
-
|
|
184
|
-
- failed-result tracing
|
|
185
|
-
- thrown-error tracing
|
|
186
|
-
- rejected-promise tracing
|
|
187
|
-
- nested trace-stack propagation
|
|
188
|
-
- wrapper and proxy caches
|
|
189
|
-
- optional process and module hooks
|
|
190
|
-
|
|
191
164
|
```ts
|
|
192
165
|
import { createResultTracer, result } from "@trebired/result";
|
|
193
166
|
|
|
194
|
-
const records: unknown[] = [];
|
|
195
167
|
const tracer = createResultTracer({
|
|
196
|
-
stackDepth: 10,
|
|
197
168
|
failedResultSeverity: "warn",
|
|
198
169
|
logger: console,
|
|
199
|
-
onTrace(record) {
|
|
200
|
-
records.push(record);
|
|
201
|
-
},
|
|
202
170
|
});
|
|
203
171
|
|
|
204
|
-
tracer.traceFailure(result.notFound("
|
|
172
|
+
tracer.traceFailure(result.notFound("projectMissing"), {
|
|
205
173
|
label: "project.read",
|
|
206
174
|
});
|
|
207
175
|
```
|
|
208
176
|
|
|
209
|
-
|
|
177
|
+
`createResultTracer()` supports:
|
|
210
178
|
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
-
- `compactStack`
|
|
218
|
-
- `failureSite`
|
|
219
|
-
- `argumentPreview`
|
|
220
|
-
- `metadataSummary`
|
|
221
|
-
- `dataSummary`
|
|
222
|
-
- `detailsSummary`
|
|
223
|
-
- `source`
|
|
224
|
-
- `traceStack`
|
|
179
|
+
- failed-result tracing
|
|
180
|
+
- thrown-error tracing
|
|
181
|
+
- rejected-promise tracing
|
|
182
|
+
- nested trace-stack propagation
|
|
183
|
+
- wrapper and proxy caches
|
|
184
|
+
- optional process and module hooks
|
|
225
185
|
|
|
226
186
|
## Wrapping Functions And Promises
|
|
227
187
|
|
|
@@ -234,23 +194,15 @@ const tracer = createResultTracer();
|
|
|
234
194
|
|
|
235
195
|
const saveProject = tracer.wrapFunction(async (input: { id: string }) => {
|
|
236
196
|
if (!input.id) {
|
|
237
|
-
return result.badRequest("
|
|
197
|
+
return result.badRequest("missingId", {
|
|
198
|
+
field: "id",
|
|
199
|
+
});
|
|
238
200
|
}
|
|
239
201
|
|
|
240
|
-
return result.ok("
|
|
202
|
+
return result.ok("saved");
|
|
241
203
|
}, {
|
|
242
204
|
label: "project.save",
|
|
243
205
|
});
|
|
244
|
-
|
|
245
|
-
const remoteSync = tracer.wrapPromise(fetch("https://example.test").then((res) => {
|
|
246
|
-
if (!res.ok) {
|
|
247
|
-
throw new Error(`Remote sync failed: ${res.status}`);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return res;
|
|
251
|
-
}), {
|
|
252
|
-
label: "project.sync",
|
|
253
|
-
});
|
|
254
206
|
```
|
|
255
207
|
|
|
256
208
|
Wrappers preserve original behavior:
|
|
@@ -261,128 +213,34 @@ Wrappers preserve original behavior:
|
|
|
261
213
|
- thrown and rejected failures are traced
|
|
262
214
|
- the same function or promise is not wrapped twice inside the same tracer runtime
|
|
263
215
|
|
|
264
|
-
##
|
|
265
|
-
|
|
266
|
-
If a module exports a plain object tree, you can instrument it without hand-wrapping every method:
|
|
267
|
-
|
|
268
|
-
```ts
|
|
269
|
-
import { createResultTracer } from "@trebired/result";
|
|
270
|
-
import * as handlers from "./handlers.js";
|
|
271
|
-
|
|
272
|
-
const tracer = createResultTracer({
|
|
273
|
-
objectDepth: 3,
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const instrumented = tracer.instrumentExports(handlers, {
|
|
277
|
-
label: "handlers",
|
|
278
|
-
include: "invoice",
|
|
279
|
-
});
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Instrumentation:
|
|
283
|
-
|
|
284
|
-
- wraps callable exports
|
|
285
|
-
- descends into plain object trees up to the configured depth
|
|
286
|
-
- leaves symbol-based access alone
|
|
287
|
-
- caches proxies and wrappers so the same target is reused
|
|
288
|
-
|
|
289
|
-
## Process And Module Hooks
|
|
290
|
-
|
|
291
|
-
Advanced runtime hooks are available when you explicitly opt in.
|
|
292
|
-
|
|
293
|
-
Process hooks:
|
|
294
|
-
|
|
295
|
-
```ts
|
|
296
|
-
import { installResultProcessHooks } from "@trebired/result";
|
|
297
|
-
|
|
298
|
-
const hooks = installResultProcessHooks({
|
|
299
|
-
logger: console,
|
|
300
|
-
exitOnUncaughtException: false,
|
|
301
|
-
exitOnUnhandledRejection: false,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
hooks.uninstall();
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Module hooks:
|
|
308
|
-
|
|
309
|
-
```ts
|
|
310
|
-
import { installResultModuleHooks } from "@trebired/result";
|
|
311
|
-
|
|
312
|
-
const hooks = installResultModuleHooks({
|
|
313
|
-
include: [/services/, /workers/],
|
|
314
|
-
labelPrefix: "module",
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
hooks.uninstall();
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
Module instrumentation only works in runtimes that expose a CommonJS-style loader with `_load` support. It is meant for targeted observability, not for blanket patching in every environment.
|
|
321
|
-
|
|
322
|
-
## Boot Helper
|
|
216
|
+
## Presets
|
|
323
217
|
|
|
324
|
-
|
|
218
|
+
The package still exports generic preset helpers for callers that want shared status/title defaults:
|
|
325
219
|
|
|
326
220
|
```ts
|
|
327
|
-
import {
|
|
221
|
+
import {
|
|
222
|
+
DEFAULT_RESULT_PRESETS,
|
|
223
|
+
mergeResultPresets,
|
|
224
|
+
resolveResultPreset,
|
|
225
|
+
} from "@trebired/result";
|
|
328
226
|
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
227
|
+
const presets = mergeResultPresets(DEFAULT_RESULT_PRESETS, {
|
|
228
|
+
error: {
|
|
229
|
+
statuses: {
|
|
230
|
+
404: {
|
|
231
|
+
title: "Missing",
|
|
232
|
+
},
|
|
233
|
+
},
|
|
333
234
|
},
|
|
334
235
|
});
|
|
335
236
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
237
|
+
const preset = resolveResultPreset({
|
|
238
|
+
presets,
|
|
239
|
+
level: "error",
|
|
240
|
+
status: 404,
|
|
340
241
|
});
|
|
341
242
|
```
|
|
342
243
|
|
|
343
|
-
## Configuration
|
|
344
|
-
|
|
345
|
-
Tracing configuration lets hosts control:
|
|
346
|
-
|
|
347
|
-
- `enabled`
|
|
348
|
-
- `logger`
|
|
349
|
-
- `loggerAdapter`
|
|
350
|
-
- `onTrace`
|
|
351
|
-
- `include`
|
|
352
|
-
- `exclude`
|
|
353
|
-
- `objectDepth`
|
|
354
|
-
- `stackDepth`
|
|
355
|
-
- `argumentPreview`
|
|
356
|
-
- `summaryPreview`
|
|
357
|
-
- `failedResultSeverity`
|
|
358
|
-
|
|
359
|
-
Wrapper and hook helpers also accept:
|
|
360
|
-
|
|
361
|
-
- `label`
|
|
362
|
-
- `source`
|
|
363
|
-
- `tracer`
|
|
364
|
-
- per-call `include` and `exclude`
|
|
365
|
-
- process exit policies
|
|
366
|
-
- module label prefixes and traversal depth
|
|
367
|
-
|
|
368
|
-
## Safe Defaults
|
|
369
|
-
|
|
370
|
-
Safe by default:
|
|
371
|
-
|
|
372
|
-
- result builders
|
|
373
|
-
- responder factory
|
|
374
|
-
- preset resolution
|
|
375
|
-
- manual tracing with `traceFailure`, `traceResult`, or `traceError`
|
|
376
|
-
- function and promise wrapping
|
|
377
|
-
|
|
378
|
-
More invasive surfaces:
|
|
379
|
-
|
|
380
|
-
- export/object instrumentation
|
|
381
|
-
- process hooks
|
|
382
|
-
- module hooks
|
|
383
|
-
|
|
384
|
-
Those advanced surfaces are still opt-in and can be turned off per host.
|
|
385
|
-
|
|
386
244
|
## Public API
|
|
387
245
|
|
|
388
246
|
Runtime exports:
|
|
@@ -397,7 +255,10 @@ Runtime exports:
|
|
|
397
255
|
- `notFound`
|
|
398
256
|
- `conflict`
|
|
399
257
|
- `internal`
|
|
400
|
-
- `
|
|
258
|
+
- `createResponder`
|
|
259
|
+
- `respond`
|
|
260
|
+
- `shapeResultPayload`
|
|
261
|
+
- `translateMessage`
|
|
401
262
|
- `createResultTracer`
|
|
402
263
|
- `bootResultTracing`
|
|
403
264
|
- `wrapResultFunction`
|
|
@@ -422,4 +283,4 @@ Runtime exports:
|
|
|
422
283
|
- `previewValue`
|
|
423
284
|
- `summarizeFailedResult`
|
|
424
285
|
|
|
425
|
-
Type exports include
|
|
286
|
+
Type exports include result, responder, i18n, preset, and tracing types used by those APIs.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { badRequest, conflict, error, forbidden, internal, noop, notFound, ok, result, unauthorized, } from "./result.js";
|
|
2
|
-
export {
|
|
2
|
+
export { createResponder, respond, } from "./responder.js";
|
|
3
|
+
export { shapeResultPayload, translateMessage, } from "./responder_support.js";
|
|
3
4
|
export { bootResultTracing, createResultTracer, } from "./tracer.js";
|
|
4
5
|
export { instrumentResultExports, } from "./instrument_result_exports.js";
|
|
5
6
|
export { installResultModuleHooks, } from "./module_hooks.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,EACF,MAAM,EACN,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,EACF,MAAM,EACN,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,eAAe,EACf,OAAO,GACR,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,wBAAwB,EACxB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,mBAAmB,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { badRequest, conflict, error, forbidden, internal, noop, notFound, ok, result, unauthorized, } from "./result.js";
|
|
2
|
-
export {
|
|
2
|
+
export { createResponder, respond, } from "./responder.js";
|
|
3
|
+
export { shapeResultPayload, translateMessage, } from "./responder_support.js";
|
|
3
4
|
export { bootResultTracing, createResultTracer, } from "./tracer.js";
|
|
4
5
|
export { instrumentResultExports, } from "./instrument_result_exports.js";
|
|
5
6
|
export { installResultModuleHooks, } from "./module_hooks.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,EACF,MAAM,EACN,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,EACF,MAAM,EACN,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,eAAe,EACf,OAAO,GACR,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,wBAAwB,EACxB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,GAClB,MAAM,0BAA0B,CAAC"}
|
package/dist/responder.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ResultResponder, ResultResponderConfig } from "./types.js";
|
|
2
|
-
declare function
|
|
3
|
-
|
|
1
|
+
import type { ResultLike, ResultResponder, ResultResponderConfig, ResultRespondOptions } from "./types.js";
|
|
2
|
+
declare function createResponder<Ctx = unknown, TType extends string = string>(config: ResultResponderConfig<Ctx, TType>): ResultResponder<Ctx, TType>;
|
|
3
|
+
declare function respond<Ctx = unknown, TType extends string = string>(context: Ctx, result: ResultLike | null | undefined, options: ResultRespondOptions<TType>, config: ResultResponderConfig<Ctx, TType>): unknown;
|
|
4
|
+
export { createResponder, respond, };
|
|
4
5
|
//# sourceMappingURL=responder.d.ts.map
|
package/dist/responder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responder.d.ts","sourceRoot":"","sources":["../../src/responder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"responder.d.ts","sourceRoot":"","sources":["../../src/responder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,QAAQ,CAAC;AAEhB,iBAAS,eAAe,CAAC,GAAG,GAAG,OAAO,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,MAAM,EAAE,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,GACxC,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAQ7B;AAED,iBAAS,OAAO,CAAC,GAAG,GAAG,OAAO,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,EAC3D,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACrC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACpC,MAAM,EAAE,qBAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,WAuB1C;AAsBD,OAAO,EACL,eAAe,EACf,OAAO,GACR,CAAC"}
|