rest-pipeline-js 1.3.7 → 1.3.9
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 +65 -25
- package/package.json +3 -2
- package/src/vue-demo/demo.css +768 -38
- package/src/vue-demo/demo.vue +558 -109
- package/src/vue-demo/index.html +21 -12
- package/new.md +0 -501
package/README.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center" style="background:#111827;border-radius:20px;padding:28px 20px 20px;margin-bottom:32px">
|
|
2
|
+
<h1 style="color:#f9fafb;margin:0 0 32px;font-size:2.2em;letter-spacing:-0.03em;font-weight:700;font-family:sans-serif">
|
|
3
|
+
rest-pipeline-js
|
|
4
|
+
</h1>
|
|
5
|
+
<img
|
|
6
|
+
src="https://s3.twcstorage.ru/c9a2cc89-780f97fd-311d-4a1a-b86f-c25665c9dc46/images/npm/rest-pipeline-js.webp"
|
|
7
|
+
alt="vue-virtual-scroller-kit"
|
|
8
|
+
style="max-width:100%;width:auto;height:300px;border-radius:12px"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
2
11
|
|
|
3
12
|
**Flexible, modular pipeline orchestrator for REST APIs.**
|
|
4
13
|
|
|
@@ -467,7 +476,9 @@ Observe pipeline execution without modifying stage logic:
|
|
|
467
476
|
```js
|
|
468
477
|
const orchestrator = new PipelineOrchestrator({
|
|
469
478
|
config: {
|
|
470
|
-
stages: [
|
|
479
|
+
stages: [
|
|
480
|
+
/* ... */
|
|
481
|
+
],
|
|
471
482
|
metrics: {
|
|
472
483
|
onPipelineStart: ({ timestamp }) => {
|
|
473
484
|
console.log("Pipeline started at", new Date(timestamp).toISOString());
|
|
@@ -483,11 +494,11 @@ const orchestrator = new PipelineOrchestrator({
|
|
|
483
494
|
});
|
|
484
495
|
```
|
|
485
496
|
|
|
486
|
-
| Callback
|
|
487
|
-
|
|
488
|
-
| `onPipelineStart` | `{ timestamp }`
|
|
489
|
-
| `onPipelineEnd`
|
|
490
|
-
| `onStepDuration`
|
|
497
|
+
| Callback | Receives | Description |
|
|
498
|
+
| ----------------- | --------------------------------------- | --------------------------------- |
|
|
499
|
+
| `onPipelineStart` | `{ timestamp }` | Fires at the beginning of `run()` |
|
|
500
|
+
| `onPipelineEnd` | `{ durationMs, success, stageResults }` | Fires when `run()` completes |
|
|
501
|
+
| `onStepDuration` | `{ stepKey, durationMs, status }` | Fires after every executed step |
|
|
491
502
|
|
|
492
503
|
---
|
|
493
504
|
|
|
@@ -501,13 +512,16 @@ import { createPipeline } from "rest-pipeline-js";
|
|
|
501
512
|
const orchestrator = createPipeline(
|
|
502
513
|
[
|
|
503
514
|
{ key: "fetchUser", request: async () => fetchUser() },
|
|
504
|
-
{ key: "process",
|
|
515
|
+
{ key: "process", request: async ({ prev }) => process(prev) },
|
|
505
516
|
],
|
|
506
517
|
{
|
|
507
518
|
httpConfig: { baseURL: "https://api.example.com" },
|
|
508
519
|
sharedData: { userId: 42 },
|
|
509
520
|
pipelineOptions: { continueOnError: false },
|
|
510
|
-
metrics: {
|
|
521
|
+
metrics: {
|
|
522
|
+
onStepDuration: ({ stepKey, durationMs }) =>
|
|
523
|
+
console.log(stepKey, durationMs),
|
|
524
|
+
},
|
|
511
525
|
},
|
|
512
526
|
);
|
|
513
527
|
```
|
|
@@ -521,25 +535,27 @@ const orchestrator = pipe()
|
|
|
521
535
|
.step({ key: "auth", request: async () => getToken() })
|
|
522
536
|
.step({ key: "fetchUser", request: async ({ prev }) => fetchUser(prev) })
|
|
523
537
|
.parallel([
|
|
524
|
-
{ key: "loadPosts",
|
|
538
|
+
{ key: "loadPosts", request: async () => fetchPosts() },
|
|
525
539
|
{ key: "loadNotifs", request: async () => fetchNotifications() },
|
|
526
540
|
])
|
|
527
541
|
.stream({
|
|
528
542
|
key: "liveUpdates",
|
|
529
|
-
stream: async function* () {
|
|
543
|
+
stream: async function* () {
|
|
544
|
+
yield* subscribe("/events");
|
|
545
|
+
},
|
|
530
546
|
onChunk: (chunk) => updateUI(chunk),
|
|
531
547
|
})
|
|
532
548
|
.build({ httpConfig: { baseURL: "https://api.example.com" } });
|
|
533
549
|
```
|
|
534
550
|
|
|
535
|
-
| Builder method
|
|
536
|
-
|
|
537
|
-
| `.step(stage)`
|
|
538
|
-
| `.parallel(stages, options?)` | Add a parallel group (`key` auto-generated if omitted)
|
|
539
|
-
| `.subPipeline(item)`
|
|
540
|
-
| `.stream(stage)`
|
|
541
|
-
| `.build(options?)`
|
|
542
|
-
| `.toConfig(options?)`
|
|
551
|
+
| Builder method | Description |
|
|
552
|
+
| ----------------------------- | -------------------------------------------------------- |
|
|
553
|
+
| `.step(stage)` | Add a sequential stage |
|
|
554
|
+
| `.parallel(stages, options?)` | Add a parallel group (`key` auto-generated if omitted) |
|
|
555
|
+
| `.subPipeline(item)` | Embed a sub-pipeline as a stage |
|
|
556
|
+
| `.stream(stage)` | Add a stream stage (AsyncIterable) |
|
|
557
|
+
| `.build(options?)` | Create and return a `PipelineOrchestrator` |
|
|
558
|
+
| `.toConfig(options?)` | Return `PipelineConfig` without creating an orchestrator |
|
|
543
559
|
|
|
544
560
|
---
|
|
545
561
|
|
|
@@ -554,7 +570,7 @@ const { valid, errors } = validatePipelineConfig({
|
|
|
554
570
|
stages: [
|
|
555
571
|
{ key: "step1", request: async () => data },
|
|
556
572
|
{ key: "step1", request: async () => other }, // duplicate!
|
|
557
|
-
{ key: "",
|
|
573
|
+
{ key: "", request: async () => other }, // empty key!
|
|
558
574
|
],
|
|
559
575
|
});
|
|
560
576
|
|
|
@@ -576,7 +592,8 @@ const loggingPlugin = {
|
|
|
576
592
|
install(orchestrator) {
|
|
577
593
|
const off = orchestrator.on("log", (event) => {
|
|
578
594
|
if (event.type === "step:success") console.log("✓", event.stepKey);
|
|
579
|
-
if (event.type === "step:error")
|
|
595
|
+
if (event.type === "step:error")
|
|
596
|
+
console.error("✗", event.stepKey, event.error);
|
|
580
597
|
});
|
|
581
598
|
return () => off(); // cleanup on orchestrator.destroy()
|
|
582
599
|
},
|
|
@@ -584,7 +601,9 @@ const loggingPlugin = {
|
|
|
584
601
|
|
|
585
602
|
const orchestrator = new PipelineOrchestrator({
|
|
586
603
|
config: {
|
|
587
|
-
stages: [
|
|
604
|
+
stages: [
|
|
605
|
+
/* ... */
|
|
606
|
+
],
|
|
588
607
|
options: {
|
|
589
608
|
plugins: [loggingPlugin, analyticsPlugin],
|
|
590
609
|
},
|
|
@@ -615,7 +634,9 @@ const localStorageAdapter = {
|
|
|
615
634
|
|
|
616
635
|
const orchestrator = new PipelineOrchestrator({
|
|
617
636
|
config: {
|
|
618
|
-
stages: [
|
|
637
|
+
stages: [
|
|
638
|
+
/* ... */
|
|
639
|
+
],
|
|
619
640
|
options: { persistAdapter: localStorageAdapter },
|
|
620
641
|
},
|
|
621
642
|
});
|
|
@@ -685,8 +706,12 @@ const fetchAdapter = {
|
|
|
685
706
|
signal: config.signal,
|
|
686
707
|
});
|
|
687
708
|
const data = await res.json();
|
|
688
|
-
return {
|
|
689
|
-
|
|
709
|
+
return {
|
|
710
|
+
data,
|
|
711
|
+
status: res.status,
|
|
712
|
+
statusText: res.statusText,
|
|
713
|
+
headers: Object.fromEntries(res.headers.entries()),
|
|
714
|
+
};
|
|
690
715
|
},
|
|
691
716
|
};
|
|
692
717
|
|
|
@@ -850,6 +875,21 @@ import {
|
|
|
850
875
|
|
|
851
876
|
---
|
|
852
877
|
|
|
878
|
+
## Vue Demo
|
|
879
|
+
|
|
880
|
+
A live interactive demo of the pipeline running against a real flight-search API — 4 sequential stages: airport lookup, availability, ancillary services, and seat map.
|
|
881
|
+
|
|
882
|
+
```bash
|
|
883
|
+
git clone https://github.com/macrulezru/pipeline-js.git
|
|
884
|
+
cd pipeline-js
|
|
885
|
+
npm install
|
|
886
|
+
npm run demo:vue
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
Opens at `http://localhost:3000` (or the next available port). Click **Run Pipeline** to execute all stages and watch results appear in real time. A boarding pass is rendered when all stages succeed.
|
|
890
|
+
|
|
891
|
+
---
|
|
892
|
+
|
|
853
893
|
## Development
|
|
854
894
|
|
|
855
895
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rest-pipeline-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Pipeline Orchestration Utilities for JavaScript REST API Clients",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"react-dom": "^19.2.3"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"axios": "^1.13.2"
|
|
71
|
+
"axios": "^1.13.2",
|
|
72
|
+
"prismjs": "^1.30.0"
|
|
72
73
|
}
|
|
73
74
|
}
|