rest-pipeline-js 1.0.3 → 1.0.4
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/package.json +2 -2
- package/src/pipeline-orchestrator.ts +8 -0
- package/src/progress-tracker.ts +8 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm i rest-pipeline-js
|
|
|
13
13
|
## Быстрый старт (чистый JS)
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
const { createRestClient, PipelineOrchestrator } = require('pipeline-js');
|
|
16
|
+
const { createRestClient, PipelineOrchestrator } = require('rest-pipeline-js');
|
|
17
17
|
|
|
18
18
|
// Создание REST клиента
|
|
19
19
|
const client = createRestClient({ baseURL: 'https://api.example.com' });
|
|
@@ -50,8 +50,8 @@ console.log(pipeline.getProgress());
|
|
|
50
50
|
|
|
51
51
|
### usePipelineProgress
|
|
52
52
|
```jsx
|
|
53
|
-
import { usePipelineProgress } from 'pipeline-js/react';
|
|
54
|
-
import { PipelineOrchestrator } from 'pipeline-js';
|
|
53
|
+
import { usePipelineProgress } from 'rest-pipeline-js/react';
|
|
54
|
+
import { PipelineOrchestrator } from 'rest-pipeline-js';
|
|
55
55
|
|
|
56
56
|
const pipeline = new PipelineOrchestrator({ stages: [...] }, { baseURL: '...' });
|
|
57
57
|
const progress = usePipelineProgress(pipeline);
|
|
@@ -59,7 +59,7 @@ const progress = usePipelineProgress(pipeline);
|
|
|
59
59
|
|
|
60
60
|
### usePipelineRun
|
|
61
61
|
```jsx
|
|
62
|
-
import { usePipelineRun } from 'pipeline-js/react';
|
|
62
|
+
import { usePipelineRun } from 'rest-pipeline-js/react';
|
|
63
63
|
const [run, { running, result, error }] = usePipelineRun(pipeline);
|
|
64
64
|
|
|
65
65
|
// В компоненте:
|
|
@@ -71,7 +71,7 @@ const [run, { running, result, error }] = usePipelineRun(pipeline);
|
|
|
71
71
|
|
|
72
72
|
### useRestClient
|
|
73
73
|
```jsx
|
|
74
|
-
import { useRestClient } from 'pipeline-js/react';
|
|
74
|
+
import { useRestClient } from 'rest-pipeline-js/react';
|
|
75
75
|
const api = useRestClient({ baseURL: '...' });
|
|
76
76
|
```
|
|
77
77
|
|
|
@@ -79,8 +79,8 @@ const api = useRestClient({ baseURL: '...' });
|
|
|
79
79
|
|
|
80
80
|
### usePipelineProgress
|
|
81
81
|
```js
|
|
82
|
-
import { usePipelineProgress } from 'pipeline-js/vue';
|
|
83
|
-
import { PipelineOrchestrator } from 'pipeline-js';
|
|
82
|
+
import { usePipelineProgress } from 'rest-pipeline-js/vue';
|
|
83
|
+
import { PipelineOrchestrator } from 'rest-pipeline-js';
|
|
84
84
|
|
|
85
85
|
const pipeline = new PipelineOrchestrator({ stages: [...] }, { baseURL: '...' });
|
|
86
86
|
const progress = usePipelineProgress(pipeline);
|
|
@@ -88,20 +88,20 @@ const progress = usePipelineProgress(pipeline);
|
|
|
88
88
|
|
|
89
89
|
### usePipelineRun
|
|
90
90
|
```js
|
|
91
|
-
import { usePipelineRun } from 'pipeline-js/vue';
|
|
91
|
+
import { usePipelineRun } from 'rest-pipeline-js/vue';
|
|
92
92
|
const { run, running, result, error } = usePipelineRun(pipeline);
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
### useRestClient
|
|
96
96
|
```js
|
|
97
|
-
import { useRestClient } from 'pipeline-js/vue';
|
|
97
|
+
import { useRestClient } from 'rest-pipeline-js/vue';
|
|
98
98
|
const api = useRestClient({ baseURL: '...' });
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
## Использование в Vue 3
|
|
102
102
|
|
|
103
103
|
```js
|
|
104
|
-
import { createRestClient, PipelineOrchestrator } from 'pipeline-js';
|
|
104
|
+
import { createRestClient, PipelineOrchestrator } from 'rest-pipeline-js';
|
|
105
105
|
import { ref, onUnmounted } from 'vue';
|
|
106
106
|
|
|
107
107
|
const client = createRestClient({ baseURL: 'https://api.example.com' });
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rest-pipeline-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Pipeline Orchestration Utilities for JavaScript REST API Clients",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"types": "
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"test": "echo \"No tests specified\" && exit 0"
|
|
@@ -39,6 +39,14 @@ export class PipelineOrchestrator {
|
|
|
39
39
|
return this.progress.getProgress();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Возвращает текущий снимок состояния прогресса (не реактивный).
|
|
44
|
+
* Для отслеживания изменений используйте subscribeProgress.
|
|
45
|
+
*/
|
|
46
|
+
getProgressRef() {
|
|
47
|
+
return this.progress.getProgressRef();
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
* @param onStepPause
|
|
44
52
|
* Необязательный callback, вызывается после каждого шага (до перехода к следующему).
|
package/src/progress-tracker.ts
CHANGED
|
@@ -15,6 +15,14 @@ export class ProgressTracker {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Возвращает текущий снимок состояния прогресса (не реактивный).
|
|
20
|
+
* Для отслеживания изменений используйте subscribeProgress.
|
|
21
|
+
*/
|
|
22
|
+
getProgressRef() {
|
|
23
|
+
return this.progress;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
updateStage(stage: number, status: PipelineProgress['stageStatuses'][number]) {
|
|
19
27
|
this.progress.stageStatuses[stage] = status;
|
|
20
28
|
this.progress.currentStage = stage;
|