conduithub 0.0.1 → 0.0.2

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.
@@ -0,0 +1,40 @@
1
+ import { c as createLogger } from '../../shared/conduithub.B7aryjPG.js';
2
+
3
+ interface HookResult<T = unknown> {
4
+ success: boolean;
5
+ data?: T;
6
+ error?: string;
7
+ }
8
+ interface HookHandler<I = unknown, O = unknown> {
9
+ id: string;
10
+ hook: string;
11
+ handler: (data: I) => Promise<HookResult<O> | O> | HookResult<O> | O;
12
+ priority: number;
13
+ }
14
+
15
+ declare class Hook<HM extends Record<string, {
16
+ input: any;
17
+ output: any;
18
+ }>> {
19
+ private hooks;
20
+ private initialized;
21
+ private logger;
22
+ private failFast;
23
+ private onError?;
24
+ constructor(options?: {
25
+ failFast?: boolean;
26
+ onError?: (err: unknown, hook: keyof HM) => void;
27
+ }, logger?: ReturnType<typeof createLogger>);
28
+ private ensure;
29
+ initialize(): Promise<void>;
30
+ shutdown(): Promise<void>;
31
+ registerHook<K extends keyof HM>(hook: K, handler: (data: HM[K]["input"]) => HookResult<HM[K]["output"]> | Promise<HookResult<HM[K]["output"]>> | HM[K]["output"] | Promise<HM[K]["output"]>, priority?: number, customId?: string): string;
32
+ unregisterHook<K extends keyof HM>(hook: K, id: string): boolean;
33
+ private handleHookResult;
34
+ executeHook<K extends keyof HM>(hook: K, data: HM[K]["input"]): Promise<HM[K]["output"]>;
35
+ executeHookSeries<K extends keyof HM>(hook: K, data: HM[K]["input"]): Promise<HookResult<HM[K]["output"]>[]>;
36
+ executeHookSeriesWithContext<K extends keyof HM>(hook: K, data: HM[K]["input"], context: Record<string, unknown>): Promise<HookResult<HM[K]["output"]>[]>;
37
+ }
38
+
39
+ export { Hook };
40
+ export type { HookHandler, HookResult };
@@ -0,0 +1,208 @@
1
+ import { c as createLogger, g as generateUuid } from '../../shared/conduithub.74V0wiLi.mjs';
2
+ import 'uuid';
3
+
4
+ class Hook {
5
+ hooks = /* @__PURE__ */ new Map();
6
+ initialized = false;
7
+ logger;
8
+ failFast;
9
+ onError;
10
+ constructor(options, logger) {
11
+ this.failFast = options?.failFast ?? false;
12
+ this.onError = options?.onError;
13
+ this.logger = logger ?? createLogger({ name: "Hook" });
14
+ }
15
+ ensure() {
16
+ if (!this.initialized) throw new Error("Hook system is not initialized");
17
+ }
18
+ async initialize() {
19
+ if (!this.initialized) {
20
+ this.initialized = true;
21
+ this.logger.success("Hook system initialized successfully");
22
+ }
23
+ }
24
+ async shutdown() {
25
+ this.ensure();
26
+ const hookCount = Array.from(this.hooks.values()).reduce(
27
+ (total, handlers) => total + handlers.length,
28
+ 0
29
+ );
30
+ this.hooks.clear();
31
+ this.initialized = false;
32
+ this.logger.success(
33
+ `Hook system shutdown completed - cleared ${hookCount} handlers`
34
+ );
35
+ }
36
+ registerHook(hook, handler, priority = 0, customId) {
37
+ this.ensure();
38
+ if (!this.hooks.has(hook)) this.hooks.set(hook, []);
39
+ const id = customId ?? generateUuid();
40
+ const entry = {
41
+ id,
42
+ hook: String(hook),
43
+ handler,
44
+ priority
45
+ };
46
+ this.hooks.get(hook).push(entry);
47
+ this.hooks.get(hook).sort((a, b) => b.priority - a.priority);
48
+ const handlerCount = this.hooks.get(hook).length;
49
+ this.logger.debug(
50
+ `Hook registered: '${String(hook)}' \u2192 ${id} (priority: ${priority}, total handlers: ${handlerCount})`
51
+ );
52
+ return id;
53
+ }
54
+ unregisterHook(hook, id) {
55
+ this.ensure();
56
+ const list = this.hooks.get(hook);
57
+ if (!list) {
58
+ this.logger.warn(
59
+ `Failed to unregister hook: '${String(hook)}' \u2192 ${id} (handler not found)`
60
+ );
61
+ return false;
62
+ }
63
+ const index = list.findIndex((h) => h.id === id);
64
+ if (index >= 0) {
65
+ list.splice(index, 1);
66
+ const remainingCount = list.length;
67
+ if (remainingCount === 0) this.hooks.delete(hook);
68
+ this.logger.debug(
69
+ `Hook unregistered: '${String(hook)}' \u2192 ${id} (remaining handlers: ${remainingCount})`
70
+ );
71
+ return true;
72
+ }
73
+ this.logger.warn(
74
+ `Failed to unregister hook: '${String(hook)}' \u2192 ${id} (handler not found)`
75
+ );
76
+ return false;
77
+ }
78
+ async handleHookResult(raw, failFast, hook, handlerId) {
79
+ try {
80
+ const result = await raw;
81
+ if (typeof result === "object" && result && "success" in result) {
82
+ const res = result;
83
+ if (!res.success && failFast) throw new Error(res.error);
84
+ this.logger.debug(
85
+ `Hook handler completed: '${String(hook)}' \u2192 ${handlerId} (success: ${res.success})`
86
+ );
87
+ return res;
88
+ }
89
+ this.logger.debug(
90
+ `Hook handler completed: '${String(hook)}' \u2192 ${handlerId} (success: true)`
91
+ );
92
+ return { success: true, data: result };
93
+ } catch (err) {
94
+ if (failFast) throw err;
95
+ const errorMessage = err instanceof Error ? err.message : String(err);
96
+ this.logger.error(
97
+ `Hook handler failed: '${String(hook)}' \u2192 ${handlerId} - ${errorMessage}`
98
+ );
99
+ this.onError?.(err, hook);
100
+ return {
101
+ success: false,
102
+ error: errorMessage
103
+ };
104
+ }
105
+ }
106
+ async executeHook(hook, data) {
107
+ this.ensure();
108
+ const list = this.hooks.get(hook);
109
+ if (!list?.length) {
110
+ this.logger.debug(
111
+ `Hook execution skipped: '${String(hook)}' (no handlers registered)`
112
+ );
113
+ return data;
114
+ }
115
+ this.logger.debug(
116
+ `Hook execution started: '${String(hook)}' (${list.length} handlers)`
117
+ );
118
+ let result = data;
119
+ let successCount = 0;
120
+ let errorCount = 0;
121
+ for (const { handler, id } of list) {
122
+ const {
123
+ success,
124
+ data: output,
125
+ error
126
+ } = await this.handleHookResult(
127
+ Promise.resolve().then(() => handler(result)),
128
+ this.failFast,
129
+ hook,
130
+ id
131
+ );
132
+ if (success) {
133
+ successCount++;
134
+ if (output !== void 0) result = output;
135
+ } else {
136
+ errorCount++;
137
+ if (this.failFast) throw new Error(error);
138
+ }
139
+ }
140
+ this.logger.debug(
141
+ `Hook execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
142
+ );
143
+ return result;
144
+ }
145
+ async executeHookSeries(hook, data) {
146
+ this.ensure();
147
+ const list = this.hooks.get(hook);
148
+ if (!list?.length) {
149
+ this.logger.debug(
150
+ `Hook series execution skipped: '${String(hook)}' (no handlers registered)`
151
+ );
152
+ return [];
153
+ }
154
+ this.logger.debug(
155
+ `Hook series execution started: '${String(hook)}' (${list.length} handlers)`
156
+ );
157
+ const results = [];
158
+ for (const { handler, id } of list) {
159
+ const result = await this.handleHookResult(
160
+ Promise.resolve().then(() => handler(data)),
161
+ false,
162
+ // Never fail fast in series execution, just collect results
163
+ hook,
164
+ id
165
+ );
166
+ results.push(result);
167
+ if (!result.success && this.failFast) break;
168
+ }
169
+ const successCount = results.filter((r) => r.success).length;
170
+ const errorCount = results.filter((r) => !r.success).length;
171
+ this.logger.debug(
172
+ `Hook series execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
173
+ );
174
+ return results;
175
+ }
176
+ async executeHookSeriesWithContext(hook, data, context) {
177
+ this.ensure();
178
+ const handlers = this.hooks.get(hook);
179
+ if (!handlers || handlers.length === 0) {
180
+ this.logger.debug(
181
+ `Hook series execution skipped: '${String(hook)}' (no handlers registered)`
182
+ );
183
+ return [];
184
+ }
185
+ this.logger.debug(
186
+ `Hook series execution started: '${String(hook)}' (${handlers.length} handlers)`
187
+ );
188
+ const results = [];
189
+ for (const { handler, id } of handlers) {
190
+ const result = await this.handleHookResult(
191
+ Promise.resolve().then(() => handler(data)),
192
+ this.failFast,
193
+ hook,
194
+ id
195
+ );
196
+ results.push(result);
197
+ if (!result.success && this.failFast) break;
198
+ }
199
+ const successCount = results.filter((r) => r.success).length;
200
+ const errorCount = results.filter((r) => !r.success).length;
201
+ this.logger.debug(
202
+ `Hook series execution completed: '${String(hook)}' (${successCount} succeeded, ${errorCount} failed)`
203
+ );
204
+ return results;
205
+ }
206
+ }
207
+
208
+ export { Hook };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ const core_eventBus_index = require('./event-bus/index.cjs');
4
+ const core_hook_index = require('./hook/index.cjs');
5
+ require('../shared/conduithub.CvMLTa-R.cjs');
6
+ require('uuid');
7
+
8
+
9
+
10
+ exports.EventBus = core_eventBus_index.EventBus;
11
+ exports.Hook = core_hook_index.Hook;
@@ -0,0 +1,3 @@
1
+ export { EventBus, EventData, EventHandlerRecord } from './event-bus/index.cjs';
2
+ export { Hook, HookHandler, HookResult } from './hook/index.cjs';
3
+ import '../shared/conduithub.B7aryjPG.cjs';
@@ -0,0 +1,3 @@
1
+ export { EventBus, EventData, EventHandlerRecord } from './event-bus/index.mjs';
2
+ export { Hook, HookHandler, HookResult } from './hook/index.mjs';
3
+ import '../shared/conduithub.B7aryjPG.mjs';
@@ -0,0 +1,3 @@
1
+ export { EventBus, EventData, EventHandlerRecord } from './event-bus/index.js';
2
+ export { Hook, HookHandler, HookResult } from './hook/index.js';
3
+ import '../shared/conduithub.B7aryjPG.js';
@@ -0,0 +1,4 @@
1
+ export { EventBus } from './event-bus/index.mjs';
2
+ export { Hook } from './hook/index.mjs';
3
+ import '../shared/conduithub.74V0wiLi.mjs';
4
+ import 'uuid';
package/dist/index.cjs CHANGED
@@ -1,10 +1,16 @@
1
1
  'use strict';
