Skip to content

Commit 2cff2b7

Browse files
feat(cc-api-client): enable resourceIdResolverStore (localStorage)
1 parent 01da001 commit 2cff2b7

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/lib/cc-api-client.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { CcApiClient } from '@clevercloud/client/cc-api-client.js';
2+
// FIXME: the import-x/resovler plugin needs to be configured to use `browser` export condition
3+
// eslint-disable-next-line import-x/no-unresolved
4+
import { LocalStorageStore } from '@clevercloud/client/cc-api-local-storage-store.js';
25
import { CcApiErrorEvent } from './send-to-api.events.js';
36

7+
/**
8+
* @typedef {Omit<ConstructorParameters<typeof CcApiClient>[0], 'hooks'>} CcApiClientConfigWithoutHooks
9+
*/
10+
411
/** @import { ApiConfig, ApiTokenConfig } from './send-to-api.types.js' */
512

613
/** @type {Map<string, CcApiClient>} */
@@ -99,6 +106,7 @@ export function getCcApiClientWithToken(apiTokenConfig) {
99106
},
100107
baseUrl: apiTokenConfig.API_HOST,
101108
defaultRequestConfig: { cors: true },
109+
resourceIdResolverStore: new LocalStorageStore(`cc-client-cache-${cacheKey}`),
102110
}),
103111
);
104112
}
@@ -109,7 +117,7 @@ export function getCcApiClientWithToken(apiTokenConfig) {
109117
/**
110118
* Create a CcApiClient with an onError hook that dispatches CcApiErrorEvent.
111119
*
112-
* @param {object} config - CcApiClient configuration
120+
* @param {CcApiClientConfigWithoutHooks} config - CcApiClient configuration
113121
* @returns {CcApiClient}
114122
*/
115123
function createClient(config) {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
/* Modules */
2525
"module": "nodenext" /* Specify what module code is generated. */,
2626
"moduleDetection": "force" /* Make TypeScript treat every file as a module even if it does not have any imports or export (see https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable) */,
27+
"customConditions": ["browser"],
2728
/* JavaScript Support */
2829
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
2930
"checkJs": true /* Enable error reporting in type-checked JavaScript files. */,

web-test-runner.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
return logMessage != null && !logsToExclude.includes(logMessage);
2323
},
2424
nodeResolve: {
25-
exportConditions: ['production', 'default'],
25+
exportConditions: ['production', 'default', 'browser'],
2626
},
2727
browsers: [
2828
chromeLauncher({

0 commit comments

Comments
 (0)