@masterteam/work-center 0.0.81 → 0.0.82

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.
@@ -3142,48 +3142,18 @@ class WorkCenterFormValidationError extends Error {
3142
3142
  }
3143
3143
  }
3144
3144
 
3145
- const FORM_VALIDATION_WARNINGS = 'FormValidationWarnings';
3146
- /** Handles the process action validation handshake owned by Work Center. */
3145
+ /**
3146
+ * Renders what a process action's validation has to say, before it runs and
3147
+ * after it fails.
3148
+ *
3149
+ * Actions do not negotiate over warnings. A Work Center action is one HTTP
3150
+ * request: the `process-submit/validate` pre-flight asks about non-blocking
3151
+ * failures up front (`confirmWarnings`), and whatever the action itself answers
3152
+ * is final — a failure is reported, never acknowledged and retried.
3153
+ */
3147
3154
  class WorkCenterActionValidationHandler {
3148
3155
  modal = inject(ModalService);
3149
- runner = inject(RuntimeActionRunner);
3150
3156
  transloco = inject(TranslocoService);
3151
- async recover(action, error, submittedPayload, defaultAfterSuccess,
3152
- /**
3153
- * The user already answered this action's warning prompt in the
3154
- * `process-submit/validate` pre-flight, against the same values. The
3155
- * backend still raises them, because the first request carried no token —
3156
- * so complete the handshake silently rather than asking again.
3157
- */
3158
- warningsAlreadyAcknowledged = false) {
3159
- const validationError = readProcessActionValidationError(error);
3160
- if (validationError?.kind !== FORM_VALIDATION_WARNINGS ||
3161
- !validationError.requiresAcknowledgement ||
3162
- !validationError.validationWarningsToken) {
3163
- return null;
3164
- }
3165
- const confirmed = warningsAlreadyAcknowledged ||
3166
- (await this.confirmWarnings(this.resolveValidationMessages(validationError)));
3167
- if (!confirmed) {
3168
- return {
3169
- status: 'cancelled',
3170
- actionKey: action.actionKey,
3171
- afterSuccess: null,
3172
- };
3173
- }
3174
- const retryPayload = {
3175
- ...(submittedPayload ?? {}),
3176
- validationWarningsToken: validationError.validationWarningsToken,
3177
- };
3178
- // This descriptor is intentionally ephemeral. A later action rebuilds its
3179
- // payload from the current form and therefore cannot reuse this token.
3180
- return this.runner.execute({
3181
- ...action,
3182
- needConfirmation: false,
3183
- payloadKeys: Object.keys(retryPayload),
3184
- payloadTemplate: retryPayload,
3185
- }, { defaultAfterSuccess, silent: true });
3186
- }
3187
3157
  /**
3188
3158
  * One entry per failing rule, so the footer can list them instead of
3189
3159
  * rendering one newline-joined blob. A single-entry array is the normal
@@ -3222,8 +3192,10 @@ class WorkCenterActionValidationHandler {
3222
3192
  return messages;
3223
3193
  }
3224
3194
  /**
3225
- * Shared by the backend-driven acknowledgement handshake above and by the
3226
- * `process-submit/validate` pre-flight in `WorkCenterActionFormValidator`.
3195
+ * The one place a Work Center action prompts about warnings: the
3196
+ * `process-submit/validate` pre-flight in `WorkCenterActionFormValidator`,
3197
+ * before the action runs. Nothing on the action's own response path opens
3198
+ * this dialog.
3227
3199
  *
3228
3200
  * Uses the client form's own warnings dialog so an approver sees the exact
3229
3201
  * same prompt the normal submit path raises — same layout, same wording
@@ -3271,8 +3243,6 @@ function readProcessActionValidationError(error) {
3271
3243
  : [];
3272
3244
  return {
3273
3245
  kind,
3274
- requiresAcknowledgement: details?.['requiresAcknowledgement'] === true,
3275
- validationWarningsToken: readNonEmptyString$1(details?.['validationWarningsToken']),
3276
3246
  message: readNonEmptyString$1(errors?.['message']),
3277
3247
  results,
3278
3248
  };
@@ -3319,10 +3289,7 @@ function readNonEmptyString$1(value) {
3319
3289
  return normalized.length ? normalized : null;
3320
3290
  }
3321
3291
 
3322
- const PROCEED = {
3323
- status: 'proceed',
3324
- warningsAcknowledged: false,
3325
- };
3292
+ const PROCEED = { status: 'proceed' };
3326
3293
  /** The payload key carrying the edited client-form values. */
3327
3294
  const FORM_VALUES_PAYLOAD_KEY = 'values';
3328
3295
  /**
@@ -3335,9 +3302,9 @@ const FORM_VALUES_PAYLOAD_KEY = 'values';
3335
3302
  * client-form submit ceremony — blocking failures stop the action, warnings
3336
3303
  * raise the acknowledge-and-continue prompt — without submitting anything.
3337
3304
  *
3338
- * It is advisory only. The action endpoint stays authoritative, and the
3339
- * backend-driven `FormValidationWarnings` handshake in
3340
- * `WorkCenterActionValidationHandler` keeps working untouched on top of it.
3305
+ * It is advisory only the action endpoint stays authoritative but it is the
3306
+ * single place a Work Center action ever asks about warnings. Nothing is
3307
+ * negotiated afterwards: the action runs once and its answer stands.
3341
3308
  */
3342
3309
  class WorkCenterActionFormValidator {
3343
3310
  api = inject(ClientFormApiService);
@@ -3377,9 +3344,7 @@ class WorkCenterActionFormValidator {
3377
3344
  return PROCEED;
3378
3345
  }
3379
3346
  const confirmed = await this.warnings.confirmWarnings(this.resolveMessages(failures));
3380
- return confirmed
3381
- ? { status: 'proceed', warningsAcknowledged: true }
3382
- : { status: 'cancelled' };
3347
+ return confirmed ? PROCEED : { status: 'cancelled' };
3383
3348
  }
3384
3349
  async runValidation(context, fields) {
3385
3350
  const response = await firstValueFrom(this.api
@@ -3460,12 +3425,19 @@ function readNonEmptyString(value) {
3460
3425
  return normalized.length ? normalized : null;
3461
3426
  }
3462
3427
 
3463
- /** Executes Work Center actions while preserving form payloads for validation retries. */
3428
+ /**
3429
+ * Runs a Work Center footer action as **one** HTTP request.
3430
+ *
3431
+ * Everything negotiable happens before that request: the
3432
+ * `process-submit/validate` pre-flight blocks the action or takes the
3433
+ * acknowledgement, then the reason/note dialog collects its fields. Whatever
3434
+ * the action endpoint answers is final — the footer refreshes on success or
3435
+ * lists the failure.
3436
+ */
3464
3437
  class WorkCenterRuntimeActionExecutor {
3465
3438
  runner = inject(RuntimeActionRunner);
3466
3439
  actionContext = inject(RuntimeActionContextStore);
3467
3440
  modal = inject(ModalService);
3468
- validation = inject(WorkCenterActionValidationHandler);
3469
3441
  formValidation = inject(WorkCenterActionFormValidator);
3470
3442
  confirmDialogClass = inject(RUNTIME_ACTION_CONFIRM_DIALOG, {
3471
3443
  optional: true,
@@ -3490,31 +3462,20 @@ class WorkCenterRuntimeActionExecutor {
3490
3462
  error: preflight.error,
3491
3463
  };
3492
3464
  }
3493
- const warningsAcknowledged = preflight.warningsAcknowledged;
3494
3465
  if (action.needConfirmation &&
3495
3466
  hasActionFormFields(action) &&
3496
3467
  this.confirmDialogClass) {
3497
- return this.executeFormAction(action, defaultAfterSuccess, warningsAcknowledged);
3468
+ return this.executeFormAction(action, defaultAfterSuccess);
3498
3469
  }
3499
- let submittedPayload;
3500
- let result = await this.runner.execute(action, {
3470
+ return this.runner.execute(action, {
3501
3471
  defaultAfterSuccess,
3502
3472
  silent: true,
3503
3473
  externalPayloadResolvers: {
3504
3474
  values: () => this.actionContext.resolveFormValues(),
3505
3475
  },
3506
- transformPayload: (payload) => {
3507
- submittedPayload = payload;
3508
- return payload;
3509
- },
3510
3476
  });
3511
- if (result.status === 'error') {
3512
- result =
3513
- (await this.validation.recover(action, result.error, submittedPayload, defaultAfterSuccess, warningsAcknowledged)) ?? result;
3514
- }
3515
- return result;
3516
3477
  }
3517
- executeFormAction(action, defaultAfterSuccess, warningsAcknowledged) {
3478
+ executeFormAction(action, defaultAfterSuccess) {
3518
3479
  return new Promise((resolve) => {
3519
3480
  let pendingRun = null;
3520
3481
  let finalResult = null;
@@ -3525,27 +3486,19 @@ class WorkCenterRuntimeActionExecutor {
3525
3486
  inputValues: {
3526
3487
  action,
3527
3488
  onSubmit: async (formValue) => {
3528
- const submittedPayload = buildActionPayload(action, formValue, {
3489
+ const executablePayload = buildActionPayload(action, formValue, {
3529
3490
  values: () => this.actionContext.resolveFormValues(),
3530
- });
3531
- const executablePayload = submittedPayload ?? {};
3491
+ }) ?? {};
3532
3492
  const executableAction = {
3533
3493
  ...action,
3534
3494
  needConfirmation: false,
3535
3495
  payloadKeys: Object.keys(executablePayload),
3536
3496
  payloadTemplate: executablePayload,
3537
3497
  };
3538
- pendingRun = (async () => {
3539
- let result = await this.runner.execute(executableAction, {
3540
- defaultAfterSuccess,
3541
- silent: true,
3542
- });
3543
- if (result.status === 'error') {
3544
- result =
3545
- (await this.validation.recover(action, result.error, submittedPayload, defaultAfterSuccess, warningsAcknowledged)) ?? result;
3546
- }
3547
- return result;
3548
- })();
3498
+ pendingRun = this.runner.execute(executableAction, {
3499
+ defaultAfterSuccess,
3500
+ silent: true,
3501
+ });
3549
3502
  finalResult = await pendingRun;
3550
3503
  // Every backend outcome leaves the action dialog. The footer then
3551
3504
  // refreshes on success or displays the actionable validation error.