diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e53e097694..2f0f9e2cbc 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -189,6 +189,8 @@ jobs: ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }} ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} MONITORING_API_KEY: ${{ secrets.MONITORING_API_KEY }} + METIS_APPLICATION_ID: ${{ secrets.METIS_APPLICATION_ID }} + METIS_API_KEY: ${{ secrets.METIS_API_KEY }} name: client javascript${{ needs.setup.outputs.RUN_GEN_JAVASCRIPT == 'true' && format('@{0}', fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).version) || '' }} steps: - uses: actions/checkout@v4 diff --git a/generators/src/main/java/com/algolia/codegen/cts/tests/TestsRequest.java b/generators/src/main/java/com/algolia/codegen/cts/tests/TestsRequest.java index 384f38451e..62b7869194 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/tests/TestsRequest.java +++ b/generators/src/main/java/com/algolia/codegen/cts/tests/TestsRequest.java @@ -81,7 +81,11 @@ public void run(Map models, Map List blocksE2E = new ArrayList<>(); ParametersWithDataType paramsType = new ParametersWithDataType(models, language, client, false); - bundle.put("e2eApiKey", client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY"); + bundle.put("e2eAppID", client.equals("composition") ? "METIS_APPLICATION_ID" : "ALGOLIA_APPLICATION_ID"); + bundle.put( + "e2eApiKey", + client.equals("composition") ? "METIS_API_KEY" : (client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY") + ); bundle.put("useEchoRequester", true); for (Map.Entry entry : operations.entrySet()) { diff --git a/playground/.env.example b/playground/.env.example index a7b291d2bb..4d7f6f7c62 100644 --- a/playground/.env.example +++ b/playground/.env.example @@ -10,3 +10,6 @@ SEARCH_INDEX="" SEARCH_QUERY="" ANALYTICS_INDEX="" + +METIS_APPLICATION_ID= +METIS_API_KEY= diff --git a/playground/javascript/node/algoliasearch.ts b/playground/javascript/node/algoliasearch.ts index a9e21f5e52..247699e5d5 100644 --- a/playground/javascript/node/algoliasearch.ts +++ b/playground/javascript/node/algoliasearch.ts @@ -80,7 +80,7 @@ async function testAlgoliasearch() { } try { - const analyticsClient = client.initAnalytics({region: 'de'}); + const analyticsClient = client.initAnalytics({ region: 'de' }); const res = await analyticsClient.getTopFilterForAttribute({ attribute: 'myAttribute1,myAttribute2', @@ -97,7 +97,7 @@ async function testAlgoliasearch() { } try { - const abtestingClient = client.initAbtesting({region: 'us'}); + const abtestingClient = client.initAbtesting({ region: 'us' }); const res = await abtestingClient.getABTest({ id: 42, diff --git a/playground/javascript/node/composition.ts b/playground/javascript/node/composition.ts index d9ec0f7c60..9b18a76762 100644 --- a/playground/javascript/node/composition.ts +++ b/playground/javascript/node/composition.ts @@ -1,17 +1,44 @@ import { ApiError } from '@algolia/client-common'; import { compositionClient } from '@algolia/client-composition'; -const appId = process.env.ALGOLIA_APPLICATION_ID || '**** APP_ID *****'; -const apiKey = process.env.ALGOLIA_ADMIN_KEY || '**** ADMIN_KEY *****'; +const appId = process.env.METIS_APPLICATION_ID || '**** APP_ID *****'; +const apiKey = process.env.METIS_API_KEY || '**** ADMIN_KEY *****'; // Init client with appId and apiKey const client = compositionClient(appId, apiKey); async function testComposition() { try { - const res = await client.listCompositions(); - + // create a new composition + /* + const res = await client.multipleBatch({ + requests: [ + { + action: 'upsert', + body: { + objectID: 'id1', + description: 'the first ever composition from the client', + behavior: { + injection: { + main: { + source: { + search: { + index: 'cts_e2e_small', + }, + }, + }, + }, + }, + }, + }, + ], + }); console.log(`[OK]`, res); + */ + + const compos = await client.listCompositions(); + + console.log(`[OK]`, compos); } catch (e) { if (e instanceof ApiError) { return console.log(`[${e.status}] ${e.message}`, e.stackTrace, e); diff --git a/playground/javascript/node/search.ts b/playground/javascript/node/search.ts index 26bc2a304f..054d3f470f 100644 --- a/playground/javascript/node/search.ts +++ b/playground/javascript/node/search.ts @@ -1,6 +1,5 @@ import { ApiError } from '@algolia/client-common'; -import { apiClientVersion, searchClient } from '@algolia/client-search'; -import { SearchQuery } from '@algolia/client-search'; +import { apiClientVersion, searchClient, SearchQuery } from '@algolia/client-search'; const appId = process.env.ALGOLIA_APPLICATION_ID || '**** APP_ID *****'; const apiKey = process.env.ALGOLIA_ADMIN_KEY || '**** SEARCH_API_KEY *****'; diff --git a/templates/csharp/tests/e2e/e2e.mustache b/templates/csharp/tests/e2e/e2e.mustache index 037b35631e..ad871b6cee 100644 --- a/templates/csharp/tests/e2e/e2e.mustache +++ b/templates/csharp/tests/e2e/e2e.mustache @@ -25,10 +25,10 @@ public class {{client}}RequestTestsE2E { DotEnv.Load(options: new DotEnvOptions(ignoreExceptions: true, probeForEnv: true, probeLevelsToSearch: 8, envFilePaths: new[] { ".env" })); - var appId = Environment.GetEnvironmentVariable("ALGOLIA_APPLICATION_ID"); + var appId = Environment.GetEnvironmentVariable("{{e2eAppID}}"); if (appId == null) { - throw new Exception("please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests"); + throw new Exception("please provide an `{{e2eAppID}}` env var for e2e tests"); } var apiKey = Environment.GetEnvironmentVariable("{{e2eApiKey}}"); diff --git a/templates/go/tests/e2e/e2e.mustache b/templates/go/tests/e2e/e2e.mustache index 3d413e53a4..2382998148 100644 --- a/templates/go/tests/e2e/e2e.mustache +++ b/templates/go/tests/e2e/e2e.mustache @@ -15,11 +15,11 @@ import ( func createE2E{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}Client(t *testing.T) *{{clientPrefix}}.APIClient { t.Helper() - appID := os.Getenv("ALGOLIA_APPLICATION_ID") + appID := os.Getenv("{{e2eAppID}}") if appID == "" && os.Getenv("CI") != "true" { err := godotenv.Load("../../../../.env") require.NoError(t, err) - appID = os.Getenv("ALGOLIA_APPLICATION_ID") + appID = os.Getenv("{{e2eAppID}}") } apiKey := os.Getenv("{{e2eApiKey}}") client, err := {{clientPrefix}}.NewClient(appID, apiKey, {{#hasRegionalHost}}{{clientPrefix}}.{{#lambda.uppercase}}{{defaultRegion}}{{/lambda.uppercase}},{{/hasRegionalHost}}) diff --git a/templates/java/tests/e2e/e2e.mustache b/templates/java/tests/e2e/e2e.mustache index e6c2c7ffea..2dc150c0cc 100644 --- a/templates/java/tests/e2e/e2e.mustache +++ b/templates/java/tests/e2e/e2e.mustache @@ -24,10 +24,10 @@ class {{client}}RequestsTestsE2E { this.json = JsonMapper.builder().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build(); if ("true".equals(System.getenv("CI"))) { - this.client = new {{client}}(System.getenv("ALGOLIA_APPLICATION_ID"), System.getenv("{{e2eApiKey}}"){{#hasRegionalHost}}, "{{defaultRegion}}"{{/hasRegionalHost}}); + this.client = new {{client}}(System.getenv("{{e2eAppID}}"), System.getenv("{{e2eApiKey}}"){{#hasRegionalHost}}, "{{defaultRegion}}"{{/hasRegionalHost}}); } else { Dotenv dotenv = Dotenv.configure().directory("../../").load(); - this.client = new {{client}}(dotenv.get("ALGOLIA_APPLICATION_ID"), dotenv.get("{{e2eApiKey}}"){{#hasRegionalHost}}, "{{defaultRegion}}"{{/hasRegionalHost}}); + this.client = new {{client}}(dotenv.get("{{e2eAppID}}"), dotenv.get("{{e2eApiKey}}"){{#hasRegionalHost}}, "{{defaultRegion}}"{{/hasRegionalHost}}); } } diff --git a/templates/javascript/tests/e2e/e2e.mustache b/templates/javascript/tests/e2e/e2e.mustache index 079424f392..867f8a2fd1 100644 --- a/templates/javascript/tests/e2e/e2e.mustache +++ b/templates/javascript/tests/e2e/e2e.mustache @@ -14,15 +14,15 @@ import { compositionClient } from '@algolia/client-composition'; {{/isCompositionClient}} import type { RequestOptions } from '@algolia/client-common'; -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error("please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests"); +if (!process.env.{{e2eAppID}}) { + throw new Error("please provide an `{{e2eAppID}}` env var for e2e tests"); } if (!process.env.{{e2eApiKey}}) { throw new Error("please provide an `{{e2eApiKey}}` env var for e2e tests"); } -const client = {{^isCompositionClient}}{{{clientName}}}{{/isCompositionClient}}{{#isCompositionClient}}compositionClient{{/isCompositionClient}}(process.env.ALGOLIA_APPLICATION_ID, process.env.{{e2eApiKey}}){{^isStandaloneClient}}.{{{initMethod}}}({{#hasRegionalHost}} {region:'{{{defaultRegion}}}'} {{/hasRegionalHost}}){{/isStandaloneClient}}; +const client = {{^isCompositionClient}}{{{clientName}}}{{/isCompositionClient}}{{#isCompositionClient}}compositionClient{{/isCompositionClient}}(process.env.{{e2eAppID}}, process.env.{{e2eApiKey}}){{^isStandaloneClient}}.{{{initMethod}}}({{#hasRegionalHost}} {region:'{{{defaultRegion}}}'} {{/hasRegionalHost}}){{/isStandaloneClient}}; {{#blocksE2E}} describe('{{operationId}}', () => { diff --git a/templates/kotlin/tests/e2e/e2e.mustache b/templates/kotlin/tests/e2e/e2e.mustache index b463c673e0..12a66463b4 100644 --- a/templates/kotlin/tests/e2e/e2e.mustache +++ b/templates/kotlin/tests/e2e/e2e.mustache @@ -21,10 +21,10 @@ class {{clientPrefix}}Test { init { if (System.getenv("CI") == "true") { - this.client = {{client}}(appId = System.getenv("ALGOLIA_APPLICATION_ID"), apiKey = System.getenv("{{e2eApiKey}}"){{#hasRegionalHost}}, region = "{{defaultRegion}}", {{/hasRegionalHost}}); + this.client = {{client}}(appId = System.getenv("{{e2eAppID}}"), apiKey = System.getenv("{{e2eApiKey}}"){{#hasRegionalHost}}, region = "{{defaultRegion}}", {{/hasRegionalHost}}); } else { val dotenv = Dotenv.configure().directory("../../").load() - this.client = {{client}}(appId = dotenv["ALGOLIA_APPLICATION_ID"], apiKey = dotenv["{{e2eApiKey}}"]{{#hasRegionalHost}}, region = "{{defaultRegion}}", {{/hasRegionalHost}}); + this.client = {{client}}(appId = dotenv["{{e2eAppID}}"], apiKey = dotenv["{{e2eApiKey}}"]{{#hasRegionalHost}}, region = "{{defaultRegion}}", {{/hasRegionalHost}}); } } diff --git a/templates/php/tests/e2e/e2e.mustache b/templates/php/tests/e2e/e2e.mustache index b801725c77..a7e970bc88 100644 --- a/templates/php/tests/e2e/e2e.mustache +++ b/templates/php/tests/e2e/e2e.mustache @@ -17,7 +17,7 @@ use Psr\Http\Message\RequestInterface; use Dotenv\Dotenv; // we only read .env file if we run locally -if (getenv('ALGOLIA_APPLICATION_ID')) { +if (getenv('{{e2eAppID}}')) { $_ENV = getenv(); } else { $dotenv = Dotenv::createImmutable('tests'); @@ -44,7 +44,7 @@ class {{clientPrefix}}Test extends TestCase protected function getClient(): {{client}} { - return {{client}}::create($_ENV['ALGOLIA_APPLICATION_ID'], $_ENV['{{e2eApiKey}}']{{#hasRegionalHost}},'{{defaultRegion}}' {{/hasRegionalHost}}); + return {{client}}::create($_ENV['{{e2eAppID}}'], $_ENV['{{e2eApiKey}}']{{#hasRegionalHost}},'{{defaultRegion}}' {{/hasRegionalHost}}); } {{#blocksE2E}} diff --git a/templates/python/tests/e2e/e2e.mustache b/templates/python/tests/e2e/e2e.mustache index cd71c3097f..8dfcfb7ccb 100644 --- a/templates/python/tests/e2e/e2e.mustache +++ b/templates/python/tests/e2e/e2e.mustache @@ -16,9 +16,9 @@ load_dotenv("../../.env") {{#modes}} class Test{{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}{{#isSyncClient}}Sync{{/isSyncClient}}E2E: _helpers = Helpers() - _e2e_app_id = environ.get("ALGOLIA_APPLICATION_ID") + _e2e_app_id = environ.get("{{e2eAppID}}") if _e2e_app_id is None: - raise Exception("please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests") + raise Exception("please provide an `{{e2eAppID}}` env var for e2e tests") _e2e_api_key = environ.get("{{e2eApiKey}}") if _e2e_api_key is None: diff --git a/templates/ruby/tests/e2e/e2e.mustache b/templates/ruby/tests/e2e/e2e.mustache index 5b4880740e..a3f418b7db 100644 --- a/templates/ruby/tests/e2e/e2e.mustache +++ b/templates/ruby/tests/e2e/e2e.mustache @@ -9,7 +9,7 @@ Dotenv.load('../../.env') class Test{{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}E2E < Test::Unit::TestCase def setup @client = Algolia::{{#lambda.pascalcase}}{{{client}}}{{/lambda.pascalcase}}.create( - ENV.fetch('ALGOLIA_APPLICATION_ID', nil), + ENV.fetch('{{e2eAppID}}', nil), ENV.fetch('{{e2eApiKey}}', nil){{#hasRegionalHost}}, '{{{defaultRegion}}}'{{/hasRegionalHost}} ) diff --git a/templates/scala/tests/e2e/e2e.mustache b/templates/scala/tests/e2e/e2e.mustache index cd408fc424..6bbbbf5e61 100644 --- a/templates/scala/tests/e2e/e2e.mustache +++ b/templates/scala/tests/e2e/e2e.mustache @@ -26,14 +26,14 @@ class {{clientPrefix}}TestE2E extends AnyFunSuite { {{/hasRegionalHost}} if (System.getenv("CI") == "true") { {{client}}( - appId = System.getenv("ALGOLIA_APPLICATION_ID"), + appId = System.getenv("{{e2eAppID}}"), apiKey = System.getenv("{{e2eApiKey}}"){{#hasRegionalHost}}, region = region{{/hasRegionalHost}} ) } else { val dotenv = Dotenv.configure.directory("../../").load {{client}}( - appId = dotenv.get("ALGOLIA_APPLICATION_ID"), + appId = dotenv.get("{{e2eAppID}}"), apiKey = dotenv.get("{{e2eApiKey}}"){{#hasRegionalHost}}, region = region{{/hasRegionalHost}} ) diff --git a/templates/swift/tests/e2e/e2e.mustache b/templates/swift/tests/e2e/e2e.mustache index 0d6b724cbf..ad9ef58166 100644 --- a/templates/swift/tests/e2e/e2e.mustache +++ b/templates/swift/tests/e2e/e2e.mustache @@ -35,9 +35,9 @@ final class {{client}}RequestsTestsE2E: XCTestCase { } do { - APPLICATION_ID = try XCTUnwrap(ProcessInfo.processInfo.environment["ALGOLIA_APPLICATION_ID"]) + APPLICATION_ID = try XCTUnwrap(ProcessInfo.processInfo.environment["{{e2eAppID}}"]) } catch { - XCTFail("Please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests") + XCTFail("Please provide an `{{e2eAppID}}` env var for e2e tests") } do { diff --git a/tests/.env.example b/tests/.env.example index 8a310fc4ef..3590a282a3 100644 --- a/tests/.env.example +++ b/tests/.env.example @@ -1,3 +1,7 @@ ALGOLIA_APPLICATION_ID= ALGOLIA_ADMIN_KEY= + MONITORING_API_KEY= + +METIS_APPLICATION_ID= +METIS_API_KEY= \ No newline at end of file diff --git a/tests/CTS/requests/composition/listCompositions.json b/tests/CTS/requests/composition/listCompositions.json index aeddc5c455..0fe9de7c0c 100644 --- a/tests/CTS/requests/composition/listCompositions.json +++ b/tests/CTS/requests/composition/listCompositions.json @@ -11,6 +11,29 @@ "request": { "path": "/1/compositions", "method": "GET" + }, + "response": { + "statusCode": 200, + "body": { + "items": [ + { + "objectID": "id1", + "description": "the first ever composition from the client", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "cts_e2e_small" + } + } + } + } + } + } + ], + "nbPages": 1 + } } } ]