@jumoo/processing 17.4.3-prerelease.3 → 17.4.3-prerelease.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/dist/api/index.d.ts +1 -1
- package/dist/api/types.gen.d.ts +24 -0
- package/dist/lang/files/en.d.ts +8 -0
- package/dist/lang/files/en.js +8 -0
- package/dist/pipeline/index.d.ts +1 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/pipeline-conflict.d.ts +31 -0
- package/dist/pipeline/pipeline-conflict.js +42 -0
- package/dist/pipeline/pipeline.context.d.ts +6 -1
- package/dist/pipeline/pipeline.context.js +43 -8
- package/dist/pipeline/pipeline.element.d.ts +4 -0
- package/dist/pipeline/pipeline.element.js +96 -1
- package/dist/pipeline/pipeline.repository.d.ts +26 -0
- package/dist/pipeline/pipeline.repository.js +22 -0
- package/dist/pipeline/pipeline.source.d.ts +19 -1
- package/dist/pipeline/pipeline.source.js +23 -4
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { client, type CreateClientConfig } from './client.gen';
|
|
2
2
|
export { type Options, PipelinesService, QueuesService } from './sdk.gen';
|
|
3
|
-
export { type CancelPipelineData, type CancelPipelineError, type CancelPipelineErrors, type CancelPipelineResponses, type ClearPipelineData, type ClearPipelineError, type ClearPipelineErrors, type ClearPipelineResponses, type ClientOptions, type CreatePipelineData, type CreatePipelineError, type CreatePipelineErrors, type CreatePipelineResponse, type CreatePipelineResponses, type DeleteData, type DeleteError, type DeleteErrors, type DeleteResponses, type GetPipelineData, type GetPipelineError, type GetPipelineErrors, type GetPipelineResponse, type GetPipelineResponses, type GetProcessorsData, type GetProcessorsError, type GetProcessorsErrors, type GetProcessorsResponse, type GetProcessorsResponses, type GetResultsData, type GetResultsError, type GetResultsErrors, type GetResultsResponse, type GetResultsResponses, type ListPipelinesByStrategyData, type ListPipelinesByStrategyError, type ListPipelinesByStrategyErrors, type ListPipelinesByStrategyResponse, type ListPipelinesByStrategyResponses, type ListPipelinesData, type ListPipelinesError, type ListPipelinesErrors, type ListPipelinesResponse, type ListPipelinesResponses, type ListQueueData, type ListQueueError, type ListQueueErrors, type ListQueueResponse, type ListQueueResponses, type PagedModelQueuedItemModel, type PeekItemData, type PeekItemError, type PeekItemErrors, type PeekItemResponse, type PeekItemResponses, type Pipeline, type PipelineBackgroundState, type PipelineCreateRequest, type PipelineRunError, type PipelineRunProgress, type PipelineRunRejected, PipelineRunRejectedReason, type PipelineRunRequest, type PipelineRunStarted, PipelineRunState, type PipelineRunStatus, type PipelineRunSummary, type PipelineState, PipelineStatus, type PipelineStatusData, type PipelineStatusError, type PipelineStatusErrors, type PipelineStatusResponse, type PipelineStatusResponses, type ProblemDetails, type ProcessData, type ProcessError, type ProcessErrors, type ProcessingChildRequestAction, type ProcessingErrorDetails, type ProcessingOptions, type ProcessingOptionsResults, type ProcessingRequest, type ProcessingRequestAction, type ProcessingResults, type ProcessPipelineData, type ProcessPipelineError, type ProcessPipelineErrors, type ProcessPipelineResponse, type ProcessPipelineResponses, type ProcessResponse, type ProcessResponses, type ProgressInformation, type QueuedItem, type ReattachPipelineData, type ReattachPipelineError, type ReattachPipelineErrors, type ReattachPipelineResponse, type ReattachPipelineResponses, type StartPipelineData, type StartPipelineError, type StartPipelineErrors, type StartPipelineResponse, type StartPipelineResponses, type StepInfo, StepStatus, type UpdatePipelineData, type UpdatePipelineError, type UpdatePipelineErrors, type UpdatePipelineResponse, type UpdatePipelineResponses } from './types.gen';
|
|
3
|
+
export { type CancelPipelineData, type CancelPipelineError, type CancelPipelineErrors, type CancelPipelineResponses, type ClearPipelineData, type ClearPipelineError, type ClearPipelineErrors, type ClearPipelineResponses, type ClientOptions, type CreatePipelineData, type CreatePipelineError, type CreatePipelineErrors, type CreatePipelineResponse, type CreatePipelineResponses, type DeleteData, type DeleteError, type DeleteErrors, type DeleteResponses, type GetPipelineData, type GetPipelineError, type GetPipelineErrors, type GetPipelineResponse, type GetPipelineResponses, type GetProcessorsData, type GetProcessorsError, type GetProcessorsErrors, type GetProcessorsResponse, type GetProcessorsResponses, type GetResultsData, type GetResultsError, type GetResultsErrors, type GetResultsResponse, type GetResultsResponses, type ListPipelinesByStrategyData, type ListPipelinesByStrategyError, type ListPipelinesByStrategyErrors, type ListPipelinesByStrategyResponse, type ListPipelinesByStrategyResponses, type ListPipelinesData, type ListPipelinesError, type ListPipelinesErrors, type ListPipelinesResponse, type ListPipelinesResponses, type ListQueueData, type ListQueueError, type ListQueueErrors, type ListQueueResponse, type ListQueueResponses, type PagedModelQueuedItemModel, type PeekItemData, type PeekItemError, type PeekItemErrors, type PeekItemResponse, type PeekItemResponses, type Pipeline, type PipelineBackgroundState, type PipelineConflictProblemDetails, type PipelineCreateRequest, type PipelineRunError, type PipelineRunProgress, type PipelineRunRejected, PipelineRunRejectedReason, type PipelineRunRequest, type PipelineRunStarted, PipelineRunState, type PipelineRunStatus, type PipelineRunSummary, type PipelineState, PipelineStatus, type PipelineStatusData, type PipelineStatusError, type PipelineStatusErrors, type PipelineStatusResponse, type PipelineStatusResponses, type ProblemDetails, type ProcessData, type ProcessError, type ProcessErrors, type ProcessingChildRequestAction, type ProcessingErrorDetails, type ProcessingOptions, type ProcessingOptionsResults, type ProcessingRequest, type ProcessingRequestAction, type ProcessingResults, type ProcessPipelineData, type ProcessPipelineError, type ProcessPipelineErrors, type ProcessPipelineResponse, type ProcessPipelineResponses, type ProcessResponse, type ProcessResponses, type ProgressInformation, type QueuedItem, type ReattachPipelineData, type ReattachPipelineError, type ReattachPipelineErrors, type ReattachPipelineResponse, type ReattachPipelineResponses, type StartPipelineData, type StartPipelineError, type StartPipelineErrors, type StartPipelineResponse, type StartPipelineResponses, type StepInfo, StepStatus, type UpdatePipelineData, type UpdatePipelineError, type UpdatePipelineErrors, type UpdatePipelineResponse, type UpdatePipelineResponses } from './types.gen';
|
package/dist/api/types.gen.d.ts
CHANGED
|
@@ -20,6 +20,16 @@ export type PipelineBackgroundState = {
|
|
|
20
20
|
failedElement?: string | null;
|
|
21
21
|
clientId?: string | null;
|
|
22
22
|
};
|
|
23
|
+
export type PipelineConflictProblemDetails = {
|
|
24
|
+
type?: string | null;
|
|
25
|
+
title?: string | null;
|
|
26
|
+
status?: number | null;
|
|
27
|
+
detail?: string | null;
|
|
28
|
+
instance?: string | null;
|
|
29
|
+
runningPipelineId: string;
|
|
30
|
+
concurrencyKey: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
};
|
|
23
33
|
export type PipelineCreateRequest = {
|
|
24
34
|
alias: string;
|
|
25
35
|
strategy: string;
|
|
@@ -202,6 +212,8 @@ export type QueuedItem = {
|
|
|
202
212
|
note?: string | null;
|
|
203
213
|
claimedBy?: string | null;
|
|
204
214
|
claimedUntil?: string | null;
|
|
215
|
+
ownerNode?: string | null;
|
|
216
|
+
ownerHeartbeat?: string | null;
|
|
205
217
|
};
|
|
206
218
|
export type StepInfo = {
|
|
207
219
|
icon: string;
|
|
@@ -295,6 +307,10 @@ export type CreatePipelineErrors = {
|
|
|
295
307
|
* Not Found
|
|
296
308
|
*/
|
|
297
309
|
404: unknown;
|
|
310
|
+
/**
|
|
311
|
+
* Conflict
|
|
312
|
+
*/
|
|
313
|
+
409: PipelineConflictProblemDetails;
|
|
298
314
|
};
|
|
299
315
|
export type CreatePipelineError = CreatePipelineErrors[keyof CreatePipelineErrors];
|
|
300
316
|
export type CreatePipelineResponses = {
|
|
@@ -498,6 +514,10 @@ export type ProcessPipelineErrors = {
|
|
|
498
514
|
* The resource is protected and requires an authentication token
|
|
499
515
|
*/
|
|
500
516
|
401: unknown;
|
|
517
|
+
/**
|
|
518
|
+
* Conflict
|
|
519
|
+
*/
|
|
520
|
+
409: PipelineConflictProblemDetails;
|
|
501
521
|
};
|
|
502
522
|
export type ProcessPipelineError = ProcessPipelineErrors[keyof ProcessPipelineErrors];
|
|
503
523
|
export type ProcessPipelineResponses = {
|
|
@@ -588,6 +608,10 @@ export type UpdatePipelineErrors = {
|
|
|
588
608
|
* The resource is protected and requires an authentication token
|
|
589
609
|
*/
|
|
590
610
|
401: unknown;
|
|
611
|
+
/**
|
|
612
|
+
* Conflict
|
|
613
|
+
*/
|
|
614
|
+
409: PipelineConflictProblemDetails;
|
|
591
615
|
};
|
|
592
616
|
export type UpdatePipelineError = UpdatePipelineErrors[keyof UpdatePipelineErrors];
|
|
593
617
|
export type UpdatePipelineResponses = {
|
package/dist/lang/files/en.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ declare const _default: {
|
|
|
13
13
|
method: string;
|
|
14
14
|
stack: string;
|
|
15
15
|
};
|
|
16
|
+
jumooProcConflict: {
|
|
17
|
+
headline: string;
|
|
18
|
+
message: string;
|
|
19
|
+
status: string;
|
|
20
|
+
startedBy: string;
|
|
21
|
+
started: string;
|
|
22
|
+
progress: string;
|
|
23
|
+
};
|
|
16
24
|
jumooProcBackground: {
|
|
17
25
|
completed: string;
|
|
18
26
|
error: string;
|
package/dist/lang/files/en.js
CHANGED
|
@@ -13,6 +13,14 @@ export default {
|
|
|
13
13
|
method: 'Method',
|
|
14
14
|
stack: 'Stack',
|
|
15
15
|
},
|
|
16
|
+
jumooProcConflict: {
|
|
17
|
+
headline: 'Already running',
|
|
18
|
+
message: 'Another process is already running for this target. Wait for it to finish, or cancel it, then try again.',
|
|
19
|
+
status: 'Status',
|
|
20
|
+
startedBy: 'Started by',
|
|
21
|
+
started: 'Started',
|
|
22
|
+
progress: 'Progress',
|
|
23
|
+
},
|
|
16
24
|
jumooProcBackground: {
|
|
17
25
|
completed: 'This process has completed in the background',
|
|
18
26
|
error: 'This process has errored in the background',
|
package/dist/pipeline/index.d.ts
CHANGED
package/dist/pipeline/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
|
2
|
+
import type { PipelineRunStatus } from '../api';
|
|
3
|
+
/**
|
|
4
|
+
* @description a pipeline that couldn't be created or resumed because another one holds its
|
|
5
|
+
* concurrency key (the server's 409 `PipelineConflictProblemDetails`).
|
|
6
|
+
*/
|
|
7
|
+
export interface PipelineConflict {
|
|
8
|
+
/** the pipeline holding the key */
|
|
9
|
+
runningPipelineId: string;
|
|
10
|
+
/** the key that is held */
|
|
11
|
+
concurrencyKey: string;
|
|
12
|
+
/** the server's message */
|
|
13
|
+
detail?: string | null;
|
|
14
|
+
/** the holder's status, when the current user can see it */
|
|
15
|
+
holder?: PipelineRunStatus;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description reads the 409 "already running" body off an error, whether it is the raw
|
|
19
|
+
* problem details the generated client throws or the `UmbApiError` tryExecute wraps it in.
|
|
20
|
+
* @param error the error from a request.
|
|
21
|
+
* @returns the conflict, or undefined for any other error.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPipelineConflict(error: unknown): PipelineConflict | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* @description tryExecute, except a 409 "already running" comes back as the error without a
|
|
26
|
+
* notification, so the caller can show it inline. Every other error notifies as normal.
|
|
27
|
+
* @param host the host the request (and any notification) belongs to.
|
|
28
|
+
* @param promise the request.
|
|
29
|
+
* @returns the response, as tryExecute returns it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tryExecuteAllowingConflict<T>(host: UmbControllerHost, promise: Promise<T>): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<T>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { tryExecute, UmbApiError } from '@umbraco-cms/backoffice/resources';
|
|
2
|
+
/**
|
|
3
|
+
* @description reads the 409 "already running" body off an error, whether it is the raw
|
|
4
|
+
* problem details the generated client throws or the `UmbApiError` tryExecute wraps it in.
|
|
5
|
+
* @param error the error from a request.
|
|
6
|
+
* @returns the conflict, or undefined for any other error.
|
|
7
|
+
*/
|
|
8
|
+
export function getPipelineConflict(error) {
|
|
9
|
+
const body = UmbApiError.isUmbApiError(error) ? error.problemDetails : error;
|
|
10
|
+
if (!body || typeof body !== 'object')
|
|
11
|
+
return undefined;
|
|
12
|
+
const problem = body;
|
|
13
|
+
if (problem.status !== 409 || typeof problem.runningPipelineId !== 'string')
|
|
14
|
+
return undefined;
|
|
15
|
+
return {
|
|
16
|
+
runningPipelineId: problem.runningPipelineId,
|
|
17
|
+
concurrencyKey: typeof problem.concurrencyKey === 'string' ? problem.concurrencyKey : '',
|
|
18
|
+
detail: typeof problem.detail === 'string' ? problem.detail : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @description tryExecute, except a 409 "already running" comes back as the error without a
|
|
23
|
+
* notification, so the caller can show it inline. Every other error notifies as normal.
|
|
24
|
+
* @param host the host the request (and any notification) belongs to.
|
|
25
|
+
* @param promise the request.
|
|
26
|
+
* @returns the response, as tryExecute returns it.
|
|
27
|
+
*/
|
|
28
|
+
export async function tryExecuteAllowingConflict(host, promise) {
|
|
29
|
+
let conflict;
|
|
30
|
+
const response = await tryExecute(host, promise.catch((error) => {
|
|
31
|
+
if (!getPipelineConflict(error))
|
|
32
|
+
throw error;
|
|
33
|
+
conflict = error;
|
|
34
|
+
return undefined;
|
|
35
|
+
}));
|
|
36
|
+
if (!conflict)
|
|
37
|
+
return response;
|
|
38
|
+
const problem = conflict;
|
|
39
|
+
return {
|
|
40
|
+
error: new UmbApiError(problem.detail ?? problem.title ?? 'Conflict', 409, null, problem),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
|
|
2
2
|
import { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
|
3
3
|
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
|
4
|
-
import { PipelineState, ProcessingMessage, ProcessingOptions, ProcessingResults } from '@jumoo/processing';
|
|
4
|
+
import { PipelineState, ProcessingMessage, ProcessingOptions, ProcessingResults, PipelineConflict } from '@jumoo/processing';
|
|
5
5
|
/**
|
|
6
6
|
* @description context for keeping pipeline status and progress as we do things.
|
|
7
7
|
*/
|
|
@@ -13,6 +13,11 @@ export declare class PipelineContext extends UmbControllerBase {
|
|
|
13
13
|
readonly results: import("rxjs").Observable<ProcessingResults | undefined>;
|
|
14
14
|
readonly message: import("rxjs").Observable<ProcessingMessage | undefined>;
|
|
15
15
|
readonly backgroundState: import("rxjs").Observable<PipelineState | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* @description set when the pipeline couldn't be created or resumed because another one
|
|
18
|
+
* holds its concurrency key - "already running".
|
|
19
|
+
*/
|
|
20
|
+
readonly conflict: import("rxjs").Observable<PipelineConflict | undefined>;
|
|
16
21
|
constructor(host: UmbControllerHost);
|
|
17
22
|
private isMessage;
|
|
18
23
|
private isState;
|
|
@@ -9,11 +9,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _PipelineContext_instances, _PipelineContext_repository, _PipelineContext_hubContext, _PipelineContext_pipeline, _PipelineContext_state, _PipelineContext_options, _PipelineContext_results, _PipelineContext_message, _PipelineContext_backgroundState, _PipelineContext_clientId, _PipelineContext_hasConnectedBefore, _PipelineContext_onClientIdChanged, _PipelineContext_isInFlight, _PipelineContext_trigger, _PipelineContext_close, _PipelineContext_finalized, _PipelineContext_valid, _PipelineContext_pending;
|
|
12
|
+
var _PipelineContext_instances, _PipelineContext_repository, _PipelineContext_hubContext, _PipelineContext_pipeline, _PipelineContext_state, _PipelineContext_options, _PipelineContext_results, _PipelineContext_message, _PipelineContext_backgroundState, _PipelineContext_conflict, _PipelineContext_clientId, _PipelineContext_hasConnectedBefore, _PipelineContext_onClientIdChanged, _PipelineContext_isInFlight, _PipelineContext_setConflict, _PipelineContext_trigger, _PipelineContext_close, _PipelineContext_finalized, _PipelineContext_valid, _PipelineContext_pending;
|
|
13
13
|
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
|
|
14
14
|
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
|
|
15
15
|
import { UmbBooleanState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
|
|
16
|
-
import { PipelineStatus, PipelineRepository, ProcessingSignalRContext, } from '@jumoo/processing';
|
|
16
|
+
import { PipelineStatus, PipelineRepository, ProcessingSignalRContext, getPipelineConflict, } from '@jumoo/processing';
|
|
17
17
|
/**
|
|
18
18
|
* @description context for keeping pipeline status and progress as we do things.
|
|
19
19
|
*/
|
|
@@ -35,6 +35,12 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
35
35
|
this.message = __classPrivateFieldGet(this, _PipelineContext_message, "f").asObservable();
|
|
36
36
|
_PipelineContext_backgroundState.set(this, new UmbObjectState(undefined));
|
|
37
37
|
this.backgroundState = __classPrivateFieldGet(this, _PipelineContext_backgroundState, "f").asObservable();
|
|
38
|
+
_PipelineContext_conflict.set(this, new UmbObjectState(undefined));
|
|
39
|
+
/**
|
|
40
|
+
* @description set when the pipeline couldn't be created or resumed because another one
|
|
41
|
+
* holds its concurrency key - "already running".
|
|
42
|
+
*/
|
|
43
|
+
this.conflict = __classPrivateFieldGet(this, _PipelineContext_conflict, "f").asObservable();
|
|
38
44
|
// tracks the SignalR connection id ourselves, alongside the hub context's own clientId
|
|
39
45
|
// observable, so #onClientIdChanged can tell "first connect" (nothing to reattach - there's
|
|
40
46
|
// no prior, now-dead connection) apart from "changed after already having one" (a genuine
|
|
@@ -86,8 +92,13 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
86
92
|
return message !== undefined;
|
|
87
93
|
}
|
|
88
94
|
async createPipeline(processor, strategy, options) {
|
|
89
|
-
|
|
90
|
-
__classPrivateFieldGet(this,
|
|
95
|
+
__classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
|
|
96
|
+
const { data, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryCreate(processor, strategy, options);
|
|
97
|
+
if (error) {
|
|
98
|
+
await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").setValue(data);
|
|
91
102
|
}
|
|
92
103
|
async loadPipeline(id) {
|
|
93
104
|
const pipeline = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").Get(id);
|
|
@@ -113,7 +124,11 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
113
124
|
if (!__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value)
|
|
114
125
|
return;
|
|
115
126
|
const clientId = __classPrivateFieldGet(this, _PipelineContext_hubContext, "f")?.getClientId() ?? null;
|
|
116
|
-
const response = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").
|
|
127
|
+
const { data: response, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryProcess(__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value, clientId);
|
|
128
|
+
if (error) {
|
|
129
|
+
await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
117
132
|
if (response?.state) {
|
|
118
133
|
__classPrivateFieldGet(this, _PipelineContext_state, "f").setValue(response.state);
|
|
119
134
|
}
|
|
@@ -128,7 +143,9 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
128
143
|
async updateOptions(options) {
|
|
129
144
|
if (!__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value)
|
|
130
145
|
return;
|
|
131
|
-
const response = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").
|
|
146
|
+
const { data: response, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryUpdate(__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value, options);
|
|
147
|
+
if (error)
|
|
148
|
+
await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
|
|
132
149
|
if (response?.options) {
|
|
133
150
|
console.debug('update: pipeline.options', response);
|
|
134
151
|
__classPrivateFieldGet(this, _PipelineContext_options, "f").setValue(response.options);
|
|
@@ -140,7 +157,9 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
140
157
|
async saveOptions() {
|
|
141
158
|
if (!__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value)
|
|
142
159
|
return;
|
|
143
|
-
const response = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").
|
|
160
|
+
const { data: response, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryUpdate(__classPrivateFieldGet(this, _PipelineContext_pipeline, "f").value, __classPrivateFieldGet(this, _PipelineContext_options, "f").value);
|
|
161
|
+
if (error)
|
|
162
|
+
await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
|
|
144
163
|
if (response?.options) {
|
|
145
164
|
console.debug('save:pipeline.options', response);
|
|
146
165
|
__classPrivateFieldGet(this, _PipelineContext_options, "f").setValue(response.options);
|
|
@@ -217,7 +236,7 @@ export class PipelineContext extends UmbControllerBase {
|
|
|
217
236
|
__classPrivateFieldGet(this, _PipelineContext_pending, "f").setValue(__classPrivateFieldGet(this, _PipelineContext_options, "f").value);
|
|
218
237
|
}
|
|
219
238
|
}
|
|
220
|
-
_PipelineContext_repository = new WeakMap(), _PipelineContext_hubContext = new WeakMap(), _PipelineContext_pipeline = new WeakMap(), _PipelineContext_state = new WeakMap(), _PipelineContext_options = new WeakMap(), _PipelineContext_results = new WeakMap(), _PipelineContext_message = new WeakMap(), _PipelineContext_backgroundState = new WeakMap(), _PipelineContext_clientId = new WeakMap(), _PipelineContext_hasConnectedBefore = new WeakMap(), _PipelineContext_trigger = new WeakMap(), _PipelineContext_close = new WeakMap(), _PipelineContext_finalized = new WeakMap(), _PipelineContext_valid = new WeakMap(), _PipelineContext_pending = new WeakMap(), _PipelineContext_instances = new WeakSet(), _PipelineContext_onClientIdChanged =
|
|
239
|
+
_PipelineContext_repository = new WeakMap(), _PipelineContext_hubContext = new WeakMap(), _PipelineContext_pipeline = new WeakMap(), _PipelineContext_state = new WeakMap(), _PipelineContext_options = new WeakMap(), _PipelineContext_results = new WeakMap(), _PipelineContext_message = new WeakMap(), _PipelineContext_backgroundState = new WeakMap(), _PipelineContext_conflict = new WeakMap(), _PipelineContext_clientId = new WeakMap(), _PipelineContext_hasConnectedBefore = new WeakMap(), _PipelineContext_trigger = new WeakMap(), _PipelineContext_close = new WeakMap(), _PipelineContext_finalized = new WeakMap(), _PipelineContext_valid = new WeakMap(), _PipelineContext_pending = new WeakMap(), _PipelineContext_instances = new WeakSet(), _PipelineContext_onClientIdChanged =
|
|
221
240
|
/**
|
|
222
241
|
* @description called whenever the SignalR connection id changes - which includes the very
|
|
223
242
|
* first connect, where there's nothing to reattach yet, and a reconnect, where a pipeline
|
|
@@ -255,6 +274,22 @@ async function _PipelineContext_onClientIdChanged(clientId) {
|
|
|
255
274
|
default:
|
|
256
275
|
return false;
|
|
257
276
|
}
|
|
277
|
+
}, _PipelineContext_setConflict =
|
|
278
|
+
/**
|
|
279
|
+
* @description records a 409 "already running", with the holder's status when the user can
|
|
280
|
+
* see it.
|
|
281
|
+
* @param error the error from a create, process or update.
|
|
282
|
+
* @returns true when it was a conflict.
|
|
283
|
+
*/
|
|
284
|
+
async function _PipelineContext_setConflict(error) {
|
|
285
|
+
const conflict = getPipelineConflict(error);
|
|
286
|
+
if (!conflict)
|
|
287
|
+
return false;
|
|
288
|
+
__classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(conflict);
|
|
289
|
+
const holder = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").getRunStatus(conflict.runningPipelineId);
|
|
290
|
+
if (holder)
|
|
291
|
+
__classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue({ ...conflict, holder });
|
|
292
|
+
return true;
|
|
258
293
|
};
|
|
259
294
|
export default PipelineContext;
|
|
260
295
|
export const JUMOO_PROCESSING_CONTEXT = new UmbContextToken('JumooPipelineContext');
|
|
@@ -9,6 +9,8 @@ import { ProcessingOptions } from '@jumoo/processing';
|
|
|
9
9
|
* @fires pipeline-waiting - when the pipeline is waiting for user input
|
|
10
10
|
* @fires pipeline-last-action - when the pipeline is on the last action
|
|
11
11
|
* @fires pipeline-status - the current status of the pipeline.
|
|
12
|
+
* @fires pipeline-conflict - when the pipeline can't be created or resumed because another
|
|
13
|
+
* process is already running for the same target (detail is the PipelineConflict).
|
|
12
14
|
*/
|
|
13
15
|
export declare class JumooPipelineElement extends UmbLitElement {
|
|
14
16
|
private context?;
|
|
@@ -35,6 +37,7 @@ export declare class JumooPipelineElement extends UmbLitElement {
|
|
|
35
37
|
private results;
|
|
36
38
|
private message;
|
|
37
39
|
private backgroundState;
|
|
40
|
+
private conflict;
|
|
38
41
|
constructor();
|
|
39
42
|
connectedCallback(): void;
|
|
40
43
|
private process;
|
|
@@ -57,6 +60,7 @@ export declare class JumooPipelineElement extends UmbLitElement {
|
|
|
57
60
|
*/
|
|
58
61
|
private onLastAction;
|
|
59
62
|
render(): import("lit-html").TemplateResult<1>;
|
|
63
|
+
private renderConflict;
|
|
60
64
|
private renderDebug;
|
|
61
65
|
private renderStatus;
|
|
62
66
|
private renderBackground;
|
|
@@ -16,6 +16,8 @@ import { PipelineStatus, JUMOO_PROCESSING_CONTEXT, } from '@jumoo/processing';
|
|
|
16
16
|
* @fires pipeline-waiting - when the pipeline is waiting for user input
|
|
17
17
|
* @fires pipeline-last-action - when the pipeline is on the last action
|
|
18
18
|
* @fires pipeline-status - the current status of the pipeline.
|
|
19
|
+
* @fires pipeline-conflict - when the pipeline can't be created or resumed because another
|
|
20
|
+
* process is already running for the same target (detail is the PipelineConflict).
|
|
19
21
|
*/
|
|
20
22
|
let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
|
|
21
23
|
constructor() {
|
|
@@ -73,6 +75,17 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
|
|
|
73
75
|
this.observe(this.context.results, (results) => {
|
|
74
76
|
this.results = results;
|
|
75
77
|
});
|
|
78
|
+
this.observe(this.context.conflict, (conflict) => {
|
|
79
|
+
const isNew = conflict && !this.conflict;
|
|
80
|
+
this.conflict = conflict;
|
|
81
|
+
if (isNew) {
|
|
82
|
+
this.dispatchEvent(new CustomEvent('pipeline-conflict', {
|
|
83
|
+
bubbles: true,
|
|
84
|
+
composed: true,
|
|
85
|
+
detail: conflict,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
76
89
|
});
|
|
77
90
|
}
|
|
78
91
|
connectedCallback() {
|
|
@@ -139,7 +152,52 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
|
|
|
139
152
|
this.fireEvent('pipeline-last-action');
|
|
140
153
|
}
|
|
141
154
|
render() {
|
|
142
|
-
return html `${this.renderStatus()}${this.renderDebug()}`;
|
|
155
|
+
return html `${this.conflict ? this.renderConflict(this.conflict) : this.renderStatus()}${this.renderDebug()}`;
|
|
156
|
+
}
|
|
157
|
+
renderConflict(conflict) {
|
|
158
|
+
const holder = conflict.holder;
|
|
159
|
+
return html `<div class="conflict">
|
|
160
|
+
<div class="header">
|
|
161
|
+
<uui-icon name="icon-alert"></uui-icon>
|
|
162
|
+
<h3>
|
|
163
|
+
<umb-localize key="jumooProcConflict_headline">Already running</umb-localize>
|
|
164
|
+
</h3>
|
|
165
|
+
</div>
|
|
166
|
+
<p>
|
|
167
|
+
<umb-localize key="jumooProcConflict_message">
|
|
168
|
+
Another process is already running for this target. Wait for it to finish, or
|
|
169
|
+
cancel it, then try again.
|
|
170
|
+
</umb-localize>
|
|
171
|
+
</p>
|
|
172
|
+
${holder
|
|
173
|
+
? html `<dl>
|
|
174
|
+
<dt><umb-localize key="jumooProcConflict_status">Status</umb-localize></dt>
|
|
175
|
+
<dd>${holder.status}</dd>
|
|
176
|
+
${holder.startedBy
|
|
177
|
+
? html `<dt>
|
|
178
|
+
<umb-localize key="jumooProcConflict_startedBy"
|
|
179
|
+
>Started by</umb-localize
|
|
180
|
+
>
|
|
181
|
+
</dt>
|
|
182
|
+
<dd>${holder.startedBy}</dd>`
|
|
183
|
+
: nothing}
|
|
184
|
+
${holder.created
|
|
185
|
+
? html `<dt>
|
|
186
|
+
<umb-localize key="jumooProcConflict_started"
|
|
187
|
+
>Started</umb-localize
|
|
188
|
+
>
|
|
189
|
+
</dt>
|
|
190
|
+
<dd>
|
|
191
|
+
${this.localize.date(holder.created, { dateStyle: 'medium', timeStyle: 'short' })}
|
|
192
|
+
</dd>`
|
|
193
|
+
: nothing}
|
|
194
|
+
<dt>
|
|
195
|
+
<umb-localize key="jumooProcConflict_progress">Progress</umb-localize>
|
|
196
|
+
</dt>
|
|
197
|
+
<dd>${Math.round(holder.progress.percentage)}%</dd>
|
|
198
|
+
</dl>`
|
|
199
|
+
: nothing}
|
|
200
|
+
</div>`;
|
|
143
201
|
}
|
|
144
202
|
renderDebug() {
|
|
145
203
|
return this.debug
|
|
@@ -220,6 +278,40 @@ JumooPipelineElement.styles = css `
|
|
|
220
278
|
umb-extension-slot {
|
|
221
279
|
height: 100%;
|
|
222
280
|
}
|
|
281
|
+
|
|
282
|
+
.conflict {
|
|
283
|
+
padding: var(--uui-size-space-5);
|
|
284
|
+
border: 1px solid var(--uui-color-warning-standalone);
|
|
285
|
+
border-left-width: 4px;
|
|
286
|
+
border-radius: var(--uui-border-radius);
|
|
287
|
+
background-color: var(--uui-color-surface);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.conflict .header {
|
|
291
|
+
display: flex;
|
|
292
|
+
align-items: center;
|
|
293
|
+
gap: var(--uui-size-space-3);
|
|
294
|
+
color: var(--uui-color-warning-standalone);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.conflict h3 {
|
|
298
|
+
margin: 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.conflict dl {
|
|
302
|
+
display: grid;
|
|
303
|
+
grid-template-columns: max-content 1fr;
|
|
304
|
+
gap: var(--uui-size-space-2) var(--uui-size-space-5);
|
|
305
|
+
margin: var(--uui-size-space-4) 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.conflict dt {
|
|
309
|
+
font-weight: bold;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.conflict dd {
|
|
313
|
+
margin: 0;
|
|
314
|
+
}
|
|
223
315
|
`;
|
|
224
316
|
__decorate([
|
|
225
317
|
property({ type: String })
|
|
@@ -254,6 +346,9 @@ __decorate([
|
|
|
254
346
|
__decorate([
|
|
255
347
|
state()
|
|
256
348
|
], JumooPipelineElement.prototype, "backgroundState", void 0);
|
|
349
|
+
__decorate([
|
|
350
|
+
state()
|
|
351
|
+
], JumooPipelineElement.prototype, "conflict", void 0);
|
|
257
352
|
JumooPipelineElement = __decorate([
|
|
258
353
|
customElement('jumoo-pipeline')
|
|
259
354
|
], JumooPipelineElement);
|
|
@@ -14,6 +14,32 @@ export declare class PipelineRepository extends UmbControllerBase {
|
|
|
14
14
|
getProcessors(): Promise<string[]>;
|
|
15
15
|
Get(id: string): Promise<import("@jumoo/processing").Pipeline>;
|
|
16
16
|
create(processor: string, strategy: string, options: ProcessingOptions | undefined): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* @description create, returning the whole response rather than just the id, so the caller
|
|
19
|
+
* can tell a 409 "already running" (see getPipelineConflict) from any other failure.
|
|
20
|
+
*/
|
|
21
|
+
tryCreate(processor: string, strategy: string, options: ProcessingOptions | undefined): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
22
|
+
data: string;
|
|
23
|
+
request: Request;
|
|
24
|
+
response: Response;
|
|
25
|
+
}>>;
|
|
26
|
+
/**
|
|
27
|
+
* @description process, returning the whole response - see tryCreate.
|
|
28
|
+
*/
|
|
29
|
+
tryProcess(id: string, clientId: string | null): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
30
|
+
data: import("@jumoo/processing").Pipeline;
|
|
31
|
+
request: Request;
|
|
32
|
+
response: Response;
|
|
33
|
+
}>>;
|
|
34
|
+
/**
|
|
35
|
+
* @description update, returning the whole response - see tryCreate.
|
|
36
|
+
*/
|
|
37
|
+
tryUpdate(id: string, body: ProcessingOptions | undefined): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
38
|
+
data: import("@jumoo/processing").ProcessingOptionsResults;
|
|
39
|
+
request: Request;
|
|
40
|
+
response: Response;
|
|
41
|
+
}>>;
|
|
42
|
+
getRunStatus(id: string): Promise<import("@jumoo/processing").PipelineRunStatus>;
|
|
17
43
|
complete(id: string): Promise<void>;
|
|
18
44
|
getResults(id: string): Promise<import("@jumoo/processing").ProcessingResults>;
|
|
19
45
|
listPipelines(status: PipelineStatus): Promise<import("@jumoo/processing").Pipeline[]>;
|
|
@@ -29,6 +29,28 @@ export class PipelineRepository extends UmbControllerBase {
|
|
|
29
29
|
async create(processor, strategy, options) {
|
|
30
30
|
return (await this.source.create(processor, strategy, options)).data;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @description create, returning the whole response rather than just the id, so the caller
|
|
34
|
+
* can tell a 409 "already running" (see getPipelineConflict) from any other failure.
|
|
35
|
+
*/
|
|
36
|
+
async tryCreate(processor, strategy, options) {
|
|
37
|
+
return await this.source.create(processor, strategy, options);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @description process, returning the whole response - see tryCreate.
|
|
41
|
+
*/
|
|
42
|
+
async tryProcess(id, clientId) {
|
|
43
|
+
return await this.source.process(id, clientId);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @description update, returning the whole response - see tryCreate.
|
|
47
|
+
*/
|
|
48
|
+
async tryUpdate(id, body) {
|
|
49
|
+
return await this.source.update(id, body);
|
|
50
|
+
}
|
|
51
|
+
async getRunStatus(id) {
|
|
52
|
+
return (await this.source.getRunStatus(id)).data;
|
|
53
|
+
}
|
|
32
54
|
async complete(id) {
|
|
33
55
|
console.debug('complete', id);
|
|
34
56
|
}
|
|
@@ -3,6 +3,10 @@ import { PipelineStatus } from '../api';
|
|
|
3
3
|
export declare class PipelineSource {
|
|
4
4
|
private readonly host;
|
|
5
5
|
constructor(host: UmbControllerHost);
|
|
6
|
+
/**
|
|
7
|
+
* @description a 409 (another pipeline holds this one's concurrency key, so it can't resume)
|
|
8
|
+
* is returned as the error without a notification - see getPipelineConflict.
|
|
9
|
+
*/
|
|
6
10
|
process(id: string, clientId: string | null): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
7
11
|
data: import("..").Pipeline;
|
|
8
12
|
request: Request;
|
|
@@ -19,6 +23,10 @@ export declare class PipelineSource {
|
|
|
19
23
|
request: Request;
|
|
20
24
|
response: Response;
|
|
21
25
|
}>>;
|
|
26
|
+
/**
|
|
27
|
+
* @description a 409 (the new options' concurrency key is held) is returned as the error
|
|
28
|
+
* without a notification - see getPipelineConflict.
|
|
29
|
+
*/
|
|
22
30
|
update(id: string, body: any): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
23
31
|
data: import("..").ProcessingOptionsResults;
|
|
24
32
|
request: Request;
|
|
@@ -42,7 +50,8 @@ export declare class PipelineSource {
|
|
|
42
50
|
/**
|
|
43
51
|
*
|
|
44
52
|
* @param strategy alias of the strategy to use for the pipeline
|
|
45
|
-
* @returns
|
|
53
|
+
* @returns the new pipeline's id. A 409 (another pipeline holds its concurrency key) is
|
|
54
|
+
* returned as the error without a notification - see getPipelineConflict.
|
|
46
55
|
*/
|
|
47
56
|
create(processor: string, strategy: string, options: any): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
48
57
|
data: string;
|
|
@@ -68,6 +77,15 @@ export declare class PipelineSource {
|
|
|
68
77
|
request: Request;
|
|
69
78
|
response: Response;
|
|
70
79
|
}>>;
|
|
80
|
+
/**
|
|
81
|
+
* @param id guid id of the pipeline
|
|
82
|
+
* @returns its run status, or an error (without a notification) if the user can't see it.
|
|
83
|
+
*/
|
|
84
|
+
getRunStatus(id: string): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
85
|
+
data: import("..").PipelineRunStatus;
|
|
86
|
+
request: Request;
|
|
87
|
+
response: Response;
|
|
88
|
+
}>>;
|
|
71
89
|
listPiplelines(status: PipelineStatus): Promise<import("@umbraco-cms/backoffice/resources").UmbApiResponse<{
|
|
72
90
|
data: import("..").Pipeline[];
|
|
73
91
|
request: Request;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { tryExecute } from '@umbraco-cms/backoffice/resources';
|
|
2
2
|
import { PipelinesService } from '../api';
|
|
3
|
+
import { tryExecuteAllowingConflict } from './pipeline-conflict.js';
|
|
3
4
|
export class PipelineSource {
|
|
4
5
|
constructor(host) {
|
|
5
6
|
this.host = host;
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @description a 409 (another pipeline holds this one's concurrency key, so it can't resume)
|
|
10
|
+
* is returned as the error without a notification - see getPipelineConflict.
|
|
11
|
+
*/
|
|
7
12
|
async process(id, clientId) {
|
|
8
|
-
const result = await
|
|
13
|
+
const result = await tryExecuteAllowingConflict(this.host, PipelinesService.processPipeline({
|
|
9
14
|
path: { id: id },
|
|
10
15
|
query: { clientId: clientId ?? undefined },
|
|
11
16
|
}));
|
|
@@ -24,8 +29,12 @@ export class PipelineSource {
|
|
|
24
29
|
}));
|
|
25
30
|
return result;
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @description a 409 (the new options' concurrency key is held) is returned as the error
|
|
34
|
+
* without a notification - see getPipelineConflict.
|
|
35
|
+
*/
|
|
27
36
|
async update(id, body) {
|
|
28
|
-
return await
|
|
37
|
+
return await tryExecuteAllowingConflict(this.host, PipelinesService.updatePipeline({
|
|
29
38
|
path: { id: id },
|
|
30
39
|
body: body,
|
|
31
40
|
}));
|
|
@@ -44,10 +53,11 @@ export class PipelineSource {
|
|
|
44
53
|
/**
|
|
45
54
|
*
|
|
46
55
|
* @param strategy alias of the strategy to use for the pipeline
|
|
47
|
-
* @returns
|
|
56
|
+
* @returns the new pipeline's id. A 409 (another pipeline holds its concurrency key) is
|
|
57
|
+
* returned as the error without a notification - see getPipelineConflict.
|
|
48
58
|
*/
|
|
49
59
|
async create(processor, strategy, options) {
|
|
50
|
-
return await
|
|
60
|
+
return await tryExecuteAllowingConflict(this.host, PipelinesService.createPipeline({
|
|
51
61
|
body: {
|
|
52
62
|
alias: processor,
|
|
53
63
|
strategy: strategy,
|
|
@@ -73,6 +83,15 @@ export class PipelineSource {
|
|
|
73
83
|
path: { id: id },
|
|
74
84
|
}));
|
|
75
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @param id guid id of the pipeline
|
|
88
|
+
* @returns its run status, or an error (without a notification) if the user can't see it.
|
|
89
|
+
*/
|
|
90
|
+
async getRunStatus(id) {
|
|
91
|
+
return await tryExecute(this.host, PipelinesService.pipelineStatus({ path: { id: id } }), {
|
|
92
|
+
disableNotifications: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
76
95
|
async listPiplelines(status) {
|
|
77
96
|
return await tryExecute(this.host, PipelinesService.listPipelines({ path: { status: status } }));
|
|
78
97
|
}
|