@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.
Files changed (79) hide show
  1. package/README.md +55 -24
  2. package/dist/199.mjs +2 -0
  3. package/dist/649.mjs +131 -0
  4. package/dist/649.mjs.map +1 -0
  5. package/dist/api-schemas.cjs +60 -0
  6. package/dist/api-schemas.cjs.map +1 -0
  7. package/dist/api-schemas.d.cts +4 -0
  8. package/dist/api-schemas.d.mts +4 -0
  9. package/dist/api-schemas.d.ts +4 -0
  10. package/dist/api-schemas.mjs +2 -0
  11. package/dist/index.cjs +588 -575
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +1649 -0
  14. package/dist/index.d.mts +1649 -0
  15. package/dist/index.d.ts +1649 -8
  16. package/dist/index.mjs +103 -136
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/logger.cjs +207 -0
  19. package/dist/logger.cjs.map +1 -0
  20. package/dist/logger.d.cts +287 -0
  21. package/dist/logger.d.mts +287 -0
  22. package/dist/logger.d.ts +287 -0
  23. package/dist/logger.mjs +1 -0
  24. package/package.json +33 -10
  25. package/dist/ApiClient.d.ts +0 -74
  26. package/dist/ApiClient.d.ts.map +0 -1
  27. package/dist/ApiClient.js +0 -61
  28. package/dist/ApiClient.js.map +0 -1
  29. package/dist/ApiClientBase.d.ts +0 -113
  30. package/dist/ApiClientBase.d.ts.map +0 -1
  31. package/dist/ApiClientBase.js +0 -94
  32. package/dist/ApiClientBase.js.map +0 -1
  33. package/dist/builders/EventBuilder.d.ts +0 -589
  34. package/dist/builders/EventBuilder.d.ts.map +0 -1
  35. package/dist/builders/EventBuilder.js +0 -349
  36. package/dist/builders/EventBuilder.js.map +0 -1
  37. package/dist/builders/index.d.ts +0 -3
  38. package/dist/builders/index.d.ts.map +0 -1
  39. package/dist/builders/index.js +0 -3
  40. package/dist/builders/index.js.map +0 -1
  41. package/dist/experience/ExperienceApiClient.d.ts +0 -267
  42. package/dist/experience/ExperienceApiClient.d.ts.map +0 -1
  43. package/dist/experience/ExperienceApiClient.js +0 -324
  44. package/dist/experience/ExperienceApiClient.js.map +0 -1
  45. package/dist/experience/index.d.ts +0 -4
  46. package/dist/experience/index.d.ts.map +0 -1
  47. package/dist/experience/index.js +0 -4
  48. package/dist/experience/index.js.map +0 -1
  49. package/dist/fetch/Fetch.d.ts +0 -96
  50. package/dist/fetch/Fetch.d.ts.map +0 -1
  51. package/dist/fetch/Fetch.js +0 -27
  52. package/dist/fetch/Fetch.js.map +0 -1
  53. package/dist/fetch/createProtectedFetchMethod.d.ts +0 -40
  54. package/dist/fetch/createProtectedFetchMethod.d.ts.map +0 -1
  55. package/dist/fetch/createProtectedFetchMethod.js +0 -53
  56. package/dist/fetch/createProtectedFetchMethod.js.map +0 -1
  57. package/dist/fetch/createRetryFetchMethod.d.ts +0 -60
  58. package/dist/fetch/createRetryFetchMethod.d.ts.map +0 -1
  59. package/dist/fetch/createRetryFetchMethod.js +0 -138
  60. package/dist/fetch/createRetryFetchMethod.js.map +0 -1
  61. package/dist/fetch/createTimeoutFetchMethod.d.ts +0 -51
  62. package/dist/fetch/createTimeoutFetchMethod.d.ts.map +0 -1
  63. package/dist/fetch/createTimeoutFetchMethod.js +0 -51
  64. package/dist/fetch/createTimeoutFetchMethod.js.map +0 -1
  65. package/dist/fetch/index.d.ts +0 -7
  66. package/dist/fetch/index.d.ts.map +0 -1
  67. package/dist/fetch/index.js +0 -7
  68. package/dist/fetch/index.js.map +0 -1
  69. package/dist/index.d.ts.map +0 -1
  70. package/dist/index.js +0 -8
  71. package/dist/index.js.map +0 -1
  72. package/dist/insights/InsightsApiClient.d.ts +0 -130
  73. package/dist/insights/InsightsApiClient.d.ts.map +0 -1
  74. package/dist/insights/InsightsApiClient.js +0 -143
  75. package/dist/insights/InsightsApiClient.js.map +0 -1
  76. package/dist/insights/index.d.ts +0 -4
  77. package/dist/insights/index.d.ts.map +0 -1
  78. package/dist/insights/index.js +0 -4
  79. package/dist/insights/index.js.map +0 -1
