From faa72713b2d5d8ec9b8c8085a80d617d6d3de264 Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Thu, 31 Oct 2024 11:20:10 +0000 Subject: [PATCH 1/7] feat: add ai-personalization spec file --- specs/ai-personalization/common/enums.yml | 22 +++ .../common/responses/BadRequest.yml | 5 + .../common/responses/BaseResponse.yml | 8 + .../responses/ConfigurationNotFound.yml | 5 + .../common/responses/InternalServerError.yml | 5 + .../common/responses/InvalidUserID.yml | 5 + .../common/responses/Unauthorized.yml | 5 + .../common/responses/UserNotFound.yml | 5 + .../common/schemas/User.yml | 30 ++++ .../common/schemas/UsersParams.yml | 104 ++++++++++++ .../common/schemas/configuration.yml | 65 ++++++++ specs/ai-personalization/paths/config.yml | 149 ++++++++++++++++++ specs/ai-personalization/paths/user.yml | 71 +++++++++ specs/ai-personalization/paths/users.yml | 42 +++++ specs/ai-personalization/spec.yml | 116 ++++++++++++++ 15 files changed, 637 insertions(+) create mode 100644 specs/ai-personalization/common/enums.yml create mode 100644 specs/ai-personalization/common/responses/BadRequest.yml create mode 100644 specs/ai-personalization/common/responses/BaseResponse.yml create mode 100644 specs/ai-personalization/common/responses/ConfigurationNotFound.yml create mode 100644 specs/ai-personalization/common/responses/InternalServerError.yml create mode 100644 specs/ai-personalization/common/responses/InvalidUserID.yml create mode 100644 specs/ai-personalization/common/responses/Unauthorized.yml create mode 100644 specs/ai-personalization/common/responses/UserNotFound.yml create mode 100644 specs/ai-personalization/common/schemas/User.yml create mode 100644 specs/ai-personalization/common/schemas/UsersParams.yml create mode 100644 specs/ai-personalization/common/schemas/configuration.yml create mode 100644 specs/ai-personalization/paths/config.yml create mode 100644 specs/ai-personalization/paths/user.yml create mode 100644 specs/ai-personalization/paths/users.yml create mode 100644 specs/ai-personalization/spec.yml diff --git a/specs/ai-personalization/common/enums.yml b/specs/ai-personalization/common/enums.yml new file mode 100644 index 00000000000..0b7ddd249f7 --- /dev/null +++ b/specs/ai-personalization/common/enums.yml @@ -0,0 +1,22 @@ +errorCodes: + title: errorCodes + type: string + enum: + - blocked + - deleted + - no_perso_access + - all_attr_value_filtered + - missing_index + - no_events_last_30_days + - pending_pipelines + - invalid_config + +status: + title: status + type: string + enum: [pending, active, paused] + +type: + title: type + type: string + enum: [insights] diff --git a/specs/ai-personalization/common/responses/BadRequest.yml b/specs/ai-personalization/common/responses/BadRequest.yml new file mode 100644 index 00000000000..357a0146330 --- /dev/null +++ b/specs/ai-personalization/common/responses/BadRequest.yml @@ -0,0 +1,5 @@ +description: Bad request. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/responses/BaseResponse.yml b/specs/ai-personalization/common/responses/BaseResponse.yml new file mode 100644 index 00000000000..d7e894e1f81 --- /dev/null +++ b/specs/ai-personalization/common/responses/BaseResponse.yml @@ -0,0 +1,8 @@ +type: object +properties: + status: + type: integer + description: HTTP status code. + message: + type: string + description: Details about the response, such as error messages. diff --git a/specs/ai-personalization/common/responses/ConfigurationNotFound.yml b/specs/ai-personalization/common/responses/ConfigurationNotFound.yml new file mode 100644 index 00000000000..a220d45ef6f --- /dev/null +++ b/specs/ai-personalization/common/responses/ConfigurationNotFound.yml @@ -0,0 +1,5 @@ +description: Configuration not found. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/responses/InternalServerError.yml b/specs/ai-personalization/common/responses/InternalServerError.yml new file mode 100644 index 00000000000..b7561238468 --- /dev/null +++ b/specs/ai-personalization/common/responses/InternalServerError.yml @@ -0,0 +1,5 @@ +description: Internal server error. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/responses/InvalidUserID.yml b/specs/ai-personalization/common/responses/InvalidUserID.yml new file mode 100644 index 00000000000..1d0b01fb851 --- /dev/null +++ b/specs/ai-personalization/common/responses/InvalidUserID.yml @@ -0,0 +1,5 @@ +description: Invalid user ID format. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/responses/Unauthorized.yml b/specs/ai-personalization/common/responses/Unauthorized.yml new file mode 100644 index 00000000000..b1197e3c42f --- /dev/null +++ b/specs/ai-personalization/common/responses/Unauthorized.yml @@ -0,0 +1,5 @@ +description: Not authorized to access this resource. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/responses/UserNotFound.yml b/specs/ai-personalization/common/responses/UserNotFound.yml new file mode 100644 index 00000000000..d03d5e01616 --- /dev/null +++ b/specs/ai-personalization/common/responses/UserNotFound.yml @@ -0,0 +1,5 @@ +description: User not found. +content: + application/json: + schema: + $ref: './BaseResponse.yml' diff --git a/specs/ai-personalization/common/schemas/User.yml b/specs/ai-personalization/common/schemas/User.yml new file mode 100644 index 00000000000..a4d62fe7fda --- /dev/null +++ b/specs/ai-personalization/common/schemas/User.yml @@ -0,0 +1,30 @@ +user: + type: object + properties: + userID: + type: string + affinities: + type: array + items: + title: affinity + type: object + properties: + name: + type: string + indices: + type: array + items: + type: string + minimum: 1 + value: + type: string + score: + type: number + minimum: 1 + maximum: 20 + lastUpdatedAt: + type: string + required: [name, indices, value, score, lastUpdatedAt] + lastUpdatedAt: + type: string + required: [userID, affinities, lastUpdatedAt] diff --git a/specs/ai-personalization/common/schemas/UsersParams.yml b/specs/ai-personalization/common/schemas/UsersParams.yml new file mode 100644 index 00000000000..1a4b9f4cc6a --- /dev/null +++ b/specs/ai-personalization/common/schemas/UsersParams.yml @@ -0,0 +1,104 @@ +# query +startDate: + name: startDate + description: | + Filter users by start date (in RFC3339 format). + Only users that were updated after the passed date will be returned. + in: query + schema: + type: string + example: 2024-06-27T08:27:26Z + +endDate: + name: endDate + description: | + Filter users by end date (in RFC3339 format). + Only users that were updated before the passed date will be returned. + in: query + schema: + type: string + example: 2024-06-28T08:27:26Z + +indices: + name: indices + description: | + Filter users by matching indices. + If multiple indices are passed, returned users will match all indices. + in: query + schema: + type: array + items: + type: string + examples: + singleIndex: + value: [products_EN] + summary: Filter by single index + multipleIndices: + value: [products_EN, products_FR] + summary: Filter by multiple indices + style: form + explode: false + +affinity: + name: affinity + description: | + Filter users by affinity name and value. + If multiple values are passed, returned users will match all values. + in: query + schema: + type: array + items: + type: string + examples: + affinityName: + value: brand + summary: Filter by single affinity name + affinityValuePair: + value: brand:Nike + summary: Filter by single affinity name and value + multipleAffinityNames: + value: brand,color + summary: Filter by multiple affinity names + multipleAffinityValuePairs: + value: brand:Nike,color:white + summary: Filter by multiple affinity name and value pairs + +limit: + name: limit + description: | + Limit the number of users in the response. + The value of this parameter ranges from 1 to 1000. + in: query + schema: + type: integer + default: 10 + minimum: 1 + maximum: 1000 + +nextPageToken: + name: nextPageToken + description: | + Reference for the next page, when navigating forward using pagination. + Can't be used in the same request as `previousPageToken`. + in: query + schema: + type: string + +previousPageToken: + name: previousPageToken + description: | + Reference for the previous page, when navigating backward using pagination. + Can't be used in the same request as `nextPageToken`. + in: query + schema: + type: string + +# path + +userID: + name: userID + description: ID of the user. + in: path + required: true + schema: + type: string diff --git a/specs/ai-personalization/common/schemas/configuration.yml b/specs/ai-personalization/common/schemas/configuration.yml new file mode 100644 index 00000000000..bb19dd05146 --- /dev/null +++ b/specs/ai-personalization/common/schemas/configuration.yml @@ -0,0 +1,65 @@ +event: + type: object + properties: + type: + $ref: '#/type' + subtype: + $ref: '#/subtype' + name: + type: string + required: [type, name] + +events: + type: object + properties: + viewDetails: + type: array + items: + $ref: '#/event' + viewListing: + type: array + items: + $ref: '#/event' + addToCart: + type: array + items: + $ref: '#/event' + purchase: + type: array + items: + $ref: '#/event' + required: [viewDetails, viewListing, addToCart, purchase] + +issue: + type: object + description: An issue is either an 'error' or a 'warning' that is generated by the validator. + properties: + code: + type: string + index: + type: string + message: + type: string + required: [code, index, message] + +personalizationReRanking: + type: string + description: The impact that personalization has on the re-ranking of search results. + enum: [none, low, medium, high, maximum] + +profileType: + type: string + enum: [basic, predictive] + description: | + The type of user profiles to generate. + + Basic profiles are based on past behaviors, ensuring search results align with previous interests. + Predictive profiles are AI-powered profiles that predict and adapt to users' interests, ensuring search results align with evolving preferences. + +type: + type: string + enum: [view, click, conversion] + +subtype: + type: string + enum: [addToCart, purchase] diff --git a/specs/ai-personalization/paths/config.yml b/specs/ai-personalization/paths/config.yml new file mode 100644 index 00000000000..8463ef9de90 --- /dev/null +++ b/specs/ai-personalization/paths/config.yml @@ -0,0 +1,149 @@ +get: + tags: + - config + operationId: getConfig + x-acl: + - search + - browse + - recommendation + summary: Retrieve the configuration + description: Retrieves a list of configuration objects for each index. + responses: + '200': + description: OK + content: + application/json: + schema: + title: getConfigResponse + type: object + properties: + indices: + type: array + items: + title: configurationObject + type: object + properties: + index: + type: string + affinities: + type: array + items: + type: string + source: + title: source + type: object + properties: + type: + $ref: '../common/enums.yml#/type' + events: + $ref: '../common/schemas/Configuration.yml#/events' + errors: + type: array + items: + $ref: '../common/schemas/Configuration.yml#/issue' + warnings: + type: array + items: + $ref: '../common/schemas/Configuration.yml#/issue' + lastUpdatedAt: + type: string + required: + [index, affinities, source, errors, warnings, lastUpdatedAt] + personalizationReRanking: + $ref: '../common/schemas/Configuration.yml#/personalizationReRanking' + profileType: + $ref: '../common/schemas/Configuration.yml#/profileType' + status: + title: status + type: object + properties: + type: + $ref: '../common/enums.yml#/status' + errors: + type: array + items: + $ref: '../common/enums.yml#/errorCodes' + required: [indices, personalzationReRanking, profileType, status] + '401': + $ref: '../common/responses/Unauthorized.yml' + '404': + $ref: '../common/responses/ConfigurationNotFound.yml' + '500': + $ref: '../common/responses/InternalServerError.yml' + +put: + tags: + - config + operationId: putConfig + x-acl: + - search + - browse + - recommendation + summary: Update the configuration + description: | + Updates the configuration. + + The configuration is a list of configuration objects for each index. To configure AI Personalization for an index, create a new configuration object for the index. + requestBody: + required: true + content: + application/json: + schema: + title: configurationParameters + type: object + properties: + indices: + type: array + items: + title: configurationParametersObject + type: object + properties: + index: + type: string + affinities: + type: array + items: + type: string + source: + title: source + type: object + properties: + type: + $ref: '../common/enums.yml#/type' + events: + $ref: '../common/schemas/Configuration.yml#/events' + required: [type] + required: [index, affinities, source] + personalizationReRanking: + $ref: '../common/schemas/Configuration.yml#/personalizationReRanking' + profileType: + $ref: '../common/schemas/Configuration.yml#/profileType' + required: [indices, personalizationReRanking, profileType] + responses: + '200': + description: OK + content: + application/json: + schema: + title: putConfigResponse + type: object + properties: + status: + type: number + errors: + type: array + items: + $ref: '../common/schemas/Configuration.yml#/issue' + warnings: + type: array + items: + $ref: '../common/schemas/Configuration.yml#/issue' + message: + type: string + required: [status, errors, warnings, message] + '400': + $ref: '../common/responses/BadRequest.yml' + '401': + $ref: '../common/responses/Unauthorized.yml' + '500': + $ref: '../common/responses/InternalServerError.yml' diff --git a/specs/ai-personalization/paths/user.yml b/specs/ai-personalization/paths/user.yml new file mode 100644 index 00000000000..801edd57b2f --- /dev/null +++ b/specs/ai-personalization/paths/user.yml @@ -0,0 +1,71 @@ +get: + tags: + - users + operationId: getUser + x-acl: + - search + - browse + - recommendation + summary: Get a user profile + description: Retrieves a user profile. + parameters: + - $ref: '../common/schemas/UsersParams.yml#/userID' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '../common/schemas/User.yml#/user' + '400': + $ref: '../common/responses/BadRequest.yml' + '401': + $ref: '../common/responses/Unauthorized.yml' + '404': + $ref: '../common/responses/UserNotFound.yml' + '422': + $ref: '../common/responses/InvalidUserID.yml' + '500': + $ref: '../common/responses/InternalServerError.yml' + +delete: + tags: + - users + operationId: deleteUser + x-acl: + - search + - browse + - recommendation + summary: Delete a user profile + description: Deletes a user profile. + parameters: + - $ref: '../common/schemas/UsersParams.yml#/userID' + responses: + '200': + description: OK + content: + application/json: + schema: + title: deleteUserResponse + type: object + properties: + message: + type: string + status: + type: integer + userID: + type: string + deletedUntil: + type: string + deletedAt: + type: string + '400': + $ref: '../common/responses/BadRequest.yml' + '401': + $ref: '../common/responses/Unauthorized.yml' + '404': + $ref: '../common/responses/UserNotFound.yml' + '422': + $ref: '../common/responses/InvalidUserID.yml' + '500': + $ref: '../common/responses/InternalServerError.yml' diff --git a/specs/ai-personalization/paths/users.yml b/specs/ai-personalization/paths/users.yml new file mode 100644 index 00000000000..b380a988073 --- /dev/null +++ b/specs/ai-personalization/paths/users.yml @@ -0,0 +1,42 @@ +get: + tags: + - users + operationId: getUsers + x-acl: + - search + - browse + - recommendation + summary: Get a list of user profiles + description: Retrieves a list of user profiles in [lexicographical order](https://www.educative.io/answers/what-is-a-lexicographic-order). + parameters: + - $ref: '../common/schemas/UsersParams.yml#/startDate' + - $ref: '../common/schemas/UsersParams.yml#/endDate' + - $ref: '../common/schemas/UsersParams.yml#/indices' + - $ref: '../common/schemas/UsersParams.yml#/affinity' + - $ref: '../common/schemas/UsersParams.yml#/limit' + - $ref: '../common/schemas/UsersParams.yml#/nextPageToken' + - $ref: '../common/schemas/UsersParams.yml#/previousPageToken' + responses: + '200': + description: OK + content: + application/json: + schema: + title: getUsersResponse + type: object + properties: + users: + type: array + items: + $ref: '../common/schemas/User.yml#/user' + previousPageToken: + type: string + nextPageToken: + type: string + required: [users] + '400': + $ref: '../common/responses/BadRequest.yml' + '401': + $ref: '../common/responses/Unauthorized.yml' + '500': + $ref: '../common/responses/InternalServerError.yml' diff --git a/specs/ai-personalization/spec.yml b/specs/ai-personalization/spec.yml new file mode 100644 index 00000000000..d16c89ab6cb --- /dev/null +++ b/specs/ai-personalization/spec.yml @@ -0,0 +1,116 @@ +openapi: 3.1.0 +info: + title: AI Personalization API + description: | + The AI Personalization API lets you access user profiles built based on the behavior of your users on your website or app. + + ## Client libraries + + Use Algolia's API clients and libraries to reliably integrate Algolia's APIs with your apps. + The official API clients are covered by Algolia's [Service Level Agreement](https://www.algolia.com/policies/sla/). + + See: [Algolia's ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) + + ## Base URLs + + The AI Personalization API can be reached from multiple domains, each specific to a region. + + - `https://ai-personalization.eu.algolia.com` + - `https://ai-personalization.us.algolia.com` + + Use the URL that matches your [analytics region](https://dashboard.algolia.com/account/infrastructure/analytics). + + **All requests must use HTTPS.** + + ## Authentication + + To authenticate your API requests, add these headers: + + - `x-algolia-application-id`. Your Algolia application ID. + - `x-algolia-api-key`. An API key with the `search`, `browse` and `recommendation` ACL permissions. + + You can find your application ID and API key in the [Algolia dashboard](https://dashboard.algolia.com/account). + + ## Request format + + Request bodies must be JSON objects. + + ## Response status and errors + + The AI Personalization API returns JSON responses. + Since JSON doesn't guarantee any specific ordering, don't rely on the order of attributes in the API response. + + Successful responses return a `2xx` status. Client errors return a `4xx` status. Server errors are indicated by a `5xx` status. + Error responses have a `message` property with more information. + + ## Rate limiting + + When making requests to the AI Personalization API, you are limited to 500 API calls per minute per application. + + The following headers provide information about your current limit: + + - `x-ratelimit-limit`: The number of requests allowed every 60 seconds. + - `x-ratelimit-remaining`: The number of requests remaining in the current 60 second period. + - `x-ratelimit-reset`: [Unix timestamp](https://www.unixtimestamp.com/) of the next time period. + + ## Version + + The current version of the AI Personalization API is version 2, as indicated by the `/2/` in each endpoint's URL. + version: 2.0.0 +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 domain that matches the region where your Analytics data is stored and processed. If you are unsure what region your data is stored in, you can find it in the Algolia dashboard by going to Settings > General > Infrastructure > Analytics. + enum: [eu, us] + default: eu +externalDocs: + url: https://www.algolia.com/doc/guides/personalization/ai-personalization/what-is-ai-personalization/ +security: + - appId: [] + apiKey: [] +tags: + - name: config + x-displayName: Configuration + description: | + Manage your AI Personalization configuration. + + The configuration defines the indices, facet attributes and events that describe your user's + behaviour on your website or app. It helps AI Personalization determine how personalization should affect the search results. + - name: users + x-displayName: Users + description: | + Manage user profiles generated by AI Personalization. + + User profiles represent the affinities each user has for the different facets in your index. + externalDocs: + url: https://www.algolia.com/doc/guides/personalization/ai-personalization/what-is-ai-personalization/concepts/user-profiles/ + description: | + Related guide: User Profiles. +x-tagGroups: + - name: AI Personalization + tags: + - config + - users +paths: + # ###################### + # ### Custom request ### + # ###################### + /{path}: + $ref: '../common/paths/customRequest.yml' + + /2/config: + $ref: 'paths/config.yml' + + /2/users: + $ref: 'paths/users.yml' + + /2/users/{userID}: + $ref: 'paths/user.yml' From 277bf7ef072e7f7e0a5c42120b3e5d8caca9c698 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Thu, 31 Oct 2024 12:37:17 +0100 Subject: [PATCH 2/7] fix: bundle ai-personalization --- scripts/common.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/common.ts b/scripts/common.ts index 28ebc98dd8c..bc9b83ddc7d 100644 --- a/scripts/common.ts +++ b/scripts/common.ts @@ -69,7 +69,13 @@ export const GENERATORS = Object.entries(clientsConfig).reduce( export const LANGUAGES = [...new Set(Object.values(GENERATORS).map((gen) => gen.language))]; -export const CLIENTS = [...new Set(Object.values(GENERATORS).map((gen) => gen.client)), 'crawler']; +// `crawler` and `ai-personalization` are manually added so we can still bundled and validate the specs +// the entry can be removed once at least one client is generated +export const CLIENTS = [ + ...new Set(Object.values(GENERATORS).map((gen) => gen.client)), + 'crawler', + 'ai-personalization', +]; export async function run(command: string, { errorMessage, cwd, language }: RunOptions = {}): Promise { const realCwd = path.resolve(ROOT_DIR, cwd ?? '.'); From 5ef63e0d1c4542287254c7861c0ca358646e50d5 Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Thu, 31 Oct 2024 11:57:39 +0000 Subject: [PATCH 3/7] fix: issue with casing --- .../common/schemas/{configuration.yml => Configuration.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename specs/ai-personalization/common/schemas/{configuration.yml => Configuration.yml} (100%) diff --git a/specs/ai-personalization/common/schemas/configuration.yml b/specs/ai-personalization/common/schemas/Configuration.yml similarity index 100% rename from specs/ai-personalization/common/schemas/configuration.yml rename to specs/ai-personalization/common/schemas/Configuration.yml From 2ddec72324fea4aa390091d9a87a3f01b05f889f Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Fri, 1 Nov 2024 14:19:03 +0000 Subject: [PATCH 4/7] fix: prefer API description --- specs/ai-personalization/spec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/ai-personalization/spec.yml b/specs/ai-personalization/spec.yml index d16c89ab6cb..06e5c9b51bc 100644 --- a/specs/ai-personalization/spec.yml +++ b/specs/ai-personalization/spec.yml @@ -68,7 +68,7 @@ servers: variables: region: description: | - Use the domain that matches the region where your Analytics data is stored and processed. If you are unsure what region your data is stored in, you can find it in the Algolia dashboard by going to Settings > General > Infrastructure > Analytics. + Use the URL that matches your [analytics region](https://dashboard.algolia.com/account/infrastructure/analytics). enum: [eu, us] default: eu externalDocs: @@ -89,7 +89,7 @@ tags: description: | Manage user profiles generated by AI Personalization. - User profiles represent the affinities each user has for the different facets in your index. + User profiles contain the affinities each user has for the different facets in your index. externalDocs: url: https://www.algolia.com/doc/guides/personalization/ai-personalization/what-is-ai-personalization/concepts/user-profiles/ description: | From 99566f3016d9ce49a2856e1df9585090d138126f Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Fri, 1 Nov 2024 14:22:07 +0000 Subject: [PATCH 5/7] fix: future proof type --- specs/ai-personalization/common/enums.yml | 4 ++-- specs/ai-personalization/common/schemas/Configuration.yml | 4 ++-- specs/ai-personalization/paths/config.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/specs/ai-personalization/common/enums.yml b/specs/ai-personalization/common/enums.yml index 0b7ddd249f7..c904d899a23 100644 --- a/specs/ai-personalization/common/enums.yml +++ b/specs/ai-personalization/common/enums.yml @@ -10,13 +10,13 @@ errorCodes: - no_events_last_30_days - pending_pipelines - invalid_config - + status: title: status type: string enum: [pending, active, paused] -type: +sourceType: title: type type: string enum: [insights] diff --git a/specs/ai-personalization/common/schemas/Configuration.yml b/specs/ai-personalization/common/schemas/Configuration.yml index bb19dd05146..c36bab00e56 100644 --- a/specs/ai-personalization/common/schemas/Configuration.yml +++ b/specs/ai-personalization/common/schemas/Configuration.yml @@ -2,7 +2,7 @@ event: type: object properties: type: - $ref: '#/type' + $ref: '#/eventType' subtype: $ref: '#/subtype' name: @@ -56,7 +56,7 @@ profileType: Basic profiles are based on past behaviors, ensuring search results align with previous interests. Predictive profiles are AI-powered profiles that predict and adapt to users' interests, ensuring search results align with evolving preferences. -type: +eventType: type: string enum: [view, click, conversion] diff --git a/specs/ai-personalization/paths/config.yml b/specs/ai-personalization/paths/config.yml index 8463ef9de90..e53495bf993 100644 --- a/specs/ai-personalization/paths/config.yml +++ b/specs/ai-personalization/paths/config.yml @@ -34,7 +34,7 @@ get: type: object properties: type: - $ref: '../common/enums.yml#/type' + $ref: '../common/enums.yml#/sourceType' events: $ref: '../common/schemas/Configuration.yml#/events' errors: @@ -109,7 +109,7 @@ put: type: object properties: type: - $ref: '../common/enums.yml#/type' + $ref: '../common/enums.yml#/sourceType' events: $ref: '../common/schemas/Configuration.yml#/events' required: [type] From d14f3d11dbaf21c39b76e4a0638bfd472ed27620 Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Fri, 1 Nov 2024 14:26:38 +0000 Subject: [PATCH 6/7] fix: move status to Configuration.yml --- .../common/schemas/Configuration.yml | 10 ++++++++++ specs/ai-personalization/paths/config.yml | 10 +--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/specs/ai-personalization/common/schemas/Configuration.yml b/specs/ai-personalization/common/schemas/Configuration.yml index c36bab00e56..85b25becbcc 100644 --- a/specs/ai-personalization/common/schemas/Configuration.yml +++ b/specs/ai-personalization/common/schemas/Configuration.yml @@ -63,3 +63,13 @@ eventType: subtype: type: string enum: [addToCart, purchase] + +status: + type: object + properties: + type: + $ref: '../enums.yml#/status' + errors: + type: array + items: + $ref: '../enums.yml#/errorCodes' diff --git a/specs/ai-personalization/paths/config.yml b/specs/ai-personalization/paths/config.yml index e53495bf993..dd6f0c1f1ca 100644 --- a/specs/ai-personalization/paths/config.yml +++ b/specs/ai-personalization/paths/config.yml @@ -54,15 +54,7 @@ get: profileType: $ref: '../common/schemas/Configuration.yml#/profileType' status: - title: status - type: object - properties: - type: - $ref: '../common/enums.yml#/status' - errors: - type: array - items: - $ref: '../common/enums.yml#/errorCodes' + $ref: '../common/schemas/Configuration.yml#/status' required: [indices, personalzationReRanking, profileType, status] '401': $ref: '../common/responses/Unauthorized.yml' From eb456c27e8a7224f657419c9c116378e5f800c4a Mon Sep 17 00:00:00 2001 From: Adewusi Victor Date: Fri, 1 Nov 2024 14:46:22 +0000 Subject: [PATCH 7/7] fix: move config object to standalone file --- .../common/schemas/ConfigurationObject.yml | 41 ++++++++++++++++++ specs/ai-personalization/paths/config.yml | 43 +------------------ 2 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 specs/ai-personalization/common/schemas/ConfigurationObject.yml diff --git a/specs/ai-personalization/common/schemas/ConfigurationObject.yml b/specs/ai-personalization/common/schemas/ConfigurationObject.yml new file mode 100644 index 00000000000..12a04206160 --- /dev/null +++ b/specs/ai-personalization/common/schemas/ConfigurationObject.yml @@ -0,0 +1,41 @@ +configurationObject: + type: object + properties: + indices: + type: array + items: + title: configurationObject + type: object + properties: + index: + type: string + affinities: + type: array + items: + type: string + source: + title: source + type: object + properties: + type: + $ref: '../enums.yml#/sourceType' + events: + $ref: './Configuration.yml#/events' + errors: + type: array + items: + $ref: './Configuration.yml#/issue' + warnings: + type: array + items: + $ref: './Configuration.yml#/issue' + lastUpdatedAt: + type: string + required: [index, affinities, source, errors, warnings, lastUpdatedAt] + personalizationReRanking: + $ref: './Configuration.yml#/personalizationReRanking' + profileType: + $ref: './Configuration.yml#/profileType' + status: + $ref: './Configuration.yml#/status' + required: [indices, personalzationReRanking, profileType, status] diff --git a/specs/ai-personalization/paths/config.yml b/specs/ai-personalization/paths/config.yml index dd6f0c1f1ca..bed84f60230 100644 --- a/specs/ai-personalization/paths/config.yml +++ b/specs/ai-personalization/paths/config.yml @@ -14,48 +14,7 @@ get: content: application/json: schema: - title: getConfigResponse - type: object - properties: - indices: - type: array - items: - title: configurationObject - type: object - properties: - index: - type: string - affinities: - type: array - items: - type: string - source: - title: source - type: object - properties: - type: - $ref: '../common/enums.yml#/sourceType' - events: - $ref: '../common/schemas/Configuration.yml#/events' - errors: - type: array - items: - $ref: '../common/schemas/Configuration.yml#/issue' - warnings: - type: array - items: - $ref: '../common/schemas/Configuration.yml#/issue' - lastUpdatedAt: - type: string - required: - [index, affinities, source, errors, warnings, lastUpdatedAt] - personalizationReRanking: - $ref: '../common/schemas/Configuration.yml#/personalizationReRanking' - profileType: - $ref: '../common/schemas/Configuration.yml#/profileType' - status: - $ref: '../common/schemas/Configuration.yml#/status' - required: [indices, personalzationReRanking, profileType, status] + $ref: '../common/schemas/ConfigurationObject.yml#/configurationObject' '401': $ref: '../common/responses/Unauthorized.yml' '404':