@decaf-ts/core 0.28.0 → 0.29.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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/dist/core.cjs +1 -1
  3. package/dist/core.cjs.map +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/core.js.map +1 -1
  6. package/lib/cjs/index.cjs +3 -3
  7. package/lib/cjs/migrations/Migration.cjs +16 -2
  8. package/lib/cjs/migrations/Migration.cjs.map +1 -1
  9. package/lib/cjs/migrations/MigrationService.cjs +48 -25
  10. package/lib/cjs/migrations/MigrationService.cjs.map +1 -1
  11. package/lib/cjs/tasks/TaskContext.cjs +3 -0
  12. package/lib/cjs/tasks/TaskContext.cjs.map +1 -1
  13. package/lib/cjs/tasks/TaskEngine.cjs +148 -69
  14. package/lib/cjs/tasks/TaskEngine.cjs.map +1 -1
  15. package/lib/cjs/tasks/builder.cjs +4 -0
  16. package/lib/cjs/tasks/builder.cjs.map +1 -1
  17. package/lib/cjs/tasks/constants.cjs +1 -0
  18. package/lib/cjs/tasks/constants.cjs.map +1 -1
  19. package/lib/cjs/tasks/models/TaskStepSpecModel.cjs +6 -0
  20. package/lib/cjs/tasks/models/TaskStepSpecModel.cjs.map +1 -1
  21. package/lib/esm/index.js +3 -3
  22. package/lib/esm/migrations/Migration.js +17 -3
  23. package/lib/esm/migrations/Migration.js.map +1 -1
  24. package/lib/esm/migrations/MigrationService.js +48 -25
  25. package/lib/esm/migrations/MigrationService.js.map +1 -1
  26. package/lib/esm/tasks/TaskContext.js +3 -0
  27. package/lib/esm/tasks/TaskContext.js.map +1 -1
  28. package/lib/esm/tasks/TaskEngine.js +148 -69
  29. package/lib/esm/tasks/TaskEngine.js.map +1 -1
  30. package/lib/esm/tasks/builder.js +4 -0
  31. package/lib/esm/tasks/builder.js.map +1 -1
  32. package/lib/esm/tasks/constants.js +1 -0
  33. package/lib/esm/tasks/constants.js.map +1 -1
  34. package/lib/esm/tasks/models/TaskStepSpecModel.js +6 -0
  35. package/lib/esm/tasks/models/TaskStepSpecModel.js.map +1 -1
  36. package/lib/types/index.d.cts +3 -3
  37. package/lib/types/index.d.mts +3 -3
  38. package/lib/types/migrations/Migration.d.cts +6 -2
  39. package/lib/types/migrations/Migration.d.mts +6 -2
  40. package/lib/types/migrations/MigrationService.d.cts +13 -5
  41. package/lib/types/migrations/MigrationService.d.mts +13 -5
  42. package/lib/types/migrations/types.d.cts +1 -0
  43. package/lib/types/migrations/types.d.mts +1 -0
  44. package/lib/types/tasks/TaskContext.d.cts +2 -0
  45. package/lib/types/tasks/TaskContext.d.mts +2 -0
  46. package/lib/types/tasks/TaskEngine.d.cts +5 -0
  47. package/lib/types/tasks/TaskEngine.d.mts +5 -0
  48. package/lib/types/tasks/builder.d.cts +1 -0
  49. package/lib/types/tasks/builder.d.mts +1 -0
  50. package/lib/types/tasks/models/TaskStepSpecModel.d.cts +1 -0
  51. package/lib/types/tasks/models/TaskStepSpecModel.d.mts +1 -0
  52. package/lib/types/tasks/types.d.cts +4 -0
  53. package/lib/types/tasks/types.d.mts +4 -0
  54. package/package.json +1 -1
@@ -24,21 +24,21 @@ export * from "./persistence/index.d.cts";
24
24
  * @const VERSION
25
25
  * @memberOf module:core
26
26
  */