package/README.md CHANGED
@@ -11,10 +11,14 @@
11
11
  <div align="center">
12
12
 
13
13
  [Readme](./README.md) · [Reference](https://contentful.github.io/optimization) ·
14
- [Contributing](/CONTRIBUTING.md)
14
+ [Contributing](../../CONTRIBUTING.md)
15
15
 
16
16
  </div>
17
17
 
18
+ > [!WARNING]
19
+ >
20
+ > The Optimization SDK Suite is pre-release (alpha). Breaking changes may be published at any time.
21
+
18
22
  The Contentful Optimization API Client Library provides methods for interfacing with Contentful's
19
23
  Experience and Insights APIs, which serve its Personalization and Analytics products.
20
24
 
@@ -72,13 +76,13 @@ const client = new ApiClient({ clientId: 'abc123' })
72
76
 
73
77
  ### Top-level Configuration Options
74
78
 
75
- | Option | Required? | Default | Description |
76
- | ----------------- | --------- | ----------------------------- | --------------------------------------------------------------------- |
77
- | `analytics` | No | See "Analytics Options" | Configuration specific to the Analytics/Insights API |
78
- | `clientId` | Yes | N/A | The Ninetailed API Key which can be found in the Ninetailed Admin app |
79
- | `environment` | No | `'main'` | The Ninetailed environment configured in the Ninetailed Admin app |
80
- | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
81
- | `personalization` | No | See "Personalization Options" | Configuration specific to the Personalization/Experience API |
79
+ | Option | Required? | Default | Description |
80
+ | ----------------- | --------- | ----------------------------- | ------------------------------------------------------------ |
81
+ | `analytics` | No | See "Analytics Options" | Configuration specific to the Analytics/Insights API |
82
+ | `clientId` | Yes | N/A | The Optimization API key |
83
+ | `environment` | No | `'main'` | The environment identifier |
84
+ | `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
85
+ | `personalization` | No | See "Personalization Options" | Configuration specific to the Personalization/Experience API |
82
86
 
83
87
  ### Fetch Options
84
88
 
@@ -101,6 +105,15 @@ Configuration method signatures:
101
105
  - `fetchMethod`: `(url: string \| URL, init: RequestInit) => Promise<Response>`
102
106
  - `onFailedAttempt` and `onRequestTimeout`: `(options: FetchMethodCallbackOptions) => void`
103
107
 
108
+ > [!NOTE]
109
+ >
110
+ > Retry behavior is intentionally fixed to HTTP `503` responses (`Service Unavailable`) for the
111
+ > default SDK transport policy. This matches current Experience and Insights API expectations: `503`
112
+ > is treated as the transient availability signal, while other response classes are handled by
113
+ > caller logic and are intentionally not retried by default. Treat this as deliberate contract
114
+ > behavior, not a transport gap; broaden retry status handling only with an explicit API contract
115
+ > change.
116
+
104
117
  ### Analytics Options
105
118
 
106
119
  | Option | Required? | Default | Description |
@@ -131,8 +144,8 @@ Configuration method signatures:
131
144
 
132
145
  ### Experience API
133
146
 
134
- Experience API methods are scoped to the client's `personalization` member. All singular
135
- personalization methods return a `Promise` that resolves with the following data:
147
+ Experience API methods are scoped to the client's `experience` member. All singular experience
148
+ methods return a `Promise` that resolves with the following data:
136
149
 
137
150
  ```json
138
151
  {
@@ -156,21 +169,21 @@ personalization methods return a `Promise` that resolves with the following data
156
169
 
157
170
  ```ts
158
171
  const client = new ApiClient({ clientId: 'abc123' })
159
- const { profile } = await client.personalization.getProfile('profile-123', { locale: 'de-DE' })
172
+ const { profile } = await client.experience.getProfile('profile-123', { locale: 'de-DE' })
160
173
  ```
161
174
 
162
175
  #### Create a New Profile
163
176
 
164
177
  ```ts
165
178
  const client = new ApiClient({ clientId: 'abc123' })
166
- const { profile } = await client.personalization.createProfile({ events: [...] }, { locale: 'de-DE' })
179
+ const { profile } = await client.experience.createProfile({ events: [...] }, { locale: 'de-DE' })
167
180
  ```
168
181
 
169
182
  #### Update an Existing Profile
170
183
 
171
184
  ```ts
172
185
  const client = new ApiClient({ clientId: 'abc123' })
173
- const { profile } = await client.personalization.updateProfile(
186
+ const { profile } = await client.experience.updateProfile(
174
187
  {
175
188
  profileId: 'profile-123',
176
189
  events: [...],
@@ -183,7 +196,7 @@ const { profile } = await client.personalization.updateProfile(
183
196
 
184
197
  ```ts
185
198
  const client = new ApiClient({ clientId: 'abc123' })
186
- const { profile } = await client.personalization.upsertProfile(
199
+ const { profile } = await client.experience.upsertProfile(
187
200
  {
188
201
  profileId,
189
202
  events: [...],
@@ -195,30 +208,45 @@ const { profile } = await client.personalization.upsertProfile(
195
208
  #### Upsert Many Profiles
196
209
 
197
210
  The `upsertManyProfiles` method returns a `Promise` that resolves with an array of user profiles.
198
- Each event should have an additional `anonymousId` property set to the associated anonymous ID or
199
- profile ID.
211
+ The `events` array must contain at least one event. Each event should have an additional
212
+ `anonymousId` property set to the associated anonymous ID or profile ID.
200
213
 
201
214
  ```ts
202
215
  const client = new ApiClient({ clientId: 'abc123' })
203
- const profiles = await client.personalization.upsertManyProfiles(
204
- { events: [...]},
216
+ const profiles = await client.experience.upsertManyProfiles(
217
+ {
218
+ events: [
219
+ {
220
+ anonymousId: 'anon-123',
221
+ // valid Experience event payload fields
222
+ },
223
+ ],
224
+ },
205
225
  { locale: 'de-DE' },
206
226
  )
207
227
  ```
208
228
 
209
229
  ### Insights API
210
230
 
211
- Insights API methods are scoped to the client's `analytics` member. All analytics methods return a
212
- `Promise` that resolves to `void` (no value).
231
+ Insights API methods are scoped to the client's `insights` member. The batch send method returns a
232
+ `Promise` that resolves to `boolean`.
213
233
 
214
234
  #### Send Batch Events
215
235
 
216
236
  ```ts
217
237
  const client = new ApiClient({ clientId: 'abc123' })
218
- await client.analytics.sendBatchEvents([
238
+ await client.insights.sendBatchEvents([
219
239
  {
220
240
  profile: { id: 'abc-123', ... },
221
- events: [{ type: 'track', ... }],
241
+ events: [
242
+ {
243
+ type: 'component',
244
+ componentId: 'hero-banner',
245
+ componentType: 'Entry',
246
+ variantIndex: 0,
247
+ ...,
248
+ },
249
+ ],
222
250
  }
223
251
  ])
224
252
  ```
@@ -271,12 +299,15 @@ Configuration method signatures:
271
299
 
272
300
  #### Event Builder Configured Methods
273
301
 
302
+ - `buildComponentClick`: Builds a component click event payload for a Contentful entry-based
303
+ component
274
304
  - `buildComponentView`: Builds a component view event payload for a Contentful entry-based component
275
305
  - `buildFlagView`: Builds a component view payload event for a Custom Flag component
276
306
  - `buildIdentify`: Builds an identify event payload to associate a user ID with traits
277
307
  - `buildPageView`: Builds a page view event payload
308
+ - `buildScreenView`: Builds a screen view event payload
278
309
  - `buildTrack`: Builds a track event payload for arbitrary user actions
279
310
 
280
311
  See the
281
- [Event Builder documentation](../classes/_contentful_optimization-api-client.EventBuilder.html) for
282
- more information regarding arguments and return values.
312
+ [Event Builder documentation](https://contentful.github.io/optimization/classes/_contentful_optimization-api-client.EventBuilder.html)
313
+ for more information regarding arguments and return values.
package/dist/199.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import * as __rspack_external__contentful_optimization_api_schemas_66dcf407 from "@contentful/optimization-api-schemas";
2
+ export { __rspack_external__contentful_optimization_api_schemas_66dcf407 };
package/dist/649.mjs ADDED
@@ -0,0 +1,131 @@
1
+ class LogSink {
2
+ }
3
+ const logger_LogSink = LogSink;
4
+ class Logger {
5
+ name = '@contentful/optimization';
6
+ PREFIX_PARTS = [
7
+ 'Ctfl',
8
+ 'O10n'
9
+ ];
10
+ DELIMITER = ':';
11
+ sinks = [];
12
+ assembleLocationPrefix(logLocation) {
13
+ return `[${[
14
+ ...this.PREFIX_PARTS,
15
+ logLocation
16
+ ].join(this.DELIMITER)}]`;
17
+ }
18
+ addSink(sink) {
19
+ this.sinks = [
20
+ ...this.sinks.filter((existingSink)=>existingSink.name !== sink.name),
21
+ sink
22
+ ];
23
+ }
24
+ removeSink(name) {
25
+ this.sinks = this.sinks.filter((sink)=>sink.name !== name);
26
+ }
27
+ removeSinks() {
28
+ this.sinks = [];
29
+ }
30
+ debug(logLocation, message, ...args) {
31
+ this.emit('debug', logLocation, message, ...args);
32
+ }
33
+ info(logLocation, message, ...args) {
34
+ this.emit('info', logLocation, message, ...args);
35
+ }
36
+ log(logLocation, message, ...args) {
37
+ this.emit('log', logLocation, message, ...args);
38
+ }
39
+ warn(logLocation, message, ...args) {
40
+ this.emit('warn', logLocation, message, ...args);
41
+ }
42
+ error(logLocation, message, ...args) {
43
+ this.emit('error', logLocation, message, ...args);
44
+ }
45
+ fatal(logLocation, message, ...args) {
46
+ this.emit('fatal', logLocation, message, ...args);
47
+ }
48
+ emit(level, logLocation, message, ...args) {
49
+ this.onLogEvent({
50
+ name: this.name,
51
+ level,
52
+ messages: [
53
+ `${this.assembleLocationPrefix(logLocation)} ${String(message)}`,
54
+ ...args
55
+ ]
56
+ });
57
+ }
58
+ onLogEvent(event) {
59
+ this.sinks.forEach((sink)=>{
60
+ sink.ingest(event);
61
+ });
62
+ }
63
+ }
64
+ const logger = new Logger();
65
+ function createScopedLogger(location) {
66
+ return {
67
+ debug: (message, ...args)=>{
68
+ logger.debug(location, message, ...args);
69
+ },
70
+ info: (message, ...args)=>{
71
+ logger.info(location, message, ...args);
72
+ },
73
+ log: (message, ...args)=>{
74
+ logger.log(location, message, ...args);
75
+ },
76
+ warn: (message, ...args)=>{
77
+ logger.warn(location, message, ...args);
78
+ },
79
+ error: (message, ...args)=>{
80
+ logger.error(location, message, ...args);
81
+ },
82
+ fatal: (message, ...args)=>{
83
+ logger.fatal(location, message, ...args);
84
+ }
85
+ };
86
+ }
87
+ const logLevelSeverity = {
88
+ fatal: 60,
89
+ error: 50,
90
+ warn: 40,
91
+ info: 30,
92
+ debug: 20,
93
+ log: 10
94
+ };
95
+ const consoleMap = {
96
+ debug: (...args)=>{
97
+ console.debug(...args);
98
+ },
99
+ info: (...args)=>{
100
+ console.info(...args);
101
+ },
102
+ log: (...args)=>{
103
+ console.log(...args);
104
+ },
105
+ warn: (...args)=>{
106
+ console.warn(...args);
107
+ },
108
+ error: (...args)=>{
109
+ console.error(...args);
110
+ },
111
+ fatal: (...args)=>{
112
+ console.error(...args);
113
+ }
114
+ };
115
+ class ConsoleLogSink extends logger_LogSink {
116
+ name = 'ConsoleLogSink';
117
+ verbosity;
118
+ constructor(verbosity){
119
+ super();
120
+ this.verbosity = verbosity ?? 'error';
121
+ }
122
+ ingest(event) {
123
+ if (logLevelSeverity[event.level] < logLevelSeverity[this.verbosity]) return;
124
+ consoleMap[event.level](...event.messages);
125
+ }
126
+ }
127
+ const lib_logger = Logger;
128
+ export default lib_logger;
129
+ export { ConsoleLogSink, Logger, createScopedLogger, logLevelSeverity, logger, logger_LogSink as LogSink };
130
+
131
+ //# sourceMappingURL=649.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"649.mjs","sources":["../src/lib/logger/LogSink.ts","../src/lib/logger/Logger.ts","../src/lib/logger/logging.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","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","/**\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","/* 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","Logger","logLocation","sink","existingSink","name","message","args","level","String","event","logger","createScopedLogger","location","logLevelSeverity","consoleMap","console","ConsoleLogSink","verbosity"],"mappings":"AAkBA,MAAeA;AAWf;AAEA,uBAAeA;AChBR,MAAMC;IAEF,OAAO,2BAA0B;IAEzB,eAAe;QAAC;QAAQ;KAAO;IAC/B,YAAY,IAAG;IACxB,QAAmB,EAAE;IAErB,uBAAuBC,WAAmB,EAAU;QAC1D,OAAO,CAAC,CAAC,EAAE;eAAI,IAAI,CAAC,YAAY;YAAEA;SAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACxE;IAeO,QAAQC,IAAa,EAAQ;QAClC,IAAI,CAAC,KAAK,GAAG;eAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAACC,eAAiBA,aAAa,IAAI,KAAKD,KAAK,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C5B,IAAII,gBAAgB,CAACJ,MAAM,KAAK,CAAC,GAAGI,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAEtEC,UAAU,CAACL,MAAM,KAAK,CAAC,IAAIA,MAAM,QAAQ;IAC3C;AACF;AC9DA,mBAAeT"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "@contentful/optimization-api-schemas" (module) {
4
+ module.exports = require("@contentful/optimization-api-schemas");
5
+ }
6
+ };
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
44
+ });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ var _contentful_optimization_api_schemas__rspack_import_0 = __webpack_require__("@contentful/optimization-api-schemas");
51
+ var __rspack_reexport = {};
52
+ for(const __rspack_import_key in _contentful_optimization_api_schemas__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_api_schemas__rspack_import_0[__rspack_import_key];
53
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
54
+ })();
55
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ Object.defineProperty(exports, '__esModule', {
57
+ value: true
58
+ });
59
+
60
+ //# sourceMappingURL=api-schemas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-schemas.cjs","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\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};"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D"}
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,4 @@
1
+
2
+ export * from "@contentful/optimization-api-schemas";
3
+
4
+ export { }
@@ -0,0 +1,2 @@
1
+ import "./199.mjs";
2
+ export * from "@contentful/optimization-api-schemas";