@decaf-ts/utils 1.2.3 → 1.3.1
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/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/cjs/cli/commands/build-scripts.cjs +27 -10
- package/lib/cjs/cli/commands/build-scripts.cjs.map +1 -1
- package/lib/cjs/index.cjs +1 -1
- package/lib/esm/cli/commands/build-scripts.js +27 -10
- package/lib/esm/cli/commands/build-scripts.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/types/cli/command.d.cts +3 -3
- package/lib/types/cli/command.d.mts +3 -3
- package/lib/types/cli/commands/build-scripts.d.cts +4 -3
- package/lib/types/cli/commands/build-scripts.d.mts +4 -3
- package/lib/types/cli/commands/index.d.cts +3 -3
- package/lib/types/cli/commands/index.d.mts +3 -3
- package/lib/types/cli/commands/release-chain.d.cts +3 -3
- package/lib/types/cli/commands/release-chain.d.mts +3 -3
- package/lib/types/cli/commands/tag-release.d.cts +2 -2
- package/lib/types/cli/commands/tag-release.d.mts +2 -2
- package/lib/types/cli/index.d.cts +4 -4
- package/lib/types/cli/index.d.mts +4 -4
- package/lib/types/cli/types.d.cts +1 -1
- package/lib/types/cli/types.d.mts +1 -1
- package/lib/types/index.d.cts +7 -7
- package/lib/types/index.d.mts +7 -7
- package/lib/types/input/index.d.cts +2 -2
- package/lib/types/input/index.d.mts +2 -2
- package/lib/types/input/input.d.cts +1 -1
- package/lib/types/input/input.d.mts +1 -1
- package/lib/types/output/index.d.cts +1 -1
- package/lib/types/output/index.d.mts +1 -1
- package/lib/types/tests/Consumer.d.cts +1 -1
- package/lib/types/tests/Consumer.d.mts +1 -1
- package/lib/types/tests/TestReporter.d.cts +1 -1
- package/lib/types/tests/TestReporter.d.mts +1 -1
- package/lib/types/tests/index.d.cts +4 -4
- package/lib/types/tests/index.d.mts +4 -4
- package/lib/types/tests/jestPerformanceRunner.d.cts +1 -1
- package/lib/types/tests/jestPerformanceRunner.d.mts +1 -1
- package/lib/types/tests/utils.d.cts +3 -3
- package/lib/types/tests/utils.d.mts +3 -3
- package/lib/types/utils/fs.d.cts +1 -1
- package/lib/types/utils/fs.d.mts +1 -1
- package/lib/types/utils/index.d.cts +6 -6
- package/lib/types/utils/index.d.mts +6 -6
- package/lib/types/utils/utils.d.cts +3 -3
- package/lib/types/utils/utils.d.mts +3 -3
- package/lib/types/writers/RegexpOutputWriter.d.cts +2 -2
- package/lib/types/writers/RegexpOutputWriter.d.mts +2 -2
- package/lib/types/writers/StandardOutputWriter.d.cts +3 -3
- package/lib/types/writers/StandardOutputWriter.d.mts +3 -3
- package/lib/types/writers/index.d.cts +4 -4
- package/lib/types/writers/index.d.mts +4 -4
- package/lib/types/writers/types.d.cts +2 -2
- package/lib/types/writers/types.d.mts +2 -2
- package/package.json +1 -1
- package/lib/types/assets/slogans.d.ts +0 -19
- package/lib/types/bin/build-scripts.d.ts +0 -1
- package/lib/types/bin/release-chain-dispatch.d.ts +0 -1
- package/lib/types/bin/release-chain.d.ts +0 -1
- package/lib/types/bin/tag-release.d.ts +0 -1
- package/lib/types/cli/command.d.ts +0 -104
- package/lib/types/cli/commands/build-scripts.d.ts +0 -148
- package/lib/types/cli/commands/index.d.ts +0 -3
- package/lib/types/cli/commands/release-chain.d.ts +0 -62
- package/lib/types/cli/commands/tag-release.d.ts +0 -105
- package/lib/types/cli/constants.d.ts +0 -75
- package/lib/types/cli/index.d.ts +0 -4
- package/lib/types/cli/types.d.ts +0 -30
- package/lib/types/index.d.ts +0 -38
- package/lib/types/input/index.d.ts +0 -2
- package/lib/types/input/input.d.ts +0 -517
- package/lib/types/input/types.d.ts +0 -159
- package/lib/types/output/common.d.ts +0 -53
- package/lib/types/output/index.d.ts +0 -1
- package/lib/types/release-chain/index.d.ts +0 -43
- package/lib/types/tests/Consumer.d.ts +0 -151
- package/lib/types/tests/ProducerChildProcess.d.ts +0 -18
- package/lib/types/tests/TestReporter.d.ts +0 -245
- package/lib/types/tests/index.d.ts +0 -4
- package/lib/types/tests/jestPerformanceRunner.d.ts +0 -37
- package/lib/types/tests/utils.d.ts +0 -5
- package/lib/types/utils/constants.d.ts +0 -65
- package/lib/types/utils/fs.d.ts +0 -259
- package/lib/types/utils/http.d.ts +0 -41
- package/lib/types/utils/index.d.ts +0 -6
- package/lib/types/utils/md.d.ts +0 -156
- package/lib/types/utils/performanceRunner.d.ts +0 -129
- package/lib/types/utils/timeout.d.ts +0 -12
- package/lib/types/utils/types.d.ts +0 -112
- package/lib/types/utils/utils.d.ts +0 -133
- package/lib/types/writers/OutputWriter.d.ts +0 -49
- package/lib/types/writers/RegexpOutputWriter.d.ts +0 -110
- package/lib/types/writers/StandardOutputWriter.d.ts +0 -130
- package/lib/types/writers/index.d.ts +0 -4
- package/lib/types/writers/types.d.ts +0 -29
package/lib/types/utils/fs.d.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { DependencyMap, SimpleDependencyMap } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @description Patches a file with given values.
|
|
5
|
-
* @summary Reads a file, applies patches using TextUtils, and writes the result back to the file.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} path - The path to the file to be patched.
|
|
8
|
-
* @param {Record<string, number | string>} values - The values to patch into the file.
|
|
9
|
-
* @return {void}
|
|
10
|
-
*
|
|
11
|
-
* @function patchFile
|
|
12
|
-
*
|
|
13
|
-
* @mermaid
|
|
14
|
-
* sequenceDiagram
|
|
15
|
-
* participant Caller
|
|
16
|
-
* participant patchFile
|
|
17
|
-
* participant fs
|
|
18
|
-
* participant readFile
|
|
19
|
-
* participant TextUtils
|
|
20
|
-
* participant writeFile
|
|
21
|
-
* Caller->>patchFile: Call with path and values
|
|
22
|
-
* patchFile->>fs: Check if file exists
|
|
23
|
-
* patchFile->>readFile: Read file content
|
|
24
|
-
* readFile->>fs: Read file
|
|
25
|
-
* fs-->>readFile: Return file content
|
|
26
|
-
* readFile-->>patchFile: Return file content
|
|
27
|
-
* patchFile->>TextUtils: Patch string
|
|
28
|
-
* TextUtils-->>patchFile: Return patched content
|
|
29
|
-
* patchFile->>writeFile: Write patched content
|
|
30
|
-
* writeFile->>fs: Write to file
|
|
31
|
-
* fs-->>writeFile: File written
|
|
32
|
-
* writeFile-->>patchFile: File written
|
|
33
|
-
* patchFile-->>Caller: Patching complete
|
|
34
|
-
*
|
|
35
|
-
* @memberOf module:utils
|
|
36
|
-
*/
|
|
37
|
-
export declare function patchFile(path: string, values: Record<string, number | string>, filter?: (str: string) => boolean): void;
|
|
38
|
-
/**
|
|
39
|
-
* @description Reads a file and returns its content.
|
|
40
|
-
* @summary Reads the content of a file at the specified path and returns it as a string.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} path - The path to the file to be read.
|
|
43
|
-
* @return {string} The content of the file.
|
|
44
|
-
*
|
|
45
|
-
* @function readFile
|
|
46
|
-
*
|
|
47
|
-
* @memberOf module:utils
|
|
48
|
-
*/
|
|
49
|
-
export declare function readFile(path: string): string;
|
|
50
|
-
/**
|
|
51
|
-
* @description Writes data to a file.
|
|
52
|
-
* @summary Writes the provided data to a file at the specified path.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} path - The path to the file to be written.
|
|
55
|
-
* @param {string | Buffer} data - The data to be written to the file.
|
|
56
|
-
* @return {void}
|
|
57
|
-
*
|
|
58
|
-
* @function writeFile
|
|
59
|
-
*
|
|
60
|
-
* @memberOf module:utils
|
|
61
|
-
*/
|
|
62
|
-
export declare function writeFile(path: string, data: string | Buffer): void;
|
|
63
|
-
/**
|
|
64
|
-
* @description Retrieves all files recursively from a directory.
|
|
65
|
-
* @summary Traverses through directories and subdirectories to collect all file paths.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} p - The path to start searching from.
|
|
68
|
-
* @param {function} [filter] - Optional function to filter files by name or index.
|
|
69
|
-
* @return {string[]} Array of file paths.
|
|
70
|
-
*
|
|
71
|
-
* @function getAllFiles
|
|
72
|
-
*
|
|
73
|
-
* @memberOf module:utils
|
|
74
|
-
*/
|
|
75
|
-
export declare function getAllFiles(p: string, filter?: (f: string, i?: number) => boolean): string[];
|
|
76
|
-
/**
|
|
77
|
-
* @description Renames a file or directory.
|
|
78
|
-
* @summary Moves a file or directory from the source path to the destination path.
|
|
79
|
-
*
|
|
80
|
-
* @param {string} source - The source path of the file or directory.
|
|
81
|
-
* @param {string} dest - The destination path for the file or directory.
|
|
82
|
-
* @return {Promise<void>} A promise that resolves when the rename operation is complete.
|
|
83
|
-
*
|
|
84
|
-
* @function renameFile
|
|
85
|
-
*
|
|
86
|
-
* @memberOf module:utils
|
|
87
|
-
*/
|
|
88
|
-
export declare function renameFile(source: string, dest: string): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* @description Copies a file or directory.
|
|
91
|
-
* @summary Creates a copy of a file or directory from the source path to the destination path.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} source - The source path of the file or directory.
|
|
94
|
-
* @param {string} dest - The destination path for the file or directory.
|
|
95
|
-
* @return {void}
|
|
96
|
-
*
|
|
97
|
-
* @function copyFile
|
|
98
|
-
*
|
|
99
|
-
* @memberOf module:utils
|
|
100
|
-
*/
|
|
101
|
-
export declare function copyFile(source: string, dest: string): void;
|
|
102
|
-
/**
|
|
103
|
-
* @description Deletes a file or directory.
|
|
104
|
-
* @summary Removes a file or directory at the specified path, with recursive and force options enabled.
|
|
105
|
-
*
|
|
106
|
-
* @param {string} p - The path to the file or directory to delete.
|
|
107
|
-
* @return {void}
|
|
108
|
-
*
|
|
109
|
-
* @function deletePath
|
|
110
|
-
*
|
|
111
|
-
* @memberOf module:utils
|
|
112
|
-
*/
|
|
113
|
-
export declare function deletePath(p: string): void;
|
|
114
|
-
/**
|
|
115
|
-
* @description Retrieves package information from package.json.
|
|
116
|
-
* @summary Loads and parses the package.json file from a specified directory or the current working directory. Can return the entire package object or a specific property.
|
|
117
|
-
* @param {string} [p=process.cwd()] - The directory path where the package.json file is located.
|
|
118
|
-
* @param {string} [property] - Optional. The specific property to retrieve from package.json.
|
|
119
|
-
* @return {object | string} The parsed contents of package.json or the value of the specified property.
|
|
120
|
-
* @function getPackage
|
|
121
|
-
* @mermaid
|
|
122
|
-
* sequenceDiagram
|
|
123
|
-
* participant Caller
|
|
124
|
-
* participant getPackage
|
|
125
|
-
* participant readFile
|
|
126
|
-
* participant JSON
|
|
127
|
-
* Caller->>getPackage: Call with path and optional property
|
|
128
|
-
* getPackage->>readFile: Read package.json
|
|
129
|
-
* readFile-->>getPackage: Return file content
|
|
130
|
-
* getPackage->>JSON: Parse file content
|
|
131
|
-
* JSON-->>getPackage: Return parsed object
|
|
132
|
-
* alt property specified
|
|
133
|
-
* getPackage->>getPackage: Check if property exists
|
|
134
|
-
* alt property exists
|
|
135
|
-
* getPackage-->>Caller: Return property value
|
|
136
|
-
* else property doesn't exist
|
|
137
|
-
* getPackage-->>Caller: Throw Error
|
|
138
|
-
* end
|
|
139
|
-
* else no property specified
|
|
140
|
-
* getPackage-->>Caller: Return entire package object
|
|
141
|
-
* end
|
|
142
|
-
* @memberOf module:utils
|
|
143
|
-
*/
|
|
144
|
-
export declare function getPackage(p?: string, property?: string): object | string;
|
|
145
|
-
/**
|
|
146
|
-
* @description Sets an attribute in the package.json file.
|
|
147
|
-
* @summary Updates a specific attribute in the package.json file with the provided value.
|
|
148
|
-
*
|
|
149
|
-
* @param {string} attr - The attribute name to set in package.json.
|
|
150
|
-
* @param {string | number | object} value - The value to set for the attribute.
|
|
151
|
-
* @param {string} [p=process.cwd()] - The directory path where the package.json file is located.
|
|
152
|
-
* @return {void}
|
|
153
|
-
*
|
|
154
|
-
* @function setPackageAttribute
|
|
155
|
-
*
|
|
156
|
-
* @memberOf module:utils
|
|
157
|
-
*/
|
|
158
|
-
export declare function setPackageAttribute(attr: string, value: string, p?: string): void;
|
|
159
|
-
/**
|
|
160
|
-
* @description Retrieves the version from package.json.
|
|
161
|
-
* @summary A convenience function that calls getPackage to retrieve the "version" property from package.json.
|
|
162
|
-
* @param {string} [p=process.cwd()] - The directory path where the package.json file is located.
|
|
163
|
-
* @return {string} The version string from package.json.
|
|
164
|
-
* @function getPackageVersion
|
|
165
|
-
* @memberOf module:utils
|
|
166
|
-
*/
|
|
167
|
-
export declare function getPackageVersion(p?: string): string;
|
|
168
|
-
/**
|
|
169
|
-
* @description Retrieves all dependencies from the project.
|
|
170
|
-
* @summary Executes 'npm ls --json' command to get a detailed list of all dependencies (production, development, and peer) and their versions.
|
|
171
|
-
* @param {string} [path=process.cwd()] - The directory path of the project.
|
|
172
|
-
* @return {Promise<{prod: Array<{name: string, version: string}>, dev: Array<{name: string, version: string}>, peer: Array<{name: string, version: string}>}>} An object containing arrays of production, development, and peer dependencies.
|
|
173
|
-
* @function getDependencies
|
|
174
|
-
* @mermaid
|
|
175
|
-
* sequenceDiagram
|
|
176
|
-
* participant Caller
|
|
177
|
-
* participant getDependencies
|
|
178
|
-
* participant runCommand
|
|
179
|
-
* participant JSON
|
|
180
|
-
* Caller->>getDependencies: Call with optional path
|
|
181
|
-
* getDependencies->>runCommand: Execute 'npm ls --json'
|
|
182
|
-
* runCommand-->>getDependencies: Return command output
|
|
183
|
-
* getDependencies->>JSON: Parse command output
|
|
184
|
-
* JSON-->>getDependencies: Return parsed object
|
|
185
|
-
* getDependencies->>getDependencies: Process dependencies
|
|
186
|
-
* getDependencies-->>Caller: Return processed dependencies
|
|
187
|
-
* @memberOf module:utils
|
|
188
|
-
*/
|
|
189
|
-
export declare function getDependencies(p?: string): Promise<DependencyMap>;
|
|
190
|
-
/**
|
|
191
|
-
* @description Updates project dependencies to their latest versions.
|
|
192
|
-
* @summary Runs npm-check-updates to update package.json and then installs the updated dependencies.
|
|
193
|
-
*
|
|
194
|
-
* @return {Promise<void>} A promise that resolves when dependencies are updated.
|
|
195
|
-
*
|
|
196
|
-
* @function updateDependencies
|
|
197
|
-
*
|
|
198
|
-
* @memberOf module:utils
|
|
199
|
-
*/
|
|
200
|
-
export declare function updateDependencies(): Promise<void>;
|
|
201
|
-
/**
|
|
202
|
-
* @description Installs dependencies if they are not already available.
|
|
203
|
-
* @summary Checks if specified dependencies are installed and installs any that are missing.
|
|
204
|
-
*
|
|
205
|
-
* @param {string[] | string} deps - The dependencies to check and potentially install.
|
|
206
|
-
* @param {SimpleDependencyMap} [dependencies] - Optional map of existing dependencies.
|
|
207
|
-
* @return {Promise<SimpleDependencyMap>} Updated map of dependencies.
|
|
208
|
-
*
|
|
209
|
-
* @function installIfNotAvailable
|
|
210
|
-
*
|
|
211
|
-
* @memberOf module:utils
|
|
212
|
-
*/
|
|
213
|
-
export declare function installIfNotAvailable(deps: string[] | string, dependencies?: SimpleDependencyMap): Promise<SimpleDependencyMap>;
|
|
214
|
-
/**
|
|
215
|
-
* @description Pushes changes to Git repository.
|
|
216
|
-
* @summary Temporarily changes Git user configuration, commits all changes, pushes to remote, and restores original user configuration.
|
|
217
|
-
*
|
|
218
|
-
* @return {Promise<void>} A promise that resolves when changes are pushed.
|
|
219
|
-
*
|
|
220
|
-
* @function pushToGit
|
|
221
|
-
*
|
|
222
|
-
* @memberOf module:utils
|
|
223
|
-
*/
|
|
224
|
-
export declare function pushToGit(): Promise<void>;
|
|
225
|
-
/**
|
|
226
|
-
* @description Installs project dependencies.
|
|
227
|
-
* @summary Installs production, development, and peer dependencies as specified.
|
|
228
|
-
*
|
|
229
|
-
* @param {object} dependencies - Object containing arrays of dependencies to install.
|
|
230
|
-
* @param {string[]} [dependencies.prod] - Production dependencies to install.
|
|
231
|
-
* @param {string[]} [dependencies.dev] - Development dependencies to install.
|
|
232
|
-
* @param {string[]} [dependencies.peer] - Peer dependencies to install.
|
|
233
|
-
* @return {Promise<void>} A promise that resolves when all dependencies are installed.
|
|
234
|
-
*
|
|
235
|
-
* @function installDependencies
|
|
236
|
-
*
|
|
237
|
-
* @memberOf module:utils
|
|
238
|
-
*/
|
|
239
|
-
export declare function installDependencies(dependencies: {
|
|
240
|
-
prod?: string[];
|
|
241
|
-
dev?: string[];
|
|
242
|
-
peer?: string[];
|
|
243
|
-
}): Promise<void>;
|
|
244
|
-
/**
|
|
245
|
-
* @description Normalizes imports to handle both CommonJS and ESModule formats.
|
|
246
|
-
* @summary Utility function to handle module import differences between formats.
|
|
247
|
-
*
|
|
248
|
-
* @template T - Type of the imported module.
|
|
249
|
-
* @param {Promise<T>} importPromise - Promise returned by dynamic import.
|
|
250
|
-
* @return {Promise<T>} Normalized module.
|
|
251
|
-
*
|
|
252
|
-
* @function normalizeImport
|
|
253
|
-
*
|
|
254
|
-
* @memberOf module:utils
|
|
255
|
-
*/
|
|
256
|
-
export declare function normalizeImport<T>(importPromise: Promise<T>): Promise<T>;
|
|
257
|
-
export declare function getFileSizeZipped(dir: string): Promise<number>;
|
|
258
|
-
export declare function listFolder(basePath?: string, filter?: (name: string, dirent: fs.Dirent) => boolean): string[];
|
|
259
|
-
export declare function listNodeModulesPackages(basePath?: string): string[];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description A simple HTTP client for downloading files.
|
|
3
|
-
* @summary This class provides functionality to download files from HTTPS URLs.
|
|
4
|
-
* It uses Node.js built-in https module to make requests.
|
|
5
|
-
*
|
|
6
|
-
* @class HttpClient
|
|
7
|
-
*/
|
|
8
|
-
export declare class HttpClient {
|
|
9
|
-
protected static log: import("@decaf-ts/logging").Logger;
|
|
10
|
-
/**
|
|
11
|
-
* @description Downloads a file from a given URL.
|
|
12
|
-
* @summary This method sends a GET request to the specified URL and returns the response body as a string.
|
|
13
|
-
* It handles different scenarios such as non-200 status codes and network errors.
|
|
14
|
-
*
|
|
15
|
-
* @param url - The URL of the file to download.
|
|
16
|
-
* @return A promise that resolves with the file content as a string.
|
|
17
|
-
*
|
|
18
|
-
* @mermaid
|
|
19
|
-
* sequenceDiagram
|
|
20
|
-
* participant Client
|
|
21
|
-
* participant HttpClient
|
|
22
|
-
* participant HTTPS
|
|
23
|
-
* participant Server
|
|
24
|
-
* Client->>HttpClient: downloadFile(url)
|
|
25
|
-
* HttpClient->>HTTPS: get(url)
|
|
26
|
-
* HTTPS->>Server: GET request
|
|
27
|
-
* Server-->>HTTPS: Response
|
|
28
|
-
* HTTPS-->>HttpClient: Response object
|
|
29
|
-
* alt Status code is 200
|
|
30
|
-
* loop For each data chunk
|
|
31
|
-
* HTTPS->>HttpClient: 'data' event
|
|
32
|
-
* HttpClient->>HttpClient: Accumulate data
|
|
33
|
-
* end
|
|
34
|
-
* HTTPS->>HttpClient: 'end' event
|
|
35
|
-
* HttpClient-->>Client: Resolve with data
|
|
36
|
-
* else Status code is not 200
|
|
37
|
-
* HttpClient-->>Client: Reject with error
|
|
38
|
-
* end
|
|
39
|
-
*/
|
|
40
|
-
static downloadFile(url: string): Promise<string>;
|
|
41
|
-
}
|
package/lib/types/utils/md.d.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
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;
|
|
@@ -1,129 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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>;
|