Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(headless): fix internal resolution errors in node16 #4445

Merged
merged 17 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .github/workflows/prbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: ./.github/actions/setup
- run: npm test
packages-compatibility:
name: 'Are packages compatible?'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: ./.github/actions/setup
- run: npm run packages:compatibility
e2e-atomic-csp-test:
name: 'Run e2e tests on Atomic CSP'
needs: build
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"e2e": "nx run-many --target=e2e",
"lint:check": "eslint . && cspell **/*.md --no-progress --show-suggestions --show-context && prettier --check '**/*.{css,pcss,html,md,yml,ts,tsx,js,mjs,json}'",
"lint:fix": "eslint --fix . && prettier --write '**/*.{css,pcss,html,md,yml,ts,tsx,js,mjs,json}'",
"packages:compatibility": "node ./scripts/ci/packages-compatibility.mjs",
"pr:report": "node ./scripts/reports/pr-report.mjs",
"report:bundle-size:time-series": "node ./scripts/reports/bundle-size/time-series.mjs",
"commit": "git-cz",
Expand Down Expand Up @@ -83,6 +84,7 @@
"patch-package": "8.0.0",
"prettier": "3.3.3",
"prettier-plugin-tailwindcss": "0.6.5",
"publint": "0.2.11",
"react-syntax-highlighter": "15.5.0",
"rimraf": "5.0.9",
"semver": "7.6.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/atomic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest",
"build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang "
},
"main": "./dist/cjs/atomic-react.js",
"main": "./dist/cjs/atomic-react.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -63,17 +63,17 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/cjs/atomic-react.js"
"require": "./dist/cjs/atomic-react.cjs"
},
"./commerce": {
"types": "./dist/commerce.index.d.ts",
"import": "./dist/commerce.index.js",
"require": "./dist/cjs/commerce/atomic-react.js"
"require": "./dist/cjs/commerce/atomic-react.cjs"
},
"./recommendation": {
"types": "./dist/recommendation.index.d.ts",
"import": "./dist/recommendation.index.js",
"require": "./dist/cjs/recommendation/atomic-react.js"
"require": "./dist/cjs/recommendation/atomic-react.cjs"
}
}
}
2 changes: 1 addition & 1 deletion packages/atomic-react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const commonExternal = [

/** @returns {import('rollup').OutputOptions} */
const outputCJS = ({useCase}) => ({
file: `dist/cjs/${useCase}atomic-react.js`,
file: `dist/cjs/${useCase}atomic-react.cjs`,
format: 'cjs',
});

Expand Down
11 changes: 6 additions & 5 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"types": "dist/types/index.d.ts",
"exports": {
"./loader": {
"types": "./loader/index.d.ts",
"import": "./loader/index.js",
"require": "./loader/index.cjs.js",
"types": "./loader/index.d.ts"
"require": "./loader/index.cjs.js"
},
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs.js",
"types": "./dist/types/index.d.ts"
"require": "./dist/index.cjs.js"
},
"./themes/*": {
"import": "./dist/atomic/themes/*",
Expand All @@ -39,7 +39,8 @@
"files": [
"dist/",
"docs/",
"licenses/"
"licenses/",
"loader/"
],
"scripts": {
"clean": "rimraf -rf dist/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/headless/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async function buildBrowserConfig(options, outDir) {
const nodeCjs = Object.entries(useCaseEntries).map((entry) => {
const [useCase, entryPoint] = entry;
const dir = getUseCaseDir('dist/', useCase);
const outfile = `${dir}/headless.js`;
const outfile = `${dir}/headless.cjs`;
return buildNodeConfig(
{
entryPoints: [entryPoint],
Expand Down
16 changes: 8 additions & 8 deletions packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "git+https://github.com/coveo/ui-kit.git",
"directory": "packages/headless"
},
"main": "./dist/headless.js",
"main": "./dist/headless.cjs",
"module": "./dist/headless.esm.js",
"type": "module",
"exports": {
Expand All @@ -15,7 +15,7 @@
"node": {
"types": "./dist/definitions/index.d.ts",
"import": "./dist/headless.esm.js",
"require": "./dist/headless.js"
"require": "./dist/headless.cjs"
},
"browser": {
"types": "./dist/definitions/index.d.ts",
Expand All @@ -30,7 +30,7 @@
"node": {
"types": "./dist/definitions/case-assist.index.d.ts",
"import": "./dist/case-assist/headless.esm.js",
"require": "./dist/case-assist/headless.js"
"require": "./dist/case-assist/headless.cjs"
},
"browser": {
"types": "./dist/definitions/case-assist.index.d.ts",
Expand All @@ -45,7 +45,7 @@
"node": {
"types": "./dist/definitions/commerce.index.d.ts",
"import": "./dist/commerce/headless.esm.js",
"require": "./dist/commerce/headless.js"
"require": "./dist/commerce/headless.cjs"
},
"browser": {
"types": "./dist/definitions/commerce.index.d.ts",
Expand All @@ -60,7 +60,7 @@
"node": {
"types": "./dist/definitions/insight.index.d.ts",
"import": "./dist/insight/headless.esm.js",
"require": "./dist/insight/headless.js"
"require": "./dist/insight/headless.cjs"
},
"browser": {
"types": "./dist/definitions/insight.index.d.ts",
Expand All @@ -75,7 +75,7 @@
"node": {
"types": "./dist/definitions/recommendation.index.d.ts",
"import": "./dist/recommendation/headless.esm.js",
"require": "./dist/recommendation/headless.js"
"require": "./dist/recommendation/headless.cjs"
},
"browser": {
"types": "./dist/definitions/recommendation.index.d.ts",
Expand All @@ -90,7 +90,7 @@
"node": {
"types": "./dist/definitions/ssr.index.d.ts",
"import": "./dist/ssr/headless.esm.js",
"require": "./dist/ssr/headless.js"
"require": "./dist/ssr/headless.cjs"
},
"browser": {
"types": "./dist/definitions/ssr.index.d.ts",
Expand All @@ -105,7 +105,7 @@
"node": {
"types": "./dist/definitions/ssr-commerce.index.d.ts",
"import": "./dist/ssr-commerce/headless.esm.js",
"require": "./dist/ssr-commerce/headless.js"
"require": "./dist/ssr-commerce/headless.cjs"
},
"browser": {
"types": "./dist/definitions/ssr-commerce.index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {createRelay} from '@coveo/relay';
import {createMockState} from '../../test/mock-state';
import {getAnalyticsNextApiBaseUrl} from '../platform-client';
import {getRelayInstanceFromState} from './analytics-relay-client';
import {getAnalyticsSource} from './analytics-selectors';
import {createMockState} from '../../test/mock-state.js';
import {getAnalyticsNextApiBaseUrl} from '../platform-client.js';
import {getRelayInstanceFromState} from './analytics-relay-client.js';
import {getAnalyticsSource} from './analytics-selectors.js';

jest.mock('@coveo/relay');
jest.mock('./analytics-selectors');
Expand Down
6 changes: 3 additions & 3 deletions packages/headless/src/api/analytics/analytics-relay-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {createSelector} from '@reduxjs/toolkit';
import {
CommerceConfigurationSection,
ConfigurationSection,
} from '../../state/state-sections';
import {getAnalyticsNextApiBaseUrl} from '../platform-client';
import {getAnalyticsSource} from './analytics-selectors';
} from '../../state/state-sections.js';
import {getAnalyticsNextApiBaseUrl} from '../platform-client.js';
import {getAnalyticsSource} from './analytics-selectors.js';

type StateNeededByRelay = ConfigurationSection | CommerceConfigurationSection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createMockState} from '../../test/mock-state';
import {VERSION} from '../../utils/version';
import {getAnalyticsSource} from './analytics-selectors';
import {createMockState} from '../../test/mock-state.js';
import {VERSION} from '../../utils/version.js';
import {getAnalyticsSource} from './analytics-selectors.js';

describe('#getAnalyticsSources', () => {
it('without a source, returns an array only with `@coveo/headless`', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/headless/src/api/analytics/analytics-selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createSelector} from '@reduxjs/toolkit';
import {CoreAnalyticsState} from '../../features/configuration/configuration-state';
import {VERSION} from '../../utils/version';
import {CoreAnalyticsState} from '../../features/configuration/configuration-state.js';
import {VERSION} from '../../utils/version.js';

export const getAnalyticsSource = createSelector(
(state: CoreAnalyticsState) => state.source,
Expand Down
10 changes: 5 additions & 5 deletions packages/headless/src/api/analytics/base-analytics.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events';
import {getConfigurationInitialState} from '../../features/configuration/configuration-state';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state';
import {buildMockAnalyticsState} from '../../test/mock-analytics-state';
import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js';
import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js';
import {buildMockAnalyticsState} from '../../test/mock-analytics-state.js';
import {
BaseAnalyticsProvider,
StateNeededByBaseAnalyticsProvider,
} from './base-analytics';
} from './base-analytics.js';

class TestProvider extends BaseAnalyticsProvider<StateNeededByBaseAnalyticsProvider> {
public getPipeline(): string {
Expand Down
8 changes: 4 additions & 4 deletions packages/headless/src/api/analytics/base-analytics.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {SearchPageClientProvider} from 'coveo.analytics';
import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state';
import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js';
import {
ConfigurationSection,
ContextSection,
PipelineSection,
QuerySection,
SearchHubSection,
} from '../../state/state-sections';
import {VERSION} from '../../utils/version';
} from '../../state/state-sections.js';
import {VERSION} from '../../utils/version.js';

export const getLanguage = (state: ConfigurationSection) => {
const langKey = state.configuration.search.locale.split('-')[0];
Expand Down
10 changes: 5 additions & 5 deletions packages/headless/src/api/analytics/case-assist-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import {
CaseAssistClientProvider,
} from 'coveo.analytics';
import {Logger} from 'pino';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state';
import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js';
import {
CaseAssistConfigurationSection,
CaseFieldSection,
CaseInputSection,
ConfigurationSection,
DocumentSuggestionSection,
SearchHubSection,
} from '../../state/state-sections';
import {getOrganizationEndpoint} from '../platform-client';
import {PreprocessRequest} from '../preprocess-request';
} from '../../state/state-sections.js';
import {getOrganizationEndpoint} from '../platform-client.js';
import {PreprocessRequest} from '../preprocess-request.js';
import {
wrapAnalyticsClientSendEventHook,
wrapPreprocessRequest,
} from './coveo-analytics-utils';
} from './coveo-analytics-utils.js';

export type StateNeededByCaseAssistAnalytics = ConfigurationSection &
Partial<CaseAssistConfigurationSection> &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {AnalyticsClientSendEventHook} from 'coveo.analytics';
import {pino} from 'pino';
import {PlatformRequestOptions, PreprocessRequest} from '../preprocess-request';
import {
PlatformRequestOptions,
PreprocessRequest,
} from '../preprocess-request.js';
import {
wrapAnalyticsClientSendEventHook,
wrapPreprocessRequest,
} from './coveo-analytics-utils';
} from './coveo-analytics-utils.js';

describe('coveo-analytics-utils', () => {
it('should properly wrap preprocessRequest', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/headless/src/api/analytics/coveo-analytics-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
history,
} from 'coveo.analytics';
import {Logger} from 'pino';
import {clone} from '../../utils/utils';
import {PreprocessRequest} from '../preprocess-request';
import {clone} from '../../utils/utils.js';
import {PreprocessRequest} from '../preprocess-request.js';

export const getVisitorID = (options: {
runtimeEnvironment?: IRuntimeEnvironment;
Expand Down
26 changes: 13 additions & 13 deletions packages/headless/src/api/analytics/insight-analytics.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {CoveoAnalyticsClient} from 'coveo.analytics';
import pino from 'pino';
import {getConfigurationInitialState} from '../../features/configuration/configuration-state';
import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state';
import {buildMockFacetRequest} from '../../test/mock-facet-request';
import {buildMockFacetResponse} from '../../test/mock-facet-response';
import {buildMockFacetSlice} from '../../test/mock-facet-slice';
import {buildMockFacetValue} from '../../test/mock-facet-value';
import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request';
import {buildMockInsightState} from '../../test/mock-insight-state';
import {buildMockQueryState} from '../../test/mock-query-state';
import {buildMockResult} from '../../test/mock-result';
import {buildMockSearchState} from '../../test/mock-search-state';
import {pino} from 'pino';
import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js';
import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state.js';
import {buildMockFacetRequest} from '../../test/mock-facet-request.js';
import {buildMockFacetResponse} from '../../test/mock-facet-response.js';
import {buildMockFacetSlice} from '../../test/mock-facet-slice.js';
import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request.js';
import {buildMockFacetValue} from '../../test/mock-facet-value.js';
import {buildMockInsightState} from '../../test/mock-insight-state.js';
import {buildMockQueryState} from '../../test/mock-query-state.js';
import {buildMockResult} from '../../test/mock-result.js';
import {buildMockSearchState} from '../../test/mock-search-state.js';
import {
configureInsightAnalytics,
InsightAnalyticsProvider,
StateNeededByInsightAnalyticsProvider,
} from './insight-analytics';
} from './insight-analytics.js';

describe('insight analytics', () => {
const logger = pino({level: 'silent'});
Expand Down
Loading
Loading