27
- export declare const VERSION = "0.27.5";
27
+ export declare const VERSION = "0.28.1";
28
28
  /**
29
29
  * @description Represents the current commit hash of the module build.
30
30
  * @summary Stores the current git commit hash for the package. The build replaces
31
31
  * the placeholder with the actual commit hash at publish time.
32
32
  * @const COMMIT
33
33
  */
34
- export declare const COMMIT = "63a97aa";
34
+ export declare const COMMIT = "49b1386";
35
35
  /**
36
36
  * @description Represents the full version string of the module.
37
37
  * @summary Stores the semver version and commit hash for the package.
38
38
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
39
39
  * @const FULL_VERSION
40
40
  */
41
- export declare const FULL_VERSION = "0.27.5-63a97aa";
41
+ export declare const FULL_VERSION = "0.28.1-49b1386";
42
42
  /**
43
43
  * @description Stores the current package version
44
44
  * @summary A constant representing the version of the core package
@@ -24,21 +24,21 @@ export * from "./persistence/index.d.mts";
24
24
  * @const VERSION
25
25
  * @memberOf module:core
26
26
  */
27
- export declare const VERSION = "0.27.5";
27
+ export declare const VERSION = "0.28.1";
28
28
  /**
29
29
  * @description Represents the current commit hash of the module build.
30
30
  * @summary Stores the current git commit hash for the package. The build replaces
31
31
  * the placeholder with the actual commit hash at publish time.
32
32
  * @const COMMIT
33
33
  */
34
- export declare const COMMIT = "63a97aa";
34
+ export declare const COMMIT = "49b1386";
35
35
  /**
36
36
  * @description Represents the full version string of the module.
37
37
  * @summary Stores the semver version and commit hash for the package.
38
38
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
39
39
  * @const FULL_VERSION
40
40
  */
