diff --git a/clients/algoliasearch-client-dart/packages/client_composition/lib/src/extension.dart b/clients/algoliasearch-client-dart/packages/client_composition/lib/src/extension.dart new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/clients/algoliasearch-client-dart/packages/client_composition/lib/src/extension.dart @@ -0,0 +1 @@ + diff --git a/clients/algoliasearch-client-dart/packages/client_realtime_personalization/build.yaml b/clients/algoliasearch-client-dart/packages/client_realtime_personalization/build.yaml new file mode 100644 index 0000000000..6d71b406a7 --- /dev/null +++ b/clients/algoliasearch-client-dart/packages/client_realtime_personalization/build.yaml @@ -0,0 +1,14 @@ +targets: + $default: + builders: + json_serializable: + options: + any_map: false + checked: true + create_factory: true + create_to_json: true + disallow_unrecognized_keys: false + explicit_to_json: true + field_rename: none + ignore_unannotated: false + include_if_null: false diff --git a/clients/algoliasearch-client-dart/packages/client_realtime_personalization/lib/src/extension.dart b/clients/algoliasearch-client-dart/packages/client_realtime_personalization/lib/src/extension.dart new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/clients/algoliasearch-client-dart/packages/client_realtime_personalization/lib/src/extension.dart @@ -0,0 +1 @@ + diff --git a/clients/algoliasearch-client-javascript/package.json b/clients/algoliasearch-client-javascript/package.json index cc2262f903..2b1210b8b7 100644 --- a/clients/algoliasearch-client-javascript/package.json +++ b/clients/algoliasearch-client-javascript/package.json @@ -7,7 +7,7 @@ "packages/*" ], "scripts": { - "build": "lerna run build --skip-nx-cache --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope 'algoliasearch' --scope '@algolia/client-composition' --scope '@algolia/composition' --include-dependencies", + "build": "lerna run build --skip-nx-cache --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope 'algoliasearch' --scope '@algolia/client-composition' --scope '@algolia/composition' --scope '@algolia/client-realtime-personalization' --include-dependencies", "clean": "lerna run clean", "release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/publish.js", "test": "lerna run test $*", diff --git a/clients/algoliasearch-client-javascript/packages/client-realtime-personalization/package.json b/clients/algoliasearch-client-javascript/packages/client-realtime-personalization/package.json new file mode 100644 index 0000000000..523419b501 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-realtime-personalization/package.json @@ -0,0 +1,68 @@ +{ + "version": "0.0.1-alpha.0", + "repository": { + "type": "git", + "url": "git+https://github.com/algolia/algoliasearch-client-javascript.git" + }, + "homepage": "https://github.com/algolia/algoliasearch-client-javascript/packages/client-realtime-personalization#readme", + "type": "module", + "license": "MIT", + "author": "Algolia", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, + "name": "@algolia/client-realtime-personalization", + "description": "JavaScript client for client-realtime-personalization", + "exports": { + ".": { + "node": { + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" + }, + "worker": { + "types": "./dist/worker.d.ts", + "default": "./dist/builds/worker.js" + }, + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" + } + }, + "./dist/builds/*": "./dist/builds/*.js" + }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", + "react-native": "./dist/builds/browser.js", + "files": [ + "dist", + "index.js", + "index.d.ts" + ], + "dependencies": { + "@algolia/client-common": "5.22.0", + "@algolia/requester-browser-xhr": "5.22.0", + "@algolia/requester-fetch": "5.22.0", + "@algolia/requester-node-http": "5.22.0" + }, + "devDependencies": { + "@arethetypeswrong/cli": "0.17.4", + "@types/node": "22.13.11", + "publint": "0.3.9", + "rollup": "4.36.0", + "tsup": "8.4.0", + "typescript": "5.7.3" + }, + "engines": { + "node": ">= 14.0.0" + } +} diff --git a/clients/algoliasearch-client-javascript/yarn.lock b/clients/algoliasearch-client-javascript/yarn.lock index 0091041bcf..c067acc5e7 100644 --- a/clients/algoliasearch-client-javascript/yarn.lock +++ b/clients/algoliasearch-client-javascript/yarn.lock @@ -122,6 +122,23 @@ __metadata: languageName: unknown linkType: soft +"@algolia/client-realtime-personalization@workspace:packages/client-realtime-personalization": + version: 0.0.0-use.local + resolution: "@algolia/client-realtime-personalization@workspace:packages/client-realtime-personalization" + dependencies: + "@algolia/client-common": "npm:5.22.0" + "@algolia/requester-browser-xhr": "npm:5.22.0" + "@algolia/requester-fetch": "npm:5.22.0" + "@algolia/requester-node-http": "npm:5.22.0" + "@arethetypeswrong/cli": "npm:0.17.4" + "@types/node": "npm:22.13.11" + publint: "npm:0.3.9" + rollup: "npm:4.36.0" + tsup: "npm:8.4.0" + typescript: "npm:5.7.3" + languageName: unknown + linkType: soft + "@algolia/client-search@npm:5.22.0, @algolia/client-search@workspace:packages/client-search": version: 0.0.0-use.local resolution: "@algolia/client-search@workspace:packages/client-search" diff --git a/config/clients.config.json b/config/clients.config.json index 276c0d0ad1..6c30364cd2 100644 --- a/config/clients.config.json +++ b/config/clients.config.json @@ -10,7 +10,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-csharp", "gitRepoId": "algoliasearch-client-csharp", @@ -48,6 +49,10 @@ { "name": "search", "output": "clients/algoliasearch-client-dart/packages/client_search" + }, + { + "name": "realtime-personalization", + "output": "clients/algoliasearch-client-dart/packages/client_realtime_personalization" } ], "folder": "clients/algoliasearch-client-dart", @@ -76,7 +81,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-go", "gitRepoId": "algoliasearch-client-go", @@ -104,7 +110,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-java", "gitRepoId": "algoliasearch-client-java", @@ -176,6 +183,10 @@ { "name": "composition-full", "output": "clients/algoliasearch-client-javascript/packages/client-composition" + }, + { + "name": "realtime-personalization", + "output": "clients/algoliasearch-client-javascript/packages/client-realtime-personalization" } ], "folder": "clients/algoliasearch-client-javascript", @@ -203,7 +214,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-kotlin", "gitRepoId": "algoliasearch-client-kotlin", @@ -231,7 +243,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-php", "gitRepoId": "algoliasearch-client-php", @@ -259,7 +272,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-python", "gitRepoId": "algoliasearch-client-python", @@ -294,7 +308,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-ruby", "gitRepoId": "algoliasearch-client-ruby", @@ -322,7 +337,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-scala", "gitRepoId": "algoliasearch-client-scala", @@ -349,7 +365,8 @@ "personalization", "query-suggestions", "recommend", - "search" + "search", + "realtime-personalization" ], "folder": "clients/algoliasearch-client-swift", "gitRepoId": "algoliasearch-client-swift", diff --git a/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java b/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java index 8e060a731c..821b9322f3 100644 --- a/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/AlgoliaGoGenerator.java @@ -28,9 +28,9 @@ public String getName() { public void processOpts() { String client = (String) additionalProperties.get("client"); - additionalProperties.put("packageName", client.equals("query-suggestions") ? "suggestions" : client); + additionalProperties.put("packageName", client.equals("query-suggestions") ? "suggestions" : Helpers.camelize(client)); additionalProperties.put("enumClassPrefix", true); - additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize((String) additionalProperties.get("client"))) + "Client", true); + additionalProperties.put("is" + Helpers.capitalize(Helpers.camelize(client)) + "Client", true); String outputFolder = "algolia" + File.separator + client; setOutputDir(getOutputDir() + File.separator + outputFolder); diff --git a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCTSGenerator.java b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCTSGenerator.java index 4df0bfa986..f5eba690c6 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCTSGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCTSGenerator.java @@ -145,7 +145,7 @@ public Map postProcessSupportingFileData(Map obj // We can put whatever we want in the bundle, and it will be accessible in the template bundle.put("mode", mode); bundle.put("is" + Helpers.capitalize(Helpers.camelize(client)) + "Client", true); - bundle.put("isStandaloneClient", client.contains("search") || client.contains("composition")); + bundle.put("isStandaloneClient", client.contains("search") || client.contains("composition") || client.contains("realtime")); bundle.put("isSearchClient", client.contains("search")); // just so algoliasearch is treated as a search client too bundle.put("client", Helpers.createClientName(importClientName, language) + "Client"); bundle.put("clientPrefix", Helpers.createClientName(importClientName, language)); diff --git a/generators/src/main/java/com/algolia/codegen/cts/manager/GoCTSManager.java b/generators/src/main/java/com/algolia/codegen/cts/manager/GoCTSManager.java index 930ed8de1c..45090a0da7 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/manager/GoCTSManager.java +++ b/generators/src/main/java/com/algolia/codegen/cts/manager/GoCTSManager.java @@ -23,11 +23,13 @@ public String getClient() { @Override public void addDataToBundle(Map bundle) throws GeneratorException { - Object clientPrefix = bundle.get("clientPrefix"); + String clientPrefix = (String) bundle.get("clientPrefix"); bundle.put("clientName", Helpers.toPascalCase(this.client)); if (clientPrefix.equals("query-suggestions")) { bundle.put("clientPrefix", "suggestions"); + } else { + bundle.put("clientPrefix", Helpers.camelize(clientPrefix)); } bundle.put("clientImport", clientPrefix); diff --git a/generators/src/main/java/com/algolia/codegen/cts/manager/JavascriptCTSManager.java b/generators/src/main/java/com/algolia/codegen/cts/manager/JavascriptCTSManager.java index 48782d2b66..6d472861f2 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/manager/JavascriptCTSManager.java +++ b/generators/src/main/java/com/algolia/codegen/cts/manager/JavascriptCTSManager.java @@ -56,6 +56,10 @@ public void addDataToBundle(Map bundle) throws GeneratorExceptio bundle.put("clientName", "compositionClient"); bundle.put("importPackage", "@algolia/client-composition"); break; + case "realtime-personalization": + bundle.put("clientName", "realtimePersonalizationClient"); + bundle.put("importPackage", "@algolia/client-realtime-personalization"); + break; case "algoliasearch": bundle.put("clientName", "liteClient"); bundle.put("importPackage", "algoliasearch/lite"); 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 7d4f63acfd..e77e1596dd 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,10 +81,15 @@ public void run(Map models, Map List blocksE2E = new ArrayList<>(); ParametersWithDataType paramsType = new ParametersWithDataType(models, language, client, false); - bundle.put("e2eAppID", client.startsWith("composition") ? "METIS_APPLICATION_ID" : "ALGOLIA_APPLICATION_ID"); + bundle.put( + "e2eAppID", + client.startsWith("composition") || client.startsWith("realtime") ? "METIS_APPLICATION_ID" : "ALGOLIA_APPLICATION_ID" + ); bundle.put( "e2eApiKey", - client.startsWith("composition") ? "METIS_API_KEY" : (client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY") + client.startsWith("composition") || client.startsWith("realtime") + ? "METIS_API_KEY" + : (client.equals("monitoring") ? "MONITORING_API_KEY" : "ALGOLIA_ADMIN_KEY") ); bundle.put("useEchoRequester", true); diff --git a/playground/javascript/node/package.json b/playground/javascript/node/package.json index 920c189572..ddd3bd3db3 100644 --- a/playground/javascript/node/package.json +++ b/playground/javascript/node/package.json @@ -14,6 +14,7 @@ "@algolia/client-insights": "link:../../../clients/algoliasearch-client-javascript/packages/client-insights", "@algolia/client-personalization": "link:../../../clients/algoliasearch-client-javascript/packages/client-personalization", "@algolia/client-query-suggestions": "link:../../../clients/algoliasearch-client-javascript/packages/client-query-suggestions", + "@algolia/client-realtime-personalization": "link:../../../clients/algoliasearch-client-javascript/packages/client-realtime-personalization", "@algolia/client-search": "link:../../../clients/algoliasearch-client-javascript/packages/client-search", "@algolia/composition": "link:../../../clients/algoliasearch-client-javascript/packages/composition", "@algolia/ingestion": "link:../../../clients/algoliasearch-client-javascript/packages/ingestion", diff --git a/playground/javascript/node/realtimePersonalization.ts b/playground/javascript/node/realtimePersonalization.ts new file mode 100644 index 0000000000..ec39d2dce3 --- /dev/null +++ b/playground/javascript/node/realtimePersonalization.ts @@ -0,0 +1,27 @@ +import { ApiError } from '@algolia/client-common'; +import { realtimePersonalizationClient } from '@algolia/client-realtime-personalization'; + +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 = realtimePersonalizationClient(appId, apiKey, 'us'); + +async function testRealtimePersonalization() { + try { + console.log(appId, apiKey); + + const resp = await client.getUser({userToken: "foo"}); + + console.log(resp); + + } catch (e) { + if (e instanceof ApiError) { + return console.log(`[${e.status}] ${e.message}`, e.stackTrace, e); + } + + console.log('[ERROR]', e); + } +} + +testRealtimePersonalization(); diff --git a/specs/realtime-personalization/common/enums.yml b/specs/realtime-personalization/common/enums.yml new file mode 100644 index 0000000000..dccbc0aca7 --- /dev/null +++ b/specs/realtime-personalization/common/enums.yml @@ -0,0 +1,6 @@ +strategy: + type: string + enum: + - session + - hybrid + example: 'session' diff --git a/specs/realtime-personalization/common/parameters.yml b/specs/realtime-personalization/common/parameters.yml new file mode 100644 index 0000000000..6e8fc3922d --- /dev/null +++ b/specs/realtime-personalization/common/parameters.yml @@ -0,0 +1,8 @@ +# path +UserToken: + name: userToken + in: path + required: true + description: Unique identifier representing a user for which to fetch the personalization profile. + schema: + $ref: '../../common/schemas/SearchParams.yml#/userToken' diff --git a/specs/realtime-personalization/common/schemas/user.yml b/specs/realtime-personalization/common/schemas/user.yml new file mode 100644 index 0000000000..bec1b795b8 --- /dev/null +++ b/specs/realtime-personalization/common/schemas/user.yml @@ -0,0 +1,44 @@ +user: + type: object + additionalProperties: false + required: + - version + - userID + - search + properties: + version: + type: string + description: Version of the response format. + userID: + type: string + description: User ID of the user. + search: + type: object + description: | + Index personalization filters by index name. + additionalProperties: + $ref: '#/searchFilters' + +searchFilters: + type: object + additionalProperties: false + properties: + indices: + type: array + items: + type: string + example: ['storefront', 'storefront_price_asc', 'storefront_price_desc'] + strategy: + $ref: '../enums.yml#/strategy' + filters: + $ref: '#/searchFilter' + +searchFilter: + type: object + additionalProperties: false + properties: + session: + type: array + items: + type: string + example: ['brand:Dyson'] diff --git a/specs/realtime-personalization/paths/getUser.yml b/specs/realtime-personalization/paths/getUser.yml new file mode 100644 index 0000000000..ca49bccba9 --- /dev/null +++ b/specs/realtime-personalization/paths/getUser.yml @@ -0,0 +1,25 @@ +get: + tags: + - users + operationId: getUser + x-acl: + - recommendation + summary: Retrieve the user's personalization profile + description: Retrieves the user's personalization profiles containing search filters. + parameters: + - $ref: '../common/parameters.yml#/UserToken' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '../common/schemas/user.yml#/user' + '400': + $ref: '../../common/responses/BadRequest.yml' + '402': + $ref: '../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../common/responses/IndexNotFound.yml' diff --git a/specs/realtime-personalization/spec.yml b/specs/realtime-personalization/spec.yml new file mode 100644 index 0000000000..533ad0ce34 --- /dev/null +++ b/specs/realtime-personalization/spec.yml @@ -0,0 +1,51 @@ +openapi: 3.0.2 +info: + title: Realtime Personalization API + description: TODO + version: 0.0.1 +externalDocs: + # TODO: Update the URL + url: https://www.algolia.com/doc/guides/personalization/what-is-personalization/ + description: | + Related guide: Algolia Realtime Personalization. +components: + securitySchemes: + appId: + $ref: '../common/securitySchemes.yml#/appId' + apiKey: + $ref: '../common/securitySchemes.yml#/apiKey' +servers: + - url: https://ai-personalization.{region}.algolia.com + variables: + region: + description: | + Use the URL that matches your [analytics region](https://dashboard.algolia.com/account/infrastructure/analytics). + enum: [eu, us] + default: eu +security: + - appId: [] + apiKey: [] +tags: + - name: users + x-displayName: Users + description: | + User profiles contains the search filters each user has for the different facets in your index. +x-tagGroups: + - name: General + tags: + - filters +paths: + # ###################### + # ### Custom request ### + # ###################### + /{path}: + $ref: '../common/paths/customRequest.yml' + + # ############### + # ### Helpers ### + # ############### + /setClientApiKey: + $ref: '../common/helpers/setClientApiKey.yml#/method' + + /2/realtime/users/{userToken}: + $ref: 'paths/getUser.yml' diff --git a/templates/dart/lib.mustache b/templates/dart/lib.mustache index 6a02bfd826..c9108ef2fe 100644 --- a/templates/dart/lib.mustache +++ b/templates/dart/lib.mustache @@ -7,6 +7,4 @@ export 'package:algolia_client_core/algolia_client_core.dart'; {{/apis}}{{/apiInfo}} {{#models}}{{#model}}export '{{sourceFolder}}/{{modelPackage}}/{{classFilename}}.dart'; {{/model}}{{/models}} -{{^isCompositionClient}} -export 'src/extension.dart'; -{{/isCompositionClient}} \ No newline at end of file +export 'src/extension.dart'; \ No newline at end of file diff --git a/templates/javascript/snippets/init.mustache b/templates/javascript/snippets/init.mustache index 62c7f55e00..9ae6c58d8a 100644 --- a/templates/javascript/snippets/init.mustache +++ b/templates/javascript/snippets/init.mustache @@ -1 +1 @@ -const client = {{{clientName}}}("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"){{^isSearchClient}}{{^isCompositionClient}}{{^isCompositionFullClient}}.{{{initMethod}}}({{#hasRegionalHost}} {region: '{{defaultRegion}}'} {{/hasRegionalHost}}){{/isCompositionFullClient}}{{/isCompositionClient}}{{/isSearchClient}}; \ No newline at end of file +const client = {{{clientName}}}("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"{{#isStandaloneClient}}{{#hasRegionalHost}}, '{{defaultRegion}}' {{/hasRegionalHost}}{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({{#hasRegionalHost}} {region: '{{defaultRegion}}'} {{/hasRegionalHost}}){{/isStandaloneClient}}; \ No newline at end of file diff --git a/templates/javascript/tests/client/client.mustache b/templates/javascript/tests/client/client.mustache index a2fbd5e209..15623b5c02 100644 --- a/templates/javascript/tests/client/client.mustache +++ b/templates/javascript/tests/client/client.mustache @@ -10,7 +10,7 @@ const appId = 'test-app-id'; const apiKey = 'test-api-key'; function createClient() { - return {{{clientName}}}(appId, apiKey{{#isStandaloneClient}}, { requester: nodeEchoRequester() }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester() }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; + return {{{clientName}}}(appId, apiKey{{#isStandaloneClient}}, {{#hasRegionalHost}}'{{{defaultRegion}}}', {{/hasRegionalHost}} { requester: nodeEchoRequester() }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester() }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; } {{#blocksClient}} @@ -20,8 +20,8 @@ function createClient() { {{^isCompositionClient}} describe('init', () => { test('sets authMode', async () => { - const qpClient = {{{clientName}}}('foo', 'bar'{{#isStandaloneClient}}, { requester: nodeEchoRequester(), authMode: 'WithinQueryParameters' }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester(), authMode: 'WithinQueryParameters' }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; - const headerClient = {{{clientName}}}('foo', 'bar'{{#isStandaloneClient}}, { requester: nodeEchoRequester(), authMode: 'WithinHeaders' }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester(), authMode: 'WithinHeaders' }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; + const qpClient = {{{clientName}}}('foo', 'bar'{{#isStandaloneClient}},{{#hasRegionalHost}}'{{{defaultRegion}}}', {{/hasRegionalHost}} { requester: nodeEchoRequester(), authMode: 'WithinQueryParameters' }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester(), authMode: 'WithinQueryParameters' }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; + const headerClient = {{{clientName}}}('foo', 'bar'{{#isStandaloneClient}},{{#hasRegionalHost}}'{{{defaultRegion}}}', {{/hasRegionalHost}} { requester: nodeEchoRequester(), authMode: 'WithinHeaders' }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: { requester: nodeEchoRequester(), authMode: 'WithinHeaders' }, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; const qpResult = (await qpClient.customGet({ path: '1/foo', diff --git a/templates/javascript/tests/client/createClient.mustache b/templates/javascript/tests/client/createClient.mustache index 3c79e0c9c4..4fdc5fa709 100644 --- a/templates/javascript/tests/client/createClient.mustache +++ b/templates/javascript/tests/client/createClient.mustache @@ -2,6 +2,7 @@ '{{parametersWithDataTypeMap.appId.value}}', '{{parametersWithDataTypeMap.apiKey.value}}' {{#isStandaloneClient}}, + {{#hasRegionalHost}}'{{{parametersWithDataTypeMap.region.value}}}', {{/hasRegionalHost}} { {{#useEchoRequester}} requester: nodeEchoRequester(), diff --git a/templates/javascript/tests/requests/requests.mustache b/templates/javascript/tests/requests/requests.mustache index 7c247fa5f6..679c8448b1 100644 --- a/templates/javascript/tests/requests/requests.mustache +++ b/templates/javascript/tests/requests/requests.mustache @@ -10,7 +10,7 @@ const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; const clientOptions: ClientOptions = { requester: nodeEchoRequester() }; // this makes sure the types are correctly exported -const client = {{{clientName}}}(appId, apiKey{{#isStandaloneClient}}, { requester: nodeEchoRequester() }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: clientOptions, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; +const client = {{{clientName}}}(appId, apiKey{{#isStandaloneClient}}, {{#hasRegionalHost}}'{{{defaultRegion}}}', {{/hasRegionalHost}} { requester: nodeEchoRequester() }{{/isStandaloneClient}}){{^isStandaloneClient}}.{{{initMethod}}}({ options: clientOptions, {{#hasRegionalHost}} region:'{{{defaultRegion}}}' {{/hasRegionalHost}} });{{/isStandaloneClient}}; {{#blocksRequests}} describe('{{operationId}}', () => { diff --git a/tests/CTS/client/realtime-personalization/api.json b/tests/CTS/client/realtime-personalization/api.json new file mode 100644 index 0000000000..77527df8f6 --- /dev/null +++ b/tests/CTS/client/realtime-personalization/api.json @@ -0,0 +1,19 @@ +[ + { + "testName": "throws when incorrect region is given", + "autoCreateClient": false, + "steps": [ + { + "type": "createClient", + "parameters": { + "appId": "my-app-id", + "apiKey": "my-api-key", + "region": "not_a_region" + }, + "expected": { + "error": "`region` is required and must be one of the following: eu, us" + } + } + ] + } +] diff --git a/tests/CTS/requests/realtime-personalization/getUser.json b/tests/CTS/requests/realtime-personalization/getUser.json new file mode 100644 index 0000000000..19b96e2e2b --- /dev/null +++ b/tests/CTS/requests/realtime-personalization/getUser.json @@ -0,0 +1,11 @@ +[ + { + "parameters": { + "userToken": "foo" + }, + "request": { + "path": "/2/realtime/users/foo", + "method": "GET" + } + } +] diff --git a/tests/output/dart/pubspec.yaml b/tests/output/dart/pubspec.yaml index bca1bd7b07..e93353bd3e 100644 --- a/tests/output/dart/pubspec.yaml +++ b/tests/output/dart/pubspec.yaml @@ -17,3 +17,4 @@ dependencies: algolia_client_core: any dev_dependencies: lints: ^4.0.0 + algolia_client_realtime_personalization: any diff --git a/tests/output/dart/pubspec_overrides.yaml b/tests/output/dart/pubspec_overrides.yaml index 8d82f4fd7a..167fe76159 100644 --- a/tests/output/dart/pubspec_overrides.yaml +++ b/tests/output/dart/pubspec_overrides.yaml @@ -11,3 +11,5 @@ dependency_overrides: path: ../../../clients/algoliasearch-client-dart/packages/client_recommend algolia_client_composition: path: ../../../clients/algoliasearch-client-dart/packages/client_composition + algolia_client_realtime_personalization: + path: ../../../clients/algoliasearch-client-dart/packages/client_realtime_personalization diff --git a/tests/output/javascript/yarn.lock b/tests/output/javascript/yarn.lock index 65bb01c0dd..d3ee02c3ad 100644 --- a/tests/output/javascript/yarn.lock +++ b/tests/output/javascript/yarn.lock @@ -397,32 +397,32 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:22.13.1": - version: 22.13.1 - resolution: "@types/node@npm:22.13.1" +"@types/node@npm:22.13.11": + version: 22.13.11 + resolution: "@types/node@npm:22.13.11" dependencies: undici-types: "npm:~6.20.0" - checksum: 10/d8ba7068b0445643c0fa6e4917cdb7a90e8756a9daff8c8a332689cd5b2eaa01e4cd07de42e3cd7e6a6f465eeda803d5a1363d00b5ab3f6cea7950350a159497 + checksum: 10/5e556eda347f3395669bd6fa7a10c77722f06befe0a6b51b97ed7a4bd0f92b24aa867ee611b547614f17dfc5a0bb7946a75263bd1f302bcac3039729d22acab5 languageName: node linkType: hard -"@vitest/expect@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/expect@npm:3.0.5" +"@vitest/expect@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/expect@npm:3.0.9" dependencies: - "@vitest/spy": "npm:3.0.5" - "@vitest/utils": "npm:3.0.5" - chai: "npm:^5.1.2" + "@vitest/spy": "npm:3.0.9" + "@vitest/utils": "npm:3.0.9" + chai: "npm:^5.2.0" tinyrainbow: "npm:^2.0.0" - checksum: 10/e9dfaed51e3a2952306fa621b4fe6c4323b367c8b731fc57d661d971628df89d1bfa163be79e4de3004d6e2e32c99b496efb8d065db6cf41d6be01dc2b833f8d + checksum: 10/09fc02ae3a639d5db23705a393ef571001f7f1006f7527529ec7807699b739788d5b54b71cb917c56379874b006f2de49933585694927b23c0d50787f96b9e94 languageName: node linkType: hard -"@vitest/mocker@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/mocker@npm:3.0.5" +"@vitest/mocker@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/mocker@npm:3.0.9" dependencies: - "@vitest/spy": "npm:3.0.5" + "@vitest/spy": "npm:3.0.9" estree-walker: "npm:^3.0.3" magic-string: "npm:^0.30.17" peerDependencies: @@ -433,66 +433,57 @@ __metadata: optional: true vite: optional: true - checksum: 10/84f3f8bbefdde91467d4bb6e5ea62227fdd86dce5567d0a2a04329033e1ed6cffe140d5b1cd58d323792d4116ba67562539d22c80910d60310eede940c94eb8b + checksum: 10/ef9e4e11e6c3f1d41884641a72298bd64e8440d2925e60ae5d5c8297a7b744ca41a8b6ab227dbcf523a82de6577ab610109ea155471fd1c722a157e59041d9dc languageName: node linkType: hard -"@vitest/pretty-format@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/pretty-format@npm:3.0.5" +"@vitest/pretty-format@npm:3.0.9, @vitest/pretty-format@npm:^3.0.9": + version: 3.0.9 + resolution: "@vitest/pretty-format@npm:3.0.9" dependencies: tinyrainbow: "npm:^2.0.0" - checksum: 10/1ffbee16e9aa2cd7862bc6b83c30b7b53031d29ddae0302d09e6b1f6bfa0e4338e5c74a2dfaeed1bab317aff300c4fd309004dbaa69baf9ebe71f6806b132e96 + checksum: 10/cfcdda2c72cf16a5e76ad2c9b014a4e36fea3988389613497cad5a2491ebc380ded4397afc95c32a2bd2734b0386996df76f6c5cbfc6be561262b8d112fb7a27 languageName: node linkType: hard -"@vitest/pretty-format@npm:^3.0.5": - version: 3.0.7 - resolution: "@vitest/pretty-format@npm:3.0.7" +"@vitest/runner@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/runner@npm:3.0.9" dependencies: - tinyrainbow: "npm:^2.0.0" - checksum: 10/700479370765a8db24403e9abda808397c137873244531f50d91c9fc6434299b416f6742e0d6512e8a0c5786dad676f17091584f3f48bfce5c2ccb7cec1f4f64 - languageName: node - linkType: hard - -"@vitest/runner@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/runner@npm:3.0.5" - dependencies: - "@vitest/utils": "npm:3.0.5" - pathe: "npm:^2.0.2" - checksum: 10/7aedf5d445aec3da83790cc94e135f64a1c407e437276694ca5a0567db055f49481b2622ab24faabb4482a1829d18dbc5cae31738b5a015669651cda8e0e7238 + "@vitest/utils": "npm:3.0.9" + pathe: "npm:^2.0.3" + checksum: 10/67036d3c5053aab8f2c7eb36c65a850cdc8dc395e5b27913417f39bfde82140eaf1c07204bda5809b8c44306fb0bedade2735c4f21026c2797fe4b562f47a812 languageName: node linkType: hard -"@vitest/snapshot@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/snapshot@npm:3.0.5" +"@vitest/snapshot@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/snapshot@npm:3.0.9" dependencies: - "@vitest/pretty-format": "npm:3.0.5" + "@vitest/pretty-format": "npm:3.0.9" magic-string: "npm:^0.30.17" - pathe: "npm:^2.0.2" - checksum: 10/3c6a3165556dc4a3fc50c9532dc047b5bf57df1bbad657ca7e34ca65e9aeb61740a0eaebe9eb6200a30d92f457a402ce3d22b21700a1763a5ec4bddf81733709 + pathe: "npm:^2.0.3" + checksum: 10/367c9390e7170b965494aff09dd69d7f678ad676d79a36c651a6237984290de53839de1a2bf5a60a6e5457a012a5f92b24298957d609705bc2d06fb5c21703aa languageName: node linkType: hard -"@vitest/spy@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/spy@npm:3.0.5" +"@vitest/spy@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/spy@npm:3.0.9" dependencies: tinyspy: "npm:^3.0.2" - checksum: 10/ed85319cd03f3f35121e84ce31721316daf94a7c01d493dff746ff5469d12e40b218cc728d57c5a71612c5a3882e8e66d9cefe82b82c2044d5f257954ec7e9d8 + checksum: 10/967b403293c9325292be4843753bf8ae516ec158df2372a14bec98c9bfb233fa6bbf76cb319cf1a9ea1b5ab795e3abff68ca66fa7523045562d7449a95ed8bf9 languageName: node linkType: hard -"@vitest/utils@npm:3.0.5": - version: 3.0.5 - resolution: "@vitest/utils@npm:3.0.5" +"@vitest/utils@npm:3.0.9": + version: 3.0.9 + resolution: "@vitest/utils@npm:3.0.9" dependencies: - "@vitest/pretty-format": "npm:3.0.5" - loupe: "npm:^3.1.2" + "@vitest/pretty-format": "npm:3.0.9" + loupe: "npm:^3.1.3" tinyrainbow: "npm:^2.0.0" - checksum: 10/4e85a7514592df63870eb4ec27c434034cc91c9e63c052bcb2304c4cc2f4fbb49350099280480313e93526247d020b42bea52436cf7f93fee0bd98cfac51a644 + checksum: 10/c77e2a4a5c62dabc57c0d27536428e6b4f9a7998b59161deb82cf797e1d6cb61a7531bef19f079c4bdca7b48fd656b48e4d1bcfb4a5bdf3c177931670a287163 languageName: node linkType: hard @@ -596,7 +587,7 @@ __metadata: languageName: node linkType: hard -"chai@npm:^5.1.2": +"chai@npm:^5.2.0": version: 5.2.0 resolution: "chai@npm:5.2.0" dependencies: @@ -991,11 +982,11 @@ __metadata: "@algolia/client-composition": "link:../../../clients/algoliasearch-client-javascript/packages/client-composition" "@algolia/composition": "link:../../../clients/algoliasearch-client-javascript/packages/composition" "@algolia/requester-testing": "link:../../../clients/algoliasearch-client-javascript/packages/requester-testing" - "@types/node": "npm:22.13.1" + "@types/node": "npm:22.13.11" algoliasearch: "link:../../../clients/algoliasearch-client-javascript/packages/algoliasearch" dotenv: "npm:16.4.7" typescript: "npm:5.7.3" - vitest: "npm:3.0.5" + vitest: "npm:3.0.9" languageName: unknown linkType: soft @@ -1006,7 +997,7 @@ __metadata: languageName: node linkType: hard -"loupe@npm:^3.1.0, loupe@npm:^3.1.2": +"loupe@npm:^3.1.0, loupe@npm:^3.1.3": version: 3.1.3 resolution: "loupe@npm:3.1.3" checksum: 10/9e98c34daf0eba48ccc603595e51f2ae002110982d84879cf78c51de2c632f0c571dfe82ce4210af60c32203d06b443465c269bda925076fe6d9b612cc65c321 @@ -1228,7 +1219,7 @@ __metadata: languageName: node linkType: hard -"pathe@npm:^2.0.2": +"pathe@npm:^2.0.3": version: 2.0.3 resolution: "pathe@npm:2.0.3" checksum: 10/01e9a69928f39087d96e1751ce7d6d50da8c39abf9a12e0ac2389c42c83bc76f78c45a475bd9026a02e6a6f79be63acc75667df855862fe567d99a00a540d23d @@ -1612,18 +1603,18 @@ __metadata: languageName: node linkType: hard -"vite-node@npm:3.0.5": - version: 3.0.5 - resolution: "vite-node@npm:3.0.5" +"vite-node@npm:3.0.9": + version: 3.0.9 + resolution: "vite-node@npm:3.0.9" dependencies: cac: "npm:^6.7.14" debug: "npm:^4.4.0" es-module-lexer: "npm:^1.6.0" - pathe: "npm:^2.0.2" + pathe: "npm:^2.0.3" vite: "npm:^5.0.0 || ^6.0.0" bin: vite-node: vite-node.mjs - checksum: 10/804d3a4a794f9fa7d5c7b433e96b0813eee39b8c0d4da5c8fe28c9a2aa226702ec711e272a66a5208944f26a35e46d931fc09b1404b04db1cf607f58af1baf6b + checksum: 10/2ea7f6d15c0776509aa4055a2dab65833d434364fd43a66c294912618867f715f48f27e1a91156045503b3169462519617fbf0d78239ebd8ea4333794dbf0a18 languageName: node linkType: hard @@ -1679,36 +1670,36 @@ __metadata: languageName: node linkType: hard -"vitest@npm:3.0.5": - version: 3.0.5 - resolution: "vitest@npm:3.0.5" +"vitest@npm:3.0.9": + version: 3.0.9 + resolution: "vitest@npm:3.0.9" dependencies: - "@vitest/expect": "npm:3.0.5" - "@vitest/mocker": "npm:3.0.5" - "@vitest/pretty-format": "npm:^3.0.5" - "@vitest/runner": "npm:3.0.5" - "@vitest/snapshot": "npm:3.0.5" - "@vitest/spy": "npm:3.0.5" - "@vitest/utils": "npm:3.0.5" - chai: "npm:^5.1.2" + "@vitest/expect": "npm:3.0.9" + "@vitest/mocker": "npm:3.0.9" + "@vitest/pretty-format": "npm:^3.0.9" + "@vitest/runner": "npm:3.0.9" + "@vitest/snapshot": "npm:3.0.9" + "@vitest/spy": "npm:3.0.9" + "@vitest/utils": "npm:3.0.9" + chai: "npm:^5.2.0" debug: "npm:^4.4.0" expect-type: "npm:^1.1.0" magic-string: "npm:^0.30.17" - pathe: "npm:^2.0.2" + pathe: "npm:^2.0.3" std-env: "npm:^3.8.0" tinybench: "npm:^2.9.0" tinyexec: "npm:^0.3.2" tinypool: "npm:^1.0.2" tinyrainbow: "npm:^2.0.0" vite: "npm:^5.0.0 || ^6.0.0" - vite-node: "npm:3.0.5" + vite-node: "npm:3.0.9" why-is-node-running: "npm:^2.3.0" peerDependencies: "@edge-runtime/vm": "*" "@types/debug": ^4.1.12 "@types/node": ^18.0.0 || ^20.0.0 || >=22.0.0 - "@vitest/browser": 3.0.5 - "@vitest/ui": 3.0.5 + "@vitest/browser": 3.0.9 + "@vitest/ui": 3.0.9 happy-dom: "*" jsdom: "*" peerDependenciesMeta: @@ -1728,7 +1719,7 @@ __metadata: optional: true bin: vitest: vitest.mjs - checksum: 10/63bf6474d314e0694489d23236a6aebd4f2173b40e47f861824668fe4b3dde5b6b95d30134acc7b1a0694c0b82b4996deb7ebc7c0ae62cb58823ff51cdcadbe1 + checksum: 10/fdecd56e6bdf145ca433c38572bf3b94adcfb59408fa140aa40d887cedc0b9d859b3f1095e1d06beef3ba9efcf7763aa9614d17fe755ebf3b2956ba0af3a067c languageName: node linkType: hard diff --git a/yarn.lock b/yarn.lock index 070d5dedea..de25895071 100644 --- a/yarn.lock +++ b/yarn.lock @@ -148,6 +148,12 @@ __metadata: languageName: node linkType: soft +"@algolia/client-realtime-personalization@link:../../../clients/algoliasearch-client-javascript/packages/client-realtime-personalization::locator=javascript-playground%40workspace%3Aplayground%2Fjavascript%2Fnode": + version: 0.0.0-use.local + resolution: "@algolia/client-realtime-personalization@link:../../../clients/algoliasearch-client-javascript/packages/client-realtime-personalization::locator=javascript-playground%40workspace%3Aplayground%2Fjavascript%2Fnode" + languageName: node + linkType: soft + "@algolia/client-search@link:../../../clients/algoliasearch-client-javascript/packages/client-search::locator=javascript-playground%40workspace%3Aplayground%2Fjavascript%2Fnode": version: 0.0.0-use.local resolution: "@algolia/client-search@link:../../../clients/algoliasearch-client-javascript/packages/client-search::locator=javascript-playground%40workspace%3Aplayground%2Fjavascript%2Fnode" @@ -5478,6 +5484,7 @@ __metadata: "@algolia/client-insights": "link:../../../clients/algoliasearch-client-javascript/packages/client-insights" "@algolia/client-personalization": "link:../../../clients/algoliasearch-client-javascript/packages/client-personalization" "@algolia/client-query-suggestions": "link:../../../clients/algoliasearch-client-javascript/packages/client-query-suggestions" + "@algolia/client-realtime-personalization": "link:../../../clients/algoliasearch-client-javascript/packages/client-realtime-personalization" "@algolia/client-search": "link:../../../clients/algoliasearch-client-javascript/packages/client-search" "@algolia/composition": "link:../../../clients/algoliasearch-client-javascript/packages/composition" "@algolia/ingestion": "link:../../../clients/algoliasearch-client-javascript/packages/ingestion"