rest-pipeline-js 1.3.8 → 1.3.10

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.
Files changed (2) hide show
  1. package/README.md +64 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,13 @@
1
- ## rest-pipeline-js
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 | Receives | Description |
487
- |----------|----------|-------------|
488
- | `onPipelineStart` | `{ timestamp }` | Fires at the beginning of `run()` |
489
- | `onPipelineEnd` | `{ durationMs, success, stageResults }` | Fires when `run()` completes |
490
- | `onStepDuration` | `{ stepKey, durationMs, status }` | Fires after every executed step |
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", request: async ({ prev }) => process(prev) },
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: { onStepDuration: ({ stepKey, durationMs }) => console.log(stepKey, durationMs) },
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", request: async () => fetchPosts() },
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* () { yield* subscribe("/events"); },
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 | Description |
536
- |----------------|-------------|
537
- | `.step(stage)` | Add a sequential stage |
538
- | `.parallel(stages, options?)` | Add a parallel group (`key` auto-generated if omitted) |
539
- | `.subPipeline(item)` | Embed a sub-pipeline as a stage |
540
- | `.stream(stage)` | Add a stream stage (AsyncIterable) |
541
- | `.build(options?)` | Create and return a `PipelineOrchestrator` |
542
- | `.toConfig(options?)` | Return `PipelineConfig` without creating an orchestrator |
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: "", request: async () => other }, // empty 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") console.error("✗", event.stepKey, event.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 { data, status: res.status, statusText: res.statusText,
689
- headers: Object.fromEntries(res.headers.entries()) };
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
 
@@ -886,6 +911,18 @@ MIT
886
911
 
887
912
  Danil Lisin Vladimirovich aka Macrulez
888
913
 
889
- GitHub: [macrulezru](https://github.com/macrulezru) · Website: [macrulez.ru](https://macrulez.ru/)
914
+ GitHub: [macrulezru](https://github.com/macrulezru) · Website: [macrulez.ru/en](https://macrulez.ru/en)
915
+
916
+ Bugs and questions — [issues](https://github.com/macrulezru/pipeline-js/issues)
917
+
918
+ ---
919
+
920
+ ## 💖 Support the project
921
+
922
+ Open source takes time and effort. If my work saves you time or brings value, consider supporting further development.
923
+
924
+ <a href="https://donate.cryptocloud.plus/M6O34NIN" target="_blank">
925
+ <img src="https://img.shields.io/badge/Donate-CryptoCloud-8A2BE2?style=for-the-badge&logo=cryptocurrency&logoColor=white" alt="Donate via CryptoCloud">
926
+ </a>
890
927
 
891
- Questions and bugs [issues](https://github.com/macrulezru/pipeline-js/issues)
928
+ Thank you for being part of this journey. ❤️
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rest-pipeline-js",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
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",