41
- export declare const FULL_VERSION = "0.27.5-63a97aa";
41
+ export declare const FULL_VERSION = "0.28.1-49b1386";
42
42
  /**
43
43
  * @description Stores the current package version
44
44
  * @summary A constant representing the version of the core package
@@ -1,7 +1,8 @@
1
1
  import { ConnectionForAdapter, Migration } from "./types.d.cts";
2
- import { AbsContextual, ContextualArgs } from "../utils/ContextualLoggedClass.d.cts";
2
+ import { AbsContextual, ContextualArgs, ContextualizedArgs, MaybeContextualArg, MethodOrOperation } from "../utils/ContextualLoggedClass.d.cts";
3
3
  import { Adapter } from "../persistence/Adapter.d.cts";
4
- import { ContextOf } from "../persistence/types.d.cts";
4
+ import { ContextOf, FlagsOf } from "../persistence/types.d.cts";
5
+ import { Context } from "../persistence/Context.d.cts";
5
6
  export declare abstract class AbsMigration<A extends Adapter<any, any, any, any>, R = void> extends AbsContextual<ContextOf<A>> implements Migration<A, R> {
6
7
  private _reference?;
7
8
  private _precedence?;
@@ -16,4 +17,7 @@ export declare abstract class AbsMigration<A extends Adapter<any, any, any, any>
16
17
  abstract down(qr: ConnectionForAdapter<A>, adapter: A, ...args: ContextualArgs<ContextOf<A>>): Promise<void>;
17
18
  abstract migrate(qr: ConnectionForAdapter<A>, adapter: A, ...args: ContextualArgs<ContextOf<A>>): Promise<R>;
18
19
  abstract up(qr: ConnectionForAdapter<A>, adapter: A, ctx: ContextOf<A>): Promise<void>;
20
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD): ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>;
21
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<ContextOf<A>>>): ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>;
22
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<ContextOf<any>>>): Promise<ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>>;
19
23
  }
@@ -1,7 +1,8 @@
1
1
  import { ConnectionForAdapter, Migration } from "./types.d.mts";
2
- import { AbsContextual, ContextualArgs } from "../utils/ContextualLoggedClass.d.mts";
2
+ import { AbsContextual, ContextualArgs, ContextualizedArgs, MaybeContextualArg, MethodOrOperation } from "../utils/ContextualLoggedClass.d.mts";
3
3
  import { Adapter } from "../persistence/Adapter.d.mts";
4
- import { ContextOf } from "../persistence/types.d.mts";
4
+ import { ContextOf, FlagsOf } from "../persistence/types.d.mts";
5
+ import { Context } from "../persistence/Context.d.mts";
5
6
  export declare abstract class AbsMigration<A extends Adapter<any, any, any, any>, R = void> extends AbsContextual<ContextOf<A>> implements Migration<A, R> {
6
7
  private _reference?;
7
8
  private _precedence?;
@@ -16,4 +17,7 @@ export declare abstract class AbsMigration<A extends Adapter<any, any, any, any>
16
17
  abstract down(qr: ConnectionForAdapter<A>, adapter: A, ...args: ContextualArgs<ContextOf<A>>): Promise<void>;
17
18
  abstract migrate(qr: ConnectionForAdapter<A>, adapter: A, ...args: ContextualArgs<ContextOf<A>>): Promise<R>;
18
19
  abstract up(qr: ConnectionForAdapter<A>, adapter: A, ctx: ContextOf<A>): Promise<void>;
20
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD): ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>;
21
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<ContextOf<A>>>): ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>;
22
+ protected logCtx<CONTEXT extends Context<any> = ContextOf<A>, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<ContextOf<any>>>): Promise<ContextualizedArgs<ContextOf<A>, ARGS, METHOD extends string ? true : false>>;
19
23
  }
@@ -15,19 +15,25 @@ type VersionTask = {
15
15
  version: string;
16
16
  task: TaskModel;
17
17
  };
18
+ type QueuedMigrationTask<A extends Adapter<any, any, any, any>> = {
19
+ id: string;
20
+ version: string;
21
+ adapter?: A;
22
+ setCurrentVersion?: MigrationConfig<boolean>["setCurrentVersion"];
23
+ };
18
24
  export declare class MigrationService<PERSIST extends boolean, A extends Adapter<any, any, any, any> = any, R = void> extends ClientBasedService<PERSIST extends boolean ? A : void, MigrationConfig<PERSIST>> implements Migration<A, R> {
25
+ private static defaultSingleton?;
19
26
  protected versioning: MigrationVersioning;
20
27
  protected allowedReferences: Set<string> | undefined;
21
- protected queuedTaskChain: Array<{
22
- id: string;
23
- version: string;
24
- }>;
28
+ protected queuedTaskChain: QueuedMigrationTask<A>[];
29
+ protected orchestrationConfig?: MigrationConfig<true>;
25
30
  flavour?: string;
26
31
  readonly reference: string;
27
32
  readonly precedence: Migration<any, any> | Migration<any, any>[] | null;
28
33
  transaction: boolean;
29
34
  constructor();
30
- static migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>[]>;
35
+ static migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>>;
36
+ migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>>;
31
37
  initialize(...args: MaybeContextualArg<ContextOf<A>>): Promise<{
32
38
  config: MigrationConfig<PERSIST>;
33
39
  client: PERSIST extends boolean ? A : void;
@@ -56,7 +62,9 @@ export declare class MigrationService<PERSIST extends boolean, A extends Adapter
56
62
  protected migrationTaskIdsFromContext(taskKey: string, args: ContextualArgs<ContextOf<any>>): string[];
57
63
  migrate(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
58
64
  migrateNormally(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
65
+ protected migrateNormallyWithConfig(cfg: MigrationConfig<boolean>, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
59
66
  migrateViaTasks(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
67
+ protected migrateViaTasksWithConfig(cfg: MigrationConfig<boolean>, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
60
68
  track(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
61
69
  retry(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
62
70
  up(qr: any, adapter: any, ...args: ContextualArgs<ContextOf<any>>): Promise<void>;
@@ -15,19 +15,25 @@ type VersionTask = {
15
15
  version: string;
16
16
  task: TaskModel;
17
17
  };
18
+ type QueuedMigrationTask<A extends Adapter<any, any, any, any>> = {
19
+ id: string;
20
+ version: string;
21
+ adapter?: A;
22
+ setCurrentVersion?: MigrationConfig<boolean>["setCurrentVersion"];
23
+ };
18
24
  export declare class MigrationService<PERSIST extends boolean, A extends Adapter<any, any, any, any> = any, R = void> extends ClientBasedService<PERSIST extends boolean ? A : void, MigrationConfig<PERSIST>> implements Migration<A, R> {
25
+ private static defaultSingleton?;
19
26
  protected versioning: MigrationVersioning;
20
27
  protected allowedReferences: Set<string> | undefined;
21
- protected queuedTaskChain: Array<{
22
- id: string;
23
- version: string;
24
- }>;
28
+ protected queuedTaskChain: QueuedMigrationTask<A>[];
29
+ protected orchestrationConfig?: MigrationConfig<true>;
25
30
  flavour?: string;
26
31
  readonly reference: string;
27
32
  readonly precedence: Migration<any, any> | Migration<any, any>[] | null;
28
33
  transaction: boolean;
29
34
  constructor();
30
- static migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>[]>;
35
+ static migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>>;
36
+ migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>>;
31
37
  initialize(...args: MaybeContextualArg<ContextOf<A>>): Promise<{
32
38
  config: MigrationConfig<PERSIST>;
33
39
  client: PERSIST extends boolean ? A : void;
@@ -56,7 +62,9 @@ export declare class MigrationService<PERSIST extends boolean, A extends Adapter
56
62
  protected migrationTaskIdsFromContext(taskKey: string, args: ContextualArgs<ContextOf<any>>): string[];
57
63
  migrate(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
58
64
  migrateNormally(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
65
+ protected migrateNormallyWithConfig(cfg: MigrationConfig<boolean>, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
59
66
  migrateViaTasks(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
67
+ protected migrateViaTasksWithConfig(cfg: MigrationConfig<boolean>, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
60
68
  track(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
61
69
  retry(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
62
70
  up(qr: any, adapter: any, ...args: ContextualArgs<ContextOf<any>>): Promise<void>;
@@ -28,6 +28,7 @@ export type AdapterMigrationHandlers<AD extends Adapter<any, any, any, any> = Ad
28
28
  export type PersistenceMigrationConfig<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>> = {
29
29
  toVersion?: string;
30
30
  taskMode?: boolean;
31
+ includeGenericInTaskMode?: boolean;
31
32
  dryRun?: boolean;
32
33
  flavours?: string[];
33
34
  taskService?: TaskService<any>;
@@ -28,6 +28,7 @@ export type AdapterMigrationHandlers<AD extends Adapter<any, any, any, any> = Ad
28
28
  export type PersistenceMigrationConfig<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>> = {
29
29
  toVersion?: string;
30
30
  taskMode?: boolean;
31
+ includeGenericInTaskMode?: boolean;
31
32
  dryRun?: boolean;
32
33
  flavours?: string[];
33
34
  taskService?: TaskService<any>;
@@ -6,6 +6,7 @@ import { TaskErrorModel } from "./models/TaskErrorModel.d.cts";
6
6
  import { TaskStatus } from "./constants.d.cts";
7
7
  import { TaskStateChangeRequest } from "./TaskStateChangeError.d.cts";
8
8
  import { TaskStepSpecModel } from "./models/TaskStepSpecModel.d.cts";
9
+ import { Lock } from "@decaf-ts/transactional-decorators";
9
10
  export declare class TaskContext extends Context<TaskFlags> {
10
11
  get taskId(): string;
11
12
  get logger(): TaskLogger<any>;
@@ -16,6 +17,7 @@ export declare class TaskContext extends Context<TaskFlags> {
16
17
  get attempt(): number;
17
18
  get progress(): (data: any) => Promise<void>;
18
19
  get heartbeat(): () => Promise<void>;
20
+ get stepWriteLock(): Lock;
19
21
  cacheResult(taskId: string, payload: any): void;
20
22
  protected changeState(status: TaskStatus, payload?: Partial<TaskStateChangeRequest>): never;
21
23
  cancel(reason?: string | Error | TaskErrorModel, details?: any): never;
@@ -6,6 +6,7 @@ import { TaskErrorModel } from "./models/TaskErrorModel.d.mts";
6
6
  import { TaskStatus } from "./constants.d.mts";
7
7
  import { TaskStateChangeRequest } from "./TaskStateChangeError.d.mts";
8
8
  import { TaskStepSpecModel } from "./models/TaskStepSpecModel.d.mts";
9
+ import { Lock } from "@decaf-ts/transactional-decorators";
9
10
  export declare class TaskContext extends Context<TaskFlags> {
10
11
  get taskId(): string;
11
12
  get logger(): TaskLogger<any>;
@@ -16,6 +17,7 @@ export declare class TaskContext extends Context<TaskFlags> {
16
17
  get attempt(): number;
17
18
  get progress(): (data: any) => Promise<void>;
18
19
  get heartbeat(): () => Promise<void>;
20
+ get stepWriteLock(): Lock;
19
21
  cacheResult(taskId: string, payload: any): void;
20
22
  protected changeState(status: TaskStatus, payload?: Partial<TaskStateChangeRequest>): never;
21
23
  cancel(reason?: string | Error | TaskErrorModel, details?: any): never;
@@ -79,6 +79,11 @@ export declare class TaskEngine<A extends Adapter<any, any, any, any>, C extends
79
79
  protected getStepLock(task: TaskModel, stepIndex: number | undefined): string | undefined;
80
80
  protected hasLockConflict(task: TaskModel, stepIndex: number | undefined, ctx: Context): Promise<boolean>;
81
81
  protected isRunnable(task: TaskModel, ctx: Context): Promise<boolean>;
82
+ protected getCompositeStepConcurrencyLimit(): number;
83
+ protected isConcurrentCompositeStep(step: TaskStepSpecModel): boolean;
84
+ protected createCompositeStepContext(context: TaskContext, stepIndex: number): TaskContext;
85
+ protected withStepWriteLock<T>(ctx: TaskContext, fn: () => Promise<T>): Promise<T>;
86
+ protected recalculateCompositeCurrentStep(steps: TaskStepSpecModel[], results: TaskStepResultModel[]): number;
82
87
  protected executeClaimed(task: TaskModel): Promise<void>;
83
88
  protected handleTaskStateChange(request: TaskStateChangeRequest, task: TaskModel, ctx: TaskContext): Promise<void>;
84
89
  protected runComposite(task: TaskModel, context: TaskContext): Promise<any>;
@@ -79,6 +79,11 @@ export declare class TaskEngine<A extends Adapter<any, any, any, any>, C extends
79
79
  protected getStepLock(task: TaskModel, stepIndex: number | undefined): string | undefined;
80
80
  protected hasLockConflict(task: TaskModel, stepIndex: number | undefined, ctx: Context): Promise<boolean>;
81
81
  protected isRunnable(task: TaskModel, ctx: Context): Promise<boolean>;
82
+ protected getCompositeStepConcurrencyLimit(): number;
83
+ protected isConcurrentCompositeStep(step: TaskStepSpecModel): boolean;
84
+ protected createCompositeStepContext(context: TaskContext, stepIndex: number): TaskContext;
85
+ protected withStepWriteLock<T>(ctx: TaskContext, fn: () => Promise<T>): Promise<T>;
86
+ protected recalculateCompositeCurrentStep(steps: TaskStepSpecModel[], results: TaskStepResultModel[]): number;
82
87
  protected executeClaimed(task: TaskModel): Promise<void>;
83
88
  protected handleTaskStateChange(request: TaskStateChangeRequest, task: TaskModel, ctx: TaskContext): Promise<void>;
84
89
  protected runComposite(task: TaskModel, context: TaskContext): Promise<any>;
@@ -45,6 +45,7 @@ export declare class TaskStepSpecBuilder {
45
45
  setName(value?: string): this;
46
46
  setInput(value: any): this;
47
47
  setLock(value?: string): this;
48
+ setAllowConcurrent(value?: boolean): this;
48
49
  setDependsOn(value?: string[]): this;
49
50
  setCanFail(value: boolean): this;
50
51
  setMaxAttempts(value?: number): this;
@@ -45,6 +45,7 @@ export declare class TaskStepSpecBuilder {
45
45
  setName(value?: string): this;
46
46
  setInput(value: any): this;
47
47
  setLock(value?: string): this;
48
+ setAllowConcurrent(value?: boolean): this;
48
49
  setDependsOn(value?: string[]): this;
49
50
  setCanFail(value: boolean): this;
50
51
  setMaxAttempts(value?: number): this;
@@ -5,6 +5,7 @@ export declare class TaskStepSpecModel extends Model {
5
5
  name?: string;
6
6
  input?: any;
7
7
  lock?: string;
8
+ allowConcurrent: boolean;
8
9
  dependsOn?: string[];
9
10
  canFail: boolean;
10
11
  maxAttempts?: number;
@@ -5,6 +5,7 @@ export declare class TaskStepSpecModel extends Model {
5
5
  name?: string;
6
6
  input?: any;
7
7
  lock?: string;
8
+ allowConcurrent: boolean;
8
9
  dependsOn?: string[];
9
10
  canFail: boolean;
10
11
  maxAttempts?: number;
@@ -9,6 +9,7 @@ import { TaskEventModel } from "./models/TaskEventModel.d.cts";
9
9
  import { TaskStatus } from "./constants.d.cts";
10
10
  import { TaskErrorModel } from "./models/TaskErrorModel.d.cts";
11
11
  import { TaskStepSpecModel } from "./models/TaskStepSpecModel.d.cts";
12
+ import { Lock } from "@decaf-ts/transactional-decorators";
12
13
  export interface ITaskHandler<I = any, O = any> {
13
14
  type: string;
14
15
  run(input: I, ctx: TaskContext): Promise<O>;
@@ -31,6 +32,8 @@ export interface LogPipe {
31
32
  export interface TaskFlags<LOG extends TaskLogger<any> = TaskLogger<any>> extends ContextFlags<LOG> {
32
33
  taskId: string;
33
34
  attempt: number;
35
+ step?: number;
36
+ stepWriteLock?: Lock;
34
37
  pipe: LogPipe;
35
38
  flush: () => Promise<void>;
36
39
  progress: (data: any) => Promise<void>;
@@ -47,6 +50,7 @@ export type TaskEngineConfig<A extends Adapter<any, any, any, any>> = {
47
50
  registry?: TaskHandlerRegistry;
48
51
  workerId: string;
49
52
  concurrency: number;
53
+ maxConcurrentCompositeSteps?: number;
50
54
  leaseMs: number;
51
55
  pollMsIdle: number;
52
56
  pollMsBusy: number;
@@ -9,6 +9,7 @@ import { TaskEventModel } from "./models/TaskEventModel.d.mts";
9
9
  import { TaskStatus } from "./constants.d.mts";
10
10
  import { TaskErrorModel } from "./models/TaskErrorModel.d.mts";
11
11
  import { TaskStepSpecModel } from "./models/TaskStepSpecModel.d.mts";
12
+ import { Lock } from "@decaf-ts/transactional-decorators";
12
13
  export interface ITaskHandler<I = any, O = any> {
13
14
  type: string;
14
15
  run(input: I, ctx: TaskContext): Promise<O>;
@@ -31,6 +32,8 @@ export interface LogPipe {
31
32
  export interface TaskFlags<LOG extends TaskLogger<any> = TaskLogger<any>> extends ContextFlags<LOG> {
32
33
  taskId: string;
33
34
  attempt: number;
35
+ step?: number;
36
+ stepWriteLock?: Lock;
34
37
  pipe: LogPipe;
35
38
  flush: () => Promise<void>;
36
39
  progress: (data: any) => Promise<void>;
@@ -47,6 +50,7 @@ export type TaskEngineConfig<A extends Adapter<any, any, any, any>> = {
47
50
  registry?: TaskHandlerRegistry;
48
51
  workerId: string;
49
52
  concurrency: number;
53
+ maxConcurrentCompositeSteps?: number;
50
54
  leaseMs: number;
51
55
  pollMsIdle: number;
52
56
  pollMsBusy: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/core",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Core persistence module for the decaf framework",
5
5
  "type": "module",
6
6
  "exports": {