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

[search] Migrate search projects to use snippets extraction #33265

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9760ccc
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Mar 3, 2025
4875176
Migration: Update test config
mpodwysocki Mar 3, 2025
54602bb
Migration: Clean up files
mpodwysocki Mar 3, 2025
4687214
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Mar 3, 2025
b07fb0d
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Mar 3, 2025
a5acd54
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Mar 3, 2025
26ec9e6
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Mar 3, 2025
8410e20
Migration: Apply codemod: "addViHelper"
mpodwysocki Mar 3, 2025
7041b83
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Mar 3, 2025
f80c73f
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Mar 3, 2025
dab641f
Migration: npm run format
mpodwysocki Mar 3, 2025
1d7f929
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Mar 3, 2025
5355546
Migration: Update test config
mpodwysocki Mar 3, 2025
2c122e5
Migration: Clean up files
mpodwysocki Mar 3, 2025
fbc7e9b
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Mar 3, 2025
99a4d56
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Mar 3, 2025
d8241a4
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Mar 3, 2025
2a6b63a
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Mar 3, 2025
f21ebb3
Migration: Apply codemod: "addViHelper"
mpodwysocki Mar 3, 2025
372a9fe
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Mar 3, 2025
264d96a
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Mar 3, 2025
4babbb0
Migration: npm run format
mpodwysocki Mar 3, 2025
a7e908f
[search] Migrate search projects to use snippets extraction
mpodwysocki Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 135 additions & 192 deletions sdk/search/search-documents/README.md

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions sdk/search/search-documents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"test:node": "npm run build:test && npm run unit-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest --test-proxy-debug",
"update-snippets": "echo skipped"
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "dev-tool run update-snippets"
},
"files": [
"dist/",
Expand Down Expand Up @@ -83,7 +83,7 @@
"@azure/core-client": "^1.9.2",
"@azure/core-http-compat": "^2.1.2",
"@azure/core-paging": "^1.6.2",
"@azure/core-rest-pipeline": "^1.18.0",
"@azure/core-rest-pipeline": "^1.19.0",
"@azure/core-tracing": "^1.2.0",
"@azure/core-util": "^1.11.0",
"@azure/logger": "^1.1.4",
Expand All @@ -96,17 +96,17 @@
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.5.0",
"@azure/identity": "^4.7.0",
"@azure/openai": "1.0.0-beta.12",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-istanbul": "^3.0.6",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"playwright": "^1.49.0",
"playwright": "^1.50.1",
"type-plus": "^7.6.2",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"vitest": "^3.0.6"
},
"//sampleConfiguration": {
"productName": "Azure Search Documents",
Expand All @@ -121,6 +121,7 @@
},
"type": "module",
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
Expand All @@ -133,8 +134,7 @@
"browser",
"react-native"
],
"selfLink": false,
"project": "./tsconfig.src.json"
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
Expand All @@ -156,5 +156,6 @@
"default": "./dist/commonjs/index.js"
}
}
}
},
"react-native": "./dist/react-native/index.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import {
GeographyPoint,
SearchIndexClient
} from "@azure/search-documents";
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup";
import { Hotel } from "./interfaces";

import * as dotenv from "dotenv";
dotenv.config();
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup.js";
import { Hotel } from "./interfaces.js";

