@decaf-ts/utils 1.1.0 → 1.2.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 (94) hide show
  1. package/README.md +1 -1
  2. package/dist/utils.cjs +1 -1
  3. package/dist/utils.cjs.map +1 -1
  4. package/dist/utils.js +1 -1
  5. package/dist/utils.js.map +1 -1
  6. package/lib/cjs/cli/commands/build-scripts.cjs +87 -0
  7. package/lib/cjs/cli/commands/build-scripts.cjs.map +1 -1
  8. package/lib/cjs/index.cjs +1 -1
  9. package/lib/esm/cli/commands/build-scripts.js +87 -0
  10. package/lib/esm/cli/commands/build-scripts.js.map +1 -1
  11. package/lib/esm/index.js +1 -1
  12. package/lib/types/assets/slogans.d.cts +19 -0
  13. package/lib/types/assets/slogans.d.mts +19 -0
  14. package/lib/types/bin/build-scripts.d.cts +1 -0
  15. package/lib/types/bin/build-scripts.d.mts +1 -0
  16. package/lib/types/bin/release-chain-dispatch.d.cts +1 -0
  17. package/lib/types/bin/release-chain-dispatch.d.mts +1 -0
  18. package/lib/types/bin/release-chain.d.cts +1 -0
  19. package/lib/types/bin/release-chain.d.mts +1 -0
  20. package/lib/types/bin/tag-release.d.cts +1 -0
  21. package/lib/types/bin/tag-release.d.mts +1 -0
  22. package/lib/types/cli/command.d.cts +104 -0
  23. package/lib/types/cli/command.d.mts +104 -0
  24. package/lib/types/cli/commands/build-scripts.d.cts +148 -0
  25. package/lib/types/cli/commands/build-scripts.d.mts +148 -0
  26. package/lib/types/cli/commands/build-scripts.d.ts +3 -0
  27. package/lib/types/cli/commands/index.d.cts +3 -0
  28. package/lib/types/cli/commands/index.d.mts +3 -0
  29. package/lib/types/cli/commands/release-chain.d.cts +62 -0
  30. package/lib/types/cli/commands/release-chain.d.mts +62 -0
  31. package/lib/types/cli/commands/tag-release.d.cts +105 -0
  32. package/lib/types/cli/commands/tag-release.d.mts +105 -0
  33. package/lib/types/cli/constants.d.cts +75 -0
  34. package/lib/types/cli/constants.d.mts +75 -0
  35. package/lib/types/cli/index.d.cts +4 -0
  36. package/lib/types/cli/index.d.mts +4 -0
  37. package/lib/types/cli/types.d.cts +30 -0
  38. package/lib/types/cli/types.d.mts +30 -0
  39. package/lib/types/index.d.cts +38 -0
  40. package/lib/types/index.d.mts +38 -0
  41. package/lib/types/index.d.ts +1 -1
  42. package/lib/types/input/index.d.cts +2 -0
  43. package/lib/types/input/index.d.mts +2 -0
  44. package/lib/types/input/input.d.cts +517 -0
  45. package/lib/types/input/input.d.mts +517 -0
  46. package/lib/types/input/types.d.cts +159 -0
  47. package/lib/types/input/types.d.mts +159 -0
  48. package/lib/types/output/common.d.cts +53 -0
  49. package/lib/types/output/common.d.mts +53 -0
  50. package/lib/types/output/index.d.cts +1 -0
  51. package/lib/types/output/index.d.mts +1 -0
  52. package/lib/types/release-chain/index.d.cts +43 -0
  53. package/lib/types/release-chain/index.d.mts +43 -0
  54. package/lib/types/tests/Consumer.d.cts +151 -0
  55. package/lib/types/tests/Consumer.d.mts +151 -0
  56. package/lib/types/tests/ProducerChildProcess.d.cts +18 -0
  57. package/lib/types/tests/ProducerChildProcess.d.mts +18 -0
  58. package/lib/types/tests/TestReporter.d.cts +245 -0
  59. package/lib/types/tests/TestReporter.d.mts +245 -0
  60. package/lib/types/tests/index.d.cts +4 -0
  61. package/lib/types/tests/index.d.mts +4 -0
  62. package/lib/types/tests/jestPerformanceRunner.d.cts +37 -0
  63. package/lib/types/tests/jestPerformanceRunner.d.mts +37 -0
  64. package/lib/types/tests/utils.d.cts +5 -0
  65. package/lib/types/tests/utils.d.mts +5 -0
  66. package/lib/types/utils/constants.d.cts +65 -0
  67. package/lib/types/utils/constants.d.mts +65 -0
  68. package/lib/types/utils/fs.d.cts +259 -0
  69. package/lib/types/utils/fs.d.mts +259 -0
  70. package/lib/types/utils/http.d.cts +41 -0
  71. package/lib/types/utils/http.d.mts +41 -0
  72. package/lib/types/utils/index.d.cts +6 -0
  73. package/lib/types/utils/index.d.mts +6 -0
  74. package/lib/types/utils/md.d.cts +156 -0
  75. package/lib/types/utils/md.d.mts +156 -0
  76. package/lib/types/utils/performanceRunner.d.cts +129 -0
  77. package/lib/types/utils/performanceRunner.d.mts +129 -0
  78. package/lib/types/utils/timeout.d.cts +12 -0
  79. package/lib/types/utils/timeout.d.mts +12 -0
  80. package/lib/types/utils/types.d.cts +112 -0
  81. package/lib/types/utils/types.d.mts +112 -0
  82. package/lib/types/utils/utils.d.cts +133 -0
  83. package/lib/types/utils/utils.d.mts +133 -0
  84. package/lib/types/writers/OutputWriter.d.cts +49 -0
  85. package/lib/types/writers/OutputWriter.d.mts +49 -0
  86. package/lib/types/writers/RegexpOutputWriter.d.cts +110 -0
  87. package/lib/types/writers/RegexpOutputWriter.d.mts +110 -0
  88. package/lib/types/writers/StandardOutputWriter.d.cts +130 -0
  89. package/lib/types/writers/StandardOutputWriter.d.mts +130 -0
  90. package/lib/types/writers/index.d.cts +4 -0
  91. package/lib/types/writers/index.d.mts +4 -0
  92. package/lib/types/writers/types.d.cts +29 -0
  93. package/lib/types/writers/types.d.mts +29 -0
  94. package/package.json +14 -8
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @description Single line markdown element type
3
+ * @summary Represents the possible header levels in markdown
4
+ * @typedef {"h1"|"h2"|"h3"|"h4"|"h5"|"h6"} MdSingleLineElement
5
+ * @memberOf module:utils
6
+ */
7
+ export type MdSingleLineElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
8
+ /**
9
+ * @description Multi-line element types in markdown
10
+ * @summary Defines the available multi-line element types
11
+ * @typedef {"p"|"blockquote"} MdMultiLineElement
12
+ * @memberOf module:utils
13
+ */
14
+ export type MdMultiLineElement = "p" | "blockquote";
15
+ /**
16
+ * @description List element types in markdown
17
+ * @summary Defines the available list types
18
+ * @typedef {"ul"|"ol"} MdListElement
19
+ * @memberOf module:utils
20
+ */
21
+ export type MdListElement = "ul" | "ol";
22
+ /**
23
+ * @description List element types in markdown
24
+ * @summary Defines the available list types
25
+ * @typedef {Object} MdSingleLine
26
+ * @property {string} [ul] - unordered list
27
+ * @property {string} [ol] - ordered list
28
+ * @memberOf module:utils
29
+ */
30
+ export type MdSingleLine = {
31
+ [k in MdSingleLineElement]?: string;
32
+ };
33
+ /**
34
+ * @description Multi-line markdown element type
35
+ * @summary Represents markdown elements that can contain multiple lines of text
36
+ * @typedef {Object} MdMultiLine
37
+ * @property {string|string[]} [p] - Paragraph content
38
+ * @property {string|string[]} [blockquote] - Blockquote content
39
+ * @memberOf module:utils
40
+ */
41
+ export type MdMultiLine = {
42
+ [k in MdMultiLineElement]?: string | string[];
43
+ };
44
+ /**
45
+ * @description Image definition type in markdown
46
+ * @summary Defines the structure for image elements
47
+ * @typedef {Object} MdImageDefinition
48
+ * @property {string} [title] - Optional image title
49
+ * @property {string} source - Image source URL
50
+ * @property {string} [alt] - Optional alternative text
51
+ * @memberOf module:utils
52
+ */
53
+ export type MdImageDefinition = {
54
+ title?: string;
55
+ source: string;
56
+ alt?: string;
57
+ };
58
+ /**
59
+ * @description Image element type in markdown
60
+ * @summary Represents an image element with its properties
61
+ * @typedef {Object} MdImage
62
+ * @property {MdImageDefinition} img - The image definition object
63
+ * @memberOf module:utils
64
+ */
65
+ export type MdImage = {
66
+ img: MdImageDefinition;
67
+ };
68
+ /**
69
+ * @description List item element type in markdown
70
+ * @summary Represents ordered and unordered lists in markdown
71
+ * @typedef {Object} MdListItem
72
+ * @property {string[]} ul - Unordered list items
73
+ * @property {string[]} ol - Ordered list items
74
+ * @memberOf module:utils
75
+ */
76
+ export type MdListItem = {
77
+ [k in MdListElement]: string[];
78
+ };
79
+ /**
80
+ * @description Table definition type in markdown
81
+ * @summary Defines the structure for table elements
82
+ * @typedef {Object} MdTableDefinition
83
+ * @property {string[]} headers - Array of table header names
84
+ * @property {Object[]} rows - Array of row objects containing column values
85
+ * @memberOf module:utils
86
+ */
87
+ export type MdTableDefinition = {
88
+ headers: string[];
89
+ rows: {
90
+ [column: string]: string | string[];
91
+ }[];
92
+ };
93
+ /**
94
+ * @description Table element type in markdown
95
+ * @summary Represents a table structure with headers and rows
96
+ * @typedef {Object} MdTable
97
+ * @property {MdTableDefinition} table - The table definition object
98
+ * @memberOf module:utils
99
+ */
100
+ export type MdTable = {
101
+ table: MdTableDefinition;
102
+ };
103
+ /**
104
+ * @description Code block definition type in markdown
105
+ * @summary Defines the structure for code blocks
106
+ * @typedef {Object} MdCodeDefinition
107
+ * @property {string} [language] - Optional programming language specification
108
+ * @property {string|string[]} content - The code content as string or array of strings
109
+ * @memberOf module:utils
110
+ */
111
+ export type MdCodeDefinition = {
112
+ language?: string;
113
+ content: string | string[];
114
+ };
115
+ /**
116
+ * @description Code block element type in markdown
117
+ * @summary Represents a code block with optional language specification
118
+ * @typedef {Object} MdCode
119
+ * @property {MdCodeDefinition} code - The code block definition object
120
+ * @memberOf module:utils
121
+ */
122
+ export type MdCode = {
123
+ code: MdCodeDefinition;
124
+ };
125
+ /**
126
+ * @description Horizontal rule element type in markdown
127
+ * @summary Represents a horizontal rule separator
128
+ * @typedef {Object} MdSeparator
129
+ * @property {string} hr - The horizontal rule representation
130
+ * @memberOf module:utils
131
+ */
132
+ export type MdSeparator = {
133
+ hr: string;
134
+ };
135
+ /**
136
+ * @description Link element type in markdown
137
+ * @summary Represents a hyperlink with title and source
138
+ * @typedef {Object} MdLink
139
+ * @property {{title: string, source: string}} link - The link definition object
140
+ * @memberOf module:utils
141
+ */
142
+ export type MdLink = {
143
+ link: {
144
+ title: string;
145
+ source: string;
146
+ };
147
+ };
148
+ /**
149
+ * @description Markdown element type definition
150
+ * @summary Represents all possible markdown elements that can be used in document generation.
151
+ * This type combines various markdown elements including headers, paragraphs, images, lists,
152
+ * tables, code blocks, separators, and links into a union type for flexible markdown content creation.
153
+ * @typedef {(MdSingleLine | MdMultiLine | MdImage | MdListItem | MdTable | MdCode | MdSeparator | MdLink)} MdElements
154
+ * @memberOf module:utils
155
+ */
156
+ export type MdElements = MdSingleLine | MdMultiLine | MdImage | MdListItem | MdTable | MdCode | MdSeparator | MdLink;
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @description Single line markdown element type
3
+ * @summary Represents the possible header levels in markdown
4
+ * @typedef {"h1"|"h2"|"h3"|"h4"|"h5"|"h6"} MdSingleLineElement
5
+ * @memberOf module:utils
6
+ */
7
+ export type MdSingleLineElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
8
+ /**
9
+ * @description Multi-line element types in markdown
10
+ * @summary Defines the available multi-line element types
11
+ * @typedef {"p"|"blockquote"} MdMultiLineElement
12
+ * @memberOf module:utils
13
+ */
14
+ export type MdMultiLineElement = "p" | "blockquote";
15
+ /**
16
+ * @description List element types in markdown
17
+ * @summary Defines the available list types
18
+ * @typedef {"ul"|"ol"} MdListElement
19
+ * @memberOf module:utils
20
+ */
21
+ export type MdListElement = "ul" | "ol";
22
+ /**
23
+ * @description List element types in markdown
24
+ * @summary Defines the available list types
25
+ * @typedef {Object} MdSingleLine
26
+ * @property {string} [ul] - unordered list
27
+ * @property {string} [ol] - ordered list
28
+ * @memberOf module:utils
29
+ */
30
+ export type MdSingleLine = {
31
+ [k in MdSingleLineElement]?: string;
32
+ };
33
+ /**
34
+ * @description Multi-line markdown element type
35
+ * @summary Represents markdown elements that can contain multiple lines of text
36
+ * @typedef {Object} MdMultiLine
37
+ * @property {string|string[]} [p] - Paragraph content
38
+ * @property {string|string[]} [blockquote] - Blockquote content
39
+ * @memberOf module:utils
40
+ */
41
+ export type MdMultiLine = {
42
+ [k in MdMultiLineElement]?: string | string[];
43
+ };
44
+ /**
45
+ * @description Image definition type in markdown
46
+ * @summary Defines the structure for image elements
47
+ * @typedef {Object} MdImageDefinition
48
+ * @property {string} [title] - Optional image title
49
+ * @property {string} source - Image source URL
50
+ * @property {string} [alt] - Optional alternative text
51
+ * @memberOf module:utils
52
+ */
53
+ export type MdImageDefinition = {
54
+ title?: string;
55
+ source: string;
56
+ alt?: string;
57
+ };
58
+ /**
59
+ * @description Image element type in markdown
60
+ * @summary Represents an image element with its properties
61
+ * @typedef {Object} MdImage
62
+ * @property {MdImageDefinition} img - The image definition object
63
+ * @memberOf module:utils
64
+ */
65
+ export type MdImage = {
66
+ img: MdImageDefinition;
67
+ };
68
+ /**
69
+ * @description List item element type in markdown
70
+ * @summary Represents ordered and unordered lists in markdown
71
+ * @typedef {Object} MdListItem
72
+ * @property {string[]} ul - Unordered list items
73
+ * @property {string[]} ol - Ordered list items
74
+ * @memberOf module:utils
75
+ */
76
+ export type MdListItem = {
77
+ [k in MdListElement]: string[];
78
+ };
79
+ /**
80
+ * @description Table definition type in markdown
81
+ * @summary Defines the structure for table elements
82
+ * @typedef {Object} MdTableDefinition
83
+ * @property {string[]} headers - Array of table header names
84
+ * @property {Object[]} rows - Array of row objects containing column values
85
+ * @memberOf module:utils
86
+ */
87
+ export type MdTableDefinition = {
88
+ headers: string[];
89
+ rows: {
90
+ [column: string]: string | string[];
91
+ }[];
92
+ };
93
+ /**
94
+ * @description Table element type in markdown
95
+ * @summary Represents a table structure with headers and rows
96
+ * @typedef {Object} MdTable
97
+ * @property {MdTableDefinition} table - The table definition object
98
+ * @memberOf module:utils
99
+ */
100
+ export type MdTable = {
101
+ table: MdTableDefinition;
102
+ };
103
+ /**
104
+ * @description Code block definition type in markdown
105
+ * @summary Defines the structure for code blocks
106
+ * @typedef {Object} MdCodeDefinition
107
+ * @property {string} [language] - Optional programming language specification
108
+ * @property {string|string[]} content - The code content as string or array of strings
109
+ * @memberOf module:utils
110
+ */
111
+ export type MdCodeDefinition = {
112
+ language?: string;
113
+ content: string | string[];
114
+ };
115
+ /**
116
+ * @description Code block element type in markdown
117
+ * @summary Represents a code block with optional language specification
118
+ * @typedef {Object} MdCode
119
+ * @property {MdCodeDefinition} code - The code block definition object
120
+ * @memberOf module:utils
121
+ */
122
+ export type MdCode = {
123
+ code: MdCodeDefinition;
124
+ };
125
+ /**
126
+ * @description Horizontal rule element type in markdown
127
+ * @summary Represents a horizontal rule separator
128
+ * @typedef {Object} MdSeparator
129
+ * @property {string} hr - The horizontal rule representation
130
+ * @memberOf module:utils
131
+ */
132
+ export type MdSeparator = {
133
+ hr: string;
134
+ };
135
+ /**
136
+ * @description Link element type in markdown
137
+ * @summary Represents a hyperlink with title and source
138
+ * @typedef {Object} MdLink
139
+ * @property {{title: string, source: string}} link - The link definition object
140
+ * @memberOf module:utils
141
+ */
142
+ export type MdLink = {
143
+ link: {
144
+ title: string;
145
+ source: string;
146
+ };
147
+ };
148
+ /**
149
+ * @description Markdown element type definition
150
+ * @summary Represents all possible markdown elements that can be used in document generation.
151
+ * This type combines various markdown elements including headers, paragraphs, images, lists,
152
+ * tables, code blocks, separators, and links into a union type for flexible markdown content creation.
153
+ * @typedef {(MdSingleLine | MdMultiLine | MdImage | MdListItem | MdTable | MdCode | MdSeparator | MdLink)} MdElements
154
+ * @memberOf module:utils
155
+ */
156
+ export type MdElements = MdSingleLine | MdMultiLine | MdImage | MdListItem | MdTable | MdCode | MdSeparator | MdLink;
@@ -0,0 +1,129 @@
1
+ export type ExecutionMode = "sequential" | "concurrent" | "burst";
2
+ export interface PhaseBurstConfig {
3
+ size: number;
4
+ intervalMs?: number;
5
+ }
6
+ export interface PhaseWarmupConfig<TContext = Record<string, unknown>> {
7
+ iterations: number;
8
+ handler?: PerformanceHandler<TContext>;
9
+ delayBetweenIterationsMs?: number;
10
+ }
11
+ export interface PhaseConfig<TContext = Record<string, unknown>> {
12
+ iterations: number;
13
+ mode: ExecutionMode;
14
+ concurrency?: number;
15
+ delayBetweenIterationsMs?: number;
16
+ burst?: PhaseBurstConfig;
17
+ loadStart?: number;
18
+ loadStep?: number;
19
+ loadMultiplier?: number;
20
+ context?: Partial<TContext>;
21
+ metadata?: Record<string, unknown>;
22
+ warmup?: PhaseWarmupConfig<TContext>;
23
+ pauseAfterMs?: number;
24
+ }
25
+ export interface Phase<TContext = Record<string, unknown>> {
26
+ name: string;
27
+ config: PhaseConfig<TContext>;
28
+ generator?: PhaseGenerator<TContext>;
29
+ subPhases?: Phase<TContext>[];
30
+ }
31
+ export interface PhaseGeneratorPhase<TContext> {
32
+ name?: string;
33
+ config: PhaseConfig<Partial<TContext>>;
34
+ }
35
+ export type PhaseGeneratorResult<TContext> = PhaseConfig<TContext> | PhaseGeneratorPhase<TContext>;
36
+ export type PhaseGenerator<TContext> = (payload: PhaseGeneratorPayload<TContext>) => Promise<PhaseGeneratorResult<TContext> | undefined> | PhaseGeneratorResult<TContext> | undefined;
37
+ export interface PhaseResult<TContext = Record<string, unknown>> {
38
+ phase: Phase<TContext>;
39
+ config: PhaseConfig<TContext>;
40
+ iterationMetrics: IterationMetric[];
41
+ aggregated: AggregatedMetrics;
42
+ context: TContext;
43
+ segmentCount: number;
44
+ /** Wall-clock elapsed ms for the segment loop (excludes warmup and pauseAfterMs) */
45
+ wallClockMs: number;
46
+ }
47
+ export interface PhaseGeneratorMetadata<TContext = Record<string, unknown>> {
48
+ phaseNumber: number;
49
+ phaseName: string;
50
+ iterationCount: number;
51
+ burstSegments: number;
52
+ segmentCount: number;
53
+ mode: ExecutionMode;
54
+ history: PhaseResult<TContext>[];
55
+ }
56
+ export interface PhaseGeneratorPayload<TContext = Record<string, unknown>> {
57
+ result: PhaseResult<TContext>;
58
+ history: PhaseResult<TContext>[];
59
+ metadata: PhaseGeneratorMetadata<TContext>;
60
+ }
61
+ export interface AggregatedMetrics {
62
+ totalDurationMs: number;
63
+ minMs: number;
64
+ maxMs: number;
65
+ averageMs: number;
66
+ successCount: number;
67
+ failureCount: number;
68
+ loadStart: number;
69
+ loadEnd: number;
70
+ }
71
+ export interface IterationMetric {
72
+ iteration: number;
73
+ durationMs: number;
74
+ success: boolean;
75
+ meta?: Record<string, unknown>;
76
+ loadFactor: number;
77
+ }
78
+ export interface HandlerPayload<TContext = Record<string, unknown>> {
79
+ iteration: number;
80
+ config: PhaseConfig<TContext>;
81
+ loadFactor: number;
82
+ context: TContext;
83
+ }
84
+ export interface HandlerResult {
85
+ success?: boolean;
86
+ meta?: Record<string, unknown>;
87
+ }
88
+ export type PerformanceHandler<TContext = Record<string, unknown>> = (payload: HandlerPayload<TContext>) => Promise<HandlerResult> | HandlerResult;
89
+ export interface CanvasRenderOptions {
90
+ width?: number;
91
+ height?: number;
92
+ padding?: number;
93
+ backgroundColor?: string;
94
+ headerFont?: string;
95
+ rowFont?: string;
96
+ headerColor?: string;
97
+ rowColor?: string;
98
+ }
99
+ export interface PerformanceScenario<TContext = Record<string, unknown>> {
100
+ name: string;
101
+ handler: PerformanceHandler<TContext>;
102
+ phases: Phase<TContext>[];
103
+ baseContext?: TContext;
104
+ failOnError?: boolean;
105
+ initialize?: () => Promise<void> | void;
106
+ canvasOptions?: CanvasRenderOptions;
107
+ canvasOutputPath?: string;
108
+ enableCanvas?: boolean;
109
+ }
110
+ export declare const defaultCanvasOptions: Required<CanvasRenderOptions>;
111
+ export declare class PerformanceRunner<TContext = Record<string, unknown>> {
112
+ protected readonly scenario: PerformanceScenario<TContext>;
113
+ constructor(scenario: PerformanceScenario<TContext>);
114
+ run(): Promise<PhaseResult<TContext>[]>;
115
+ protected runPhase(phase: Phase<TContext>, context: TContext): Promise<PhaseResult<TContext>>;
116
+ protected runWarmup(phase: Phase<TContext>, context: TContext): Promise<void>;
117
+ protected computeLoadFactor(config: PhaseConfig<TContext>, iteration: number): number;
118
+ protected buildSegmentIndices(iterations: number, burst?: PhaseBurstConfig): number[][];
119
+ protected mergeContext(phase: Phase<TContext>): TContext;
120
+ protected mergeContexts(a: TContext, b: Partial<TContext>): TContext;
121
+ protected executeSegment(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
122
+ protected collectSequential(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
123
+ protected collectConcurrent(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
124
+ protected runIteration(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, iteration: number): Promise<IterationMetric>;
125
+ protected aggregateMetrics(metrics: IterationMetric[]): AggregatedMetrics;
126
+ protected logPhaseTable(result: PhaseResult<TContext>): void;
127
+ protected logSummary(results: PhaseResult<TContext>[]): Promise<void>;
128
+ protected shouldRenderCanvas(): boolean;
129
+ }
@@ -0,0 +1,129 @@
1
+ export type ExecutionMode = "sequential" | "concurrent" | "burst";
2
+ export interface PhaseBurstConfig {
3
+ size: number;
4
+ intervalMs?: number;
5
+ }
6
+ export interface PhaseWarmupConfig<TContext = Record<string, unknown>> {
7
+ iterations: number;
8
+ handler?: PerformanceHandler<TContext>;
9
+ delayBetweenIterationsMs?: number;
10
+ }
11
+ export interface PhaseConfig<TContext = Record<string, unknown>> {
12
+ iterations: number;
13
+ mode: ExecutionMode;
14
+ concurrency?: number;
15
+ delayBetweenIterationsMs?: number;
16
+ burst?: PhaseBurstConfig;
17
+ loadStart?: number;
18
+ loadStep?: number;
19
+ loadMultiplier?: number;
20
+ context?: Partial<TContext>;
21
+ metadata?: Record<string, unknown>;
22
+ warmup?: PhaseWarmupConfig<TContext>;
23
+ pauseAfterMs?: number;
24
+ }
25
+ export interface Phase<TContext = Record<string, unknown>> {
26
+ name: string;
27
+ config: PhaseConfig<TContext>;
28
+ generator?: PhaseGenerator<TContext>;
29
+ subPhases?: Phase<TContext>[];
30
+ }
31
+ export interface PhaseGeneratorPhase<TContext> {
32
+ name?: string;
33
+ config: PhaseConfig<Partial<TContext>>;
34
+ }
35
+ export type PhaseGeneratorResult<TContext> = PhaseConfig<TContext> | PhaseGeneratorPhase<TContext>;
36
+ export type PhaseGenerator<TContext> = (payload: PhaseGeneratorPayload<TContext>) => Promise<PhaseGeneratorResult<TContext> | undefined> | PhaseGeneratorResult<TContext> | undefined;
37
+ export interface PhaseResult<TContext = Record<string, unknown>> {
38
+ phase: Phase<TContext>;
39
+ config: PhaseConfig<TContext>;
40
+ iterationMetrics: IterationMetric[];
41
+ aggregated: AggregatedMetrics;
42
+ context: TContext;
43
+ segmentCount: number;
44
+ /** Wall-clock elapsed ms for the segment loop (excludes warmup and pauseAfterMs) */
45
+ wallClockMs: number;
46
+ }
47
+ export interface PhaseGeneratorMetadata<TContext = Record<string, unknown>> {
48
+ phaseNumber: number;
49
+ phaseName: string;
50
+ iterationCount: number;
51
+ burstSegments: number;
52
+ segmentCount: number;
53
+ mode: ExecutionMode;
54
+ history: PhaseResult<TContext>[];
55
+ }
56
+ export interface PhaseGeneratorPayload<TContext = Record<string, unknown>> {
57
+ result: PhaseResult<TContext>;
58
+ history: PhaseResult<TContext>[];
59
+ metadata: PhaseGeneratorMetadata<TContext>;
60
+ }
61
+ export interface AggregatedMetrics {
62
+ totalDurationMs: number;
63
+ minMs: number;
64
+ maxMs: number;
65
+ averageMs: number;
66
+ successCount: number;
67
+ failureCount: number;
68
+ loadStart: number;
69
+ loadEnd: number;
70
+ }
71
+ export interface IterationMetric {
72
+ iteration: number;
73
+ durationMs: number;
74
+ success: boolean;
75
+ meta?: Record<string, unknown>;
76
+ loadFactor: number;
77
+ }
78
+ export interface HandlerPayload<TContext = Record<string, unknown>> {
79
+ iteration: number;
80
+ config: PhaseConfig<TContext>;
81
+ loadFactor: number;
82
+ context: TContext;
83
+ }
84
+ export interface HandlerResult {
85
+ success?: boolean;
86
+ meta?: Record<string, unknown>;
87
+ }
88
+ export type PerformanceHandler<TContext = Record<string, unknown>> = (payload: HandlerPayload<TContext>) => Promise<HandlerResult> | HandlerResult;
89
+ export interface CanvasRenderOptions {
90
+ width?: number;
91
+ height?: number;
92
+ padding?: number;
93
+ backgroundColor?: string;
94
+ headerFont?: string;
95
+ rowFont?: string;
96
+ headerColor?: string;
97
+ rowColor?: string;
98
+ }
99
+ export interface PerformanceScenario<TContext = Record<string, unknown>> {
100
+ name: string;
101
+ handler: PerformanceHandler<TContext>;
102
+ phases: Phase<TContext>[];
103
+ baseContext?: TContext;
104
+ failOnError?: boolean;
105
+ initialize?: () => Promise<void> | void;
106
+ canvasOptions?: CanvasRenderOptions;
107
+ canvasOutputPath?: string;
108
+ enableCanvas?: boolean;
109
+ }
110
+ export declare const defaultCanvasOptions: Required<CanvasRenderOptions>;
111
+ export declare class PerformanceRunner<TContext = Record<string, unknown>> {
112
+ protected readonly scenario: PerformanceScenario<TContext>;
113
+ constructor(scenario: PerformanceScenario<TContext>);
114
+ run(): Promise<PhaseResult<TContext>[]>;
115
+ protected runPhase(phase: Phase<TContext>, context: TContext): Promise<PhaseResult<TContext>>;
116
+ protected runWarmup(phase: Phase<TContext>, context: TContext): Promise<void>;
117
+ protected computeLoadFactor(config: PhaseConfig<TContext>, iteration: number): number;
118
+ protected buildSegmentIndices(iterations: number, burst?: PhaseBurstConfig): number[][];
119
+ protected mergeContext(phase: Phase<TContext>): TContext;
120
+ protected mergeContexts(a: TContext, b: Partial<TContext>): TContext;
121
+ protected executeSegment(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
122
+ protected collectSequential(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
123
+ protected collectConcurrent(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, indices: number[]): Promise<IterationMetric[]>;
124
+ protected runIteration(handler: PerformanceHandler<TContext>, config: PhaseConfig<TContext>, context: TContext, iteration: number): Promise<IterationMetric>;
125
+ protected aggregateMetrics(metrics: IterationMetric[]): AggregatedMetrics;
126
+ protected logPhaseTable(result: PhaseResult<TContext>): void;
127
+ protected logSummary(results: PhaseResult<TContext>[]): Promise<void>;
128
+ protected shouldRenderCanvas(): boolean;
129
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @description Creates a promise that resolves after a specified time.
3
+ * @summary Utility function that pauses execution for a given number of milliseconds.
4
+ *
5
+ * @param {number} ms - The number of milliseconds to wait.
6
+ * @return {Promise<void>} A promise that resolves after the specified timeout.
7
+ *
8
+ * @function awaitTimeout
9
+ *
10
+ * @memberOf module:utils
11
+ */
12
+ export declare function awaitTimeout(ms: number): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @description Creates a promise that resolves after a specified time.
3
+ * @summary Utility function that pauses execution for a given number of milliseconds.
4
+ *
5
+ * @param {number} ms - The number of milliseconds to wait.
6
+ * @return {Promise<void>} A promise that resolves after the specified timeout.
7
+ *
8
+ * @function awaitTimeout
9
+ *
10
+ * @memberOf module:utils
11
+ */
12
+ export declare function awaitTimeout(ms: number): Promise<void>;