77
88
99Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
10- exports . ApplicationError = exports . APPLICATION_ERROR_METADATA = void 0 ;
10+ exports . ApplicationError = exports . APPLICATION_ERROR_RECOVERY_IDS = exports . APPLICATION_ERROR_METADATA = void 0 ;
1111exports . toApplicationError = toApplicationError ;
1212const application_error_1 = __nccwpck_require__ ( 7790 ) ;
1313const application_error_context_1 = __nccwpck_require__ ( 4034 ) ;
1414var application_error_2 = __nccwpck_require__ ( 7790 ) ;
1515Object . defineProperty ( exports , "APPLICATION_ERROR_METADATA" , ( { enumerable : true , get : function ( ) { return application_error_2 . APPLICATION_ERROR_METADATA ; } } ) ) ;
16+ Object . defineProperty ( exports , "APPLICATION_ERROR_RECOVERY_IDS" , ( { enumerable : true , get : function ( ) { return application_error_2 . APPLICATION_ERROR_RECOVERY_IDS ; } } ) ) ;
1617/** Creates a semantic error and owns correlation identity outside the pure model. */
1718class ApplicationError extends application_error_1 . ApplicationError {
1819 constructor ( code , message , options = { } ) {
@@ -4528,8 +4529,16 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
45284529} ;
45294530var _ApplicationError_cause ;
45304531Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
4531- exports . ApplicationError = exports . APPLICATION_ERROR_METADATA = void 0 ;
4532+ exports . ApplicationError = exports . APPLICATION_ERROR_METADATA = exports . APPLICATION_ERROR_RECOVERY_IDS = void 0 ;
45324533exports . isApplicationErrorCorrelationId = isApplicationErrorCorrelationId ;
4534+ exports . APPLICATION_ERROR_RECOVERY_IDS = Object . freeze ( [
4535+ 'pull-request-link-restored' ,
4536+ 'pull-request-link-base-retained' ,
4537+ 'pull-request-link-reference-retained' ,
4538+ 'pull-request-link-base-and-reference-retained' ,
4539+ 'managed-branch-enrichment-failed' ,
4540+ 'inactivity-explanation-failed' ,
4541+ ] ) ;
45334542const PRESERVED_STATE = 'Existing persisted state and completed external effects were preserved.' ;
45344543const UNCHANGED_STATE = 'No new state or external effect was created.' ;
45354544exports . APPLICATION_ERROR_METADATA = {
@@ -4677,10 +4686,11 @@ class ApplicationError extends Error {
46774686 this . code = code ;
46784687 this . kind = metadata . kind ;
46794688 this . retryable = options . retryable ?? metadata . retryable ;
4680- this . impact = options . impact ?? metadata . impact ;
4681- this . action = options . action ?? metadata . action ;
4682- this . retainedState = options . retainedState ?? metadata . retainedState ;
4689+ this . impact = metadata . impact ;
4690+ this . action = metadata . action ;
4691+ this . retainedState = metadata . retainedState ;
46834692 this . correlationId = correlationId ;
4693+ this . recovery = normalizeApplicationErrorRecovery ( options . recovery ) ;
46844694 __classPrivateFieldSet ( this , _ApplicationError_cause , options . cause , "f" ) ;
46854695 }
46864696 toJSON ( ) {
@@ -4694,11 +4704,49 @@ class ApplicationError extends Error {
46944704 action : this . action ,
46954705 retainedState : this . retainedState ,
46964706 correlationId : this . correlationId ,
4707+ ...( this . recovery ? { recovery : this . recovery } : { } ) ,
46974708 } ;
46984709 }
46994710}
47004711exports . ApplicationError = ApplicationError ;
47014712_ApplicationError_cause = new WeakMap ( ) ;
4713+ const RECOVERY_VARIABLE_KEYS = Object . freeze ( {
4714+ 'pull-request-link-restored' : Object . freeze ( [ ] ) ,
4715+ 'pull-request-link-base-retained' : Object . freeze ( [ ] ) ,
4716+ 'pull-request-link-reference-retained' : Object . freeze ( [ ] ) ,
4717+ 'pull-request-link-base-and-reference-retained' : Object . freeze ( [ ] ) ,
4718+ 'managed-branch-enrichment-failed' : Object . freeze ( [ 'branchName' ] ) ,
4719+ 'inactivity-explanation-failed' : Object . freeze ( [ 'issueNumber' ] ) ,
4720+ } ) ;
4721+ function normalizeApplicationErrorRecovery ( recovery ) {
4722+ if ( ! recovery )
4723+ return undefined ;
4724+ if ( ! exports . APPLICATION_ERROR_RECOVERY_IDS . includes ( recovery . id ) ) {
4725+ throw new TypeError ( 'Application error recovery ID is invalid.' ) ;
4726+ }
4727+ const variables = recovery . variables ;
4728+ const actualKeys = Object . keys ( variables ) . sort ( ) ;
4729+ const expectedKeys = [ ...RECOVERY_VARIABLE_KEYS [ recovery . id ] ] . sort ( ) ;
4730+ if ( actualKeys . length !== expectedKeys . length
4731+ || actualKeys . some ( ( key , index ) => key !== expectedKeys [ index ] ) ) {
4732+ throw new TypeError ( `Application error recovery variables are invalid for ${ recovery . id } .` ) ;
4733+ }
4734+ if ( recovery . id === 'managed-branch-enrichment-failed'
4735+ && ( typeof variables . branchName !== 'string'
4736+ || ! / ^ [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . _ / - ] { 0 , 254 } $ / u. test ( variables . branchName ) ) ) {
4737+ throw new TypeError ( 'Application error recovery branch name is invalid.' ) ;
4738+ }
4739+ if ( recovery . id === 'inactivity-explanation-failed'
4740+ && ( typeof variables . issueNumber !== 'number'
4741+ || ! Number . isSafeInteger ( variables . issueNumber )
4742+ || variables . issueNumber < 1 ) ) {
4743+ throw new TypeError ( 'Application error recovery issue number is invalid.' ) ;
4744+ }
4745+ return Object . freeze ( {
4746+ id : recovery . id ,
4747+ variables : Object . freeze ( { ...variables } ) ,
4748+ } ) ;
4749+ }
47024750
47034751
47044752/***/ } ) ,
@@ -5338,7 +5386,7 @@ exports.renderCatalogMessage = renderCatalogMessage;
53385386exports . catalogPlaceholders = catalogPlaceholders ;
53395387exports . catalogPluralCategories = catalogPluralCategories ;
53405388const locale_1 = __nccwpck_require__ ( 5386 ) ;
5341- exports . MESSAGE_CATALOG_VERSION = '1 ' ;
5389+ exports . MESSAGE_CATALOG_VERSION = '2 ' ;
53425390exports . CATALOG_PLURAL_CATEGORIES = Object . freeze ( [
53435391 'zero' ,
53445392 'one' ,
0 commit comments