UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

1 lines 5.36 kB
{"version":3,"sources":["../../../packages/core/workflow/persistent-work-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,aAAK,kBAAkB,GAAG,GAAG,CAAC;AAC9B,aAAK,eAAe,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,8BAAsB,kBAAkB,CAAC,QAAQ,SAAS,yBAAyB,CAAC,eAAe,EAAE,kBAAkB,CAAC;IAsBjG,IAAI,EAAE,MAAM;IArB/B;;OAEG;IACI,EAAE,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACI,MAAM,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACI,KAAK,EAAE,uBAAuB,CAAsC;IAE3E;;;;OAIG;gBACgB,IAAI,EAAE,MAAM;IAE/B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAEtC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IAE7D;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IAEvD;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IAE9D;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;CAC7C","file":"persistent-work-item.d.ts","sourcesContent":["import { Observable } from 'rxjs';\r\nimport { PersistentWorkItemState } from './persistent-work-item-state';\r\nimport { PersistentWorkflowContext } from './persistent-workflow-context';\r\n\r\ntype PersistentDataType = any;\r\ntype TransitDataType = any;\r\n\r\n/**\r\n * Abstract class of work item to build a work flow. The sequence of handlers called within\r\n * the work item.\r\n *\r\n * [Standard sequence]\r\n * The workflow has been completed within single worker instance. If there is an error the\r\n * sequence stops at the error.\r\n *\r\n * 1) init() => void.\r\n * 2) preValidate() => Observable. (state === PersistentWorkItemState.PreValidating)\r\n * 3) apply() => Observable.\r\n * 4) postValidate() => Observable.\r\n * 5) finalize() => void.\r\n *\r\n * [Restore the work item]\r\n * When user closed the browser but completion of apply() was not undetermined, restoration of\r\n * work item will be processed.\r\n *\r\n * If preValidate() updates applyState to 'PersistentWorkItemApplyState.Required', call apply() again.\r\n * 1) preValidate() => Observable. (state === PersistentWorkItemState.PreValidating)\r\n * 2) apply() => Observable.\r\n * 3) postValidate() => Observable.\r\n * 4) finalize() => void.\r\n *\r\n * If preValidate() updates applyState to 'PersistentWorkItemApplyState.Skip', skip apply().\r\n * 1) preValidate() => Observable. (state === PersistentWorkItemState.PreValidating)\r\n * 2) postValidate() => Observable.\r\n * 3) finalize() => void.\r\n *\r\n * When apply() was already succeeded state, it starts from postValidate() call.\r\n *\r\n * 1) postValidate() => Observable.\r\n * 2) finalize() => void.\r\n *\r\n */\r\nexport abstract class PersistentWorkItem<TContext extends PersistentWorkflowContext<TransitDataType, PersistentDataType>> {\r\n /**\r\n * The identification of work item in the workflow.\r\n */\r\n public id: number;\r\n\r\n /**\r\n * The next identification of work item. This value can be update dynamically to switch the work item\r\n * instead of single sequence.\r\n */\r\n public nextId: number;\r\n\r\n /**\r\n * The state of work item. This value is maintained by the workflow runner, so don't modify it.\r\n */\r\n public state: PersistentWorkItemState = PersistentWorkItemState.NotStarted;\r\n\r\n /**\r\n * Initializes a new instance of the PersistentWorkItem class.\r\n *\r\n * @param name the name of work item.\r\n */\r\n constructor(public name: string) { }\r\n\r\n /**\r\n * Initializes the transit data in the context before processing apply() call.\r\n * Update the persistent data just before calling apply().\r\n *\r\n * @param context the workflow context.\r\n */\r\n abstract init(context: TContext): void;\r\n\r\n /**\r\n * The function is called after init() call and before apply() call.\r\n *\r\n * Pre-validation can determine to skip 'apply()' call if not required, set context.applyState to 'Skip'.\r\n *\r\n * Two states of work item are possible:\r\n * - PersistentWorkItemState.PreValidatingByRestore\r\n * pre-validation is called by restore operation.\r\n * - PersistentWorkItemState.PreValidating\r\n * pre-validation is called in normal sequence.\r\n *\r\n * @param context the workflow context.\r\n * @returns Observable<TContext> the observable to execute.\r\n */\r\n abstract preValidate(context: TContext): Observable<TContext>;\r\n\r\n /**\r\n * Apply the change.\r\n *\r\n * @param context the workflow context.\r\n * @returns Observable<TContext> the observable to execute.\r\n */\r\n abstract apply(context: TContext): Observable<TContext>;\r\n\r\n /**\r\n * Verify the change if it was completely done.\r\n *\r\n * @param context the workflow context.\r\n * @returns Observable<TContext> the observable to execute.\r\n */\r\n abstract postValidate(context: TContext): Observable<TContext>;\r\n\r\n /**\r\n * Finalize the work item\r\n *\r\n * Within this call, it can update property nextId to switch to non-predefined work item.\r\n *\r\n * @param context the workflow context.\r\n */\r\n abstract finalize(context: TContext): void;\r\n}\r\n"]}