Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from './cache';
export * from './constants';
export * from './createAlgoliaAgent';
export * from './createAuth';
export * from './createIterablePromise';
export * from './getAlgoliaAgent';
export * from './logger';
export * from './transporter';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"types": ["node", "vitest/globals"],
"outDir": "dist"
},
"include": ["src", "index.ts"],
"include": ["src"],
"exclude": ["dist", "node_modules", "src/__tests__"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export default defineConfig([
{
...getBaseNodeOptions(pkg, __dirname),
format: 'cjs',
dts: { entry: { common: 'index.ts' } },
entry: { common: 'index.ts' },
dts: { entry: { common: 'src/index.ts' } },
entry: { common: 'src/index.ts' },
},
{
...getBaseNodeOptions(pkg, __dirname),
format: 'esm',
dts: { entry: { common: 'index.ts' } },
entry: { common: 'index.ts' },
dts: { entry: { common: 'src/index.ts' } },
entry: { common: 'src/index.ts' },
},
]);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export default defineConfig([
{
...getBaseNodeOptions(pkg, __dirname),
format: 'cjs',
dts: { entry: { logger: 'index.ts' } },
entry: { logger: 'index.ts' },
dts: { entry: { logger: 'src/logger.ts' } },
entry: { logger: 'src/logger.ts' },
},
{
...getBaseNodeOptions(pkg, __dirname),
format: 'esm',
dts: { entry: { logger: 'index.ts' } },
entry: { logger: 'index.ts' },
dts: { entry: { logger: 'src/logger.ts' } },
entry: { logger: 'src/logger.ts' },
},
]);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './createXhrRequester';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"types": ["node", "vitest/globals"],
"outDir": "dist"
},
"include": ["src", "index.ts"],
"include": ["src"],
"exclude": ["dist", "node_modules", "src/__tests__"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default defineConfig({
...getBaseBrowserOptions(pkg, __dirname),
minify: true,
globalName: 'requesterxhr',
entry: { 'requester.xhr': 'index.ts' },
dts: { entry: { 'requester.xhr': 'index.ts' } },
entry: { 'requester.xhr': 'src/index.ts' },
dts: { entry: { 'requester.xhr': 'src/index.ts' } },
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './createFetchRequester';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"types": ["node", "vitest/globals"],
"outDir": "dist"
},
"include": ["src", "index.ts"],
"include": ["src"],
"exclude": ["dist", "node_modules", "src/__tests__"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ export default defineConfig([
...getBaseNodeOptions(pkg, __dirname),
format: 'cjs',
name: 'node cjs',
entry: { 'requester.fetch.node': 'index.ts' },
dts: { entry: { 'requester.fetch.node': 'index.ts' } },
entry: { 'requester.fetch.node': 'src/index.ts' },
dts: { entry: { 'requester.fetch.node': 'src/index.ts' } },
},
{
...getBaseNodeOptions(pkg, __dirname),
format: 'esm',
name: 'node esm',
entry: { 'requester.fetch.node': 'index.ts' },
dts: { entry: { 'requester.fetch.node': 'index.ts' } },
entry: { 'requester.fetch.node': 'src/index.ts' },
dts: { entry: { 'requester.fetch.node': 'src/index.ts' } },
},
{
...getBaseBrowserOptions(pkg, __dirname),
minify: true,
name: 'browser esm',
entry: { 'requester.fetch.browser': 'index.ts' },
dts: { entry: { 'requester.fetch.browser': 'index.ts' } },
entry: { 'requester.fetch.browser': 'src/index.ts' },
dts: { entry: { 'requester.fetch.browser': 'src/index.ts' } },
globalName: 'requesterfetch',
},
]);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './createHttpRequester';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"types": ["node", "vitest/globals"],
"outDir": "dist"
},
"include": ["src", "index.ts"],
"include": ["src"],
"exclude": ["dist", "node_modules", "src/__tests__"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export default defineConfig([
{
...getBaseNodeOptions(pkg, __dirname),
format: 'cjs',
entry: { 'requester.http': 'index.ts' },
dts: { entry: { 'requester.http': 'index.ts' } },
entry: { 'requester.http': 'src/index.ts' },
dts: { entry: { 'requester.http': 'src/index.ts' } },
},
{
...getBaseNodeOptions(pkg, __dirname),
format: 'esm',
entry: { 'requester.http': 'index.ts' },
dts: { entry: { 'requester.http': 'index.ts' } },
entry: { 'requester.http': 'src/index.ts' },
dts: { entry: { 'requester.http': 'src/index.ts' } },
},
]);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import { createEchoRequester } from './createEchoRequester';
export function browserEchoRequester(status: number = 200): Requester {
return createEchoRequester({ getURL: (url: string) => new URL(url), status });
}

export type { EchoResponse } from './createEchoRequester.ts';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './browserEchoRequester';
export * from './createEchoRequester';
export * from './nodeEchoRequester';
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ import { createEchoRequester } from './createEchoRequester';
export function nodeEchoRequester(status: number = 200): Requester {
return createEchoRequester({ getURL: (url: string) => new URL(url), status });
}

export type { EchoResponse } from './createEchoRequester.ts';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"types": ["node"],
"outDir": "dist"
},
"include": ["src", "index.ts"],
"include": ["src"],
"exclude": ["dist", "node_modules"]
}
4 changes: 2 additions & 2 deletions config/base.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "nodenext",
"noImplicitAny": false,
"target": "esnext",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "node",
"moduleResolution": "nodenext",
"removeComments": true,
"sourceMap": true,
"noLib": false,
Expand Down
1 change: 0 additions & 1 deletion templates/javascript/tests/client/client.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// {{generationBanner}}
/* eslint-disable eslint/no-unused-vars */
// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines.
import { describe, test, expect } from 'vitest';

