@lokalise/maestro-expert-tenant-lib 2.4.0 → 2.6.0

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/index.cjs CHANGED
@@ -258,6 +258,7 @@ var DEFAULT_SCHEDULED_TRIGGER_STEP_SETTINGS = {
258
258
  };
259
259
 
260
260
  // src/workflow/steps/aiMtTranslationStep.ts
261
+ var import_maestro_common4 = require("@lokalise/maestro-common");
261
262
  var import_zod4 = require("zod");
262
263
 
263
264
  // src/workflow/messages.ts
@@ -338,18 +339,18 @@ var AI_MT_TRANSLATION_STEP_FORM_SCHEMA = import_zod4.z.object({
338
339
  taskTitle: import_zod4.z.string().optional(),
339
340
  aiInstructions: import_zod4.z.string().optional(),
340
341
  tagKeysAfterClose: import_zod4.z.boolean(),
341
- tags: import_zod4.z.array(import_zod4.z.string()).optional(),
342
+ tagsToAddAfterClose: import_zod4.z.array(import_zod4.z.string()).optional(),
342
343
  customTranslationStatusIds: import_zod4.z.array(import_zod4.z.number()).optional(),
343
344
  hasCustomTranslationStatuses: import_zod4.z.boolean()
344
- }).superRefine(({ tagKeysAfterClose, tags }, context) => {
345
- if (tagKeysAfterClose && tags?.length === 0) {
345
+ }).superRefine(({ tagKeysAfterClose, tagsToAddAfterClose }, context) => {
346
+ if (tagKeysAfterClose && tagsToAddAfterClose?.length === 0) {
346
347
  context.addIssue({
347
348
  code: import_zod4.z.ZodIssueCode.custom,
348
349
  message: 'At least one tag must be added if "Tag keys after task is closed" is checked',
349
350
  path: ["tags"]
350
351
  });
351
352
  }
352
- if (!tagKeysAfterClose && tags && tags.length > 0) {
353
+ if (!tagKeysAfterClose && tagsToAddAfterClose && tagsToAddAfterClose.length > 0) {
353
354
  context.addIssue({
354
355
  code: import_zod4.z.ZodIssueCode.custom,
355
356
  message: 'One or more tags are set but "Tag keys after task is closed" is not checked',
@@ -372,9 +373,19 @@ var AI_MT_TRANSLATION_STEP_FORM_SCHEMA = import_zod4.z.object({
372
373
  });
373
374
  }
374
375
  });
375
- var AI_MT_TRANSLATION_STEP_SETTINGS_SCHEMA = CREATE_TASK_STEP_SETTINGS_SCHEMA.extend({
376
+ var AI_MT_TRANSLATION_STEP_SETTINGS_SCHEMA = import_maestro_common4.WORKFLOW_LAYOUT_STEP_SETTINGS.merge(
377
+ import_zod4.z.object(AI_MT_TRANSLATION_STEP_FORM_SCHEMA._def.schema._def.schema.shape)
378
+ ).extend({
376
379
  stepType: import_zod4.z.literal("ai_mt_translation_step"),
377
- taskType: import_zod4.z.literal("translation")
380
+ taskType: import_zod4.z.literal("translation"),
381
+ stepTitle: import_zod4.z.string().min(1),
382
+ translationEngine: TRANSLATION_ENGINE,
383
+ taskTitle: import_zod4.z.string().optional(),
384
+ aiInstructions: import_zod4.z.string().optional(),
385
+ tagKeysAfterClose: import_zod4.z.boolean(),
386
+ tagsToAddAfterClose: import_zod4.z.array(import_zod4.z.string()).optional(),
387
+ customTranslationStatusIds: import_zod4.z.array(import_zod4.z.number()).optional(),
388
+ hasCustomTranslationStatuses: import_zod4.z.boolean()
378
389
  });
379
390
  var DEFAULT_AI_MT_TRANSLATION_STEP_SETTINGS = {
380
391
  stepType: "ai_mt_translation_step",
@@ -384,7 +395,7 @@ var DEFAULT_AI_MT_TRANSLATION_STEP_SETTINGS = {
384
395
  translationEngine: "ai",
385
396
  taskTitle: void 0,
386
397
  tagKeysAfterClose: false,
387
- tags: [],
398
+ tagsToAddAfterClose: [],
388
399
  customTranslationStatusIds: [],
389
400
  hasCustomTranslationStatuses: false
390
401
  };
@@ -508,10 +519,10 @@ var DEFAULT_REVIEW_TASK_STEP_SETTINGS = {
508
519
  };
509
520
 
510
521
  // src/workflow/steps/clearTranslationsStep.ts
511
- var import_maestro_common4 = require("@lokalise/maestro-common");
522
+ var import_maestro_common5 = require("@lokalise/maestro-common");
512
523
  var import_zod7 = require("zod");
513
524
  var CLEAR_TRANSLATIONS_STEP_FORM_SCHEMA = import_zod7.z.object({});
514
- var CLEAR_TRANSLATIONS_STEP_SETTINGS_SCHEMA = import_maestro_common4.WORKFLOW_LAYOUT_STEP_SETTINGS.merge(
525
+ var CLEAR_TRANSLATIONS_STEP_SETTINGS_SCHEMA = import_maestro_common5.WORKFLOW_LAYOUT_STEP_SETTINGS.merge(
515
526
  CLEAR_TRANSLATIONS_STEP_FORM_SCHEMA
516
527
  ).extend({
517
528
  stepType: import_zod7.z.literal("clear_translations_step")
@@ -521,10 +532,10 @@ var DEFAULT_CLEAR_TRANSLATIONS_STEP_SETTINGS = {
521
532
  };
522
533
 
523
534
  // src/workflow/steps/endStep.ts
524
- var import_maestro_common5 = require("@lokalise/maestro-common");
535
+ var import_maestro_common6 = require("@lokalise/maestro-common");
525
536
  var import_zod8 = require("zod");
526
537
  var END_STEP_FORM_SCHEMA = import_zod8.z.object({});
527
- var END_STEP_SETTINGS_SCHEMA = import_maestro_common5.WORKFLOW_LAYOUT_STEP_SETTINGS.merge(
538
+ var END_STEP_SETTINGS_SCHEMA = import_maestro_common6.WORKFLOW_LAYOUT_STEP_SETTINGS.merge(
528
539
  END_STEP_FORM_SCHEMA
529
540
  ).extend({
530
541
  stepType: import_zod8.z.literal("end_step")
@@ -544,23 +555,35 @@ var STEP_TYPES = [
544
555
  "ai_mt_translation_step"
545
556
  ];
546
557
 
547
- // src/templates/resources/ai-mt-translation-task.template.ts
548
- var AI_MT_TRANSLATION_TASK_TEMPLATE = {
549
- id: "aiMtTranslationTask",
550
- title: "AI/MT Translation Task",
551
- summary: "A workflow for automatic translation using AI",
552
- description: "A workflow for automatic translation using AI",
558
+ // src/templates/resources/clear-translations-mt-ai-review-task.template.ts
559
+ var CLEAR_TRANSLATIONS_MT_AI_REVIEW_TASK_TEMPLATE = {
560
+ id: "clearTranslationsMtAiReviewTask",
561
+ title: "Clear translations \u2192 MT/AI translation \u2192 review task",
562
+ summary: "Clear translations, apply MT/AI translation, and create a review task",
563
+ description: "This template sets up a workflow that clears existing translations, applies MT/AI translation, and creates a review task for human verification.",
553
564
  layout: {
554
565
  initial: "TriggerStep",
555
566
  states: {
556
567
  TriggerStep: {
557
568
  on: {
558
569
  WorkflowTriggerEvent: {
559
- target: "AiMtTranslationStep",
570
+ target: "ClearTranslationsStep",
560
571
  actions: [{ type: "storeWorkflowTriggerEventScope" }]
561
572
  }
562
573
  }
563
574
  },
575
+ ClearTranslationsStep: {
576
+ entry: [
577
+ {
578
+ type: "clearTranslationsAction"
579
+ }
580
+ ],
581
+ on: {
582
+ TranslationsClearedEvent: {
583
+ target: "AiMtTranslationStep"
584
+ }
585
+ }
586
+ },
564
587
  AiMtTranslationStep: {
565
588
  entry: [
566
589
  {
@@ -571,6 +594,27 @@ var AI_MT_TRANSLATION_TASK_TEMPLATE = {
571
594
  }
572
595
  ],
573
596
  on: {
597
+ TaskCreatedEvent: {
598
+ actions: [{ type: "storeCreatedTaskId" }]
599
+ },
600
+ TaskClosedEvent: {
601
+ target: "ReviewTaskStep"
602
+ }
603
+ }
604
+ },
605
+ ReviewTaskStep: {
606
+ entry: [
607
+ {
608
+ type: "createTaskAction",
609
+ params: {
610
+ type: "review"
611
+ }
612
+ }
613
+ ],
614
+ on: {
615
+ TaskCreatedEvent: {
616
+ actions: [{ type: "storeCreatedTaskId" }]
617
+ },
574
618
  TaskClosedEvent: {
575
619
  target: "EndStep"
576
620
  }
@@ -583,10 +627,179 @@ var AI_MT_TRANSLATION_TASK_TEMPLATE = {
583
627
  },
584
628
  settings: {
585
629
  TriggerStep: DEFAULT_SCHEDULED_TRIGGER_STEP_SETTINGS,
630
+ ClearTranslationsStep: DEFAULT_CLEAR_TRANSLATIONS_STEP_SETTINGS,
586
631
  AiMtTranslationStep: DEFAULT_AI_MT_TRANSLATION_STEP_SETTINGS,
632
+ ReviewTaskStep: DEFAULT_REVIEW_TASK_STEP_SETTINGS,
587
633
  EndStep: DEFAULT_END_STEP_SETTINGS
588
634
  },
589
- sort: ["TriggerStep", "AiMtTranslationStep", "EndStep"]
635
+ sort: [
636
+ "TriggerStep",
637
+ "ClearTranslationsStep",
638
+ "AiMtTranslationStep",
639
+ "ReviewTaskStep",
640
+ "EndStep"
641
+ ]
642
+ };
643
+
644
+ // src/templates/resources/clear-translations-mt-ai-task.template.ts
645
+ var CLEAR_TRANSLATIONS_MT_AI_TASK_TEMPLATE = {
646
+ id: "clearTranslationsMtAiTask",
647
+ title: "Clear translations \u2192 MT/AI translation",
648
+ summary: "Clear existing translations before applying MT/AI translation",
649
+ description: "This template sets up a workflow that first clears existing translations and then applies MT/AI translation.",
650
+ layout: {
651
+ initial: "TriggerStep",
652
+ states: {
653
+ TriggerStep: {
654
+ on: {
655
+ WorkflowTriggerEvent: {
656
+ target: "ClearTranslationsStep",
657
+ actions: [{ type: "storeWorkflowTriggerEventScope" }]
658
+ }
659
+ }
660
+ },
661
+ ClearTranslationsStep: {
662
+ entry: [
663
+ {
664
+ type: "clearTranslationsAction"
665
+ }
666
+ ],
667
+ on: {
668
+ TranslationsClearedEvent: {
669
+ target: "AiMtTranslationStep"
670
+ }
671
+ }
672
+ },
673
+ AiMtTranslationStep: {
674
+ entry: [
675
+ {
676
+ type: "createTaskAction",
677
+ params: {
678
+ type: "translation"
679
+ }
680
+ }
681
+ ],
682
+ on: {
683
+ TaskCreatedEvent: {
684
+ actions: [{ type: "storeCreatedTaskId" }]
685
+ },
686
+ TaskClosedEvent: {
687
+ target: "EndStep"
688
+ }
689
+ }
690
+ },
691
+ EndStep: {
692
+ type: "final"
693
+ }
694
+ }
695
+ },
696
+ settings: {
697
+ TriggerStep: DEFAULT_SCHEDULED_TRIGGER_STEP_SETTINGS,
698
+ ClearTranslationsStep: DEFAULT_CLEAR_TRANSLATIONS_STEP_SETTINGS,
699
+ AiMtTranslationStep: DEFAULT_AI_MT_TRANSLATION_STEP_SETTINGS,
700
+ EndStep: DEFAULT_END_STEP_SETTINGS
701
+ },
702
+ sort: ["TriggerStep", "ClearTranslationsStep", "AiMtTranslationStep", "EndStep"]
703
+ };
704
+
705
+ // src/templates/resources/clear-translations-tm-mt-ai-review-task.template.ts
706
+ var CLEAR_TRANSLATIONS_TM_MT_AI_REVIEW_TASK_TEMPLATE = {
707
+ id: "clearTranslationsTmMtAiReviewTask",
708
+ title: "Clear translations \u2192 TM \u2192 MT/AI translation \u2192 review task",
709
+ summary: "Clear translations, apply TM and MT/AI translation, followed by a review task",
710
+ description: "This template sets up a workflow that clears existing translations, applies Translation Memory, then MT/AI translation, and creates a review task for human verification.",
711
+ layout: {
712
+ initial: "TriggerStep",
713
+ states: {
714
+ TriggerStep: {
715
+ on: {
716
+ WorkflowTriggerEvent: {
717
+ target: "ClearTranslationsStep",
718
+ actions: [{ type: "storeWorkflowTriggerEventScope" }]
719
+ }
720
+ }
721
+ },
722
+ ClearTranslationsStep: {
723
+ entry: [
724
+ {
725
+ type: "clearTranslationsAction"
726
+ }
727
+ ],
728
+ on: {
729
+ TranslationsClearedEvent: {
730
+ target: "ApplyTmStep"
731
+ }
732
+ }
733
+ },
734
+ ApplyTmStep: {
735
+ entry: [
736
+ {
737
+ type: "applyTmAction"
738
+ }
739
+ ],
740
+ on: {
741
+ TmAppliedEvent: {
742
+ target: "AiMtTranslationStep"
743
+ }
744
+ }
745
+ },
746
+ AiMtTranslationStep: {
747
+ entry: [
748
+ {
749
+ type: "createTaskAction",
750
+ params: {
751
+ type: "translation"
752
+ }
753
+ }
754
+ ],
755
+ on: {
756
+ TaskCreatedEvent: {
757
+ actions: [{ type: "storeCreatedTaskId" }]
758
+ },
759
+ TaskClosedEvent: {
760
+ target: "ReviewTaskStep"
761
+ }
762
+ }
763
+ },
764
+ ReviewTaskStep: {
765
+ entry: [
766
+ {
767
+ type: "createTaskAction",
768
+ params: {
769
+ type: "review"
770
+ }
771
+ }
772
+ ],
773
+ on: {
774
+ TaskCreatedEvent: {
775
+ actions: [{ type: "storeCreatedTaskId" }]
776
+ },
777
+ TaskClosedEvent: {
778
+ target: "EndStep"
779
+ }
780
+ }
781
+ },
782
+ EndStep: {
783
+ type: "final"
784
+ }
785
+ }
786
+ },
787
+ settings: {
788
+ TriggerStep: DEFAULT_SCHEDULED_TRIGGER_STEP_SETTINGS,
789
+ ClearTranslationsStep: DEFAULT_CLEAR_TRANSLATIONS_STEP_SETTINGS,
790
+ ApplyTmStep: DEFAULT_APPLY_TM_STEP_SETTINGS,
791
+ AiMtTranslationStep: DEFAULT_AI_MT_TRANSLATION_STEP_SETTINGS,
792
+ ReviewTaskStep: DEFAULT_REVIEW_TASK_STEP_SETTINGS,
793
+ EndStep: DEFAULT_END_STEP_SETTINGS
794
+ },
795
+ sort: [
796
+ "TriggerStep",
797
+ "ClearTranslationsStep",
798
+ "ApplyTmStep",
799
+ "AiMtTranslationStep",
800
+ "ReviewTaskStep",
801
+ "EndStep"
802
+ ]
590
803
  };
591
804
 
592
805
  // src/templates/resources/clear-translations-tm-templates.ts
@@ -1229,10 +1442,12 @@ var TEMPLATE_IDS = [
1229
1442
  "reviewTranslateTask",
1230
1443
  "translateReviewReviewTask",
1231
1444
  "reviewTranslateReviewTask",
1232
- "aiMtTranslationTask",
1233
1445
  "clearTranslationsTm",
1234
1446
  "clearTranslationsTmTranslateTask",
1235
- "clearTranslationsTmTranslateReviewTask"
1447
+ "clearTranslationsTmTranslateReviewTask",
1448
+ "clearTranslationsMtAiTask",
1449
+ "clearTranslationsMtAiReviewTask",
1450
+ "clearTranslationsTmMtAiReviewTask"
1236
1451
  ];
1237
1452
  var buildTemplate = /* @__PURE__ */ __name((internalTemplate) => {
1238
1453
  const layoutTranslator = new LayoutTranslator();
@@ -1254,7 +1469,11 @@ var TEMPLATES = {
1254
1469
  translateReviewReviewTask: buildTemplate(TRANSLATE_REVIEW_REVIEW_TASK_TEMPLATE),
1255
1470
  reviewTranslateTask: buildTemplate(REVIEW_TRANSLATE_TASK_TEMPLATE),
1256
1471
  reviewTranslateReviewTask: buildTemplate(REVIEW_TRANSLATE_REVIEW_TASK_TEMPLATE),
1257
- aiMtTranslationTask: buildTemplate(AI_MT_TRANSLATION_TASK_TEMPLATE)
1472
+ clearTranslationsMtAiTask: buildTemplate(CLEAR_TRANSLATIONS_MT_AI_TASK_TEMPLATE),
1473
+ clearTranslationsMtAiReviewTask: buildTemplate(CLEAR_TRANSLATIONS_MT_AI_REVIEW_TASK_TEMPLATE),
1474
+ clearTranslationsTmMtAiReviewTask: buildTemplate(
1475
+ CLEAR_TRANSLATIONS_TM_MT_AI_REVIEW_TASK_TEMPLATE
1476
+ )
1258
1477
  };
1259
1478
 
1260
1479
  // src/apiContract/schemas.ts