@gesslar/bedoc 1.1.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.
Files changed (49) hide show
  1. package/dist/types/cli.d.ts +3 -0
  2. package/dist/types/cli.d.ts.map +10 -0
  3. package/dist/types/core/ActionManager.d.ts +27 -0
  4. package/dist/types/core/ActionManager.d.ts.map +10 -0
  5. package/dist/types/core/Configuration.d.ts +27 -0
  6. package/dist/types/core/Configuration.d.ts.map +10 -0
  7. package/dist/types/core/ConfigurationParameters.d.ts +38 -0
  8. package/dist/types/core/ConfigurationParameters.d.ts.map +10 -0
  9. package/dist/types/core/Conveyor.d.ts +47 -0
  10. package/dist/types/core/Conveyor.d.ts.map +10 -0
  11. package/dist/types/core/Core.d.ts +53 -0
  12. package/dist/types/core/Core.d.ts.map +10 -0
  13. package/dist/types/core/Discovery.d.ts +73 -0
  14. package/dist/types/core/Discovery.d.ts.map +10 -0
  15. package/dist/types/core/HookManager.d.ts +60 -0
  16. package/dist/types/core/HookManager.d.ts.map +10 -0
  17. package/dist/types/core/Logger.d.ts +55 -0
  18. package/dist/types/core/Logger.d.ts.map +10 -0
  19. package/dist/types/core/action/ParseManager.d.ts +8 -0
  20. package/dist/types/core/action/ParseManager.d.ts.map +10 -0
  21. package/dist/types/core/action/PrintManager.d.ts +8 -0
  22. package/dist/types/core/action/PrintManager.d.ts.map +10 -0
  23. package/dist/types/core/util/ActionUtil.d.ts +35 -0
  24. package/dist/types/core/util/ActionUtil.d.ts.map +10 -0
  25. package/dist/types/core/util/DataUtil.d.ts +52 -0
  26. package/dist/types/core/util/DataUtil.d.ts.map +10 -0
  27. package/dist/types/core/util/FDUtil.d.ts +146 -0
  28. package/dist/types/core/util/FDUtil.d.ts.map +10 -0
  29. package/dist/types/core/util/ModuleUtil.d.ts +27 -0
  30. package/dist/types/core/util/ModuleUtil.d.ts.map +10 -0
  31. package/dist/types/core/util/StringUtil.d.ts +5 -0
  32. package/dist/types/core/util/StringUtil.d.ts.map +10 -0
  33. package/dist/types/core/util/TypeSpec.d.ts +42 -0
  34. package/dist/types/core/util/TypeSpec.d.ts.map +10 -0
  35. package/dist/types/core/util/ValidUtil.d.ts +29 -0
  36. package/dist/types/core/util/ValidUtil.d.ts.map +10 -0
  37. package/package.json +10 -3
  38. package/src/cli.js +12 -11
  39. package/src/core/ActionManager.js +85 -22
  40. package/src/core/Conveyor.js +36 -16
  41. package/src/core/Core.js +68 -78
  42. package/src/core/Discovery.js +219 -65
  43. package/src/core/{HooksManager.js → HookManager.js} +14 -13
  44. package/src/core/Logger.js +3 -11
  45. package/src/core/action/ParseManager.js +0 -19
  46. package/src/core/action/PrintManager.js +0 -19
  47. package/src/core/util/DataUtil.js +3 -1
  48. package/src/core/util/FDUtil.js +1 -1
  49. package/tsconfig.json +20 -0
@@ -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
 
@@ -119,8 +111,8 @@ export default class Logger {
119
111
  return `[${this.#name}] ${loggerColours[level]}${tag}${loggerColours.reset}: ${message}`
120
112
  }
121
113
 
122
- lastStackLine(stepsRemoved = 3) {
123
- const stack = ErrorStackParser.parse(new Error())
114
+ lastStackLine(error = new Error(), stepsRemoved = 3) {
115
+ const stack = ErrorStackParser.parse(error)
124
116
  return stack[stepsRemoved]
125
117
  }
126
118
 
@@ -170,7 +162,7 @@ export default class Logger {
170
162
  }
171
163
 
172
164
  debug(message, level = 0, ...arg) {
173
- if(this.debugMode === true && level <= (this.debugLevel ?? 4))
165
+ if(level <= (this.debugLevel ?? 4))
174
166
  console.debug(this.#compose("debug", message, level), ...arg)
175
167
  }
176
168
 
@@ -4,23 +4,4 @@ export default class ParseManager extends ActionManager {
4
4
  constructor(actionDefinition, logger) {
5
5
  super(actionDefinition, logger)
6
6
  }
7
-
8
- async parse(fileMap, content) {
9
- const log = this.log
10
- const debug = log.newDebug()
11
-
12
- debug("Parsing file `%j`", 3, fileMap)
13
-
14
- if(this.action.init)
15
- this.action.init({parent: this, log})
16
-
17
- if(!this.action.parse)
18
- throw new Error(`No parse function found for action: ${this.module}`)
19
-
20
- const result = await this.action.parse(fileMap.path, content)
21
-
22
- debug("Parse complete of file `%j`", 3, fileMap)
23
-
24
- return result
25
- }
26
7
  }
@@ -4,23 +4,4 @@ export default class PrintManager extends ActionManager {
4
4
  constructor(actionDefinition, logger) {
5
5
  super(actionDefinition, logger)
6
6
  }
7
-
8
- async print(fileMap, content) {
9
- const log = this.log
10
- const debug = log.newDebug()
11
-
12
- debug("Printing data for `%s`", 3, fileMap.module)
13
-
14
- if(this.action.init)
15
- this.action.init({parent: this, log})
16
-
17
- if(!this.action.print)
18
- throw new Error(`No print function found for action: ${this.module}`)
19
-
20
- const result = await this.action.print(fileMap.module, content)
21
-
22
- debug("Print complete for `%s`", 3, fileMap.module)
23
-
24
- return result
25
- }
26
7
  }
@@ -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,
@@ -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 {Promise<string>} The file contents
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
+ }