@equinor/fusion-framework-module-bookmark 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ import type { ILogger, LogLevel } from '@equinor/fusion-log';
13
13
 
14
14
  import { BookmarkClient } from './BookmarkClient';
15
15
  import type { BookmarkModule } from './bookmark-module';
16
- import { bookmarkConfigSchema } from './bookmark-config.schema';
16
+ import { bookmarkConfigSchema, parseBookmarkConfig } from './bookmark-config.schema';
17
17
  import type { BookmarkModuleConfig } from './types';
18
18
  import type { BookmarkProvider } from './BookmarkProvider';
19
19
 
@@ -26,7 +26,9 @@ const initialBookmarkConfig = bookmarkConfigSchema
26
26
  .partial()
27
27
  .optional();
28
28
 
29
- type InitialBookmarkConfig = z.infer<typeof initialBookmarkConfig>;
29
+ const parseInitialBookmarkConfigConfig = (initial?: unknown): BookmarkModuleConfig => {
30
+ return initialBookmarkConfig.parse(initial) as BookmarkModuleConfig;
31
+ };
30
32
 
31
33
  /**
32
34
  * Configurator for the bookmark module.
@@ -185,7 +187,10 @@ export class BookmarkModuleConfigurator extends BaseConfigBuilder<BookmarkModule
185
187
  * @param initial - An optional initial config to merge into the returned config.
186
188
  * @returns The config object.
187
189
  */
188
- protected _createConfig(init: ConfigBuilderCallbackArgs, initial?: InitialBookmarkConfig) {
190
+ protected _createConfig(
191
+ init: ConfigBuilderCallbackArgs,
192
+ initial?: Partial<BookmarkModuleConfig>,
193
+ ) {
189
194
  // check if parent is provided
190
195
  if (!this._has('parent')) {
191
196
  this.#log?.debug('No parent provided, using default parent');
@@ -232,7 +237,7 @@ export class BookmarkModuleConfigurator extends BaseConfigBuilder<BookmarkModule
232
237
  }
233
238
 
234
239
  // call super to create config
235
- return super._createConfig(init, initialBookmarkConfig.parse(initial));
240
+ return super._createConfig(init, parseInitialBookmarkConfigConfig(initial));
236
241
  }
237
242
 
238
243
  /**
@@ -359,7 +364,7 @@ export class BookmarkModuleConfigurator extends BaseConfigBuilder<BookmarkModule
359
364
  _init: ConfigBuilderCallbackArgs,
360
365
  ): Promise<BookmarkModuleConfig> {
361
366
  try {
362
- return bookmarkConfigSchema.parse(config);
367
+ return parseBookmarkConfig(config);
363
368
  } catch (err) {
364
369
  this.#log?.error('Failed to parse config', config, (err as ZodError).issues ?? err);
365
370
  throw err;