2
2
 
3
- const utils_index = require('./utils/index.cjs');
3
+ const core_eventBus_index = require('./core/event-bus/index.cjs');
4
+ const core_hook_index = require('./core/hook/index.cjs');
5
+ const uuid = require('./shared/conduithub.CvMLTa-R.cjs');
6
+ require('uuid');
4
7
 
5
8
 
6
9
 
7
- exports.createLogger = utils_index.createLogger;
8
- exports.levels = utils_index.levels;
9
- exports.logger = utils_index.logger;
10
- exports.shouldPublishLog = utils_index.shouldPublishLog;
10
+ exports.EventBus = core_eventBus_index.EventBus;
11
+ exports.Hook = core_hook_index.Hook;
12
+ exports.createLogger = uuid.createLogger;
13
+ exports.generateUuid = uuid.generateUuid;
14
+ exports.levels = uuid.levels;
15
+ exports.logger = uuid.logger;
16
+ exports.shouldPublishLog = uuid.shouldPublishLog;
package/dist/index.d.cts CHANGED
@@ -1 +1,4 @@
1
- export { LogHandlerParams, LogLevel, Logger, createLogger, levels, logger, shouldPublishLog } from './utils/index.cjs';
1
+ export { EventBus, EventData, EventHandlerRecord } from './core/event-bus/index.cjs';
2
+ export { Hook, HookHandler, HookResult } from './core/hook/index.cjs';
3
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from './shared/conduithub.B7aryjPG.cjs';
4
+ export { generateUuid } from './utils/index.cjs';
package/dist/index.d.mts CHANGED
@@ -1 +1,4 @@
1
- export { LogHandlerParams, LogLevel, Logger, createLogger, levels, logger, shouldPublishLog } from './utils/index.mjs';
1
+ export { EventBus, EventData, EventHandlerRecord } from './core/event-bus/index.mjs';
2
+ export { Hook, HookHandler, HookResult } from './core/hook/index.mjs';
3
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from './shared/conduithub.B7aryjPG.mjs';
4
+ export { generateUuid } from './utils/index.mjs';
package/dist/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export { LogHandlerParams, LogLevel, Logger, createLogger, levels, logger, shouldPublishLog } from './utils/index.js';
1
+ export { EventBus, EventData, EventHandlerRecord } from './core/event-bus/index.js';
2
+ export { Hook, HookHandler, HookResult } from './core/hook/index.js';
3
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from './shared/conduithub.B7aryjPG.js';
4
+ export { generateUuid } from './utils/index.js';
package/dist/index.mjs CHANGED
@@ -1 +1,4 @@
1
- export { createLogger, levels, logger, shouldPublishLog } from './utils/index.mjs';
1
+ export { EventBus } from './core/event-bus/index.mjs';
2
+ export { Hook } from './core/hook/index.mjs';
3
+ export { c as createLogger, g as generateUuid, l as levels, a as logger, s as shouldPublishLog } from './shared/conduithub.74V0wiLi.mjs';
4
+ import 'uuid';
@@ -0,0 +1,62 @@
1
+ import { v4 } from 'uuid';
2
+
3
+ const levels = ["info", "success", "warn", "error", "debug"];
4
+ function shouldPublishLog(currentLogLevel, logLevel) {
5
+ return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
6
+ }
7
+ const colors = {
8
+ reset: "\x1B[0m",
9
+ bright: "\x1B[1m",
10
+ dim: "\x1B[2m",
11
+ fg: {
12
+ red: "\x1B[31m",
13
+ green: "\x1B[32m",
14
+ yellow: "\x1B[33m",
15
+ blue: "\x1B[34m",
16
+ magenta: "\x1B[35m"}};
17
+ const levelColors = {
18
+ info: colors.fg.blue,
19
+ success: colors.fg.green,
20
+ warn: colors.fg.yellow,
21
+ error: colors.fg.red,
22
+ debug: colors.fg.magenta
23
+ };
24
+ const formatMessage = (level, message, name) => {
25
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
26
+ return `${colors.dim}${timestamp}${colors.reset} ${levelColors[level]}${level.toUpperCase()}${colors.reset} ${colors.bright}[${name ?? "ConduiHub"}]:${colors.reset} ${message}`;
27
+ };
28
+ const createLogger = (options) => {
29
+ const enabled = options?.disabled !== true;
30
+ const logLevel = options?.level ?? "error";
31
+ const name = options?.name ?? "ConduiHub";
32
+ const LogFunc = (level, message, args = []) => {
33
+ if (!enabled || !shouldPublishLog(logLevel, level)) {
34
+ return;
35
+ }
36
+ const formattedMessage = formatMessage(level, message, name);
37
+ if (!options || typeof options.log !== "function") {
38
+ if (level === "error") {
39
+ console.error(formattedMessage, ...args);
40
+ } else if (level === "warn") {
41
+ console.warn(formattedMessage, ...args);
42
+ } else {
43
+ console.log(formattedMessage, ...args);
44
+ }
45
+ return;
46
+ }
47
+ options.log(level === "success" ? "info" : level, message, ...args);
48
+ };
49
+ return Object.fromEntries(
50
+ levels.map((level) => [
51
+ level,
52
+ (...[message, ...args]) => LogFunc(level, message, args)
53
+ ])
54
+ );
55
+ };
56
+ const logger = createLogger();
57
+
58
+ const generateUuid = () => {
59
+ return v4();
60
+ };
61
+
62
+ export { logger as a, createLogger as c, generateUuid as g, levels as l, shouldPublishLog as s };
@@ -0,0 +1,18 @@
1
+ type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
+ declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
+ declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
+ interface Logger {
5
+ disabled?: boolean;
6
+ level?: Exclude<LogLevel, "success">;
7
+ name?: string;
8
+ log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
+ }
10
+ type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [
11
+ LogLevel,
12
+ ...infer Rest
13
+ ] ? Rest : never;
14
+ declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
15
+ declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
16
+
17
+ export { createLogger as c, logger as d, levels as l, shouldPublishLog as s };
18
+ export type { LogLevel as L, Logger as a, LogHandlerParams as b };
@@ -0,0 +1,18 @@
1
+ type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
+ declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
+ declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
+ interface Logger {
5
+ disabled?: boolean;
6
+ level?: Exclude<LogLevel, "success">;
7
+ name?: string;
8
+ log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
+ }
10
+ type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [
11
+ LogLevel,
12
+ ...infer Rest
13
+ ] ? Rest : never;
14
+ declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
15
+ declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
16
+
17
+ export { createLogger as c, logger as d, levels as l, shouldPublishLog as s };
18
+ export type { LogLevel as L, Logger as a, LogHandlerParams as b };
@@ -0,0 +1,18 @@
1
+ type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
+ declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
+ declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
+ interface Logger {
5
+ disabled?: boolean;
6
+ level?: Exclude<LogLevel, "success">;
7
+ name?: string;
8
+ log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
+ }
10
+ type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [
11
+ LogLevel,
12
+ ...infer Rest
13
+ ] ? Rest : never;
14
+ declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
15
+ declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
16
+
17
+ export { createLogger as c, logger as d, levels as l, shouldPublishLog as s };
18
+ export type { LogLevel as L, Logger as a, LogHandlerParams as b };
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ const uuid = require('uuid');
4
+
5
+ const levels = ["info", "success", "warn", "error", "debug"];
6
+ function shouldPublishLog(currentLogLevel, logLevel) {
7
+ return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
8
+ }
9
+ const colors = {
10
+ reset: "\x1B[0m",
11
+ bright: "\x1B[1m",
12
+ dim: "\x1B[2m",
13
+ fg: {
14
+ red: "\x1B[31m",
15
+ green: "\x1B[32m",
16
+ yellow: "\x1B[33m",
17
+ blue: "\x1B[34m",
18
+ magenta: "\x1B[35m"}};
19
+ const levelColors = {
20
+ info: colors.fg.blue,
21
+ success: colors.fg.green,
22
+ warn: colors.fg.yellow,
23
+ error: colors.fg.red,
24
+ debug: colors.fg.magenta
25
+ };
26
+ const formatMessage = (level, message, name) => {
27
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
28
+ return `${colors.dim}${timestamp}${colors.reset} ${levelColors[level]}${level.toUpperCase()}${colors.reset} ${colors.bright}[${name ?? "ConduiHub"}]:${colors.reset} ${message}`;
29
+ };
30
+ const createLogger = (options) => {
31
+ const enabled = options?.disabled !== true;
32
+ const logLevel = options?.level ?? "error";
33
+ const name = options?.name ?? "ConduiHub";
34
+ const LogFunc = (level, message, args = []) => {
35
+ if (!enabled || !shouldPublishLog(logLevel, level)) {
36
+ return;
37
+ }
38
+ const formattedMessage = formatMessage(level, message, name);
39
+ if (!options || typeof options.log !== "function") {
40
+ if (level === "error") {
41
+ console.error(formattedMessage, ...args);
42
+ } else if (level === "warn") {
43
+ console.warn(formattedMessage, ...args);
44
+ } else {
45
+ console.log(formattedMessage, ...args);
46
+ }
47
+ return;
48
+ }
49
+ options.log(level === "success" ? "info" : level, message, ...args);
50
+ };
51
+ return Object.fromEntries(
52
+ levels.map((level) => [
53
+ level,
54
+ (...[message, ...args]) => LogFunc(level, message, args)
55
+ ])
56
+ );
57
+ };
58
+ const logger = createLogger();
59
+
60
+ const generateUuid = () => {
61
+ return uuid.v4();
62
+ };
63
+
64
+ exports.createLogger = createLogger;
65
+ exports.generateUuid = generateUuid;
66
+ exports.levels = levels;
67
+ exports.logger = logger;
68
+ exports.shouldPublishLog = shouldPublishLog;
@@ -1,58 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const levels = ["info", "success", "warn", "error", "debug"];
4
- function shouldPublishLog(currentLogLevel, logLevel) {
5
- return levels.indexOf(logLevel) <= levels.indexOf(currentLogLevel);
6
- }
7
- const colors = {
8
- reset: "\x1B[0m",
9
- bright: "\x1B[1m",
10
- dim: "\x1B[2m",
11
- fg: {
12
- red: "\x1B[31m",
13
- green: "\x1B[32m",
14
- yellow: "\x1B[33m",
15
- blue: "\x1B[34m",
16
- magenta: "\x1B[35m"}};
17
- const levelColors = {
18
- info: colors.fg.blue,
19
- success: colors.fg.green,
20
- warn: colors.fg.yellow,
21
- error: colors.fg.red,
22
- debug: colors.fg.magenta
23
- };
24
- const formatMessage = (level, message, name) => {
25
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
26
- return `${colors.dim}${timestamp}${colors.reset} ${levelColors[level]}${level.toUpperCase()}${colors.reset} ${colors.bright}[${name ?? "ConduiHub"}]:${colors.reset} ${message}`;
27
- };
28
- const createLogger = (options) => {
29
- const enabled = options?.disabled !== true;
30
- const logLevel = options?.level ?? "error";
31
- const name = options?.name ?? "ConduiHub";
32
- const LogFunc = (level, message, args = []) => {
33
- if (!enabled || !shouldPublishLog(logLevel, level)) {
34
- return;
35
- }
36
- const formattedMessage = formatMessage(level, message, name);
37
- if (!options || typeof options.log !== "function") {
38
- if (level === "error") {
39
- console.error(formattedMessage, ...args);
40
- } else if (level === "warn") {
41
- console.warn(formattedMessage, ...args);
42
- } else {
43
- console.log(formattedMessage, ...args);
44
- }
45
- return;
46
- }
47
- options.log(level === "success" ? "info" : level, message, ...args);
48
- };
49
- return Object.fromEntries(
50
- levels.map((level) => [level, (...[message, ...args]) => LogFunc(level, message, args)])
51
- );
52
- };
53
- const logger = createLogger();
3
+ const uuid = require('../shared/conduithub.CvMLTa-R.cjs');
4
+ require('uuid');
54
5
 