import { {{{clientName}}} } from '{{{importPackage}}}';
Expand Down
48 changes: 47 additions & 1 deletion templates/javascript/tests/client/createClient.mustache
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
{{^autoCreateClient}}const client = {{/autoCreateClient}}{{{clientName}}}('{{parametersWithDataTypeMap.appId.value}}', '{{parametersWithDataTypeMap.apiKey.value}}'{{#isSearchClient}}, { {{#useEchoRequester}}requester: nodeEchoRequester(),{{/useEchoRequester}}{{#hasCustomHosts}}hosts:[{{#customHosts}}{ url: 'localhost', port: {{port}}, accept: 'readWrite', protocol: 'http' },{{/customHosts}}]{{/hasCustomHosts}} }{{/isSearchClient}}){{^isSearchClient}}.{{{initMethod}}}({ options: { {{#useEchoRequester}}requester: nodeEchoRequester(),{{/useEchoRequester}} {{#hasCustomHosts}}hosts:[{{#customHosts}}{ url: 'localhost', port: {{port}}, accept: 'readWrite', protocol: 'http' },{{/customHosts}}]{{/hasCustomHosts}} }, {{#hasRegionalHost}} region:'{{{parametersWithDataTypeMap.region.value}}}' {{/hasRegionalHost}} }){{/isSearchClient}};
{{^autoCreateClient}}const client = {{/autoCreateClient}}{{{clientName}}}(
'{{parametersWithDataTypeMap.appId.value}}',
'{{parametersWithDataTypeMap.apiKey.value}}'
{{#isSearchClient}},
{
{{#useEchoRequester}}
requester: nodeEchoRequester(),
{{/useEchoRequester}}
{{#hasCustomHosts}}
hosts:[
{{#customHosts}}
{
url: 'localhost',
port: {{port}},
accept: 'readWrite',
protocol: 'http'
},
{{/customHosts}}
]
{{/hasCustomHosts}}
}
{{/isSearchClient}}
){{^isSearchClient}}.{{{initMethod}}}(
{
options: {
{{#useEchoRequester}}
requester: nodeEchoRequester(),
{{/useEchoRequester}}
{{#hasCustomHosts}}
hosts:[
{{#customHosts}}
{
url: 'localhost',
port: {{port}},
accept: 'readWrite',
protocol: 'http'
},
{{/customHosts}}
]
{{/hasCustomHosts}}
},
{{#hasRegionalHost}}
// @ts-ignore
region: '{{{parametersWithDataTypeMap.region.value}}}'
{{/hasRegionalHost}}
})
{{/isSearchClient}};
3 changes: 2 additions & 1 deletion templates/javascript/tests/client/tests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('{{testType}}', () => {
{{/times}}
{{#isError}}
try {
// @ts-ignore
{{#dynamicTemplate}}{{/dynamicTemplate}}
throw new Error('test is expected to throw error');
} catch(e) {
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('{{testType}}', () => {
expect(result).toEqual("{{{match.value}}}");
{{/match.isString}}
{{^match.isString}}
expect(result).toEqual({{{match.value}}});
expect(result).toEqual({{^match.isNull}}{{{match.value}}}{{/match.isNull}}{{#match.isNull}}undefined{{/match.isNull}});
{{/match.isString}}
{{/match.isPrimitive}}
{{^match.isPrimitive}}
Expand Down
2 changes: 1 addition & 1 deletion templates/javascript/tests/e2e/e2e.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// {{generationBanner}}
import { describe, test, expect } from 'vitest';

import { union } from '../helpers';
import { union } from '../helpers.js';

import * as dotenv from 'dotenv';

Expand Down
2 changes: 1 addition & 1 deletion templates/javascript/tests/package.mustache
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "javascript-tests",
"type": "module",
"version": "1.0.0",
"scripts": {
"test": "tsc --noEmit && vitest run"
},
"dependencies": {
"algoliasearch": "link:../../../clients/algoliasearch-client-javascript/packages/algoliasearch",
"@algolia/client-common": "link:../../../clients/algoliasearch-client-javascript/packages/client-common",
"@algolia/requester-testing": "link:../../../clients/algoliasearch-client-javascript/packages/requester-testing"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions templates/javascript/tests/requests/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { describe, test, expect } from 'vitest';
import { {{{clientName}}} } from '{{{importPackage}}}';
import { nodeEchoRequester } from '@algolia/requester-testing';
import type { EchoResponse } from '@algolia/requester-testing';
import type { RequestOptions } from '@algolia/client-common';
import type { ClientOptions } from '@algolia/client-common';

const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id';
const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key';

const client = {{{clientName}}}(appId, apiKey{{#isSearchClient}}, { requester: nodeEchoRequester() }{{/isSearchClient}}){{^isSearchClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester() }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isSearchClient}};
const clientOptions: ClientOptions = { requester: nodeEchoRequester() }; // this makes sure the types are correctly exported
const client = {{{clientName}}}(appId, apiKey{{#isSearchClient}}, { requester: nodeEchoRequester() }{{/isSearchClient}}){{^isSearchClient}}.{{{initMethod}}}({ options: clientOptions, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isSearchClient}};

{{#blocksRequests}}
describe('{{operationId}}', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/output/javascript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../../config/base.tsconfig.json",
"compilerOptions": {
"typeRoots": ["../../../node_modules/@types"],
"skipLibCheck": false,
"types": ["node"],
"lib": ["dom", "esnext"]
},
Expand Down
Loading
Loading