Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(specs): add support for widgets / banners in search for the csharp client #3870

9 changes: 7 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}

- name: Download all artifacts
Expand Down Expand Up @@ -571,12 +570,17 @@ jobs:
} >> "$GITHUB_OUTPUT"
rm -rf tests/output/**/benchmarkResult.json

- name: Extract branch name
id: extract_branch
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

- name: Push generated code
id: pushGeneratedCode
run: yarn workspace scripts pushGeneratedCode
env:
GITHUB_TOKEN: ${{ secrets.ALGOLIA_BOT_TOKEN != '' && secrets.ALGOLIA_BOT_TOKEN || secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}

- name: update generation comment
uses: marocchino/sticky-pull-request-comment@v2
Expand Down Expand Up @@ -663,8 +667,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
ref: ${{ needs.codegen.outputs.generatedCommit }}
token: ${{ secrets.ALGOLIA_BOT_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Setup
uses: ./.github/actions/setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public override bool Equals(object obj)
}

return
(FacetOrdering == input.FacetOrdering || (FacetOrdering != null && FacetOrdering.Equals(input.FacetOrdering))) &&
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect)));
(FacetOrdering == input.FacetOrdering || (FacetOrdering != null && FacetOrdering.Equals(input.FacetOrdering))) &&
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect)));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
"aroundradiusall",
"automaticfacetfilter",
"automaticfacetfilters",
"banner",
"bannerimage",
"bannerimageurl",
"bannerlink",
"banners",
"baseindexsettings",
"basesearchparams",
"basesearchparamswithoutquery",
Expand Down Expand Up @@ -109,7 +114,8 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen {
"timerange",
"typotolerance",
"typotoleranceenum",
"value"
"value",
"widgets"
);

// This is used for the CTS generation
Expand Down
14 changes: 7 additions & 7 deletions scripts/ci/codegen/pushGeneratedCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import text, { commitStartPrepareRelease } from './text.js';

async function isUpToDate(baseBranch: string): Promise<boolean> {
await run('git fetch origin');
return (await run(`git pull origin ${baseBranch}`)).includes('Already up to date.');
return (await run(`git pull origin "${baseBranch}"`)).includes('Already up to date.');
}

/**
Expand All @@ -19,7 +19,7 @@ export async function pushGeneratedCode(): Promise<void> {

await configureGitHubAuthor();

const baseBranch = await run('git branch --show-current');
const baseBranch = process.env.BRANCH_NAME || (await run('git branch --show-current'));
const isMainBranch = baseBranch === MAIN_BRANCH;
const IS_RELEASE_COMMIT = (await run('git log -1 --format="%s"')).startsWith(commitStartPrepareRelease);
console.log(`Checking codegen status on '${baseBranch}'.`);
Expand All @@ -41,10 +41,10 @@ export async function pushGeneratedCode(): Promise<void> {
const branchToPush = isMainBranch ? baseBranch : `generated/${baseBranch}`;

if (!isMainBranch) {
await run(`git push -d origin generated/${baseBranch} || true`);
await run(`git push -d origin "generated/${baseBranch}" || true`);

console.log(`Creating branch for generated code: '${branchToPush}'`);
await run(`git checkout -b ${branchToPush}`);
await run(`git checkout -b "${branchToPush}"`);
}

if (!(await isUpToDate(baseBranch))) {
Expand All @@ -55,9 +55,9 @@ export async function pushGeneratedCode(): Promise<void> {
}

const skipCi = isMainBranch ? '[skip ci]' : '';
let message = await run(`git show -s ${baseBranch} --format="%s ${text.commitEndMessage} ${skipCi}"`);
let message = await run(`git show -s "${baseBranch}" --format="%s ${text.commitEndMessage} ${skipCi}"`);
const authors = await run(
`git show -s ${baseBranch} --format="
`git show -s "${baseBranch}" --format="

Co-authored-by: %an <%ae>
%(trailers:key=Co-authored-by)"`,
Expand All @@ -73,7 +73,7 @@ Co-authored-by: %an <%ae>
console.log(`Pushing code to generated branch: '${branchToPush}'`);
await run('git add .');
await run(`git commit -m "${message}"`);
await run(`git push origin ${branchToPush}`);
await run(`git push origin "${branchToPush}"`);

setOutput('GENERATED_COMMIT', await run('git rev-parse HEAD'));
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function getNbGitDiff({

return parseInt(
(
await run(`git add -N . && git diff --shortstat ${branch}${checkHead} -- ${path} | wc -l`, {
await run(`git add -N . && git diff --shortstat "${branch}${checkHead}" -- ${path} | wc -l`, {
cwd,
})
).trim(),
Expand Down
54 changes: 54 additions & 0 deletions specs/common/schemas/IndexSettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,8 @@ renderingContent:
$ref: '#/facetOrdering'
redirect:
$ref: '#/redirectURL'
widgets:
$ref: '#/widgets'
x-categories:
- Advanced

Expand All @@ -1022,6 +1024,58 @@ facetOrdering:
values:
$ref: '#/values'

widgets:
description: widgets returned from any rules that are applied to the current search.
type: object
additionalProperties: false
properties:
banners:
$ref: '#/banners'

banners:
description: banners defined in the merchandising studio for the given search.
type: array
additionalProperties: false
properties:
banners:
$ref: '#/banner'

banner:
description: a search banner with image and url.
type: object
additionalProperties: false
properties:
image:
$ref: '#/bannerImage'
link:
$ref: '#/bannerLink'

bannerLink:
description: link for a banner defined in merchandising studio.
type: object
additionalProperties: false
properties:
url:
type: string

bannerImage:
description: image of a search banner.
type: object
additionalProperties: false
properties:
urls:
$ref: '#/bannerImageUrl'
title:
type: string

bannerImageUrl:
description: url for a search banner image.
type: array
additionalProperties: false
properties:
url:
type: string

facets:
description: Order of facet names.
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import type {
AroundRadiusAll,
AutomaticFacetFilter,
AutomaticFacetFilters,
Banner,
BannerImage,
BannerImageUrl,
BannerLink,
Banners,
BaseIndexSettings,
BaseSearchParams,
BaseSearchParamsWithoutQuery,
Expand Down Expand Up @@ -79,6 +84,7 @@ import type {
TypoTolerance,
TypoToleranceEnum,
Value,
Widgets,
} from '@algolia/client-search';
import { apiClientVersion } from '@algolia/client-search';
import type { RecommendClient } from '@algolia/recommend';
Expand All @@ -103,6 +109,11 @@ export {
AroundRadiusAll,
AutomaticFacetFilter,
AutomaticFacetFilters,
Banner,
BannerImage,
BannerImageUrl,
BannerLink,
Banners,
BaseIndexSettings,
BaseSearchParams,
BaseSearchParamsWithoutQuery,
Expand Down Expand Up @@ -170,6 +181,7 @@ export {
TypoTolerance,
TypoToleranceEnum,
Value,
Widgets,
};

/**
Expand Down
Loading