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

fix(types): fix missing type exports #1284

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions api-extractor.json
Expand Up @@ -32,6 +32,10 @@

"ae-missing-release-tag": {
"logLevel": "none"
},

"ae-forgotten-export": {
"logLevel": "error"
}
},

Expand Down
39 changes: 39 additions & 0 deletions packages/algoliasearch/src/builds/browserLite.ts
Expand Up @@ -29,6 +29,45 @@ import { createUserAgent, RequestOptions } from '@algolia/transporter';

import { AlgoliaSearchOptions } from '../types';

export {
MultipleQueriesOptions,
MultipleQueriesQuery,
MultipleQueriesResponse,
SearchClient as BaseSearchClient,
SearchClientOptions,
SearchForFacetValuesResponse,
SearchForFacetValuesQueryParams,
SearchIndex as BaseSearchIndex,
SearchOptions,
SearchResponse,
StrategyType,
ObjectWithObjectID,
FacetHit,
} from '@algolia/client-search';
export { AuthModeType, ClientTransporterOptions } from '@algolia/client-common';
export {
Headers,
HostOptions,
CallType,
QueryParameters,
Transporter,
TransporterOptions,
RequestOptions,
Timeouts,
UserAgent,
UserAgentOptions,
StatelessHost,
Request as TransporterRequest,
} from '@algolia/transporter';
export {
Request as RequesterRequest,
Response as RequesterResponse,
Requester,
MethodType,
} from '@algolia/requester-common';
export { Logger } from '@algolia/logger-common';
export { Cache, CacheEvents } from '@algolia/cache-common';

export default function algoliasearch(
appId: string,
apiKey: string,
Expand Down
142 changes: 142 additions & 0 deletions packages/algoliasearch/src/builds/node.ts
Expand Up @@ -196,6 +196,148 @@ import { createUserAgent, RequestOptions } from '@algolia/transporter';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just do export * from '@algolia/client-*' ?
Types listing seems unnecessary and hard to maintain + we would benefits from exporting helpers too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for node.ts only obviously)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a good option, would you want to make a PR to take this over @bodinsamuel ? The only thing to be careful of with export * is that in some cases types are exported from JS files and then will have runtime errors when accessed directly from JS. I don't think that's really an issue here, but just to keep in mind

import { AlgoliaSearchOptions, InitAnalyticsOptions, InitPersonalizationOptions } from '../types';

export {
GetPersonalizationStrategyResponse,
PersonalizationStrategy,
RecommendationClient as BaseRecommendationClient,
RecommendationClientOptions,
SetPersonalizationStrategyResponse,
} from '@algolia/client-recommendation';

export {
ABTest,
AnalyticsClient as BaseAnalyticsClient,
AnalyticsClientOptions,
AddABTestResponse,
GetABTestResponse,
GetABTestsOptions,
GetABTestsResponse,
StopABTestResponse,
DeleteABTestResponse,
Variant,
VariantResponse,
} from '@algolia/client-analytics';

export {
RequestOptions,
Transporter,
TransporterOptions,
HostOptions,
Headers,
QueryParameters,
CallType,
Timeouts,
UserAgent,
UserAgentOptions,
StatelessHost,
Request as TransporterRequest,
} from '@algolia/transporter';

export {
SearchIndex as BaseSearchIndex,
SearchResponse,
BatchRequest,
BatchResponse,
DeleteResponse,
GetObjectOptions,
ObjectWithObjectID,
GetObjectsOptions,
GetObjectsResponse,
ChunkOptions,
SaveObjectsOptions,
SaveObjectResponse,
ChunkedBatchResponse,
Settings,
SetSettingsResponse,
PartialUpdateObjectsOptions,
PartialUpdateObjectResponse,
DeleteByFiltersOptions,
BrowseOptions,
FindObjectOptions,
FindObjectResponse,
Synonym,
SaveSynonymsOptions,
SaveSynonymResponse,
SaveSynonymsResponse,
SearchSynonymsOptions,
SearchSynonymsResponse,
DeleteSynonymOptions,
ClearSynonymsOptions,
ReplaceAllObjectsOptions,
SearchRulesOptions,
Rule,
SaveRulesOptions,
SaveRuleResponse,
SaveRulesResponse,
ClearRulesOptions,
SearchClient as BaseSearchClient,
MultipleQueriesQuery,
MultipleQueriesOptions,
MultipleQueriesResponse,
SearchForFacetValuesResponse,
SearchForFacetValuesQueryParams,
SearchOptions,
MultipleBatchRequest,
MultipleBatchResponse,
MultipleGetObject,
MultipleGetObjectsResponse,
CopyIndexOptions,
IndexOperationResponse,
ListIndicesResponse,
GetLogsResponse,
ListClustersResponse,
GetApiKeyResponse,
AddApiKeyOptions,
AddApiKeyResponse,
ListApiKeysResponse,
UpdateApiKeyOptions,
UpdateApiKeyResponse,
DeleteApiKeyResponse,
RestoreApiKeyResponse,
AssignUserIDResponse,
AssignUserIDsResponse,
UserIDResponse,
SearchUserIDsOptions,
SearchUserIDsResponse,
ListUserIDsOptions,
ListUserIDsResponse,
GetTopUserIDsResponse,
RemoveUserIDResponse,
HasPendingMappingsOptions,
ScopeType,
Log,
Cluster,
Indice,
HasPendingMappingsResponse,
SecuredApiKeyRestrictions,
BatchActionType,
StrategyType,
Condition,
Consequence,
TimeRange,
FacetHit,
SynonymType,
ConsequenceParams,
ConsequencePromote,
ConsequenceQuery,
AutomaticFacetFilter,
SearchClientOptions,
} from '@algolia/client-search';

export { ClientTransporterOptions, AuthModeType, WaitablePromise } from '@algolia/client-common';

export {
Destroyable,
Requester,
Request as RequesterRequest,
Response as RequesterResponse,
MethodType,
} from '@algolia/requester-common';

export { Cache, CacheEvents } from '@algolia/cache-common';

export { Logger } from '@algolia/logger-common';

export default function algoliasearch(
appId: string,
apiKey: string,
Expand Down
9 changes: 8 additions & 1 deletion scripts/build.js
Expand Up @@ -6,6 +6,8 @@ const execa = require('execa');

const targets = fs.readdirSync('packages').filter(f => fs.statSync(`packages/${f}`).isDirectory());

const bundledPackages = targets.map(target => `@algolia/${target}`);

run();

async function run() {
Expand Down Expand Up @@ -49,7 +51,12 @@ async function buildDefinition(target, config = '') {
pkgDir,
`api-extractor${config ? `-${config}` : ''}.json`
);
const extractorConfig = ExtractorConfig.loadFileAndPrepare(extractorConfigPath);

const extractorConfig = {
...ExtractorConfig.loadFileAndPrepare(extractorConfigPath),
bundledPackages: target === 'algoliasearch' ? bundledPackages : [],
};

const result = Extractor.invoke(extractorConfig, {
localBuild: true,
showVerboseMessages: true,
Expand Down