Skip to content

refactor(specs): extract source object from behaviour object - #7074

Merged
ClaraMuller merged 4 commits into
mainfrom
clara/refactor/extract-sources-from-behaviour
Oct 2, 2026
Merged

ClaraMuller merged 4 commits into
mainfrom
clara/refactor/extract-sources-from-behaviour

Conversation

@ClaraMuller

@ClaraMuller ClaraMuller commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🧭 What and Why

🎟 JIRA Ticket: None

Refactors the Composition API spec's schema structure to prepare for future behaviours beyond injection / multifeed.
Groups the existing behaviours under a common behaviour/ directory, then extracts the actual source-type definitions (search, recommend, external, externalProvider) into a source/ directory as canonical, context-free base schemasm reusable by any future behaviour instead of being duplicated per context.

Changes included:

  • Move injection / multifeed schema components under a new components/behaviour/ directory (pure reorg, no schema change)
  • Extract each source type's base shape (baseSearchSource, baseRecommendSource, baseExternalSource, baseExternalProviderSource) into components/source/, deduplicating what were previously separate near-identical main / injectedItem schemas per source type

🧪 Test

CI

@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

💥 Breaking changes detected !!

Either this PR or a previous PR not released yet introduced breaking changes, be careful when merging.
You can find the details in the 'client java@21' CI job.

✔️ Code generated!

Name Link
🪓 Triggered by 4c515e9fa7cdfb1e42d089105b7843ec57141e23
🍃 Generated commit bb6cacb9b611b61f729f75bfaf059fd626815326
🌲 Generated branch generated/clara/refactor/extract-sources-from-behaviour
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
javascript 2159
go 1784
php 1576
python 1343
csharp 1302
java 1102
swift 997
ruby 844
scala 812

@ClaraMuller
ClaraMuller force-pushed the clara/refactor/extract-sources-from-behaviour branch from 7c252e6 to 562f663 Compare September 23, 2026 09:23
Base automatically changed from clara/feat/composition-api/add-external-provider-source to main September 23, 2026 16:01
@ClaraMuller
ClaraMuller force-pushed the clara/refactor/extract-sources-from-behaviour branch from 562f663 to 98700b2 Compare September 24, 2026 12:06
@ClaraMuller
ClaraMuller marked this pull request as ready for review September 24, 2026 12:15
@ClaraMuller
ClaraMuller requested a review from a team as a code owner September 24, 2026 12:15

@gavinwade12 gavinwade12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't quite understand the breaking changes message - are there actually any, and if so, are they just for java@21?

@gavinwade12
gavinwade12 requested a review from a team September 24, 2026 12:37
@ClaraMuller
ClaraMuller force-pushed the clara/refactor/extract-sources-from-behaviour branch from 98700b2 to 32f92a1 Compare September 29, 2026 09:51
@ClaraMuller

Copy link
Copy Markdown
Contributor Author

Breaking changes are the followings:

Old class (4.44.0) New class (this PR) Getter whose return type changed
MainSearch InjectionMainSearch InjectionMainSearchSource.getSearch()
MainRecommend InjectionMainRecommend InjectionMainRecommendSource.getRecommend()
Recommend InjectedItemRecommend InjectedItemRecommendSource.getRecommend()

There are little chances that customers are using it.
I am in favor of using the new ones.

type: string
description: |
Ordering to apply on the items retrieved from the external provider. 'default' uses the relevance ranking from the Algolia retrieval step. 'providerDefined' uses the ordering returned by the external provider.
enum: ['default', 'providerDefined']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should have added an alias to default. Sounds weird to call it default and then set providerDefined as default 😬

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and also userDefined is accepted between here and External source as well

@ClaraMuller ClaraMuller Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@aiordache The API client is expected to reflect the API exactely.
Does this differ from the API behaviour ?

@ben-kalmus As stated already here:

providerDefined: Uses the ordering returned by the external provider. This corresponds to the userDefined ordering for external source types.

This is coming from the RFC.
My understanding is that userDefined is not allowed in ExternalProvider source.
@aiordache can you confirm ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Had a quick look, we don't seem to have any validation on the ordering, if not set, it defaults to providerDefined: https://github.com/algolia/metis/blob/378e0c6a745f8c869a100163ca6ff4700b04ac1f/modules/services/api/internal/compositions/schema/source.go#L209

Raised a ticket to only allow default (I'd introduce here an alias algoliaDefined to make it less confusing) and providerDefined: https://algolia.atlassian.net/browse/CMP-976

@ClaraMuller
ClaraMuller enabled auto-merge (squash) October 2, 2026 11:41
@ClaraMuller
ClaraMuller merged commit 63c591d into main Oct 2, 2026
@ClaraMuller
ClaraMuller deleted the clara/refactor/extract-sources-from-behaviour branch October 2, 2026 11:52
algolia-api-clients-automation-bot Bot added a commit that referenced this pull request Oct 2, 2026
…(generated) [skip ci]

Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-csharp that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-dart that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-go that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-java that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-kotlin that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-php that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-python that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-ruby that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-scala that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
algolia-api-clients-automation-bot Bot added a commit to algolia/algoliasearch-client-swift that referenced this pull request Oct 2, 2026
algolia/api-clients-automation#7074

Co-authored-by: algolia-api-clients-automation-bot[bot] <288895823+algolia-api-clients-automation-bot[bot]@users.noreply.github.com>
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants