@gesslar/bedoc 1.11.0 → 2.0.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 (88) hide show
  1. package/LICENSE.txt +12 -0
  2. package/README.md +15 -3
  3. package/dist/schema/bedoc.action.json +42 -0
  4. package/dist/types/Action.d.ts +3 -0
  5. package/dist/types/Action.d.ts.map +1 -0
  6. package/dist/types/BeDoc.d.ts +208 -0
  7. package/dist/types/BeDoc.d.ts.map +1 -0
  8. package/dist/types/Configuration.d.ts +11 -0
  9. package/dist/types/Configuration.d.ts.map +1 -0
  10. package/dist/types/ConfigurationParameters.d.ts +3 -0
  11. package/dist/types/ConfigurationParameters.d.ts.map +1 -0
  12. package/dist/types/Conveyor.d.ts +27 -0
  13. package/dist/types/Conveyor.d.ts.map +1 -0
  14. package/dist/types/Discovery.d.ts +215 -0
  15. package/dist/types/Discovery.d.ts.map +1 -0
  16. package/dist/types/Environment.d.ts +3 -0
  17. package/dist/types/Environment.d.ts.map +1 -0
  18. package/dist/types/Logger.d.ts +47 -0
  19. package/dist/types/Logger.d.ts.map +1 -0
  20. package/dist/types/Schema.d.ts +3 -0
  21. package/dist/types/Schema.d.ts.map +1 -0
  22. package/dist/types/cli.d.ts +2 -2
  23. package/dist/types/cli.d.ts.map +1 -10
  24. package/package.json +24 -23
  25. package/src/Action.js +9 -0
  26. package/src/BeDoc.js +276 -0
  27. package/src/CLIOutput.js +198 -0
  28. package/src/{core/Configuration.js → Configuration.js} +72 -58
  29. package/src/{core/ConfigurationParameters.js → ConfigurationParameters.js} +35 -27
  30. package/src/Conveyor.js +256 -0
  31. package/src/Discovery.js +442 -0
  32. package/src/Environment.js +8 -0
  33. package/src/{core/Logger.js → Logger.js} +30 -18
  34. package/src/Schema.js +6 -0
  35. package/src/cli.js +77 -34
  36. package/tsconfig.types.json +42 -0
  37. package/LICENSE +0 -24
  38. package/dist/types/core/ActionManager.d.ts +0 -58
  39. package/dist/types/core/ActionManager.d.ts.map +0 -10
  40. package/dist/types/core/Configuration.d.ts +0 -27
  41. package/dist/types/core/Configuration.d.ts.map +0 -10
  42. package/dist/types/core/ConfigurationParameters.d.ts +0 -38
  43. package/dist/types/core/ConfigurationParameters.d.ts.map +0 -10
  44. package/dist/types/core/Conveyor.d.ts +0 -49
  45. package/dist/types/core/Conveyor.d.ts.map +0 -10
  46. package/dist/types/core/Core.d.ts +0 -48
  47. package/dist/types/core/Core.d.ts.map +0 -10
  48. package/dist/types/core/Discovery.d.ts +0 -73
  49. package/dist/types/core/Discovery.d.ts.map +0 -10
  50. package/dist/types/core/HookManager.d.ts +0 -60
  51. package/dist/types/core/HookManager.d.ts.map +0 -10
  52. package/dist/types/core/Logger.d.ts +0 -63
  53. package/dist/types/core/Logger.d.ts.map +0 -10
  54. package/dist/types/core/action/ParseManager.d.ts +0 -8
  55. package/dist/types/core/action/ParseManager.d.ts.map +0 -10
  56. package/dist/types/core/action/PrintManager.d.ts +0 -8
  57. package/dist/types/core/action/PrintManager.d.ts.map +0 -10
  58. package/dist/types/core/util/ActionUtil.d.ts +0 -35
  59. package/dist/types/core/util/ActionUtil.d.ts.map +0 -10
  60. package/dist/types/core/util/DataUtil.d.ts +0 -52
  61. package/dist/types/core/util/DataUtil.d.ts.map +0 -10
  62. package/dist/types/core/util/FDUtil.d.ts +0 -171
  63. package/dist/types/core/util/FDUtil.d.ts.map +0 -10
  64. package/dist/types/core/util/ModuleUtil.d.ts +0 -27
  65. package/dist/types/core/util/ModuleUtil.d.ts.map +0 -10
  66. package/dist/types/core/util/StringUtil.d.ts +0 -5
  67. package/dist/types/core/util/StringUtil.d.ts.map +0 -10
  68. package/dist/types/core/util/TypeSpec.d.ts +0 -42
  69. package/dist/types/core/util/TypeSpec.d.ts.map +0 -10
  70. package/dist/types/core/util/ValidUtil.d.ts +0 -29
  71. package/dist/types/core/util/ValidUtil.d.ts.map +0 -10
  72. package/src/core/ActionManager.js +0 -147
  73. package/src/core/ContractManager.js +0 -112
  74. package/src/core/Conveyor.js +0 -185
  75. package/src/core/Core.js +0 -166
  76. package/src/core/Discovery.js +0 -403
  77. package/src/core/HookManager.js +0 -143
  78. package/src/core/action/ParseManager.js +0 -7
  79. package/src/core/action/PrintManager.js +0 -7
  80. package/src/core/contract/ParseContract.js +0 -7
  81. package/src/core/contract/PrintContract.js +0 -7
  82. package/src/core/util/ActionUtil.js +0 -62
  83. package/src/core/util/ContractUtil.js +0 -63
  84. package/src/core/util/DataUtil.js +0 -540
  85. package/src/core/util/FDUtil.js +0 -388
  86. package/src/core/util/StringUtil.js +0 -11
  87. package/src/core/util/TypeSpec.js +0 -114
  88. package/src/core/util/ValidUtil.js +0 -50