55
- exports.createLogger = createLogger;
56
- exports.levels = levels;
57
- exports.logger = logger;
58
- exports.shouldPublishLog = shouldPublishLog;
6
+
7
+
8
+ exports.createLogger = uuid.createLogger;
9
+ exports.generateUuid = uuid.generateUuid;
10
+ exports.levels = uuid.levels;
11
+ exports.logger = uuid.logger;
12
+ exports.shouldPublishLog = uuid.shouldPublishLog;
@@ -1,15 +1,5 @@
1
- type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
- declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
- declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
- interface Logger {
5
- disabled?: boolean;
6
- level?: Exclude<LogLevel, "success">;
7
- name?: string;
8
- log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
- }
10
- type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest] ? Rest : never;
11
- declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
12
- declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
1
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from '../shared/conduithub.B7aryjPG.cjs';
13
2
 
14
- export { createLogger, levels, logger, shouldPublishLog };
15
- export type { LogHandlerParams, LogLevel, Logger };
3
+ declare const generateUuid: () => string;
4
+
5
+ export { generateUuid };
@@ -1,15 +1,5 @@
1
- type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
- declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
- declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
- interface Logger {
5
- disabled?: boolean;
6
- level?: Exclude<LogLevel, "success">;
7
- name?: string;
8
- log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
- }
10
- type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest] ? Rest : never;
11
- declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
12
- declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
1
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from '../shared/conduithub.B7aryjPG.mjs';
13
2
 
