@gesslar/bedoc 1.2.0 → 1.3.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.
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/cli.d.ts.map +10 -0
- package/dist/types/core/ActionManager.d.ts +27 -0
- package/dist/types/core/ActionManager.d.ts.map +10 -0
- package/dist/types/core/Configuration.d.ts +27 -0
- package/dist/types/core/Configuration.d.ts.map +10 -0
- package/dist/types/core/ConfigurationParameters.d.ts +38 -0
- package/dist/types/core/ConfigurationParameters.d.ts.map +10 -0
- package/dist/types/core/Conveyor.d.ts +47 -0
- package/dist/types/core/Conveyor.d.ts.map +10 -0
- package/dist/types/core/Core.d.ts +53 -0
- package/dist/types/core/Core.d.ts.map +10 -0
- package/dist/types/core/Discovery.d.ts +73 -0
- package/dist/types/core/Discovery.d.ts.map +10 -0
- package/dist/types/core/HookManager.d.ts +60 -0
- package/dist/types/core/HookManager.d.ts.map +10 -0
- package/dist/types/core/Logger.d.ts +55 -0
- package/dist/types/core/Logger.d.ts.map +10 -0
- package/dist/types/core/action/ParseManager.d.ts +8 -0
- package/dist/types/core/action/ParseManager.d.ts.map +10 -0
- package/dist/types/core/action/PrintManager.d.ts +8 -0
- package/dist/types/core/action/PrintManager.d.ts.map +10 -0
- package/dist/types/core/util/ActionUtil.d.ts +35 -0
- package/dist/types/core/util/ActionUtil.d.ts.map +10 -0
- package/dist/types/core/util/DataUtil.d.ts +52 -0
- package/dist/types/core/util/DataUtil.d.ts.map +10 -0
- package/dist/types/core/util/FDUtil.d.ts +146 -0
- package/dist/types/core/util/FDUtil.d.ts.map +10 -0
- package/dist/types/core/util/ModuleUtil.d.ts +27 -0
- package/dist/types/core/util/ModuleUtil.d.ts.map +10 -0
- package/dist/types/core/util/StringUtil.d.ts +5 -0
- package/dist/types/core/util/StringUtil.d.ts.map +10 -0
- package/dist/types/core/util/TypeSpec.d.ts +42 -0
- package/dist/types/core/util/TypeSpec.d.ts.map +10 -0
- package/dist/types/core/util/ValidUtil.d.ts +29 -0
- package/dist/types/core/util/ValidUtil.d.ts.map +10 -0
- package/package.json +10 -2
- package/src/core/Conveyor.js +16 -5
- package/src/core/Discovery.js +5 -5
- package/src/core/Logger.js +1 -9
- package/src/core/util/DataUtil.js +3 -1
- package/src/core/util/FDUtil.js +1 -1
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Logger from './Logger';
|
|
2
|
+
import HookManager from './HookManager';
|
|
3
|
+
|
|
4
|
+
export interface ActionDefinition {
|
|
5
|
+
action: string;
|
|
6
|
+
contract: Record<string, unknown>;
|
|
7
|
+
meta: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class ActionManager {
|
|
11
|
+
constructor(actionDefinition: ActionDefinition, logger: Logger);
|
|
12
|
+
get action(): ActionDefinition;
|
|
13
|
+
set hookManager(hookManager: HookManager);
|
|
14
|
+
get hookManager(): HookManager;
|
|
15
|
+
get contract(): Record<string, unknown>;
|
|
16
|
+
get meta(): Record<string, unknown>;
|
|
17
|
+
get log(): Logger;
|
|
18
|
+
setupAction(): Promise<void>;
|
|
19
|
+
runAction({ file, content }: {
|
|
20
|
+
file: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
cleanupAction(): Promise<void>;
|
|
24
|
+
toString(): string;
|
|
25
|
+
#private;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ActionManager.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ActionManager.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/ActionManager.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAEA;IAQE,gDAKC;IAsBD,kBAEC;IAMD,kCAQC;IAZD,uBAEC;IAYD,oBAEC;IAED,gBAEC;IAED,eAEC;IA0CD,6BAKC;IAED;;;qBAWC;IAED,+BAMC;IAED,mBAEC;;CACF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Environment } from './Core';
|
|
2
|
+
|
|
3
|
+
interface ConfigurationOption {
|
|
4
|
+
value: unknown;
|
|
5
|
+
source: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ConfigurationOptions {
|
|
9
|
+
[key: string]: ConfigurationOption;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ValidateParams {
|
|
13
|
+
options: ConfigurationOptions;
|
|
14
|
+
source: typeof Environment;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ValidationResult {
|
|
18
|
+
status: 'success';
|
|
19
|
+
validated: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default class Configuration {
|
|
24
|
+
validate({ options, source }: ValidateParams): Promise<ValidationResult>;
|
|
25
|
+
#private;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import TypeSpec from './util/TypeSpec';
|
|
2
|
+
|
|
3
|
+
interface PathConfig {
|
|
4
|
+
type: 'file' | 'directory';
|
|
5
|
+
mustExist: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ConfigurationParameter {
|
|
9
|
+
short: string;
|
|
10
|
+
param?: string;
|
|
11
|
+
description: string;
|
|
12
|
+
type: TypeSpec;
|
|
13
|
+
required: boolean;
|
|
14
|
+
default?: boolean | number | string;
|
|
15
|
+
path?: PathConfig;
|
|
16
|
+
exclusiveOf?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ConfigurationParametersType {
|
|
20
|
+
input: ConfigurationParameter;
|
|
21
|
+
exclude: ConfigurationParameter;
|
|
22
|
+
language: ConfigurationParameter;
|
|
23
|
+
format: ConfigurationParameter;
|
|
24
|
+
maxConcurrent: ConfigurationParameter;
|
|
25
|
+
hooks: ConfigurationParameter;
|
|
26
|
+
output: ConfigurationParameter;
|
|
27
|
+
parser: ConfigurationParameter;
|
|
28
|
+
printer: ConfigurationParameter;
|
|
29
|
+
hookTimeout: ConfigurationParameter;
|
|
30
|
+
mock: ConfigurationParameter;
|
|
31
|
+
config: ConfigurationParameter;
|
|
32
|
+
debug: ConfigurationParameter;
|
|
33
|
+
debugLevel: ConfigurationParameter;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ConfigurationParameters: Readonly<ConfigurationParametersType>;
|
|
37
|
+
export const ConfigurationPriorityKeys: readonly ['exclude', 'input'];
|
|
38
|
+
//# sourceMappingURL=ConfigurationParameters.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ConfigurationParameters.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/ConfigurationParameters.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIE;AAEF,0DAAqE"
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import ActionManager from './ActionManager';
|
|
2
|
+
import Logger from './Logger';
|
|
3
|
+
import { FileMap } from './util/FDUtil';
|
|
4
|
+
|
|
5
|
+
interface ProcessResult {
|
|
6
|
+
status: 'success' | 'error' | 'warning';
|
|
7
|
+
file?: FileMap;
|
|
8
|
+
error?: Error;
|
|
9
|
+
warning?: string;
|
|
10
|
+
result?: string;
|
|
11
|
+
destFile?: string;
|
|
12
|
+
content?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ConveyResult {
|
|
16
|
+
succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
17
|
+
errored: Array<{ input: FileMap; error: Error }>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default class Conveyor {
|
|
21
|
+
constructor(
|
|
22
|
+
parse: ActionManager,
|
|
23
|
+
print: ActionManager,
|
|
24
|
+
logger: Logger,
|
|
25
|
+
output: FileMap
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
readonly parse: ActionManager;
|
|
29
|
+
readonly print: ActionManager;
|
|
30
|
+
readonly logger: Logger;
|
|
31
|
+
readonly output: FileMap;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Processes files with a concurrency limit.
|
|
35
|
+
*
|
|
36
|
+
* @param files - List of files to process.
|
|
37
|
+
* @param maxConcurrent - Maximum number of concurrent tasks.
|
|
38
|
+
* @returns Resolves when all files are processed.
|
|
39
|
+
*/
|
|
40
|
+
convey(files: FileMap[], maxConcurrent?: number): Promise<ConveyResult>;
|
|
41
|
+
|
|
42
|
+
#succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
43
|
+
#errored: Array<{ input: FileMap; error: Error }>;
|
|
44
|
+
#processFile(file: FileMap): Promise<ProcessResult>;
|
|
45
|
+
#writeOutput(destFile: string, content: string): Promise<ProcessResult>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=Conveyor.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "Conveyor.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/Conveyor.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAMA;IAIE,8DAKC;IAJC,WAAkB;IAClB,WAAkB;IAClB,YAAoB;IACpB,YAAoB;IAGtB;;;;;;OAMG;IACH,qCAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CA8B3B;;CAgFF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import Logger from './Logger';
|
|
2
|
+
import ActionManager from './ActionManager';
|
|
3
|
+
import { FileMap } from './util/FDUtil';
|
|
4
|
+
|
|
5
|
+
export const Environment: Readonly<{
|
|
6
|
+
EXTENSION: 'extension';
|
|
7
|
+
NPM: 'npm';
|
|
8
|
+
ACTION: 'action';
|
|
9
|
+
CLI: 'cli';
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export type EnvironmentType = typeof Environment[keyof typeof Environment];
|
|
13
|
+
|
|
14
|
+
interface CoreOptions {
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
debugLevel?: number;
|
|
17
|
+
name?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface CoreConstructorOptions extends CoreOptions {
|
|
22
|
+
hooks?: string;
|
|
23
|
+
hooksTimeout?: number;
|
|
24
|
+
output?: string;
|
|
25
|
+
maxConcurrent?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface NewParams {
|
|
29
|
+
options: CoreOptions;
|
|
30
|
+
source: EnvironmentType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ProcessResult {
|
|
34
|
+
succeeded: Array<{ input: FileMap; output: FileMap }>;
|
|
35
|
+
errored: Array<{ input: FileMap; error: Error }>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default class Core {
|
|
39
|
+
static new({ options, source }: NewParams): Promise<Core>;
|
|
40
|
+
|
|
41
|
+
constructor(options: CoreConstructorOptions);
|
|
42
|
+
|
|
43
|
+
readonly options: CoreConstructorOptions;
|
|
44
|
+
readonly logger: Logger;
|
|
45
|
+
readonly packageJson: Record<string, unknown>;
|
|
46
|
+
readonly debugOptions: {
|
|
47
|
+
name: string | null;
|
|
48
|
+
debugLevel: number;
|
|
49
|
+
};
|
|
50
|
+
readonly actions: Record<string, ActionManager>;
|
|
51
|
+
|
|
52
|
+
processFiles(glob: string | string[], startTime?: [number, number]): Promise<ProcessResult>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "Core.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/Core.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAkBA;;;;;GAKE;AAEF;IASE;;;sBAoFC;IA5FD,0BAMC;IALC,aAAsB;IAEtB,eAAgE;IAChE,iBAAiD;IACjD;;;MAAuC;IAyFzC;;;OAsDC;CACF;mBA3KkB,aAAa"
|
|
10
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import Core from './Core';
|
|
2
|
+
import { FileMap } from './util/FDUtil';
|
|
3
|
+
import ActionManager from './ActionManager';
|
|
4
|
+
|
|
5
|
+
interface DiscoveryOptions {
|
|
6
|
+
print?: FileMap;
|
|
7
|
+
parse?: FileMap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ActionDefinition {
|
|
11
|
+
file: FileMap;
|
|
12
|
+
action: {
|
|
13
|
+
meta: {
|
|
14
|
+
action: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
contract: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ActionMap {
|
|
22
|
+
print: ActionDefinition[];
|
|
23
|
+
parse: ActionDefinition[];
|
|
24
|
+
[key: string]: ActionDefinition[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ValidCriteria {
|
|
28
|
+
parse: ActionDefinition[];
|
|
29
|
+
print: ActionDefinition[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class Discovery {
|
|
33
|
+
constructor(core: Core);
|
|
34
|
+
readonly core: Core;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Discover actions from local or global node_modules
|
|
38
|
+
*
|
|
39
|
+
* @param specific Configuration options for action discovery
|
|
40
|
+
* @returns A map of discovered modules
|
|
41
|
+
*/
|
|
42
|
+
discoverActions(specific?: DiscoveryOptions): Promise<ActionMap>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check which actions satisfy the configuration criteria
|
|
46
|
+
*/
|
|
47
|
+
satisfyCriteria(actions: ActionMap, validatedConfig: Record<string, unknown>): ValidCriteria;
|
|
48
|
+
|
|
49
|
+
#loadModule(module: FileMap): Promise<{
|
|
50
|
+
file: FileMap;
|
|
51
|
+
actions: ActionManager[];
|
|
52
|
+
contracts: string[];
|
|
53
|
+
}>;
|
|
54
|
+
|
|
55
|
+
#getModuleExports(dirMap: FileMap): FileMap[];
|
|
56
|
+
|
|
57
|
+
#loadActionsAndContracts(
|
|
58
|
+
moduleFiles: FileMap[],
|
|
59
|
+
specific: {
|
|
60
|
+
print?: FileMap;
|
|
61
|
+
parse?: FileMap;
|
|
62
|
+
}
|
|
63
|
+
): Promise<ActionMap>;
|
|
64
|
+
|
|
65
|
+
#validMeta(
|
|
66
|
+
actionType: string,
|
|
67
|
+
toValidate: {
|
|
68
|
+
action: ActionDefinition['action'];
|
|
69
|
+
contract: ActionDefinition['contract'];
|
|
70
|
+
}
|
|
71
|
+
): boolean;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=Discovery.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "Discovery.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/Discovery.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAYA;IAIE,uBAIC;IAHC,UAAgB;IAKlB;;;;;;;OAOG;IACH,0BAJG;QAAyB,KAAK,GAAtB,MAAM;QACW,KAAK,GAAtB,MAAM;KACd,GAAU,OAAO,CAAC,MAAM,CAAC,CAsE3B;IA6JD;;;MAiDC;;CA4DF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Logger from './Logger';
|
|
2
|
+
import { FileMap } from './util/FDUtil';
|
|
3
|
+
|
|
4
|
+
type HookEvent = 'start' | 'section_load' | 'enter' | 'exit' | 'end';
|
|
5
|
+
|
|
6
|
+
interface HookResult {
|
|
7
|
+
status?: 'success' | 'error';
|
|
8
|
+
error?: Error;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface HooksDefinition {
|
|
13
|
+
setup?: () => Promise<void>;
|
|
14
|
+
cleanup?: () => Promise<void>;
|
|
15
|
+
start?: (...args: unknown[]) => Promise<HookResult>;
|
|
16
|
+
section_load?: (...args: unknown[]) => Promise<HookResult>;
|
|
17
|
+
enter?: (...args: unknown[]) => Promise<HookResult>;
|
|
18
|
+
exit?: (...args: unknown[]) => Promise<HookResult>;
|
|
19
|
+
end?: (...args: unknown[]) => Promise<HookResult>;
|
|
20
|
+
log?: Logger;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface HookManagerConstructorParams {
|
|
24
|
+
action: string;
|
|
25
|
+
hooksFile: FileMap;
|
|
26
|
+
logger: Logger;
|
|
27
|
+
timeOut: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const hookPoints: Readonly<Record<Uppercase<HookEvent>, HookEvent>>;
|
|
31
|
+
|
|
32
|
+
export default class HookManager {
|
|
33
|
+
static new(arg: HookManagerConstructorParams): Promise<HookManager | null>;
|
|
34
|
+
|
|
35
|
+
constructor({ action, hooksFile, logger, timeOut: timeout }: HookManagerConstructorParams);
|
|
36
|
+
|
|
37
|
+
get action(): string;
|
|
38
|
+
get hooksFile(): FileMap;
|
|
39
|
+
get hooks(): HooksDefinition | null;
|
|
40
|
+
get log(): Logger;
|
|
41
|
+
get timeout(): number;
|
|
42
|
+
get setup(): (() => Promise<void>) | null;
|
|
43
|
+
get cleanup(): (() => Promise<void>) | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Trigger a hook
|
|
47
|
+
*
|
|
48
|
+
* @param event - The type of hook to trigger
|
|
49
|
+
* @param args - The hook arguments
|
|
50
|
+
* @returns The result of the hook
|
|
51
|
+
*/
|
|
52
|
+
on(event: HookEvent, ...args: unknown[]): Promise<HookResult | undefined>;
|
|
53
|
+
|
|
54
|
+
#hooksFile: FileMap | null;
|
|
55
|
+
#log: Logger | null;
|
|
56
|
+
#hooks: HooksDefinition | null;
|
|
57
|
+
#action: string | null;
|
|
58
|
+
#timeout: number;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=HookManager.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "HookManager.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/HookManager.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAUA,sCAKC;AAED;IA0CE,6CAsCC;IAzED;;;;;OAKC;IAED,kBAEC;IAED,qBAEC;IAED,iBAEC;IAED,eAEC;IAED,sBAEC;IAED,iBAEC;IAED,mBAEC;IA0CD;;;;;;OAMG;IACH,UAJW,MAAM,WACH,GAAG,EAAA,GACJ,OAAO,CAAC,GAAG,CAAC,CAsCxB;;CACF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import ErrorStackParser from 'error-stack-parser';
|
|
2
|
+
import * as vscode from 'vscode';
|
|
3
|
+
|
|
4
|
+
interface LoggerOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
debugLevel?: number;
|
|
7
|
+
env?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type LogLevel = 'debug' | 'warn' | 'info' | 'error';
|
|
11
|
+
type DebugLevel = 0 | 1 | 2 | 3 | 4;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Logger class
|
|
15
|
+
*
|
|
16
|
+
* Log levels:
|
|
17
|
+
* - debug: Debugging information
|
|
18
|
+
* - Debug levels
|
|
19
|
+
* - 0: No/critical debug information, not error level, but should be logged
|
|
20
|
+
* - 1: Basic debug information, startup, shutdown, etc
|
|
21
|
+
* - 2: Intermediate debug information, discovery
|
|
22
|
+
* - 3: Detailed debug information, parsing, processing, etc
|
|
23
|
+
* - 4: Very detailed debug information, nerd mode!
|
|
24
|
+
* - warn: Warning information
|
|
25
|
+
* - info: Informational information
|
|
26
|
+
* - error: Error information
|
|
27
|
+
*/
|
|
28
|
+
export default class Logger {
|
|
29
|
+
constructor(options?: LoggerOptions);
|
|
30
|
+
|
|
31
|
+
readonly vscodeError?: typeof vscode.window.showErrorMessage;
|
|
32
|
+
readonly vscodeWarn?: typeof vscode.window.showWarningMessage;
|
|
33
|
+
readonly vscodeInfo?: typeof vscode.window.showInformationMessage;
|
|
34
|
+
|
|
35
|
+
get name(): string;
|
|
36
|
+
get debugLevel(): number;
|
|
37
|
+
get options(): Required<Pick<LoggerOptions, 'name' | 'debugLevel'>>;
|
|
38
|
+
|
|
39
|
+
setOptions(options: LoggerOptions): void;
|
|
40
|
+
|
|
41
|
+
lastStackLine(error?: Error, stepsRemoved?: number): ErrorStackParser.StackFrame;
|
|
42
|
+
extractFileFunction(level?: DebugLevel): string;
|
|
43
|
+
|
|
44
|
+
newDebug(tag?: string): (message: string, level?: DebugLevel, ...args: unknown[]) => void;
|
|
45
|
+
|
|
46
|
+
debug(message: string, level?: DebugLevel, ...args: unknown[]): void;
|
|
47
|
+
warn(message: string, ...args: unknown[]): void;
|
|
48
|
+
info(message: string, ...args: unknown[]): void;
|
|
49
|
+
error(message: string, ...args: unknown[]): void;
|
|
50
|
+
|
|
51
|
+
#name: string | null;
|
|
52
|
+
#debugLevel: number;
|
|
53
|
+
#compose(level: LogLevel, message: string, debugLevel?: DebugLevel): string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "Logger.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/core/Logger.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAkDA;;;;;;;;;;;;;;;;GAgBG;AAEH;IAIE,0BAWC;IALK,iBAAiD;IACjD,gBAAkD;IAClD,gBAAsD;IAK5D,gBAEC;IAED,yBAEC;IAED;;;MAKC;IAED,+BAGC;IAWD,iFAGC;IAED,4CAoCC;IAED,wBAKC;IAED,yDAGC;IAED,wCAGC;IAED,wCAGC;IAED,yCAGC;;CACF;6BA7J4B,oBAAoB"
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ActionManager from '../ActionManager';
|
|
2
|
+
import Logger from '../Logger';
|
|
3
|
+
import { ActionDefinition } from "../ActionManager";
|
|
4
|
+
|
|
5
|
+
export default class ParseManager extends ActionManager {
|
|
6
|
+
constructor(actionDefinition: ActionDefinition, logger: Logger);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ParseManager.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ActionManager from '../ActionManager';
|
|
2
|
+
import Logger from '../Logger';
|
|
3
|
+
import { ActionDefinition } from "../ActionManager";
|
|
4
|
+
|
|
5
|
+
export default class PrintManager extends ActionManager {
|
|
6
|
+
constructor(actionDefinition: ActionDefinition, logger: Logger);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=PrintManager.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FileMap } from './FDUtil';
|
|
2
|
+
|
|
3
|
+
type ActionType = 'parse' | 'print';
|
|
4
|
+
|
|
5
|
+
interface ActionMeta {
|
|
6
|
+
action: ActionType;
|
|
7
|
+
language?: string;
|
|
8
|
+
format?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ActionRequirement {
|
|
12
|
+
action: ActionType;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ActionMetaRequirement = ActionRequirement | keyof ActionMeta;
|
|
16
|
+
|
|
17
|
+
export const actionMetaRequirements: Readonly<Record<ActionType, ActionMetaRequirement[]>>;
|
|
18
|
+
export const actionTypes: readonly ActionType[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Loads a JSON file asynchronously
|
|
22
|
+
*
|
|
23
|
+
* @param jsonFileObject - The JSON file to load
|
|
24
|
+
* @returns The parsed JSON content
|
|
25
|
+
*/
|
|
26
|
+
export function loadJson(jsonFileObject: FileMap): Record<string, unknown>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Loads the package.json file asynchronously
|
|
30
|
+
*
|
|
31
|
+
* @param basePath - The base path to use
|
|
32
|
+
* @returns The parsed package.json content
|
|
33
|
+
*/
|
|
34
|
+
export function loadPackageJson(basePath?: string | FileMap | null): Record<string, unknown>;
|
|
35
|
+
//# sourceMappingURL=ActionUtil.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ActionUtil.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/ActionUtil.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAQA;;;;;;;GAGE;AALF,4CAA8C;AAO9C;;;;;GAKG;AACH,yCAHW,MAAM,GACJ,MAAM,CAOlB;AAED;;;;;GAKG;AACH,2CAHW,MAAM,GAAC,MAAM,GACX,MAAM,CAOlB"
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Logger from '../Logger';
|
|
2
|
+
import TypeSpec from './TypeSpec';
|
|
3
|
+
|
|
4
|
+
type PrimitiveType = 'undefined' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'object' | 'function';
|
|
5
|
+
type ConstructorType = 'object' | 'array' | 'function' | 'date' | 'regexp' | 'error' | 'map' | 'set' | 'weakmap' | 'weakset' | 'promise' | 'int8array' | 'uint8array' | 'float32array' | 'float64array';
|
|
6
|
+
type DataType = PrimitiveType | ConstructorType;
|
|
7
|
+
|
|
8
|
+
export const dataTypes: readonly DataType[];
|
|
9
|
+
export const emptyableTypes: readonly ['string', 'array', 'object'];
|
|
10
|
+
|
|
11
|
+
interface TypeSpecOptions {
|
|
12
|
+
allowEmpty?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface SchemaCompareResult {
|
|
16
|
+
status: 'success' | 'error';
|
|
17
|
+
errors: Error[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function allocateObject<T>(source: string[], spec: T[] | ((source: string[]) => Promise<T[]>)): Promise<Record<string, T>>;
|
|
21
|
+
export function appendString(str: string, append: string): string;
|
|
22
|
+
export function prependString(str: string, prepend: string): string;
|
|
23
|
+
export function arrayIntersection<T>(arr1: T[], arr2: T[]): T[];
|
|
24
|
+
export function arrayPad<T>(arr: T[], length: number, value: T, position?: 0 | -1): T[];
|
|
25
|
+
export function isArrayUniform(arr: unknown[], type?: string): boolean;
|
|
26
|
+
export function isArrayUnique<T>(arr: T[]): T[];
|
|
27
|
+
|
|
28
|
+
export function cloneObject<T extends Record<string, unknown>>(obj: T, freeze?: boolean): T;
|
|
29
|
+
export function deepFreezeObject<T extends Record<string, unknown>>(obj: T): Readonly<T>;
|
|
30
|
+
export function isObjectEmpty(obj: Record<string, unknown>): boolean;
|
|
31
|
+
|
|
32
|
+
export function mapObject<T extends Record<string, unknown>>(
|
|
33
|
+
original: T,
|
|
34
|
+
transformer: (key: string, value: unknown) => Promise<unknown>,
|
|
35
|
+
mutate?: boolean
|
|
36
|
+
): Promise<T>;
|
|
37
|
+
|
|
38
|
+
export function isNothing(value: unknown): value is null | undefined;
|
|
39
|
+
export function isEmpty(value: unknown, checkForNothing?: boolean): boolean;
|
|
40
|
+
export function isType(value: unknown, type: string | TypeSpec, options: TypeSpecOptions): boolean;
|
|
41
|
+
export function isBaseType(value: unknown, type: DataType): boolean;
|
|
42
|
+
export function isValidType(type: string): type is DataType;
|
|
43
|
+
export function typeOf(value: unknown): DataType;
|
|
44
|
+
|
|
45
|
+
export function newTypeSpec(str: string, options?: TypeSpecOptions): TypeSpec;
|
|
46
|
+
|
|
47
|
+
export function schemaCompare(
|
|
48
|
+
schema: Record<string, unknown>,
|
|
49
|
+
definition: Record<string, unknown>,
|
|
50
|
+
stack?: string[],
|
|
51
|
+
logger?: Logger
|
|
52
|
+
): SchemaCompareResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "DataUtil.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/DataUtil.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAwCA,iCAA8E;AAE9E,sCAAoD;AAwGpD;;;;;;GAMG;AACH,uCAJW,GAAG,QACH,GAAG,WAAS,GACV,OAAO,CAAC,MAAM,CAAC,CA2C3B;AAtJD;;;;;;GAMG;AACH,qCAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAIlB;AAqCD;;;;;;GAMG;AACH,mEAEC;AAED;;;;;;;;;GASG;AACH,6CALW,MAAM,SACN,GAAG,aACH,MAAM,SAgBhB;AAED;;;;;;GAMG;AACH,iCAJW,MAAM,WACN,OAAO,GACL,MAAM,CAalB;AAqND;;;;;GAKG;AACH,sCAHW,MAAM,GACJ,MAAM,CAmBlB;AA1TD;;;;;;;GAOG;AACH,iDAJW,MAAM,GAEJ,OAAO,CAMnB;AAED;;;;;GAKG;AACH,iDAEC;AAkLD;;;;;;;;GAQG;AACH,kCAJW,GAAG,QACH,MAAM,GACJ,OAAO,CAgCnB;AAsBD;;;;;;;;GAQG;AACH,+BALW,GAAG,oBACH,OAAO,GAEL,OAAO,CAqBnB;AAtCD;;;;;GAKG;AACH,iCAHW,GAAG,GACD,OAAO,CAInB;AA1GD;;;;;GAKG;AACH,mCAHW,MAAM,GACJ,OAAO,CAInB;AAcD;;;;;;;GAOG;AACH,8BALW,GAAG,QACH,MAAM,GAAC,QAAQ,WACf,MAAM,GACJ,OAAO,CAOnB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,OAAO,CAInB;AApED;;;;;;;GAOG;AACH,oCALW,MAAM,kCAEN,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAe3B;AAYD;;;;;;;GAOG;AACH,oCAJW,MAAM,WACN,MAAM,GACJ,MAAM,EAAE,CAIpB;AAxLD;;;;;;GAMG;AACH,sCAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAIlB;AA8TD;;;;;;;;GAQG;AACH,sCANW,MAAM,cACN,MAAM,0BAEN,MAAM,GACJ,OAAO,CA+DnB;AAjJD;;;;;GAKG;AACH,8BAHW,GAAG,GACD,MAAM,CAIlB;qBA1ToB,eAAe"
|
|
10
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export type FDType = 'file' | 'directory';
|
|
2
|
+
|
|
3
|
+
export interface FileMap {
|
|
4
|
+
path: string;
|
|
5
|
+
uri: string;
|
|
6
|
+
absolutePath: string;
|
|
7
|
+
absoluteUri: string;
|
|
8
|
+
name: string;
|
|
9
|
+
module: string;
|
|
10
|
+
extension: string;
|
|
11
|
+
isFile: true;
|
|
12
|
+
isDirectory: false;
|
|
13
|
+
directory?: DirMap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DirMap {
|
|
17
|
+
path: string;
|
|
18
|
+
uri: string;
|
|
19
|
+
absolutePath: string;
|
|
20
|
+
absoluteUri: string;
|
|
21
|
+
name: string;
|
|
22
|
+
separator: string;
|
|
23
|
+
isFile: false;
|
|
24
|
+
isDirectory: true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FilenameParts {
|
|
28
|
+
basename: string;
|
|
29
|
+
dirname: string;
|
|
30
|
+
extname: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const fdType: Readonly<Record<Uppercase<FDType>, FDType>>;
|
|
34
|
+
export const fdTypes: readonly FDType[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Compose a directory map from a path
|
|
38
|
+
*
|
|
39
|
+
* @param {string} directory - The directory
|
|
40
|
+
* @returns {DirMap} A directory object
|
|
41
|
+
*/
|
|
42
|
+
export function composeDirectory(directory: string): DirMap;
|
|
43
|
+
/**
|
|
44
|
+
* Compose a file path from a directory and a file
|
|
45
|
+
*
|
|
46
|
+
* @param {string|DirMap} directoryNameorObject - The directory
|
|
47
|
+
* @param {string} fileName - The file
|
|
48
|
+
* @returns {FileMap} A file object
|
|
49
|
+
*/
|
|
50
|
+
export function composeFilename(directoryNameorObject: string | DirMap, fileName: string): FileMap;
|
|
51
|
+
/**
|
|
52
|
+
* Deconstruct a filename into parts
|
|
53
|
+
*
|
|
54
|
+
* @param {string} fileName - The filename to deconstruct
|
|
55
|
+
* @returns {FilenameParts} The filename parts
|
|
56
|
+
*/
|
|
57
|
+
export function deconstructFilenameToParts(fileName: string): FilenameParts;
|
|
58
|
+
/**
|
|
59
|
+
* Fix slashes in a path
|
|
60
|
+
*
|
|
61
|
+
* @param {string} pathName - The path to fix
|
|
62
|
+
* @returns {string} The fixed path
|
|
63
|
+
*/
|
|
64
|
+
export function fixSlashes(pathName: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieve all files matching a specific glob pattern.
|
|
67
|
+
*
|
|
68
|
+
* @param {string|string[]} globPattern - The glob pattern(s) to search.
|
|
69
|
+
* @returns {Promise<FileMap[]>} An array of file objects
|
|
70
|
+
* @throws {Error} Throws an error for invalid input or search failure.
|
|
71
|
+
*/
|
|
72
|
+
export function getFiles(globPattern: string | string[]): Promise<FileMap[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Lists the contents of a directory.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} directory - The directory to list.
|
|
77
|
+
* @returns {Promise<{files: FileMap[], directories: DirMap[]}>} The files and
|
|
78
|
+
* directories in the directory.
|
|
79
|
+
*/
|
|
80
|
+
export function ls(directory: string): Promise<{
|
|
81
|
+
files: FileMap[];
|
|
82
|
+
directories: DirMap[];
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Map a directory to a DirMap
|
|
86
|
+
*
|
|
87
|
+
* @param {string} directoryName - The directory to map
|
|
88
|
+
* @returns {DirMap} A directory object
|
|
89
|
+
*/
|
|
90
|
+
export function mapDirectory(directoryName: string): DirMap;
|
|
91
|
+
/**
|
|
92
|
+
* Map a file to a FileMap
|
|
93
|
+
*
|
|
94
|
+
* @param {string} fileName - The file to map
|
|
95
|
+
* @returns {FileMap} A file object
|
|
96
|
+
*/
|
|
97
|
+
export function mapFilename(fileName: string): FileMap;
|
|
98
|
+
/**
|
|
99
|
+
* Convert a path to a URI
|
|
100
|
+
*
|
|
101
|
+
* @param {string} pathName - The path to convert
|
|
102
|
+
* @returns {string} The URI
|
|
103
|
+
* @throws {Error} If the path is not a valid file path
|
|
104
|
+
*/
|
|
105
|
+
export function pathToUri(pathName: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Reads the content of a file synchronously.
|
|
108
|
+
*
|
|
109
|
+
* @param {FileMap} fileObject - The file map containing the file path
|
|
110
|
+
* @returns {string} The file contents
|
|
111
|
+
*/
|
|
112
|
+
export function readFile(fileObject: FileMap): string;
|
|
113
|
+
/**
|
|
114
|
+
* Resolves a path to an absolute path
|
|
115
|
+
*
|
|
116
|
+
* @param {string} directoryName - The path to resolve
|
|
117
|
+
* @returns {DirMap} The directory object
|
|
118
|
+
* @throws {Error}
|
|
119
|
+
*/
|
|
120
|
+
export function resolveDirectory(directoryName: string): DirMap;
|
|
121
|
+
/**
|
|
122
|
+
* Resolves a file to an absolute path
|
|
123
|
+
*
|
|
124
|
+
* @param {string} fileName - The file to resolve
|
|
125
|
+
* @param {DirMap} [directoryObject] - The directory object to resolve the
|
|
126
|
+
* file in
|
|
127
|
+
* @returns {FileMap} A file object (validated)
|
|
128
|
+
* @throws {Error}
|
|
129
|
+
*/
|
|
130
|
+
export function resolveFilename(fileName: string, directoryObject?: DirMap | null): FileMap;
|
|
131
|
+
/**
|
|
132
|
+
* Convert a URI to a path
|
|
133
|
+
*
|
|
134
|
+
* @param {string} pathName - The URI to convert
|
|
135
|
+
* @returns {string} The path
|
|
136
|
+
* @throws {Error} If the URI is not a valid file URL
|
|
137
|
+
*/
|
|
138
|
+
export function uriToPath(pathName: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Writes content to a file synchronously.
|
|
141
|
+
*
|
|
142
|
+
* @param {FileMap} fileObject - The file map containing the file path
|
|
143
|
+
* @param {string} content - The content to write
|
|
144
|
+
*/
|
|
145
|
+
export function writeFile(fileObject: FileMap, content: string): void;
|
|
146
|
+
//# sourceMappingURL=FDUtil.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "FDUtil.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/FDUtil.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAgBA,yBAAkE;AAFlE,0BAA6C;AA0N7C;;;;;GAKG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAjJD;;;;;;GAMG;AACH,uDAJW,MAAM,GAAC,MAAM,YACb,MAAM,GACJ,MAAM,CAiBlB;AAyCD;;;;;GAKG;AACH,qDAHW,MAAM,GACJ,MAAM,CAMlB;AAtJD;;;;;GAKG;AACH,qCAHW,MAAM,GACJ,MAAM,CAIlB;AAgJD;;;;;;GAMG;AACH,sCAJW,MAAM,GAAC,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CA+B7B;AAqCD;;;;;;GAMG;AACH,8BAJW,MAAM,GACJ,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAsB7D;AAjID;;;;;GAKG;AACH,4CAHW,MAAM,GACJ,MAAM,CAalB;AArCD;;;;;GAKG;AACH,sCAHW,MAAM,GACJ,MAAM,CAclB;AA7GD;;;;;;GAMG;AACH,oCAJW,MAAM,GACJ,MAAM,CAUlB;AAoOD;;;;;GAKG;AACH,qCAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAW3B;AA9ED;;;;;;GAMG;AACH,gDAJW,MAAM,GACJ,MAAM,CAmBlB;AA1KD;;;;;;;;GAQG;AACH,0CANW,MAAM,oBACN,MAAM,GAEJ,MAAM,CA2BlB;AAjDD;;;;;;GAMG;AACH,oCAJW,MAAM,GACJ,MAAM,CAUlB;AAqOD;;;;;GAKG;AACH,sCAHW,MAAM,WACN,MAAM,QAShB"
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FileMap } from './FDUtil';
|
|
2
|
+
|
|
3
|
+
export default class ModuleUtil {
|
|
4
|
+
/**
|
|
5
|
+
* Requires a module synchronously
|
|
6
|
+
*
|
|
7
|
+
* @param {FileMap} fileObject - The file to require
|
|
8
|
+
* @returns {unknown} The required module
|
|
9
|
+
*/
|
|
10
|
+
static require(fileObject: FileMap): unknown;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Loads a JSON file asynchronously
|
|
14
|
+
*
|
|
15
|
+
* @param {FileMap} jsonFileObject - The JSON file to load
|
|
16
|
+
* @returns {Promise<Record<string, unknown>>} The parsed JSON content
|
|
17
|
+
*/
|
|
18
|
+
static loadJson(jsonFileObject: FileMap): Promise<Record<string, unknown>>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Loads the package.json file asynchronously
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise<Record<string, unknown>>} The parsed package.json content
|
|
24
|
+
*/
|
|
25
|
+
static loadPackageJson(): Promise<Record<string, unknown>>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ModuleUtil.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ModuleUtil.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/ModuleUtil.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAGA;IACE;;;;;OAKG;IACH,2BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,gCAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAO3B;IAED;;;;OAIG;IACH,0BAFa,OAAO,CAAC,MAAM,CAAC,CAO3B;CACF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DataType } from './DataUtil';
|
|
2
|
+
|
|
3
|
+
interface TypeSpecification {
|
|
4
|
+
typeName: DataType;
|
|
5
|
+
array: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface TypeSpecOptions {
|
|
9
|
+
delimiter?: string;
|
|
10
|
+
allowEmpty?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface TypeSpecJSON {
|
|
14
|
+
specs: TypeSpecification[];
|
|
15
|
+
length: number;
|
|
16
|
+
stringRepresentation: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class TypeSpec {
|
|
20
|
+
constructor(typeString: string, options?: TypeSpecOptions);
|
|
21
|
+
|
|
22
|
+
readonly specs: readonly TypeSpecification[];
|
|
23
|
+
readonly length: number;
|
|
24
|
+
readonly stringRepresentation: string;
|
|
25
|
+
|
|
26
|
+
toString(): string;
|
|
27
|
+
toJSON(): TypeSpecJSON;
|
|
28
|
+
|
|
29
|
+
forEach(callback: (spec: TypeSpecification) => void): void;
|
|
30
|
+
every(callback: (spec: TypeSpecification) => boolean): boolean;
|
|
31
|
+
some(callback: (spec: TypeSpecification) => boolean): boolean;
|
|
32
|
+
filter(callback: (spec: TypeSpecification) => boolean): TypeSpecification[];
|
|
33
|
+
map<T>(callback: (spec: TypeSpecification) => T): T[];
|
|
34
|
+
reduce<T>(callback: (acc: T, spec: TypeSpecification) => T, initialValue: T): T;
|
|
35
|
+
find(callback: (spec: TypeSpecification) => boolean): TypeSpecification | undefined;
|
|
36
|
+
|
|
37
|
+
match(value: unknown, options?: TypeSpecOptions): boolean;
|
|
38
|
+
|
|
39
|
+
#specs: TypeSpecification[];
|
|
40
|
+
#parse(typeString: string, options?: TypeSpecOptions): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=TypeSpec.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "TypeSpec.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/TypeSpec.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAIA;IAGE,uCAQC;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C,mBAMC;IAED;;;;MAOC;IAED,6BAEC;IACD,8BAEC;IACD,6BAEC;IACD,6BAEC;IACD,0BAEC;IACD,8CAEC;IACD,yBAEC;IAED,yCAqCC;;CAoBF"
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import TypeSpec from './TypeSpec';
|
|
2
|
+
|
|
3
|
+
interface ValidTypeOptions {
|
|
4
|
+
allowEmpty?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Validates a value against a type
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} If the value does not match the expected type
|
|
11
|
+
*/
|
|
12
|
+
export function validType(
|
|
13
|
+
value: unknown,
|
|
14
|
+
type: string | TypeSpec,
|
|
15
|
+
options?: ValidTypeOptions,
|
|
16
|
+
depth?: number
|
|
17
|
+
): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Asserts a condition
|
|
21
|
+
*
|
|
22
|
+
* @throws {Error} If the condition is not met, with optional argument in message
|
|
23
|
+
*/
|
|
24
|
+
export function assert(
|
|
25
|
+
condition: boolean,
|
|
26
|
+
message: string,
|
|
27
|
+
arg?: number | null
|
|
28
|
+
): asserts condition;
|
|
29
|
+
//# sourceMappingURL=ValidUtil.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "ValidUtil.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../../src/core/util/ValidUtil.js"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAsBA;;;;;;;;GAQG;AACH,kCANW,OAAO,WACP,MAAM,QAEN,MAAM,QAmBhB;AAzCD;;;;;;;GAOG;AACH,iCALW,GAAC,QACD,MAAM,YAEN,MAAM,QAQhB"
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/bedoc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Pluggable documentation engine for any language and format",
|
|
5
5
|
"publisher": "gesslar",
|
|
6
6
|
"main": "./src/core/Core.js",
|
|
@@ -14,12 +14,20 @@
|
|
|
14
14
|
"bin": {
|
|
15
15
|
"bedoc": "src/cli.js"
|
|
16
16
|
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./src/core/Core.js",
|
|
20
|
+
"types": "./dist/types/core/Core.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
17
23
|
"type": "module",
|
|
24
|
+
"types": "dist/types/index.d.ts",
|
|
18
25
|
"scripts": {
|
|
19
26
|
"lint:check": "npx eslint .",
|
|
20
27
|
"lint:fix": "npx eslint . --fix"
|
|
21
28
|
},
|
|
22
29
|
"dependencies": {
|
|
30
|
+
"@gesslar/bedoc": "^1.2.0",
|
|
23
31
|
"commander": "^13.0.0",
|
|
24
32
|
"dotenv": "^16.4.7",
|
|
25
33
|
"error-stack-parser": "^2.1.4",
|
|
@@ -30,7 +38,7 @@
|
|
|
30
38
|
"yaml": "^2.7.0"
|
|
31
39
|
},
|
|
32
40
|
"devDependencies": {
|
|
33
|
-
"@stylistic/eslint-plugin-js": "^
|
|
41
|
+
"@stylistic/eslint-plugin-js": "^3.0.0",
|
|
34
42
|
"axios": "^1.7.9",
|
|
35
43
|
"chokidar": "^4.0.3",
|
|
36
44
|
"eslint": "^9.18.0",
|
package/src/core/Conveyor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {format} from "node:util"
|
|
2
|
+
|
|
1
3
|
import * as FDUtil from "./util/FDUtil.js"
|
|
2
4
|
|
|
3
5
|
const {readFile, writeFile, composeFilename} = FDUtil
|
|
@@ -31,10 +33,11 @@ export default class Conveyor {
|
|
|
31
33
|
const slot = Promise.race(semaphore) // Wait for an available slot
|
|
32
34
|
semaphore.push(slot.then(async() => {
|
|
33
35
|
const result = await this.#processFile(file)
|
|
34
|
-
if(result.status === "success")
|
|
36
|
+
if(result.status === "success" || result.status === "warning")
|
|
35
37
|
this.#succeeded.push({input: file, output: result.file})
|
|
36
|
-
else
|
|
38
|
+
else {
|
|
37
39
|
this.#errored.push({input: file, error: result.error})
|
|
40
|
+
}
|
|
38
41
|
}))
|
|
39
42
|
semaphore.shift() // Remove the oldest promise
|
|
40
43
|
}
|
|
@@ -57,6 +60,7 @@ export default class Conveyor {
|
|
|
57
60
|
*/
|
|
58
61
|
async #processFile(file) {
|
|
59
62
|
const debug = this.logger.newDebug()
|
|
63
|
+
const warn = (...arg) => this.logger.warn(...arg)
|
|
60
64
|
const {parse, print} = this
|
|
61
65
|
|
|
62
66
|
try {
|
|
@@ -87,9 +91,16 @@ export default class Conveyor {
|
|
|
87
91
|
debug("Printed file successfully: `%s`", 2, file.path)
|
|
88
92
|
|
|
89
93
|
// Step 4: Write output
|
|
90
|
-
const {destFile, content} = printResult
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
const {status: printStatus, destFile, content} = printResult
|
|
95
|
+
const isNullish = (value) => value == null // Checks null or undefined
|
|
96
|
+
|
|
97
|
+
if(printStatus !== "success" || isNullish(destFile) || isNullish(content)) {
|
|
98
|
+
return {status: "error", file, error: new Error("Invalid print result")}
|
|
99
|
+
} else if(!destFile || !content) {
|
|
100
|
+
const mess = format("No content or destination file for %s", file.path)
|
|
101
|
+
warn(mess)
|
|
102
|
+
return {status: "warning", file, warning: mess}
|
|
103
|
+
}
|
|
93
104
|
|
|
94
105
|
const writeResult = await this.#writeOutput(destFile, content)
|
|
95
106
|
|
package/src/core/Discovery.js
CHANGED
|
@@ -23,10 +23,12 @@ export default class Discovery {
|
|
|
23
23
|
/**
|
|
24
24
|
* Discover actions from local or global node_modules
|
|
25
25
|
*
|
|
26
|
-
* @param {object[]
|
|
26
|
+
* @param {object} [specific] Configuration options for action discovery
|
|
27
|
+
* @param {object} [specific.print] Print-related configuration options
|
|
28
|
+
* @param {object} [specific.parse] Parse-related configuration options
|
|
27
29
|
* @returns {Promise<object>} A map of discovered modules
|
|
28
30
|
*/
|
|
29
|
-
async discoverActions(
|
|
31
|
+
async discoverActions(specific = {}) {
|
|
30
32
|
const debug = this.#debug
|
|
31
33
|
|
|
32
34
|
debug("Discovering actions", 2)
|
|
@@ -90,9 +92,7 @@ export default class Discovery {
|
|
|
90
92
|
|
|
91
93
|
debug("Discovered %d actions", 2, bucket.length)
|
|
92
94
|
|
|
93
|
-
return await this.#loadActionsAndContracts(
|
|
94
|
-
bucket, {print: print, parse: parse}
|
|
95
|
-
)
|
|
95
|
+
return await this.#loadActionsAndContracts(bucket, specific)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
package/src/core/Logger.js
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
import console from "node:console"
|
|
27
27
|
import ErrorStackParser from "error-stack-parser"
|
|
28
|
-
|
|
29
28
|
import {Environment} from "./Core.js"
|
|
30
29
|
|
|
31
30
|
import * as FDUtil from "./util/FDUtil.js"
|
|
@@ -68,7 +67,6 @@ const loggerColours = {
|
|
|
68
67
|
|
|
69
68
|
export default class Logger {
|
|
70
69
|
#name = null
|
|
71
|
-
#debugMode = false
|
|
72
70
|
#debugLevel = 0
|
|
73
71
|
|
|
74
72
|
constructor(options) {
|
|
@@ -88,10 +86,6 @@ export default class Logger {
|
|
|
88
86
|
return this.#name
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
get debugMode() {
|
|
92
|
-
return this.#debugMode
|
|
93
|
-
}
|
|
94
|
-
|
|
95
89
|
get debugLevel() {
|
|
96
90
|
return this.#debugLevel
|
|
97
91
|
}
|
|
@@ -99,14 +93,12 @@ export default class Logger {
|
|
|
99
93
|
get options() {
|
|
100
94
|
return {
|
|
101
95
|
name: this.#name,
|
|
102
|
-
debugMode: this.#debugMode,
|
|
103
96
|
debugLevel: this.#debugLevel,
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
setOptions(options) {
|
|
108
101
|
this.#name = options.name ?? this.#name
|
|
109
|
-
this.#debugMode = options.debugMode
|
|
110
102
|
this.#debugLevel = options.debugLevel
|
|
111
103
|
}
|
|
112
104
|
|
|
@@ -170,7 +162,7 @@ export default class Logger {
|
|
|
170
162
|
}
|
|
171
163
|
|
|
172
164
|
debug(message, level = 0, ...arg) {
|
|
173
|
-
if(
|
|
165
|
+
if(level <= (this.debugLevel ?? 4))
|
|
174
166
|
console.debug(this.#compose("debug", message, level), ...arg)
|
|
175
167
|
}
|
|
176
168
|
|
|
@@ -247,7 +247,7 @@ function newTypeSpec(string, options) {
|
|
|
247
247
|
* @param {object} options Additional options for checking
|
|
248
248
|
* @returns {boolean} Whether the value is of the specified type
|
|
249
249
|
*/
|
|
250
|
-
function isType(value, type, options) {
|
|
250
|
+
function isType(value, type, options = {}) {
|
|
251
251
|
const typeSpec = type instanceof TypeSpec ? type : newTypeSpec(type, options)
|
|
252
252
|
// we're comparing a typeSpec object to a File object. this will always
|
|
253
253
|
// return false. do fix.
|
|
@@ -453,6 +453,8 @@ function schemaCompare(schema, definition, stack = [], logger = new Logger()) {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
export {
|
|
456
|
+
// Classes
|
|
457
|
+
TypeSpec,
|
|
456
458
|
// Variables
|
|
457
459
|
dataTypes,
|
|
458
460
|
emptyableTypes,
|
package/src/core/util/FDUtil.js
CHANGED
|
@@ -272,7 +272,7 @@ async function ls(directory) {
|
|
|
272
272
|
* Reads the content of a file synchronously.
|
|
273
273
|
*
|
|
274
274
|
* @param {object} fileObject - The file map containing the file path
|
|
275
|
-
* @returns {
|
|
275
|
+
* @returns {string} The file contents
|
|
276
276
|
*/
|
|
277
277
|
function readFile(fileObject) {
|
|
278
278
|
const {absolutePath} = fileObject
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["src/**/*.js"], // Match all .js files in the src/ directory
|
|
3
|
+
"exclude": ["node_modules"], // Ignore node_modules/ (but NOT src/)
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022", // Modern JavaScript output
|
|
6
|
+
"allowJs": true, // Process .js files
|
|
7
|
+
"declaration": true, // Generate .d.ts files
|
|
8
|
+
"emitDeclarationOnly": true, // Only output .d.ts files
|
|
9
|
+
"declarationMap": true, // Generate .d.ts.map for IDE support
|
|
10
|
+
"module": "NodeNext", // Use ESM-compatible Node.js modules
|
|
11
|
+
"moduleResolution": "nodenext", // Resolve ESM imports properly
|
|
12
|
+
"rootDir": "src", // Base input directory
|
|
13
|
+
"outDir": "dist/types", // Emit .d.ts files to a separate directory
|
|
14
|
+
"strict": true, // Enable strict type-checking
|
|
15
|
+
"esModuleInterop": true, // Interoperability for CommonJS modules
|
|
16
|
+
"forceConsistentCasingInFileNames": true, // Avoid case-sensitive issues
|
|
17
|
+
"skipLibCheck": true, // Skip checking .d.ts files in node_modules/
|
|
18
|
+
"noEmitOnError": true // Prevent output if there are errors
|
|
19
|
+
}
|
|
20
|
+
}
|