package/src/cli.js CHANGED
@@ -1,31 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import {Schemer} from "@gesslar/negotiator"
4
+ import {Data, DirectoryObject, FileObject, Glog, Sass, Tantrum, Term} from "@gesslar/toolkit"
3
5
  import {program} from "commander"
4
- import console from "node:console"
5
6
  import process from "node:process"
6
- import {fileURLToPath,URL} from "node:url"
7
+ import url from "node:url"
7
8
 
8
- import BeDoc, {Environment} from "./core/Core.js"
9
- import {ConfigurationParameters} from "./core/ConfigurationParameters.js"
10
-
11
- import * as ActionUtil from "./core/util/ActionUtil.js"
12
- import * as FDUtil from "./core/util/FDUtil.js"
13
-
14
- const {loadDataFile} = ActionUtil
15
- const {resolveFilename,resolveDirectory} = FDUtil
9
+ import BeDoc from "./BeDoc.js"
10
+ import {ConfigurationParameters} from "./ConfigurationParameters.js"
11
+ import Environment from "./Environment.js"
12
+ import Schema from "./Schema.js"
13
+ import CLIOutput from "./CLIOutput.js"
16
14
 
17
15
  // Main entry point
18
- ;(async() => {
16
+ void (async() => {
19
17
  try {
18
+ const glog = new Glog()
19
+ .withName("BeDoc")
20
+ .withStackTrace()
21
+ .noDisplayName()
22
+
20
23
  // Get package info
21
- const basePath = resolveDirectory(process.cwd())
22
- const thisPath = resolveDirectory(fileURLToPath(new URL("..", import.meta.url)))
23
- const bedocPackageJson = loadDataFile(resolveFilename("package.json", thisPath))
24
+ const thisPath = new DirectoryObject(url.fileURLToPath(new url.URL("..", import.meta.url)))
25
+ const pkgJsonFile = new FileObject("package.json", thisPath)
26
+ const pkgJson = await pkgJsonFile.loadData()
24
27
 
25
28
  // Setup program
26
29
  program
27
- .name(bedocPackageJson.name)
28
- .description(bedocPackageJson.description)
30
+ .name(pkgJson.name)
31
+ .description(pkgJson.description)
29
32
 
30
33
  // Build CLI
31
34
  for(const [name, parameter] of Object.entries(ConfigurationParameters)) {
@@ -46,7 +49,7 @@ const {resolveFilename,resolveDirectory} = FDUtil
46
49
 
47
50
  // Add version option last
48
51
  program.version(
49
- bedocPackageJson.version,
52
+ pkgJson.version,
50
53
  "-v, --version",
51
54
  "Output the version number",
52
55
  )
@@ -58,45 +61,85 @@ const {resolveFilename,resolveDirectory} = FDUtil
58
61
 
59
62
  const sources = program._optionValueSources
60
63
  const optionsWithSources = {}
64
+
61
65
  for(const [key, value] of Object.entries(options)) {
62
66
  const element = {
63
67
  value,
64
68
  source: sources[key],
65
69
  }
70
+
66
71
  optionsWithSources[key] = element
67
72
  }
68
73
 
69
74
  // Create core instance with validated config
75
+ const prjPath = new DirectoryObject()
76
+ const cliOutput = new CLIOutput({
77
+ basePath: prjPath,
78
+ terse: Boolean(options.terse),
79
+ })
80
+ const prjPkJsonFile = new FileObject("package.json", prjPath)
81
+ const prjPkjJson = await prjPkJsonFile.loadData()
82
+ const pkjBedoc = prjPkjJson?.bedoc ?? {}
83
+ const validateBeDocSchema = await loadSchemaValidator(thisPath)
84
+
70
85
  const bedoc = await BeDoc
71
86
  .new({
72
87
  options: {
73
88
  ...optionsWithSources,
74
- basePath: {value: basePath, source: "cli"},
89
+ basePath: prjPath,
90
+ project: pkjBedoc,
75
91
  },
76
- source: Environment.CLI
92
+ source: Environment.CLI,
93
+ glog,
94
+ validateBeDocSchema,
95
+ cliOutput
77
96
  })
78
97
 
79
- const filesToProcess = bedoc.options.input.map(f => f.absolutePath)
80
- const result = await bedoc.processFiles(filesToProcess)
98
+ if(!(bedoc instanceof BeDoc)) {
99
+ if(Data.isPlainObject(bedoc)) {
100
+ Term.info(bedoc.message)
101
+ process.exit(0)
102
+ }
103
+ }
104
+
105
+ Term.altScreen()
106
+
107
+ const result = await bedoc.processFiles()
108
+
109
+ Term.mainScreen()
110
+
111
+ cliOutput.render(false)
112
+
81
113
  const errored = result.errored
82
114
  const warned = result.warned
83
115
 
84
- if(warned.length > 0)
85
- warned.forEach(w => bedoc.logger.warn(w.warning))
116
+ if(warned?.length > 0)
117
+ warned.forEach(w => glog.warn(w.warning))
86
118
 
87
- if(errored.length > 0)
88
- throw new AggregateError(errored.map(e => e.error), "Error processing files")
89
- } catch(error) {
90
- if(error instanceof Error) {
91
- if(error instanceof AggregateError) {
92
- error.errors.forEach(e => console.error(e))
93
- } else {
94
- console.error(error.message, error.stack)
95
- }
96
- } else {
97
- console.error("Error: %o", error)
119
+ if(errored?.length > 0) {
120
+ const errors = errored.map(e => e.error)
121
+ Tantrum.new("Error processing files", errors).report(true)
98
122
  }
99
123
 
124
+ process.exit(0)
125
+ } catch(error) {
126
+ Term.mainScreen()
127
+
128
+ Sass.new("Starting BeDoc", error).report(true)
129
+
100
130
  process.exit(1)
101
131
  }
132
+
133
+ /**
134
+ * Load the BeDoc action schema and return a validator function.
135
+ *
136
+ * @returns {Promise<Function>} AJV validator function
137
+ */
138
+ async function loadSchemaValidator(pkgPath) {
139
+ const schemaFile = new FileObject(Schema.local, pkgPath)
140
+ if(!(await schemaFile.exists))
141
+ throw Sass.new(`Missing schema at ${schemaFile.path}`)
142
+
143
+ return await Schemer.fromFile(schemaFile)
144
+ }
102
145
  })()
@@ -0,0 +1,42 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable JavaScript support
4
+ "allowJs": true,
5
+ "checkJs": false,
6
+ "maxNodeModuleJsDepth": 0,
7
+ // Type declaration generation
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "emitDeclarationOnly": true,
11
+ // Output configuration
12
+ "outDir": "./dist/types",
13
+ "rootDir": "./src",
14
+ // Module system
15
+ "module": "ES2022",
16
+ "moduleResolution": "node",
17
+ "target": "ES2022",
18
+ // Strict type checking (helps generate better types)
19
+ "strict": false,
20
+ "noImplicitAny": false,
21
+ "strictNullChecks": false,
22
+ // Additional checks
23
+ "skipLibCheck": true,
24
+ "esModuleInterop": true,
25
+ "allowSyntheticDefaultImports": true,
26
+ "resolveJsonModule": true,
27
+ // Emit settings
28
+ "stripInternal": false,
29
+ "removeComments": false,
30
+ "preserveConstEnums": true
31
+ },
32
+ "include": [
33
+ "src/**/*.js"
34
+ ],
35
+ "exclude": [
36
+ "node_modules",
37
+ "tests",
38
+ "work",
39
+ "src/types",
40
+ "examples/"
41
+ ]
42
+ }
package/LICENSE DELETED
@@ -1,24 +0,0 @@
1
- This is free and unencumbered software released into the public domain.
2
-
3
- Anyone is free to copy, modify, publish, use, compile, sell, or
4
- distribute this software, either in source code form or as a compiled
5
- binary, for any purpose, commercial or non-commercial, and by any
6
- means.
7
-
8
- In jurisdictions that recognize copyright laws, the author or authors
9
- of this software dedicate any and all copyright interest in the
10
- software to the public domain. We make this dedication for the benefit
11
- of the public at large and to the detriment of our heirs and
12
- successors. We intend this dedication to be an overt act of
13
- relinquishment in perpetuity of all present and future rights to this
14
- software under copyright law.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
23
-
24
- For more information, please refer to <https://unlicense.org>
@@ -1,58 +0,0 @@
1
- import Logger from './Logger'
2
- import HookManager, {HookPoints} from './HookManager'
3
-
4
- export type MetaActionType = "print" | "parse"
5
-
6
- export interface MetaDefinition {
7
- action: MetaActionType
8
- }
9
-
10
- export interface ParseMetaDefinition extends MetaDefinition {
11
- action: "parse"
12
- language: string
13
- }
14
-
15
- export interface PrintMetaDefinition extends MetaDefinition {
16
- action: "print"
17
- format: string
18
- }
19
-
20
- export type MetaType = ParseMetaDefinition | PrintMetaDefinition
21
-
22
- export interface ActionDefinition {
23
- meta: MetaType
24
- setup?: (params: { parent: ActionManager; log: Logger }) => void
25
- run({ module, content }: { module: string; content: object }): Promise<string>
26
- hook?: (event: string, ...args: unknown[]) => Promise<unknown>
27
-
28
- HOOKS?: HookPoints
29
- }
30
-
31
- export interface PrintActionDefinition extends ActionDefinition {
32
- meta: PrintMetaDefinition
33
- }
34
-
35
- export interface ParseActionDefinition extends ActionDefinition {
36
- meta: ParseMetaDefinition
37
- }
38
-
39
- export default class ActionManager {
40
- constructor(actionDefinition: ActionDefinition, logger: Logger)
41
- get action(): ActionDefinition
42
- set hookManager(hookManager: HookManager)
43
- get hookManager(): HookManager
44
- get contract(): string
45
- get meta(): MetaType
46
- get log(): Logger
47
- setupAction(): Promise<void>
48
- runAction({ file, content }: {
49
- file: string
50
- content: string
51
- }): Promise<string>
52
- cleanupAction(): Promise<void>
53
- toString(): string
54
- #private
55
- }
56
-
57
- export type ActionContract = string
58
- //# sourceMappingURL=ActionManager.d.ts.map
@@ -1,10 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
1
- import { EnvironmentType } 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: EnvironmentType;
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
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "file": "Configuration.d.ts",
4
- "sourceRoot": "",
5
- "sources": [
6
- "../../../src/core/Configuration.js"
7
- ],
8
- "names": [],
9
- "mappings": "AAiBA;IACE;;;;;;OAqHC;;CAwMF"
10
- }
@@ -1,38 +0,0 @@
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
@@ -1,10 +0,0 @@
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
- }
@@ -1,49 +0,0 @@
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
- export interface ConveyResult {
16
- succeeded: Array<{ input: FileMap; output: FileMap }>;
17
- errored: Array<{ input: FileMap; error: Error }>;
18
- warned: Array<{ input: FileMap; warning: string }>;
19
- }
20
-
21
- export default class Conveyor {
22
- constructor(
23
- parse: ActionManager,
24
- print: ActionManager,
25
- logger: Logger,
26
- output: FileMap
27
- );
28
-
29
- readonly parse: ActionManager;
30
- readonly print: ActionManager;
31
- readonly logger: Logger;
32
- readonly output: FileMap;
33
-
34
- /**
35
- * Processes files with a concurrency limit.
36
- *
37
- * @param files - List of files to process.
38
- * @param maxConcurrent - Maximum number of concurrent tasks.
39
- * @returns Resolves when all files are processed.
40
- */
41
- convey(files: FileMap[], maxConcurrent?: number): Promise<ConveyResult>;
42
-
43
- #succeeded: Array<{ input: FileMap; output: FileMap }>;
44
- #errored: Array<{ input: FileMap; error: Error }>;
45
- #warned: Array<{ input: FileMap; warning: string }>;
46
- #processFile(file: FileMap): Promise<ProcessResult>;
47
- #writeOutput(destFile: string, content: string): Promise<ProcessResult>;
48
- }
49
- //# sourceMappingURL=Conveyor.d.ts.map
@@ -1,10 +0,0 @@
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
- }
@@ -1,48 +0,0 @@
1
- import Logger from './Logger';
2
- import ActionManager from './ActionManager';
3
- import { ConveyResult} from './Conveyor';
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
- export default class Core {
34
- static new({ options, source }: NewParams): Promise<Core>;
35
-
36
- constructor(options: CoreConstructorOptions);
37
-
38
- readonly options: CoreConstructorOptions;
39
- readonly logger: Logger;
40
- readonly packageJson: Record<string, unknown>;
41
- readonly debugOptions: {
42
- name: string | null;
43
- debugLevel: number;
44
- };
45
- readonly actions: Record<string, ActionManager>;
46
-
47
- processFiles(glob: string | string[], startTime?: [number, number]): Promise<ConveyResult>;
48
- }
@@ -1,10 +0,0 @@
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
- }
@@ -1,73 +0,0 @@
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
@@ -1,10 +0,0 @@
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
- }
@@ -1,60 +0,0 @@
1
- import Logger from './Logger';
2
- import { FileMap } from './util/FDUtil';
3
-
4
- export type HookEventType = '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<HookEventType>, HookEventType>>;
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 | null;
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: HookEventType, ...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
@@ -1,10 +0,0 @@
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
- }