14
- export { createLogger, levels, logger, shouldPublishLog };
15
- export type { LogHandlerParams, LogLevel, Logger };
3
+ declare const generateUuid: () => string;
4
+
5
+ export { generateUuid };
@@ -1,15 +1,5 @@
1
- type LogLevel = "info" | "success" | "warn" | "error" | "debug";
2
- declare const levels: readonly ["info", "success", "warn", "error", "debug"];
3
- declare function shouldPublishLog(currentLogLevel: LogLevel, logLevel: LogLevel): boolean;
4
- interface Logger {
5
- disabled?: boolean;
6
- level?: Exclude<LogLevel, "success">;
7
- name?: string;
8
- log?: (level: Exclude<LogLevel, "success">, message: string, ...args: unknown[]) => void;
9
- }
10
- type LogHandlerParams = Parameters<NonNullable<Logger["log"]>> extends [LogLevel, ...infer Rest] ? Rest : never;
11
- declare const createLogger: (options?: Logger) => Record<LogLevel, (...params: LogHandlerParams) => void>;
12
- declare const logger: Record<LogLevel, (message: string, ...args: unknown[]) => void>;
1
+ export { b as LogHandlerParams, L as LogLevel, a as Logger, c as createLogger, l as levels, d as logger, s as shouldPublishLog } from '../shared/conduithub.B7aryjPG.js';
13
2
 
14
- export { createLogger, levels, logger, shouldPublishLog };
15
- export type { LogHandlerParams, LogLevel, Logger };
3
+ declare const generateUuid: () => string;
4
+
5
+ export { generateUuid };