@cccsaurora/howler-ui 3.1.0-dev.1619 → 3.1.0-dev.1621

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/package.json CHANGED
@@ -97,7 +97,7 @@
97
97
  "url": "https://github.com/CybercentreCanada/howler"
98
98
  },
99
99
  "type": "module",
100
- "version": "3.1.0-dev.1619",
100
+ "version": "3.1.0-dev.1621",
101
101
  "exports": {
102
102
  "./i18n": "./i18n.js",
103
103
  "./index.css": "./index.css",
@@ -1,3 +1,4 @@
1
+ import type { DatabaseConfig } from '@cccsaurora/clue-ui/database/types';
1
2
  import { type PropsWithChildren } from 'react';
2
3
  export interface CluePluginOptions {
3
4
  baseURL?: string;
@@ -7,6 +8,8 @@ export interface CluePluginOptions {
7
8
  includeContext?: boolean;
8
9
  defaultTimeout?: number;
9
10
  chunkSize?: number;
11
+ replicate?: boolean;
12
+ storageType?: DatabaseConfig['storageType'];
10
13
  }
11
14
  type ProviderProps = PropsWithChildren<{
12
15
  options?: CluePluginOptions;
@@ -20,7 +20,12 @@ const Provider = ({ children, options = {} }) => {
20
20
  if (!features.clue) {
21
21
  return;
22
22
  }
23
- void buildDatabase({ storageType: 'memory', replicate: true, baseURL, getToken }).then(database => {
23
+ void buildDatabase({
24
+ storageType: options.storageType ?? 'memory',
25
+ replicate: !!options.replicate,
26
+ baseURL,
27
+ getToken
28
+ }).then(database => {
24
29
  if (!cancelled) {
25
30
  setDatabase(database);
26
31
  }
@@ -28,7 +33,7 @@ const Provider = ({ children, options = {} }) => {
28
33
  return () => {
29
34
  cancelled = true;
30
35
  };
31
- }, [baseURL, features.clue, getToken]);
36
+ }, [baseURL, features.clue, getToken, options.storageType, options.replicate]);
32
37
  return (_jsx(ClueProvider, { baseURL: baseURL, getToken: getToken, enabled: features.clue, publicIconify: publicIconify, customIconify: customIconify, defaultTimeout: options.defaultTimeout ?? 5, i18next: useTranslation('clue'), chunkSize: options.chunkSize ?? 50, database: database, includeContext: options.includeContext, children: children }));
33
38
  };
34
39
  export default Provider;
@@ -58,7 +58,7 @@ describe('Clue Provider', () => {
58
58
  renderProvider({ configuration: { features: { clue: false } } });
59
59
  expect(getProviderProps().getToken?.()).toBe('stored-token');
60
60
  });
61
- it('builds a replicated database and passes supplied deployment options', async () => {
61
+ it('builds a configured database and passes supplied deployment options', async () => {
62
62
  const database = { name: 'replicated' };
63
63
  const getToken = vi.fn(() => 'custom-token');
64
64
  mocks.buildDatabase.mockResolvedValue(database);
@@ -69,7 +69,9 @@ describe('Clue Provider', () => {
69
69
  customIconify: 'https://icons.example',
70
70
  includeContext: true,
71
71
  defaultTimeout: 7,
72
- chunkSize: 25
72
+ chunkSize: 25,
73
+ replicate: true,
74
+ storageType: 'memory'
73
75
  });
74
76
  await waitFor(() => {
75
77
  expect(mocks.buildDatabase).toHaveBeenCalledWith({
@@ -90,6 +92,18 @@ describe('Clue Provider', () => {
90
92
  chunkSize: 25
91
93
  });
92
94
  });
95
+ it('uses non-replicated in-memory storage by default', async () => {
96
+ mocks.buildDatabase.mockResolvedValue({ name: 'local' });
97
+ renderProvider({ configuration: { features: { clue: true } } });
98
+ await waitFor(() => {
99
+ expect(mocks.buildDatabase).toHaveBeenCalledWith({
100
+ storageType: 'memory',
101
+ replicate: false,
102
+ baseURL: `${location.origin}/api/v1/clue`,
103
+ getToken: expect.any(Function)
104
+ });
105
+ });
106
+ });
93
107
  it('ignores a database that resolves after the provider unmounts', async () => {
94
108
  let resolveDatabase = () => { };
95
109
  mocks.buildDatabase.mockReturnValue(new Promise(resolve => {