@xrystal/dto 26.6.27-v14 → 26.6.27-v15
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 +10 -10
- package/dist/adapters/elysia.cjs +9 -27
- package/dist/adapters/elysia.js +10 -27
- package/dist/adapters/express.cjs +9 -19
- package/dist/adapters/express.js +10 -19
- package/dist/adapters/fetch.cjs +9 -15
- package/dist/adapters/fetch.js +10 -15
- package/dist/adapters/node.cjs +9 -19
- package/dist/adapters/node.js +10 -19
- package/dist/adapters/socketio.cjs +9 -21
- package/dist/adapters/socketio.js +10 -21
- package/dist/adapters/websocket.cjs +9 -19
- package/dist/adapters/websocket.js +10 -19
- package/dist/dto/adapters/elysia.d.ts +1 -1
- package/dist/dto/adapters/express.d.ts +1 -1
- package/dist/dto/adapters/fetch.d.ts +1 -1
- package/dist/dto/adapters/http.d.ts +5 -86
- package/dist/dto/adapters/node.d.ts +1 -1
- package/dist/dto/adapters/realtime.d.ts +3 -17
- package/dist/dto/adapters/socketio.d.ts +1 -1
- package/dist/dto/adapters/websocket.d.ts +1 -1
- package/dist/dto/index.cjs +9 -17
- package/dist/dto/index.js +9 -17
- package/dist/dto/response/index.cjs +9 -9
- package/dist/dto/response/index.js +9 -9
- package/dist/dto/runtime/index.cjs +9 -17
- package/dist/dto/runtime/index.d.ts +2 -2
- package/dist/dto/runtime/index.js +9 -17
- package/dist/dto/send/builder.d.ts +4 -4
- package/dist/dto/send/transport.d.ts +3 -3
- package/dist/index.cjs +9 -75
- package/dist/index.d.ts +7 -7
- package/dist/index.js +10 -70
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,7 +159,7 @@ builder.as.ok() → .build() → FinalResult
|
|
|
159
159
|
→ res.json / Response / ws.send / …
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
Core dispatch lives in `dto/send/transport.ts`. Adapters
|
|
162
|
+
Core dispatch lives in `dto/send/transport.ts`. Adapters attach a **send sink** to each builder via `createBuilderRuntime()`. The sink is only **invoked** on `.send()` — `.build()` never touches it.
|
|
163
163
|
|
|
164
164
|
### Runtime map
|
|
165
165
|
|
|
@@ -212,12 +212,12 @@ Subpath imports (tree-shake friendly):
|
|
|
212
212
|
|
|
213
213
|
| Import | Contents |
|
|
214
214
|
|--------|----------|
|
|
215
|
-
| `@xrystal/dto/express` | `ExpressAdapter`, `
|
|
216
|
-
| `@xrystal/dto/node` | `NodeAdapter`, `
|
|
217
|
-
| `@xrystal/dto/fetch` | `FetchAdapter`, `
|
|
218
|
-
| `@xrystal/dto/elysia` | `ElysiaAdapter`, `
|
|
219
|
-
| `@xrystal/dto/websocket` | `WebSocketAdapter`, `
|
|
220
|
-
| `@xrystal/dto/socketio` | `SocketIoAdapter`, `
|
|
215
|
+
| `@xrystal/dto/express` | `ExpressAdapter`, `expressSink`, `expressMiddleware` |
|
|
216
|
+
| `@xrystal/dto/node` | `NodeAdapter`, `nodeSink`, `nodeMiddleware` |
|
|
217
|
+
| `@xrystal/dto/fetch` | `FetchAdapter`, `fetchSink`, `createFetchDerive` |
|
|
218
|
+
| `@xrystal/dto/elysia` | `ElysiaAdapter`, `elysiaSink`, `createElysiaDerive` |
|
|
219
|
+
| `@xrystal/dto/websocket` | `WebSocketAdapter`, `websocketSink` |
|
|
220
|
+
| `@xrystal/dto/socketio` | `SocketIoAdapter`, `socketIoSink` |
|
|
221
221
|
|
|
222
222
|
---
|
|
223
223
|
|
|
@@ -261,7 +261,7 @@ Kütüphanenin **iki işi** var; mimari buna göre bölündü:
|
|
|
261
261
|
| **Custom framework (Fastify vb.)** | `createBuilderRuntime(expressSink(res), …)` veya kendi sink'in |
|
|
262
262
|
| **WS + HTTP aynı app'te** | Her transport için bir kez wire: `.express()` + `.websocket()` |
|
|
263
263
|
|
|
264
|
-
**Özet:** Handler'dan client'a cevap gönderiyorsan bir adapter
|
|
264
|
+
**Özet:** Handler'dan client'a cevap gönderiyorsan bir adapter şart — ama çoğu app'te `new DTO().express()` tek satır yeter. Adapter request başında sink'i builder'a **takır**; sink yalnızca `.send()` çağrıldığında çalışır. `.build()` saf şema döner, transport'a dokunmaz.
|
|
265
265
|
|
|
266
266
|
| Layer | Import eder misin? | Ne yapar |
|
|
267
267
|
|-------|-------------------|----------|
|
|
@@ -553,11 +553,11 @@ See source `dto/send/presets.ts` for the full list.
|
|
|
553
553
|
|
|
554
554
|
- **Fetch API adapter** — `runtime.fetch()`, `runtime.forRequest(request)`, `@xrystal/dto/fetch`. Returns Web `Response` from `.send()`. Works with Workers, Hono, Bun.serve, Next.js route handlers.
|
|
555
555
|
- **Core transport layer** — `dto/send/transport.ts` centralises headers, cookies, JSON body, Fetch `Response`, and realtime wire envelope.
|
|
556
|
-
- **
|
|
556
|
+
- **Send sinks** — `expressSink`, `fetchSink`, … replace dispatcher classes; attached per request, invoked only on `.send()`.
|
|
557
557
|
|
|
558
558
|
### Fixes & consistency
|
|
559
559
|
|
|
560
|
-
- **Elysia** —
|
|
560
|
+
- **Elysia** — `ElysiaAdapter.plugin()` + `elysiaSink(set)` (same pattern as Express/Node/Fetch).
|
|
561
561
|
- **Node http** — `Set-Cookie` support added (was Express-only via `res.cookie`).
|
|
562
562
|
- **Dispatch hooks** — `beforeDispatch` / `afterDispatch` plugins run on `.send()` only, not on `.build()`.
|
|
563
563
|
|
package/dist/adapters/elysia.cjs
CHANGED
|
@@ -412,13 +412,13 @@ function applyElysiaTransport(result, sink) {
|
|
|
412
412
|
}
|
|
413
413
|
return null;
|
|
414
414
|
}
|
|
415
|
-
function dispatchResult(result,
|
|
416
|
-
if (!
|
|
415
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
416
|
+
if (!sink) {
|
|
417
417
|
return result;
|
|
418
418
|
}
|
|
419
419
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
420
420
|
emitHook("before_dispatch", next);
|
|
421
|
-
const dispatched =
|
|
421
|
+
const dispatched = sink.dispatch(next);
|
|
422
422
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
423
423
|
emitHook("after_dispatch", next);
|
|
424
424
|
return dispatched ?? next;
|
|
@@ -561,7 +561,7 @@ var ResponsePresets = class {
|
|
|
561
561
|
|
|
562
562
|
// src/dto/send/builder.ts
|
|
563
563
|
var Builder = class {
|
|
564
|
-
|
|
564
|
+
sink;
|
|
565
565
|
options;
|
|
566
566
|
context;
|
|
567
567
|
plugins;
|
|
@@ -570,8 +570,8 @@ var Builder = class {
|
|
|
570
570
|
_headers = {};
|
|
571
571
|
_cookies = [];
|
|
572
572
|
_presets;
|
|
573
|
-
constructor(
|
|
574
|
-
this.
|
|
573
|
+
constructor(sink, options = {}, context) {
|
|
574
|
+
this.sink = sink;
|
|
575
575
|
this.options = resolveBuilderConfig(options);
|
|
576
576
|
this.context = context;
|
|
577
577
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -710,7 +710,7 @@ var Builder = class {
|
|
|
710
710
|
const result = this.build();
|
|
711
711
|
return dispatchResult(
|
|
712
712
|
result,
|
|
713
|
-
this.
|
|
713
|
+
this.sink,
|
|
714
714
|
this.plugins,
|
|
715
715
|
pluginCtx,
|
|
716
716
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -741,8 +741,8 @@ var Builder = class {
|
|
|
741
741
|
hooks.emit(event, structuredClone(result));
|
|
742
742
|
}
|
|
743
743
|
};
|
|
744
|
-
function createBuilderProxy(
|
|
745
|
-
const instance = new Builder(
|
|
744
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
745
|
+
const instance = new Builder(sink, options, context);
|
|
746
746
|
return new Proxy(instance, {
|
|
747
747
|
get(target, prop, receiver) {
|
|
748
748
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -775,15 +775,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
775
775
|
function elysiaSink(set) {
|
|
776
776
|
return { dispatch: (result) => applyElysiaTransport(result, set) };
|
|
777
777
|
}
|
|
778
|
-
var ElysiaDispatcher = class {
|
|
779
|
-
sink;
|
|
780
|
-
constructor(sink) {
|
|
781
|
-
this.sink = sink;
|
|
782
|
-
}
|
|
783
|
-
dispatch(result) {
|
|
784
|
-
return applyElysiaTransport(result, this.sink);
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
778
|
function createElysiaDerive(options = {}) {
|
|
788
779
|
return ({ request, set }) => {
|
|
789
780
|
const context = ContextFactory.create(
|
|
@@ -817,14 +808,6 @@ var ElysiaAdapter = class {
|
|
|
817
808
|
})
|
|
818
809
|
);
|
|
819
810
|
}
|
|
820
|
-
/** @deprecated Use {@link plugin} */
|
|
821
|
-
middleware() {
|
|
822
|
-
return this.plugin();
|
|
823
|
-
}
|
|
824
|
-
/** @deprecated Use {@link plugin} */
|
|
825
|
-
handler() {
|
|
826
|
-
return this.plugin();
|
|
827
|
-
}
|
|
828
811
|
};
|
|
829
812
|
function elysiaMiddleware(options = {}) {
|
|
830
813
|
return new ElysiaAdapter(options).plugin();
|
|
@@ -838,7 +821,6 @@ function headersToRecord(headers) {
|
|
|
838
821
|
}
|
|
839
822
|
|
|
840
823
|
exports.ElysiaAdapter = ElysiaAdapter;
|
|
841
|
-
exports.ElysiaDispatcher = ElysiaDispatcher;
|
|
842
824
|
exports.createElysiaDerive = createElysiaDerive;
|
|
843
825
|
exports.elysiaMiddleware = elysiaMiddleware;
|
|
844
826
|
exports.elysiaSink = elysiaSink;
|
package/dist/adapters/elysia.js
CHANGED
|
@@ -410,13 +410,13 @@ function applyElysiaTransport(result, sink) {
|
|
|
410
410
|
}
|
|
411
411
|
return null;
|
|
412
412
|
}
|
|
413
|
-
function dispatchResult(result,
|
|
414
|
-
if (!
|
|
413
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
414
|
+
if (!sink) {
|
|
415
415
|
return result;
|
|
416
416
|
}
|
|
417
417
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
418
418
|
emitHook("before_dispatch", next);
|
|
419
|
-
const dispatched =
|
|
419
|
+
const dispatched = sink.dispatch(next);
|
|
420
420
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
421
421
|
emitHook("after_dispatch", next);
|
|
422
422
|
return dispatched ?? next;
|
|
@@ -559,7 +559,7 @@ var ResponsePresets = class {
|
|
|
559
559
|
|
|
560
560
|
// src/dto/send/builder.ts
|
|
561
561
|
var Builder = class {
|
|
562
|
-
|
|
562
|
+
sink;
|
|
563
563
|
options;
|
|
564
564
|
context;
|
|
565
565
|
plugins;
|
|
@@ -568,8 +568,8 @@ var Builder = class {
|
|
|
568
568
|
_headers = {};
|
|
569
569
|
_cookies = [];
|
|
570
570
|
_presets;
|
|
571
|
-
constructor(
|
|
572
|
-
this.
|
|
571
|
+
constructor(sink, options = {}, context) {
|
|
572
|
+
this.sink = sink;
|
|
573
573
|
this.options = resolveBuilderConfig(options);
|
|
574
574
|
this.context = context;
|
|
575
575
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -708,7 +708,7 @@ var Builder = class {
|
|
|
708
708
|
const result = this.build();
|
|
709
709
|
return dispatchResult(
|
|
710
710
|
result,
|
|
711
|
-
this.
|
|
711
|
+
this.sink,
|
|
712
712
|
this.plugins,
|
|
713
713
|
pluginCtx,
|
|
714
714
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -739,8 +739,8 @@ var Builder = class {
|
|
|
739
739
|
hooks.emit(event, structuredClone(result));
|
|
740
740
|
}
|
|
741
741
|
};
|
|
742
|
-
function createBuilderProxy(
|
|
743
|
-
const instance = new Builder(
|
|
742
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
743
|
+
const instance = new Builder(sink, options, context);
|
|
744
744
|
return new Proxy(instance, {
|
|
745
745
|
get(target, prop, receiver) {
|
|
746
746
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -773,15 +773,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
773
773
|
function elysiaSink(set) {
|
|
774
774
|
return { dispatch: (result) => applyElysiaTransport(result, set) };
|
|
775
775
|
}
|
|
776
|
-
var ElysiaDispatcher = class {
|
|
777
|
-
sink;
|
|
778
|
-
constructor(sink) {
|
|
779
|
-
this.sink = sink;
|
|
780
|
-
}
|
|
781
|
-
dispatch(result) {
|
|
782
|
-
return applyElysiaTransport(result, this.sink);
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
776
|
function createElysiaDerive(options = {}) {
|
|
786
777
|
return ({ request, set }) => {
|
|
787
778
|
const context = ContextFactory.create(
|
|
@@ -815,14 +806,6 @@ var ElysiaAdapter = class {
|
|
|
815
806
|
})
|
|
816
807
|
);
|
|
817
808
|
}
|
|
818
|
-
/** @deprecated Use {@link plugin} */
|
|
819
|
-
middleware() {
|
|
820
|
-
return this.plugin();
|
|
821
|
-
}
|
|
822
|
-
/** @deprecated Use {@link plugin} */
|
|
823
|
-
handler() {
|
|
824
|
-
return this.plugin();
|
|
825
|
-
}
|
|
826
809
|
};
|
|
827
810
|
function elysiaMiddleware(options = {}) {
|
|
828
811
|
return new ElysiaAdapter(options).plugin();
|
|
@@ -835,4 +818,4 @@ function headersToRecord(headers) {
|
|
|
835
818
|
return record;
|
|
836
819
|
}
|
|
837
820
|
|
|
838
|
-
export { ElysiaAdapter,
|
|
821
|
+
export { ElysiaAdapter, createElysiaDerive, elysiaMiddleware, elysiaSink };
|
|
@@ -396,13 +396,13 @@ function dispatchExpressResponse(result, res) {
|
|
|
396
396
|
}
|
|
397
397
|
return result;
|
|
398
398
|
}
|
|
399
|
-
function dispatchResult(result,
|
|
400
|
-
if (!
|
|
399
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
400
|
+
if (!sink) {
|
|
401
401
|
return result;
|
|
402
402
|
}
|
|
403
403
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
404
404
|
emitHook("before_dispatch", next);
|
|
405
|
-
const dispatched =
|
|
405
|
+
const dispatched = sink.dispatch(next);
|
|
406
406
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
407
407
|
emitHook("after_dispatch", next);
|
|
408
408
|
return dispatched ?? next;
|
|
@@ -545,7 +545,7 @@ var ResponsePresets = class {
|
|
|
545
545
|
|
|
546
546
|
// src/dto/send/builder.ts
|
|
547
547
|
var Builder = class {
|
|
548
|
-
|
|
548
|
+
sink;
|
|
549
549
|
options;
|
|
550
550
|
context;
|
|
551
551
|
plugins;
|
|
@@ -554,8 +554,8 @@ var Builder = class {
|
|
|
554
554
|
_headers = {};
|
|
555
555
|
_cookies = [];
|
|
556
556
|
_presets;
|
|
557
|
-
constructor(
|
|
558
|
-
this.
|
|
557
|
+
constructor(sink, options = {}, context) {
|
|
558
|
+
this.sink = sink;
|
|
559
559
|
this.options = resolveBuilderConfig(options);
|
|
560
560
|
this.context = context;
|
|
561
561
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -694,7 +694,7 @@ var Builder = class {
|
|
|
694
694
|
const result = this.build();
|
|
695
695
|
return dispatchResult(
|
|
696
696
|
result,
|
|
697
|
-
this.
|
|
697
|
+
this.sink,
|
|
698
698
|
this.plugins,
|
|
699
699
|
pluginCtx,
|
|
700
700
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -725,8 +725,8 @@ var Builder = class {
|
|
|
725
725
|
hooks.emit(event, structuredClone(result));
|
|
726
726
|
}
|
|
727
727
|
};
|
|
728
|
-
function createBuilderProxy(
|
|
729
|
-
const instance = new Builder(
|
|
728
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
729
|
+
const instance = new Builder(sink, options, context);
|
|
730
730
|
return new Proxy(instance, {
|
|
731
731
|
get(target, prop, receiver) {
|
|
732
732
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -759,15 +759,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
759
759
|
function expressSink(res) {
|
|
760
760
|
return { dispatch: (result) => dispatchExpressResponse(result, res) };
|
|
761
761
|
}
|
|
762
|
-
var ExpressDispatcher = class {
|
|
763
|
-
res;
|
|
764
|
-
constructor(res) {
|
|
765
|
-
this.res = res;
|
|
766
|
-
}
|
|
767
|
-
dispatch(result) {
|
|
768
|
-
return dispatchExpressResponse(result, this.res);
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
762
|
var ExpressAdapter = class {
|
|
772
763
|
constructor(options = {}) {
|
|
773
764
|
this.options = options;
|
|
@@ -796,6 +787,5 @@ function applyDefaultHeaders(options, setHeader) {
|
|
|
796
787
|
}
|
|
797
788
|
|
|
798
789
|
exports.ExpressAdapter = ExpressAdapter;
|
|
799
|
-
exports.ExpressDispatcher = ExpressDispatcher;
|
|
800
790
|
exports.expressMiddleware = expressMiddleware;
|
|
801
791
|
exports.expressSink = expressSink;
|
package/dist/adapters/express.js
CHANGED
|
@@ -394,13 +394,13 @@ function dispatchExpressResponse(result, res) {
|
|
|
394
394
|
}
|
|
395
395
|
return result;
|
|
396
396
|
}
|
|
397
|
-
function dispatchResult(result,
|
|
398
|
-
if (!
|
|
397
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
398
|
+
if (!sink) {
|
|
399
399
|
return result;
|
|
400
400
|
}
|
|
401
401
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
402
402
|
emitHook("before_dispatch", next);
|
|
403
|
-
const dispatched =
|
|
403
|
+
const dispatched = sink.dispatch(next);
|
|
404
404
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
405
405
|
emitHook("after_dispatch", next);
|
|
406
406
|
return dispatched ?? next;
|
|
@@ -543,7 +543,7 @@ var ResponsePresets = class {
|
|
|
543
543
|
|
|
544
544
|
// src/dto/send/builder.ts
|
|
545
545
|
var Builder = class {
|
|
546
|
-
|
|
546
|
+
sink;
|
|
547
547
|
options;
|
|
548
548
|
context;
|
|
549
549
|
plugins;
|
|
@@ -552,8 +552,8 @@ var Builder = class {
|
|
|
552
552
|
_headers = {};
|
|
553
553
|
_cookies = [];
|
|
554
554
|
_presets;
|
|
555
|
-
constructor(
|
|
556
|
-
this.
|
|
555
|
+
constructor(sink, options = {}, context) {
|
|
556
|
+
this.sink = sink;
|
|
557
557
|
this.options = resolveBuilderConfig(options);
|
|
558
558
|
this.context = context;
|
|
559
559
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -692,7 +692,7 @@ var Builder = class {
|
|
|
692
692
|
const result = this.build();
|
|
693
693
|
return dispatchResult(
|
|
694
694
|
result,
|
|
695
|
-
this.
|
|
695
|
+
this.sink,
|
|
696
696
|
this.plugins,
|
|
697
697
|
pluginCtx,
|
|
698
698
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -723,8 +723,8 @@ var Builder = class {
|
|
|
723
723
|
hooks.emit(event, structuredClone(result));
|
|
724
724
|
}
|
|
725
725
|
};
|
|
726
|
-
function createBuilderProxy(
|
|
727
|
-
const instance = new Builder(
|
|
726
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
727
|
+
const instance = new Builder(sink, options, context);
|
|
728
728
|
return new Proxy(instance, {
|
|
729
729
|
get(target, prop, receiver) {
|
|
730
730
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -757,15 +757,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
757
757
|
function expressSink(res) {
|
|
758
758
|
return { dispatch: (result) => dispatchExpressResponse(result, res) };
|
|
759
759
|
}
|
|
760
|
-
var ExpressDispatcher = class {
|
|
761
|
-
res;
|
|
762
|
-
constructor(res) {
|
|
763
|
-
this.res = res;
|
|
764
|
-
}
|
|
765
|
-
dispatch(result) {
|
|
766
|
-
return dispatchExpressResponse(result, this.res);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
760
|
var ExpressAdapter = class {
|
|
770
761
|
constructor(options = {}) {
|
|
771
762
|
this.options = options;
|
|
@@ -793,4 +784,4 @@ function applyDefaultHeaders(options, setHeader) {
|
|
|
793
784
|
}
|
|
794
785
|
}
|
|
795
786
|
|
|
796
|
-
export { ExpressAdapter,
|
|
787
|
+
export { ExpressAdapter, expressMiddleware, expressSink };
|
package/dist/adapters/fetch.cjs
CHANGED
|
@@ -415,13 +415,13 @@ function toFetchResponse(result) {
|
|
|
415
415
|
headers
|
|
416
416
|
});
|
|
417
417
|
}
|
|
418
|
-
function dispatchResult(result,
|
|
419
|
-
if (!
|
|
418
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
419
|
+
if (!sink) {
|
|
420
420
|
return result;
|
|
421
421
|
}
|
|
422
422
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
423
423
|
emitHook("before_dispatch", next);
|
|
424
|
-
const dispatched =
|
|
424
|
+
const dispatched = sink.dispatch(next);
|
|
425
425
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
426
426
|
emitHook("after_dispatch", next);
|
|
427
427
|
return dispatched ?? next;
|
|
@@ -564,7 +564,7 @@ var ResponsePresets = class {
|
|
|
564
564
|
|
|
565
565
|
// src/dto/send/builder.ts
|
|
566
566
|
var Builder = class {
|
|
567
|
-
|
|
567
|
+
sink;
|
|
568
568
|
options;
|
|
569
569
|
context;
|
|
570
570
|
plugins;
|
|
@@ -573,8 +573,8 @@ var Builder = class {
|
|
|
573
573
|
_headers = {};
|
|
574
574
|
_cookies = [];
|
|
575
575
|
_presets;
|
|
576
|
-
constructor(
|
|
577
|
-
this.
|
|
576
|
+
constructor(sink, options = {}, context) {
|
|
577
|
+
this.sink = sink;
|
|
578
578
|
this.options = resolveBuilderConfig(options);
|
|
579
579
|
this.context = context;
|
|
580
580
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -713,7 +713,7 @@ var Builder = class {
|
|
|
713
713
|
const result = this.build();
|
|
714
714
|
return dispatchResult(
|
|
715
715
|
result,
|
|
716
|
-
this.
|
|
716
|
+
this.sink,
|
|
717
717
|
this.plugins,
|
|
718
718
|
pluginCtx,
|
|
719
719
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -744,8 +744,8 @@ var Builder = class {
|
|
|
744
744
|
hooks.emit(event, structuredClone(result));
|
|
745
745
|
}
|
|
746
746
|
};
|
|
747
|
-
function createBuilderProxy(
|
|
748
|
-
const instance = new Builder(
|
|
747
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
748
|
+
const instance = new Builder(sink, options, context);
|
|
749
749
|
return new Proxy(instance, {
|
|
750
750
|
get(target, prop, receiver) {
|
|
751
751
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -776,11 +776,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
776
776
|
|
|
777
777
|
// src/dto/adapters/http.ts
|
|
778
778
|
var fetchSink = { dispatch: (result) => toFetchResponse(result) };
|
|
779
|
-
var FetchDispatcher = class {
|
|
780
|
-
dispatch(result) {
|
|
781
|
-
return toFetchResponse(result);
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
779
|
function createFetchDerive(options = {}) {
|
|
785
780
|
return (request) => {
|
|
786
781
|
const context = ContextFactory.create(
|
|
@@ -826,7 +821,6 @@ function headersToRecord(headers) {
|
|
|
826
821
|
}
|
|
827
822
|
|
|
828
823
|
exports.FetchAdapter = FetchAdapter;
|
|
829
|
-
exports.FetchDispatcher = FetchDispatcher;
|
|
830
824
|
exports.createFetchDerive = createFetchDerive;
|
|
831
825
|
exports.fetchDerive = fetchDerive;
|
|
832
826
|
exports.fetchSink = fetchSink;
|
package/dist/adapters/fetch.js
CHANGED
|
@@ -413,13 +413,13 @@ function toFetchResponse(result) {
|
|
|
413
413
|
headers
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
|
-
function dispatchResult(result,
|
|
417
|
-
if (!
|
|
416
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
417
|
+
if (!sink) {
|
|
418
418
|
return result;
|
|
419
419
|
}
|
|
420
420
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
421
421
|
emitHook("before_dispatch", next);
|
|
422
|
-
const dispatched =
|
|
422
|
+
const dispatched = sink.dispatch(next);
|
|
423
423
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
424
424
|
emitHook("after_dispatch", next);
|
|
425
425
|
return dispatched ?? next;
|
|
@@ -562,7 +562,7 @@ var ResponsePresets = class {
|
|
|
562
562
|
|
|
563
563
|
// src/dto/send/builder.ts
|
|
564
564
|
var Builder = class {
|
|
565
|
-
|
|
565
|
+
sink;
|
|
566
566
|
options;
|
|
567
567
|
context;
|
|
568
568
|
plugins;
|
|
@@ -571,8 +571,8 @@ var Builder = class {
|
|
|
571
571
|
_headers = {};
|
|
572
572
|
_cookies = [];
|
|
573
573
|
_presets;
|
|
574
|
-
constructor(
|
|
575
|
-
this.
|
|
574
|
+
constructor(sink, options = {}, context) {
|
|
575
|
+
this.sink = sink;
|
|
576
576
|
this.options = resolveBuilderConfig(options);
|
|
577
577
|
this.context = context;
|
|
578
578
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -711,7 +711,7 @@ var Builder = class {
|
|
|
711
711
|
const result = this.build();
|
|
712
712
|
return dispatchResult(
|
|
713
713
|
result,
|
|
714
|
-
this.
|
|
714
|
+
this.sink,
|
|
715
715
|
this.plugins,
|
|
716
716
|
pluginCtx,
|
|
717
717
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -742,8 +742,8 @@ var Builder = class {
|
|
|
742
742
|
hooks.emit(event, structuredClone(result));
|
|
743
743
|
}
|
|
744
744
|
};
|
|
745
|
-
function createBuilderProxy(
|
|
746
|
-
const instance = new Builder(
|
|
745
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
746
|
+
const instance = new Builder(sink, options, context);
|
|
747
747
|
return new Proxy(instance, {
|
|
748
748
|
get(target, prop, receiver) {
|
|
749
749
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -774,11 +774,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
774
774
|
|
|
775
775
|
// src/dto/adapters/http.ts
|
|
776
776
|
var fetchSink = { dispatch: (result) => toFetchResponse(result) };
|
|
777
|
-
var FetchDispatcher = class {
|
|
778
|
-
dispatch(result) {
|
|
779
|
-
return toFetchResponse(result);
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
777
|
function createFetchDerive(options = {}) {
|
|
783
778
|
return (request) => {
|
|
784
779
|
const context = ContextFactory.create(
|
|
@@ -823,4 +818,4 @@ function headersToRecord(headers) {
|
|
|
823
818
|
return record;
|
|
824
819
|
}
|
|
825
820
|
|
|
826
|
-
export { FetchAdapter,
|
|
821
|
+
export { FetchAdapter, createFetchDerive, fetchDerive, fetchSink };
|
package/dist/adapters/node.cjs
CHANGED
|
@@ -414,13 +414,13 @@ function dispatchNodeResponse(result, res) {
|
|
|
414
414
|
res.end(encodeResponseBody(result));
|
|
415
415
|
return result;
|
|
416
416
|
}
|
|
417
|
-
function dispatchResult(result,
|
|
418
|
-
if (!
|
|
417
|
+
function dispatchResult(result, sink, plugins, pluginCtx, emitHook) {
|
|
418
|
+
if (!sink) {
|
|
419
419
|
return result;
|
|
420
420
|
}
|
|
421
421
|
let next = plugins.runBeforeDispatch(result, pluginCtx);
|
|
422
422
|
emitHook("before_dispatch", next);
|
|
423
|
-
const dispatched =
|
|
423
|
+
const dispatched = sink.dispatch(next);
|
|
424
424
|
plugins.runAfterDispatch(next, pluginCtx);
|
|
425
425
|
emitHook("after_dispatch", next);
|
|
426
426
|
return dispatched ?? next;
|
|
@@ -563,7 +563,7 @@ var ResponsePresets = class {
|
|
|
563
563
|
|
|
564
564
|
// src/dto/send/builder.ts
|
|
565
565
|
var Builder = class {
|
|
566
|
-
|
|
566
|
+
sink;
|
|
567
567
|
options;
|
|
568
568
|
context;
|
|
569
569
|
plugins;
|
|
@@ -572,8 +572,8 @@ var Builder = class {
|
|
|
572
572
|
_headers = {};
|
|
573
573
|
_cookies = [];
|
|
574
574
|
_presets;
|
|
575
|
-
constructor(
|
|
576
|
-
this.
|
|
575
|
+
constructor(sink, options = {}, context) {
|
|
576
|
+
this.sink = sink;
|
|
577
577
|
this.options = resolveBuilderConfig(options);
|
|
578
578
|
this.context = context;
|
|
579
579
|
this.plugins = new PluginRegistry(this.options.plugins);
|
|
@@ -712,7 +712,7 @@ var Builder = class {
|
|
|
712
712
|
const result = this.build();
|
|
713
713
|
return dispatchResult(
|
|
714
714
|
result,
|
|
715
|
-
this.
|
|
715
|
+
this.sink,
|
|
716
716
|
this.plugins,
|
|
717
717
|
pluginCtx,
|
|
718
718
|
(event, payload) => this.emitHook(event, payload)
|
|
@@ -743,8 +743,8 @@ var Builder = class {
|
|
|
743
743
|
hooks.emit(event, structuredClone(result));
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
|
-
function createBuilderProxy(
|
|
747
|
-
const instance = new Builder(
|
|
746
|
+
function createBuilderProxy(sink, options = {}, context) {
|
|
747
|
+
const instance = new Builder(sink, options, context);
|
|
748
748
|
return new Proxy(instance, {
|
|
749
749
|
get(target, prop, receiver) {
|
|
750
750
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -777,15 +777,6 @@ function createBuilderRuntime(sink, options, context) {
|
|
|
777
777
|
function nodeSink(res) {
|
|
778
778
|
return { dispatch: (result) => dispatchNodeResponse(result, res) };
|
|
779
779
|
}
|
|
780
|
-
var NodeDispatcher = class {
|
|
781
|
-
res;
|
|
782
|
-
constructor(res) {
|
|
783
|
-
this.res = res;
|
|
784
|
-
}
|
|
785
|
-
dispatch(result) {
|
|
786
|
-
return dispatchNodeResponse(result, this.res);
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
780
|
var NodeAdapter = class {
|
|
790
781
|
constructor(options = {}) {
|
|
791
782
|
this.options = options;
|
|
@@ -816,6 +807,5 @@ function applyDefaultHeaders(options, setHeader) {
|
|
|
816
807
|
}
|
|
817
808
|
|
|
818
809
|
exports.NodeAdapter = NodeAdapter;
|
|
819
|
-
exports.NodeDispatcher = NodeDispatcher;
|
|
820
810
|
exports.nodeMiddleware = nodeMiddleware;
|
|
821
811
|
exports.nodeSink = nodeSink;
|