@jumoo/processing 18.3.2 → 18.3.3

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.
@@ -24,6 +24,8 @@ declare const _default: {
24
24
  messageWaiting: string;
25
25
  headlineScheduled: string;
26
26
  messageScheduled: string;
27
+ checked: string;
28
+ tryAgain: string;
27
29
  status: string;
28
30
  startedBy: string;
29
31
  queued: string;
@@ -38,6 +40,11 @@ declare const _default: {
38
40
  stateCompleted: string;
39
41
  stateFailed: string;
40
42
  stateCancelled: string;
43
+ stalled: string;
44
+ clear: string;
45
+ clearHeadline: string;
46
+ clearConfirm: string;
47
+ clearConfirmLabel: string;
41
48
  };
42
49
  jumooProcBackground: {
43
50
  completed: string;
@@ -15,15 +15,17 @@ export default {
15
15
  },
16
16
  jumooProcConflict: {
17
17
  headline: 'Already in progress',
18
- message: 'Another process is already in progress for this target. Wait for it to finish, or cancel it, then try again.',
18
+ message: 'Another process is already in progress for this target. Try again once it has finished.',
19
19
  headlineRunning: 'Already running',
20
- messageRunning: 'Another process is already running for this target. Wait for it to finish, or cancel it, then try again.',
20
+ messageRunning: 'Another process is already running for this target. Try again once it has finished.',
21
21
  headlineQueued: 'Already queued',
22
- messageQueued: 'Another process for this target is queued and will start shortly. Wait for it to finish, or cancel it, then try again.',
22
+ messageQueued: 'Another process for this target is queued and will start shortly. Try again once it has finished.',
23
23
  headlineWaiting: 'Waiting to continue',
24
- messageWaiting: 'Another process for this target is paused and waiting to continue. Finish or cancel it, then try again.',
24
+ messageWaiting: 'Another process for this target is paused, waiting for whoever started it to continue. Try again once it has been finished or cancelled.',
25
25
  headlineScheduled: 'Already scheduled',
26
- messageScheduled: 'Another process for this target is scheduled. Cancel it, or wait for it to run, then try again.',
26
+ messageScheduled: 'Another process for this target is scheduled. Try again once it has run.',
27
+ checked: 'Checked',
28
+ tryAgain: 'Try again',
27
29
  status: 'Status',
28
30
  startedBy: 'Started by',
29
31
  queued: 'Queued',
@@ -38,6 +40,11 @@ export default {
38
40
  stateCompleted: 'Completed',
39
41
  stateFailed: 'Failed',
40
42
  stateCancelled: 'Cancelled',
43
+ stalled: "It hasn't moved for a while, so it has probably stopped (a closed browser, or an error). You can clear it and start again.",
44
+ clear: 'Clear it',
45
+ clearHeadline: 'Clear the other process?',
46
+ clearConfirm: 'This removes the other process so this one can start. If it is still working, it stops part way through.',
47
+ clearConfirmLabel: 'Clear and start',
41
48
  },
42
49
  jumooProcBackground: {
43
50
  completed: 'This process has completed in the background',
@@ -22,6 +22,12 @@ export declare class PipelineContext extends UmbControllerBase {
22
22
  private isMessage;
23
23
  private isState;
24
24
  createPipeline(processor: string, strategy: string, options: ProcessingOptions | undefined): Promise<void>;
25
+ /**
26
+ * @description clears the pipeline holding the key, so a create can be tried again. For a
27
+ * holder that has stopped moving - the server only lets go of a browser-driven run once it
28
+ * has been idle for the concurrency key idle timeout.
29
+ */
30
+ clearConflictHolder(): Promise<void>;
25
31
  loadPipeline(id: string): Promise<void>;
26
32
  getPipeline(id: string): Promise<import("@jumoo/processing").Pipeline>;
27
33
  fetchPipeline(id: string): Promise<import("@jumoo/processing").Pipeline>;
@@ -92,14 +92,27 @@ export class PipelineContext extends UmbControllerBase {
92
92
  return message !== undefined;
93
93
  }
94
94
  async createPipeline(processor, strategy, options) {
95
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
95
+ // a retry keeps the current conflict showing until there's a new answer.
96
96
  const { data, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryCreate(processor, strategy, options);
97
97
  if (error) {
98
98
  await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
99
99
  return;
100
100
  }
101
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
101
102
  __classPrivateFieldGet(this, _PipelineContext_pipeline, "f").setValue(data);
102
103
  }
104
+ /**
105
+ * @description clears the pipeline holding the key, so a create can be tried again. For a
106
+ * holder that has stopped moving - the server only lets go of a browser-driven run once it
107
+ * has been idle for the concurrency key idle timeout.
108
+ */
109
+ async clearConflictHolder() {
110
+ const conflict = __classPrivateFieldGet(this, _PipelineContext_conflict, "f").value;
111
+ if (!conflict)
112
+ return;
113
+ await __classPrivateFieldGet(this, _PipelineContext_repository, "f").clear(conflict.runningPipelineId);
114
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
115
+ }
103
116
  async loadPipeline(id) {
104
117
  const pipeline = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").Get(id);
105
118
  if (!pipeline)
@@ -285,10 +298,8 @@ async function _PipelineContext_setConflict(error) {
285
298
  const conflict = getPipelineConflict(error);
286
299
  if (!conflict)
287
300
  return false;
288
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(conflict);
289
301
  const holder = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").getRunStatus(conflict.runningPipelineId);
290
- if (holder)
291
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue({ ...conflict, holder });
302
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(holder ? { ...conflict, holder } : conflict);
292
303
  return true;
293
304
  };
294
305
  export default PipelineContext;
@@ -13,6 +13,7 @@ import { ProcessingOptions } from '@jumoo/processing';
13
13
  * process is already running for the same target (detail is the PipelineConflict).
14
14
  */
15
15
  export declare class JumooPipelineElement extends UmbLitElement {
16
+ #private;
16
17
  private context?;
17
18
  /**
18
19
  * @description The processor to use for the pipeline
@@ -38,6 +39,12 @@ export declare class JumooPipelineElement extends UmbLitElement {
38
39
  private message;
39
40
  private backgroundState;
40
41
  private conflict;
42
+ /**
43
+ * @description when the conflict was last checked. The panel doesn't update by itself, so it
44
+ * shows how old its answer is.
45
+ */
46
+ private conflictCheckedAt;
47
+ private retrying;
41
48
  constructor();
42
49
  connectedCallback(): void;
43
50
  private process;
@@ -61,6 +68,20 @@ export declare class JumooPipelineElement extends UmbLitElement {
61
68
  private onLastAction;
62
69
  render(): import("lit-html").TemplateResult<1>;
63
70
  private renderConflict;
71
+ /**
72
+ * @description only a conflict from creating this pipeline can be tried again from here -
73
+ * one from an existing pipeline has nothing to recreate.
74
+ * @returns true when the panel should offer to try again.
75
+ */
76
+ private canRetry;
77
+ /**
78
+ * @description a running holder that has stopped moving can be cleared, but only when the
79
+ * conflict came from creating this pipeline - that's the one we know how to try again.
80
+ * The holder is only there when the user can see it (its owner, or an admin).
81
+ * @param holder the holder's status.
82
+ * @returns true when the panel should offer to clear it.
83
+ */
84
+ private canClear;
64
85
  /**
65
86
  * @description the time worth showing for the holder: when it was queued, when it last
66
87
  * moved, how long it has been paused, or when it is due.
@@ -4,8 +4,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _JumooPipelineElement_instances, _JumooPipelineElement_onRetryConflict, _JumooPipelineElement_onClearConflict;
7
13
  import { css, customElement, html, nothing, property, state, } from '@umbraco-cms/backoffice/external/lit';
8
14
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
15
+ import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
9
16
  import { PipelineStatus, JUMOO_PROCESSING_CONTEXT, } from '@jumoo/processing';
10
17
  import { PipelineRunState } from '../api/index.js';
11
18
  /**
@@ -25,6 +32,12 @@ function conflictSuffix(status) {
25
32
  return '';
26
33
  }
27
34
  }
35
+ /**
36
+ * @description how long a running holder goes without moving before the conflict panel offers
37
+ * to clear it. A browser-driven run saves after every step, so one this quiet has most likely
38
+ * lost its browser.
39
+ */
40
+ const CLEAR_AFTER_IDLE_MS = 5 * 60 * 1000;
28
41
  /**
29
42
  * @property {string} processor - the processor to use for the pipeline
30
43
  * @property {string} strategy - the strategy to use for the pipeline
@@ -40,10 +53,12 @@ function conflictSuffix(status) {
40
53
  let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
41
54
  constructor() {
42
55
  super();
56
+ _JumooPipelineElement_instances.add(this);
43
57
  /**
44
58
  * @description - show debug information
45
59
  */
46
60
  this.debug = false;
61
+ this.retrying = false;
47
62
  this.consumeContext(JUMOO_PROCESSING_CONTEXT, (context) => {
48
63
  if (!context)
49
64
  return;
@@ -96,6 +111,7 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
96
111
  this.observe(this.context.conflict, (conflict) => {
97
112
  const isNew = conflict && !this.conflict;
98
113
  this.conflict = conflict;
114
+ this.conflictCheckedAt = conflict ? new Date() : undefined;
99
115
  if (isNew) {
100
116
  this.dispatchEvent(new CustomEvent('pipeline-conflict', {
101
117
  bubbles: true,
@@ -209,11 +225,69 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
209
225
  >
210
226
  </dt>
211
227
  <dd>${Math.round(holder.progress.percentage)}%</dd>`
228
+ : nothing}
229
+ ${this.conflictCheckedAt
230
+ ? html `<dt>
231
+ <umb-localize key="jumooProcConflict_checked"
232
+ >Checked</umb-localize
233
+ >
234
+ </dt>
235
+ <dd>
236
+ ${this.localize.date(this.conflictCheckedAt, {
237
+ timeStyle: 'medium',
238
+ })}
239
+ </dd>`
212
240
  : nothing}
213
241
  </dl>`
242
+ : nothing}
243
+ ${holder && this.canClear(holder)
244
+ ? html `<p>${this.localize.term('jumooProcConflict_stalled')}</p>`
245
+ : nothing}
246
+ ${this.canRetry()
247
+ ? html `<div class="actions">
248
+ <uui-button
249
+ look="secondary"
250
+ label=${this.localize.term('jumooProcConflict_tryAgain')}
251
+ .state=${this.retrying ? 'waiting' : undefined}
252
+ ?disabled=${this.retrying}
253
+ @click=${__classPrivateFieldGet(this, _JumooPipelineElement_instances, "m", _JumooPipelineElement_onRetryConflict)}></uui-button>
254
+ ${holder && this.canClear(holder)
255
+ ? html `<uui-button
256
+ look="primary"
257
+ color="warning"
258
+ label=${this.localize.term('jumooProcConflict_clear')}
259
+ ?disabled=${this.retrying}
260
+ @click=${__classPrivateFieldGet(this, _JumooPipelineElement_instances, "m", _JumooPipelineElement_onClearConflict)}></uui-button>`
261
+ : nothing}
262
+ </div>`
214
263
  : nothing}
215
264
  </div>`;
216
265
  }
266
+ /**
267
+ * @description only a conflict from creating this pipeline can be tried again from here -
268
+ * one from an existing pipeline has nothing to recreate.
269
+ * @returns true when the panel should offer to try again.
270
+ */
271
+ canRetry() {
272
+ return !this._pipelineId && !!this.processor && !!this.strategy;
273
+ }
274
+ /**
275
+ * @description a running holder that has stopped moving can be cleared, but only when the
276
+ * conflict came from creating this pipeline - that's the one we know how to try again.
277
+ * The holder is only there when the user can see it (its owner, or an admin).
278
+ * @param holder the holder's status.
279
+ * @returns true when the panel should offer to clear it.
280
+ */
281
+ canClear(holder) {
282
+ if (!this.canRetry())
283
+ return false;
284
+ if (holder.status !== PipelineRunState.RUNNING)
285
+ return false;
286
+ const lastActivity = holder.modified ?? holder.created;
287
+ if (!lastActivity)
288
+ return false;
289
+ return Date.now() - new Date(lastActivity).getTime() > CLEAR_AFTER_IDLE_MS;
290
+ }
217
291
  /**
218
292
  * @description the time worth showing for the holder: when it was queued, when it last
219
293
  * moved, how long it has been paused, or when it is due.
@@ -307,6 +381,43 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
307
381
  `;
308
382
  }
309
383
  };
384
+ _JumooPipelineElement_instances = new WeakSet();
385
+ _JumooPipelineElement_onRetryConflict =
386
+ /**
387
+ * @description tries the create again: starts if the other process has gone, otherwise the
388
+ * panel redraws with its latest status (which may now offer to clear it).
389
+ */
390
+ async function _JumooPipelineElement_onRetryConflict() {
391
+ if (!this.processor || !this.strategy)
392
+ return;
393
+ this.retrying = true;
394
+ try {
395
+ await this.context?.createPipeline(this.processor, this.strategy, this.setup);
396
+ }
397
+ finally {
398
+ this.retrying = false;
399
+ }
400
+ // an unchanged answer doesn't reach the conflict observer, so stamp it here too.
401
+ if (this.conflict)
402
+ this.conflictCheckedAt = new Date();
403
+ };
404
+ _JumooPipelineElement_onClearConflict = async function _JumooPipelineElement_onClearConflict() {
405
+ try {
406
+ await umbConfirmModal(this, {
407
+ headline: this.localize.term('jumooProcConflict_clearHeadline'),
408
+ content: this.localize.term('jumooProcConflict_clearConfirm'),
409
+ color: 'danger',
410
+ confirmLabel: this.localize.term('jumooProcConflict_clearConfirmLabel'),
411
+ });
412
+ }
413
+ catch {
414
+ return; // closed the dialog.
415
+ }
416
+ if (!this.processor || !this.strategy)
417
+ return;
418
+ await this.context?.clearConflictHolder();
419
+ await this.context?.createPipeline(this.processor, this.strategy, this.setup);
420
+ };
310
421
  JumooPipelineElement.styles = css `
311
422
  .wrapper,
312
423
  umb-extension-slot {
@@ -346,6 +457,11 @@ JumooPipelineElement.styles = css `
346
457
  .conflict dd {
347
458
  margin: 0;
348
459
  }
460
+
461
+ .conflict .actions {
462
+ display: flex;
463
+ gap: var(--uui-size-space-3);
464
+ }
349
465
  `;
350
466
  __decorate([
351
467
  property({ type: String })
@@ -383,6 +499,12 @@ __decorate([
383
499
  __decorate([
384
500
  state()
385
501
  ], JumooPipelineElement.prototype, "conflict", void 0);
502
+ __decorate([
503
+ state()
504
+ ], JumooPipelineElement.prototype, "conflictCheckedAt", void 0);
505
+ __decorate([
506
+ state()
507
+ ], JumooPipelineElement.prototype, "retrying", void 0);
386
508
  JumooPipelineElement = __decorate([
387
509
  customElement('jumoo-pipeline')
388
510
  ], JumooPipelineElement);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jumoo/processing",
3
3
  "licence": "custom",
4
- "version": "18.3.2",
4
+ "version": "18.3.3",
5
5
  "type": "module",
6
6
  "description": "Jumoo processing library",
7
7
  "exports": {
@@ -43,8 +43,8 @@
43
43
  "@umbraco-cms/backoffice": "18.0.1",
44
44
  "chalk": "^6.0.1",
45
45
  "cross-env": "^10.1.0",
46
- "eslint": "^10.13.0",
47
- "globals": "^17.13.0",
46
+ "eslint": "^10.14.0",
47
+ "globals": "^17.14.0",
48
48
  "node-fetch": "^3.3.2",
49
49
  "prettier": "^3.9.10",
50
50
  "typescript": "^6.0.3",