@contentful/optimization-api-client 0.1.0-alpha7 → 0.1.0-alpha9
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/README.md +55 -24
- package/dist/199.mjs +2 -0
- package/dist/649.mjs +131 -0
- package/dist/649.mjs.map +1 -0
- package/dist/api-schemas.cjs +60 -0
- package/dist/api-schemas.cjs.map +1 -0
- package/dist/api-schemas.d.cts +4 -0
- package/dist/api-schemas.d.mts +4 -0
- package/dist/api-schemas.d.ts +4 -0
- package/dist/api-schemas.mjs +2 -0
- package/dist/index.cjs +588 -575
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1649 -0
- package/dist/index.d.mts +1649 -0
- package/dist/index.d.ts +1649 -8
- package/dist/index.mjs +103 -136
- package/dist/index.mjs.map +1 -1
- package/dist/logger.cjs +207 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +287 -0
- package/dist/logger.d.mts +287 -0
- package/dist/logger.d.ts +287 -0
- package/dist/logger.mjs +1 -0
- package/package.json +33 -10
- package/dist/ApiClient.d.ts +0 -74
- package/dist/ApiClient.d.ts.map +0 -1
- package/dist/ApiClient.js +0 -61
- package/dist/ApiClient.js.map +0 -1
- package/dist/ApiClientBase.d.ts +0 -113
- package/dist/ApiClientBase.d.ts.map +0 -1
- package/dist/ApiClientBase.js +0 -94
- package/dist/ApiClientBase.js.map +0 -1
- package/dist/builders/EventBuilder.d.ts +0 -589
- package/dist/builders/EventBuilder.d.ts.map +0 -1
- package/dist/builders/EventBuilder.js +0 -349
- package/dist/builders/EventBuilder.js.map +0 -1
- package/dist/builders/index.d.ts +0 -3
- package/dist/builders/index.d.ts.map +0 -1
- package/dist/builders/index.js +0 -3
- package/dist/builders/index.js.map +0 -1
- package/dist/experience/ExperienceApiClient.d.ts +0 -267
- package/dist/experience/ExperienceApiClient.d.ts.map +0 -1
- package/dist/experience/ExperienceApiClient.js +0 -324
- package/dist/experience/ExperienceApiClient.js.map +0 -1
- package/dist/experience/index.d.ts +0 -4
- package/dist/experience/index.d.ts.map +0 -1
- package/dist/experience/index.js +0 -4
- package/dist/experience/index.js.map +0 -1
- package/dist/fetch/Fetch.d.ts +0 -96
- package/dist/fetch/Fetch.d.ts.map +0 -1
- package/dist/fetch/Fetch.js +0 -27
- package/dist/fetch/Fetch.js.map +0 -1
- package/dist/fetch/createProtectedFetchMethod.d.ts +0 -40
- package/dist/fetch/createProtectedFetchMethod.d.ts.map +0 -1
- package/dist/fetch/createProtectedFetchMethod.js +0 -53
- package/dist/fetch/createProtectedFetchMethod.js.map +0 -1
- package/dist/fetch/createRetryFetchMethod.d.ts +0 -60
- package/dist/fetch/createRetryFetchMethod.d.ts.map +0 -1
- package/dist/fetch/createRetryFetchMethod.js +0 -138
- package/dist/fetch/createRetryFetchMethod.js.map +0 -1
- package/dist/fetch/createTimeoutFetchMethod.d.ts +0 -51
- package/dist/fetch/createTimeoutFetchMethod.d.ts.map +0 -1
- package/dist/fetch/createTimeoutFetchMethod.js +0 -51
- package/dist/fetch/createTimeoutFetchMethod.js.map +0 -1
- package/dist/fetch/index.d.ts +0 -7
- package/dist/fetch/index.d.ts.map +0 -1
- package/dist/fetch/index.js +0 -7
- package/dist/fetch/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/insights/InsightsApiClient.d.ts +0 -130
- package/dist/insights/InsightsApiClient.d.ts.map +0 -1
- package/dist/insights/InsightsApiClient.js +0 -143
- package/dist/insights/InsightsApiClient.js.map +0 -1
- package/dist/insights/index.d.ts +0 -4
- package/dist/insights/index.d.ts.map +0 -1
- package/dist/insights/index.js +0 -4
- package/dist/insights/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","sources":["../src/lib/logger/LogSink.ts","../src/lib/logger/logging.ts","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/lib/logger/Logger.ts","../src/lib/logger/ConsoleLogSink.ts","../src/lib/logger/index.ts"],"sourcesContent":["import type { LogEvent } from './logging'\n\n/**\n * Abstract base class for log sinks that receive and process log events.\n *\n * @example\n * ```typescript\n * class MyCustomSink extends LogSink {\n * name = 'MyCustomSink'\n *\n * ingest(event: LogEvent): void {\n * // process the event\n * }\n * }\n * ```\n *\n * @public\n */\nabstract class LogSink {\n /** Display name used to identify this sink for addition and removal. */\n abstract name: string\n\n /**\n * Processes an incoming log event.\n *\n * @param event - The log event to process.\n * @returns Nothing.\n */\n abstract ingest(event: LogEvent): void\n}\n\nexport default LogSink\n","/**\n * Supported log levels ordered from highest to lowest severity.\n *\n * @public\n */\nexport type LogLevels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'log'\n\n/**\n * A log event emitted by the logger package.\n *\n * @public\n */\nexport interface LogEvent {\n /** Logger scope name. */\n name: string\n /** Event severity level. */\n level: LogLevels\n /** Event payload, where the first entry is the formatted message. */\n messages: unknown[]\n /** Optional additional context attached by sinks or middleware. */\n [other: string]: unknown\n}\n\n/**\n * Numeric severity map used for log-level threshold comparisons.\n *\n * @public\n */\nexport const logLevelSeverity: Readonly<Record<LogLevels, number>> = {\n fatal: 60,\n error: 50,\n warn: 40,\n info: 30,\n debug: 20,\n log: 10,\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type LogSink from './LogSink'\nimport type { LogEvent, LogLevels } from './logging'\n\n/**\n * Central logger that routes log events through registered {@link LogSink} instances.\n *\n * @example\n * ```typescript\n * import { logger } from '@contentful/optimization-api-client/logger'\n *\n * logger.info('MyModule', 'Application started')\n * ```\n *\n * @public\n */\nexport class Logger {\n /** The logger's identifier, used as the event scope name. */\n readonly name = '@contentful/optimization'\n\n private readonly PREFIX_PARTS = ['Ctfl', 'O10n']\n private readonly DELIMITER = ':'\n private sinks: LogSink[] = []\n\n private assembleLocationPrefix(logLocation: string): string {\n return `[${[...this.PREFIX_PARTS, logLocation].join(this.DELIMITER)}]`\n }\n\n /**\n * Registers a log sink. If a sink with the same name already exists, it is replaced.\n *\n * @param sink - The {@link LogSink} instance to register.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'\n *\n * logger.addSink(new ConsoleLogSink('debug'))\n * ```\n */\n public addSink(sink: LogSink): void {\n this.sinks = [...this.sinks.filter((existingSink) => existingSink.name !== sink.name), sink]\n }\n\n /**\n * Removes a registered sink by name.\n *\n * @param name - The name of the sink to remove.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.removeSink('ConsoleLogSink')\n * ```\n */\n public removeSink(name: string): void {\n this.sinks = this.sinks.filter((sink) => sink.name !== name)\n }\n\n /**\n * Removes all registered sinks.\n *\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.removeSinks()\n * ```\n */\n public removeSinks(): void {\n this.sinks = []\n }\n\n /**\n * Logs a message at the debug level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.debug('MyModule', 'Debugging value', someVariable)\n * ```\n */\n public debug(logLocation: string, message: string, ...args: unknown[]): void {\n this.emit('debug', logLocation, message, ...args)\n }\n\n /**\n * Logs a message at the info level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.info('MyModule', 'Operation completed')\n * ```\n */\n public info(logLocation: string, message: string, ...args: unknown[]): void {\n this.emit('info', logLocation, message, ...args)\n }\n\n /**\n * Logs a message at the log level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.log('MyModule', 'General log entry')\n * ```\n */\n public log(logLocation: string, message: string, ...args: unknown[]): void {\n this.emit('log', logLocation, message, ...args)\n }\n\n /**\n * Logs a message at the warn level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.warn('MyModule', 'Deprecated method called')\n * ```\n */\n public warn(logLocation: string, message: string, ...args: unknown[]): void {\n this.emit('warn', logLocation, message, ...args)\n }\n\n /**\n * Logs a message at the error level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message or Error object.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.error('MyModule', new Error('Something failed'))\n * ```\n */\n public error(logLocation: string, message: string | Error, ...args: unknown[]): void {\n this.emit('error', logLocation, message, ...args)\n }\n\n /**\n * Logs a message at the fatal level.\n *\n * @param logLocation - The module or component identifier.\n * @param message - The log message or Error object.\n * @param args - Additional arguments forwarded in the log event.\n * @returns Nothing.\n *\n * @example\n * ```typescript\n * logger.fatal('MyModule', new Error('Unrecoverable failure'))\n * ```\n */\n public fatal(logLocation: string, message: string | Error, ...args: unknown[]): void {\n this.emit('fatal', logLocation, message, ...args)\n }\n\n private emit(\n level: LogLevels,\n logLocation: string,\n message: string | Error,\n ...args: unknown[]\n ): void {\n this.onLogEvent({\n name: this.name,\n level,\n messages: [`${this.assembleLocationPrefix(logLocation)} ${String(message)}`, ...args],\n })\n }\n\n private onLogEvent(event: LogEvent): void {\n this.sinks.forEach((sink) => {\n sink.ingest(event)\n })\n }\n}\n\n/**\n * Shared singleton {@link Logger} instance used across the SDK.\n *\n * @public\n */\nexport const logger = new Logger()\n\n/**\n * A location-scoped logger interface whose methods omit the `logLocation` parameter.\n *\n * @public\n */\nexport interface ScopedLogger {\n /** Logs at debug level. */\n debug: (message: string, ...args: unknown[]) => void\n /** Logs at info level. */\n info: (message: string, ...args: unknown[]) => void\n /** Logs at log level. */\n log: (message: string, ...args: unknown[]) => void\n /** Logs at warn level. */\n warn: (message: string, ...args: unknown[]) => void\n /** Logs at error level. */\n error: (message: string | Error, ...args: unknown[]) => void\n /** Logs at fatal level. */\n fatal: (message: string | Error, ...args: unknown[]) => void\n}\n\n/**\n * Creates a {@link ScopedLogger} that automatically prepends the given location to every log call.\n *\n * @param location - The module or component identifier to prepend.\n * @returns A {@link ScopedLogger} bound to the specified location.\n *\n * @example\n * ```typescript\n * import { createScopedLogger } from '@contentful/optimization-api-client/logger'\n *\n * const log = createScopedLogger('MyModule')\n * log.info('Initialization complete')\n * ```\n *\n * @public\n */\nexport function createScopedLogger(location: string): ScopedLogger {\n return {\n debug: (message: string, ...args: unknown[]) => {\n logger.debug(location, message, ...args)\n },\n info: (message: string, ...args: unknown[]) => {\n logger.info(location, message, ...args)\n },\n log: (message: string, ...args: unknown[]) => {\n logger.log(location, message, ...args)\n },\n warn: (message: string, ...args: unknown[]) => {\n logger.warn(location, message, ...args)\n },\n error: (message: string | Error, ...args: unknown[]) => {\n logger.error(location, message, ...args)\n },\n fatal: (message: string | Error, ...args: unknown[]) => {\n logger.fatal(location, message, ...args)\n },\n }\n}\n","/* eslint-disable no-console -- using console */\nimport { logLevelSeverity, type LogEvent, type LogLevels } from './logging'\nimport LogSink from './LogSink'\n\nconst consoleMap = {\n debug: (...args: unknown[]) => {\n console.debug(...args)\n },\n info: (...args: unknown[]) => {\n console.info(...args)\n },\n log: (...args: unknown[]) => {\n console.log(...args)\n },\n warn: (...args: unknown[]) => {\n console.warn(...args)\n },\n error: (...args: unknown[]) => {\n console.error(...args)\n },\n fatal: (...args: unknown[]) => {\n console.error(...args)\n },\n}\n\n/**\n * A {@link LogSink} that writes log events to the browser or Node.js console,\n * filtering by a configurable verbosity threshold.\n *\n * @example\n * ```typescript\n * import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'\n *\n * logger.addSink(new ConsoleLogSink('debug'))\n * ```\n *\n * @public\n */\nexport class ConsoleLogSink extends LogSink {\n /** Identifies this sink when registered with the {@link Logger}. */\n public name = 'ConsoleLogSink'\n\n /**\n * Minimum log level required for events to be output.\n *\n * @defaultValue 'error'\n */\n readonly verbosity: LogLevels\n\n /**\n * Creates a new ConsoleLogSink.\n *\n * @param verbosity - Minimum log level to output.\n */\n constructor(verbosity?: LogLevels) {\n super()\n\n this.verbosity = verbosity ?? 'error'\n }\n\n /**\n * Writes a log event to the console if its level meets the verbosity threshold.\n *\n * @param event - The log event to process.\n * @returns Nothing.\n */\n ingest(event: LogEvent): void {\n if (logLevelSeverity[event.level] < logLevelSeverity[this.verbosity]) return\n\n consoleMap[event.level](...event.messages)\n }\n}\n","import LogSink from './LogSink'\nimport { Logger } from './Logger'\n\nexport * from './ConsoleLogSink'\nexport * from './LogSink'\nexport * from './Logger'\nexport * from './logging'\n\nexport { LogSink }\nexport default Logger\n"],"names":["LogSink","logLevelSeverity","__webpack_require__","definition","key","Object","obj","prop","Symbol","Logger","logLocation","sink","existingSink","name","message","args","level","String","event","logger","createScopedLogger","location","consoleMap","console","ConsoleLogSink","verbosity"],"mappings":"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"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link LogSink} that writes log events to the browser or Node.js console,
|
|
3
|
+
* filtering by a configurable verbosity threshold.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'
|
|
8
|
+
*
|
|
9
|
+
* logger.addSink(new ConsoleLogSink('debug'))
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConsoleLogSink extends LogSink {
|
|
15
|
+
/** Identifies this sink when registered with the {@link Logger}. */
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum log level required for events to be output.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue 'error'
|
|
21
|
+
*/
|
|
22
|
+
readonly verbosity: LogLevels;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new ConsoleLogSink.
|
|
25
|
+
*
|
|
26
|
+
* @param verbosity - Minimum log level to output.
|
|
27
|
+
*/
|
|
28
|
+
constructor(verbosity?: LogLevels);
|
|
29
|
+
/**
|
|
30
|
+
* Writes a log event to the console if its level meets the verbosity threshold.
|
|
31
|
+
*
|
|
32
|
+
* @param event - The log event to process.
|
|
33
|
+
* @returns Nothing.
|
|
34
|
+
*/
|
|
35
|
+
ingest(event: LogEvent): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a {@link ScopedLogger} that automatically prepends the given location to every log call.
|
|
40
|
+
*
|
|
41
|
+
* @param location - The module or component identifier to prepend.
|
|
42
|
+
* @returns A {@link ScopedLogger} bound to the specified location.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { createScopedLogger } from '@contentful/optimization-api-client/logger'
|
|
47
|
+
*
|
|
48
|
+
* const log = createScopedLogger('MyModule')
|
|
49
|
+
* log.info('Initialization complete')
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function createScopedLogger(location: string): ScopedLogger;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A log event emitted by the logger package.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare interface LogEvent {
|
|
62
|
+
/** Logger scope name. */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Event severity level. */
|
|
65
|
+
level: LogLevels;
|
|
66
|
+
/** Event payload, where the first entry is the formatted message. */
|
|
67
|
+
messages: unknown[];
|
|
68
|
+
/** Optional additional context attached by sinks or middleware. */
|
|
69
|
+
[other: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Central logger that routes log events through registered {@link LogSink} instances.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { logger } from '@contentful/optimization-api-client/logger'
|
|
78
|
+
*
|
|
79
|
+
* logger.info('MyModule', 'Application started')
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
declare class Logger {
|
|
85
|
+
/** The logger's identifier, used as the event scope name. */
|
|
86
|
+
readonly name = "@contentful/optimization";
|
|
87
|
+
private readonly PREFIX_PARTS;
|
|
88
|
+
private readonly DELIMITER;
|
|
89
|
+
private sinks;
|
|
90
|
+
private assembleLocationPrefix;
|
|
91
|
+
/**
|
|
92
|
+
* Registers a log sink. If a sink with the same name already exists, it is replaced.
|
|
93
|
+
*
|
|
94
|
+
* @param sink - The {@link LogSink} instance to register.
|
|
95
|
+
* @returns Nothing.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'
|
|
100
|
+
*
|
|
101
|
+
* logger.addSink(new ConsoleLogSink('debug'))
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
addSink(sink: LogSink): void;
|
|
105
|
+
/**
|
|
106
|
+
* Removes a registered sink by name.
|
|
107
|
+
*
|
|
108
|
+
* @param name - The name of the sink to remove.
|
|
109
|
+
* @returns Nothing.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* logger.removeSink('ConsoleLogSink')
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
removeSink(name: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Removes all registered sinks.
|
|
119
|
+
*
|
|
120
|
+
* @returns Nothing.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* logger.removeSinks()
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
removeSinks(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Logs a message at the debug level.
|
|
130
|
+
*
|
|
131
|
+
* @param logLocation - The module or component identifier.
|
|
132
|
+
* @param message - The log message.
|
|
133
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
134
|
+
* @returns Nothing.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* logger.debug('MyModule', 'Debugging value', someVariable)
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
debug(logLocation: string, message: string, ...args: unknown[]): void;
|
|
142
|
+
/**
|
|
143
|
+
* Logs a message at the info level.
|
|
144
|
+
*
|
|
145
|
+
* @param logLocation - The module or component identifier.
|
|
146
|
+
* @param message - The log message.
|
|
147
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
148
|
+
* @returns Nothing.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* logger.info('MyModule', 'Operation completed')
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
info(logLocation: string, message: string, ...args: unknown[]): void;
|
|
156
|
+
/**
|
|
157
|
+
* Logs a message at the log level.
|
|
158
|
+
*
|
|
159
|
+
* @param logLocation - The module or component identifier.
|
|
160
|
+
* @param message - The log message.
|
|
161
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
162
|
+
* @returns Nothing.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* logger.log('MyModule', 'General log entry')
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
log(logLocation: string, message: string, ...args: unknown[]): void;
|
|
170
|
+
/**
|
|
171
|
+
* Logs a message at the warn level.
|
|
172
|
+
*
|
|
173
|
+
* @param logLocation - The module or component identifier.
|
|
174
|
+
* @param message - The log message.
|
|
175
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
176
|
+
* @returns Nothing.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* logger.warn('MyModule', 'Deprecated method called')
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
warn(logLocation: string, message: string, ...args: unknown[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Logs a message at the error level.
|
|
186
|
+
*
|
|
187
|
+
* @param logLocation - The module or component identifier.
|
|
188
|
+
* @param message - The log message or Error object.
|
|
189
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
190
|
+
* @returns Nothing.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* logger.error('MyModule', new Error('Something failed'))
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
error(logLocation: string, message: string | Error, ...args: unknown[]): void;
|
|
198
|
+
/**
|
|
199
|
+
* Logs a message at the fatal level.
|
|
200
|
+
*
|
|
201
|
+
* @param logLocation - The module or component identifier.
|
|
202
|
+
* @param message - The log message or Error object.
|
|
203
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
204
|
+
* @returns Nothing.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* logger.fatal('MyModule', new Error('Unrecoverable failure'))
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
fatal(logLocation: string, message: string | Error, ...args: unknown[]): void;
|
|
212
|
+
private emit;
|
|
213
|
+
private onLogEvent;
|
|
214
|
+
}
|
|
215
|
+
export { Logger }
|
|
216
|
+
export default Logger;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Shared singleton {@link Logger} instance used across the SDK.
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export declare const logger: Logger;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Supported log levels ordered from highest to lowest severity.
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare type LogLevels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'log';
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Numeric severity map used for log-level threshold comparisons.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
export declare const logLevelSeverity: Readonly<Record<LogLevels, number>>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Abstract base class for log sinks that receive and process log events.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* class MyCustomSink extends LogSink {
|
|
245
|
+
* name = 'MyCustomSink'
|
|
246
|
+
*
|
|
247
|
+
* ingest(event: LogEvent): void {
|
|
248
|
+
* // process the event
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare abstract class LogSink {
|
|
256
|
+
/** Display name used to identify this sink for addition and removal. */
|
|
257
|
+
abstract name: string;
|
|
258
|
+
/**
|
|
259
|
+
* Processes an incoming log event.
|
|
260
|
+
*
|
|
261
|
+
* @param event - The log event to process.
|
|
262
|
+
* @returns Nothing.
|
|
263
|
+
*/
|
|
264
|
+
abstract ingest(event: LogEvent): void;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A location-scoped logger interface whose methods omit the `logLocation` parameter.
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare interface ScopedLogger {
|
|
273
|
+
/** Logs at debug level. */
|
|
274
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
275
|
+
/** Logs at info level. */
|
|
276
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
277
|
+
/** Logs at log level. */
|
|
278
|
+
log: (message: string, ...args: unknown[]) => void;
|
|
279
|
+
/** Logs at warn level. */
|
|
280
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
281
|
+
/** Logs at error level. */
|
|
282
|
+
error: (message: string | Error, ...args: unknown[]) => void;
|
|
283
|
+
/** Logs at fatal level. */
|
|
284
|
+
fatal: (message: string | Error, ...args: unknown[]) => void;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { }
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link LogSink} that writes log events to the browser or Node.js console,
|
|
3
|
+
* filtering by a configurable verbosity threshold.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'
|
|
8
|
+
*
|
|
9
|
+
* logger.addSink(new ConsoleLogSink('debug'))
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConsoleLogSink extends LogSink {
|
|
15
|
+
/** Identifies this sink when registered with the {@link Logger}. */
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum log level required for events to be output.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue 'error'
|
|
21
|
+
*/
|
|
22
|
+
readonly verbosity: LogLevels;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new ConsoleLogSink.
|
|
25
|
+
*
|
|
26
|
+
* @param verbosity - Minimum log level to output.
|
|
27
|
+
*/
|
|
28
|
+
constructor(verbosity?: LogLevels);
|
|
29
|
+
/**
|
|
30
|
+
* Writes a log event to the console if its level meets the verbosity threshold.
|
|
31
|
+
*
|
|
32
|
+
* @param event - The log event to process.
|
|
33
|
+
* @returns Nothing.
|
|
34
|
+
*/
|
|
35
|
+
ingest(event: LogEvent): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a {@link ScopedLogger} that automatically prepends the given location to every log call.
|
|
40
|
+
*
|
|
41
|
+
* @param location - The module or component identifier to prepend.
|
|
42
|
+
* @returns A {@link ScopedLogger} bound to the specified location.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { createScopedLogger } from '@contentful/optimization-api-client/logger'
|
|
47
|
+
*
|
|
48
|
+
* const log = createScopedLogger('MyModule')
|
|
49
|
+
* log.info('Initialization complete')
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function createScopedLogger(location: string): ScopedLogger;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A log event emitted by the logger package.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare interface LogEvent {
|
|
62
|
+
/** Logger scope name. */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Event severity level. */
|
|
65
|
+
level: LogLevels;
|
|
66
|
+
/** Event payload, where the first entry is the formatted message. */
|
|
67
|
+
messages: unknown[];
|
|
68
|
+
/** Optional additional context attached by sinks or middleware. */
|
|
69
|
+
[other: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Central logger that routes log events through registered {@link LogSink} instances.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { logger } from '@contentful/optimization-api-client/logger'
|
|
78
|
+
*
|
|
79
|
+
* logger.info('MyModule', 'Application started')
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
declare class Logger {
|
|
85
|
+
/** The logger's identifier, used as the event scope name. */
|
|
86
|
+
readonly name = "@contentful/optimization";
|
|
87
|
+
private readonly PREFIX_PARTS;
|
|
88
|
+
private readonly DELIMITER;
|
|
89
|
+
private sinks;
|
|
90
|
+
private assembleLocationPrefix;
|
|
91
|
+
/**
|
|
92
|
+
* Registers a log sink. If a sink with the same name already exists, it is replaced.
|
|
93
|
+
*
|
|
94
|
+
* @param sink - The {@link LogSink} instance to register.
|
|
95
|
+
* @returns Nothing.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import { logger, ConsoleLogSink } from '@contentful/optimization-api-client/logger'
|
|
100
|
+
*
|
|
101
|
+
* logger.addSink(new ConsoleLogSink('debug'))
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
addSink(sink: LogSink): void;
|
|
105
|
+
/**
|
|
106
|
+
* Removes a registered sink by name.
|
|
107
|
+
*
|
|
108
|
+
* @param name - The name of the sink to remove.
|
|
109
|
+
* @returns Nothing.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* logger.removeSink('ConsoleLogSink')
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
removeSink(name: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Removes all registered sinks.
|
|
119
|
+
*
|
|
120
|
+
* @returns Nothing.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* logger.removeSinks()
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
removeSinks(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Logs a message at the debug level.
|
|
130
|
+
*
|
|
131
|
+
* @param logLocation - The module or component identifier.
|
|
132
|
+
* @param message - The log message.
|
|
133
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
134
|
+
* @returns Nothing.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* logger.debug('MyModule', 'Debugging value', someVariable)
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
debug(logLocation: string, message: string, ...args: unknown[]): void;
|
|
142
|
+
/**
|
|
143
|
+
* Logs a message at the info level.
|
|
144
|
+
*
|
|
145
|
+
* @param logLocation - The module or component identifier.
|
|
146
|
+
* @param message - The log message.
|
|
147
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
148
|
+
* @returns Nothing.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* logger.info('MyModule', 'Operation completed')
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
info(logLocation: string, message: string, ...args: unknown[]): void;
|
|
156
|
+
/**
|
|
157
|
+
* Logs a message at the log level.
|
|
158
|
+
*
|
|
159
|
+
* @param logLocation - The module or component identifier.
|
|
160
|
+
* @param message - The log message.
|
|
161
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
162
|
+
* @returns Nothing.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* logger.log('MyModule', 'General log entry')
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
log(logLocation: string, message: string, ...args: unknown[]): void;
|
|
170
|
+
/**
|
|
171
|
+
* Logs a message at the warn level.
|
|
172
|
+
*
|
|
173
|
+
* @param logLocation - The module or component identifier.
|
|
174
|
+
* @param message - The log message.
|
|
175
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
176
|
+
* @returns Nothing.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* logger.warn('MyModule', 'Deprecated method called')
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
warn(logLocation: string, message: string, ...args: unknown[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Logs a message at the error level.
|
|
186
|
+
*
|
|
187
|
+
* @param logLocation - The module or component identifier.
|
|
188
|
+
* @param message - The log message or Error object.
|
|
189
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
190
|
+
* @returns Nothing.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* logger.error('MyModule', new Error('Something failed'))
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
error(logLocation: string, message: string | Error, ...args: unknown[]): void;
|
|
198
|
+
/**
|
|
199
|
+
* Logs a message at the fatal level.
|
|
200
|
+
*
|
|
201
|
+
* @param logLocation - The module or component identifier.
|
|
202
|
+
* @param message - The log message or Error object.
|
|
203
|
+
* @param args - Additional arguments forwarded in the log event.
|
|
204
|
+
* @returns Nothing.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* logger.fatal('MyModule', new Error('Unrecoverable failure'))
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
fatal(logLocation: string, message: string | Error, ...args: unknown[]): void;
|
|
212
|
+
private emit;
|
|
213
|
+
private onLogEvent;
|
|
214
|
+
}
|
|
215
|
+
export { Logger }
|
|
216
|
+
export default Logger;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Shared singleton {@link Logger} instance used across the SDK.
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export declare const logger: Logger;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Supported log levels ordered from highest to lowest severity.
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare type LogLevels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'log';
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Numeric severity map used for log-level threshold comparisons.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
export declare const logLevelSeverity: Readonly<Record<LogLevels, number>>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Abstract base class for log sinks that receive and process log events.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* class MyCustomSink extends LogSink {
|
|
245
|
+
* name = 'MyCustomSink'
|
|
246
|
+
*
|
|
247
|
+
* ingest(event: LogEvent): void {
|
|
248
|
+
* // process the event
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare abstract class LogSink {
|
|
256
|
+
/** Display name used to identify this sink for addition and removal. */
|
|
257
|
+
abstract name: string;
|
|
258
|
+
/**
|
|
259
|
+
* Processes an incoming log event.
|
|
260
|
+
*
|
|
261
|
+
* @param event - The log event to process.
|
|
262
|
+
* @returns Nothing.
|
|
263
|
+
*/
|
|
264
|
+
abstract ingest(event: LogEvent): void;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* A location-scoped logger interface whose methods omit the `logLocation` parameter.
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare interface ScopedLogger {
|
|
273
|
+
/** Logs at debug level. */
|
|
274
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
275
|
+
/** Logs at info level. */
|
|
276
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
277
|
+
/** Logs at log level. */
|
|
278
|
+
log: (message: string, ...args: unknown[]) => void;
|
|
279
|
+
/** Logs at warn level. */
|
|
280
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
281
|
+
/** Logs at error level. */
|
|
282
|
+
error: (message: string | Error, ...args: unknown[]) => void;
|
|
283
|
+
/** Logs at fatal level. */
|
|
284
|
+
fatal: (message: string | Error, ...args: unknown[]) => void;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { }
|