import "dotenv/config";
/**
* This sample is to demonstrate the use of SearchIndexingBufferedSender.
* In this sample, the autoFlush is set to true. i.e. the user does not
Expand Down Expand Up @@ -58,7 +56,7 @@ function getDocumentsArray(size: number): Hotel[] {
return array;
}

async function main() {
async function main(): Promise<void> {
if (!endpoint || !apiKey) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import {
SearchIndexClient,
DEFAULT_FLUSH_WINDOW
} from "@azure/search-documents";
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup";
import { Hotel } from "./interfaces";

import * as dotenv from "dotenv";
dotenv.config();
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup.js";
import { Hotel } from "./interfaces.js";

import "dotenv/config";
/**
* This sample is to demonstrate the use of SearchIndexingBufferedSender.
* In this sample, the autoFlush is set to true. i.e. the user does not
Expand All @@ -30,7 +28,7 @@ const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";
const TEST_INDEX_NAME = "example-index-sample-5";

export async function main() {
export async function main(): Promise<void> {
if (!endpoint || !apiKey) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import {
GeographyPoint,
SearchIndexClient
} from "@azure/search-documents";
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup";
import { Hotel } from "./interfaces";

import * as dotenv from "dotenv";
dotenv.config();
import { createIndex, documentKeyRetriever, WAIT_TIME, delay } from "./setup.js";
import { Hotel } from "./interfaces.js";

import "dotenv/config";
/**
* This sample is to demonstrate the use of SearchIndexingBufferedSender.
* In this sample, the autoFlush is set to false. i.e. the user
Expand All @@ -27,7 +25,7 @@ const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";
const TEST_INDEX_NAME = "example-index-sample-6";

export async function main() {
export async function main(): Promise<void> {
if (!endpoint || !apiKey) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
SearchIndexerDataSourceConnection
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

import "dotenv/config";
const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";
const connectionString = process.env.CONNECTION_STRING || "";
Expand All @@ -22,7 +20,7 @@ const dataSourceConnectionName = "example-ds-connection-sample-1";
async function createDataSourceConnection(
dataSourceConnectionName: string,
client: SearchIndexerClient
) {
): Promise<void> {
console.log(`Creating DS Connection Operation`);
const dataSourceConnection: SearchIndexerDataSourceConnection = {
name: dataSourceConnectionName,
Expand All @@ -39,7 +37,7 @@ async function createDataSourceConnection(
async function getAndUpdateDataSourceConnection(
dataSourceConnectionName: string,
client: SearchIndexerClient
) {
): Promise<void> {
console.log(`Get And Update DS Connection Operation`);
const ds: SearchIndexerDataSourceConnection = await client.getDataSourceConnection(
dataSourceConnectionName
Expand All @@ -49,7 +47,7 @@ async function getAndUpdateDataSourceConnection(
await client.createOrUpdateDataSourceConnection(ds);
}

async function listDataSourceConnections(client: SearchIndexerClient) {
async function listDataSourceConnections(client: SearchIndexerClient): Promise<void> {
console.log(`List DS Connection Operation`);
const listOfDataSourceConnections: Array<SearchIndexerDataSourceConnection> = await client.listDataSourceConnections();

Expand All @@ -72,12 +70,12 @@ async function listDataSourceConnections(client: SearchIndexerClient) {
async function deleteDataSourceConnection(
dataSourceConnectionName: string,
client: SearchIndexerClient
) {
): Promise<void> {
console.log(`Deleting DS Connection Operation`);
await client.deleteDataSourceConnection(dataSourceConnectionName);
}

async function main() {
async function main(): Promise<void> {
console.log(`Running DS Connection Operations Sample....`);
if (!endpoint || !apiKey || !connectionString) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import {
SearchIndexStatistics
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

import "dotenv/config";
const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";
const indexName = "example-index-sample-1";

async function createIndex(indexName: string, client: SearchIndexClient) {
async function createIndex(indexName: string, client: SearchIndexClient): Promise<void> {
console.log(`Creating Index Operation`);
const index: SearchIndex = {
name: indexName,
Expand Down Expand Up @@ -62,7 +60,7 @@ async function createIndex(indexName: string, client: SearchIndexClient) {
await client.createIndex(index);
}

async function getAndUpdateIndex(indexName: string, client: SearchIndexClient) {
async function getAndUpdateIndex(indexName: string, client: SearchIndexClient): Promise<void> {
console.log(`Get And Update Index Operation`);
const index: SearchIndex = await client.getIndex(indexName);
index.fields.push({
Expand All @@ -73,14 +71,14 @@ async function getAndUpdateIndex(indexName: string, client: SearchIndexClient) {
await client.createOrUpdateIndex(index);
}

async function getIndexStatistics(indexName: string, client: SearchIndexClient) {
async function getIndexStatistics(indexName: string, client: SearchIndexClient): Promise<void> {
console.log(`Get Index Statistics Operation`);
const statistics: SearchIndexStatistics = await client.getIndexStatistics(indexName);
console.log(`Document Count: ${statistics.documentCount}`);
console.log(`Storage Size: ${statistics.storageSize}`);
}

async function getServiceStatistics(client: SearchIndexClient) {
async function getServiceStatistics(client: SearchIndexClient): Promise<void> {
console.log(`Get Service Statistics Operation`);
const { counters, limits } = await client.getServiceStatistics();
console.log(`Counters`);
Expand Down Expand Up @@ -116,7 +114,7 @@ async function getServiceStatistics(client: SearchIndexClient) {
);
}

async function listIndexes(client: SearchIndexClient) {
async function listIndexes(client: SearchIndexClient): Promise<void> {
console.log(`List Indexes Operation`);
const result = await client.listIndexes();
let listOfIndexes = await result.next();
Expand All @@ -132,12 +130,12 @@ async function listIndexes(client: SearchIndexClient) {
}
}

async function deleteIndex(indexName: string, client: SearchIndexClient) {
async function deleteIndex(indexName: string, client: SearchIndexClient): Promise<void> {
console.log(`Deleting Index Operation`);
await client.deleteIndex(indexName);
}

async function main() {
async function main(): Promise<void> {
console.log(`Running Index Operations Sample....`);
if (!endpoint || !apiKey) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import {
SearchIndexerStatus
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

import "dotenv/config";
const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";
const dataSourceName = process.env.DATA_SOURCE_NAME || "";
const targetIndexName = process.env.TARGET_INDEX_NAME || "";

const indexerName = "example-indexer-sample-1";

async function createIndexer(indexerName: string, client: SearchIndexerClient) {
async function createIndexer(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Creating Indexer Operation`);
const indexer: SearchIndexer = {
name: indexerName,
Expand All @@ -34,7 +32,7 @@ async function createIndexer(indexerName: string, client: SearchIndexerClient) {
await client.createIndexer(indexer);
}

async function getAndUpdateIndexer(indexerName: string, client: SearchIndexerClient) {
async function getAndUpdateIndexer(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Get And Update Indexer Operation`);
const indexer: SearchIndexer = await client.getIndexer(indexerName);
indexer.isDisabled = true;
Expand All @@ -43,7 +41,7 @@ async function getAndUpdateIndexer(indexerName: string, client: SearchIndexerCli
await client.createOrUpdateIndexer(indexer);
}

async function getIndexerStatus(indexerName: string, client: SearchIndexerClient) {
async function getIndexerStatus(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Get Indexer Status Operation`);
const indexerStatus: SearchIndexerStatus = await client.getIndexerStatus(indexerName);
console.log(`Status: ${indexerStatus.status}`);
Expand All @@ -56,7 +54,7 @@ async function getIndexerStatus(indexerName: string, client: SearchIndexerClient
console.log(`MaxRunTime: ${indexerStatus.limits.maxRunTime}`);
}

async function listIndexers(client: SearchIndexerClient) {
async function listIndexers(client: SearchIndexerClient): Promise<void> {
console.log(`List Indexers Operation`);
const listOfIndexers: Array<SearchIndexer> = await client.listIndexers();

Expand All @@ -82,22 +80,22 @@ async function listIndexers(client: SearchIndexerClient) {
}
}

async function resetIndexer(indexerName: string, client: SearchIndexerClient) {
async function resetIndexer(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Reset Indexer Operation`);
await client.resetIndexer(indexerName);
}

async function deleteIndexer(indexerName: string, client: SearchIndexerClient) {
async function deleteIndexer(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Deleting Indexer Operation`);
await client.deleteIndexer(indexerName);
}

async function runIndexer(indexerName: string, client: SearchIndexerClient) {
async function runIndexer(indexerName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Run Indexer Operation`);
await client.runIndexer(indexerName);
}

async function main() {
async function main(): Promise<void> {
console.log(`Running Indexer Operations Sample....`);
if (!endpoint || !apiKey || !dataSourceName || !targetIndexName) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { SearchIndexClient, SearchIndex, KnownAnalyzerNames } from "@azure/search-documents";
import { Hotel } from "./interfaces";
import { Hotel } from "./interfaces.js";

export const WAIT_TIME = 4000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import {
SearchIndexerSkillset
} from "@azure/search-documents";

import * as dotenv from "dotenv";
dotenv.config();

import "dotenv/config";
const endpoint = process.env.ENDPOINT || "";
const apiKey = process.env.SEARCH_API_ADMIN_KEY || "";

const skillsetName = "example-skillset-sample-1";

async function createSkillset(skillsetName: string, client: SearchIndexerClient) {
async function createSkillset(skillsetName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Creating Skillset Operation`);
const skillset: SearchIndexerSkillset = {
name: skillsetName,
Expand Down Expand Up @@ -57,7 +55,7 @@ async function createSkillset(skillsetName: string, client: SearchIndexerClient)
await client.createSkillset(skillset);
}

async function getAndUpdateSkillset(skillsetName: string, client: SearchIndexerClient) {
async function getAndUpdateSkillset(skillsetName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Get And Update Skillset Operation`);
const skillset: SearchIndexerSkillset = await client.getSkillset(skillsetName);

Expand All @@ -75,7 +73,7 @@ async function getAndUpdateSkillset(skillsetName: string, client: SearchIndexerC
await client.createOrUpdateSkillset(skillset);
}

async function listSkillsets(client: SearchIndexerClient) {
async function listSkillsets(client: SearchIndexerClient): Promise<void> {
console.log(`List Skillset Operation`);
const listOfSkillsets: Array<SearchIndexerSkillset> = await client.listSkillsets();

Expand All @@ -102,12 +100,12 @@ async function listSkillsets(client: SearchIndexerClient) {
}
}

async function deleteSkillset(skillsetName: string, client: SearchIndexerClient) {
async function deleteSkillset(skillsetName: string, client: SearchIndexerClient): Promise<void> {
console.log(`Deleting Skillset Operation`);
await client.deleteSkillset(skillsetName);
}

async function main() {
async function main(): Promise<void> {
console.log(`Running Skillset Operations Sample....`);
if (!endpoint || !apiKey) {
console.log("Make sure to set valid values for endpoint and apiKey with proper authorization.");
Expand Down
Loading
Loading